1 // Copyright (c) 1999-2012 OPEN CASCADE SAS
3 // The content of this file is subject to the Open CASCADE Technology Public
4 // License Version 6.5 (the "License"). You may not use the content of this file
5 // except in compliance with the License. Please obtain a copy of the License
6 // at http://www.opencascade.org and read it completely before using this file.
8 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
11 // The Original Code and all software distributed under the License is
12 // distributed on an "AS IS" basis, without warranty of any kind, and the
13 // Initial Developer hereby disclaims all such warranties, including without
14 // limitation, any warranties of merchantability, fitness for a particular
15 // purpose or non-infringement. Please see the License for the specific terms
16 // and conditions governing the rights and limitations under the License.
18 /***********************************************************************
24 HISTORIQUE DES MODIFICATIONS :
25 --------------------------------
26 16-07-98 : CAL ; S3892. Ajout grilles 3d.
27 22-09-98 : CAL ; Erreur de compilation sur WNT dans V3d_Viewer_4.cxx.
29 ************************************************************************/
31 #define IMP200100 //GG
32 // -> Add GridDrawMode() method.
33 // -> Compute the case Aspect_TDM_None
34 // in ActivateGrid(..)
36 #define IMP240100 //GG
37 // -> Add SetGridEcho() & GridEcho() methods
38 // -> Add ShowGridEcho() private method.
40 #define OCC281 //SAV added new field to store grid echo aspect
42 /*----------------------------------------------------------------------*/
46 #include <V3d_Viewer.jxx>
48 /*----------------------------------------------------------------------*/
50 Handle(Aspect_Grid) V3d_Viewer::Grid () const {
52 if (myGridType == Aspect_GT_Circular)
54 else if (myGridType == Aspect_GT_Rectangular)
60 Aspect_GridType V3d_Viewer::GridType () const {
66 Aspect_GridDrawMode V3d_Viewer::GridDrawMode () const {
68 return Grid()->DrawMode();
72 void V3d_Viewer::ActivateGrid (const Aspect_GridType aType, const Aspect_GridDrawMode aMode) {
76 Grid ()->SetDrawMode (aMode);
78 if( aMode != Aspect_GDM_None ) Grid ()->Display ();
83 for (InitActiveViews (); MoreActiveViews (); NextActiveViews ()) {
84 ActiveView ()->SetGrid (myPrivilegedPlane, Grid ());
85 #ifndef IMP200100 //Do nothing more than the previous Grid()->Activate()
86 ActiveView ()->SetGridActivity (Standard_True);
92 void V3d_Viewer::DeactivateGrid () {
95 myGridType = Aspect_GT_Rectangular;
96 Grid ()->Deactivate ();
97 for (InitActiveViews (); MoreActiveViews (); NextActiveViews ()) {
98 ActiveView ()->SetGridActivity (Standard_False);
103 Standard_Boolean V3d_Viewer::IsActive () const {
105 return Grid ()->IsActive ();
108 void V3d_Viewer::RectangularGridValues (Quantity_Length& theXOrigin, Quantity_Length& theYOrigin, Quantity_Length& theXStep, Quantity_Length& theYStep, Quantity_PlaneAngle& theRotationAngle) const {
110 theXOrigin = myRGrid->XOrigin ();
111 theYOrigin = myRGrid->YOrigin ();
112 theXStep = myRGrid->XStep ();
113 theYStep = myRGrid->YStep ();
114 theRotationAngle = myRGrid->RotationAngle ();
117 void V3d_Viewer::SetRectangularGridValues (const Quantity_Length theXOrigin, const Quantity_Length theYOrigin, const Quantity_Length theXStep, const Quantity_Length theYStep, const Quantity_PlaneAngle theRotationAngle) {
119 myRGrid->SetGridValues
120 (theXOrigin, theYOrigin, theXStep, theYStep, theRotationAngle);
121 for (InitActiveViews (); MoreActiveViews (); NextActiveViews ())
122 ActiveView ()->SetGrid (myPrivilegedPlane, myRGrid);
126 void V3d_Viewer::CircularGridValues (Quantity_Length& theXOrigin, Quantity_Length& theYOrigin, Quantity_Length& theRadiusStep, Standard_Integer& theDivisionNumber, Quantity_PlaneAngle& theRotationAngle) const {
128 theXOrigin = myCGrid->XOrigin ();
129 theYOrigin = myCGrid->YOrigin ();
130 theRadiusStep = myCGrid->RadiusStep ();
131 theDivisionNumber = myCGrid->DivisionNumber ();
132 theRotationAngle = myCGrid->RotationAngle ();
135 void V3d_Viewer::SetCircularGridValues (const Quantity_Length theXOrigin, const Quantity_Length theYOrigin, const Quantity_Length theRadiusStep, const Standard_Integer theDivisionNumber, const Quantity_PlaneAngle theRotationAngle) {
137 myCGrid->SetGridValues
138 (theXOrigin, theYOrigin, theRadiusStep,
139 theDivisionNumber, theRotationAngle);
140 for (InitActiveViews (); MoreActiveViews (); NextActiveViews ())
141 ActiveView ()->SetGrid (myPrivilegedPlane, myCGrid);
145 void V3d_Viewer::RectangularGridGraphicValues (Quantity_Length& theXSize, Quantity_Length& theYSize, Quantity_Length& theOffSet) const {
147 myRGrid->GraphicValues (theXSize, theYSize, theOffSet);
150 void V3d_Viewer::SetRectangularGridGraphicValues (const Quantity_Length theXSize, const Quantity_Length theYSize, const Quantity_Length theOffSet) {
152 myRGrid->SetGraphicValues (theXSize, theYSize, theOffSet);
153 for (InitActiveViews (); MoreActiveViews (); NextActiveViews ())
154 ActiveView ()->SetGridGraphicValues (myRGrid);
158 void V3d_Viewer::CircularGridGraphicValues (Quantity_Length& theRadius, Quantity_Length& theOffSet) const {
160 myCGrid->GraphicValues (theRadius, theOffSet);
163 void V3d_Viewer::SetCircularGridGraphicValues (const Quantity_Length theRadius, const Quantity_Length theOffSet) {
165 myCGrid->SetGraphicValues (theRadius, theOffSet);
166 for (InitActiveViews (); MoreActiveViews (); NextActiveViews ())
167 ActiveView ()->SetGridGraphicValues (myCGrid);
172 void V3d_Viewer::SetGridEcho( const Standard_Boolean showGrid ) {
174 myGridEcho = showGrid;
177 void V3d_Viewer::SetGridEcho( const Handle(Graphic3d_AspectMarker3d)& aMarker ) {
178 if( myGridEchoStructure.IsNull() ) {
179 myGridEchoStructure = new Graphic3d_Structure(Viewer());
180 myGridEchoGroup = new Graphic3d_Group (myGridEchoStructure);
183 myGridEchoAspect = aMarker;
185 myGridEchoGroup->SetPrimitivesAspect (aMarker);
188 Standard_Boolean V3d_Viewer::GridEcho() const {
193 #include <Visual3d_TransientManager.hxx>
194 void V3d_Viewer::ShowGridEcho( const Handle(V3d_View)& aView,
195 const Graphic3d_Vertex& aVertex ) {
197 if( myGridEchoStructure.IsNull() ) {
198 myGridEchoStructure = new Graphic3d_Structure(Viewer());
199 myGridEchoGroup = new Graphic3d_Group (myGridEchoStructure);
201 myGridEchoAspect = new Graphic3d_AspectMarker3d( Aspect_TOM_STAR,
202 Quantity_Color( Quantity_NOC_GRAY90 ),
204 myGridEchoGroup->SetPrimitivesAspect( myGridEchoAspect );
206 Handle(Graphic3d_AspectMarker3d) markerAttrib =
207 new Graphic3d_AspectMarker3d(Aspect_TOM_STAR,
208 Quantity_Color(Quantity_NOC_GRAY90),3.0);
209 myGridEchoGroup->SetPrimitivesAspect (markerAttrib);
213 static Graphic3d_Vertex lastVertex;
214 if( Graphic3d_Vertex::Distance(aVertex,lastVertex) != 0.0 ) {
215 lastVertex = aVertex;
216 myGridEchoGroup->Clear();
218 myGridEchoGroup->SetPrimitivesAspect( myGridEchoAspect );
220 myGridEchoGroup->Marker(aVertex);
221 Visual3d_TransientManager::BeginDraw(
222 aView->View(), Standard_False, Standard_False);
223 Visual3d_TransientManager::DrawStructure (myGridEchoStructure);
224 Visual3d_TransientManager::EndDraw (Standard_True);