]> SALOME platform Git repositories - modules/gui.git/blob - src/GuiHelpers/StandardApp_Module.hxx
Salome HOME
Merge from V6_main 01/04/2013
[modules/gui.git] / src / GuiHelpers / StandardApp_Module.hxx
1 // Copyright (C) 2011-2013  CEA/DEN, EDF R&D, 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.
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 : Guillaume Boulant (EDF) 
20
21 #ifndef _STANDARDAPP_MODULE_HXX_
22 #define _STANDARDAPP_MODULE_HXX_
23
24 #include <SUIT_ResourceMgr.h>
25 #include <SalomeApp_Module.h>
26
27 #include <SALOMEconfig.h>
28 #include CORBA_SERVER_HEADER(SALOME_Component)
29
30 #include <QString>
31
32 #include "SalomeGuiHelpers.hxx"
33
34 /*!
35  * This class is provided as the base class for the standard gui part
36  * of a SALOME module. To define a gui part, you just have to
37  * implement the virtual functions:
38  * - getEngine() to specify the engine component associated to this module
39  * - createModuleActions(...) to specify the action functions
40  * - createModuleWidgets(...) to specify special additionnal widgets
41  *
42  * The gui part of a SALOME module is an extension of the SALOME
43  * client Application for this module. Technically speaking, it
44  * consists in a plugin that provides a derived class of CAM_Module
45  * (provided by the GUI module).
46  *
47  * A standard gui is the standard design for most of SALOME module
48  * (object browser on the left, viewer on the rigth, python console on
49  * the bottom, and toolbox in the toolbar with standard definition of
50  * the tool function). This standard design suggests also to specify
51  * the engine associated to the module by implementing the virtual
52  * pure function getEngine(). The engine of a module is the SALOME
53  * component that is associated to the study component for this
54  * module, and generally which is responsible for the persistency
55  * functions or data management for the module.
56  *
57  * See a use case example in the test module Xsalome provided by the
58  * test package (tst/module/gui/Xsalome.hxx and
59  * tst/module/gui/factory.cxx in the XSALOME library).
60  */
61 class SALOMEGUIHELPERS_EXPORT StandardApp_Module: public SalomeApp_Module
62 {
63   Q_OBJECT
64
65 public:
66
67   // ================================================================
68   // This part defines the standard interface of the SalomeApp_Module
69   // ================================================================
70
71   StandardApp_Module();
72   void    initialize( CAM_Application* );
73   QString engineIOR() const;
74   virtual void  windows( QMap<int, int>& theMap ) const;
75
76 public slots:
77   bool    deactivateModule( SUIT_Study* );
78   bool    activateModule( SUIT_Study* );
79
80   // ================================================================
81   // This part defines the specific interface of this class
82   // ================================================================
83
84 public:
85   /* Creates an action with standard default values */
86   int createStandardAction(const QString& label,
87                            QObject * slotobject,
88                            const char* slotmember,
89                            const QString& iconName=QString(),
90                            const QString& tooltip=QString(),
91                            const int identifier=ACTIONID_UNDEFINED);
92
93   void addActionInToolbar(int actionId);
94   void addActionInMenubar(int actionId);
95   void addActionInPopupMenu(int actionId,const QString& rule="client='ObjectBrowser'");
96
97 protected:
98   /* Implement this to create additionnal widget (e.g. docked widget) */
99   virtual void createModuleWidgets();
100   /* Implement this to define the actions for this gui */
101   virtual void createModuleActions();
102
103   /* Use this to create a root entry in the study for this module */
104   void createStudyComponent(SUIT_Study*);
105   /* Implement this to say if study component entry should be created
106      at activation step */
107   virtual bool createStudyComponentAtActivation();
108
109   /* The engine is the SALOME component associated to the study */
110   virtual Engines::EngineComponent_ptr getEngine() const = 0;
111   // Note that the function getEngine() is virtual pure and must be
112   // implemented in the specific inherited classes. Note also that the
113   // const flag is required because getEngine is used by functions
114   // with const flags (see for ex: engineIOR()).
115   virtual QString studyIconName();
116
117   QIcon createIcon(const QString& iconName);
118   int newActionId();
119
120   enum DockLayoutType {
121     DOCKLAYOUT_BOTTOM_HLARGE, // Bottom is Horizontal Large
122     DOCKLAYOUT_LEFT_VLARGE,   // Left is Vertical Large
123   };
124   virtual void setDockLayout(DockLayoutType layoutType);
125   virtual void unsetDockLayout();
126   
127   SUIT_ResourceMgr* _resourceMgr;
128   int _defaultMenuId;
129   int _defaultToolbarId;
130
131   static int ACTIONID_DEFAULT_INIT_VALUE;
132   static int ACTIONID_UNDEFINED;
133
134 private:
135   int _actionId_internalCount;
136   Qt::DockWidgetArea _areaAtBottomLeftCorner;
137   Qt::DockWidgetArea _areaAtBottomRightCorner;
138
139   // =========================================================
140   // This part defines slots for test purposes
141   // =========================================================
142
143 protected slots:
144   void OnTest();
145 };
146
147 #endif