0029747: Samples - Inspector tool - start DFBrowser inside FuncDemo qt sample
authornds <nds@opencascade.com>
Tue, 8 May 2018 16:56:11 +0000 (19:56 +0300)
committerabv <abv@opencascade.com>
Wed, 23 May 2018 04:00:35 +0000 (07:00 +0300)
new Model->DFBrowser action to start Inspector tool with active DFBrowser plugin filled by the sample OCAF application.
To update content of the DFBrowser, use <F5> shortcut.

samples/qt/FuncDemo/CMakeLists.txt
samples/qt/FuncDemo/src/mainwindow.cpp
samples/qt/FuncDemo/src/mainwindow.h

index 92dc1e6..1ea39b5 100644 (file)
@@ -3,3 +3,7 @@ project(FuncDemo)
 OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_sample)
 OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
 OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_sample)
+
+if (BUILD_Inspector)
+  target_link_libraries (FuncDemo TKTInspector)
+endif()
index 0668b35..3f8e1d6 100644 (file)
 #include <unistd.h>
 #endif
 
+#ifdef HAVE_Inspector
+#include <inspector/TInspector_Communicator.hxx>
+static TInspector_Communicator* MyTCommunicator;
+#endif
+
 MainWindow::MainWindow()
 {
     graph = new GraphWidget(this);
@@ -224,6 +229,30 @@ void MainWindow::nbThreads()
         graph->setNbThreads(nb);
 }
 
+#ifdef HAVE_Inspector
+void MainWindow::startDFBrowser()
+{
+  Handle(AppStd_Application) anApplication = getApplication();
+  if (!anApplication.IsNull())
+  {
+    if (!MyTCommunicator)
+    {
+      MyTCommunicator = new TInspector_Communicator();
+
+      NCollection_List<Handle(Standard_Transient)> aParameters;
+      aParameters.Append(anApplication);
+
+      MyTCommunicator->RegisterPlugin("TKDFBrowser");
+
+      MyTCommunicator->Init(aParameters);
+      MyTCommunicator->Activate("TKDFBrowser");
+
+    }
+    MyTCommunicator->SetVisible(true);
+  }
+}
+#endif
+
 void MainWindow::about()
 {
    QMessageBox::about(this, tr("Test-application of the advanced Function Mechanism"),
@@ -250,6 +279,12 @@ void MainWindow::createActions()
     nbThreadsAct->setStatusTip(tr("Number of threads"));
     connect(nbThreadsAct, SIGNAL(triggered()), this, SLOT(nbThreads()));
 
+#ifdef HAVE_Inspector
+    dfBrowserAct = new QAction(tr("DFBrowser"), this);
+    dfBrowserAct->setStatusTip(tr("OCAF structure presentation"));
+    connect(dfBrowserAct, SIGNAL(triggered()), this, SLOT(startDFBrowser()));
+#endif
+
     exitAct = new QAction(tr("E&xit"), this);
     exitAct->setShortcut(tr("Ctrl+Q"));
     exitAct->setStatusTip(tr("Exit the application"));
@@ -269,6 +304,10 @@ void MainWindow::createMenus()
     computeMenu->addAction(computeAct);
     computeMenu->addAction(nbThreadsAct);
     computeMenu->addSeparator();
+#ifdef HAVE_Inspector
+    computeMenu->addAction(dfBrowserAct);
+    computeMenu->addSeparator();
+#endif
     computeMenu->addAction(exitAct);
 
     menuBar()->addSeparator();
index ca2b7a8..2bf4b88 100644 (file)
@@ -70,6 +70,9 @@ private slots:
     void model2();
     void compute();
     void nbThreads();
+#ifdef HAVE_Inspector
+    void startDFBrowser();
+#endif
     void about();
 
 private:
@@ -87,6 +90,9 @@ private:
     QAction *model2Act;
     QAction *computeAct;
     QAction *nbThreadsAct;
+#ifdef HAVE_Inspector
+    QAction *dfBrowserAct;
+#endif
     QAction *exitAct;
     QAction *aboutAct;