1 // Copyright (C) 2011-2012 CEA/DEN, EDF R&D, OPEN CASCADE
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Guillaume Boulant (EDF)
21 #ifndef _STANDARDAPP_MODULE_HXX_
22 #define _STANDARDAPP_MODULE_HXX_
24 #include <SUIT_ResourceMgr.h>
25 #include <SalomeApp_Module.h>
27 #include <SALOMEconfig.h>
28 #include CORBA_SERVER_HEADER(SALOME_Component)
33 * This class is provided as the base class for the standard gui part
34 * of a SALOME module. To define a gui part, you just have to
35 * implement the virtual functions:
36 * - getEngine() to specify the engine component associated to this module
37 * - createModuleActions(...) to specify the action functions
38 * - createModuleWidgets(...) to specify special additionnal widgets
40 * The gui part of a SALOME module is an extension of the SALOME
41 * client Application for this module. Technically speaking, it
42 * consists in a plugin that provides a derived class of CAM_Module
43 * (provided by the GUI module).
45 * A standard gui is the standard design for most of SALOME module
46 * (object browser on the left, viewer on the rigth, python console on
47 * the bottom, and toolbox in the toolbar with standard definition of
48 * the tool function). This standard design suggests also to specify
49 * the engine associated to the module by implementing the virtual
50 * pure function getEngine(). The engine of a module is the SALOME
51 * component that is associated to the study component for this
52 * module, and generally which is responsible for the persistency
53 * functions or data management for the module.
55 * See a use case example in the test module Xsalome provided by the
56 * test package (tst/module/gui/Xsalome.hxx and
57 * tst/module/gui/factory.cxx in the XSALOME library).
59 class StandardApp_Module: public SalomeApp_Module
65 // ================================================================
66 // This part defines the standard interface of the SalomeApp_Module
67 // ================================================================
70 void initialize( CAM_Application* );
71 QString engineIOR() const;
72 virtual void windows( QMap<int, int>& theMap ) const;
75 bool deactivateModule( SUIT_Study* );
76 bool activateModule( SUIT_Study* );
78 // ================================================================
79 // This part defines the specific interface of this class
80 // ================================================================
83 /* Creates an action with standard default values */
84 int createStandardAction(const QString& label,
86 const char* slotmember,
87 const QString& iconName=QString(),
88 const QString& tooltip=QString(),
89 const int identifier=ACTIONID_UNDEFINED);
91 void addActionInToolbar(int actionId);
92 void addActionInMenubar(int actionId);
93 void addActionInPopupMenu(int actionId,const QString& rule="client='ObjectBrowser'");
96 /* Implement this to create additionnal widget (e.g. docked widget) */
97 virtual void createModuleWidgets();
98 /* Implement this to define the actions for this gui */
99 virtual void createModuleActions();
101 /* Use this to create a root entry in the study for this module */
102 void createStudyComponent(SUIT_Study*);
103 /* Implement this to say if study component entry should be created
104 at activation step */
105 virtual bool createStudyComponentAtActivation();
107 /* The engine is the SALOME component associated to the study */
108 virtual Engines::EngineComponent_ptr getEngine() const = 0;
109 // Note that the function getEngine() is virtual pure and must be
110 // implemented in the specific inherited classes. Note also that the
111 // const flag is required because getEngine is used by functions
112 // with const flags (see for ex: engineIOR()).
113 virtual QString studyIconName();
115 QIcon createIcon(const QString& iconName);
118 enum DockLayoutType {
119 DOCKLAYOUT_BOTTOM_HLARGE, // Bottom is Horizontal Large
120 DOCKLAYOUT_LEFT_VLARGE, // Left is Vertical Large
122 virtual void setDockLayout(DockLayoutType layoutType);
123 virtual void unsetDockLayout();
125 SUIT_ResourceMgr* _resourceMgr;
127 int _defaultToolbarId;
129 static int ACTIONID_DEFAULT_INIT_VALUE;
130 static int ACTIONID_UNDEFINED;
133 int _actionId_internalCount;
134 Qt::DockWidgetArea _areaAtBottomLeftCorner;
135 Qt::DockWidgetArea _areaAtBottomRightCorner;
137 // =========================================================
138 // This part defines slots for test purposes
139 // =========================================================