0029807: [Regression to 7.0.0] Impossible to cut cone from prism
[occt.git] / tools / TreeModel / TreeModel_VisibilityState.hxx
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 TreeModel_VisibilityState_H
17 #define TreeModel_VisibilityState_H
18
19 #include <inspector/TreeModel.hxx>
20 #include <inspector/TreeModel_ModelBase.hxx>
21 #include <inspector/TreeModel_ColumnType.hxx>
22
23 #include <Standard.hxx>
24 #include <Standard_Macro.hxx>
25
26 #include <Standard_WarningsDisable.hxx>
27 #include <QObject>
28 #include <QString>
29 #include <Standard_WarningsRestore.hxx>
30
31 //! \class TreeModel_VisibilityState
32 //! \brief Interface that provides connection between model and visualization control to:
33 //! - know whether the model item is visible
34 //! - change visibility of the model item
35 class TREEMODEL_EXPORT TreeModel_VisibilityState : public QObject
36 {
37   Q_OBJECT
38 public:
39   //! Constructor
40   TreeModel_VisibilityState (TreeModel_ModelBase* theModel) : myModel (theModel) {}
41
42   //! Destructor
43   ~TreeModel_VisibilityState() {}
44
45   //! Returns true if visibility of the item can be changed
46   //! \param theIndex tree model index
47   //! \return boolean value
48   virtual bool CanBeVisible (const QModelIndex& theIndex) const = 0;
49
50   //! Sets visibility state
51   //! \param theIndex tree model index
52   //! \param theState visibility state
53   //! \param toEmitDataChanged boolean flag whether emit of the model should be done immediatelly
54   //! \return true if state is changed
55   virtual bool SetVisible (const QModelIndex& theIndex, const bool theState, const bool toEmitDataChanged = true) = 0;
56
57   //! Returns visibility state value
58   //! \param theIndex tree model index
59   //! \return boolean value
60   virtual bool IsVisible (const QModelIndex& theIndex) const = 0;
61
62 public slots:
63   //! Processes the mouse clicked on the index.
64   //! It changes the item visibility if model allows to change it.
65   //! \theIndex tree model index
66   void OnClicked (const QModelIndex& theIndex);
67
68 signals:
69   //! Signal after OnClicked is performed
70   //! \theIndex tree model index
71   void itemClicked (const QModelIndex& theIndex);
72
73 protected:
74   //! tree view model
75   TreeModel_ModelBase* getModel() const { return myModel; }
76
77 private:
78   TreeModel_ModelBase* myModel; //! tree view model
79 };
80
81 #endif