1 // Copyright (C) 2014-2017 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #ifndef XGUI_SALOMECONNECTOR_H
22 #define XGUI_SALOMECONNECTOR_H
27 #include <QStringList>
29 #include <ModuleBase_ActionInfo.h>
32 class Config_FeatureMessage;
33 class ModuleBase_IViewer;
37 * An interface which provides a connection of XGUI functionality
38 * with functionality of SALOME module interface.
40 class XGUI_EXPORT XGUI_SalomeConnector
43 /// Default constructor
44 XGUI_SalomeConnector();
45 /// Virtual destructor
46 virtual ~XGUI_SalomeConnector();
48 //! Creates a feature (command) in SALOME desktop
49 //! \param theWBName - a workbench name
50 //! \param theId - an id of the feature
51 //! \param theTitle - a menu item string
52 //! \param theTip - a tooltip string (help)
53 //! \param theIcon - icon
54 //! \param isCheckable - is checkable or not
55 //! \param theKeys - hot keys
56 //! \param isAddSeparator boolean flag about adding separator after the action
57 //! returns created action
58 virtual QAction* addFeature(const QString& theWBName, const QString& theId,
59 const QString& theTitle, const QString& theTip,
61 const QKeySequence& theKeys, bool isCheckable,
62 const bool isAddSeparator,
63 const QString& theStatusTip) = 0;
65 //! Creates a feature (command) in SALOME desktop
66 //! \param theWBName - name of toolbar (workbench)
67 //! \param theInfo - information about action (icon, text, etc)
68 //! \param isAddSeparator boolean flag about adding separator after the action
69 virtual QAction* addFeature(const QString& theWBName,
70 const ActionInfo& theInfo, const bool isAddSeparator) = 0;
72 //! Creates a feature (command) in SALOME desktop
73 //! \param theWBName - name of toolbar (workbench)
74 //! \param theInfo - information about action (icon, text, etc)
75 //! \param theNestedActions a list of nested actions
76 virtual QAction* addFeatureOfNested(const QString& theWBName,
77 const ActionInfo& theInfo,
78 const QList<QAction*>& theNestedActions) = 0;
80 //! Returns true if the feature action is a nested action, in other words,
81 //! it is created by addFeatureOfNested().
82 //! \param theAction - an action of a feature
83 //! returns boolean result
84 virtual bool isFeatureOfNested(const QAction* theAction) = 0;
86 //! Creates a command in Edit menu of SALOME desktop
87 //! \param theId - an id of the feature
88 //! \param theTitle - a menu item string
89 //! \param theTip - a tooltip string (help)
90 //! \param theIcon - icon
91 //! \param isCheckable - is checkable or not
92 //! \param theKeys - hot keys
93 //! \param theMenuSourceText - a source text of the desktop menu
94 //! \param theMenuPosition - a position of the command in the desktop menu
95 //! returns created action
96 virtual QAction* addDesktopCommand(const QString& theId, const QString& theTitle,
97 const QString& theTip, const QIcon& theIcon,
98 const QKeySequence& theKeys, bool isCheckable,
99 const char* theMenuSourceText,
100 const int theMenuPosition = 10) = 0;
102 //! Insert separator into Edit menu of SALOME desktop
103 virtual void addDesktopMenuSeparator(const char* theMenuSourceText,
104 const int theMenuPosition = 10) = 0;
106 /// Add an action into tool bar
107 /// \param theAction the Action object
108 /// \param theToolBarTitle the toolbar name
109 virtual bool addActionInToolbar( QAction* theAction, const QString& theToolBarTitle ) = 0;
111 /// Creates menu/tool bar actions for loaded features stored in the menu manager
112 virtual void createFeatureActions() = 0;
114 //! Returns desktop window of SALOME
115 virtual QMainWindow* desktop() const = 0;
117 //! Returns list of defined actions (just by SHAPER module)
118 virtual QList<QAction*> commandList() const = 0;
120 //! Stores XML information for the feature kind
121 //! \param theFeatureId a feature kind
122 //! \param theMessage a container of the feature XML properties
123 virtual void setFeatureInfo(const QString& theFeatureId,
124 const std::shared_ptr<Config_FeatureMessage>& theMessage) = 0;
126 //! Returns XML information for the feature kind
127 //! \param theFeatureId a feature kind
128 //! \return theMessage a container of the feature XML properties
129 virtual std::shared_ptr<Config_FeatureMessage> featureInfo(const QString& theFeatureId) = 0;
131 //! Returns interface to Salome viewer
132 virtual ModuleBase_IViewer* viewer() const = 0;
134 //! Create preferences
135 virtual void createPreferences() = 0;
137 //! Shows the given text in status bar as a permanent text
138 //! \theInfo a string value
139 //! \theMsecs interval of msec milliseconds when the message will be hidden, if -1, it stays.
140 // If 0, default value is used, it is 3000
141 virtual void putInfo(const QString& theInfo, const int theMSecs = 0) = 0;