Skip to content

Commit

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

// Retrieve the application items being selected and visible
auto appSelectionModel = guiDoc->guiApplication()->selectionModel();
std::vector<ApplicationItem> appItems;
for (const ApplicationItem& item : appSelectionModel->selectedItems()) {
if (item.document() == guiDoc->document())
appItems.push_back(item);
if (item.document() == guiDoc->document()) {
if (item.isDocument()) {
appItems.push_back(item);
}
else if (item.isDocumentTreeNode()) {
const TreeNodeId nodeId = item.documentTreeNode().id();
if (guiDoc->nodeVisibleState(nodeId) == CheckState::On)
appItems.push_back(item);
}
}
}

// If no application items selected(and visible), then take the whole document
if (appItems.empty())
appItems = { ApplicationItem{guiDoc->document()} };

// Helper function to extend main bounding box with each visible graphics object inside tree node
auto fnAddTreeNodeBndBox = [&](TreeNodeId nodeId) {
if (guiDoc->nodeVisibleState(nodeId) == CheckState::On) {
guiDoc->foreachGraphicsObject(nodeId, [&](GraphicsObjectPtr gfxObject) {
Expand All @@ -393,6 +404,7 @@ Bnd_Box boundingBoxForFitAll(const GuiDocument* guiDoc)
}
};

// Iterate over application items to compute main bounding box
for (const ApplicationItem& item : appItems) {
const Tree<TDF_Label>& modelTree = item.document()->modelTree();
if (item.isDocument())
Expand Down

0 comments on commit 1cb7ef5

Please sign in to comment.