1 // Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
33 #include <QKeySequence>
40 class QtxActionMenuMgr;
41 class QtxActionToolMgr;
43 class SUIT_Application;
46 class CAM_Application;
49 #pragma warning( disable: 4251 )
52 class CAM_EXPORT CAM_Module : public QObject
58 CAM_Module( const QString& );
59 virtual ~CAM_Module();
61 virtual void initialize( CAM_Application* );
64 QString moduleName() const;
65 virtual QPixmap moduleIcon() const;
66 virtual QString iconName() const;
68 CAM_DataModel* dataModel() const;
69 CAM_Application* application() const;
71 virtual void contextMenuPopup( const QString&, QMenu*, QString& ) {};
72 virtual void updateCommandsStatus() {};
74 virtual void putInfo( const QString&, const int = -1 );
76 int showNotification(const QString& message, const QString& title, int timeout = -1);
77 void hideNotification(const QString& message);
78 void hideNotification(int id);
80 bool isActiveModule() const;
82 virtual void setMenuShown( const bool );
83 void setMenuShown( QAction*, const bool );
84 void setMenuShown( const int, const bool );
86 virtual void setToolShown( const bool );
87 void setToolShown( QAction*, const bool );
88 void setToolShown( const int, const bool );
90 virtual void updateModuleVisibilityState();
92 virtual bool activateOperation( int actionId );
93 virtual bool activateOperation( const QString& actionId );
94 virtual bool activateOperation( const QString& actionId, const QString& pluginName );
96 // actions/menu/toolbars management
98 QtxActionMenuMgr* menuMgr() const;
99 QtxActionToolMgr* toolMgr() const;
101 virtual QAction* action( const int ) const;
102 virtual int actionId( const QAction* ) const;
103 virtual QAction* createAction( const int, const QString&, const QIcon&, const QString&,
104 const QString&, const int, QObject* = 0,
105 const bool = false, QObject* = 0, const char* = 0, const QString& = QString() );
106 virtual QAction* createAction( const int, const QString&, const QIcon&, const QString&,
107 const QString&, const QKeySequence&, QObject* = 0,
108 const bool = false, QObject* = 0, const char* = 0, const QString& = QString() );
109 QtxActionGroup* createActionGroup( const int, const bool = true );
111 int createTool( const QString&, const QString& = QString() );
112 int createTool( const int, const int, const int = -1 );
113 int createTool( const int, const QString&, const int = -1 );
114 int createTool( QAction*, const int, const int = -1, const int = -1 );
115 int createTool( QAction*, const QString&, const int = -1, const int = -1 );
116 void clearTool( const QString& title );
118 int createMenu( const QString&, const int, const int = -1, const int = -1, const int = -1,QMenu * = 0);
119 int createMenu( const QString&, const QString&, const int = -1, const int = -1, const int = -1 );
120 int createMenu( const int, const int, const int = -1, const int = -1 );
121 int createMenu( const int, const QString&, const int = -1, const int = -1 );
122 int createMenu( QAction*, const int, const int = -1, const int = -1, const int = -1 );
123 int createMenu( QAction*, const QString&, const int = -1, const int = -1, const int = -1 );
125 virtual void logAction( QAction* );
126 bool isActionLoggingEnabled() const;
127 void setActionLoggingEnabled( bool );
129 static QAction* separator();
132 virtual bool activateModule( SUIT_Study* );
133 virtual bool deactivateModule( SUIT_Study* );
135 virtual void connectToStudy( CAM_Study* );
137 virtual void studyClosed( SUIT_Study* );
138 virtual void studyChanged( SUIT_Study*, SUIT_Study* );
140 virtual void onApplicationClosed( SUIT_Application* );
142 virtual void moduleActionActivated();
145 void onInfoChanged( QString );
148 virtual bool isSelectionCompatible();
150 virtual CAM_DataModel* createDataModel();
152 void setName( const QString& );
153 virtual void setModuleName( const QString& );
155 int registerAction( const int, QAction* );
156 bool unregisterAction( const int );
157 bool unregisterAction( QAction* );
158 // IMN 05/03/2015: we copied myActionMap for reset/unset actions accelerator keys
159 // after activate/deactivate modules
160 QMap<QAction*, QKeySequence> myActionShortcutMap; //!< copy actions shortcut map
162 virtual bool abortAllOperations();
165 CAM_Application* myApp; //!< parent application object
166 QString myName; //!< module title (user name)
167 QPixmap myIcon; //!< module icon
168 QString myInfo; //!< latest info message
169 CAM_DataModel* myDataModel; //!< data model
170 QMap<int, QAction*> myActionMap; //!< menu actions
171 bool myMenuShown; //!< menu shown flag
172 bool myToolShown; //!< tool shown flag
173 bool myActionLoggingEnabled; //!< action logging enabled
175 friend class CAM_Application;
179 #pragma warning( default: 4251 )
184 typedef CAM_Module* (*GET_MODULE_FUNC)();
185 typedef char* (*GET_VERSION_FUNC)();
188 #define GET_MODULE_NAME "createModule"
189 #define GET_VERSION_NAME "getModuleVersion"