From 767da232da1de39384fe2b98346ba1252016c47b Mon Sep 17 00:00:00 2001 From: Guido Ranzuglia granzuglia Date: Wed, 21 Sep 2016 07:56:35 +0000 Subject: [PATCH] - experimental version of the MainWindow class using a current multiviewer container member --- src/meshlab/mainwindow.h | 41 ++++++++++++++++-------------- src/meshlab/mainwindow_Init.cpp | 3 +++ src/meshlab/mainwindow_RunTime.cpp | 29 +++++++++++++++++++-- 3 files changed, 52 insertions(+), 21 deletions(-) diff --git a/src/meshlab/mainwindow.h b/src/meshlab/mainwindow.h index 297c7137c..410757670 100644 --- a/src/meshlab/mainwindow.h +++ b/src/meshlab/mainwindow.h @@ -235,6 +235,7 @@ private slots: void sendHistory(); ///////////Solt Wrapper for QMdiArea ////////////////// void wrapSetActiveSubWindow(QWidget* window); + void switchCurrentContainer(QMdiSubWindow *); void scriptCodeExecuted(const QScriptValue& val,const int time,const QString& output); void updateGPUMemBar(int,int); @@ -329,26 +330,26 @@ public: } MultiViewer_Container* currentViewContainer() const { - /* MultiViewer_Container *mvc = dynamic_cast(mdiarea->currentSubWindow()); - if(mvc) return mvc;*/ - if(mdiarea->currentSubWindow()!=0 ) - { - Splitter* split = reinterpret_cast(mdiarea->currentSubWindow()->widget()); - if (split->isMultiViewerContainer()) - return reinterpret_cast(split); - } - /*QList subwinList=mdiarea->subWindowList(); - foreach(QMdiSubWindow *subwinPtr,subwinList) - { - MultiViewer_Container *mvc = dynamic_cast(subwinPtr); - if(mvc) return mvc; - if(mvc==0 && subwinPtr!=0){ - mvc = dynamic_cast(subwinPtr->widget()); - if(mvc) return mvc; - } - }*/ + // /* MultiViewer_Container *mvc = dynamic_cast(mdiarea->currentSubWindow()); + // if(mvc) return mvc;*/ + // if(mdiarea->currentSubWindow()!=0 ) + //{ + // Splitter* split = reinterpret_cast(mdiarea->currentSubWindow()->widget()); + // if (split->isMultiViewerContainer()) + // return reinterpret_cast(split); + // } + // /*QList subwinList=mdiarea->subWindowList(); + // foreach(QMdiSubWindow *subwinPtr,subwinList) + // { + // MultiViewer_Container *mvc = dynamic_cast(subwinPtr); + // if(mvc) return mvc; + // if(mvc==0 && subwinPtr!=0){ + // mvc = dynamic_cast(subwinPtr->widget()); + // if(mvc) return mvc; + // } + // }*/ - return 0; + return _currviewcontainer; } const PluginManager& pluginManager() const { return PM; } @@ -512,6 +513,8 @@ private: QAction *checkUpdatesAct; //////////////////////////////////////////////////// static QString getDecoratedFileName(const QString& name); + + MultiViewer_Container* _currviewcontainer; }; /// Event filter that is installed to intercept the open events sent directly by the Operative System diff --git a/src/meshlab/mainwindow_Init.cpp b/src/meshlab/mainwindow_Init.cpp index b354f5be2..4f04489a4 100644 --- a/src/meshlab/mainwindow_Init.cpp +++ b/src/meshlab/mainwindow_Init.cpp @@ -53,6 +53,7 @@ QProgressBar *MainWindow::qb; MainWindow::MainWindow() :mwsettings(), xmlfiltertimer(), wama(), gpumeminfo(NULL) { + _currviewcontainer = NULL; //xmlfiltertimer will be called repeatedly, so like Qt documentation suggests, the first time start function should be called. //Subsequently restart function will be invoked. setContextMenuPolicy(Qt::NoContextMenu); @@ -64,6 +65,7 @@ MainWindow::MainWindow() layerDialog = new LayerDialog(this); connect(layerDialog, SIGNAL(toBeShow()), this, SLOT(updateLayerDialog())); layerDialog->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); + layerDialog->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum); addDockWidget(Qt::RightDockWidgetArea, layerDialog); @@ -73,6 +75,7 @@ MainWindow::MainWindow() // Permette di passare da una finestra all'altra e tenere aggiornato il workspace connect(windowMapper, SIGNAL(mapped(QWidget*)), this, SLOT(wrapSetActiveSubWindow(QWidget *))); // Quando si passa da una finestra all'altra aggiorna lo stato delle toolbar e dei menu + connect(mdiarea, SIGNAL(subWindowActivated(QMdiSubWindow *)), this, SLOT(switchCurrentContainer(QMdiSubWindow *))); connect(mdiarea, SIGNAL(subWindowActivated(QMdiSubWindow *)), this, SLOT(updateLayerDialog())); connect(mdiarea, SIGNAL(subWindowActivated(QMdiSubWindow *)), this, SLOT(updateMenus())); connect(mdiarea, SIGNAL(subWindowActivated(QMdiSubWindow *)), this, SLOT(updateWindowMenu())); diff --git a/src/meshlab/mainwindow_RunTime.cpp b/src/meshlab/mainwindow_RunTime.cpp index d0ad79cdb..764f0225f 100644 --- a/src/meshlab/mainwindow_RunTime.cpp +++ b/src/meshlab/mainwindow_RunTime.cpp @@ -331,6 +331,8 @@ void MainWindow::switchOffDecorator(QAction* decorator) void MainWindow::updateLayerDialog() { + if (meshDoc() == NULL) + return; MultiViewer_Container* mvc = currentViewContainer(); if (mvc == NULL) return; @@ -349,19 +351,21 @@ void MainWindow::updateLayerDialog() layerDialog->updateLog(meshDoc()->Log); layerDialog->updateDecoratorParsView(); MLRenderingData dt; - if ((meshDoc()!=NULL) && (meshDoc()->mm() != NULL)) + if (meshDoc()->mm() != NULL) { MLSceneGLSharedDataContext::PerMeshRenderingDataMap::iterator it = dtf.find(meshDoc()->mm()->id()); if (it != dtf.end()) layerDialog->updateRenderingParametersTab(meshDoc()->mm()->id(),*it); } layerDialog->setMinimumSize(layerDialog->_tabw->size().width() + 10,layerDialog->minimumSize().height()); - layerDialog->setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Minimum); } } void MainWindow::updateMenus() { + if (meshDoc() == NULL) + return; + bool activeDoc = (bool) !mdiarea->subWindowList().empty() && mdiarea->currentSubWindow(); bool notEmptyActiveDoc = activeDoc && !meshDoc()->meshList.empty(); importMeshAct->setEnabled(activeDoc); @@ -3719,4 +3723,25 @@ void MainWindow::updateLog() GLLogStream* senderlog = qobject_cast(sender()); if ((senderlog != NULL) && (layerDialog != NULL)) layerDialog->updateLog(*senderlog); +} + +void MainWindow::switchCurrentContainer(QMdiSubWindow * subwin) +{ + if (subwin == NULL) + return; + if (mdiarea->currentSubWindow() != 0) + { + MultiViewer_Container* split = qobject_cast(mdiarea->currentSubWindow()->widget()); + if (split != NULL) + _currviewcontainer = split; + } + if (_currviewcontainer != NULL) + { + updateLayerDialog(); + updateMenus(); + updateWindowMenu(); + updateStdDialog(); + updateXMLStdDialog(); + updateDocumentScriptBindings(); + } } \ No newline at end of file