Salome HOME
updated copyright message
[modules/gui.git] / src / PVViewer / PVViewer_Behaviors.cxx
1 // Copyright (C) 2014-2023  CEA, EDF, OPEN CASCADE
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 <QMainWindow>
24
25 #include <pqInterfaceTracker.h>
26 #include <pqApplicationCore.h>
27 #include <pqPluginManager.h>
28 #include <pqStandardPropertyWidgetInterface.h>
29 #include <pqStandardViewFrameActionsImplementation.h>
30 #include <pqPropertiesPanel.h>
31
32 #include <pqAlwaysConnectedBehavior.h>
33 #include <pqAutoLoadPluginXMLBehavior.h>
34 #include <pqCommandLineOptionsBehavior.h>
35 #include <pqCrashRecoveryBehavior.h>
36 #include <pqDataTimeStepBehavior.h>
37 #include <pqDefaultViewBehavior.h>
38 #include <pqObjectPickingBehavior.h>
39 #include <pqPipelineContextMenuBehavior.h>
40 #include <pqPluginActionGroupBehavior.h>
41 #include <pqPluginDockWidgetsBehavior.h>
42 #include <pqSpreadSheetVisibilityBehavior.h>
43 #include <pqUndoRedoBehavior.h>
44 #include <pqViewStreamingBehavior.h>
45 #include <pqCollaborationBehavior.h>
46 #include <pqVerifyRequiredPluginBehavior.h>
47 #include <pqPluginSettingsBehavior.h>
48 #include <pqApplyBehavior.h>
49
50 #include <pqPropertiesPanel.h>
51
52 int PVViewer_Behaviors::BehaviorLoadingLevel = 0;
53
54 PVViewer_Behaviors::PVViewer_Behaviors(QMainWindow * parent)
55   : QObject(parent)
56 {
57 }
58
59 /**! Instanciate minimal ParaView behaviors needed when using an instance of PVViewer.
60  * This method should be updated at each new version of ParaView with what is found in
61  *    Qt/ApplicationComponents/pqParaViewBehaviors.cxx
62  */
63 void PVViewer_Behaviors::instanciateMinimalBehaviors(QMainWindow * /*desk*/)
64 {
65   if (BehaviorLoadingLevel < 1)
66     {
67       // Register ParaView interfaces.
68       pqInterfaceTracker* pgm = pqApplicationCore::instance()->interfaceTracker();
69
70       // Register standard types of property widgets.
71       pgm->addInterface(new pqStandardPropertyWidgetInterface(pgm));
72       // Register standard types of view-frame actions.
73       pgm->addInterface(new pqStandardViewFrameActionsImplementation(pgm));
74
75       new pqPipelineContextMenuBehavior(this);
76       new pqDefaultViewBehavior(this);  // shows a 3D view as soon as a server connection is made
77       new pqAlwaysConnectedBehavior(this);  // client always connected to a server
78       new pqVerifyRequiredPluginBehavior(this);
79       new pqPluginSettingsBehavior(this);
80       new pqCrashRecoveryBehavior(this);
81       new pqCommandLineOptionsBehavior(this);
82
83       BehaviorLoadingLevel = 1;
84     }
85 }
86
87 /**! Instanciate usual ParaView behaviors.
88  * This method should be updated at each new version of ParaView with what is found in
89  *    Qt/ApplicationComponents/pqParaViewBehaviors.cxx
90  */
91 void PVViewer_Behaviors::instanciateAllBehaviors(QMainWindow * desk)
92 {
93   //    "new pqParaViewBehaviors(anApp->desktop(), this);"
94   // -> (which loads all standard ParaView behaviors at once) has to be replaced in order to
95   // exclude using of pqQtMessageHandlerBehaviour
96
97   // Define application behaviors.
98   if (BehaviorLoadingLevel < 1)
99     instanciateMinimalBehaviors(desk);
100
101   if (BehaviorLoadingLevel < 2)
102     {
103       //new pqQtMessageHandlerBehavior(this);   // THIS ONE TO EXCLUDE !! see comment above
104       new pqDataTimeStepBehavior(this);
105       new pqSpreadSheetVisibilityBehavior(this);
106       //new pqPipelineContextMenuBehavior(this);
107       new pqUndoRedoBehavior(this);
108       new pqAutoLoadPluginXMLBehavior(this);  // auto load plugins GUI stuff
109       new pqPluginDockWidgetsBehavior(desk);
110       new pqPluginActionGroupBehavior(desk);
111       // rnv: Disable ParaView main window persistance mechanism,
112       //      because SALOME has own functionality for store/restore windows state.
113       //  new pqPersistentMainWindowStateBehavior(desk);
114       new pqObjectPickingBehavior(desk);
115       new pqCollaborationBehavior(this);
116       new pqViewStreamingBehavior(this);
117
118       // Move instantiation of the pqApplyBehavior to the PVViewer_GUIElements::buildPVWidgets(),
119       // because without pqPropertiesPanel it doesn't make sense.      
120       /*
121       pqApplyBehavior* applyBehavior = new pqApplyBehavior(this);
122       foreach (pqPropertiesPanel* ppanel, desk->findChildren<pqPropertiesPanel*>())
123       {
124         applyBehavior->registerPanel(ppanel);
125       }
126       */
127       BehaviorLoadingLevel = 2;
128     }
129 }