-
-
Notifications
You must be signed in to change notification settings - Fork 175
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
Integration with 3Dconnexion input devices #1311
Conversation
There was a problem hiding this 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.
Here are the build results |
@pskowronskiTDx - any comments / concerns about the requested changes? Happy to discuss over e-mail if that's easier. Thanks! |
@ghutchis - Here is a summary of changes I did according to your review. I hope you wil be happy with them.
|
Signed-off-by: Patryk Skowroński <pskowronski@3dconnexion.com>
Signed-off-by: Patryk Skowroński <pskowronski@3dconnexion.com>
52775f9
to
d30019f
Compare
I'm traveling today, but will take a look. @cryos - do you have a moment to look as well? |
Here are the build results |
Hi Geoff, do you managed to take a look on the changes I have proposed to both PRs? Thanks. |
Can't you calculate the bounding box (or selected atom bounding) in |
Please just run |
There was a problem hiding this 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.
avogadro/rendering/camera.h
Outdated
@@ -121,6 +121,20 @@ class AVOGADRORENDERING_EXPORT Camera | |||
*/ | |||
void calculatePerspective(float fieldOfView, float zNear, float zFar); | |||
|
|||
/** | |||
* << API Extension for TDX >> |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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.
avogadro/rendering/geometryvisitor.h
Outdated
@@ -62,6 +64,22 @@ class GeometryVisitor : public Visitor | |||
*/ | |||
float radius(); | |||
|
|||
/** | |||
* <<API Extension for TDX>> |
There was a problem hiding this comment.
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.
avogadro/rendering/scene.cpp
Outdated
double& maxX, double& maxY, double& maxZ, | ||
const std::vector<bool>& flags) | ||
{ | ||
GeometryVisitor visitor; |
There was a problem hiding this comment.
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?
avogadro/rendering/scene.h
Outdated
@@ -131,10 +131,26 @@ class AVOGADRORENDERING_EXPORT Scene | |||
/** Clear the scene of all elements. */ | |||
void clear(); | |||
|
|||
/** | |||
* <<API Extension for TDX>> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this line.
avogadro/rendering/scene.h
Outdated
* @param flags [in] flags informing which atoms will be included | ||
* in the bounding box | ||
*/ | ||
void getBoundingBox(double& minX, double& minY, double& minZ, double& maxX, |
There was a problem hiding this comment.
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.)
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 |
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>
avogadro/core/molecule.cpp
Outdated
|
||
bool noSelection = true; | ||
|
||
for (uint32_t i = 0; i < m_selectedAtoms.size(); i++) { |
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
avogadro/core/molecule.cpp
Outdated
|
||
for (uint32_t i = 0; i < atomCount(); i++) { | ||
if (noSelection || m_selectedAtoms[i]) { | ||
double radius = 1.0; |
There was a problem hiding this comment.
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?
avogadro/core/molecule.cpp
Outdated
Vector3 boxMinBuffer; | ||
Vector3 boxMaxBuffer; | ||
|
||
boxMinBuffer.x() = atom(i).position3d().x() - radius; |
There was a problem hiding this comment.
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;
avogadro/core/molecule.cpp
Outdated
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; |
There was a problem hiding this comment.
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.
avogadro/core/molecule.cpp
Outdated
boxMaxBuffer.z() = atom(i).position3d().z() + radius; | ||
|
||
if (boxMinBuffer.x() < boxMin.x()) | ||
boxMin.x() = boxMinBuffer.x(); |
There was a problem hiding this comment.
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
Signed-off-by: Patryk Skowroński <pskowronski@3dconnexion.com>
Here are the build results |
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. |
Congrats on merging your first pull request! 🎉 Thanks for making Avogadro better for everyone! |
Here are the build results |
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.