src/CAM/CAM_Module.h

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