From ed3f97468077d8eeb13871e04b2e34f049a28f7a Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Tue, 4 Apr 2023 18:35:09 +0200 Subject: [PATCH] WIP --- src/PV3DViewer/PV3DViewer_ViewWindow.cxx | 4 ++-- src/SPV3D/SPV3D_ViewManager.cxx | 16 ++++++++----- src/SPV3D/SPV3D_ViewModel.cxx | 30 +++++++++++++++++++++--- src/SPV3D/SPV3D_ViewWindow.cxx | 12 ++++++++-- src/SPV3D/SPV3D_ViewWindow.h | 3 ++- 5 files changed, 51 insertions(+), 14 deletions(-) diff --git a/src/PV3DViewer/PV3DViewer_ViewWindow.cxx b/src/PV3DViewer/PV3DViewer_ViewWindow.cxx index ca774d63d..9a21c91c2 100644 --- a/src/PV3DViewer/PV3DViewer_ViewWindow.cxx +++ b/src/PV3DViewer/PV3DViewer_ViewWindow.cxx @@ -57,7 +57,7 @@ PV3DViewer_ViewWindow::PV3DViewer_ViewWindow( SUIT_Desktop* theDesktop, PV3DView myDesktop = theDesktop; myModel = theModel; setViewManager(myModel->getViewManager()); - myPVMgr = qobject_cast(pqApplicationCore::instance()->manager("MULTIVIEW_WIDGET")); + /*myPVMgr = qobject_cast(pqApplicationCore::instance()->manager("MULTIVIEW_WIDGET")); if (myPVMgr) { SUIT_Application* app = SUIT_Session::session()->activeApplication(); if ( app ) @@ -67,7 +67,7 @@ PV3DViewer_ViewWindow::PV3DViewer_ViewWindow( SUIT_Desktop* theDesktop, PV3DView myPVMgr->show(); setCentralWidget( myPVMgr ); } else - qDebug("No multiViewManager defined"); + qDebug("No multiViewManager defined");*/ } /*! diff --git a/src/SPV3D/SPV3D_ViewManager.cxx b/src/SPV3D/SPV3D_ViewManager.cxx index 89f04e9f4..70878e63c 100644 --- a/src/SPV3D/SPV3D_ViewManager.cxx +++ b/src/SPV3D/SPV3D_ViewManager.cxx @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -56,19 +57,22 @@ SPV3D_ViewManager::SPV3D_ViewManager( SUIT_Study* study, SUIT_Desktop* theDeskto { DBG_FUN(); setTitle( PV3DViewer_ViewManager::tr( "PARAVIEW3D_VIEW_TITLE" ) ); - int argc = 1; - char *argv[2]; - argv[0] = strdup("salome"); - argv[1] = nullptr; + /*QStringList args = QCoreApplication::arguments(); + int argc = args.length(); + char **argv = new char *[argc+1]; + for(auto i = 0 ; i < argc ; ++i) + argv[i] = strdup(args[i].toStdString().c_str()); + argv[argc] = nullptr; pqPVApplicationCore appPV(argc,argv); QApplication::instance()->installEventFilter(&appPV); + new pqParaViewBehaviors(theDesktop,theDesktop); pqObjectBuilder *builder(pqApplicationCore::instance()->getObjectBuilder()); pqServer *serv(pqApplicationCore::instance()->getServerManagerModel()->findServer(pqServerResource("builtin:"))); pqView *view=builder->createView(QString("RenderView"),serv); - static_cast(this->getViewModel())->setView(view); + static_cast(this->getViewModel())->setView(view);*/ //QVBoxLayout *lay(new QVBoxLayout(theDesktop)); //lay->addWidget( view->widget() ); - view->widget()->setParent( theDesktop); + //view->widget()->setParent( theDesktop); // Initialize minimal paraview stuff (if not already done) //PVViewer_InitSingleton::Init(theDesktop); diff --git a/src/SPV3D/SPV3D_ViewModel.cxx b/src/SPV3D/SPV3D_ViewModel.cxx index 7e660807d..dfab79f24 100644 --- a/src/SPV3D/SPV3D_ViewModel.cxx +++ b/src/SPV3D/SPV3D_ViewModel.cxx @@ -51,6 +51,16 @@ #include "QtxActionToolMgr.h" #include "QtxBackgroundTool.h" +#include +#include +#include +#include +#include +#include +#include + +#include + // VSR: Uncomment below line to allow texture background support in PV3D viewer #define PV3D_ENABLE_TEXTURED_BACKGROUND @@ -81,9 +91,6 @@ SPV3D_ViewModel::~SPV3D_ViewModel() void SPV3D_ViewModel::initialize() { DBG_FUN(); - - const auto* builder = pqApplicationCore::instance()->getObjectBuilder(); - QObject::connect(builder, &pqObjectBuilder::sourceCreated, this, &SPV3D_ViewModel::onSourceCreated); } @@ -96,6 +103,23 @@ SUIT_ViewWindow* SPV3D_ViewModel::createView( SUIT_Desktop* theDesktop ) SPV3D_ViewWindow* aViewWindow = new SPV3D_ViewWindow(theDesktop, this); aViewWindow->SetSelectionEnabled( isSelectionEnabled() ); + + QStringList args = QCoreApplication::arguments(); + int argc = args.length(); + char **argv = new char *[argc+1]; + for(auto i = 0 ; i < argc ; ++i) + argv[i] = strdup(args[i].toStdString().c_str()); + argv[argc] = nullptr; + pqPVApplicationCore appPV(argc,argv); + QApplication::instance()->installEventFilter(&appPV); + new pqParaViewBehaviors(aViewWindow,aViewWindow); + pqObjectBuilder *builder(pqApplicationCore::instance()->getObjectBuilder()); + QObject::connect(builder, &pqObjectBuilder::sourceCreated, this, &SPV3D_ViewModel::onSourceCreated); + pqServer *serv(pqApplicationCore::instance()->getServerManagerModel()->findServer(pqServerResource("builtin:"))); + pqView *view=builder->createView(QString("RenderView"),serv); + setView(view); + + aViewWindow->init(); return aViewWindow; } diff --git a/src/SPV3D/SPV3D_ViewWindow.cxx b/src/SPV3D/SPV3D_ViewWindow.cxx index ea440feb5..bb97d3da7 100644 --- a/src/SPV3D/SPV3D_ViewWindow.cxx +++ b/src/SPV3D/SPV3D_ViewWindow.cxx @@ -34,6 +34,8 @@ #include #include +#include + #include "QtxAction.h" #include "SUIT_Session.h" @@ -65,12 +67,18 @@ */ SPV3D_ViewWindow::SPV3D_ViewWindow(SUIT_Desktop* theDesktop, SPV3D_ViewModel* theModel): PV3DViewer_ViewWindow(theDesktop, theModel), - myModel(theModel), - myView(NULL) + myModel(theModel) { DBG_FUN(); } +void SPV3D_ViewWindow::init() +{ + QWidget *wid = myModel->getView()->widget(); + wid->setParent( this ); + setCentralWidget( myModel->getView()->widget() ); +} + /*! Destructor */ diff --git a/src/SPV3D/SPV3D_ViewWindow.h b/src/SPV3D/SPV3D_ViewWindow.h index 8f4411b4c..eeada3ec3 100644 --- a/src/SPV3D/SPV3D_ViewWindow.h +++ b/src/SPV3D/SPV3D_ViewWindow.h @@ -84,6 +84,8 @@ class SPV3D_EXPORT SPV3D_ViewWindow : public PV3DViewer_ViewWindow //SUIT_ViewWi //! To construct #SPV3D_ViewWindow instance SPV3D_ViewWindow(SUIT_Desktop* theDesktop, SPV3D_ViewModel* theModel); + void init(); + virtual ~SPV3D_ViewWindow(); /* display */ @@ -128,7 +130,6 @@ protected slots: void onMouseMoving(QMouseEvent* event); protected: - SPV3D_View* myView; SPV3D_ViewModel* myModel; }; -- 2.39.2