Salome HOME
refs #430: incorrect coordinates in dump polyline
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_Displayer.h
1 // Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #ifndef HYDROGUI_DISPLAYER_H
24 #define HYDROGUI_DISPLAYER_H
25
26 #include "HYDROGUI_AbstractDisplayer.h"
27
28 #include <QMap>
29 #include <QPoint>
30 #include <vtkNew.h>
31
32 class HYDROGUI_PrsDriver;
33 class SUIT_ViewWindow;
34 class vtkWorldPointPicker;
35
36 /**
37  * \class HYDROGUI_Displayer
38  * \brief Class intended to create, display and update the presentations in 2D graphics viewer.
39  */
40 class HYDROGUI_Displayer : public HYDROGUI_AbstractDisplayer
41 {
42 public:
43   /**
44    * \brief Constructor.
45    * \param theModule module object
46    */
47   HYDROGUI_Displayer( HYDROGUI_Module* theModule );
48
49   /**
50    * \brief Destructor.
51    */
52   virtual ~HYDROGUI_Displayer();
53
54 public:
55   /**
56    * \brief Force the specified objects to be updated.
57    * \param theObjs sequence of objects to update
58    * \param theViewerId viewer identifier
59    */
60   void             SetToUpdate( const HYDROData_SequenceOfObjects& theObjs,
61                                 const int theViewerId );
62
63   /**
64    * \brief Get the applicable viewer type.
65    */
66   virtual QString  GetType() const;
67
68   /*
69    * Get the current cursor view position and save it in the displayer
70    * to be used in the obtaining the view coordinates of the cursor.
71    * \param theViewWindow a view window. If a view window is null, an active view is used
72    * only OCC and VTK views are processed
73    */
74   void             SaveCursorViewPosition( SUIT_ViewWindow* theViewWindow = 0 );
75   /**
76    * \brief Get the coodinates from the view window, projected on XOY plane
77    * \param theViewWindow a view window
78    * \param theXCoordinate a X coordinate
79    * \param theXCoordinate an Y coordinate
80    * \param theXCoordinate a Z coordinate, has a zero value because of the plane
81    * \return true if the coordinates are got
82    */
83   bool             GetCursorViewCoordinates( SUIT_ViewWindow* theViewWindow,
84                                              double& theXCoordinate,
85                                              double& theYCoordinate,
86                                              double& theZCoordinate );
87 protected:
88   /**
89    * \brief Erase all viewer objects.
90    * \param theViewerId viewer identifier
91    */
92   void             EraseAll( const int theViewerId );
93
94   /**
95    * \brief Erase the specified viewer objects.
96    * \param theObjs sequence of objects to erase
97    * \param theViewerId viewer identifier
98    */
99   void             Erase( const HYDROData_SequenceOfObjects& theObjs,
100                           const int theViewerId );
101
102   /**
103    * \brief Display the specified viewer objects.
104    * \param theObjs sequence of objects to display
105    * \param theViewerId viewer identifier
106    * \param theIsForced flag used to update all objects, including the unchanged ones
107    * \param theDoFitAll flag used to fit the view to all visible objects; do not fit by default
108    */
109   void             Display( const HYDROData_SequenceOfObjects& theObjs,
110                             const int theViewerId,
111                             const bool theIsForced,
112                             const bool theDoFitAll );
113
114 protected:
115   /**
116    * \brief Purge all invalid objects in the viewer.
117    * \param theViewerId viewer identifier
118    */
119   void             purgeObjects( const int theViewerId );
120
121 private:
122   /**
123    * \brief Get the presentation driver for the specified data object.
124    * \param theObj data object
125    */
126   HYDROGUI_PrsDriver*             getDriver( const Handle(HYDROData_Entity)& theObj );
127
128 private:
129   typedef QMap< ObjectKind, HYDROGUI_PrsDriver* > PrsDriversMap;
130   PrsDriversMap                   myPrsDriversMap;
131   vtkNew<vtkWorldPointPicker>     myPicker;
132   int                             myXPosition;
133   int                             myYPosition;
134   bool                            myIsPositionSaved;
135 };
136
137 #endif