Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration with 3Dconnexion input devices #1311

Merged
merged 5 commits into from
Aug 10, 2023

Conversation

pskowronskiTDx
Copy link

Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.

Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file.

I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.

Copy link
Member

@ghutchis ghutchis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, these seem reasonable. I'd much, much rather see new API methods and implementations in their associated files than a tdxextensions.cpp with some miscellaneous methods that belong elsewhere.

The main ifdef pieces I'd want to see are relative to drawing icons, etc.

avogadro/rendering/camera.cpp Outdated Show resolved Hide resolved
avogadro/rendering/camera.h Outdated Show resolved Hide resolved
avogadro/rendering/geometryvisitor.cpp Outdated Show resolved Hide resolved
avogadro/rendering/geometryvisitor.cpp Show resolved Hide resolved
avogadro/rendering/geometryvisitor.h Outdated Show resolved Hide resolved
avogadro/rendering/geometryvisitor.h Outdated Show resolved Hide resolved
avogadro/rendering/glrenderer.cpp Outdated Show resolved Hide resolved
avogadro/rendering/glrenderer.cpp Outdated Show resolved Hide resolved
avogadro/rendering/scene.h Outdated Show resolved Hide resolved
avogadro/rendering/tdxextensions.cpp Outdated Show resolved Hide resolved
@github-actions
Copy link
Contributor

Here are the build results
Avogadro2.AppImage
macOS.dmg
Ubuntu-Latest.tar.gz
Win64.exe
Artifacts will only be retained for 90 days.

@ghutchis
Copy link
Member

@pskowronskiTDx - any comments / concerns about the requested changes? Happy to discuss over e-mail if that's easier. Thanks!

@pskowronskiTDx
Copy link
Author

pskowronskiTDx commented Jul 5, 2023

@ghutchis - Here is a summary of changes I did according to your review. I hope you wil be happy with them.

  • The definitions of new methods have been putted back to relevant source files, tdxextensions.cpp has been removed.
  • The #ifdef conditions got removed for Scene, Camera and GLRenderer (except for part responsible for drawing the 3Dx icon) classes.
  • Saving the geometry got reduced to spheres. The point of doing so is to access the current collection of the spheres visible on scene. It is needed to calculate bounding box of the whole molecule or it's part consisting of selected atoms. I couldn't come up with more efficient solution to this problem so far. Maybe there is another approach you can suggest to follow?
  • Sources were cleaned-up of whitespace changes and unnecessary includes.

Patryk Skowroński added 2 commits July 5, 2023 12:56
Signed-off-by: Patryk Skowroński <pskowronski@3dconnexion.com>
Signed-off-by: Patryk Skowroński <pskowronski@3dconnexion.com>
@ghutchis
Copy link
Member

ghutchis commented Jul 5, 2023

I'm traveling today, but will take a look. @cryos - do you have a moment to look as well?

@github-actions
Copy link
Contributor

github-actions bot commented Jul 5, 2023

Here are the build results
Avogadro2.AppImage
macOS.dmg
Ubuntu-Latest.tar.gz
Win64.exe
Artifacts will only be retained for 90 days.

@pskowronskiTDx
Copy link
Author

Hi Geoff, do you managed to take a look on the changes I have proposed to both PRs? Thanks.

@ghutchis
Copy link
Member

  • Saving the geometry got reduced to spheres. The point of doing so is to access the current collection of the spheres visible on scene. It is needed to calculate bounding box of the whole molecule or it's part consisting of selected atoms. I couldn't come up with more efficient solution to this problem so far. Maybe there is another approach you can suggest to follow?

Can't you calculate the bounding box (or selected atom bounding) in core/molecule.* or qtgui/molecule.* instead? There are a few places that use similar code.

@ghutchis
Copy link
Member

Please just run clang-format on your modified files, thanks.

Copy link
Member

@ghutchis ghutchis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks much better, but please avoid using "API Extension" comments, which aren't needed and let's consider putting the bounding box into the Molecule class instead.

@@ -121,6 +121,20 @@ class AVOGADRORENDERING_EXPORT Camera
*/
void calculatePerspective(float fieldOfView, float zNear, float zFar);

/**
* << API Extension for TDX >>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please omit this. You may have added it, but there's plenty of reason to use this in other code.

@@ -187,4 +189,55 @@ void GeometryVisitor::average()
}
}

void GeometryVisitor::boundingBox(double& minX, double& minY, double& minZ,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I mentioned, it seems easier to put this into core/molecule.*. If there's some reason you can't access the Molecule class, this is okay.

@@ -62,6 +64,22 @@ class GeometryVisitor : public Visitor
*/
float radius();

/**
* <<API Extension for TDX>>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, please omit "API Extension." I'm more than happy to provide credit / acknowledgement for your work and TDX, but we don't need to clutter the documentation with who wrote particular methods.

double& maxX, double& maxY, double& maxZ,
const std::vector<bool>& flags)
{
GeometryVisitor visitor;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above - does this need to be in the Scene class?

@@ -131,10 +131,26 @@ class AVOGADRORENDERING_EXPORT Scene
/** Clear the scene of all elements. */
void clear();

/**
* <<API Extension for TDX>>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this line.

* @param flags [in] flags informing which atoms will be included
* in the bounding box
*/
void getBoundingBox(double& minX, double& minY, double& minZ, double& maxX,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, I think it would be easier to access the bounding box directly from the molecule (which could adjust as needed for isosurface meshes, etc.)

@cryos
Copy link
Member

cryos commented Jul 27, 2023

I have been really busy the last month, sorry. I can take a look, you covered a lot of my initial concerns with comments and where the additional API is best placed @ghutchis

@pskowronskiTDx
Copy link
Author

Thank you for advicing to move bounding box calculation to the Molecule class. Indeed, this is much more elegant. I have also removed mentioned lines from comments. Clang-format was applied on my code, but I can see there are still some issues...

Signed-off-by: Patryk Skowroński <pskowronski@3dconnexion.com>

bool noSelection = true;

for (uint32_t i = 0; i < m_selectedAtoms.size(); i++) {
Copy link
Member

@ghutchis ghutchis Aug 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For what it's worth, you can get this from isSelectionEmpty() but it's not a big deal either way.

Copy link
Member

@ghutchis ghutchis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all looks great .. just some minor nitpicks in the bounding box.


for (uint32_t i = 0; i < atomCount(); i++) {
if (noSelection || m_selectedAtoms[i]) {
double radius = 1.0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems small. I'd suggest adding it as a parameter with a default of 1.0?

Vector3 boxMinBuffer;
Vector3 boxMaxBuffer;

boxMinBuffer.x() = atom(i).position3d().x() - radius;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

boxMinBuffer = atom(i).position3d().array() - radius;

https://stackoverflow.com/a/35693493/131896

boxMinBuffer.x() = atom(i).position3d().x() - radius;
boxMinBuffer.y() = atom(i).position3d().y() - radius;
boxMinBuffer.z() = atom(i).position3d().z() - radius;
boxMaxBuffer.x() = atom(i).position3d().x() + radius;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

boxMaxBuffer = atom(i).position3d().array() + radius;

This way Eigen will properly perform an element-wide operation.

boxMaxBuffer.z() = atom(i).position3d().z() + radius;

if (boxMinBuffer.x() < boxMin.x())
boxMin.x() = boxMinBuffer.x();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

boxMin.x() = min(boxMin.x(), boxMinBuffer.x());

etc. .. which is more readable, since the library handles the conditional

avogadro/core/molecule.h Outdated Show resolved Hide resolved
Signed-off-by: Patryk Skowroński <pskowronski@3dconnexion.com>
@github-actions
Copy link
Contributor

Here are the build results
Avogadro2.AppImage
macOS.dmg
Ubuntu-Latest.tar.gz
Win64.exe
Artifacts will only be retained for 90 days.

@ghutchis ghutchis added the enhancement feature changes / API changes label Aug 10, 2023
@ghutchis
Copy link
Member

Looks good to me - I'll re-run clang-format when I get a chance. Thanks for sticking with this, I'll turn on the flag for Windows and Mac builds.

@ghutchis ghutchis merged commit b5239fe into OpenChemistry:master Aug 10, 2023
@welcome
Copy link

welcome bot commented Aug 10, 2023

Congrats on merging your first pull request! 🎉 Thanks for making Avogadro better for everyone!

@github-actions
Copy link
Contributor

Here are the build results
Avogadro2.AppImage
macOS.dmg
Ubuntu-Latest.tar.gz
Win64.exe
Artifacts will only be retained for 90 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement feature changes / API changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants