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_DEF_MARKER
27 STATUS Xw_def_marker (amarkmap,index,npoint,spoint,xpoint,ypoint):
28 XW_EXT_MARKMAP *amarkmap
29 int index Marker index 0 > x < MAXMARKER
30 int npoint Marker length
31 int *spoint Marker status point (move-draw boolean)
32 float *xpoint Marker X coords in space -1,+1
33 float *ypoint Marker Y coords in space -1,+1
35 Update Marker Extended markmap index with the specified line marker
37 Marker point must be defined in the float space -1,+1
39 NOTE that marker index 0 is the default marker (.)
40 and cann't be REDEFINED .
41 NOTE that the marker size in Meter is decide at the draw_marker time.
43 Returns ERROR if BadMarker Index or Bad marker coords
44 Returns SUCCESS if Successful
49 XW_STATUS Xw_def_marker (void* amarkmap,
50 int index,int npoint,int* spoint,float *xpoint,float *ypoint)
52 XW_STATUS Xw_def_marker (amarkmap,index,npoint,spoint,xpoint,ypoint)
54 int index,npoint,*spoint;
55 float *xpoint,*ypoint;
56 #endif /*XW_PROTOTYPE*/
58 XW_EXT_MARKMAP *pmarkmap = (XW_EXT_MARKMAP*) amarkmap ;
61 if ( !Xw_isdefine_markerindex(pmarkmap,index) ) {
63 Xw_set_error(10,"Xw_def_marker",&index) ;
67 if( pmarkmap->npoint[index] ) {
68 pmarkmap->npoint[index] = 0;
69 Xw_free(pmarkmap->spoint[index]);
70 pmarkmap->spoint[index] = NULL;
71 Xw_free(pmarkmap->xpoint[index]);
72 pmarkmap->xpoint[index] = NULL;
73 Xw_free(pmarkmap->ypoint[index]);
74 pmarkmap->ypoint[index] = NULL;
78 int *s = pmarkmap->spoint[index] =
79 (int*) Xw_malloc(npoint*sizeof(int));
80 float *x = pmarkmap->xpoint[index] =
81 (float*) Xw_malloc(npoint*sizeof(float));
82 float *y = pmarkmap->ypoint[index] =
83 (float*) Xw_malloc(npoint*sizeof(float));
85 pmarkmap->npoint[index] = npoint;
86 for( i=0 ; i<npoint ; i++ ) {
92 /*Marker Allocation failed*/
93 Xw_set_error(11,"Xw_def_marker",NULL) ;
98 #ifdef TRACE_DEF_MARKER
99 if( Xw_get_trace() ) {
100 printf(" Xw_def_marker(%lx,%d,%d)\n",(long ) pmarkmap,index,npoint);
101 if( Xw_get_trace() > 1 ) {
102 for( i=0 ; i<npoint ; i++ ) {
103 printf(" point(%d) = {%d,%f,%f}\n",i,spoint[i],xpoint[i],ypoint[i]);