summaryrefslogtreecommitdiff
path: root/src/OpenGl/OpenGl_togl_linecontextgroup.cxx
blob: b7c6f3237fc74574267bc2b4f74550a37a86ba10 (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
/***********************************************************************

FONCTION :
----------
File OpenGl_linecontextgroup :


REMARQUES:
---------- 

HISTORIQUE DES MODIFICATIONS   :
--------------------------------
xx-xx-xx : xxx ; Creation.
03-09-97 : FMN ; Ajout traitement Begin/EndPrimitives()
03-03-98 : CAL ; Modification des structures CALL_DEF_GROUP et STRUCTURE

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

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

#include <OpenGl_tgl_all.hxx>
#include <InterfaceGraphic_Graphic3d.hxx>
#include <OpenGl_tgl.hxx>
#include <OpenGl_tgl_funcs.hxx>
#include <OpenGl_tgl_subrs.hxx>
#include <OpenGl_tgl_utilgr.hxx>

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

void EXPORT
call_togl_linecontextgroup
(
 CALL_DEF_GROUP * agroup,
 int noinsert
 )
{
  /* for the group */
  Tfloat  liner, lineg, lineb;
  Tint    linetype=0;
  Tfloat  linewidth;

  /* for the structure */
  Tfloat  Liner, Lineg, Lineb;
  Tint    Linetype=0;
  Tfloat  Linewidth;

  /*
  * Si le groupe est ouvert cela signifie que BeginPrimitives
  * a ete utilise.
  * Dans le cas des markers composes, il faut refermer temporairement
  * le groupe pour eviter des insertions d'attributs aleatoires.
  */
  if (agroup->IsOpen) call_togl_closegroup (agroup);

  if( agroup->ContextLine.IsDef )
  {
    liner = agroup->ContextLine.Color.r;
    lineg = agroup->ContextLine.Color.g;
    lineb = agroup->ContextLine.Color.b;

    switch( agroup->ContextLine.LineType )
    {
    case 0 : /* Aspect_TOL_SOLID */
      linetype = CALL_PHIGS_LINE_SOLID;
      break;
    case 1 : /* Aspect_DASH */
      linetype = CALL_PHIGS_LINE_DASH;
      break;
    case 2 : /* Aspect_TOL_DOT */
      linetype = CALL_PHIGS_LINE_DOT;
      break;
    case 3 : /* Aspect_TOL_DOTDASH */
      linetype = CALL_PHIGS_LINE_DASH_DOT;
      break;
    default :
      break;
    }
    linewidth = (Tfloat)agroup->ContextLine.Width;

    Liner = agroup->Struct->ContextLine.Color.r;
    Lineg = agroup->Struct->ContextLine.Color.g;
    Lineb = agroup->Struct->ContextLine.Color.b;

    switch( agroup->Struct->ContextLine.LineType )
    {
    case 0 : /* Aspect_TOL_SOLID */
      Linetype = CALL_PHIGS_LINE_SOLID;
      break;
    case 1 : /* Aspect_DASH */
      Linetype = CALL_PHIGS_LINE_DASH;
      break;
    case 2 : /* Aspect_TOL_DOT */
      Linetype = CALL_PHIGS_LINE_DOT;
      break;
    case 3 : /* Aspect_TOL_DOTDASH */
      Linetype = CALL_PHIGS_LINE_DASH_DOT;
      break;
    default :
      break;
    }
    Linewidth = (Tfloat)agroup->Struct->ContextLine.Width;

    /*TransPers = agroup->TransformPersistenceFlag;*/

    if( noinsert )
    {
      if( agroup->ContextLine.IsSet )
        call_func_set_edit_mode( CALL_PHIGS_EDIT_REPLACE );
      else
        call_func_set_edit_mode( CALL_PHIGS_EDIT_INSERT );
      call_func_open_struct( agroup->Struct->Id );

      call_func_set_elem_ptr( 0 );
      call_func_set_elem_ptr_label( agroup->LabelBegin );
      if( agroup->PickId.IsSet )
        call_func_offset_elem_ptr( 1 );
      if( agroup->ContextLine.IsSet )
        call_func_offset_elem_ptr( 1 );
      call_subr_set_line_colr( liner, lineg, lineb );
      if( agroup->ContextLine.IsSet )
        call_func_offset_elem_ptr( 1 );
      call_func_set_linetype( linetype );
      if( agroup->ContextLine.IsSet )
        call_func_offset_elem_ptr( 1 );
      call_func_set_linewidth( linewidth );

      call_func_set_elem_ptr_label( agroup->LabelEnd );
      call_func_offset_elem_ptr( -call_util_context_group_place( agroup )
        - 1 );
      if( agroup->ContextLine.IsSet )
        call_func_offset_elem_ptr( 1 );
      call_subr_set_line_colr( Liner, Lineg, Lineb );
      if( agroup->ContextLine.IsSet )
        call_func_offset_elem_ptr( 1 );
      call_func_set_linetype( Linetype );
      if( agroup->ContextLine.IsSet )
        call_func_offset_elem_ptr( 1 );
      call_func_set_linewidth( Linewidth );
      call_func_close_struct(  );
    } /* no insert */

    if( noinsert == 0 )
    {
      call_func_set_edit_mode( CALL_PHIGS_EDIT_INSERT );
      call_func_open_struct( agroup->Struct->Id );

      call_func_set_elem_ptr( 0 );
      call_func_set_elem_ptr_label( agroup->LabelEnd );
      call_func_offset_elem_ptr( -call_util_context_group_place( agroup )
        - 1 );
      call_subr_set_line_colr( liner, lineg, lineb );
      call_func_set_linetype( linetype );
      call_func_set_linewidth( linewidth );

      if( !agroup->ContextLine.IsSet )
      {
        call_subr_set_line_colr( Liner, Lineg, Lineb );
        call_func_set_linetype( Linetype );
        call_func_set_linewidth( Linewidth );
      }
      call_func_close_struct();
    } /* insert */
  }
  /* Voir commentaire en debut de fonction */
  if (agroup->IsOpen) call_togl_opengroup (agroup);
  return;
}