b311480e |
1 | // Copyright (c) 1995-1999 Matra Datavision |
2 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
3 | // |
4 | // The content of this file is subject to the Open CASCADE Technology Public |
5 | // License Version 6.5 (the "License"). You may not use the content of this file |
6 | // except in compliance with the License. Please obtain a copy of the License |
7 | // at http://www.opencascade.org and read it completely before using this file. |
8 | // |
9 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
10 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
11 | // |
12 | // The Original Code and all software distributed under the License is |
13 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
14 | // Initial Developer hereby disclaims all such warranties, including without |
15 | // limitation, any warranties of merchantability, fitness for a particular |
16 | // purpose or non-infringement. Please see the License for the specific terms |
17 | // and conditions governing the rights and limitations under the License. |
18 | |
7fd59977 |
19 | |
20 | #include <Xw_MarkMap.ixx> |
21 | #include <Aspect_TypeOfMarker.hxx> |
22 | #include <Aspect_MarkerStyle.hxx> |
23 | #include <Standard_ShortReal.hxx> |
dc3fe572 |
24 | #include <Standard_PCharacter.hxx> |
7fd59977 |
25 | #include <TShort_Array1OfShortReal.hxx> |
26 | #include <TColStd_Array1OfBoolean.hxx> |
27 | |
28 | // Routines C a declarer en extern |
29 | //extern "C" { |
30 | #include <Xw_Cextern.hxx> |
31 | //} |
32 | |
33 | //-Static data definitions |
34 | |
35 | static char *ErrorMessag ; |
36 | static int ErrorNumber ; |
37 | static int ErrorGravity ; |
38 | static XW_STATUS status ; |
39 | |
40 | Xw_MarkMap::Xw_MarkMap () { |
41 | } |
42 | |
43 | Xw_MarkMap::Xw_MarkMap (const Standard_CString Connexion) { |
44 | |
45 | MyExtendedDisplay = Xw_open_display((Standard_PCharacter)Connexion) ; |
46 | |
47 | if( !MyExtendedDisplay ) { |
48 | ErrorMessag = Xw_get_error(&ErrorNumber,&ErrorGravity) ; |
49 | if( ErrorGravity ) |
50 | Aspect_MarkMapDefinitionError::Raise (ErrorMessag) ; |
51 | else Xw_print_error() ; |
52 | } |
53 | |
54 | MyExtendedMarkMap = Xw_def_markmap(MyExtendedDisplay,(int)0) ; |
55 | |
56 | if( !Xw_isdefine_markmap(MyExtendedMarkMap) ) { |
57 | ErrorMessag = Xw_get_error(&ErrorNumber,&ErrorGravity) ; |
58 | if( ErrorGravity ) |
59 | Aspect_MarkMapDefinitionError::Raise (ErrorMessag) ; |
60 | else Xw_print_error() ; |
61 | } |
62 | } |
63 | |
64 | void Xw_MarkMap::SetEntry (const Aspect_MarkMapEntry& anEntry) { |
65 | Aspect_MarkerStyle style = anEntry.Style() ; |
66 | int length = (int) style.Length() ; |
67 | int index = (int) anEntry.Index() ; |
68 | const TShort_Array1OfShortReal& xvalues(style.XValues()) ; |
69 | const TShort_Array1OfShortReal& yvalues(style.YValues()) ; |
70 | const TColStd_Array1OfBoolean& svalues(style.SValues()) ; |
71 | float *X = (float*) &xvalues.Value(xvalues.Lower()); |
72 | float *Y = (float*) &yvalues.Value(yvalues.Lower()); |
73 | int *S = (int*) &svalues.Value(svalues.Lower()); |
74 | Standard_Integer i; |
75 | |
76 | for( i=1 ; i<=length ; i++ ) { |
77 | // Standard_Real xcoord,ycoord; |
78 | // Standard_Boolean state = style.Values(i,xcoord,ycoord); |
79 | } |
80 | |
81 | if( index ) { /* Index 0 is default POINT Marker ,cann't be changed */ |
82 | status = Xw_def_marker(MyExtendedMarkMap,index,length,S,X,Y) ; |
83 | |
84 | if( !status ) { |
85 | ErrorMessag = Xw_get_error(&ErrorNumber,&ErrorGravity) ; |
86 | if( ErrorGravity > 2 ) |
87 | Aspect_BadAccess::Raise (ErrorMessag) ; |
88 | else Xw_print_error() ; |
89 | } |
90 | } |
91 | } |
92 | |
93 | void Xw_MarkMap::SetEntries (const Handle(Aspect_MarkMap)& Markmap) { |
94 | Standard_Integer size = Markmap->Size() ; |
95 | Standard_Integer i ; |
96 | |
97 | if( !Xw_isdefine_markmap(MyExtendedMarkMap) ) { |
98 | ErrorMessag = Xw_get_error(&ErrorNumber,&ErrorGravity) ; |
99 | if( ErrorGravity > 2 ) |
100 | Aspect_MarkMapDefinitionError::Raise (ErrorMessag) ; |
101 | else Xw_print_error() ; |
102 | } |
103 | |
104 | for( i=1 ; i<=size ; i++ ) { |
105 | SetEntry(Markmap->Entry(i)) ; |
106 | } |
107 | } |
108 | |
109 | void Xw_MarkMap::Destroy() { |
110 | |
111 | if( MyExtendedMarkMap ) { |
112 | Xw_close_markmap(MyExtendedMarkMap) ; |
113 | MyExtendedMarkMap = NULL ; |
114 | } |
115 | } |
116 | |
117 | Standard_Integer Xw_MarkMap::FreeMarkers( ) const { |
118 | Standard_Integer ntype ; |
119 | int mtype,utype,dtype,ftype ; |
120 | |
121 | status = Xw_get_markmap_info(MyExtendedMarkMap, |
122 | &mtype,&utype,&dtype,&ftype) ; |
123 | |
124 | if( !status ) { |
125 | ErrorMessag = Xw_get_error(&ErrorNumber,&ErrorGravity) ; |
126 | if( ErrorGravity > 2 ) |
127 | Aspect_BadAccess::Raise (ErrorMessag) ; |
128 | else Xw_print_error() ; |
129 | } |
130 | |
131 | ntype = utype - dtype ; |
132 | |
133 | return (ntype) ; |
134 | } |
135 | |
136 | Standard_Address Xw_MarkMap::ExtendedMarkMap () const { |
137 | |
138 | return (MyExtendedMarkMap); |
139 | |
140 | } |