0022792: Globally defined symbol PI conflicts with VTK definition (Intel compiler)
[occt.git] / src / OpenGl / OpenGl_togl_viewmapping.cxx
CommitLineData
7fd59977 1/***********************************************************************
2
3FONCTION :
4----------
5file OpenGl_togl_viewmapping.c :
6
7
8REMARQUES:
9----------
10
11
12HISTORIQUE DES MODIFICATIONS :
13--------------------------------
14xx-xx-xx : CAL ; Creation.
1510-07-96 : FMN ; Suppression #define sur calcul matrice
1625-07-96 : FMN ; Suppression code inutile
1718-11-98 : FMN ; Correction sur la gestion de la perspective (cf Programming Guide)
1809-12-98 : FMN ; Correction erreur de compilation sur WNT
1917-12-98 : FMN ; Correction erreur de compilation sur WNT
20
21************************************************************************/
22
23/*----------------------------------------------------------------------*/
24/*
25* Includes
26*/
27
28#include <OpenGl_tgl_all.hxx>
29#include <InterfaceGraphic_Graphic3d.hxx>
30#include <InterfaceGraphic_Visual3d.hxx>
31#include <OpenGl_tgl_vis.hxx>
32#include <OpenGl_tgl_funcs.hxx>
33
34#include <GL/gl.h>
35
36/*----------------------------------------------------------------------*/
37/*
38* Variable globales
39*/
40
41EXPORT extern GLboolean env_walkthrow; /* definit dans OpenGl_togl_begin.c */
42
43/*----------------------------------------------------------------------*/
44
45int EXPORT
46call_togl_viewmapping
47(
48 CALL_DEF_VIEW * aview,
49 int wait
50 )
51{
52 int i, j;
53 float ratio;
54 Tint waitwait;
55 Tint err_ind;
56
57 TEL_VIEW_MAPPING Map;
58
59 err_ind = 0;
60 ratio = aview->DefWindow.dy / aview->DefWindow.dx;
61
62 Map.window.xmin = aview->Mapping.WindowLimit.um;
63 Map.window.ymin = aview->Mapping.WindowLimit.vm;
64 Map.window.xmax = aview->Mapping.WindowLimit.uM;
65 Map.window.ymax = aview->Mapping.WindowLimit.vM;
66
67 Map.viewport.xmin = ( float )0.0;
68 Map.viewport.xmax = ( ( float )1. < ( float )1./ratio ? ( float )1. : ( float )1./ratio );
69 Map.viewport.ymin = ( float )0.0;
70 Map.viewport.ymax = ( ( float )1. < ratio ? ( float )1. : ratio );
71 Map.viewport.zmin = ( float )0.0;
72 Map.viewport.zmax = ( float )1.0;
73
74 /* projection type */
75 switch( aview->Mapping.Projection )
76 {
77 case 0 :
78 Map.proj = CALL_PHIGS_TYPE_PERSPECT;
79 break;
80 case 1 :
81 Map.proj = CALL_PHIGS_TYPE_PARAL;
82 break;
83 }
84
85 /* projection reference point */
86 Map.prp[0] = aview->Mapping.ProjectionReferencePoint.x;
87 Map.prp[1] = aview->Mapping.ProjectionReferencePoint.y;
88 if (env_walkthrow)
89 Map.prp[2] = aview->Mapping.ProjectionReferencePoint.z;
90 else
91 Map.prp[2] = aview->Mapping.FrontPlaneDistance +
92 aview->Mapping.ProjectionReferencePoint.z;
93
94 /* view plane distance */
95 Map.vpd = aview->Mapping.ViewPlaneDistance;
96
97 /* back plane distance */
98 Map.bpd = aview->Mapping.BackPlaneDistance;
99
100 /* front plane distance */
101 Map.fpd = aview->Mapping.FrontPlaneDistance;
102
103 /* use user-defined matrix */
104 if ( aview->Mapping.IsCustomMatrix ) {
105 for( i = 0; i < 4; i++ )
106 for( j = 0; j < 4; j++ )
107 call_viewrep.mapping_matrix[i][j] = aview->Mapping.ProjectionMatrix[i][j];
108 }
109 else
110 TelEvalViewMappingMatrix( &Map, &err_ind, call_viewrep.mapping_matrix );
111
112 if( !err_ind && aview->WsId != -1 )
113 {
114 call_viewrep.extra.map = Map;
115 if( !wait )
116 {
117 waitwait = 1;
118 call_togl_vieworientation( aview, waitwait );
119 call_togl_cliplimit( aview, waitwait );
120 TelSetViewRepresentation( aview->WsId, aview->ViewId, &call_viewrep );
121 call_togl_ratio_window( aview );
122 }
123 }
124 return err_ind;
125}
126/*----------------------------------------------------------------------*/