Back to index

salome-gui  6.5.0
CAM_Module.h
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 #ifndef CAM_MODULE_H
00024 #define CAM_MODULE_H
00025 
00026 #include "CAM.h"
00027 
00028 #include <QObject>
00029 #include <QPixmap>
00030 #include <QString>
00031 #include <QMap>
00032 
00033 class QAction;
00034 class QMenu;
00035 class QIcon;
00036 
00037 class QtxActionMenuMgr;
00038 class QtxActionToolMgr;
00039 class SUIT_Study;
00040 class SUIT_Application;
00041 class CAM_Study;
00042 class CAM_DataModel;
00043 class CAM_Application;
00044 
00045 #ifdef WIN32
00046 #pragma warning( disable: 4251 )
00047 #endif
00048 
00049 class CAM_EXPORT CAM_Module : public QObject
00050 {
00051   Q_OBJECT
00052 
00053 public:
00054   CAM_Module();
00055   CAM_Module( const QString& );
00056   virtual ~CAM_Module();
00057 
00058   virtual void           initialize( CAM_Application* );
00059 
00060   QString                name() const;
00061   QString                moduleName() const;
00062   virtual QPixmap        moduleIcon() const;
00063   virtual QString        iconName() const;
00064 
00065   CAM_DataModel*         dataModel() const;
00066   CAM_Application*       application() const;
00067 
00068   virtual void           contextMenuPopup( const QString&, QMenu*, QString& ) {};
00069   virtual void           updateCommandsStatus() {};
00070 
00071   virtual void           putInfo( const QString&, const int = -1 );
00072 
00073   bool                   isActiveModule() const;
00074 
00075   virtual void           setMenuShown( const bool );
00076   void                   setMenuShown( QAction*, const bool );
00077   void                   setMenuShown( const int, const bool );
00078 
00079   virtual void           setToolShown( const bool );
00080   void                   setToolShown( QAction*, const bool );
00081   void                   setToolShown( const int, const bool );
00082 
00083   virtual void           updateModuleVisibilityState();
00084 
00085 public slots:
00086   virtual bool           activateModule( SUIT_Study* );
00087   virtual bool           deactivateModule( SUIT_Study* );
00088 
00089   virtual void           connectToStudy( CAM_Study* );
00090 
00091   virtual void           studyClosed( SUIT_Study* );
00092   virtual void           studyChanged( SUIT_Study*, SUIT_Study* );
00093 
00094   virtual void           onApplicationClosed( SUIT_Application* );
00095 
00096 private slots:
00097   void                   onInfoChanged( QString );
00098 
00099 protected: 
00100   virtual bool           isSelectionCompatible();
00101 
00102   virtual CAM_DataModel* createDataModel();
00103 
00104   void                   setName( const QString& );
00105   virtual void           setModuleName( const QString& );
00106 
00107   QtxActionMenuMgr*      menuMgr() const;
00108   QtxActionToolMgr*      toolMgr() const;
00109 
00110   int                    createTool( const QString& );
00111   int                    createTool( const int, const int, const int = -1 );
00112   int                    createTool( const int, const QString&, const int = -1 );
00113   int                    createTool( QAction*, const int, const int = -1, const int = -1 );
00114   int                    createTool( QAction*, const QString&, const int = -1, const int = -1 );
00115 
00116   int                    createMenu( const QString&, const int, const int = -1, const int = -1, const int = -1 );
00117   int                    createMenu( const QString&, const QString&, const int = -1, const int = -1, const int = -1 );
00118   int                    createMenu( const int, const int, const int = -1, const int = -1 );
00119   int                    createMenu( const int, const QString&, const int = -1, const int = -1 );
00120   int                    createMenu( QAction*, const int, const int = -1, const int = -1, const int = -1 );
00121   int                    createMenu( QAction*, const QString&, const int = -1, const int = -1, const int = -1 );
00122 
00123   static QAction*        separator();
00124 
00125   QAction*               action( const int ) const;
00126   int                    actionId( const QAction* ) const;
00127 
00128   int                    registerAction( const int, QAction* );
00129   bool                   unregisterAction( const int );
00130   bool                   unregisterAction( QAction* );
00131   QAction*               createAction( const int, const QString&, const QIcon&, const QString&,
00132                                        const QString&, const int, QObject* = 0,
00133                                        const bool = false, QObject* = 0, const char* = 0, const QString& = QString() );
00134 
00135 private:
00136   CAM_Application*       myApp;             
00137   QString                myName;            
00138   QPixmap                myIcon;            
00139   QString                myInfo;            
00140   CAM_DataModel*         myDataModel;       
00141   QMap<int, QAction*>    myActionMap;       
00142   bool                   myMenuShown;       
00143   bool                   myToolShown;       
00144 
00145   friend class CAM_Application;
00146 };
00147 
00148 #ifdef WIN32
00149 #pragma warning( default: 4251 )
00150 #endif
00151 
00152 extern "C"
00153 {
00154   typedef CAM_Module* (*GET_MODULE_FUNC)();
00155   typedef char* (*GET_VERSION_FUNC)();
00156 }
00157 
00158 #define GET_MODULE_NAME "createModule"
00159 #define GET_VERSION_NAME "getModuleVersion"
00160 #endif