Salome HOME
Merge branch 'abn/paravis_rearch'
[modules/gui.git] / src / PVViewer / PVViewer_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 "PVViewer_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 #include <pqPropertiesPanel.h>
54
55 int PVViewer_Behaviors::BehaviorLoadingLevel = 0;
56
57 PVViewer_Behaviors::PVViewer_Behaviors(SUIT_Desktop * parent)
58   : QObject(static_cast<QObject *>(parent))
59 {
60 }
61
62 /**! Instanciate minimal ParaView behaviors needed when using an instance of PVViewer.
63  * This method should be updated at each new version of ParaView with what is found in
64  *    Qt/ApplicationComponents/pqParaViewBehaviors.cxx
65  */
66 void PVViewer_Behaviors::instanciateMinimalBehaviors(SUIT_Desktop * desk)
67 {
68   if (BehaviorLoadingLevel < 1)
69     {
70       // Register ParaView interfaces.
71       pqInterfaceTracker* pgm = pqApplicationCore::instance()->interfaceTracker();
72
73       // Register standard types of property widgets.
74       pgm->addInterface(new pqStandardPropertyWidgetInterface(pgm));
75       // Register standard types of view-frame actions.
76       pgm->addInterface(new pqStandardViewFrameActionsImplementation(pgm));
77
78       // Load plugins distributed with application.
79       pqApplicationCore::instance()->loadDistributedPlugins();
80
81       new pqDefaultViewBehavior(this);  // shows a 3D view as soon as a server connection is made
82       new pqAlwaysConnectedBehavior(this);  // client always connected to a server
83       new pqAutoLoadPluginXMLBehavior(this);  // auto load plugins
84       new pqVerifyRequiredPluginBehavior(this);
85       new pqPluginSettingsBehavior(this);
86       new pqFixPathsInStateFilesBehavior(this);
87       new pqCrashRecoveryBehavior(this);
88       new pqCommandLineOptionsBehavior(this);
89
90       BehaviorLoadingLevel = 1;
91     }
92 }
93
94 /**! Instanciate usual ParaView behaviors.
95  * This method should be updated at each new version of ParaView with what is found in
96  *    Qt/ApplicationComponents/pqParaViewBehaviors.cxx
97  */
98 void PVViewer_Behaviors::instanciateAllBehaviors(SUIT_Desktop * desk)
99 {
100   //    "new pqParaViewBehaviors(anApp->desktop(), this);"
101   // -> (which loads all standard ParaView behaviors at once) has to be replaced in order to
102   // exclude using of pqQtMessageHandlerBehaviour
103
104   // Define application behaviors.
105   if (BehaviorLoadingLevel < 1)
106     instanciateMinimalBehaviors(desk);
107
108   if (BehaviorLoadingLevel < 2)
109     {
110       //new pqQtMessageHandlerBehavior(this);   // THIS ONE TO EXCLUDE !! see comment above
111       new pqDataTimeStepBehavior(this);
112       new pqSpreadSheetVisibilityBehavior(this);
113       new pqPipelineContextMenuBehavior(this);
114       new pqUndoRedoBehavior(this);
115       new pqPluginDockWidgetsBehavior(desk);
116       new pqPluginActionGroupBehavior(desk);
117       new pqPersistentMainWindowStateBehavior(desk);
118       new pqObjectPickingBehavior(desk);
119       new pqCollaborationBehavior(this);
120       new pqViewStreamingBehavior(this);
121
122       pqApplyBehavior* applyBehavior = new pqApplyBehavior(this);
123       foreach (pqPropertiesPanel* ppanel, desk->findChildren<pqPropertiesPanel*>())
124       {
125         applyBehavior->registerPanel(ppanel);
126       }
127       BehaviorLoadingLevel = 2;
128     }
129 }