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.
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.
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
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include "HYDROGUI_AISTrihedron.h"
21 #include <Geom_Axis2Placement.hxx>
22 #include <Prs3d_DatumAspect.hxx>
23 #include <Prs3d_LineAspect.hxx>
24 #include <Prs3d_Presentation.hxx>
25 #include <Prs3d_Drawer.hxx>
26 #include <DsgPrs_XYZAxisPresentation.hxx>
29 HYDROGUI_AISTrihedron::HYDROGUI_AISTrihedron( const Handle(Geom_Axis2Placement)& thePlacement )
30 : AIS_Trihedron(thePlacement)
35 Handle(AIS_Trihedron) HYDROGUI_AISTrihedron::createTrihedron( double theSize )
37 Handle(Geom_Axis2Placement) anAxis = new Geom_Axis2Placement( gp::XOY() );
38 Handle(HYDROGUI_AISTrihedron) aTrihedron = new HYDROGUI_AISTrihedron( anAxis );
39 aTrihedron->SetInfiniteState( Standard_True );
41 Quantity_Color aCol( 193/255., 205/255., 193/255., Quantity_TOC_RGB );
42 aTrihedron->SetArrowColor( aCol.Name() );
43 aTrihedron->SetSize( theSize );
45 Handle(Prs3d_Drawer) aDrawer = aTrihedron->Attributes();
46 if ( aDrawer->HasOwnDatumAspect() ) {
47 Handle(Prs3d_DatumAspect) aDaspect = aDrawer->DatumAspect();
48 aDaspect->FirstAxisAspect()->SetColor( Quantity_Color( 1.0, 0.0, 0.0, Quantity_TOC_RGB ) );
49 aDaspect->SecondAxisAspect()->SetColor( Quantity_Color( 0.0, 1.0, 0.0, Quantity_TOC_RGB ) );
50 aDaspect->ThirdAxisAspect()->SetColor( Quantity_Color( 0.0, 0.0, 1.0, Quantity_TOC_RGB ) );
53 aTrihedron->SetAxis2Placement();
57 void HYDROGUI_AISTrihedron::SetAxis2Placement()
62 void HYDROGUI_AISTrihedron::Compute( const Handle(PrsMgr_PresentationManager3d)& /*thePresentationManager*/,
63 const Handle(Prs3d_Presentation)& thePresentation,
64 const Standard_Integer theMode)
66 thePresentation->Clear();
67 thePresentation->SetInfiniteState( Standard_True );
69 ComputeAxis(thePresentation, myUParams);
70 ComputeAxis(thePresentation, myZParams);
73 void HYDROGUI_AISTrihedron::ComputeAxis( const Handle(Prs3d_Presentation)& thePresentation,
74 const AxisParameters& theParams )
76 DsgPrs_XYZAxisPresentation::Add( thePresentation, theParams.myLineAspect,
77 myDrawer->ArrowAspect(), myDrawer->TextAspect(),
78 theParams.myDir, theParams.myVal, theParams.myText,
79 theParams.myPfirst, theParams.myPlast );
82 void HYDROGUI_AISTrihedron::Compute(const Handle(Prs3d_Projector)& aProjector,
83 const Handle(Geom_Transformation)& aTransformation,
84 const Handle(Prs3d_Presentation)& aPresentation)
88 void HYDROGUI_AISTrihedron::ComputeSelection( const Handle(SelectMgr_Selection)& aSelection,
89 const Standard_Integer aMode )
93 void HYDROGUI_AISTrihedron::ComputeFields()
95 gp_Ax2 anAx2 = Component()->Ax2();
97 Handle(Prs3d_DatumAspect) DA = myDrawer->DatumAspect();
98 gp_Pnt Orig = anAx2.Location();
99 Quantity_Length xo,yo,zo,x,y,z;
100 Orig.Coord(xo,yo,zo);
102 gp_Dir oX = anAx2.XDirection();
104 myUParams.myPfirst.SetCoord(xo,yo,zo);
105 myUParams.myVal = DA->FirstAxisLength();
106 myUParams.myDir = oX;
107 myUParams.myText = "U";
108 myUParams.myLineAspect = DA->FirstAxisAspect();
109 x = xo + x*myUParams.myVal;
110 y = yo + y*myUParams.myVal;
111 z = zo + z*myUParams.myVal;
112 myUParams.myPlast.SetCoord(x,y,z);
114 gp_Dir oY = anAx2.YDirection();
116 myZParams.myPfirst.SetCoord(xo,yo,zo);
117 myZParams.myVal = DA->SecondAxisLength();
118 myZParams.myDir = oY;
119 myZParams.myText = "Z";
120 myZParams.myLineAspect = DA->SecondAxisAspect();
121 x = xo + x*myZParams.myVal;
122 y = yo + y*myZParams.myVal;
123 z = zo + z*myZParams.myVal;
124 myZParams.myPlast.SetCoord(x,y,z);