Salome HOME
Merge branch 'BR_v14_rc' of ssh://git.salome-platform.org/modules/hydro into BR_v14_rc
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_OCCDisplayer.h
1 // Copyright (C) 2014-2015  EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
6 //
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
10 // Lesser General Public License for more details.
11 //
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
15 //
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
17 //
18
19 #ifndef HYDROGUI_OCCDISPLAYER_H
20 #define HYDROGUI_OCCDISPLAYER_H
21
22 #include "HYDROGUI_AbstractDisplayer.h"
23
24 class HYDROGUI_Shape;
25 class Handle(AIS_InteractiveContext);
26 class OCCViewer_ViewManager;
27 class OCCViewer_Viewer;
28
29 /**
30  * \class HYDROGUI_OCCDisplayer
31  * \brief Class intended to create, display and update the presentations on OCC viewer.
32  */
33 class HYDROGUI_OCCDisplayer : public HYDROGUI_AbstractDisplayer
34 {
35 public:
36   /**
37    * \brief Constructor.
38    * \param theModule module object
39    */
40   HYDROGUI_OCCDisplayer( HYDROGUI_Module* theModule );
41
42   /**
43    * \brief Destructor.
44    */
45   virtual ~HYDROGUI_OCCDisplayer();
46
47 public:
48   /**
49    * \brief Force the specified objects to be updated.
50    * \param theObjs sequence of objects to update
51    * \param theViewerId viewer identifier
52    */
53   void                            SetToUpdate( const HYDROData_SequenceOfObjects& theObjs,
54                                                const int theViewerId );
55
56   /**
57    * \brief Get the applicable viewer type.
58    */
59   virtual QString  GetType() const;
60
61   /**
62    * \brief Add the z layer for preview and returns its index.
63    * \param theMgr OCC view manager
64    */
65   int                             AddPreviewZLayer( OCCViewer_ViewManager* theMgr );
66
67   /**
68    * \brief Removes the z layer.
69    * \param theMgr OCC view manager
70    * \param theLayer a layer index
71    */
72   void                            RemoveZLayer( OCCViewer_ViewManager* theMgr,
73                                                 const int theLayer );
74
75   void SetToUpdateColorScale();
76
77 protected:
78   /**
79    * \brief Erase all viewer objects.
80    * \param theViewerId viewer identifier
81    */
82   void                            EraseAll( const int theViewerId );
83
84   /**
85    * \brief Erase the specified viewer objects.
86    * \param theObjs sequence of objects to erase
87    * \param theViewerId viewer identifier
88    */
89   void                            Erase( const HYDROData_SequenceOfObjects& theObjs,
90                                          const int theViewerId );
91
92   /**
93    * \brief Display the specified viewer objects.
94    * \param theObjs sequence of objects to display
95    * \param theViewerId viewer identifier
96    * \param theIsForced flag used to update all objects, including the unchanged ones
97    * \param theDoFitAll flag used to fit the view to all visible objects; do not fit by default
98    */
99   void                            Display( const HYDROData_SequenceOfObjects& theObjs,
100                                            const int theViewerId,
101                                            const bool theIsForced,
102                                            const bool theDoFitAll );
103
104 protected:
105   /**
106    * \brief Purge all invalid objects in the viewer.
107    * \param theViewerId viewer identifier
108    */
109   void                            purgeObjects( const int theViewerId );
110
111   void UpdateColorScale( const OCCViewer_Viewer* );
112   
113 private:
114   /**
115    * \brief Creates new OCC shape.
116    * \param theViewerId viewer identifier
117    * \param theContext context of OCC viewer
118    * \param theObject data model object
119    * \return pointer to new created shape
120    */
121   HYDROGUI_Shape*                 createShape( const int                             theViewerId,
122                                                const Handle(AIS_InteractiveContext)& theContext,
123                                                const Handle(HYDROData_Entity)&       theObject );
124
125    /**
126    * \brief Display the specified object.
127    * \param theObject the object to display
128    * \param theViewer the viewer for displaying
129    * \param theIsForced the flag used to update the object shape
130    * \return true in case of success
131    */
132   bool                            Display( const Handle(HYDROData_Entity)& theObject,
133                                            const OCCViewer_Viewer* theViewer,
134                                            const bool theIsForced );
135
136    /**
137    * \brief Set Z layer to the shape corresponding to the HYDRO data object.
138    * \param theViewer the viewer for Z layer setting
139    * \param theObject the HYDRO object
140    * \param theZLayerId the Z layer ID
141    */
142   void                            SetZLayer( const OCCViewer_Viewer* theViewer,
143                                              const Handle(HYDROData_Entity)& theObject, 
144                                              const int theZLayerId );
145
146 private:
147   bool myToUpdateColorScale;
148 };
149
150 #endif
151