From: abn Date: Wed, 3 Sep 2014 14:51:27 +0000 (+0200) Subject: Moved behaviors into a dedicated object class. X-Git-Tag: V7_5_0b1~27^2~17 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5e618cae9b3d3ed97fab5704753d1c9a7a52f9b4;p=modules%2Fparavis.git Moved behaviors into a dedicated object class. --- diff --git a/src/PVGUI/PVGUI_Module.cxx b/src/PVGUI/PVGUI_Module.cxx index 54fe2586..8b570956 100644 --- a/src/PVGUI/PVGUI_Module.cxx +++ b/src/PVGUI/PVGUI_Module.cxx @@ -40,6 +40,7 @@ #include "PVGUI_Tools.h" #include "PVGUI_ParaViewSettingsPane.h" #include "PVGUI_OutputWindowAdapter.h" +#include "PVGUI_Behaviors.h" #include #include @@ -109,7 +110,6 @@ #include #include #include -#include "pqInterfaceTracker.h" #include #include #include @@ -117,49 +117,25 @@ #include #include #include -#include #include #include #include #include #include #include -#include -#include + #include #include #include -#include - -#include - - -#include CORBA_SERVER_HEADER(SALOME_ModuleCatalog) - -#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include - #include +#include +#include + +#include CORBA_SERVER_HEADER(SALOME_ModuleCatalog) //---------------------------------------------------------------------------- pqPVApplicationCore* PVGUI_Module::MyCoreApp = 0; @@ -413,44 +389,8 @@ void PVGUI_Module::initialize( CAM_Application* app ) QList activeDocks = aDesktop->findChildren(); QList activeMenus = aDesktop->findChildren(); - // new pqParaViewBehaviors(anApp->desktop(), this); - // Has to be replaced in order to exclude using of pqQtMessageHandlerBehaviour - // Start pqParaViewBehaviors - // Register ParaView interfaces. - //pqPluginManager* pgm = pqApplicationCore::instance()->getPluginManager(); - pqInterfaceTracker* pgm = pqApplicationCore::instance()->interfaceTracker(); - - // * adds support for standard paraview views. - pgm->addInterface(new pqStandardViewModules(pgm)); - pgm->addInterface(new pqStandardPropertyWidgetInterface(pgm)); - - // Load plugins distributed with application. - pqApplicationCore::instance()->loadDistributedPlugins(); - - // Define application behaviors. - //new pqQtMessageHandlerBehavior(this); - new pqDataTimeStepBehavior(this); - new pqViewFrameActionsBehavior(this); - new pqSpreadSheetVisibilityBehavior(this); - new pqPipelineContextMenuBehavior(this); - new pqObjectPickingBehavior(this); // NEW in 4.1 - new pqDefaultViewBehavior(this); - new pqAlwaysConnectedBehavior(this); - new pqPVNewSourceBehavior(this); - new pqDeleteBehavior(this); - new pqUndoRedoBehavior(this); - new pqCrashRecoveryBehavior(this); - new pqAutoLoadPluginXMLBehavior(this); - new pqPluginDockWidgetsBehavior(aDesktop); - //new pqVerifyRequiredPluginBehavior(this); - new pqPluginActionGroupBehavior(aDesktop); - //new pqFixPathsInStateFilesBehavior(this); - new pqCommandLineOptionsBehavior(this); - new pqPersistentMainWindowStateBehavior(aDesktop); - new pqObjectPickingBehavior(aDesktop); - new pqCollaborationBehavior(this); - //new pqMultiServerBehavior(this); - new pqViewStreamingBehavior(this); + PVGUI_Behaviors * behav = new PVGUI_Behaviors(this); + behav->instanciateAllBehaviors(aDesktop); // Setup quick-launch shortcuts. QShortcut *ctrlSpace = new QShortcut(Qt::CTRL + Qt::Key_Space, aDesktop); diff --git a/src/PVGUI/view/CMakeLists.txt b/src/PVGUI/view/CMakeLists.txt index cd3c5c62..7f44bf67 100644 --- a/src/PVGUI/view/CMakeLists.txt +++ b/src/PVGUI/view/CMakeLists.txt @@ -42,6 +42,7 @@ SET(_moc_HEADERS PVGUI_ViewManager.h PVGUI_ViewModel.h PVGUI_ViewWindow.h + PVGUI_Behaviors.h ) # header files / no moc processing @@ -62,6 +63,7 @@ SET(_other_SOURCES PVGUI_ViewModel.cxx PVGUI_ViewWindow.cxx PVGUI_OutputWindowAdapter.cxx + PVGUI_Behaviors.cxx ) # sources / to compile diff --git a/src/PVGUI/view/PVGUI_Behaviors.cxx b/src/PVGUI/view/PVGUI_Behaviors.cxx new file mode 100644 index 00000000..9b3061e4 --- /dev/null +++ b/src/PVGUI/view/PVGUI_Behaviors.cxx @@ -0,0 +1,115 @@ +// Copyright (C) 2010-2014 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author: Adrien Bruneton (CEA) + +#include "PVGUI_Behaviors.h" + +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +bool PVGUI_Behaviors::hasMinimalInstanciated = false; + +PVGUI_Behaviors::PVGUI_Behaviors(SalomeApp_Module * parent) + : QObject(static_cast(parent)) +{ +} + +/**! Instanciate minimal ParaView behaviors needed when using an instance of PVViewer. + * This method should be updated at each new version of ParaView with what is found in + * Qt/ApplicationComponents/pqParaViewBehaviors.cxx + */ +void PVGUI_Behaviors::instanciateMinimalBehaviors(SUIT_Desktop * desk) +{ + hasMinimalInstanciated = true; + + // Register ParaView interfaces. + pqInterfaceTracker* pgm = pqApplicationCore::instance()->interfaceTracker(); + + // * adds support for standard paraview views. + pgm->addInterface(new pqStandardViewModules(pgm)); + pgm->addInterface(new pqStandardPropertyWidgetInterface(pgm)); + + // Load plugins distributed with application. + pqApplicationCore::instance()->loadDistributedPlugins(); + + new pqViewFrameActionsBehavior(this); // button above the view port controlling selection and camera undos + new pqDefaultViewBehavior(this); // shows a 3D view as soon as a server connection is made + new pqAlwaysConnectedBehavior(this); // client always connected to a server + new pqPVNewSourceBehavior(this); // new source is made active, ... + new pqAutoLoadPluginXMLBehavior(this); // auto load plugins +} + +/**! Instanciate usual ParaView behaviors. + * This method should be updated at each new version of ParaView with what is found in + * Qt/ApplicationComponents/pqParaViewBehaviors.cxx + */ +void PVGUI_Behaviors::instanciateAllBehaviors(SUIT_Desktop * desk) +{ + // "new pqParaViewBehaviors(anApp->desktop(), this);" + // -> (which loads all standard ParaView behaviors at once) has to be replaced in order to + // exclude using of pqQtMessageHandlerBehaviour + + // Define application behaviors. + if (!hasMinimalInstanciated) + instanciateMinimalBehaviors(desk); + //new pqQtMessageHandlerBehavior(this); // THIS ONE TO EXCLUDE !! see comment above + new pqDataTimeStepBehavior(this); + new pqSpreadSheetVisibilityBehavior(this); + new pqPipelineContextMenuBehavior(this); + new pqObjectPickingBehavior(this); // NEW in 4.1 + new pqDeleteBehavior(this); + new pqUndoRedoBehavior(this); + new pqCrashRecoveryBehavior(this); + new pqPluginDockWidgetsBehavior(desk); + //new pqVerifyRequiredPluginBehavior(this); + new pqPluginActionGroupBehavior(desk); + //new pqFixPathsInStateFilesBehavior(this); + new pqCommandLineOptionsBehavior(this); + new pqPersistentMainWindowStateBehavior(desk); + new pqObjectPickingBehavior(desk); + new pqCollaborationBehavior(this); + //new pqMultiServerBehavior(this); + new pqViewStreamingBehavior(this); + +} diff --git a/src/PVGUI/view/PVGUI_Behaviors.h b/src/PVGUI/view/PVGUI_Behaviors.h new file mode 100644 index 00000000..b6617626 --- /dev/null +++ b/src/PVGUI/view/PVGUI_Behaviors.h @@ -0,0 +1,52 @@ +// Copyright (C) 2010-2014 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author: Adrien Bruneton (CEA) + + +#ifndef PVGUIBEHAVIORS_H_ +#define PVGUIBEHAVIORS_H_ + +#include + +class SalomeApp_Module; +class SUIT_Desktop; + +/**! + * PARAVIS behaviors - mimic what is done in + * Qt/ApplicationComponents/pqParaViewBehaviors.cxx + * Except a few ones, behaviors are destroyed when the module is destroyed. + */ +class PVGUI_Behaviors: public QObject +{ + Q_OBJECT + +public: + PVGUI_Behaviors(SalomeApp_Module * parent); + + void instanciateMinimalBehaviors(SUIT_Desktop * desk); + + void instanciateAllBehaviors(SUIT_Desktop * desk); + + virtual ~PVGUI_Behaviors() {} + +private: + static bool hasMinimalInstanciated; +}; + +#endif /* PVGUIBEHAVIORS_H_ */