b311480e |
1 | // Created by: NW,JPB,CAL,GG |
2 | // Copyright (c) 1991-1999 Matra Datavision |
3 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
4 | // |
5 | // The content of this file is subject to the Open CASCADE Technology Public |
6 | // License Version 6.5 (the "License"). You may not use the content of this file |
7 | // except in compliance with the License. Please obtain a copy of the License |
8 | // at http://www.opencascade.org and read it completely before using this file. |
9 | // |
10 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
11 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
12 | // |
13 | // The Original Code and all software distributed under the License is |
14 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
15 | // Initial Developer hereby disclaims all such warranties, including without |
16 | // limitation, any warranties of merchantability, fitness for a particular |
17 | // purpose or non-infringement. Please see the License for the specific terms |
18 | // and conditions governing the rights and limitations under the License. |
19 | |
7fd59977 |
20 | // Modified : |
21 | // GG PRO5426 21/11/96 |
22 | // Proteger le viewer 2D contre des tentatives d'affichage |
23 | // dans une fentre detruite ou iconifiee. |
24 | // GG PRO6633 21/08/97 |
25 | // Protection contre capture d'image de taille NULLE. |
26 | // GG OPTIMISATION 18/09/97 |
27 | // remplacer les appels myWindow->Position() par |
28 | // myWindow->Size() qui est plus optimum. |
29 | // GG OPTIMISATION 20/10/97 |
30 | // Implementation de DoMapping() |
31 | // qui met a jour le MAPPING de la fenetre lorsque |
32 | // un evenemment de type GUI_IconifyEvent arrive dans |
33 | // l'application. |
34 | // GG PRO10676 15/12/97 |
35 | // Permettre de definir une couleur directement par ses |
36 | // composantes. |
37 | // GG PRO14093 03/07/98 |
38 | // Eviter de "raiser" lorsqu'une erreur est detectee. |
39 | // GG PRO14951 20/07/98 |
40 | // Ne pas modifier la couleur du background de la fenetre |
41 | // lorsque aucune fille n'est cree. |
42 | // (voir GUI_WidgetTools::DumpWidget()) |
43 | // GG CSR404 11/05/99 |
44 | // Avoid a crash in Dialog engine with a great number |
45 | // of views. |
46 | // GG G004 28/01/00 Add gama correction computation before dumping |
47 | // an image. |
48 | // GG IMP060200 |
49 | // Xw_get_image() signature change. |
50 | // GG IMP070200 |
51 | // Add MMSize() method |
52 | // TCL at October 2000 (G002); new method SetBackground( CString aName ) |
53 | // SAV 24/11/01 SetBackground( Quantity_Color ) |
54 | |
55 | #define BUC60701 //GG 23/06/00 Enable to dump an exact image size |
56 | // according to the window size |
57 | #define RIC120302 //GG Add a NEW XParentWindow methods which enable |
58 | // to retrieve the parent of the actual Xwindow ID. |
59 | |
7fd59977 |
60 | |
61 | //-Version |
62 | |
63 | //-Design Creation d'une fenetre X |
64 | |
65 | //-Warning |
66 | |
67 | //-References |
68 | |
69 | //-Language C++ 2.0 |
70 | |
71 | //-Declarations |
72 | |
73 | // for the class |
74 | #include <Xw_Window.ixx> |
75 | // Routines C a declarer en extern |
76 | //extern "C" { |
77 | #include <Xw_Cextern.hxx> |
78 | //} |
79 | #include <Aspect_Convert.hxx> |
692613e5 |
80 | #include <Image_AlienPixMap.hxx> |
7fd59977 |
81 | |
82 | #include <Xw_Extension.h> |
83 | |
84 | //-Static data definitions |
85 | |
86 | static XW_STATUS status ; |
87 | |
88 | //============================================================================ |
89 | //==== HashCode : Returns a HashCode CString |
90 | //============================================================================ |
91 | inline Standard_Integer HashCode (const Standard_CString Value) |
92 | { |
93 | Standard_Integer i,n,aHashCode = 0; |
94 | union { |
95 | char charPtr[80]; |
96 | int intPtr[20]; |
97 | } u; |
98 | |
99 | n = strlen(Value); |
100 | |
101 | if( n > 0 ) { |
102 | if( n < 80 ) { |
103 | n = (n+3)/4; |
104 | u.intPtr[n-1] = 0; |
105 | strcpy(u.charPtr,Value); |
106 | } else { |
107 | n = 20; |
108 | strncpy(u.charPtr,Value,80); |
109 | } |
110 | |
111 | for( i=0 ; i<n ; i++ ) { |
112 | aHashCode = aHashCode ^ u.intPtr[i]; |
113 | } |
114 | } |
115 | |
116 | //printf(" HashCode of '%s' is %d\n",Value,aHashCode); |
117 | |
118 | return Abs(aHashCode) + 1; |
119 | } |
120 | |
121 | void Xw_Window::PrintError() { |
122 | Standard_CString ErrorMessag ; |
123 | Standard_Integer ErrorNumber ; |
124 | Standard_Integer ErrorGravity ; |
125 | |
126 | status = XW_SUCCESS ; |
127 | ErrorMessag = Xw_get_error(&ErrorNumber,&ErrorGravity) ; |
128 | Xw_print_error() ; |
129 | } |
130 | |
131 | //-Aliases |
132 | |
133 | //-Global data definitions |
134 | |
135 | //-Constructors |
136 | |
137 | Xw_Window::Xw_Window (const Handle(Xw_GraphicDevice)& Device) |
138 | : Aspect_Window(Device) |
139 | { |
140 | Init(); |
141 | } |
142 | |
143 | |
144 | //======================================================================= |
145 | //function : Xw_Window |
146 | //purpose : |
147 | //======================================================================= |
148 | Xw_Window::Xw_Window (const Handle(Xw_GraphicDevice)& Device, |
149 | const Standard_Integer aPart1, |
150 | const Standard_Integer aPart2, |
151 | const Xw_WindowQuality Quality, |
152 | const Quantity_NameOfColor BackColor) |
153 | : Aspect_Window(Device) |
154 | { |
155 | Init(); |
156 | Aspect_Handle aWindow = (aPart1 << 16) | (aPart2 & 0xFFFF); |
157 | SetWindow (aWindow, Quality, BackColor); |
158 | } |
159 | |
160 | //======================================================================= |
161 | //function : Xw_Window |
162 | //purpose : |
163 | //======================================================================= |
164 | Xw_Window::Xw_Window (const Handle(Xw_GraphicDevice)& Device, |
165 | const Aspect_Handle aWindow, |
166 | const Xw_WindowQuality Quality, |
167 | const Quantity_NameOfColor BackColor) |
168 | : Aspect_Window(Device) |
169 | { |
170 | Init(); |
171 | SetWindow (aWindow, Quality, BackColor); |
172 | } |
173 | |
174 | //======================================================================= |
175 | //function : Xw_Window |
176 | //purpose : |
177 | //======================================================================= |
178 | Xw_Window::Xw_Window (const Handle(Xw_GraphicDevice)& Device, |
179 | const Standard_CString Title, |
180 | const Quantity_Parameter Xc, |
181 | const Quantity_Parameter Yc, |
182 | const Quantity_Parameter Width, |
183 | const Quantity_Parameter Height, |
184 | const Xw_WindowQuality Quality, |
185 | const Quantity_NameOfColor BackColor, |
186 | const Aspect_Handle Parent) |
187 | : Aspect_Window(Device) |
188 | { |
189 | Init(); |
190 | SetWindow (Title,Xc,Yc,Width,Height,Quality,BackColor,Parent); |
191 | } |
192 | |
193 | //======================================================================= |
194 | //function : Xw_Window |
195 | //purpose : |
196 | //======================================================================= |
197 | Xw_Window::Xw_Window (const Handle(Xw_GraphicDevice)& theDevice, |
198 | const Standard_CString theTitle, |
199 | const Standard_Integer thePxLeft, |
200 | const Standard_Integer thePxTop, |
201 | const Standard_Integer theWidth, |
202 | const Standard_Integer theHeight, |
203 | const Xw_WindowQuality theQuality, |
204 | const Quantity_NameOfColor theBackColor, |
205 | const Aspect_Handle theParent) |
206 | : Aspect_Window (theDevice) |
207 | { |
208 | Init(); |
209 | |
210 | MyExtendedDisplay = theDevice->ExtendedDisplay(); |
211 | Standard_Integer aParentSizeX = 1; |
212 | Standard_Integer aParentSizeY = 1; |
213 | |
214 | Aspect_Handle aRoot, aColormap, *aDisplay; |
215 | Xw_TypeOfVisual aVisualClass; |
216 | Standard_Integer aVisualDepth; |
217 | Xw_get_display_info (MyExtendedDisplay, |
218 | &aDisplay, &aRoot, &aColormap, &aVisualClass, &aVisualDepth); |
219 | Xw_get_screen_size (MyExtendedDisplay, &aParentSizeX, &aParentSizeY); |
220 | if (theParent) |
221 | { |
222 | XWindowAttributes anAttributes; |
223 | if(XGetWindowAttributes ((Display* )aDisplay, theParent, &anAttributes)) |
224 | { |
225 | aParentSizeX = anAttributes.width; |
226 | aParentSizeY = anAttributes.height; |
227 | } |
228 | } |
229 | Quantity_Parameter aQCenterX, aQCenterY, aQSizeX, aQSizeY; |
230 | Aspect_Convert::ConvertCoordinates (aParentSizeX, aParentSizeY, |
231 | thePxLeft, thePxTop, theWidth, theHeight, |
232 | aQCenterX, aQCenterY, aQSizeX, aQSizeY); |
233 | SetWindow (theTitle, aQCenterX, aQCenterY, aQSizeX, aQSizeY, |
234 | theQuality, theBackColor, theParent); |
235 | } |
236 | |
237 | void Xw_Window::Init() |
238 | { |
239 | MyBackgroundIndex = 0 ; |
240 | |
241 | MyXWindow = 0 ; |
242 | MyXParentWindow = 0 ; |
243 | MyXPixmap = 0 ; |
244 | MyDepth = 0 ; |
245 | MyExtendedDisplay = NULL ; |
246 | MyExtendedWindow = NULL ; |
247 | MyExtendedColorMap = NULL ; |
248 | MyExtendedTypeMap = NULL ; |
249 | MyExtendedWidthMap = NULL ; |
250 | MyExtendedFontMap = NULL ; |
251 | MyExtendedMarkMap = NULL ; |
252 | |
253 | MyQuality = Xw_WQ_3DQUALITY; |
254 | MyVisualClass = Xw_TOV_STATICGRAY; |
255 | } |
256 | |
257 | //======================================================================= |
258 | //function : SetWindow |
259 | //purpose : |
260 | //======================================================================= |
261 | |
262 | void Xw_Window::SetWindow (const Aspect_Handle aWindow, |
263 | const Xw_WindowQuality Quality, |
264 | const Quantity_NameOfColor BackColor) |
265 | { |
266 | if( (Quality == Xw_WQ_TRANSPARENT) || (Quality == Xw_WQ_OVERLAY) ) { |
267 | SetWindow ("",0.5,0.5,1.0,1.0,Quality,BackColor,aWindow); |
268 | } else { |
269 | Aspect_Handle window,root,colormap,pixmap ; |
270 | Xw_TypeOfVisual visualclass ; |
271 | int visualdepth,visualid ; |
272 | const Handle(Xw_GraphicDevice)& Device = |
273 | Handle(Xw_GraphicDevice)::DownCast(MyGraphicDevice); |
274 | |
275 | MyExtendedDisplay = Device->ExtendedDisplay() ; |
276 | |
277 | MyBackgroundIndex = 0 ; |
278 | MyXWindow = aWindow ; |
279 | MyXParentWindow = aWindow ; |
280 | MyQuality = Quality ; |
281 | |
282 | if( !MyXWindow ) { |
283 | PrintError() ; |
284 | } |
285 | |
286 | MyExtendedWindow = |
287 | Xw_def_window (MyExtendedDisplay,MyXWindow,Standard_False); |
288 | |
289 | status = Xw_get_window_info(MyExtendedWindow,&window,&pixmap, |
290 | &root,&colormap,&visualclass, |
291 | &visualdepth,&visualid); |
292 | if( !status ) { |
293 | PrintError() ; |
294 | } |
295 | |
296 | Standard_Boolean Res1 = |
297 | (Device->ExtendedColorMap3D() == Device->ExtendedColorMap2D()); |
298 | Standard_Boolean Res2 = |
299 | (Quality == Xw_WQ_SAMEQUALITY); |
300 | Standard_Boolean Res3 = |
301 | (Quality == Xw_WQ_DRAWINGQUALITY && visualclass == Xw_TOV_PSEUDOCOLOR); |
302 | Standard_Boolean Res4 = |
303 | (Quality == Xw_WQ_3DQUALITY && visualclass == Xw_TOV_TRUECOLOR); |
304 | |
305 | //if (Quality == Xw_WQ_3DQUALITY && visualclass == Xw_TOV_PSEUDOCOLOR) { |
306 | //Res4 = Standard_True; |
307 | //visualclass = Xw_TOV_TRUECOLOR; |
308 | //} |
309 | |
310 | if (Res1 || Res2 || Res3 || Res4) { |
311 | |
312 | MyVisualClass = visualclass ; |
313 | MyXPixmap = pixmap ; |
314 | MyDepth = visualdepth ; |
315 | |
316 | if( MyVisualClass == Xw_TOV_TRUECOLOR ) { |
317 | MyColorMap = Device->ColorMap3D() ; |
318 | } else { |
319 | MyColorMap = Device->ColorMap2D() ; |
320 | } |
321 | |
322 | if( visualid == MyColorMap->OverlayVisualID() ) { |
323 | MyExtendedColorMap = MyColorMap->ExtendedOverlayColorMap(); |
324 | } else { |
325 | MyExtendedColorMap = MyColorMap->ExtendedColorMap(); |
326 | } |
327 | |
328 | MyTypeMap = Device->TypeMap() ; |
329 | MyExtendedTypeMap = Device->ExtendedTypeMap(); |
330 | MyWidthMap = Device->WidthMap() ; |
331 | MyExtendedWidthMap = Device->ExtendedWidthMap(); |
332 | MyFontMap = Device->FontMap() ; |
333 | MyExtendedFontMap = Device->ExtendedFontMap(); |
334 | MyMarkMap = Device->MarkMap() ; |
335 | MyExtendedMarkMap = Device->ExtendedMarkMap(); |
336 | |
337 | status = Xw_set_colormap(MyExtendedWindow,MyExtendedColorMap) ; |
338 | |
339 | if( !status ) { |
340 | PrintError() ; |
341 | } |
342 | |
343 | status = Xw_set_typemap(MyExtendedWindow,MyExtendedTypeMap) ; |
344 | |
345 | if( !status ) { |
346 | PrintError() ; |
347 | } |
348 | |
349 | status = Xw_set_widthmap(MyExtendedWindow,MyExtendedWidthMap) ; |
350 | |
351 | if( !status ) { |
352 | PrintError() ; |
353 | } |
354 | |
355 | status = Xw_set_fontmap(MyExtendedWindow,MyExtendedFontMap) ; |
356 | |
357 | if( !status ) { |
358 | PrintError() ; |
359 | } |
360 | |
361 | status = Xw_set_markmap(MyExtendedWindow,MyExtendedMarkMap) ; |
362 | |
363 | if( !status ) { |
364 | PrintError() ; |
365 | } |
366 | SetBackground(BackColor) ; |
367 | |
368 | } else { // Create a child of this Window in the right Visual |
369 | XW_WINDOWSTATE state = XW_WS_UNKNOWN ; |
370 | int pxc, pyc; |
371 | int width, height; |
372 | float ratio; |
373 | Quantity_Parameter Width = 1.0; |
374 | Quantity_Parameter Height= 1.0; |
375 | |
376 | state = Xw_get_window_position (MyExtendedWindow, |
377 | &pxc,&pyc,&width,&height); |
378 | if( state == XW_WS_UNKNOWN ) { |
379 | Xw_print_error() ; |
380 | } |
381 | ratio = float (width)/ float (height); |
382 | if (ratio > 1.) |
383 | Width = Width*ratio; |
384 | else |
385 | Height = Height/ratio; |
386 | SetWindow ("",0.5,0.5,Width,Height,Quality,BackColor,MyXWindow); |
387 | } |
388 | } |
389 | } |
390 | |
391 | //======================================================================= |
392 | //function : SetWindow |
393 | //purpose : |
394 | //======================================================================= |
395 | |
396 | void Xw_Window::SetWindow (const Standard_CString Title, |
397 | const Quantity_Parameter Xc, |
398 | const Quantity_Parameter Yc, |
399 | const Quantity_Parameter Width, |
400 | const Quantity_Parameter Height, |
401 | const Xw_WindowQuality Quality, |
402 | const Quantity_NameOfColor BackColor, |
403 | const Aspect_Handle Parent) |
404 | { |
405 | Aspect_Handle window,root,colormap,pixmap,*display ; |
406 | Xw_TypeOfVisual visualclass ; |
407 | Standard_Integer visualdepth,visualid,istransparent = Standard_False ; |
408 | |
409 | const Handle(Xw_GraphicDevice)& Device = |
410 | Handle(Xw_GraphicDevice)::DownCast(MyGraphicDevice); |
411 | |
412 | MyBackgroundIndex = 0 ; |
413 | MyExtendedDisplay = Device->ExtendedDisplay() ; |
414 | MyXParentWindow = Parent ; |
415 | MyXWindow = 0 ; |
416 | MyQuality = Quality ; |
417 | |
418 | switch (Quality) { |
419 | case Xw_WQ_3DQUALITY : |
420 | case Xw_WQ_PICTUREQUALITY : |
421 | MyColorMap = Device->ColorMap3D() ; |
422 | MyVisualClass = Device->VisualClass3D() ; |
423 | MyExtendedColorMap = Device->ExtendedColorMap3D(); |
424 | break ; |
425 | case Xw_WQ_DRAWINGQUALITY : |
426 | MyColorMap = Device->ColorMap2D() ; |
427 | MyVisualClass = Device->VisualClass2D() ; |
428 | MyExtendedColorMap = Device->ExtendedColorMap2D(); |
429 | break ; |
430 | case Xw_WQ_SAMEQUALITY : |
431 | if( !MyXParentWindow ) { |
432 | status = Xw_get_display_info (MyExtendedDisplay, |
433 | &display,&root,&colormap,&visualclass, |
434 | &visualdepth) ; |
435 | } else { |
436 | MyExtendedWindow = Xw_def_window(MyExtendedDisplay, |
437 | MyXParentWindow,Standard_False); |
438 | |
439 | status = Xw_get_window_info(MyExtendedWindow,&window, |
440 | &pixmap,&root,&colormap,&visualclass,&visualdepth, |
441 | &visualid) ; |
442 | Xw_close_window(MyExtendedWindow,Standard_False) ; |
443 | MyExtendedWindow = NULL; |
444 | } |
445 | |
446 | if( !status ) { |
447 | PrintError() ; |
448 | } |
449 | if( visualclass == Xw_TOV_TRUECOLOR ) { |
450 | MyColorMap = Device->ColorMap3D() ; |
451 | MyVisualClass = Device->VisualClass3D() ; |
452 | MyExtendedColorMap = Device->ExtendedColorMap3D(); |
453 | } else if( visualclass == Xw_TOV_PSEUDOCOLOR ) { |
454 | MyColorMap = Device->ColorMap2D() ; |
455 | MyVisualClass = Device->VisualClass2D() ; |
456 | MyExtendedColorMap = Device->ExtendedColorMap2D(); |
457 | } |
458 | break ; |
459 | case Xw_WQ_TRANSPARENT : |
460 | istransparent = Standard_True ; |
461 | case Xw_WQ_OVERLAY : |
462 | if( !MyXParentWindow ) { |
463 | status = Xw_get_display_info (MyExtendedDisplay, |
464 | &display,&root,&colormap,&visualclass, |
465 | &visualdepth) ; |
466 | } else { |
467 | MyExtendedWindow = Xw_def_window(MyExtendedDisplay, |
468 | MyXParentWindow,istransparent); |
469 | |
470 | status = Xw_get_window_info(MyExtendedWindow,&window, |
471 | &pixmap,&root,&colormap,&visualclass,&visualdepth, |
472 | &visualid) ; |
473 | Xw_close_window(MyExtendedWindow,Standard_False) ; |
474 | MyExtendedWindow = NULL; |
475 | } |
476 | |
477 | if( !status ) { |
478 | PrintError() ; |
479 | } |
480 | if( visualclass == Xw_TOV_TRUECOLOR ) { |
481 | MyColorMap = Device->ColorMap3D() ; |
482 | MyExtendedColorMap = Device->ExtendedOverlayColorMap3D(); |
483 | MyVisualClass = Xw_TOV_OVERLAY; |
484 | if( !MyExtendedColorMap ) { |
485 | MyVisualClass = Device->VisualClass3D() ; |
486 | MyExtendedColorMap = Device->ExtendedColorMap3D(); |
487 | } |
488 | } else if( visualclass == Xw_TOV_PSEUDOCOLOR ) { |
489 | MyColorMap = Device->ColorMap2D() ; |
490 | MyExtendedColorMap = Device->ExtendedOverlayColorMap2D(); |
491 | MyVisualClass = Xw_TOV_OVERLAY; |
492 | if( !MyExtendedColorMap ) { |
493 | MyVisualClass = Device->VisualClass2D() ; |
494 | MyExtendedColorMap = Device->ExtendedColorMap2D(); |
495 | } |
496 | } |
497 | break ; |
498 | } |
499 | |
500 | if( MyVisualClass != Xw_TOV_DEFAULT ) { |
501 | MyTypeMap = Device->TypeMap() ; |
502 | MyExtendedTypeMap = Device->ExtendedTypeMap(); |
503 | MyWidthMap = Device->WidthMap() ; |
504 | MyExtendedWidthMap = Device->ExtendedWidthMap(); |
505 | MyFontMap = Device->FontMap() ; |
506 | MyExtendedFontMap = Device->ExtendedFontMap(); |
507 | MyMarkMap = Device->MarkMap() ; |
508 | MyExtendedMarkMap = Device->ExtendedMarkMap(); |
509 | |
510 | MyXWindow = Xw_open_window(MyExtendedDisplay,MyVisualClass,MyXParentWindow, |
511 | (float)Xc,(float)Yc,(float)Width,(float)Height, |
512 | (Standard_PCharacter)Title,istransparent) ; |
513 | if( !MyXWindow ) { |
514 | PrintError() ; |
515 | } |
516 | |
517 | MyExtendedWindow = |
518 | Xw_def_window (MyExtendedDisplay,MyXWindow,istransparent); |
519 | |
520 | status = Xw_get_window_info(MyExtendedWindow,&window,&pixmap, |
521 | &root,&colormap,&visualclass,&visualdepth, |
522 | &visualid) ; |
523 | if( !status ) { |
524 | PrintError() ; |
525 | } |
526 | |
527 | MyXPixmap = pixmap ; |
528 | MyDepth = visualdepth ; |
529 | |
530 | status = Xw_set_colormap(MyExtendedWindow,MyExtendedColorMap) ; |
531 | |
532 | if( !status ) { |
533 | PrintError() ; |
534 | } |
535 | |
536 | status = Xw_set_typemap(MyExtendedWindow,MyExtendedTypeMap) ; |
537 | |
538 | if( !status ) { |
539 | PrintError() ; |
540 | } |
541 | |
542 | status = Xw_set_widthmap(MyExtendedWindow,MyExtendedWidthMap) ; |
543 | |
544 | if( !status ) { |
545 | PrintError() ; |
546 | } |
547 | |
548 | status = Xw_set_fontmap(MyExtendedWindow,MyExtendedFontMap) ; |
549 | |
550 | if( !status ) { |
551 | PrintError() ; |
552 | } |
553 | |
554 | status = Xw_set_markmap(MyExtendedWindow,MyExtendedMarkMap) ; |
555 | |
556 | if( !status ) { |
557 | PrintError() ; |
558 | } |
559 | |
560 | SetBackground(BackColor) ; |
561 | |
562 | if( MyXParentWindow && (MyXWindow != MyXParentWindow) ) Map() ; |
563 | } |
564 | } |
565 | |
566 | void Xw_Window::SetBackground (const Aspect_Background& Background) { |
567 | Quantity_Color Color = Background.Color() ; |
568 | |
569 | SetBackground(Color.Name()); |
570 | |
571 | } |
572 | |
573 | void Xw_Window::SetBackground (const Quantity_NameOfColor BackColor) { |
574 | Quantity_Color Color ; |
575 | Standard_Real r,g,b ; |
576 | Standard_Integer index; |
577 | |
578 | Standard_Integer bcolor = Standard_Integer(BackColor); |
579 | if( (MyQuality != Xw_WQ_TRANSPARENT) && (bcolor >= 0) ) { |
580 | MyBackground.SetColor(BackColor) ; |
581 | |
582 | Color = MyBackground.Color() ; |
583 | Color.Values(r,g,b,Quantity_TOC_RGB) ; |
584 | |
585 | status = Xw_get_color_index(MyExtendedColorMap, |
586 | (float)r,(float)g,(float)b,&index); |
587 | |
588 | if( status ) { |
589 | MyBackgroundIndex = index; |
590 | status = Xw_close_background_pixmap(MyExtendedWindow); |
591 | status = Xw_set_background_index (MyExtendedWindow,index) ; |
592 | } |
593 | |
594 | if( !status ) { |
595 | PrintError() ; |
596 | } |
597 | } |
598 | } |
599 | |
600 | void Xw_Window::SetBackground(const Quantity_Color& color ) |
601 | { |
602 | Standard_Real r,g,b; |
603 | Standard_Integer index; |
604 | |
605 | Standard_Integer bcolor = Standard_Integer( color.Name() ); |
606 | |
607 | if( ( MyQuality != Xw_WQ_TRANSPARENT ) && ( bcolor >= 0 ) ) { |
608 | |
609 | MyBackground.SetColor( color ) ; |
610 | color.Values( r, g, b, Quantity_TOC_RGB ); |
611 | |
612 | status = Xw_get_color_index( MyExtendedColorMap, |
613 | (float)r, (float)g, (float)b, &index); |
614 | |
615 | if( status ) { |
616 | MyBackgroundIndex = index; |
617 | status = Xw_close_background_pixmap( MyExtendedWindow ); |
618 | status = Xw_set_background_index( MyExtendedWindow, index ); |
619 | } |
620 | |
621 | if( !status ) { |
622 | PrintError() ; |
623 | } |
624 | } |
625 | } |
626 | |
627 | //======================================================================= |
628 | //function : SetBackground |
629 | //purpose : |
630 | //======================================================================= |
631 | |
632 | void Xw_Window::SetBackground (const Aspect_Handle aPixmap) |
633 | { |
634 | status = Xw_set_background_pixmap( MyExtendedWindow, aPixmap); |
635 | if ( status ) { |
636 | MyHBackground = aPixmap; |
637 | MyBackgroundImage.Clear(); |
638 | MyBackgroundFillMethod = Aspect_FM_NONE; |
639 | } else { |
640 | PrintError(); |
641 | } |
642 | } |
643 | |
644 | Standard_Boolean Xw_Window::SetBackground( const Standard_CString aName, |
645 | const Aspect_FillMethod aMethod ) { |
646 | |
647 | if( !aName ) return Standard_False; |
648 | |
649 | status = XW_ERROR; |
650 | Standard_Integer hash_code = ::HashCode( aName ); |
651 | XW_EXT_IMAGEDATA* pimage = (XW_EXT_IMAGEDATA* )Xw_get_image_handle (MyExtendedWindow, (void* )hash_code); |
652 | |
653 | if ( !pimage ) |
654 | pimage = (XW_EXT_IMAGEDATA* )Xw_load_image(MyExtendedWindow,(void*)hash_code,(Standard_PCharacter)aName ); |
655 | |
656 | if ( pimage ) |
657 | status = Xw_put_background_image( MyExtendedWindow, pimage, aMethod ); |
658 | |
659 | if ( status ) { |
660 | MyBackgroundImage = aName; |
661 | MyBackgroundFillMethod = aMethod; |
662 | Xw_get_background_pixmap( MyExtendedWindow, MyHBackground); |
663 | } else { |
664 | PrintError(); |
665 | } |
666 | |
667 | return status; |
668 | |
669 | } // end Xw_Window::SetBackground |
670 | |
671 | void Xw_Window::SetBackground (const Aspect_GradientBackground& GrBackground) { |
672 | |
673 | Quantity_Color Color1, Color2; |
674 | GrBackground.Colors(Color1,Color2); |
675 | SetBackground(Color1,Color2, GrBackground.BgGradientFillMethod()); |
676 | |
677 | } |
678 | |
679 | void Xw_Window::SetBackground( const Quantity_Color& color1, |
680 | const Quantity_Color& color2, |
681 | const Aspect_GradientFillMethod aMethod) { |
682 | |
683 | Standard_Integer bcolor = Standard_Integer( color1.Name() ) + Standard_Integer( color2.Name() ); |
684 | if( ( MyQuality != Xw_WQ_TRANSPARENT ) && ( bcolor >= 0 ) ) |
685 | MyGradientBackground.SetColors( color1, color2, aMethod ) ; |
686 | |
687 | } |
688 | |
689 | void Xw_Window::SetDoubleBuffer (const Standard_Boolean DBmode) { |
690 | |
691 | status = Xw_set_double_buffer(MyExtendedWindow, |
692 | (XW_DOUBLEBUFFERMODE)DBmode) ; |
693 | |
694 | if( !status ) { |
695 | PrintError() ; |
696 | } |
697 | } |
698 | |
699 | void Xw_Window::Flush() const { |
700 | |
701 | status = Xw_flush (MyExtendedWindow,Standard_False); |
702 | |
703 | if( !status ) { |
704 | PrintError() ; |
705 | } |
706 | } |
707 | |
708 | void Xw_Window::Map () const { |
709 | #ifdef RIC120302 |
710 | if( MyXWindow == MyXParentWindow ) return; |
711 | #endif |
712 | if (IsVirtual()) return; |
713 | status = Xw_set_window_state (MyExtendedWindow, XW_MAP); |
714 | if( !status ) { |
715 | PrintError() ; |
716 | } |
717 | } |
718 | |
719 | void Xw_Window::Unmap () const { |
720 | #ifdef RIC120302 |
721 | if( MyXWindow == MyXParentWindow ) return; |
722 | #endif |
723 | status = Xw_set_window_state (MyExtendedWindow, XW_ICONIFY); |
724 | if( !status ) { |
725 | PrintError() ; |
726 | } |
727 | } |
728 | |
729 | Aspect_TypeOfResize Xw_Window::DoResize () const { |
730 | XW_RESIZETYPE state ; |
731 | |
732 | state = Xw_resize_window (MyExtendedWindow); |
733 | // if( state == Aspect_TOR_UNKNOWN ) { |
734 | if( state == XW_TOR_UNKNOWN ) { |
735 | PrintError() ; |
736 | } |
737 | |
738 | return (Aspect_TypeOfResize(state)) ; |
739 | } |
740 | |
741 | Standard_Boolean Xw_Window::DoMapping () const { |
742 | int pxc,pyc,width,height; |
743 | XW_WINDOWSTATE state; |
744 | |
745 | state = Xw_get_window_position (MyExtendedWindow,&pxc,&pyc,&width,&height); |
746 | |
747 | return IsMapped(); |
748 | } |
749 | |
750 | void Xw_Window::Destroy () { |
751 | Standard_Boolean destroy = |
752 | ( MyXWindow == MyXParentWindow ) ? Standard_False : Standard_True; |
753 | |
754 | status = Xw_close_window (MyExtendedWindow,destroy); |
755 | if( !status ) { |
756 | PrintError() ; |
757 | } |
758 | |
759 | MyXWindow = 0 ; |
760 | MyExtendedWindow = NULL ; |
761 | MyExtendedColorMap = NULL ; |
762 | MyExtendedTypeMap = NULL ; |
763 | MyExtendedWidthMap = NULL ; |
764 | MyExtendedFontMap = NULL ; |
765 | MyExtendedMarkMap = NULL ; |
766 | } |
767 | |
768 | void Xw_Window::Clear () const { |
769 | |
770 | status = Xw_erase_window (MyExtendedWindow); |
771 | |
772 | if( !status ) { |
773 | PrintError() ; |
774 | } |
775 | } |
776 | |
777 | void Xw_Window::ClearArea (const Standard_Integer Xc, const Standard_Integer Yc, const Standard_Integer Width, const Standard_Integer Height) const { |
778 | |
779 | status = Xw_erase_area (MyExtendedWindow,int(Xc),int(Yc), |
780 | int(Width),int(Height)); |
781 | |
782 | if( !status ) { |
783 | PrintError() ; |
784 | } |
785 | } |
786 | |
787 | void Xw_Window::Restore () const { |
788 | |
789 | if( !IsMapped() ) return; |
790 | status = Xw_restore_window (MyExtendedWindow); |
791 | |
792 | if( !status ) { |
793 | PrintError() ; |
794 | } |
795 | } |
796 | |
797 | void Xw_Window::RestoreArea (const Standard_Integer Xc, const Standard_Integer Yc, const Standard_Integer Width, const Standard_Integer Height) const { |
798 | |
799 | if( !IsMapped() ) return; |
800 | status = Xw_restore_area (MyExtendedWindow,int(Xc),int(Yc), |
801 | int(Width),int(Height)); |
802 | |
803 | if( !status ) { |
804 | PrintError() ; |
805 | } |
806 | } |
807 | |
808 | Standard_Boolean Xw_Window::Dump (const Standard_CString theFilename, |
809 | const Standard_Real theGammaValue) const |
810 | { |
811 | int aDummy, aWidth, aHeight; |
812 | XW_WINDOWSTATE state = Xw_get_window_position (MyExtendedWindow, |
813 | &aDummy, &aDummy, &aWidth, &aHeight); |
814 | if (state == XW_WS_UNKNOWN) |
815 | { |
816 | return Standard_False; |
817 | } |
818 | |
819 | return DumpArea (theFilename, aWidth / 2, aHeight / 2, |
820 | aWidth, aHeight, theGammaValue); |
821 | } |
822 | |
823 | Standard_Boolean Xw_Window::DumpArea (const Standard_CString theFilename, |
824 | const Standard_Integer theXc, const Standard_Integer theYc, |
825 | const Standard_Integer theWidth, const Standard_Integer theHeight, |
826 | const Standard_Real theGammaValue) const |
827 | { |
828 | int aWidth = Abs(theWidth); |
829 | int aHeight = Abs(theHeight); |
830 | XW_EXT_IMAGEDATA* pimage = NULL; |
831 | if (DoubleBuffer()) |
832 | { |
833 | Aspect_Handle window, root, colormap, pixmap; |
834 | Xw_TypeOfVisual visualclass; |
835 | int visualdepth, visualid; |
836 | Xw_get_window_info (MyExtendedWindow, &window, &pixmap, |
837 | &root, &colormap, &visualclass, |
838 | &visualdepth, &visualid); |
839 | |
840 | pimage = (XW_EXT_IMAGEDATA* )Xw_get_image_from_pixmap (MyExtendedWindow, (Standard_PCharacter )theFilename, |
841 | pixmap, |
842 | theXc, theYc, aWidth, aHeight); |
843 | } |
844 | else |
845 | { |
846 | pimage = (XW_EXT_IMAGEDATA* )Xw_get_image (MyExtendedWindow, (Standard_PCharacter )theFilename, |
847 | theXc, theYc, aWidth, aHeight); |
848 | } |
849 | |
850 | if (pimage == NULL) |
851 | { |
852 | return Standard_False; |
853 | } |
854 | |
855 | if (theGammaValue != 1.0) |
856 | { |
857 | Xw_gamma_image (pimage, Standard_ShortReal (theGammaValue)); |
858 | } |
859 | XW_STATUS aStatus = Xw_save_image (MyExtendedWindow, pimage, (Standard_PCharacter )theFilename); |
860 | Xw_close_image (pimage); |
861 | |
862 | return Standard_Boolean(aStatus); |
863 | } |
864 | |
692613e5 |
865 | Standard_Boolean Xw_Window::ToPixMap (Image_PixMap& thePixMap) const |
7fd59977 |
866 | { |
7fd59977 |
867 | int aDummy, aWidth, aHeight; |
868 | XW_WINDOWSTATE state = Xw_get_window_position (MyExtendedWindow, |
869 | &aDummy, &aDummy, &aWidth, &aHeight); |
870 | if (state == XW_WS_UNKNOWN) |
871 | { |
692613e5 |
872 | return Standard_False; |
7fd59977 |
873 | } |
874 | |
875 | XW_EXT_IMAGEDATA* pimage = NULL; |
876 | if (DoubleBuffer()) |
877 | { |
878 | Aspect_Handle window, root, colormap, pixmap; |
879 | Xw_TypeOfVisual visualclass; |
880 | int visualdepth, visualid; |
881 | Xw_get_window_info (MyExtendedWindow, &window, &pixmap, |
882 | &root, &colormap, &visualclass, |
883 | &visualdepth, &visualid); |
884 | |
885 | pimage = (XW_EXT_IMAGEDATA* )Xw_get_image_from_pixmap (MyExtendedWindow, NULL, |
886 | pixmap, |
887 | aWidth / 2, aHeight / 2, aWidth, aHeight); |
888 | } |
889 | else |
890 | { |
891 | pimage = (XW_EXT_IMAGEDATA* )Xw_get_image (MyExtendedWindow, NULL, |
892 | aWidth / 2, aHeight / 2, aWidth, aHeight); |
893 | } |
894 | |
895 | if (pimage == NULL) |
896 | { |
692613e5 |
897 | return Standard_False; |
7fd59977 |
898 | } |
899 | |
900 | XImage* pximage = (pimage->zximage) ? pimage->zximage : pimage->pximage; |
901 | XW_EXT_WINDOW* pwindow = (XW_EXT_WINDOW* )MyExtendedWindow; |
692613e5 |
902 | if (pwindow->pcolormap->visual->c_class != TrueColor) |
7fd59977 |
903 | { |
692613e5 |
904 | return Standard_False; |
7fd59977 |
905 | } |
692613e5 |
906 | |
907 | const bool isBigEndian = (pximage->byte_order == MSBFirst); |
908 | Image_PixMap::ImgFormat aFormat = (pximage->bits_per_pixel == 32) |
909 | ? (isBigEndian ? Image_PixMap::ImgRGB32 : Image_PixMap::ImgBGR32) |
910 | : (isBigEndian ? Image_PixMap::ImgRGB : Image_PixMap::ImgBGR); |
911 | Image_PixMap aWrapper; |
912 | aWrapper.InitWrapper (aFormat, (Standard_Byte* )pximage->data, pximage->width, pximage->height, pximage->bytes_per_line); |
913 | aWrapper.SetTopDown (true); |
914 | |
915 | Standard_Boolean isSuccess = thePixMap.InitCopy (aWrapper); |
7fd59977 |
916 | Xw_close_image (pimage); |
692613e5 |
917 | return isSuccess; |
7fd59977 |
918 | } |
919 | |
920 | Standard_Boolean Xw_Window::Load (const Standard_CString aFilename) const { |
921 | Standard_Integer hashcode = ::HashCode(aFilename) ; |
922 | XW_WINDOWSTATE state; |
923 | int pxc,pyc,wwidth,wheight,iwidth,iheight,idepth,resize = Standard_False; |
924 | float izoom; |
925 | |
926 | state = Xw_get_window_position (MyExtendedWindow,&pxc,&pyc,&wwidth,&wheight); |
927 | |
928 | status = XW_ERROR; |
929 | XW_EXT_IMAGEDATA* pimage = (XW_EXT_IMAGEDATA* )Xw_get_image_handle( MyExtendedWindow,(void*)hashcode ) ; |
930 | if( !pimage ) { |
931 | pimage = (XW_EXT_IMAGEDATA* )Xw_load_image(MyExtendedWindow,(void*)hashcode,(Standard_PCharacter)aFilename ); |
932 | } |
933 | |
934 | if( pimage ) { |
935 | status = Xw_get_image_info(pimage,&izoom,&iwidth,&iheight,&idepth); |
936 | iwidth = (int)(iwidth/izoom); |
937 | iheight = (int)(iheight/izoom); |
938 | } |
939 | |
940 | if( status && state != XW_WS_UNKNOWN ) { |
941 | float uxc,uyc ; |
942 | if( iwidth > wwidth ) { |
943 | resize = Standard_True; |
944 | wwidth = iwidth; |
945 | } |
946 | if( iheight > wheight ) { |
947 | resize = Standard_True; |
948 | wheight = iheight; |
949 | } |
950 | if( resize ) { |
951 | status = Xw_set_window_position (MyExtendedWindow, |
952 | pxc,pyc,wwidth,wheight); |
953 | } |
954 | status = Xw_get_window_pixelcoord(MyExtendedWindow, |
955 | wwidth/2,wheight/2,&uxc,&uyc); |
956 | status = Xw_draw_image(MyExtendedWindow, pimage, uxc, uyc); |
957 | Xw_flush(MyExtendedWindow, Standard_True); |
958 | } else status = XW_ERROR ; |
959 | |
960 | if( !status ) { |
961 | PrintError() ; |
962 | } |
963 | |
964 | return Standard_Boolean(status); |
965 | } |
966 | |
967 | Standard_Boolean Xw_Window::LoadArea (const Standard_CString aFilename, const Standard_Integer Xc, const Standard_Integer Yc, const Standard_Integer Width, const Standard_Integer Height) const { |
968 | Standard_Integer hashcode = ::HashCode(aFilename) ; |
969 | int pxc,pyc,wwidth,wheight,iwidth,iheight,idepth; |
970 | float izoom,uxc,uyc; |
971 | |
972 | XW_WINDOWSTATE state = Xw_get_window_position (MyExtendedWindow,&pxc,&pyc,&wwidth,&wheight); |
973 | status = XW_ERROR; |
974 | XW_EXT_IMAGEDATA* pimage = (XW_EXT_IMAGEDATA* )Xw_get_image_handle( MyExtendedWindow,(void*)hashcode ) ; |
975 | if( !pimage ) { |
976 | pimage = (XW_EXT_IMAGEDATA* )Xw_load_image(MyExtendedWindow,(void*)hashcode,(Standard_PCharacter)aFilename ); |
977 | } |
978 | |
979 | if( pimage ) { |
980 | status = Xw_get_image_info(pimage,&izoom,&iwidth,&iheight,&idepth); |
981 | iwidth = (int)(iwidth/izoom); |
982 | iheight = (int)(iheight/izoom); |
983 | } |
984 | |
985 | if( status && state != XW_WS_UNKNOWN ) { |
986 | if( iwidth > Width || iheight > Height ) { |
987 | izoom = (float)Min(Width,Height)/(float)Max(iwidth,iheight) ; |
988 | status = Xw_zoom_image(pimage,izoom) ; |
989 | } |
990 | status = Xw_get_window_pixelcoord(MyExtendedWindow,Xc,Yc,&uxc,&uyc); |
991 | status = Xw_draw_image(MyExtendedWindow, pimage, uxc, uyc); |
992 | Xw_flush(MyExtendedWindow, Standard_True); |
993 | } else status = XW_ERROR ; |
994 | |
995 | if( !status ) { |
996 | PrintError() ; |
997 | } |
998 | |
999 | return Standard_Boolean(status); |
1000 | } |
1001 | |
1002 | void Xw_Window::SetCursor (const Standard_Integer anId, const Quantity_NameOfColor aColor) const { |
1003 | Quantity_Color Color(aColor) ; |
1004 | Standard_Real r,g,b ; |
1005 | |
1006 | Color.Values(r,g,b,Quantity_TOC_RGB) ; |
1007 | |
1008 | status = Xw_set_hard_cursor (MyExtendedWindow,(int)anId,0, |
1009 | (float)r, |
1010 | (float)g, |
1011 | (float)b) ; |
1012 | |
1013 | if( !status ) { |
1014 | PrintError() ; |
1015 | } |
1016 | } |
1017 | |
1018 | Standard_Boolean Xw_Window::BackingStore () const { |
1019 | |
1020 | if( MyXPixmap ) status = XW_SUCCESS ; |
1021 | else { |
1022 | status = Xw_open_pixmap(MyExtendedWindow) ; |
1023 | } |
1024 | |
1025 | return (Standard_Boolean(status)) ; |
1026 | } |
1027 | |
1028 | Standard_Boolean Xw_Window::DoubleBuffer () const { |
1029 | XW_DOUBLEBUFFERMODE state = Xw_get_double_buffer(MyExtendedWindow) ; |
1030 | |
1031 | return (state == XW_ENABLE ? Standard_True : Standard_False) ; |
1032 | } |
1033 | |
1034 | Standard_Boolean Xw_Window::IsMapped () const { |
1035 | if (IsVirtual()) { |
1036 | return Standard_True; |
1037 | } |
1038 | XW_WINDOWSTATE state; |
1039 | state = Xw_get_window_state (MyExtendedWindow); |
1040 | switch (state) { |
1041 | case XW_WS_UNKNOWN: |
1042 | return Standard_False; |
1043 | case XW_ICONIFY: |
1044 | return Standard_False; |
1045 | case XW_PUSH: |
1046 | return Standard_True; |
1047 | case XW_MAP: |
1048 | return Standard_True; |
1049 | #ifndef DEB |
1050 | default: |
1051 | return Standard_False; |
1052 | #endif |
1053 | } |
1054 | return Standard_False; |
1055 | } |
1056 | |
1057 | Standard_Real Xw_Window::Ratio () const { |
1058 | int width, height; |
1059 | |
1060 | status = Xw_get_window_size (MyExtendedWindow,&width,&height); |
1061 | if( !status ) { |
1062 | Xw_print_error() ; |
1063 | } |
1064 | |
1065 | return ((Standard_Real)width/height) ; |
1066 | } |
1067 | |
1068 | void Xw_Window::Size (Standard_Real &Width, Standard_Real &Height) const { |
1069 | int width, height; |
1070 | |
1071 | status = Xw_get_window_size (MyExtendedWindow,&width,&height); |
1072 | if( !status ) { |
1073 | Xw_print_error() ; |
1074 | } |
1075 | |
1076 | Width = Xw_get_screen_pixelvalue (MyExtendedDisplay,width) ; |
1077 | Height = Xw_get_screen_pixelvalue (MyExtendedDisplay,height) ; |
1078 | } |
1079 | |
1080 | void Xw_Window::Size (Standard_Integer &Width, Standard_Integer &Height) const { |
1081 | int width, height; |
1082 | status = Xw_get_window_size (MyExtendedWindow,&width,&height); |
1083 | if( !status ) { |
1084 | Xw_print_error() ; |
1085 | } |
1086 | |
1087 | Width = width ; |
1088 | Height = height ; |
1089 | } |
1090 | |
1091 | void Xw_Window::MMSize (Standard_Real &Width, Standard_Real &Height) const { |
1092 | int width, height; |
1093 | |
1094 | status = Xw_get_window_size (MyExtendedWindow,&width,&height); |
1095 | if( !status ) { |
1096 | Xw_print_error() ; |
1097 | } |
1098 | |
1099 | float x,y ; |
1100 | status = Xw_get_window_pixelcoord(MyExtendedWindow, |
1101 | width,0,&x,&y) ; |
1102 | if( !status ) { |
1103 | PrintError() ; |
1104 | } |
1105 | |
1106 | Width = Standard_Real(x); Height = Standard_Real(y); |
1107 | } |
1108 | |
1109 | void Xw_Window::Position (Standard_Real &X1, Standard_Real &Y1, Standard_Real &X2, Standard_Real &Y2) const { |
1110 | XW_WINDOWSTATE state = XW_WS_UNKNOWN ; |
1111 | int pxc, pyc; |
1112 | int width, height; |
1113 | float x1,y1,x2,y2 ; |
1114 | |
1115 | state = Xw_get_window_position (MyExtendedWindow, |
1116 | &pxc,&pyc,&width,&height); |
1117 | if( state == XW_WS_UNKNOWN ) { |
1118 | Xw_print_error() ; |
1119 | } |
1120 | Xw_get_screen_pixelcoord (MyExtendedDisplay,pxc-width/2, |
1121 | pyc-height/2, |
1122 | &x1,&y1) ; |
1123 | Xw_get_screen_pixelcoord (MyExtendedDisplay,pxc+width/2, |
1124 | pyc+height/2, |
1125 | &x2,&y2) ; |
1126 | X1 = x1 ; Y1 = y2 ; X2 = x2 ; Y2 = y1 ; |
1127 | } |
1128 | |
1129 | void Xw_Window::Position (Standard_Integer &X1, Standard_Integer &Y1, Standard_Integer &X2, Standard_Integer &Y2) const { |
1130 | XW_WINDOWSTATE state = XW_WS_UNKNOWN ; |
1131 | int pxc, pyc; |
1132 | int width, height; |
1133 | |
1134 | state = Xw_get_window_position (MyExtendedWindow, |
1135 | &pxc,&pyc,&width,&height); |
1136 | if( state == XW_WS_UNKNOWN ) { |
1137 | Xw_print_error() ; |
1138 | } |
1139 | |
1140 | X1 = pxc - width/2 ; Y1 = pyc - height/2 ; |
1141 | X2 = X1 + width - 1 ; Y2 = Y1 + height - 1 ; |
1142 | } |
1143 | |
1144 | Standard_Real Xw_Window::Convert (const Standard_Integer Pv) const { |
1145 | Standard_Real Dv ; |
1146 | |
1147 | Dv = Xw_get_screen_pixelvalue(MyExtendedDisplay,(int)Pv) ; |
1148 | |
1149 | return (Dv) ; |
1150 | } |
1151 | |
1152 | void Xw_Window::Convert (const Standard_Integer Px, const Standard_Integer Py, Standard_Real &Dx, Standard_Real &Dy ) const { |
1153 | float x,y ; |
1154 | |
1155 | status = Xw_get_screen_pixelcoord(MyExtendedDisplay, |
1156 | (int)Px,(int)Py,&x,&y) ; |
1157 | |
1158 | if( !status ) { |
1159 | Xw_print_error() ; |
1160 | } |
1161 | |
1162 | Dx = x ; Dy = y ; |
1163 | } |
1164 | |
1165 | Standard_Integer Xw_Window::Convert (const Standard_Real Dv) const { |
1166 | Standard_Integer Pv ; |
1167 | |
1168 | Pv = Xw_get_pixel_screenvalue(MyExtendedDisplay,(float)Dv) ; |
1169 | |
1170 | return (Pv) ; |
1171 | } |
1172 | |
1173 | void Xw_Window::Convert (const Standard_Real Dx, const Standard_Real Dy, Standard_Integer &Px, Standard_Integer &Py ) const { |
1174 | int x,y ; |
1175 | |
1176 | status = Xw_get_pixel_screencoord(MyExtendedDisplay, |
1177 | (float)Dx,(float)Dy,&x,&y) ; |
1178 | |
1179 | if( !status ) { |
1180 | Xw_print_error() ; |
1181 | } |
1182 | |
1183 | Px = x ; Py = y ; |
1184 | } |
1185 | |
1186 | Handle(Xw_ColorMap) Xw_Window::ColorMap() const { |
1187 | |
1188 | return (MyColorMap) ; |
1189 | } |
1190 | |
1191 | Handle(Xw_TypeMap) Xw_Window::TypeMap() const { |
1192 | |
1193 | return (MyTypeMap) ; |
1194 | } |
1195 | |
1196 | Handle(Xw_WidthMap) Xw_Window::WidthMap() const { |
1197 | |
1198 | return (MyWidthMap) ; |
1199 | } |
1200 | |
1201 | Handle(Xw_FontMap) Xw_Window::FontMap() const { |
1202 | |
1203 | return (MyFontMap) ; |
1204 | } |
1205 | |
1206 | Handle(Xw_MarkMap) Xw_Window::MarkMap() const { |
1207 | |
1208 | return (MyMarkMap) ; |
1209 | } |
1210 | |
1211 | Aspect_Handle Xw_Window::XWindow () const { |
1212 | |
1213 | return (MyXWindow); |
1214 | |
1215 | } |
1216 | |
1217 | void Xw_Window::XWindow (Standard_Integer& aPart1, Standard_Integer& aPart2) const { |
1218 | |
1219 | aPart1 = (Standard_Integer)((MyXWindow >> 16 ) & 0xffff); |
1220 | aPart2 = (Standard_Integer)(MyXWindow & 0xffff); |
1221 | } |
1222 | |
1223 | // RIC120302 |
1224 | Aspect_Handle Xw_Window::XParentWindow () const { |
1225 | |
1226 | return (MyXParentWindow); |
1227 | |
1228 | } |
1229 | |
1230 | void Xw_Window::XParentWindow (Standard_Integer& aPart1, Standard_Integer& aPart2) const { |
1231 | |
1232 | aPart1 = (Standard_Integer)((MyXParentWindow >> 16 ) & 0xffff); |
1233 | aPart2 = (Standard_Integer)(MyXParentWindow & 0xffff); |
1234 | } |
1235 | // RIC120302 |
1236 | |
1237 | Aspect_Handle Xw_Window::XPixmap () const { |
1238 | Aspect_Handle window,pixmap,root,colormap ; |
1239 | Xw_TypeOfVisual visualclass ; |
1240 | int visualdepth,visualid ; |
1241 | |
1242 | status = Xw_get_window_info(MyExtendedWindow,&window,&pixmap, |
1243 | &root,&colormap,&visualclass,&visualdepth,&visualid) ; |
1244 | |
1245 | return (pixmap); |
1246 | } |
1247 | |
1248 | Standard_Address Xw_Window::XVisual( ) const |
1249 | { |
1250 | Aspect_Handle *VisualInfo ; |
1251 | Xw_TypeOfVisual VisualClass ; |
1252 | int MaxColor,BaseColor,MaxUserColor,MaxDefineColor,FirstFreeColorIndex,visualid ; |
1253 | |
1254 | status = Xw_get_colormap_info(MyExtendedColorMap,&VisualInfo, |
1255 | &VisualClass,&visualid,&MaxColor,&BaseColor, |
1256 | &MaxUserColor,&MaxDefineColor,&FirstFreeColorIndex); |
1257 | |
1258 | if( !status ) { |
1259 | PrintError() ; |
1260 | } |
1261 | |
1262 | return (VisualInfo) ; |
1263 | } |
1264 | |
1265 | Aspect_Handle Xw_Window::XColorMap( ) const |
1266 | { |
1267 | Aspect_Handle colormap ; |
1268 | |
1269 | colormap = Xw_get_colormap_xid(MyExtendedColorMap) ; |
1270 | |
1271 | if( !colormap ) { |
1272 | PrintError() ; |
1273 | } |
1274 | |
1275 | return (colormap) ; |
1276 | } |
1277 | |
1278 | Standard_Boolean Xw_Window::PointerPosition (Standard_Integer& X, Standard_Integer& Y) const { |
1279 | Standard_Boolean cstatus ; |
1280 | int x,y ; |
1281 | |
1282 | cstatus = Xw_get_cursor_position(MyExtendedWindow,&x,&y) ; |
1283 | X = x ; |
1284 | Y = y ; |
1285 | |
1286 | return (cstatus); |
1287 | } |
1288 | |
1289 | Xw_TypeOfVisual Xw_Window::VisualClass () const { |
1290 | |
1291 | return (MyVisualClass); |
1292 | |
1293 | } |
1294 | |
1295 | Standard_Integer Xw_Window::VisualDepth () const { |
1296 | |
1297 | return (MyDepth); |
1298 | |
1299 | } |
1300 | |
1301 | Standard_Integer Xw_Window::VisualID( ) const { |
1302 | Aspect_Handle *VisualInfo ; |
1303 | Xw_TypeOfVisual VisualClass ; |
1304 | int MaxColor,BasePixel,MaxUserColor,MaxDefineColor,FirstFreeColorIndex,visualid |
1305 | ; |
1306 | |
1307 | status = Xw_get_colormap_info(MyExtendedColorMap,&VisualInfo, |
1308 | &VisualClass,&visualid,&MaxColor,&BasePixel, |
1309 | &MaxUserColor,&MaxDefineColor,&FirstFreeColorIndex) ; |
1310 | |
1311 | return (visualid) ; |
1312 | } |
1313 | |
1314 | Xw_WindowQuality Xw_Window::Quality () const { |
1315 | |
1316 | return (MyQuality); |
1317 | |
1318 | } |
1319 | |
1320 | Standard_Boolean Xw_Window::PixelOfColor ( const Quantity_NameOfColor aColor, Standard_Integer &aPixel ) const { |
1321 | Standard_Real Red,Green,Blue ; |
1322 | unsigned long pixel ; |
1323 | Standard_Integer isapproximate; |
1324 | Quantity_Color color(aColor); |
1325 | |
1326 | color.Values(Red,Green,Blue,Quantity_TOC_RGB) ; |
1327 | |
1328 | status = Xw_get_color_pixel(MyExtendedColorMap, |
1329 | (float)Red,(float)Green,(float)Blue,&pixel,&isapproximate) ; |
1330 | if( !status ) PrintError() ; |
1331 | |
1332 | aPixel = Standard_Integer(pixel); |
1333 | |
1334 | return (isapproximate) ? Standard_True : Standard_False; |
1335 | } |
1336 | |
1337 | Standard_Boolean Xw_Window::PixelOfColor ( const Quantity_Color &aColor, Standard_Integer &aPixel ) const { |
1338 | Standard_Real Red,Green,Blue ; |
1339 | unsigned long pixel ; |
1340 | Standard_Integer isapproximate; |
1341 | |
1342 | aColor.Values(Red,Green,Blue,Quantity_TOC_RGB) ; |
1343 | |
1344 | status = Xw_get_color_pixel(MyExtendedColorMap, |
1345 | (float)Red,(float)Green,(float)Blue,&pixel,&isapproximate) ; |
1346 | if( !status ) PrintError() ; |
1347 | |
1348 | aPixel = Standard_Integer(pixel); |
1349 | |
1350 | return (isapproximate) ? Standard_True : Standard_False; |
1351 | } |
1352 | |
1353 | Standard_Boolean Xw_Window::BackgroundPixel ( Standard_Integer &aPixel ) const { |
1354 | unsigned long pixel ; |
1355 | |
1356 | status = Xw_get_background_pixel(MyExtendedWindow,&pixel) ; |
1357 | if( !status ) PrintError() ; |
1358 | |
1359 | aPixel = Standard_Integer(pixel); |
1360 | |
1361 | return status; |
1362 | } |
1363 | |
1364 | |
1365 | Standard_Address Xw_Window::ExtendedWindow () const { |
1366 | |
1367 | return (MyExtendedWindow); |
1368 | |
1369 | } |
1370 | |
1371 | Standard_Address Xw_Window::ExtendedColorMap () const { |
1372 | |
1373 | return (MyExtendedColorMap); |
1374 | |
1375 | } |
1376 | |
1377 | Standard_Address Xw_Window::ExtendedTypeMap () const { |
1378 | |
1379 | return (MyExtendedTypeMap); |
1380 | |
1381 | } |
1382 | |
1383 | Standard_Address Xw_Window::ExtendedWidthMap () const { |
1384 | |
1385 | return (MyExtendedWidthMap); |
1386 | |
1387 | } |
1388 | |
1389 | Standard_Address Xw_Window::ExtendedFontMap () const { |
1390 | |
1391 | return (MyExtendedFontMap); |
1392 | |
1393 | } |
1394 | |
1395 | Standard_Address Xw_Window::ExtendedMarkMap () const { |
1396 | |
1397 | return (MyExtendedMarkMap); |
1398 | |
1399 | } |