1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 /***********************************************************************
20 HISTORIQUE DES MODIFICATIONS :
21 --------------------------------
22 16-07-98 : CAL ; S3892. Ajout grilles 3d.
23 22-09-98 : CAL ; Erreur de compilation sur WNT dans V3d_Viewer_4.cxx.
25 ************************************************************************/
27 #define IMP200100 //GG
28 // -> Add GridDrawMode() method.
29 // -> Compute the case Aspect_TDM_None
30 // in ActivateGrid(..)
32 #define IMP240100 //GG
33 // -> Add SetGridEcho() & GridEcho() methods
34 // -> Add ShowGridEcho() private method.
36 #define OCC281 //SAV added new field to store grid echo aspect
38 /*----------------------------------------------------------------------*/
42 #include <V3d_Viewer.jxx>
44 /*----------------------------------------------------------------------*/
46 Handle(Aspect_Grid) V3d_Viewer::Grid () const {
48 if (myGridType == Aspect_GT_Circular)
50 else if (myGridType == Aspect_GT_Rectangular)
56 Aspect_GridType V3d_Viewer::GridType () const {
62 Aspect_GridDrawMode V3d_Viewer::GridDrawMode () const {
64 return Grid()->DrawMode();
68 void V3d_Viewer::ActivateGrid (const Aspect_GridType aType, const Aspect_GridDrawMode aMode) {
72 Grid ()->SetDrawMode (aMode);
74 if( aMode != Aspect_GDM_None ) Grid ()->Display ();
79 for (InitActiveViews (); MoreActiveViews (); NextActiveViews ()) {
80 ActiveView ()->SetGrid (myPrivilegedPlane, Grid ());
81 #ifndef IMP200100 //Do nothing more than the previous Grid()->Activate()
82 ActiveView ()->SetGridActivity (Standard_True);
88 void V3d_Viewer::DeactivateGrid () {
91 myGridType = Aspect_GT_Rectangular;
92 Grid ()->Deactivate ();
93 for (InitActiveViews (); MoreActiveViews (); NextActiveViews ()) {
94 ActiveView ()->SetGridActivity (Standard_False);
99 Standard_Boolean V3d_Viewer::IsActive () const {
101 return Grid ()->IsActive ();
104 void V3d_Viewer::RectangularGridValues (Quantity_Length& theXOrigin, Quantity_Length& theYOrigin, Quantity_Length& theXStep, Quantity_Length& theYStep, Quantity_PlaneAngle& theRotationAngle) const {
106 theXOrigin = myRGrid->XOrigin ();
107 theYOrigin = myRGrid->YOrigin ();
108 theXStep = myRGrid->XStep ();
109 theYStep = myRGrid->YStep ();
110 theRotationAngle = myRGrid->RotationAngle ();
113 void V3d_Viewer::SetRectangularGridValues (const Quantity_Length theXOrigin, const Quantity_Length theYOrigin, const Quantity_Length theXStep, const Quantity_Length theYStep, const Quantity_PlaneAngle theRotationAngle) {
115 myRGrid->SetGridValues
116 (theXOrigin, theYOrigin, theXStep, theYStep, theRotationAngle);
117 for (InitActiveViews (); MoreActiveViews (); NextActiveViews ())
118 ActiveView ()->SetGrid (myPrivilegedPlane, myRGrid);
122 void V3d_Viewer::CircularGridValues (Quantity_Length& theXOrigin, Quantity_Length& theYOrigin, Quantity_Length& theRadiusStep, Standard_Integer& theDivisionNumber, Quantity_PlaneAngle& theRotationAngle) const {
124 theXOrigin = myCGrid->XOrigin ();
125 theYOrigin = myCGrid->YOrigin ();
126 theRadiusStep = myCGrid->RadiusStep ();
127 theDivisionNumber = myCGrid->DivisionNumber ();
128 theRotationAngle = myCGrid->RotationAngle ();
131 void V3d_Viewer::SetCircularGridValues (const Quantity_Length theXOrigin, const Quantity_Length theYOrigin, const Quantity_Length theRadiusStep, const Standard_Integer theDivisionNumber, const Quantity_PlaneAngle theRotationAngle) {
133 myCGrid->SetGridValues
134 (theXOrigin, theYOrigin, theRadiusStep,
135 theDivisionNumber, theRotationAngle);
136 for (InitActiveViews (); MoreActiveViews (); NextActiveViews ())
137 ActiveView ()->SetGrid (myPrivilegedPlane, myCGrid);
141 void V3d_Viewer::RectangularGridGraphicValues (Quantity_Length& theXSize, Quantity_Length& theYSize, Quantity_Length& theOffSet) const {
143 myRGrid->GraphicValues (theXSize, theYSize, theOffSet);
146 void V3d_Viewer::SetRectangularGridGraphicValues (const Quantity_Length theXSize, const Quantity_Length theYSize, const Quantity_Length theOffSet) {
148 myRGrid->SetGraphicValues (theXSize, theYSize, theOffSet);
149 for (InitActiveViews (); MoreActiveViews (); NextActiveViews ())
150 ActiveView ()->SetGridGraphicValues (myRGrid);
154 void V3d_Viewer::CircularGridGraphicValues (Quantity_Length& theRadius, Quantity_Length& theOffSet) const {
156 myCGrid->GraphicValues (theRadius, theOffSet);
159 void V3d_Viewer::SetCircularGridGraphicValues (const Quantity_Length theRadius, const Quantity_Length theOffSet) {
161 myCGrid->SetGraphicValues (theRadius, theOffSet);
162 for (InitActiveViews (); MoreActiveViews (); NextActiveViews ())
163 ActiveView ()->SetGridGraphicValues (myCGrid);
168 void V3d_Viewer::SetGridEcho( const Standard_Boolean showGrid ) {
170 myGridEcho = showGrid;
173 void V3d_Viewer::SetGridEcho( const Handle(Graphic3d_AspectMarker3d)& aMarker ) {
174 if( myGridEchoStructure.IsNull() ) {
175 myGridEchoStructure = new Graphic3d_Structure(Viewer());
176 myGridEchoGroup = new Graphic3d_Group (myGridEchoStructure);
179 myGridEchoAspect = aMarker;
181 myGridEchoGroup->SetPrimitivesAspect (aMarker);
184 Standard_Boolean V3d_Viewer::GridEcho() const {
189 #include <Graphic3d_ArrayOfPoints.hxx>
190 #include <Visual3d_TransientManager.hxx>
191 void V3d_Viewer::ShowGridEcho( const Handle(V3d_View)& aView,
192 const Graphic3d_Vertex& aVertex ) {
194 if( myGridEchoStructure.IsNull() ) {
195 myGridEchoStructure = new Graphic3d_Structure(Viewer());
196 myGridEchoGroup = new Graphic3d_Group (myGridEchoStructure);
198 myGridEchoAspect = new Graphic3d_AspectMarker3d( Aspect_TOM_STAR,
199 Quantity_Color( Quantity_NOC_GRAY90 ),
201 myGridEchoGroup->SetPrimitivesAspect( myGridEchoAspect );
203 Handle(Graphic3d_AspectMarker3d) markerAttrib =
204 new Graphic3d_AspectMarker3d(Aspect_TOM_STAR,
205 Quantity_Color(Quantity_NOC_GRAY90),3.0);
206 myGridEchoGroup->SetPrimitivesAspect (markerAttrib);
210 static Graphic3d_Vertex lastVertex;
211 if( aVertex.Distance(lastVertex) != 0.0 ) {
212 lastVertex = aVertex;
213 myGridEchoGroup->Clear();
215 myGridEchoGroup->SetPrimitivesAspect( myGridEchoAspect );
217 Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (1);
218 anArrayOfPoints->AddVertex (aVertex.X(), aVertex.Y(), aVertex.Z());
219 myGridEchoGroup->AddPrimitiveArray (anArrayOfPoints);
221 Visual3d_TransientManager::BeginDraw(
222 aView->View(), Standard_False, Standard_False);
223 Visual3d_TransientManager::DrawStructure (myGridEchoStructure);
224 Visual3d_TransientManager::EndDraw (Standard_True);