1 // Copyright (c) 1999-2012 OPEN CASCADE SAS
3 // The content of this file is subject to the Open CASCADE Technology Public
4 // License Version 6.5 (the "License"). You may not use the content of this file
5 // except in compliance with the License. Please obtain a copy of the License
6 // at http://www.opencascade.org and read it completely before using this file.
8 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
11 // The Original Code and all software distributed under the License is
12 // distributed on an "AS IS" basis, without warranty of any kind, and the
13 // Initial Developer hereby disclaims all such warranties, including without
14 // limitation, any warranties of merchantability, fitness for a particular
15 // purpose or non-infringement. Please see the License for the specific terms
16 // and conditions governing the rights and limitations under the License.
19 #define PRO4391 /*GG_040696
20 // Traitement des polygones transparents.
23 #include <Xw_Extension.h>
25 /* ifdef then trace on */
27 #define TRACE_SET_POLY_ATTRIB
28 #define TRACE_GET_POLY_ATTRIB
32 XW_ATTRIB Xw_set_poly_attrib (awindow,color,type,tile,mode):
33 XW_EXT_WINDOW *awindow
34 int color ; Color index to used 0 >= x < MAXCOLOR
35 int type ; Type can be TRUE if EDGES must be Draw with the
36 set_line_attrib attributes
37 int tile ; Tile index to used x < MAXTILE
38 DRAWMODE mode ; Draw Mode must be one of DRAWMODE enum
40 Set Poly Color,Type and Tile current graphic attrib .
41 NOTE than if tile is < 0 the poly background is transparente.
43 Returns Selected Polygon Attribute Index if successful
44 Returns 0 if Bad Color,Type or Tile Index
49 XW_ATTRIB Xw_set_poly_attrib (void *awindow,int color,int type,int tile,XW_DRAWMODE mode)
51 XW_ATTRIB Xw_set_poly_attrib (awindow,color,type,tile,mode)
56 #endif /*XW_PROTOTYPE*/
58 XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow;
61 int i,j,k,function,mask = 0 ;
62 unsigned long planemask,hcolor ;
64 if( !Xw_isdefine_window(pwindow) ) {
65 /*ERROR*Bad EXT_WINDOW Address*/
66 Xw_set_error(24,"Xw_set_poly_attrib",pwindow) ;
70 if( _BINDEX > 0 ) return (1) ;
72 if ( !Xw_isdefine_color(_COLORMAP,color) ) {
73 /*ERROR*Bad Defined Color*/
74 Xw_set_error(41,"Xw_set_poly_attrib",&color) ;
79 if ( !Xw_isdefine_tile(_TILEMAP,tile) ) {
80 /*WARNING*Bad Defined Tile*/
81 Xw_set_error(78,"Xw_set_poly_attrib",&tile) ;
85 } else if( tile < 0 ) {
95 if( !_TILEMAP || !_TILEMAP->tiles[tile] ) tile = 0 ;
98 code = QGCODE(color,type,tile,mode) ;
99 if( code == pwindow->qgpoly[pwindow->polyindex].code ) {
100 /* The last index computed is already set*/
101 pwindow->qgpoly[pwindow->polyindex].count++ ;
102 return (pwindow->polyindex+1) ;
105 for( i=j=0,k=MAXQG ; i<MAXQG ; i++ ) {
106 if( code == pwindow->qgpoly[i].code ) k = i ;
107 if( pwindow->qgpoly[i].count < pwindow->qgpoly[j].count ) j = i;
111 /* A GC index already exist,use it */
112 pwindow->polyindex = k ;
113 pwindow->qgpoly[k].count++ ;
117 pwindow->polyindex = j ;
118 pwindow->qgpoly[j].count = 1 ;
120 Xw_get_color_attrib(pwindow,mode,color,&hcolor,&function,&planemask);
121 if( mode != QGMODE(pwindow->qgpoly[j].code) ) {
122 mask |= GCFunction | GCPlaneMask | GCForeground ;
123 gc_values.function = function ;
124 gc_values.plane_mask = planemask ;
125 gc_values.foreground = hcolor ;
126 } else if( color != QGCOLOR(pwindow->qgpoly[j].code) ) {
127 mask |= GCForeground;
128 gc_values.foreground = hcolor ;
131 if( tile != QGTILE(pwindow->qgpoly[j].code) ) {
132 mask |= GCFillStyle ;
134 if( (tile > 0) && _TILEMAP && _TILEMAP->tiles[tile] ) {
139 gc_values.fill_style = FillOpaqueStippled ;
140 gc_values.stipple = _TILEMAP->tiles[tile] ;
142 gc_values.fill_style = FillSolid ;
149 XChangeGC(_DISPLAY,pwindow->qgpoly[j].gc,mask,&gc_values) ;
150 pwindow->qgpoly[j].code = code ;
152 #ifdef TRACE_SET_POLY_ATTRIB
153 if( Xw_get_trace() > 1 ) {
154 printf(" %d = Xw_set_poly_attrib(%lx,%d,%d,%d,%d)\n",
155 k,(long ) pwindow,color,type,tile,mode) ;
164 XW_ATTRIB Xw_get_poly_attrib (awindow,color,type,tile,mode):
165 XW_EXT_WINDOW *awindow
166 int *color ; Returns current Color index
167 int *type ; Returns current Type
168 int *tile ; Returns current Tile index
169 DRAWMODE *mode ; Returns current Draw Mode
171 Returns Selected Polygon Attribute Index
176 XW_ATTRIB Xw_get_poly_attrib (void *awindow,int *color,int *type,int *tile,XW_DRAWMODE *mode)
178 XW_ATTRIB Xw_get_poly_attrib (awindow,color,type,tile,mode)
183 #endif /*XW_PROTOTYPE*/
185 XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow;
189 j = pwindow->polyindex; k = j+1;
191 code = pwindow->qgpoly[j].code;
193 *color = QGCOLOR(code);
194 *type = QGTYPE(code);
195 *tile = QGTILE(code) > 1 ? QGTILE(code) : QGTILE(code) - 1;
196 *mode = (XW_DRAWMODE) QGMODE(code);
198 #ifdef TRACE_GET_POLY_ATTRIB
199 if( Xw_get_trace() > 1 ) {
200 printf(" %d = Xw_get_poly_attrib(%lx,%d,%d,%d,%d)\n",
201 k,(long ) pwindow,*color,*type,*tile,*mode) ;