d39a3a532cb8bfc29d7972a35f1209a48bb3c315
[occt.git] / src / OpenGl / OpenGl_togl_vieworientation.cxx
1 /***********************************************************************
2
3 FONCTION :
4 ----------
5 file OpenGl_togl_vieworientation.c :
6
7
8 REMARQUES:
9 ---------- 
10
11
12 HISTORIQUE DES MODIFICATIONS   :
13 --------------------------------
14 xx-xx-xx : CAL ; Creation.
15 10-07-96 : FMN ; Suppression #define sur calcul matrice
16
17 ************************************************************************/
18 #define GER61454        //GG 14-09-99 Activates the model clipping planes
19
20 /*----------------------------------------------------------------------*/
21 /*
22 * Includes
23 */
24
25 #include <OpenGl_tgl_all.hxx>
26 #include <InterfaceGraphic_Graphic3d.hxx>
27 #include <InterfaceGraphic_Visual3d.hxx>
28 #include <OpenGl_tgl_vis.hxx>
29 #include <OpenGl_tgl_funcs.hxx>
30
31 /*----------------------------------------------------------------------*/
32
33 int EXPORT
34 call_togl_vieworientation
35 (
36  CALL_DEF_VIEW * aview,
37  int wait
38  )
39 {
40   int i, j;
41   Tint waitwait;
42   Tint err_ind;           /* OUT error indicator */
43
44   Tfloat Vrp[3];
45   Tfloat Vpn[3];
46   Tfloat Vup[3];
47   Tfloat ScaleFactors[3];
48
49   err_ind = 0;
50
51   Vrp[0] = aview->Orientation.ViewReferencePoint.x;
52   Vrp[1] = aview->Orientation.ViewReferencePoint.y;
53   Vrp[2] = aview->Orientation.ViewReferencePoint.z;
54
55   Vpn[0] = aview->Orientation.ViewReferencePlane.x;
56   Vpn[1] = aview->Orientation.ViewReferencePlane.y;
57   Vpn[2] = aview->Orientation.ViewReferencePlane.z;
58
59   Vup[0] = aview->Orientation.ViewReferenceUp.x;
60   Vup[1] = aview->Orientation.ViewReferenceUp.y;
61   Vup[2] = aview->Orientation.ViewReferenceUp.z;
62
63   ScaleFactors[0] = aview->Orientation.ViewScaleX;
64   ScaleFactors[1] = aview->Orientation.ViewScaleY;
65   ScaleFactors[2] = aview->Orientation.ViewScaleZ;
66
67   /* use user-defined matrix */
68   if ( aview->Orientation.IsCustomMatrix ) {
69     for( i = 0; i < 4; i++ )
70       for( j = 0; j < 4; j++ )
71         call_viewrep.orientation_matrix[i][j] = aview->Orientation.ModelViewMatrix[i][j];
72   }
73   else
74     TelEvalViewOrientationMatrix( Vrp, Vpn, Vup, ScaleFactors, &err_ind, call_viewrep.orientation_matrix);
75
76   if( !err_ind && aview->WsId != -1 )
77   {
78     call_viewrep.extra.vrp[0] = Vrp[0],
79       call_viewrep.extra.vrp[1] = Vrp[1],
80       call_viewrep.extra.vrp[2] = Vrp[2];
81
82     call_viewrep.extra.vpn[0] = Vpn[0],
83       call_viewrep.extra.vpn[1] = Vpn[1],
84       call_viewrep.extra.vpn[2] = Vpn[2];
85
86     call_viewrep.extra.vup[0] = Vup[0],
87       call_viewrep.extra.vup[1] = Vup[1],
88       call_viewrep.extra.vup[2] = Vup[2];
89
90     call_viewrep.extra.scaleFactors[0] = ScaleFactors[0],
91       call_viewrep.extra.scaleFactors[1] = ScaleFactors[1],
92       call_viewrep.extra.scaleFactors[2] = ScaleFactors[2];
93
94     if( !wait )
95     {
96       waitwait = 1;
97       call_togl_viewmapping( aview, waitwait );
98       call_togl_cliplimit( aview, waitwait );
99 #ifdef GER61454
100       call_togl_setplane( aview );
101 #endif
102       TelSetViewRepresentation( aview->WsId, aview->ViewId, &call_viewrep );
103     }
104   }
105   return err_ind;
106 }
107 /*----------------------------------------------------------------------*/