summaryrefslogtreecommitdiff
path: root/src/V3d/V3d_Viewer_4.cxx
blob: dcd80b8bdaaa8c55d7bd047f53ab900b2c4fb912 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
/***********************************************************************
 
     FONCTION :
     ----------
        Classe V3d_Viewer :
 
     HISTORIQUE DES MODIFICATIONS   :
     --------------------------------
      16-07-98 : CAL ; S3892. Ajout grilles 3d.
      22-09-98 : CAL ; Erreur de compilation sur WNT dans V3d_Viewer_4.cxx.

************************************************************************/

#define IMP200100	//GG 
//			-> Add GridDrawMode() method.
//			-> Compute the case Aspect_TDM_None
//			   in ActivateGrid(..)

#define IMP240100	//GG
//			-> Add SetGridEcho() & GridEcho() methods
//			-> Add ShowGridEcho() private method.

#define OCC281          //SAV added new field to store grid echo aspect

/*----------------------------------------------------------------------*/
/*
 * Includes
 */
#include <V3d_Viewer.jxx>

/*----------------------------------------------------------------------*/

Handle(Aspect_Grid) V3d_Viewer::Grid () const {

	if (myGridType == Aspect_GT_Circular)
		return myCGrid;	
	else if (myGridType == Aspect_GT_Rectangular)
		     return myRGrid;
	     else
		     return myRGrid;
}

Aspect_GridType V3d_Viewer::GridType () const {

	return myGridType;
}

#ifdef IMP200100
Aspect_GridDrawMode V3d_Viewer::GridDrawMode () const {

	return Grid()->DrawMode();
}
#endif

void V3d_Viewer::ActivateGrid (const Aspect_GridType aType, const Aspect_GridDrawMode aMode) {

	Grid ()->Erase ();
	myGridType = aType;
	Grid ()->SetDrawMode (aMode);
#ifdef IMP200100
	if( aMode != Aspect_GDM_None ) Grid ()->Display ();
#else
	Grid ()->Display ();
#endif
	Grid ()->Activate ();
	for (InitActiveViews (); MoreActiveViews (); NextActiveViews ()) {
		ActiveView ()->SetGrid (myPrivilegedPlane, Grid ());
#ifndef IMP200100 	//Do nothing more than the previous Grid()->Activate()
		ActiveView ()->SetGridActivity (Standard_True);
#endif
	}
	Update ();
}

void V3d_Viewer::DeactivateGrid () {

	Grid ()->Erase ();
	myGridType = Aspect_GT_Rectangular;
	Grid ()->Deactivate ();
	for (InitActiveViews (); MoreActiveViews (); NextActiveViews ()) {
		ActiveView ()->SetGridActivity (Standard_False);
	}
	Update ();
}

Standard_Boolean V3d_Viewer::IsActive () const {

	return Grid ()->IsActive ();
}

void V3d_Viewer::RectangularGridValues (Quantity_Length& theXOrigin, Quantity_Length& theYOrigin, Quantity_Length& theXStep, Quantity_Length& theYStep, Quantity_PlaneAngle& theRotationAngle) const {

	theXOrigin = myRGrid->XOrigin ();
	theYOrigin = myRGrid->YOrigin ();
	theXStep = myRGrid->XStep ();
	theYStep = myRGrid->YStep ();
	theRotationAngle = myRGrid->RotationAngle ();
}

void V3d_Viewer::SetRectangularGridValues (const Quantity_Length theXOrigin, const Quantity_Length theYOrigin, const Quantity_Length theXStep, const Quantity_Length theYStep, const Quantity_PlaneAngle theRotationAngle) {

	myRGrid->SetGridValues
		(theXOrigin, theYOrigin, theXStep, theYStep, theRotationAngle);
	for (InitActiveViews (); MoreActiveViews (); NextActiveViews ())
		ActiveView ()->SetGrid (myPrivilegedPlane, myRGrid);
	Update ();
}

void V3d_Viewer::CircularGridValues (Quantity_Length& theXOrigin, Quantity_Length& theYOrigin, Quantity_Length& theRadiusStep, Standard_Integer& theDivisionNumber, Quantity_PlaneAngle& theRotationAngle) const {

	theXOrigin = myCGrid->XOrigin ();
	theYOrigin = myCGrid->YOrigin ();
	theRadiusStep = myCGrid->RadiusStep ();
	theDivisionNumber = myCGrid->DivisionNumber ();
	theRotationAngle = myCGrid->RotationAngle ();
}

void V3d_Viewer::SetCircularGridValues (const Quantity_Length theXOrigin, const Quantity_Length theYOrigin, const Quantity_Length theRadiusStep, const Standard_Integer theDivisionNumber, const Quantity_PlaneAngle theRotationAngle) {

	myCGrid->SetGridValues
		(theXOrigin, theYOrigin, theRadiusStep,
		 theDivisionNumber, theRotationAngle);
	for (InitActiveViews (); MoreActiveViews (); NextActiveViews ())
		ActiveView ()->SetGrid (myPrivilegedPlane, myCGrid);
	Update ();
}

void V3d_Viewer::RectangularGridGraphicValues (Quantity_Length& theXSize, Quantity_Length& theYSize, Quantity_Length& theOffSet) const {

	myRGrid->GraphicValues (theXSize, theYSize, theOffSet);
}

void V3d_Viewer::SetRectangularGridGraphicValues (const Quantity_Length theXSize, const Quantity_Length theYSize, const Quantity_Length theOffSet) {

	myRGrid->SetGraphicValues (theXSize, theYSize, theOffSet);
	for (InitActiveViews (); MoreActiveViews (); NextActiveViews ())
		ActiveView ()->SetGridGraphicValues (myRGrid);
	Update ();
}

void V3d_Viewer::CircularGridGraphicValues (Quantity_Length& theRadius, Quantity_Length& theOffSet) const {

	myCGrid->GraphicValues (theRadius, theOffSet);
}

void V3d_Viewer::SetCircularGridGraphicValues (const Quantity_Length theRadius, const Quantity_Length theOffSet) {

	myCGrid->SetGraphicValues (theRadius, theOffSet);
	for (InitActiveViews (); MoreActiveViews (); NextActiveViews ())
		ActiveView ()->SetGridGraphicValues (myCGrid);
	Update ();
}

#ifdef IMP240100
void V3d_Viewer::SetGridEcho( const Standard_Boolean showGrid ) {

  myGridEcho = showGrid; 
}

void V3d_Viewer::SetGridEcho( const Handle(Graphic3d_AspectMarker3d)& aMarker ) {
    if( myGridEchoStructure.IsNull() ) {
      myGridEchoStructure = new Graphic3d_Structure(Viewer());
      myGridEchoGroup = new Graphic3d_Group (myGridEchoStructure);
    }
#ifdef OCC281
    myGridEchoAspect = aMarker;
#endif
    myGridEchoGroup->SetPrimitivesAspect (aMarker);
}

Standard_Boolean V3d_Viewer::GridEcho() const {

  return myGridEcho;
}

#include <Visual3d_TransientManager.hxx>
void V3d_Viewer::ShowGridEcho( const Handle(V3d_View)& aView, 
					const Graphic3d_Vertex& aVertex ) {
  if( myGridEcho ) {
    if( myGridEchoStructure.IsNull() ) {
      myGridEchoStructure = new Graphic3d_Structure(Viewer());
      myGridEchoGroup = new Graphic3d_Group (myGridEchoStructure);
#ifdef OCC281
      myGridEchoAspect = new Graphic3d_AspectMarker3d( Aspect_TOM_STAR, 
                                                       Quantity_Color( Quantity_NOC_GRAY90 ),
                                                       3.0 );
      myGridEchoGroup->SetPrimitivesAspect( myGridEchoAspect );
#else
      Handle(Graphic3d_AspectMarker3d) markerAttrib =
	new Graphic3d_AspectMarker3d(Aspect_TOM_STAR,
		Quantity_Color(Quantity_NOC_GRAY90),3.0);
      myGridEchoGroup->SetPrimitivesAspect (markerAttrib);
#endif
    }

    static Graphic3d_Vertex lastVertex;
    if( Graphic3d_Vertex::Distance(aVertex,lastVertex) != 0.0 ) {
      lastVertex = aVertex;
      myGridEchoGroup->Clear();
#ifdef OCC281
      myGridEchoGroup->SetPrimitivesAspect( myGridEchoAspect );
#endif
      myGridEchoGroup->Marker(aVertex);
      Visual3d_TransientManager::BeginDraw(
		aView->View(), Standard_False, Standard_False);
      Visual3d_TransientManager::DrawStructure (myGridEchoStructure);
      Visual3d_TransientManager::EndDraw (Standard_True);
    }
  }
}
#endif