1 // Copyright (C) 2014-2019 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 email : webmaster.salome@opencascade.com
20 #ifndef XGUI_SALOMECONNECTOR_H
21 #define XGUI_SALOMECONNECTOR_H
26 #include <QStringList>
28 #include <ModuleBase_ActionInfo.h>
31 class Config_FeatureMessage;
32 class ModuleBase_IViewer;
36 * An interface which provides a connection of XGUI functionality
37 * with functionality of SALOME module interface.
39 class XGUI_EXPORT XGUI_SalomeConnector
42 /// Default constructor
43 XGUI_SalomeConnector();
44 /// Virtual destructor
45 virtual ~XGUI_SalomeConnector();
47 //! Creates a feature (command) in SALOME desktop
48 //! \param theWBName - a workbench name
49 //! \param theTBName - a toolbar 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& theTBName,
60 const QString& theTitle, const QString& theTip,
62 const QKeySequence& theKeys, bool isCheckable,
63 const bool isAddSeparator,
64 const QString& theStatusTip) = 0;
66 //! Creates a feature (command) in SALOME desktop
67 //! \param theWBName - name of toolbar (workbench)
68 //! \param theInfo - information about action (icon, text, etc)
69 //! \param isAddSeparator boolean flag about adding separator after the action
70 virtual QAction* addFeature(const QString& theWBName,
71 const ActionInfo& theInfo, const bool isAddSeparator) = 0;
73 //! Creates a feature (command) in SALOME desktop
74 //! \param theWBName - name of toolbar (workbench)
75 //! \param theInfo - information about action (icon, text, etc)
76 //! \param theNestedActions a list of nested actions
77 virtual QAction* addFeatureOfNested(const QString& theWBName,
78 const ActionInfo& theInfo,
79 const QList<QAction*>& theNestedActions) = 0;
81 //! Returns true if the feature action is a nested action, in other words,
82 //! it is created by addFeatureOfNested().
83 //! \param theAction - an action of a feature
84 //! returns boolean result
85 virtual bool isFeatureOfNested(const QAction* theAction) = 0;
87 //! Creates a command in Edit menu of SALOME desktop
88 //! \param theId - an id of the feature
89 //! \param theTitle - a menu item string
90 //! \param theTip - a tooltip string (help)
91 //! \param theIcon - icon
92 //! \param isCheckable - is checkable or not
93 //! \param theKeys - hot keys
94 //! \param theMenuSourceText - a source text of the desktop menu
95 //! \param theMenuPosition - a position of the command in the desktop menu
96 //! returns created action
97 virtual QAction* addDesktopCommand(const QString& theId, const QString& theTitle,
98 const QString& theTip, const QIcon& theIcon,
99 const QKeySequence& theKeys, bool isCheckable,
100 const char* theMenuSourceText,
101 const int theMenuPosition = 10) = 0;
103 //! Insert separator into Edit menu of SALOME desktop
104 virtual void addDesktopMenuSeparator(const char* theMenuSourceText,
105 const int theMenuPosition = 10) = 0;
107 /// Add an action into tool bar
108 /// \param theAction the Action object
109 /// \param theToolBarTitle the toolbar name
110 virtual bool addActionInToolbar( QAction* theAction, const QString& theToolBarTitle ) = 0;
112 /// Creates menu/tool bar actions for loaded features stored in the menu manager
113 virtual void createFeatureActions() = 0;
115 //! Returns desktop window of SALOME
116 virtual QMainWindow* desktop() const = 0;
118 //! Returns list of defined actions (just by SHAPER module)
119 virtual QList<QAction*> commandList() const = 0;
121 //! Stores XML information for the feature kind
122 //! \param theFeatureId a feature kind
123 //! \param theMessage a container of the feature XML properties
124 virtual void setFeatureInfo(const QString& theFeatureId,
125 const std::shared_ptr<Config_FeatureMessage>& theMessage) = 0;
127 //! Returns XML information for the feature kind
128 //! \param theFeatureId a feature kind
129 //! \return theMessage a container of the feature XML properties
130 virtual std::shared_ptr<Config_FeatureMessage> featureInfo(const QString& theFeatureId) = 0;
132 //! Returns interface to Salome viewer
133 virtual ModuleBase_IViewer* viewer() const = 0;
135 //! Create preferences
136 virtual void createPreferences() = 0;
138 //! Shows the given text in status bar as a permanent text
139 //! \theInfo a string value
140 //! \theMsecs interval of msec milliseconds when the message will be hidden, if -1, it stays.
141 // If 0, default value is used, it is 3000
142 virtual void putInfo(const QString& theInfo, const int theMSecs = 0) = 0;