Version: 6.3.1

src/CAM/CAM_Module.h

Go to the documentation of this file.
00001 // Copyright (C) 2007-2011  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 public slots:
00084   virtual bool           activateModule( SUIT_Study* );
00085   virtual bool           deactivateModule( SUIT_Study* );
00086 
00087   virtual void           connectToStudy( CAM_Study* );
00088 
00089   virtual void           studyClosed( SUIT_Study* );
00090   virtual void           studyChanged( SUIT_Study*, SUIT_Study* );
00091 
00092   virtual void           onApplicationClosed( SUIT_Application* );
00093 
00094 private slots:
00095   void                   onInfoChanged( QString );
00096 
00097 protected: 
00098   virtual bool           isSelectionCompatible();
00099 
00100   virtual CAM_DataModel* createDataModel();
00101 
00102   void                   setName( const QString& );
00103   virtual void           setModuleName( const QString& );
00104 
00105   QtxActionMenuMgr*      menuMgr() const;
00106   QtxActionToolMgr*      toolMgr() const;
00107 
00108   int                    createTool( const QString& );
00109   int                    createTool( const int, const int, const int = -1 );
00110   int                    createTool( const int, const QString&, const int = -1 );
00111   int                    createTool( QAction*, const int, const int = -1, const int = -1 );
00112   int                    createTool( QAction*, const QString&, const int = -1, const int = -1 );
00113 
00114   int                    createMenu( const QString&, const int, const int = -1, const int = -1, const int = -1 );
00115   int                    createMenu( const QString&, const QString&, const int = -1, const int = -1, const int = -1 );
00116   int                    createMenu( const int, const int, const int = -1, const int = -1 );
00117   int                    createMenu( const int, const QString&, const int = -1, const int = -1 );
00118   int                    createMenu( QAction*, const int, const int = -1, const int = -1, const int = -1 );
00119   int                    createMenu( QAction*, const QString&, const int = -1, const int = -1, const int = -1 );
00120 
00121   static QAction*        separator();
00122 
00123   QAction*               action( const int ) const;
00124   int                    actionId( const QAction* ) const;
00125 
00126   int                    registerAction( const int, QAction* );
00127   bool                   unregisterAction( const int );
00128   bool                   unregisterAction( QAction* );
00129   QAction*               createAction( const int, const QString&, const QIcon&, const QString&,
00130                                        const QString&, const int, QObject* = 0,
00131                                        const bool = false, QObject* = 0, const char* = 0, const QString& = QString() );
00132 
00133 private:
00134   CAM_Application*       myApp;             
00135   QString                myName;            
00136   QPixmap                myIcon;            
00137   QString                myInfo;            
00138   CAM_DataModel*         myDataModel;       
00139   QMap<int, QAction*>    myActionMap;       
00140   bool                   myMenuShown;       
00141   bool                   myToolShown;       
00142 
00143   friend class CAM_Application;
00144 };
00145 
00146 #ifdef WIN32
00147 #pragma warning( default: 4251 )
00148 #endif
00149 
00150 extern "C"
00151 {
00152   typedef CAM_Module* (*GET_MODULE_FUNC)();
00153 }
00154 
00155 #define GET_MODULE_NAME "createModule"
00156 
00157 #endif
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS