1 // Created on: 1993-10-14
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
21 #define GG001 //GG_300197
22 // Preferer utiliser le visual de la root window en mode
23 // 2D plutot que de prendre un visual PseudoColor alors que la root
25 // Ceci corrige notamment les pb de colormap non intallees sur DEC
26 // lorsque la station est bootee en TrueColor.
32 //-Design Creation d'une unite graphique
45 #include <Xw_GraphicDevice.ixx>
47 // Routines C a declarer en extern
49 #include <Xw_Cextern.hxx>
52 //-Static data definitions
54 //static char *ErrorMessag,LocalMessag[80] ;
55 static char LocalMessag[80] ;
56 //static int ErrorNumber ;
57 //static int ErrorGravity ;
58 static XW_STATUS status ;
62 //-Global data definitions
66 Xw_GraphicDevice::Xw_GraphicDevice () : Aspect_GraphicDevice() {
67 MyExtendedDisplay = NULL;
70 Xw_GraphicDevice::Xw_GraphicDevice (const Standard_CString Connexion, const Xw_TypeOfMapping Mapping, const Standard_Integer Ncolors, const Standard_Boolean UseDefault) : Aspect_GraphicDevice() {
72 InitMaps(Connexion,Mapping,Ncolors,UseDefault) ;
75 void Xw_GraphicDevice::Destroy () {
77 if( MyColorMap2D != MyColorMap3D ) {
78 MyColorMap3D.Nullify();
79 MyColorMap2D.Nullify();
81 MyColorMap2D.Nullify();
88 if( MyExtendedDisplay ) {
89 status = Xw_close_display(MyExtendedDisplay) ;
91 MyExtendedDisplay = NULL;
95 void Xw_GraphicDevice::InitMaps (const Standard_CString Connexion,const Xw_TypeOfMapping Mapping,const Standard_Integer Ncolors,const Standard_Boolean UseDefault) {
97 Xw_TypeOfVisual v2d = Xw_TOV_DEFAULT ;
99 Xw_TypeOfVisual v2d = Xw_TOV_PREFERRED_PSEUDOCOLOR ;
101 Xw_TypeOfVisual v3d = Xw_TOV_PREFERRED_TRUECOLOR ;
103 Xw_set_trace(Xw::TraceLevel(),Xw::ErrorLevel()) ;
106 MyDisplay = TCollection_AsciiString(Connexion) ;
108 MyDisplay = TCollection_AsciiString("") ;
111 MyExtendedDisplay = Xw_open_display((Standard_PCharacter)MyDisplay.ToCString()) ;
113 if( !MyExtendedDisplay ) {
114 sprintf(LocalMessag,"Cannot connect to server '%s'",
115 MyDisplay.ToCString());
116 Aspect_GraphicDeviceDefinitionError::Raise (LocalMessag);
119 v2d = Xw_get_display_visual(MyExtendedDisplay,v2d) ;
120 MyColorMap2D = new Xw_ColorMap(MyDisplay.ToCString(),
121 v2d,Mapping,Ncolors,UseDefault) ;
123 v3d = Xw_get_display_visual(MyExtendedDisplay,v3d) ;
125 MyColorMap3D = new Xw_ColorMap(MyDisplay.ToCString(),
126 v3d,Mapping,Ncolors,UseDefault) ;
128 MyColorMap3D = MyColorMap2D ;
131 MyTypeMap = new Xw_TypeMap(MyDisplay.ToCString()) ;
132 MyWidthMap = new Xw_WidthMap(MyDisplay.ToCString()) ;
133 MyFontMap = new Xw_FontMap(MyDisplay.ToCString()) ;
134 MyMarkMap = new Xw_MarkMap(MyDisplay.ToCString()) ;
136 Standard_Address Bof;
137 Bof = ExtendedColorMap2D();
138 Bof = ExtendedColorMap3D();
139 Bof = ExtendedTypeMap();
140 Bof = ExtendedWidthMap();
141 Bof = ExtendedFontMap();
142 Bof = ExtendedMarkMap();
144 if( !ExtendedColorMap2D() ||
145 !ExtendedColorMap3D() ||
146 !ExtendedTypeMap() ||
147 !ExtendedWidthMap() ||
148 !ExtendedFontMap() ||
149 !ExtendedMarkMap() ) {
150 sprintf(LocalMessag,"Bad Graphic Device Attributs on '%s'",
152 Aspect_GraphicDeviceDefinitionError::Raise (LocalMessag);
156 Handle(Xw_ColorMap) Xw_GraphicDevice::ColorMap2D () const {
158 return (MyColorMap2D) ;
162 Xw_TypeOfVisual Xw_GraphicDevice::VisualClass2D () const {
164 return (MyColorMap2D->VisualClass()) ;
167 Xw_TypeOfVisual Xw_GraphicDevice::OverlayVisualClass2D () const {
169 return (MyColorMap2D->OverlayVisualClass()) ;
172 Standard_Address Xw_GraphicDevice::ExtendedColorMap2D () const {
174 return (MyColorMap2D->ExtendedColorMap());
177 Standard_Address Xw_GraphicDevice::ExtendedOverlayColorMap2D () const {
179 return (MyColorMap2D->ExtendedOverlayColorMap());
182 Handle(Xw_ColorMap) Xw_GraphicDevice::ColorMap3D () const {
184 return (MyColorMap3D) ;
187 Xw_TypeOfVisual Xw_GraphicDevice::VisualClass3D () const {
189 return (MyColorMap3D->VisualClass()) ;
192 Xw_TypeOfVisual Xw_GraphicDevice::OverlayVisualClass3D () const {
194 return (MyColorMap3D->OverlayVisualClass()) ;
197 Standard_Address Xw_GraphicDevice::ExtendedColorMap3D () const {
199 return (MyColorMap3D->ExtendedColorMap());
202 Standard_Address Xw_GraphicDevice::ExtendedOverlayColorMap3D () const {
204 return (MyColorMap3D->ExtendedOverlayColorMap());
207 Handle(Xw_TypeMap) Xw_GraphicDevice::TypeMap () const {
212 Standard_Address Xw_GraphicDevice::ExtendedTypeMap () const {
214 return (MyTypeMap->ExtendedTypeMap());
217 Handle(Xw_WidthMap) Xw_GraphicDevice::WidthMap () const {
219 return (MyWidthMap) ;
222 Standard_Address Xw_GraphicDevice::ExtendedWidthMap () const {
224 return (MyWidthMap->ExtendedWidthMap());
227 Handle(Xw_FontMap) Xw_GraphicDevice::FontMap () const {
232 Standard_Address Xw_GraphicDevice::ExtendedFontMap () const {
234 return (MyFontMap->ExtendedFontMap());
237 Handle(Xw_MarkMap) Xw_GraphicDevice::MarkMap () const {
242 Standard_Address Xw_GraphicDevice::ExtendedMarkMap () const {
244 return (MyMarkMap->ExtendedMarkMap());
247 Standard_CString Xw_GraphicDevice::Display () const {
249 return (MyDisplay.ToCString());
252 Standard_Address Xw_GraphicDevice::XDisplay () const {
253 Aspect_Handle *display ;
254 Aspect_Handle root,colormap ;
255 Xw_TypeOfVisual pclass ;
258 status = Xw_get_display_info(MyExtendedDisplay,&display,
259 &root,&colormap,&pclass,&depth) ;
264 Standard_Address Xw_GraphicDevice::ExtendedDisplay () const {
266 return (MyExtendedDisplay);
269 void Xw_GraphicDevice::DisplaySize (Standard_Integer &Width,Standard_Integer &Height) const {
272 status = Xw_get_screen_size(MyExtendedDisplay,&width,&height) ;
278 void Xw_GraphicDevice::DisplaySize (Quantity_Length &Width,Quantity_Length &Height) const {
281 status = Xw_get_mmscreen_size(MyExtendedDisplay,&width,&height) ;
283 Width = FROMMILLIMETER(width) ;
284 Height = FROMMILLIMETER(height) ;
287 Standard_Integer Xw_GraphicDevice::PlaneLayer (const Standard_Integer aVisualID) const {
289 return Xw_get_plane_layer(MyExtendedDisplay,aVisualID);
292 Handle(Aspect_GraphicDriver) Xw_GraphicDevice::GraphicDriver () const {
294 static Handle(Aspect_GraphicDriver) foo;
296 cout << "Xw_GraphicDevice::GraphicDriver returns foo\n" << flush;