]> SALOME platform Git repositories - modules/paravis.git/commitdiff
Salome HOME
Moved behaviors into a dedicated object class.
authorabn <adrien.bruneton@cea.fr>
Wed, 3 Sep 2014 14:51:27 +0000 (16:51 +0200)
committerabn <adrien.bruneton@cea.fr>
Wed, 3 Sep 2014 14:51:27 +0000 (16:51 +0200)
src/PVGUI/PVGUI_Module.cxx
src/PVGUI/view/CMakeLists.txt
src/PVGUI/view/PVGUI_Behaviors.cxx [new file with mode: 0644]
src/PVGUI/view/PVGUI_Behaviors.h [new file with mode: 0644]

index 54fe2586d1cd1d181c8843c22f33ad75ee0dcc78..8b57095616b160e65f6e3e3ca3921745d700b6c2 100644 (file)
@@ -40,6 +40,7 @@
 #include "PVGUI_Tools.h"
 #include "PVGUI_ParaViewSettingsPane.h"
 #include "PVGUI_OutputWindowAdapter.h"
+#include "PVGUI_Behaviors.h"
 
 #include <SUIT_DataBrowser.h>
 #include <SUIT_Desktop.h>
 #include <pqHelpReaction.h>
 #include <vtkOutputWindow.h>
 #include <pqPluginManager.h>
-#include "pqInterfaceTracker.h"
 #include <pqSettings.h>
 #include <pqPythonDialog.h>
 #include <pqPythonManager.h>
 #include <pqLoadDataReaction.h>
 #include <vtkEventQtSlotConnect.h>
 #include <pqPythonScriptEditor.h>
-#include <pqCollaborationBehavior.h>
 #include <pqDataRepresentation.h>
 #include <pqPipelineRepresentation.h>
 #include <pqLookupTableManager.h>
 #include <pqDisplayColorWidget.h>
 #include <pqColorToolbar.h>
 #include <pqScalarBarVisibilityReaction.h>
-#include <pqStandardPropertyWidgetInterface.h>
-#include <pqViewStreamingBehavior.h>
+
 #include <pqServerResource.h>
 #include <pqServerConnectReaction.h>
 #include <pqServerDisconnectReaction.h>
 
-#include <PARAVIS_version.h>
-
-#include <vtkPVConfig.h>
-
-
-#include CORBA_SERVER_HEADER(SALOME_ModuleCatalog)
-
-#include <pqAlwaysConnectedBehavior.h>
 #include <pqApplicationCore.h>
-#include <pqAutoLoadPluginXMLBehavior.h>
-#include <pqCommandLineOptionsBehavior.h>
-#include <pqCrashRecoveryBehavior.h>
-#include <pqDataTimeStepBehavior.h>
-#include <pqDefaultViewBehavior.h>
-#include <pqDeleteBehavior.h>
-#include <pqObjectPickingBehavior.h>
-#include <pqPersistentMainWindowStateBehavior.h>
-#include <pqPipelineContextMenuBehavior.h>
-#include <pqPluginActionGroupBehavior.h>
-#include <pqPluginDockWidgetsBehavior.h>
-#include <pqPluginManager.h>
-#include <pqPVNewSourceBehavior.h>
-#include <pqSpreadSheetVisibilityBehavior.h>
-#include <pqStandardViewModules.h>
-#include <pqUndoRedoBehavior.h>
-#include <pqViewFrameActionsBehavior.h>
 #include <pqServerManagerObserver.h>
-
 #include <vtkClientServerInterpreterInitializer.h>
+#include <vtkPVConfig.h>
 
+#include <PARAVIS_version.h>
+
+#include CORBA_SERVER_HEADER(SALOME_ModuleCatalog)
 
 //----------------------------------------------------------------------------
 pqPVApplicationCore* PVGUI_Module::MyCoreApp = 0;
@@ -413,44 +389,8 @@ void PVGUI_Module::initialize( CAM_Application* app )
   QList<QDockWidget*> activeDocks = aDesktop->findChildren<QDockWidget*>();
   QList<QMenu*> activeMenus = aDesktop->findChildren<QMenu*>();
 
-  // 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);
index cd3c5c624e7108f22f8e3d8b674c8d65d6375956..7f44bf67c6301f349b7b17c3173a20b042597347 100644 (file)
@@ -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 (file)
index 0000000..9b3061e
--- /dev/null
@@ -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 <SUIT_Desktop.h>
+#include <SalomeApp_Module.h>
+
+#include <pqInterfaceTracker.h>
+#include <pqApplicationCore.h>
+#include <pqPluginManager.h>
+#include <pqStandardViewModules.h>
+#include <pqStandardPropertyWidgetInterface.h>
+
+#include <pqAlwaysConnectedBehavior.h>
+#include <pqAutoLoadPluginXMLBehavior.h>
+#include <pqCommandLineOptionsBehavior.h>
+#include <pqCrashRecoveryBehavior.h>
+#include <pqDataTimeStepBehavior.h>
+#include <pqDefaultViewBehavior.h>
+#include <pqDeleteBehavior.h>
+#include <pqObjectPickingBehavior.h>
+#include <pqPersistentMainWindowStateBehavior.h>
+#include <pqPipelineContextMenuBehavior.h>
+#include <pqPluginActionGroupBehavior.h>
+#include <pqPluginDockWidgetsBehavior.h>
+#include <pqPVNewSourceBehavior.h>
+#include <pqSpreadSheetVisibilityBehavior.h>
+#include <pqUndoRedoBehavior.h>
+#include <pqViewFrameActionsBehavior.h>
+#include <pqViewStreamingBehavior.h>
+#include <pqCollaborationBehavior.h>
+
+bool PVGUI_Behaviors::hasMinimalInstanciated = false;
+
+PVGUI_Behaviors::PVGUI_Behaviors(SalomeApp_Module * parent)
+  : QObject(static_cast<QObject *>(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 (file)
index 0000000..b661762
--- /dev/null
@@ -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 <QObject>
+
+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_ */