1 // Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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, or (at your option) any later version.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include "HYDROGUI_AISTrihedron.h"
25 #include <Geom_Axis2Placement.hxx>
26 #include <Prs3d_DatumAspect.hxx>
27 #include <Prs3d_LineAspect.hxx>
28 #include <Prs3d_Presentation.hxx>
29 #include <AIS_Drawer.hxx>
30 #include <DsgPrs_XYZAxisPresentation.hxx>
33 HYDROGUI_AISTrihedron::HYDROGUI_AISTrihedron( const Handle(Geom_Axis2Placement)& thePlacement )
34 : AIS_Trihedron(thePlacement)
39 Handle(AIS_Trihedron) HYDROGUI_AISTrihedron::createTrihedron( double theSize )
41 Handle(Geom_Axis2Placement) anAxis = new Geom_Axis2Placement( gp::XOY() );
42 Handle(HYDROGUI_AISTrihedron) aTrihedron = new HYDROGUI_AISTrihedron( anAxis );
43 aTrihedron->SetInfiniteState( Standard_True );
45 Quantity_Color aCol( 193/255., 205/255., 193/255., Quantity_TOC_RGB );
46 aTrihedron->SetArrowColor( aCol.Name() );
47 aTrihedron->SetSize( theSize );
49 Handle(AIS_Drawer) aDrawer = aTrihedron->Attributes();
50 if ( aDrawer->HasDatumAspect() ) {
51 Handle(Prs3d_DatumAspect) aDaspect = aDrawer->DatumAspect();
52 aDaspect->FirstAxisAspect()->SetColor( Quantity_Color( 1.0, 0.0, 0.0, Quantity_TOC_RGB ) );
53 aDaspect->SecondAxisAspect()->SetColor( Quantity_Color( 0.0, 1.0, 0.0, Quantity_TOC_RGB ) );
54 aDaspect->ThirdAxisAspect()->SetColor( Quantity_Color( 0.0, 0.0, 1.0, Quantity_TOC_RGB ) );
56 aTrihedron->SetAxis2Placement();
60 void HYDROGUI_AISTrihedron::SetAxis2Placement()
65 void HYDROGUI_AISTrihedron::Compute( const Handle(PrsMgr_PresentationManager3d)& /*thePresentationManager*/,
66 const Handle(Prs3d_Presentation)& thePresentation,
67 const Standard_Integer theMode)
69 thePresentation->Clear();
70 thePresentation->SetInfiniteState( Standard_True );
72 ComputeAxis(thePresentation, myUParams);
73 ComputeAxis(thePresentation, myZParams);
76 void HYDROGUI_AISTrihedron::ComputeAxis( const Handle(Prs3d_Presentation)& thePresentation,
77 const AxisParameters& theParams )
79 DsgPrs_XYZAxisPresentation::Add( thePresentation, theParams.myLineAspect,
80 myDrawer->ArrowAspect(), myDrawer->TextAspect(),
81 theParams.myDir, theParams.myVal, theParams.myText,
82 theParams.myPfirst, theParams.myPlast );
85 void HYDROGUI_AISTrihedron::Compute(const Handle_Prs3d_Projector& aProjector,
86 const Handle_Geom_Transformation& aTransformation,
87 const Handle_Prs3d_Presentation& aPresentation)
91 void HYDROGUI_AISTrihedron::ComputeSelection( const Handle(SelectMgr_Selection)& aSelection,
92 const Standard_Integer aMode )
96 void HYDROGUI_AISTrihedron::ComputeFields()
98 gp_Ax2 anAx2 = Component()->Ax2();
100 Handle(Prs3d_DatumAspect) DA = myDrawer->DatumAspect();
101 gp_Pnt Orig = anAx2.Location();
102 Quantity_Length xo,yo,zo,x,y,z;
103 Orig.Coord(xo,yo,zo);
105 gp_Dir oX = anAx2.XDirection();
107 myUParams.myPfirst.SetCoord(xo,yo,zo);
108 myUParams.myVal = DA->FirstAxisLength();
109 myUParams.myDir = oX;
110 myUParams.myText = "U";
111 myUParams.myLineAspect = DA->FirstAxisAspect();
112 x = xo + x*myUParams.myVal;
113 y = yo + y*myUParams.myVal;
114 z = zo + z*myUParams.myVal;
115 myUParams.myPlast.SetCoord(x,y,z);
117 gp_Dir oY = anAx2.YDirection();
119 myZParams.myPfirst.SetCoord(xo,yo,zo);
120 myZParams.myVal = DA->SecondAxisLength();
121 myZParams.myDir = oY;
122 myZParams.myText = "Z";
123 myZParams.myLineAspect = DA->SecondAxisAspect();
124 x = xo + x*myZParams.myVal;
125 y = yo + y*myZParams.myVal;
126 z = zo + z*myZParams.myVal;
127 myZParams.myPlast.SetCoord(x,y,z);