Version: 9.16.0
CAM_Module.h
Go to the documentation of this file.
1// Copyright (C) 2007-2026 CEA, EDF, OPEN CASCADE
2//
3// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5//
6// This library is free software; you can redistribute it and/or
7// modify it under the terms of the GNU Lesser General Public
8// License as published by the Free Software Foundation; either
9// version 2.1 of the License, or (at your option) any later version.
10//
11// This library is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14// Lesser General Public License for more details.
15//
16// You should have received a copy of the GNU Lesser General Public
17// License along with this library; if not, write to the Free Software
18// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19//
20// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21//
22
23#ifndef CAM_MODULE_H
24#define CAM_MODULE_H
25
26#include "CAM.h"
27
28#include <QObject>
29#include <QPixmap>
30#include <QString>
31#include <QMap>
32#include <QPair>
33#include <QKeySequence>
34
35class QAction;
36class QMenu;
37class QIcon;
38
39class QtxActionGroup;
42class SUIT_Study;
44class CAM_Study;
45class CAM_DataModel;
46class CAM_Application;
47
48#ifdef WIN32
49#pragma warning( disable: 4251 )
50#endif
51
53{
54 Q_OBJECT
55
56public:
57 CAM_Module();
58 CAM_Module( const QString& );
59 virtual ~CAM_Module();
60
61 virtual void initialize( CAM_Application* );
62
63 QString name() const;
64 QString moduleName() const;
65 virtual QPixmap moduleIcon() const;
66 virtual QString iconName() const;
67
68 CAM_DataModel* dataModel() const;
69 CAM_Application* application() const;
70
71 virtual void contextMenuPopup( const QString&, QMenu*, QString& ) {};
72 virtual void updateCommandsStatus() {};
73
74 virtual void putInfo( const QString&, const int = -1 );
75
76 int showNotification(const QString& message, const QString& title, int timeout = -1);
77 void hideNotification(const QString& message);
78 void hideNotification(int id);
79
80 bool isActiveModule() const;
81
82 virtual void setMenuShown( const bool );
83 void setMenuShown( QAction*, const bool );
84 void setMenuShown( const int, const bool );
85
86 virtual void setToolShown( const bool );
87 void setToolShown( QAction*, const bool );
88 void setToolShown( const int, const bool );
89
90 virtual void updateModuleVisibilityState();
91
92 virtual bool activateOperation( int actionId );
93 virtual bool activateOperation( const QString& actionId );
94 virtual bool activateOperation( const QString& actionId, const QString& pluginName );
95
96 // actions/menu/toolbars management
97
98 QtxActionMenuMgr* menuMgr() const;
99 QtxActionToolMgr* toolMgr() const;
100
101 QString makeActionID(const QString& theInModuleActionID) const;
102
103 virtual QAction* action( const int ) const;
104 virtual int actionId( const QAction* ) const;
105 virtual QAction* createAction( const int, const QString&, const QIcon&, const QString&,
106 const QString&, const int, QObject* = 0,
107 const bool = false, QObject* = 0, const char* = 0, const QString& = QString() );
108 virtual QAction* createAction( const int, const QString&, const QIcon&, const QString&,
109 const QString&, const QKeySequence&, QObject* = 0,
110 const bool = false, QObject* = 0, const char* = 0, const QString& = QString() );
111 QtxActionGroup* createActionGroup( const int, const bool = true );
112
113 int createTool( const QString&, const QString& = QString() );
114 int createTool( const int, const int, const int = -1 );
115 int createTool( const int, const QString&, const int = -1 );
116 int createTool( QAction*, const int, const int = -1, const int = -1 );
117 int createTool( QAction*, const QString&, const int = -1, const int = -1 );
118 void clearTool( const QString& title );
119
120 int createMenu( const QString&, const int, const int = -1, const int = -1, const int = -1,QMenu * = 0);
121 int createMenu( const QString&, const QString&, const int = -1, const int = -1, const int = -1 );
122 int createMenu( const int, const int, const int = -1, const int = -1 );
123 int createMenu( const int, const QString&, const int = -1, const int = -1 );
124 int createMenu( QAction*, const int, const int = -1, const int = -1, const int = -1 );
125 int createMenu( QAction*, const QString&, const int = -1, const int = -1, const int = -1 );
126
127 virtual void logAction( QAction* );
128 bool isActionLoggingEnabled() const;
129 void setActionLoggingEnabled( bool );
130
131 static QAction* separator();
132
133public slots:
134 virtual bool activateModule( SUIT_Study* );
135 virtual bool deactivateModule( SUIT_Study* );
136
137 virtual void connectToStudy( CAM_Study* );
138
139 virtual void studyClosed( SUIT_Study* );
140 virtual void studyChanged( SUIT_Study*, SUIT_Study* );
141
142 virtual void onApplicationClosed( SUIT_Application* );
143
144 virtual void moduleActionActivated();
145
146private slots:
147 void onInfoChanged( QString );
148
149protected:
150 virtual bool isSelectionCompatible();
151
152 virtual CAM_DataModel* createDataModel();
153
154 void setName( const QString& );
155 virtual void setModuleName( const QString& );
156
157 int registerAction( const int, QAction* );
158 bool unregisterAction( const int );
159 bool unregisterAction( QAction* );
160 // IMN 05/03/2015: we copied myActionMap for reset/unset actions accelerator keys
161 // after activate/deactivate modules
162 QMap<QAction*, QKeySequence> myActionShortcutMap;
163
164 virtual bool abortAllOperations();
165
166private:
168 QString myName;
169 QPixmap myIcon;
170 QString myInfo;
172 QMap<int, QAction*> myActionMap;
176
177 friend class CAM_Application;
178};
179
180#ifdef WIN32
181#pragma warning( default: 4251 )
182#endif
183
184extern "C"
185{
186 typedef CAM_Module* (*GET_MODULE_FUNC)();
187 typedef char* (*GET_VERSION_FUNC)();
188}
189
190#define GET_MODULE_NAME "createModule"
191#define GET_VERSION_NAME "getModuleVersion"
192#endif
#define CAM_EXPORT
Definition: CAM.h:33
Introduces an application class which provides modular architecture.
Definition: CAM_Application.h:39
Base class for all data models used in CAM-based applications.
Definition: CAM_DataModel.h:37
Base implementation of the module in the CAM application architecture.
Definition: CAM_Module.h:53
bool myToolShown
tool shown flag
Definition: CAM_Module.h:174
QPixmap myIcon
module icon
Definition: CAM_Module.h:169
QMap< int, QAction * > myActionMap
menu actions
Definition: CAM_Module.h:172
virtual void contextMenuPopup(const QString &, QMenu *, QString &)
Create context popup menu.
Definition: CAM_Module.h:71
bool myMenuShown
menu shown flag
Definition: CAM_Module.h:173
QMap< QAction *, QKeySequence > myActionShortcutMap
copy actions shortcut map
Definition: CAM_Module.h:162
CAM_Application * myApp
parent application object
Definition: CAM_Module.h:167
CAM_DataModel * myDataModel
data model
Definition: CAM_Module.h:171
virtual void updateCommandsStatus()
Update menu/toolbar actions.
Definition: CAM_Module.h:72
bool myActionLoggingEnabled
action logging enabled
Definition: CAM_Module.h:175
QString myName
module title (user name)
Definition: CAM_Module.h:168
QString myInfo
latest info message
Definition: CAM_Module.h:170
Represents document object in the CAM application architecture.
Definition: CAM_Study.h:38
For more information see QT documentation.
The QtxActionGroup class groups actions together.
Definition: QtxActionGroup.h:36
Main menu actions manager.
Definition: QtxActionMenuMgr.h:43
Toolbar actions manager.
Definition: QtxActionToolMgr.h:44
Definition: SUIT_Application.h:61
Definition: SUIT_Study.h:41