Salome HOME
Merge branch 'abn/port_pv42' into abn/rearch
[modules/paravis.git] / src / PVGUI / view / PVGUI_Behaviors.cxx
1 // Copyright (C) 2010-2014  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Author: Adrien Bruneton (CEA)
20
21 #include "PVGUI_Behaviors.h"
22
23 #include <SUIT_Desktop.h>
24 #include <SalomeApp_Module.h>
25
26 #include <pqInterfaceTracker.h>
27 #include <pqApplicationCore.h>
28 #include <pqPluginManager.h>
29 #include <pqStandardPropertyWidgetInterface.h>
30 #include <pqStandardViewFrameActionsImplementation.h>
31 #include <pqPropertiesPanel.h>
32
33 #include <pqAlwaysConnectedBehavior.h>
34 #include <pqAutoLoadPluginXMLBehavior.h>
35 #include <pqCommandLineOptionsBehavior.h>
36 #include <pqCrashRecoveryBehavior.h>
37 #include <pqDataTimeStepBehavior.h>
38 #include <pqDefaultViewBehavior.h>
39 #include <pqObjectPickingBehavior.h>
40 #include <pqPersistentMainWindowStateBehavior.h>
41 #include <pqPipelineContextMenuBehavior.h>
42 #include <pqPluginActionGroupBehavior.h>
43 #include <pqPluginDockWidgetsBehavior.h>
44 #include <pqSpreadSheetVisibilityBehavior.h>
45 #include <pqUndoRedoBehavior.h>
46 #include <pqViewStreamingBehavior.h>
47 #include <pqCollaborationBehavior.h>
48 #include <pqVerifyRequiredPluginBehavior.h>
49 #include <pqPluginSettingsBehavior.h>
50 #include <pqFixPathsInStateFilesBehavior.h>
51 #include <pqApplyBehavior.h>
52
53 bool PVGUI_Behaviors::hasMinimalInstanciated = false;
54
55 PVGUI_Behaviors::PVGUI_Behaviors(SalomeApp_Module * parent)
56   : QObject(static_cast<QObject *>(parent))
57 {
58 }
59
60 /**! Instanciate minimal ParaView behaviors needed when using an instance of PVViewer.
61  * This method should be updated at each new version of ParaView with what is found in
62  *    Qt/ApplicationComponents/pqParaViewBehaviors.cxx
63  */
64 void PVGUI_Behaviors::instanciateMinimalBehaviors(SUIT_Desktop * desk)
65 {
66   hasMinimalInstanciated = true;
67
68   // Register ParaView interfaces.
69   pqInterfaceTracker* pgm = pqApplicationCore::instance()->interfaceTracker();
70
71   // Register standard types of property widgets.
72   pgm->addInterface(new pqStandardPropertyWidgetInterface(pgm));
73   // Register standard types of view-frame actions.
74   pgm->addInterface(new pqStandardViewFrameActionsImplementation(pgm));
75
76   // Load plugins distributed with application.
77   pqApplicationCore::instance()->loadDistributedPlugins();
78
79   new pqDefaultViewBehavior(this);  // shows a 3D view as soon as a server connection is made
80   new pqAlwaysConnectedBehavior(this);  // client always connected to a server
81   new pqAutoLoadPluginXMLBehavior(this);  // auto load plugins
82   new pqVerifyRequiredPluginBehavior(this);
83   new pqPluginSettingsBehavior(this);
84   new pqFixPathsInStateFilesBehavior(this);
85   new pqCrashRecoveryBehavior(this);
86   new pqCommandLineOptionsBehavior(this);
87 }
88
89 /**! Instanciate usual ParaView behaviors.
90  * This method should be updated at each new version of ParaView with what is found in
91  *    Qt/ApplicationComponents/pqParaViewBehaviors.cxx
92  */
93 void PVGUI_Behaviors::instanciateAllBehaviors(SUIT_Desktop * desk)
94 {
95   //    "new pqParaViewBehaviors(anApp->desktop(), this);"
96   // -> (which loads all standard ParaView behaviors at once) has to be replaced in order to
97   // exclude using of pqQtMessageHandlerBehaviour
98
99   // Define application behaviors.
100   if (!hasMinimalInstanciated)
101     instanciateMinimalBehaviors(desk);
102   //new pqQtMessageHandlerBehavior(this);   // THIS ONE TO EXCLUDE !! see comment above
103   new pqDataTimeStepBehavior(this);
104   new pqSpreadSheetVisibilityBehavior(this);
105   new pqPipelineContextMenuBehavior(this);
106   new pqUndoRedoBehavior(this);
107   new pqPluginDockWidgetsBehavior(desk);
108   new pqPluginActionGroupBehavior(desk);
109   new pqPersistentMainWindowStateBehavior(desk);
110   new pqObjectPickingBehavior(desk);
111   new pqCollaborationBehavior(this);
112   new pqViewStreamingBehavior(this);
113
114   pqApplyBehavior* applyBehavior = new pqApplyBehavior(this);
115   foreach (pqPropertiesPanel* ppanel, desk->findChildren<pqPropertiesPanel*>())
116     {
117     applyBehavior->registerPanel(ppanel);
118     }
119
120 }