Skip to content

Commit

Permalink
WIP1
Browse files Browse the repository at this point in the history
  • Loading branch information
HuguesDelorme committed Oct 14, 2024
1 parent 89b33f0 commit 47862c5
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions src/gui/gui_document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,27 +375,30 @@ Bnd_Box boundingBoxForFitAll(const GuiDocument* guiDoc)
{
Bnd_Box bndBox;

//GraphicsUtils::AisObject_isVisible(gfxObject);
auto appSelectionModel = guiDoc->guiApplication()->selectionModel();
std::vector<ApplicationItem> appItems;
for (const ApplicationItem& item : appSelectionModel->selectedItems()) {
if (item.document() == guiDoc->document())
appItems = item;
appItems.push_back(item);
}

if (appItems.empty())
appItems = ApplicationItem{guiDoc->document()};
appItems = { ApplicationItem{guiDoc->document()} };

for (const ApplicationItem& item : appItems) {
if (item.isDocument()) {
traverseTree(item.document()->modelTree(), [=](TreeNodeId nodeId) {
if (guiDoc->nodeVisibleState(nodeId) == CheckState::On) {
guiDoc->foreachGraphicsObject(nodeId, [](GraphicsObjectPtr gfxObject) {
BndUtils::add(&bndBox, GraphicsUtils::AisObject_boundingBox(gfxObject));
});
}
auto fnAddTreeNodeBndBox = [&](TreeNodeId nodeId) {
if (guiDoc->nodeVisibleState(nodeId) == CheckState::On) {
guiDoc->foreachGraphicsObject(nodeId, [&](GraphicsObjectPtr gfxObject) {
BndUtils::add(&bndBox, GraphicsUtils::AisObject_boundingBox(gfxObject));
});
}
};

for (const ApplicationItem& item : appItems) {
const Tree<TDF_Label>& modelTree = item.document()->modelTree();
if (item.isDocument())
traverseTree(modelTree, fnAddTreeNodeBndBox);
else
traverseTree(item.documentTreeNode().id(), modelTree, fnAddTreeNodeBndBox);
}

return bndBox;
Expand All @@ -405,7 +408,7 @@ void GuiDocument::setViewCameraOrientation(V3d_TypeOfOrientation projection)
{
this->runViewCameraAnimation([=](OccHandle<V3d_View> view) {
view->SetProj(projection);
view->FitAll(this->graphicsBoundingBox());
view->FitAll(boundingBoxForFitAll(this));
});
}

Expand Down Expand Up @@ -547,7 +550,7 @@ void GuiDocument::onDocumentEntityAdded(TreeNodeId entityTreeNodeId)
{
this->mapEntity(entityTreeNodeId);
BndUtils::add(&m_gfxBoundingBox, m_vecGraphicsEntity.back().bndBox);
m_v3dView->FitAll(m_gfxBoundingBox);
m_v3dView->FitAll(boundingBoxForFitAll(this));
this->signalGraphicsBoundingBoxChanged.send(m_gfxBoundingBox);
}

Expand Down

0 comments on commit 47862c5

Please sign in to comment.