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_TYPE
27 STATUS Xw_def_type (atypemap,index,length,desc):
28 XW_EXT_TYPEMAP *atypemap
29 int index Line type index
30 int length Descriptor length
31 float *desc Type Descriptor
33 Update Line Type Extended typemap index with the specified TYPE values . Descriptor is an array of float.Each value give the subline length
34 in MM .First subline is the draw part,Second the hidden part,
35 Thirst the drawn part ...
36 NOTE than type index 0 is the Default Type (SOLID)
37 and cann't be REDEFINED
39 Returns ERROR if BadType Index
40 Returns SUCCESS if Successful
45 XW_STATUS Xw_def_type (void* atypemap,
46 int index,int length,float* desc)
48 XW_STATUS Xw_def_type (atypemap,index,length,desc)
53 #endif /*XW_PROTOTYPE*/
55 XW_EXT_TYPEMAP *ptypemap = (XW_EXT_TYPEMAP*)atypemap ;
57 unsigned char *pdesc ;
60 if ( !Xw_isdefine_typeindex(ptypemap,index) ) {
62 Xw_set_error(18,"Xw_def_type",&index) ;
66 if( !desc || length < 0 ) {
67 /*Bad Type descriptor data*/
68 Xw_set_error(19,"Xw_def_type",&index) ;
72 if( ptypemap->types[index] ) Xw_free(ptypemap->types[index]) ;
73 ptypemap->types[index] = NULL ;
76 ptypemap->types[index] = pdesc = (unsigned char*) Xw_malloc(length+1) ;
78 screen = ScreenOfDisplay(_TDISPLAY,DefaultScreen(_TDISPLAY)) ;
80 for( i=0 ; i<length ; i++ ) {
82 ptype = (int) (0.5 + (desc[i] * (float)WidthOfScreen(screen)/
83 (float)WidthMMOfScreen(screen))) ;
84 if( desc[i] == 0. || ptype < 0 || ptype > 255 ) {
85 /*Bad Type descriptor data*/
86 Xw_set_error(19,"Xw_def_type",&index) ;
88 pdesc[i] = (unsigned char) (ptype) ? ptype : 1 ;
95 if( Xw_get_trace() ) {
96 printf (" Xw_def_type(%lx,%d,%d,{",(long ) ptypemap,index,length);
97 for ( i=0 ; i<length-1 ; i++ ) printf("%f,",desc[i]) ;
98 printf("%f})\n",desc[length-1]) ;