Salome HOME
Merge branch 'BR_LAND_COVER_MAP' into BR_quadtree
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_Displayer.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
20 #ifndef HYDROGUI_DISPLAYER_H
21 #define HYDROGUI_DISPLAYER_H
22
23 #include "HYDROGUI_AbstractDisplayer.h"
24
25 #include <QMap>
26 #include <QPoint>
27 #include <vtkNew.h>
28
29 class HYDROGUI_PrsDriver;
30 class SUIT_ViewWindow;
31 class vtkWorldPointPicker;
32
33 /**
34  * \class HYDROGUI_Displayer
35  * \brief Class intended to create, display and update the presentations in 2D graphics viewer.
36  */
37 class HYDROGUI_Displayer : public HYDROGUI_AbstractDisplayer
38 {
39 public:
40   /**
41    * \brief Constructor.
42    * \param theModule module object
43    */
44   HYDROGUI_Displayer( HYDROGUI_Module* theModule );
45
46   /**
47    * \brief Destructor.
48    */
49   virtual ~HYDROGUI_Displayer();
50
51 public:
52   /**
53    * \brief Force the specified objects to be updated.
54    * \param theObjs sequence of objects to update
55    * \param theViewerId viewer identifier
56    */
57   void             SetToUpdate( const HYDROData_SequenceOfObjects& theObjs,
58                                 const int theViewerId );
59
60   /**
61    * \brief Get the applicable viewer type.
62    */
63   virtual QString  GetType() const;
64
65   /*
66    * Get the current cursor view position and save it in the displayer
67    * to be used in the obtaining the view coordinates of the cursor.
68    * \param theViewWindow a view window. If a view window is null, an active view is used
69    * only OCC and VTK views are processed
70    */
71   void             SaveCursorViewPosition( SUIT_ViewWindow* theViewWindow = 0 );
72   /**
73    * \brief Get the coodinates from the view window, projected on XOY plane
74    * \param theViewWindow a view window
75    * \param theXCoordinate a X coordinate
76    * \param theXCoordinate an Y coordinate
77    * \param theXCoordinate a Z coordinate, has a zero value because of the plane
78    * \return true if the coordinates are got
79    */
80   bool             GetCursorViewCoordinates( SUIT_ViewWindow* theViewWindow,
81                                              double& theXCoordinate,
82                                              double& theYCoordinate,
83                                              double& theZCoordinate );
84 protected:
85   /**
86    * \brief Erase all viewer objects.
87    * \param theViewerId viewer identifier
88    */
89   void             EraseAll( const int theViewerId );
90
91   /**
92    * \brief Erase the specified viewer objects.
93    * \param theObjs sequence of objects to erase
94    * \param theViewerId viewer identifier
95    */
96   void             Erase( const HYDROData_SequenceOfObjects& theObjs,
97                           const int theViewerId );
98
99   /**
100    * \brief Display the specified viewer objects.
101    * \param theObjs sequence of objects to display
102    * \param theViewerId viewer identifier
103    * \param theIsForced flag used to update all objects, including the unchanged ones
104    * \param theDoFitAll flag used to fit the view to all visible objects; do not fit by default
105    */
106   void             Display( const HYDROData_SequenceOfObjects& theObjs,
107                             const int theViewerId,
108                             const bool theIsForced,
109                             const bool theDoFitAll );
110
111 protected:
112   /**
113    * \brief Purge all invalid objects in the viewer.
114    * \param theViewerId viewer identifier
115    */
116   void             purgeObjects( const int theViewerId );
117
118 private:
119   /**
120    * \brief Get the presentation driver for the specified data object.
121    * \param theObj data object
122    */
123   HYDROGUI_PrsDriver*             getDriver( const Handle(HYDROData_Entity)& theObj );
124
125 private:
126   typedef QMap< ObjectKind, HYDROGUI_PrsDriver* > PrsDriversMap;
127   PrsDriversMap                   myPrsDriversMap;
128   vtkNew<vtkWorldPointPicker>     myPicker;
129   int                             myXPosition;
130   int                             myYPosition;
131   bool                            myIsPositionSaved;
132 };
133
134 #endif