Skip to content

Commit

Permalink
Add context-menu entries for viewing
Browse files Browse the repository at this point in the history
  • Loading branch information
sisakat committed May 3, 2024
1 parent b79a316 commit 7c68b13
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 5 deletions.
22 changes: 22 additions & 0 deletions app/E57TreeNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ TNodeData3D::TNodeData3D(const E57Data3DPtr& node) : TE57Node(node)
m_images = new TNodeImages();
addChild(m_images);

m_contextMenu.addAction("Open in 3D view",
[this]()
{
auto* tree =
dynamic_cast<E57Tree*>(this->treeWidget());
tree->onAction(this, NodeAction::opView3d);
});
m_contextMenu.addAction(
"Open scan panorama",
[this]()
Expand All @@ -54,6 +61,21 @@ TNodeImage2D::TNodeImage2D(const E57Image2DPtr& node) : TE57Node(node)
{
setText(0, QString::fromStdString(node->name()));
setIcon(0, QIcon(":/icons/Image.png"));

m_contextMenu.addAction("Open in 2D view",
[this]()
{
auto* tree =
dynamic_cast<E57Tree*>(this->treeWidget());
tree->onAction(this, NodeAction::opView2d);
});
m_contextMenu.addAction("Open in 3D view",
[this]()
{
auto* tree =
dynamic_cast<E57Tree*>(this->treeWidget());
tree->onAction(this, NodeAction::opView3d);
});
}

TNode* createTNode(const E57NodePtr& e57Node)
Expand Down
4 changes: 3 additions & 1 deletion app/NodeAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
enum class NodeAction
{
opScanPanorama,
opXmlDump
opXmlDump,
opView3d,
opView2d
};

#endif // E57INSPECTOR_NODEACTION_H
30 changes: 26 additions & 4 deletions app/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ void MainWindow::twMain_onAction(const TNode* node, NodeAction action)
showXMLDump();
}
}

if (dynamic_cast<const TNodeData3D*>(node) != nullptr)
{
const auto* data3DNode = dynamic_cast<const TNodeData3D*>(node);
Expand All @@ -340,6 +341,30 @@ void MainWindow::twMain_onAction(const TNode* node, NodeAction action)
connect(thread, &QThread::finished, thread, &QThread::deleteLater);
thread->start();
}
else if (action == NodeAction::opView3d)
{
auto e57Data3D =
std::dynamic_pointer_cast<E57Data3D>(data3DNode->node());
if (e57Data3D->data().contains("points"))
{
sceneView_itemDropped(nullptr, ui->twMain);
}
}
}

if (dynamic_cast<const TNodeImage2D*>(node) != nullptr)
{
const auto* dataImage2D = dynamic_cast<const TNodeImage2D*>(node);
if (action == NodeAction::opView2d)
{
auto e57Image2D =
std::dynamic_pointer_cast<E57Image2D>(dataImage2D->node());
openImage(*e57Image2D, e57Image2D->name());
}
else if (action == NodeAction::opView3d)
{
sceneView_itemDropped(nullptr, ui->twMain);
}
}
}

Expand Down Expand Up @@ -641,10 +666,7 @@ void MainWindow::dropEvent(QDropEvent* event)
}
}

void MainWindow::closeEvent(QCloseEvent* event)
{

}
void MainWindow::closeEvent(QCloseEvent* event) {}

SceneView* MainWindow::createSceneView(const std::string& name)
{
Expand Down

0 comments on commit 7c68b13

Please sign in to comment.