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