1 // Created on: 2017-06-16
2 // Created by: Natalia ERMOLAEVA
3 // Copyright (c) 2017 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef ShapeView_VisibilityState_H
17 #define ShapeView_VisibilityState_H
19 #include <inspector/TreeModel_VisibilityState.hxx>
21 #include <inspector/View_Displayer.hxx>
23 #include <Standard.hxx>
24 #include <Standard_Macro.hxx>
25 #include <TopoDS_Shape.hxx>
27 class TreeModel_ModelBase;
29 //! \class ShapeView_VisibilityState
30 //! \brief Class provides connection between model and visualization control
31 class ShapeView_VisibilityState : public QObject, public TreeModel_VisibilityState
36 ShapeView_VisibilityState (TreeModel_ModelBase* theModel) : TreeModel_VisibilityState (theModel),
37 myPresentationType (View_PresentationType_Main) {}
40 ~ShapeView_VisibilityState() {}
42 //! Sets current displayer
43 //! \theDisplayer class that provides connection to visualized objects
44 void SetDisplayer (View_Displayer* theDisplayer) { myDisplayer = theDisplayer; }
46 //! Sets presentation type for displayer
47 //! \param theType type value
48 void SetPresentationType (const View_PresentationType theType) { myPresentationType = theType; }
50 //! Returns true if visibility of the item can be changed
51 //! \param theIndex tree model index
52 //! \return boolean value
53 virtual bool CanBeVisible (const QModelIndex& theIndex) const Standard_OVERRIDE { return !Shape (theIndex).IsNull(); }
55 //! Sets visibility state
56 //! \theIndex tree model index
57 //! \param theState visibility state
58 //! \param toEmitDataChanged boolean flag whether emit of the model should be done immediately
59 //! \return true if state is changed
60 Standard_EXPORT virtual bool SetVisible (const QModelIndex& theIndex, const bool theState, const bool toEmitDataChanged) Standard_OVERRIDE;
62 //! Returns visibility state value
63 virtual bool IsVisible (const QModelIndex& theIndex) const Standard_OVERRIDE
64 { return myDisplayer->IsVisible (Shape (theIndex), myPresentationType); }
67 //! Processes the mouse clicked on the index.
68 //! It changes the item visibility if model allows to change it.
69 //! \theIndex tree model index
70 void OnClicked (const QModelIndex& theIndex);
73 //! Signal after OnClicked is performed
74 //! \theIndex tree model index
75 void itemClicked (const QModelIndex& theIndex);
78 //! Gets shape of the view model by the parameter index if it has a shape
79 //! \param theIndex tree model index
80 //! \return shape instance
81 TopoDS_Shape Shape (const QModelIndex& theIndex) const;
84 View_Displayer* myDisplayer; //!< view displayer
85 View_PresentationType myPresentationType; //!< presentation type