Salome HOME
Edit arc by dragging
[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  public slots:
96   virtual bool activateModule(SUIT_Study* theStudy);
97   virtual bool deactivateModule(SUIT_Study* theStudy);
98
99  protected slots:
100   virtual void onViewManagerAdded(SUIT_ViewManager* theMgr);
101   void onDefaultPreferences();
102   // Obtains the current application and updates its actions
103   void onUpdateCommandStatus();
104
105  protected:
106   CAM_DataModel* createDataModel();
107   virtual QtxPopupMgr* popupMgr();
108
109  private:
110   NewGeom_OCCSelector* createSelector(SUIT_ViewManager* theMgr);
111
112   QStringList myActionsList;
113
114   XGUI_Workshop* myWorkshop;
115
116   NewGeom_OCCSelector* mySelector;
117
118   NewGeom_SalomeViewer* myProxyViewer;
119
120   QMap<QString, QStringList> myNestedActions;
121   QMap<QString, QString> myDocumentType;
122
123   bool myIsOpened;
124   // the next parameters should be restored after this module deactivation
125   bool myIsStorePositions; // the application value of the preferences parameter
126   bool myIsEditEnabled;    // the application value
127
128   QtxPopupMgr* myPopupMgr;
129 };
130
131 #endif