0031939: Coding - correction of spelling errors in comments [part 2]
[occt.git] / tools / View / View_ToolBar.hxx
CommitLineData
14bbbdcb 1// Created on: 2017-06-16
2// Created by: Natalia ERMOLAEVA
3// Copyright (c) 2017 OPEN CASCADE SAS
4//
5// This file is part of Open CASCADE Technology software library.
6//
7// This library is free software; you can redistribute it and/or modify it under
8// the terms of the GNU Lesser General Public License version 2.1 as published
9// by the Free Software Foundation, with special exception defined in the file
10// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11// distribution for complete text of the license and disclaimer of any warranty.
12//
13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
15
16#ifndef View_ToolBar_H
17#define View_ToolBar_H
18
19#include <AIS_InteractiveContext.hxx>
20#include <Standard.hxx>
0cb512c0 21#include <inspector/View_ContextType.hxx>
22#include <inspector/View_ToolActionType.hxx>
14bbbdcb 23
130eb114 24#include <Standard_WarningsDisable.hxx>
14bbbdcb 25#include <QObject>
26#include <QMap>
130eb114 27#include <Standard_WarningsRestore.hxx>
14bbbdcb 28
29class QComboBox;
30class QToolButton;
31class QWidget;
32
33//! \class View_ToolBar
34//! \brief This is a container of the next view actions:
35//! - selection of interactive context
36//! - actions of View_ToolActionType enumeration
37//!
38//! It contains container of possible interactive contexts where the presentations may be visualized
39//! and choice control to select an active context.
40//! If action is clicked, a signal about is sent.
41class View_ToolBar : public QObject
42{
43 Q_OBJECT
44
45public:
46 //! Constructor
6822a3be 47 Standard_EXPORT View_ToolBar (QWidget* theParent, const bool isUseKeepView = true);
14bbbdcb 48
49 //! Destructor
7e1c1e48 50 virtual ~View_ToolBar() {}
14bbbdcb 51
52 //! \returns parent widget of actions
53 QWidget* GetControl() const { return myMainWindow; }
54
7e1c1e48 55 //! Appends context for the given type
14bbbdcb 56 //! \param theType a context type
57 //! \param theContext a context
58 Standard_EXPORT void SetContext (View_ContextType theType, const Handle(AIS_InteractiveContext)& theContext);
59
60 //! \returns type of active item of context selector
7e1c1e48 61 Standard_EXPORT View_ContextType CurrentContextType() const;
62
63 //! Sets current context type
64 //! \param theType a context type
65 Standard_EXPORT void SetCurrentContextType (View_ContextType theType);
66
67 //! Sets default context type
68 //! \param theType a context type
69 void SetDefaultContextType (const View_ContextType theType) { myDefaultContextType = (int)theType; }
14bbbdcb 70
71 //! \returns an active context of context selector
7e1c1e48 72 Standard_EXPORT Handle(AIS_InteractiveContext) CurrentContext() const;
14bbbdcb 73
74 //! \returns whether the action is checked(toggled). Acceptable only if the action is checkable.
75 Standard_EXPORT bool IsActionChecked (const int theActionId) const;
76
7e1c1e48 77 //! Saves state of tool bar actions
78 //! \param theToolBar a view instance
79 //! \param theItems [out] properties
a110c4a3 80 //! \param thePrefix preference item prefix
7e1c1e48 81 Standard_EXPORT static void SaveState (View_ToolBar* theToolBar,
82 QMap<QString, QString>& theItems,
83 const QString& thePrefix = QString());
84 //! Restores state of tool bar actions
85 //! \param theToolBar a view instance
86 //! \param theKey property key
87 //! \param theValue property value
a110c4a3 88 //! \param thePrefix preference item prefix
7e1c1e48 89 //! \return boolean value whether the property is applied to the tree view
90 Standard_EXPORT static bool RestoreState (View_ToolBar* theToolBar,
91 const QString& theKey, const QString& theValue,
92 const QString& thePrefix = QString());
93
14bbbdcb 94signals:
95
96 //! Signal about click on action of View_ToolActionType enumeration
97 void actionClicked (int theActionId);
98
99 //! Signal about selection of context
100 void contextChanged();
101
102private slots:
103
104 //! Processes clicked action and emit signal with action identifier
105 void onActionClicked();
106
107private:
108
109 QWidget* myMainWindow; //!< tool bar parent widget
110 QComboBox* myViewSelector; //!< container of possible contexts
7e1c1e48 111 int myDefaultContextType; //!< type of context read from preferences
14bbbdcb 112
113 QMap<View_ToolActionType, QToolButton*> myActionsMap; //!< tool actions
114 QMap<View_ContextType, Handle(AIS_InteractiveContext)> myViewContexts; //!< contexts
115 QMap<View_ContextType, QString> myViewContextNames; //!< names of contexts
116};
117
118#endif