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 #include <Xw_Extension.h>
21 /* ifdef then trace on */
23 #define TRACE_SET_MARKER_ATTRIB
27 XW_ATTRIB Xw_set_marker_attrib (awindow,color,type,width,mode):
28 XW_EXT_WINDOW *awindow
29 int color ; Color index to used 0 >= x < MAXCOLOR
30 int type ; Type can be TRUE if marker must be filled with the
31 set_poly_attrib attributes
32 int width ; Width index to used 0 >= x < MAXWIDTH
33 DRAWMODE mode ; Draw Mode must be one of DRAWMODE enum
35 Set Marker Color,Type and Marker current graphic attrib .
37 Returns Selected Marker Attribute Index if successful
38 Returns 0 if Bad Color,Type or Marker Index
43 XW_ATTRIB Xw_set_marker_attrib (void *awindow,int color,int type,int width,XW_DRAWMODE mode)
45 XW_ATTRIB Xw_set_marker_attrib (awindow,color,type,width,mode)
50 #endif /*XW_PROTOTYPE*/
52 XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow;
55 int i,j,k,function,mask = 0;
56 unsigned long planemask,hcolor ;
58 if( !Xw_isdefine_window(pwindow) ) {
59 /*ERROR*Bad EXT_WINDOW Address*/
60 Xw_set_error(24,"Xw_set_marker_attrib",pwindow) ;
64 if( _BINDEX > 0 ) return (1) ;
66 if ( !Xw_isdefine_color(_COLORMAP,color) ) {
67 /*ERROR*Bad Defined Color*/
68 Xw_set_error(41,"Xw_set_marker_attrib",&color) ;
72 if ( !Xw_isdefine_width(_WIDTHMAP,width) ) {
73 /*WARNING*Bad Defined Width*/
74 Xw_set_error(52,"Xw_set_marker_attrib",&width) ;
78 if( !_WIDTHMAP || (_WIDTHMAP->widths[width] <= 1) ) width = 0 ;
80 code = QGCODE(color,type,width,mode) ;
81 if( code == pwindow->qgmark[pwindow->markindex].code ) {
82 /* The last index computed is already set*/
83 pwindow->qgmark[pwindow->markindex].count++ ;
84 return (pwindow->markindex+1) ;
87 for( i=j=0,k=MAXQG ; i<MAXQG ; i++ ) {
88 if( code == pwindow->qgmark[i].code ) k = i ;
89 if( pwindow->qgmark[i].count < pwindow->qgmark[j].count ) j = i;
93 /* A GC index already exist,use it */
94 pwindow->markindex = k ;
95 pwindow->qgmark[k].count++ ;
99 pwindow->markindex = j ;
100 pwindow->qgmark[j].count = 1 ;
102 Xw_get_color_attrib(pwindow,mode,color,&hcolor,&function,&planemask);
103 if( mode != QGMODE(pwindow->qgmark[j].code) ) {
104 mask |= GCFunction | GCPlaneMask | GCForeground ;
105 gc_values.function = function ;
106 gc_values.plane_mask = planemask ;
107 gc_values.foreground = hcolor ;
108 } else if( color != QGCOLOR(pwindow->qgmark[j].code) ) {
109 mask |= GCForeground;
110 gc_values.foreground = hcolor ;
113 if( width != QGWIDTH(pwindow->qgmark[j].code) ) {
114 mask |= GCLineWidth ;
116 gc_values.line_width = _WIDTHMAP->widths[width] ;
118 gc_values.line_width = 0 ;
125 XChangeGC(_DISPLAY,pwindow->qgmark[j].gc,mask,&gc_values) ;
126 pwindow->qgmark[j].code = code ;
128 #ifdef TRACE_SET_MARKER_ATTRIB
129 if( Xw_get_trace() > 1 ) {
130 printf(" %d = Xw_set_marker_attrib(%lx,%d,%d,%d,%d)\n",
131 k,(long ) pwindow,color,type,width,mode) ;