Skip to content

Commit

Permalink
WIP0
Browse files Browse the repository at this point in the history
  • Loading branch information
HuguesDelorme committed Sep 20, 2024
1 parent 9791ed5 commit 89b33f0
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/app/widget_gui_document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ WidgetGuiDocument::WidgetGuiDocument(GuiDocument* guiDoc, QWidget* parent)
m_qtOccView->redraw();
});
QObject::connect(m_btnFitAll, &ButtonFlat::clicked, this, [=]{
m_guiDoc->runViewCameraAnimation(&GraphicsUtils::V3dView_fitAll);
m_guiDoc->runViewCameraAnimation([=](OccHandle<V3d_View> view) {
view->FitAll(this->guiDocument()->graphicsBoundingBox());
});
});
QObject::connect(
m_btnGrid, &ButtonFlat::checked,
Expand Down
35 changes: 33 additions & 2 deletions src/gui/gui_document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ GuiDocument::GuiDocument(const DocumentPtr& doc, GuiApplication* guiApp)
for (int i = 0; i < doc->entityCount(); ++i)
this->mapEntity(doc->entityTreeNodeId(i));


doc->signalEntityAdded.connectSlot(&GuiDocument::onDocumentEntityAdded, this);
doc->signalEntityAboutToBeDestroyed.connectSlot(&GuiDocument::onDocumentEntityAboutToBeDestroyed, this);
m_gfxScene.signalSelectionChanged.connectSlot(&GuiDocument::onGraphicsSelectionChanged, this);
Expand Down Expand Up @@ -370,11 +371,41 @@ bool GuiDocument::processAction(const GraphicsOwnerPtr& gfxOwner)
return false;
}

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;
}

if (appItems.empty())
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));
});
}
});
}
}

return bndBox;
}

void GuiDocument::setViewCameraOrientation(V3d_TypeOfOrientation projection)
{
this->runViewCameraAnimation([=](OccHandle<V3d_View> view) {
view->SetProj(projection);
GraphicsUtils::V3dView_fitAll(view);
view->FitAll(this->graphicsBoundingBox());
});
}

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

Expand Down Expand Up @@ -642,7 +674,6 @@ void GuiDocument::mapEntity(TreeNodeId entityTreeNodeId)
m_mapTreeNodeCheckState.insert({ id, CheckState::On });
});

GraphicsUtils::V3dView_fitAll(m_v3dView);
m_vecGraphicsEntity.push_back(std::move(gfxEntity));
}

Expand Down

0 comments on commit 89b33f0

Please sign in to comment.