Salome HOME
Merge remote-tracking branch 'origin/BR_SHAPE_RECOGNITION' into BR_v14_rc
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_AISTrihedron.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_AISTRIHEDRON_H
21 #define HYDROGUI_AISTRIHEDRON_H
22
23 #include <AIS_Trihedron.hxx>
24 #include <Prs3d_LineAspect.hxx>
25
26 #include <gp_Pnt.hxx>
27 #include <gp_Dir.hxx>
28
29 /**
30  * \class HYDROGUI_AISTrihedron
31  * \brief AIS trihedron is redefined in order to show U text on the OX axis
32  * and Z text on the OY axis.
33  */
34 DEFINE_STANDARD_HANDLE(HYDROGUI_AISTrihedron, AIS_Trihedron)
35
36 class HYDROGUI_AISTrihedron : public AIS_Trihedron
37 {
38 public:
39   /**
40    * The struct to contain axis parameters. Save them in order to do not extract them
41    * on each compute call
42    */
43   struct AxisParameters
44   {
45     gp_Pnt myPfirst; // the first point of the axis
46     gp_Pnt myPlast;  // the last point of the axis
47     Standard_Real myVal; // the axis length
48     Handle(Prs3d_LineAspect) myLineAspect; // the line aspect
49     gp_Dir myDir; // the axis direction
50     Standard_CString myText; // the axis text. This is the main parameter,
51                              // that leads to the trihedron redefine
52   };
53
54 public:
55   HYDROGUI_AISTrihedron( const Handle(Geom_Axis2Placement)& thePlacement );
56
57   ~HYDROGUI_AISTrihedron() {}
58
59   /**
60    * The static method to create filled trihedron. It makes some additional settings
61    * to the trihedron: resize and set color to the axis
62    */
63   static Handle(AIS_Trihedron) createTrihedron( double theSize );
64
65   /**
66    * Updates the internal axis parameters. Should be called after the axis parameters change
67    * e.g. axis resize
68    */
69   void SetAxis2Placement();
70
71   /**
72    * AIS trihedron compute method. It removes the parent compute functionality.
73    * It add to the presentation only oX, oY axis with the corrected text, that contains
74    * "U"/"Z" labels
75    * \param thePresentationManager the prs manager
76    * \param thePresentationManager the presentation
77    * \param theMode the mode
78    */
79   void Compute( const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
80                 const Handle(Prs3d_Presentation)& thePresentation, 
81                 const Standard_Integer theMode);
82
83   /**
84    * AIS trihedron compute method. It is empty. We do not apply the transformation.
85    * \param thePresentationManager the prs manager
86    * \param theTransformation the transformation
87    * \param thePresentationManager the presentation
88    */
89   void Compute( const Handle_Prs3d_Projector& theProjector,
90                 const Handle_Geom_Transformation& theTransformation,
91                 const Handle_Prs3d_Presentation& thePresentation );
92
93   /**
94    * AIS trihedron compute selection method. It is empty. We do not select the trihedron
95    * \param theSelection the selection
96    * \param theMode the mode
97    */
98   void ComputeSelection( const Handle(SelectMgr_Selection)& theSelection,
99                          const Standard_Integer theMode );
100
101 private:
102   /**
103    * It adds the presentation to the DsgPrs_XYZAxisPresentation. It should be called in
104    * compute for displayed axis
105    * \param thePresentation the 3D presentation
106    * \param theParams the axis params, such as text, direction, stand and last points
107    */
108   void ComputeAxis( const Handle(Prs3d_Presentation)& thePresentation,
109                     const AxisParameters& theParams );
110   void ComputeFields();
111
112   AxisParameters myUParams; // the parameters for U axis
113   AxisParameters myZParams; // the parameters for Z axis
114 };
115
116
117 #endif