0023414: Remove deprecated classes Xw_PixMap and WNT_PixMap
[occt.git] / src / Xw / Xw_WidthMap.cxx
CommitLineData
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_WidthMap.ixx>
21#include <Aspect_WidthOfLine.hxx>
22
23// Routines C a declarer en extern
24//extern "C" {
25#include <Xw_Cextern.hxx>
26//}
27
28//-Static data definitions
29
30static char *ErrorMessag ;
31static int ErrorNumber ;
32static int ErrorGravity ;
33static XW_STATUS status ;
34
35Xw_WidthMap::Xw_WidthMap () {
36}
37
38Xw_WidthMap::Xw_WidthMap (const Standard_CString Connexion) {
39
40 MyExtendedDisplay = Xw_open_display((Standard_PCharacter)Connexion) ;
41
42 if( !MyExtendedDisplay ) {
43 ErrorMessag = Xw_get_error(&ErrorNumber,&ErrorGravity) ;
44 if( ErrorGravity )
45 Aspect_WidthMapDefinitionError::Raise (ErrorMessag) ;
46 else Xw_print_error() ;
47 }
48
49 MyExtendedWidthMap = Xw_def_widthmap(MyExtendedDisplay,(int)0) ;
50
51 if( !Xw_isdefine_widthmap(MyExtendedWidthMap) ) {
52 ErrorMessag = Xw_get_error(&ErrorNumber,&ErrorGravity) ;
53 if( ErrorGravity )
54 Aspect_WidthMapDefinitionError::Raise (ErrorMessag) ;
55 else Xw_print_error() ;
56 }
57}
58
59void Xw_WidthMap::SetEntry (const Aspect_WidthMapEntry& Entry) {
60int fwidth = (int) Entry.Index() ;
61float width = (float) TOMILLIMETER(Entry.Width()) ;
62
63 if( fwidth ) { /* Don't change Default index 0,One pixel Width */
64 status = Xw_def_width(MyExtendedWidthMap,fwidth,width) ;
65
66 if( !status ) {
67 ErrorMessag = Xw_get_error(&ErrorNumber,&ErrorGravity) ;
68 if( ErrorGravity > 2 )
69 Aspect_BadAccess::Raise (ErrorMessag) ;
70 else Xw_print_error() ;
71 }
72 }
73
74}
75
76void Xw_WidthMap::SetEntries (const Handle(Aspect_WidthMap)& Widthmap) {
77Standard_Integer size = Widthmap->Size() ;
78Standard_Integer i ;
79
80 if( !Xw_isdefine_widthmap(MyExtendedWidthMap) ) {
81 ErrorMessag = Xw_get_error(&ErrorNumber,&ErrorGravity) ;
82 if( ErrorGravity > 2 )
83 Aspect_WidthMapDefinitionError::Raise (ErrorMessag) ;
84 else Xw_print_error() ;
85 }
86
87 for( i=1 ; i<=size ; i++ ) {
88 SetEntry(Widthmap->Entry(i)) ;
89 }
90}
91
92void Xw_WidthMap::Destroy() {
93
94 if( MyExtendedWidthMap ) {
95 Xw_close_widthmap(MyExtendedWidthMap) ;
96 MyExtendedWidthMap = NULL ;
97 }
98}
99
100Standard_Integer Xw_WidthMap::FreeWidths( ) const {
101Standard_Integer nwidth ;
102int mwidth,uwidth,dwidth,fwidth ;
103
104 status = Xw_get_widthmap_info(MyExtendedWidthMap,
105 &mwidth,&uwidth,&dwidth,&fwidth) ;
106
107 if( !status ) {
108 ErrorMessag = Xw_get_error(&ErrorNumber,&ErrorGravity) ;
109 if( ErrorGravity > 2 )
110 Aspect_BadAccess::Raise (ErrorMessag) ;
111 else Xw_print_error() ;
112 }
113
114 nwidth = uwidth - dwidth ;
115
116 return (nwidth) ;
117}
118
119Standard_Address Xw_WidthMap::ExtendedWidthMap () const {
120
121 return (MyExtendedWidthMap);
122
123}