summaryrefslogtreecommitdiff
path: root/src/V3d/V3d_Viewer_3.cxx
blob: b2af02988aadcb497eee094c25a2cadd5ede7812 (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
/***********************************************************************
 
     FONCTION :
     ----------
        Classe V3d_Viewer_3.cxx :
 
     HISTORIQUE DES MODIFICATIONS   :
     --------------------------------
      00-09-92 : GG  ; Creation.
      27-12-98 : FMN ; PERF: OPTIMISATION LOADER (LOPTIM)

     REMARQUES :
     -----------
 
************************************************************************/

#define IMP240300	//GG 
//			-> Remove the grid plane axis when it is requested.
//			-> Redraw the privilegied grid plane after any change

/*----------------------------------------------------------------------*/
/*
 * Includes
 */

#include <V3d_Viewer.jxx>

#include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_AspectText3d.hxx>
#include <gp_Dir.hxx>
#include <gp_Pnt.hxx>
#include <Graphic3d_Structure.hxx>
#include <Graphic3d_Group.hxx>

#include <Graphic3d_Array1OfVertex.hxx>

/*----------------------------------------------------------------------*/
/*
 * Static variable
 */

#define LOPTIM
#ifndef LOPTIM
static TCollection_AsciiString XLetter("X");
static TCollection_AsciiString YLetter("Y");
static TCollection_AsciiString ZLetter("Z");
#else 
static TCollection_AsciiString _XLetter() {
    static TCollection_AsciiString XLetter("X");
return XLetter;
}
#define XLetter _XLetter()

static TCollection_AsciiString _YLetter() {
    static TCollection_AsciiString YLetter("Y");
return YLetter;
}
#define YLetter _YLetter()

static TCollection_AsciiString _ZLetter() {
    static TCollection_AsciiString ZLetter("Z");
return ZLetter;
}
#define ZLetter _ZLetter()

#endif // LOPTIM

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

void V3d_Viewer::SetPrivilegedPlane(const gp_Ax3& aPlane) {
  myPrivilegedPlane = aPlane;
#ifdef IMP240300
  Grid()->SetDrawMode(Grid()->DrawMode());
  for (InitActiveViews (); MoreActiveViews (); NextActiveViews ()) {
    ActiveView ()->SetGrid (myPrivilegedPlane, Grid ());
  }
#endif
  if(myDisplayPlane) {
    Standard_Real s = myDisplayPlaneLength;
    DisplayPrivilegedPlane(Standard_True,s);
#ifdef IMP240300	
  } else {
    Update();
#else
    Update();
#endif
  }
}

/*----------------------------------------------------------------------*/
gp_Ax3  V3d_Viewer::PrivilegedPlane() const {
  return myPrivilegedPlane;
    
}

/*----------------------------------------------------------------------*/
void V3d_Viewer::DisplayPrivilegedPlane(const Standard_Boolean OnOff, const Quantity_Length aSize) {
  Standard_Boolean Change =  myDisplayPlane != OnOff;
  myDisplayPlane = OnOff;
  myDisplayPlaneLength = aSize;

  if(myDisplayPlane) {
    if(myPlaneStructure.IsNull()) {
      myPlaneStructure = new Graphic3d_Structure(MyViewer);
      myPlaneStructure->SetInfiniteState(Standard_True);
      myPlaneStructure->Display();
    }
    else
      myPlaneStructure->Clear();
    
//    Handle(Graphic3d_Structure) thePlaneStructure = new Graphic3d_Structure(MyViewer);
    Handle(Graphic3d_Group) Group = new Graphic3d_Group(myPlaneStructure) ;

    Handle(Graphic3d_AspectLine3d) LineAttrib = new Graphic3d_AspectLine3d() ;
    LineAttrib->SetColor(Quantity_Color(Quantity_NOC_GRAY60));
    Group->SetPrimitivesAspect(LineAttrib) ;

    Handle(Graphic3d_AspectText3d) TextAttrib = new Graphic3d_AspectText3d();
    TextAttrib->SetColor(Quantity_Color(Quantity_NOC_ROYALBLUE1));
    Group->SetPrimitivesAspect(TextAttrib);
    
    Graphic3d_Array1OfVertex Points(0,1) ;
    Standard_Real xl,yl,zl;
    myPrivilegedPlane.Location().Coord(xl,yl,zl);
    Points(0).SetCoord(xl,yl,zl);

    Standard_Real ay,by,cy;

    myPrivilegedPlane.XDirection().Coord(ay,by,cy);
    Points(1).SetCoord(xl+myDisplayPlaneLength*ay,
		       yl+myDisplayPlaneLength*by,
		       zl+myDisplayPlaneLength*cy);
    Group->Polyline(Points);
    Group->Text(XLetter.ToCString(),Points(1),1./81.);

    myPrivilegedPlane.YDirection().Coord(ay,by,cy);
    Points(1).SetCoord(xl+myDisplayPlaneLength*ay,
		       yl+myDisplayPlaneLength*by,
		       zl+myDisplayPlaneLength*cy);
    Group->Polyline(Points);
    Group->Text(YLetter.ToCString(),Points(1),1./81.);
    
    myPrivilegedPlane.Direction().Coord(ay,by,cy);
    Points(1).SetCoord(xl+myDisplayPlaneLength*ay,
		       yl+myDisplayPlaneLength*by,
		       zl+myDisplayPlaneLength*cy);
    Group->Polyline(Points);
    Group->Text(ZLetter.ToCString(),Points(1),1./81.);
#ifdef IMP240300
    myPlaneStructure->Display();
  } else {
    if( !myPlaneStructure.IsNull() )  myPlaneStructure->Erase();
#endif
  }
  if(Change) Update();
}

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