-
-
Notifications
You must be signed in to change notification settings - Fork 186
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
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,9 +46,9 @@ Molecule::Molecule(const Molecule& other) | |
m_meshes(std::vector<Mesh*>()), m_cubes(std::vector<Cube*>()), | ||
m_basisSet(other.m_basisSet ? other.m_basisSet->clone() : nullptr), | ||
m_unitCell(other.m_unitCell ? new UnitCell(*other.m_unitCell) : nullptr), | ||
m_residues(other.m_residues), | ||
m_hallNumber(other.m_hallNumber), m_graph(other.m_graph), | ||
m_bondOrders(other.m_bondOrders), m_atomicNumbers(other.m_atomicNumbers), | ||
m_residues(other.m_residues), m_hallNumber(other.m_hallNumber), | ||
m_graph(other.m_graph), m_bondOrders(other.m_bondOrders), | ||
m_atomicNumbers(other.m_atomicNumbers), | ||
m_layers(LayerManager::getMoleculeLayer(this)) | ||
{ | ||
// Copy over any meshes | ||
|
@@ -88,8 +88,8 @@ Molecule::Molecule(Molecule&& other) noexcept | |
m_selectedAtoms(std::move(other.m_selectedAtoms)), | ||
m_meshes(std::move(other.m_meshes)), m_cubes(std::move(other.m_cubes)), | ||
m_residues(other.m_residues), m_hallNumber(other.m_hallNumber), | ||
m_graph(other.m_graph), | ||
m_bondOrders(other.m_bondOrders), m_atomicNumbers(other.m_atomicNumbers), | ||
m_graph(other.m_graph), m_bondOrders(other.m_bondOrders), | ||
m_atomicNumbers(other.m_atomicNumbers), | ||
m_layers(LayerManager::getMoleculeLayer(this)) | ||
{ | ||
m_basisSet = other.m_basisSet; | ||
|
@@ -1324,4 +1324,53 @@ std::list<Index> Molecule::getAtomsAtLayer(size_t layer) | |
return result; | ||
} | ||
|
||
void Molecule::boundingBox(Vector3& boxMin, Vector3& boxMax) const | ||
{ | ||
boxMin.setConstant(std::numeric_limits<double>::max()); | ||
boxMax.setConstant(-std::numeric_limits<double>::max()); | ||
|
||
bool noSelection = true; | ||
|
||
for (uint32_t i = 0; i < m_selectedAtoms.size(); i++) { | ||
if (m_selectedAtoms[i]) { | ||
noSelection = false; | ||
break; | ||
} | ||
} | ||
|
||
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 commentThe 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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. boxMinBuffer = atom(i).position3d().array() - 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 commentThe 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.y() = atom(i).position3d().y() + radius; | ||
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 commentThe 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 |
||
|
||
if (boxMinBuffer.y() < boxMin.y()) | ||
boxMin.y() = boxMinBuffer.y(); | ||
|
||
if (boxMinBuffer.z() < boxMin.z()) | ||
boxMin.z() = boxMinBuffer.z(); | ||
|
||
if (boxMaxBuffer.x() > boxMax.x()) | ||
boxMax.x() = boxMaxBuffer.x(); | ||
|
||
if (boxMaxBuffer.y() > boxMax.y()) | ||
boxMax.y() = boxMaxBuffer.y(); | ||
|
||
if (boxMaxBuffer.z() > boxMax.z()) | ||
boxMax.z() = boxMaxBuffer.z(); | ||
} | ||
} | ||
} | ||
|
||
} // namespace Avogadro::Core |
pskowronskiTDx marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,4 +53,4 @@ void Scene::clear() | |
m_dirty = true; | ||
} | ||
|
||
} // End Avogadro namespace | ||
} // namespace Avogadro::Rendering |
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.