1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2012 OPEN CASCADE SAS
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.
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.
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.
20 #include <Xw_WidthMap.ixx>
21 #include <Aspect_WidthOfLine.hxx>
22 #include <Standard_PCharacter.hxx>
24 // Routines C a declarer en extern
26 #include <Xw_Cextern.hxx>
29 //-Static data definitions
31 static char *ErrorMessag ;
32 static int ErrorNumber ;
33 static int ErrorGravity ;
34 static XW_STATUS status ;
36 Xw_WidthMap::Xw_WidthMap () {
39 Xw_WidthMap::Xw_WidthMap (const Standard_CString Connexion) {
41 MyExtendedDisplay = Xw_open_display((Standard_PCharacter)Connexion) ;
43 if( !MyExtendedDisplay ) {
44 ErrorMessag = Xw_get_error(&ErrorNumber,&ErrorGravity) ;
46 Aspect_WidthMapDefinitionError::Raise (ErrorMessag) ;
47 else Xw_print_error() ;
50 MyExtendedWidthMap = Xw_def_widthmap(MyExtendedDisplay,(int)0) ;
52 if( !Xw_isdefine_widthmap(MyExtendedWidthMap) ) {
53 ErrorMessag = Xw_get_error(&ErrorNumber,&ErrorGravity) ;
55 Aspect_WidthMapDefinitionError::Raise (ErrorMessag) ;
56 else Xw_print_error() ;
60 void Xw_WidthMap::SetEntry (const Aspect_WidthMapEntry& Entry) {
61 int fwidth = (int) Entry.Index() ;
62 float width = (float) TOMILLIMETER(Entry.Width()) ;
64 if( fwidth ) { /* Don't change Default index 0,One pixel Width */
65 status = Xw_def_width(MyExtendedWidthMap,fwidth,width) ;
68 ErrorMessag = Xw_get_error(&ErrorNumber,&ErrorGravity) ;
69 if( ErrorGravity > 2 )
70 Aspect_BadAccess::Raise (ErrorMessag) ;
71 else Xw_print_error() ;
77 void Xw_WidthMap::SetEntries (const Handle(Aspect_WidthMap)& Widthmap) {
78 Standard_Integer size = Widthmap->Size() ;
81 if( !Xw_isdefine_widthmap(MyExtendedWidthMap) ) {
82 ErrorMessag = Xw_get_error(&ErrorNumber,&ErrorGravity) ;
83 if( ErrorGravity > 2 )
84 Aspect_WidthMapDefinitionError::Raise (ErrorMessag) ;
85 else Xw_print_error() ;
88 for( i=1 ; i<=size ; i++ ) {
89 SetEntry(Widthmap->Entry(i)) ;
93 void Xw_WidthMap::Destroy() {
95 if( MyExtendedWidthMap ) {
96 Xw_close_widthmap(MyExtendedWidthMap) ;
97 MyExtendedWidthMap = NULL ;
101 Standard_Integer Xw_WidthMap::FreeWidths( ) const {
102 Standard_Integer nwidth ;
103 int mwidth,uwidth,dwidth,fwidth ;
105 status = Xw_get_widthmap_info(MyExtendedWidthMap,
106 &mwidth,&uwidth,&dwidth,&fwidth) ;
109 ErrorMessag = Xw_get_error(&ErrorNumber,&ErrorGravity) ;
110 if( ErrorGravity > 2 )
111 Aspect_BadAccess::Raise (ErrorMessag) ;
112 else Xw_print_error() ;
115 nwidth = uwidth - dwidth ;
120 Standard_Address Xw_WidthMap::ExtendedWidthMap () const {
122 return (MyExtendedWidthMap);