diff --git a/app/E57TreeNode.cpp b/app/E57TreeNode.cpp index e62a1f8..cc321b1 100644 --- a/app/E57TreeNode.cpp +++ b/app/E57TreeNode.cpp @@ -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(this->treeWidget()); + tree->onAction(this, NodeAction::opView3d); + }); m_contextMenu.addAction( "Open scan panorama", [this]() @@ -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(this->treeWidget()); + tree->onAction(this, NodeAction::opView2d); + }); + m_contextMenu.addAction("Open in 3D view", + [this]() + { + auto* tree = + dynamic_cast(this->treeWidget()); + tree->onAction(this, NodeAction::opView3d); + }); } TNode* createTNode(const E57NodePtr& e57Node) diff --git a/app/NodeAction.h b/app/NodeAction.h index 494f4cc..2ab6d33 100644 --- a/app/NodeAction.h +++ b/app/NodeAction.h @@ -4,7 +4,9 @@ enum class NodeAction { opScanPanorama, - opXmlDump + opXmlDump, + opView3d, + opView2d }; #endif // E57INSPECTOR_NODEACTION_H diff --git a/app/mainwindow.cpp b/app/mainwindow.cpp index 958c3ef..cb3cf1c 100644 --- a/app/mainwindow.cpp +++ b/app/mainwindow.cpp @@ -315,6 +315,7 @@ void MainWindow::twMain_onAction(const TNode* node, NodeAction action) showXMLDump(); } } + if (dynamic_cast(node) != nullptr) { const auto* data3DNode = dynamic_cast(node); @@ -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(data3DNode->node()); + if (e57Data3D->data().contains("points")) + { + sceneView_itemDropped(nullptr, ui->twMain); + } + } + } + + if (dynamic_cast(node) != nullptr) + { + const auto* dataImage2D = dynamic_cast(node); + if (action == NodeAction::opView2d) + { + auto e57Image2D = + std::dynamic_pointer_cast(dataImage2D->node()); + openImage(*e57Image2D, e57Image2D->name()); + } + else if (action == NodeAction::opView3d) + { + sceneView_itemDropped(nullptr, ui->twMain); + } } } @@ -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) {