Salome HOME
Merge branch 'master' of newgeom:newgeom
[modules/shaper.git] / src / NewGeom / NewGeom_Module.h
1
2 #ifndef NewGeom_Module_H
3 #define NewGeom_Module_H
4
5 #include "NewGeom.h"
6 #include "NewGeom_SalomeViewer.h"
7
8 #include <LightApp_Module.h>
9 #include <XGUI_SalomeConnector.h>
10
11 #include <QStringList>
12 #include <QMap>
13
14 class XGUI_Workshop;
15 class NewGeom_OCCSelector;
16 class OCCViewer_Viewer;
17
18 /** 
19  * An implementation of SALOME connector class for implementation of
20  * XGUI functionality as a module of SALOME
21  */
22 class NewGeom_EXPORT NewGeom_Module : public LightApp_Module, public XGUI_SalomeConnector
23 {
24 Q_OBJECT
25  public:
26   NewGeom_Module();
27   virtual ~NewGeom_Module();
28
29   //----- LightAPP_Module interface ---------------
30   virtual void initialize(CAM_Application* theApp);
31   virtual void windows(QMap<int, int>& theWndMap) const;
32   virtual void viewManagers(QStringList& theList) const;
33   virtual void selectionChanged();
34
35   //--- XGUI connector interface -----
36   virtual QAction* addFeature(const QString& theWBName, const QString& theId,
37                               const QString& theTitle, const QString& theTip, const QIcon& theIcon,
38                               const QKeySequence& theKeys = QKeySequence(),
39                               bool isCheckable = false);
40
41   virtual QAction* addDesktopCommand(const QString& theId, const QString& theTitle,
42                                      const QString& theTip, const QIcon& theIcon,
43                                      const QKeySequence& theKeys, bool isCheckable,
44                                      const char* theMenuSourceText,
45                                      const int theMenuPosition = 10);
46
47   virtual void addDesktopMenuSeparator(const char* theMenuSourceText,
48                                        const int theMenuPosition = 10);
49
50   virtual QMainWindow* desktop() const;
51
52   virtual QString commandId(const QAction* theCmd) const;
53
54   virtual QAction* command(const QString& theId) const;
55
56   //! Set nested actions dependent on command Id
57   //! \param theId - the command ID
58   //! \param theActions - the list of nested actions
59   virtual void setNestedActions(const QString& theId, const QStringList& theActions);
60
61   //! Returns list of nested actions according to the given command ID
62   virtual QStringList nestedActions(const QString& theId) const;
63
64   //! Set the document kind of the action by the given command Id
65   //! \param theId - the command ID
66   //! \param theKind - the document kind
67   virtual void setDocumentKind(const QString& theId, const QString& theKind);
68
69   //! Returns the document kind of the action by the given command ID
70   virtual QString documentKind(const QString& theId) const;
71
72   //! Returns interface to Salome viewer
73   virtual ModuleBase_IViewer* viewer() const
74   {
75     return myProxyViewer;
76   }
77
78   //! Returns list of defined actions (just by NewGeom module)
79   virtual QList<QAction*> commandList() const;
80
81   //! Returns list of Ids of defined actions (just by NewGeom module)
82   virtual QStringList commandIdList() const;
83
84   virtual void contextMenuPopup(const QString& theClient, QMenu* theMenu, QString& theTitle);
85
86   virtual void createPreferences();
87   virtual void preferencesChanged(const QString& theSection, const QString& theParam);
88
89   XGUI_Workshop* workshop() const { return myWorkshop; }
90
91   void setIsOpened(bool theOpened) { myIsOpened = theOpened; }
92
93  public slots:
94   virtual bool activateModule(SUIT_Study* theStudy);
95   virtual bool deactivateModule(SUIT_Study* theStudy);
96
97  protected slots:
98   virtual void onViewManagerAdded(SUIT_ViewManager* theMgr);
99   void onDefaultPreferences();
100
101  protected:
102   CAM_DataModel* createDataModel();
103   virtual QtxPopupMgr* popupMgr();
104
105  private:
106   NewGeom_OCCSelector* createSelector(SUIT_ViewManager* theMgr);
107
108   QStringList myActionsList;
109
110   XGUI_Workshop* myWorkshop;
111
112   NewGeom_OCCSelector* mySelector;
113
114   NewGeom_SalomeViewer* myProxyViewer;
115
116   QMap<QString, QStringList> myNestedActions;
117   QMap<QString, QString> myDocumentType;
118
119   bool myIsOpened;
120   bool myIsStorePositions;
121
122   QtxPopupMgr* myPopupMgr;
123 };
124
125 #endif