Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGX11.cxx
Go to the documentation of this file.
1// @(#)root/x11:$Id$
2// Author: Rene Brun, Olivier Couet, Fons Rademakers 28/11/94
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12/// \defgroup x11 X11 backend
13/// \brief Interface to X11 graphics.
14/// \ingroup GraphicsBackends
15
16/** \class TGX11
17\ingroup x11
18This class is the basic interface to the X11 (Xlib) graphics system.
19It is an implementation of the abstract TVirtualX class.
20
21This class gives access to basic X11 graphics, pixmap, text and font handling
22routines.
23
24The companion class for Win32 is TGWin32.
25
26The file G11Gui.cxx contains the implementation of the GUI methods of the
27TGX11 class. Most of the methods are used by the machine independent
28GUI classes (libGUI.so).
29
30This code was initially developed in the context of HIGZ and PAW
31by Olivier Couet (package X11INT).
32*/
33
34#include "TROOT.h"
35#include "TColor.h"
36#include "TGX11.h"
37#include "TPoint.h"
38#include "TMath.h"
39#include "TStorage.h"
40#include "TStyle.h"
41#include "TExMap.h"
42#include "TEnv.h"
43#include "TString.h"
44#include "TObjString.h"
45#include "TObjArray.h"
46#include "RStipples.h"
47#include "strlcpy.h"
48
49#include <X11/Xlib.h>
50#include <X11/Xutil.h>
51#include <X11/Xatom.h>
52#include <X11/cursorfont.h>
53#include <X11/keysym.h>
54#include <X11/xpm.h>
55
56#include <cstdio>
57#include <cstring>
58#include <cstdlib>
59#include <cctype>
60#include <unistd.h>
61#ifdef R__AIX
62# include <sys/socket.h>
63#endif
64
65extern float XRotVersion(char*, int);
66extern void XRotSetMagnification(float);
67extern void XRotSetBoundingBoxPad(int);
68extern int XRotDrawString(Display*, XFontStruct*, float,
69 Drawable, GC, int, int, char*);
70extern int XRotDrawImageString(Display*, XFontStruct*, float,
71 Drawable, GC, int, int, char*);
72extern int XRotDrawAlignedString(Display*, XFontStruct*, float,
73 Drawable, GC, int, int, char*, int);
74extern int XRotDrawAlignedImageString(Display*, XFontStruct*, float,
75 Drawable, GC, int, int, char*, int);
76extern XPoint *XRotTextExtents(Display*, XFontStruct*, float,
77 int, int, char*, int);
78
79
80
81//
82// Primitives Graphic Contexts global for all windows
83//
84const int kMAXGC = 7,
85 kGCline = 0, kGCmark = 1, kGCfill = 2,
86 kGCtext = 3, kGCinvt = 4, kGCdash = 5, kGCpxmp = 6;
87// static GC gGClist[kMAXGC];
88// static GC *gGCline = &gGClist[kGCline]; // PolyLines
89// static GC *gGCmark = &gGClist[kGCmark]; // PolyMarker
90// static GC *gGCfill = &gGClist[kGCfill]; // Fill areas
91// static GC *gGCtext = &gGClist[kGCtext]; // Text
92// static GC *gGCinvt = &gGClist[kGCinvt]; // Inverse text
93// static GC *gGCdash = &gGClist[kGCinvt]; // Dashed lines
94// static GC *gGCpxmp = &gGClist[kGCpxmp]; // Pixmap management
95
96static GC gGCecho; // Input echo
97
98
99/// Description of a X11 window.
100struct XWindow_t {
101 Int_t fOpen = 0; ///< 1 if the window is open, 0 if not
102 Int_t fDoubleBuffer = 0; ///< 1 if the double buffer is on, 0 if not
103 Int_t fIsPixmap = 0; ///< 1 if pixmap, 0 if not
104 Drawable fDrawing = 0; ///< drawing area, equal to window or buffer
105 Drawable fWindow = 0; ///< X11 window
106 Drawable fBuffer = 0; ///< pixmap used for double buffer
107 UInt_t fWidth = 0; ///< width of the window
108 UInt_t fHeight = 0; ///< height of the window
109 Int_t fClip = 0; ///< 1 if the clipping is on
110 Int_t fXclip = 0; ///< x coordinate of the clipping rectangle
111 Int_t fYclip = 0; ///< y coordinate of the clipping rectangle
112 UInt_t fWclip = 0; ///< width of the clipping rectangle
113 UInt_t fHclip = 0; ///< height of the clipping rectangle
114 ULong_t *fNewColors = 0; ///< new image colors (after processing)
115 Int_t fNcolors = 0; ///< number of different colors
116 Bool_t fShared = 0; ///< notify when window is shared
117 GC fGClist[kMAXGC]; ///< list of GC object, individual for each window
119 TAttLine fAttLine = {-1, -1, -1}; ///< current line attributes
120 Int_t lineWidth = 0; ///< X11 line width
121 Int_t lineStyle = LineSolid; ///< X11 line style
122 std::vector<char> dashList; ///< X11 array for dashes
123 Int_t dashLength = 0; ///< total length of dashes
124 Int_t dashOffset = 0; ///< current dash offset
125 TAttFill fAttFill = {-1, -1}; ///< current fill attributes
126 Int_t fillHollow = 0; ///< X11 fill method
127 Int_t fillFasi = 0; ///< selected fasi pattern
128 Pixmap fillPattern = 0; ///< current initialized fill pattern
129 TAttMarker fAttMarker = { -1, -1, -1 }; ///< current marker attribute
130 Int_t markerType = 0; ///< 4 differen kinds of marker
131 Int_t markerSize = 0; ///< size of simple markers
132 std::vector<XPoint> markerShape; ///< marker shape points
133 Int_t markerLineWidth = 0; ///< line width used for marker
134 TAttText fAttText; ///< current text attribute
135 Int_t textAlign = 0; ///< selected text align
136 XFontStruct *textFont = nullptr; ///< selected text font
137};
138
139
140//---- globals
141
142static XWindow_t *gCws; // gCws: pointer to the current window
143static XWindow_t *gTws; // gTws: temporary pointer
144
146
147
148// static Int_t gFillHollow; // Flag if fill style is hollow
149// static Pixmap gFillPattern = 0; // Fill pattern
150
151//
152// Text management
153//
154const Int_t kMAXFONT = 4;
155static struct {
157 char name[80]; // Font name
158} gFont[kMAXFONT]; // List of fonts loaded
159
160static XFontStruct *gTextFont; // Current font
161static Int_t gCurrentFontNumber = 0; // Current font number in gFont[]
162
163//
164// Markers
165//
166// const Int_t kMAXMK = 100;
167// static struct {
168// int type;
169// int n;
170// XPoint xy[kMAXMK];
171// } gMarker; // Point list to draw marker
172// static int gMarkerLineWidth = 0;
176
177//
178// Keep style values for line GC
179//
180// static int gLineWidth = 0;
181// static int gLineStyle = LineSolid;
182static int gCapStyle = CapButt;
184// static char gDashList[10];
185// static int gDashLength = 0;
186// static int gDashOffset = 0;
187// static int gDashSize = 0;
188
189//
190// Event masks
191//
198
199//
200// Data to create an invisible cursor
201//
202const char null_cursor_bits[] = {
2030x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2040x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2050x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
207
208struct RXGCValues:XGCValues{};
209struct RXColor:XColor{};
215
216////////////////////////////////////////////////////////////////////////////////
217/// Default constructor.
218
220{
221 int i;
222 fDisplay = nullptr;
223 fScreenNumber = 0;
224 fVisual = nullptr;
225 fRootWin = 0;
226 fVisRootWin = 0;
227 fColormap = 0;
228 fBlackPixel = 0;
229 fWhitePixel = 0;
230 fColors = nullptr;
231 fXEvent = new XEvent;
232 fRedDiv = -1;
233 fGreenDiv = -1;
234 fBlueDiv = -1;
235 fRedShift = -1;
236 fGreenShift = -1;
237 fBlueShift = -1;
238 fCharacterUpX = 1;
239 fCharacterUpY = 1;
240 fDepth = 0;
242 fHasXft = kFALSE;
243 fTextAlignH = 1;
244 fTextAlignV = 1;
245 fTextAlign = 7;
246 fTextMagnitude = 1;
247 for (i = 0; i < kNumCursors; i++) fCursors[i] = 0;
248}
249
250////////////////////////////////////////////////////////////////////////////////
251/// Normal Constructor.
252
253TGX11::TGX11(const char *name, const char *title) : TVirtualX(name, title)
254{
255 int i;
256 fDisplay = nullptr;
257 fScreenNumber = 0;
258 fVisual = nullptr;
259 fRootWin = 0;
260 fVisRootWin = 0;
261 fColormap = 0;
262 fBlackPixel = 0;
263 fWhitePixel = 0;
265 fXEvent = new XEvent;
266 fRedDiv = -1;
267 fGreenDiv = -1;
268 fBlueDiv = -1;
269 fRedShift = -1;
270 fGreenShift = -1;
271 fBlueShift = -1;
272 fCharacterUpX = 1;
273 fCharacterUpY = 1;
274 fDepth = 0;
276 fHasXft = kFALSE;
277 fTextAlignH = 1;
278 fTextAlignV = 1;
279 fTextAlign = 7;
280 fTextMagnitude = 1;
281 for (i = 0; i < kNumCursors; i++)
282 fCursors[i] = 0;
283
284 fColors = new TExMap;
285}
286
287////////////////////////////////////////////////////////////////////////////////
288/// Copy constructor. Currently only used by TGX11TTF.
289
291{
292 fDisplay = org.fDisplay;
293 fScreenNumber = org.fScreenNumber;
294 fVisual = org.fVisual;
295 fRootWin = org.fRootWin;
296 fVisRootWin = org.fVisRootWin;
297 fColormap = org.fColormap;
298 fBlackPixel = org.fBlackPixel;
299 fWhitePixel = org.fWhitePixel;
300 fHasTTFonts = org.fHasTTFonts;
301 fHasXft = org.fHasXft;
302 fTextAlignH = org.fTextAlignH;
303 fTextAlignV = org.fTextAlignV;
304 fTextAlign = org.fTextAlign;
305 fTextMagnitude = org.fTextMagnitude;
306 fCharacterUpX = org.fCharacterUpX;
307 fCharacterUpY = org.fCharacterUpY;
308 fDepth = org.fDepth;
309 fRedDiv = org.fRedDiv;
310 fGreenDiv = org.fGreenDiv;
311 fBlueDiv = org.fBlueDiv;
312 fRedShift = org.fRedShift;
313 fGreenShift = org.fGreenShift;
314 fBlueShift = org.fBlueShift;
315 fDrawMode = org.fDrawMode;
316 fXEvent = org.fXEvent; org.fXEvent = nullptr;
317 fColors = org.fColors; org.fColors = nullptr;
318
319 fWindows = std::move(org.fWindows);
320
321 for (int i = 0; i < kNumCursors; i++) {
322 fCursors[i] = org.fCursors[i];
323 org.fCursors[i] = 0;
324 }
325}
326
327////////////////////////////////////////////////////////////////////////////////
328/// Destructor.
329
331{
332 if (fXEvent)
333 delete (XEvent*)fXEvent;
334
335 if (fColors) {
336 Long64_t key, value;
338 while (it.Next(key, value)) {
339 XColor_t *col = (XColor_t *) (Long_t)value;
340 delete col;
341 }
342 delete fColors;
343 }
344
345 for (int i = 0; i < kNumCursors; i++)
346 if (fCursors[i])
347 XFreeCursor((Display*)fDisplay, fCursors[i]);
348}
349
350////////////////////////////////////////////////////////////////////////////////
351/// Initialize X11 system. Returns kFALSE in case of failure.
352
353Bool_t TGX11::Init(void *display)
354{
355 if (OpenDisplay(display) == -1)
356 return kFALSE;
357 return kTRUE;
358}
359
360////////////////////////////////////////////////////////////////////////////////
361/// Allocate color in colormap. If we are on an <= 8 plane machine
362/// we will use XAllocColor. If we are on a >= 15 (15, 16 or 24) plane
363/// true color machine we will calculate the pixel value using:
364/// for 15 and 16 bit true colors have 6 bits precision per color however
365/// only the 5 most significant bits are used in the color index.
366/// Except for 16 bits where green uses all 6 bits. I.e.:
367/// ~~~ {.cpp}
368/// 15 bits = rrrrrgggggbbbbb
369/// 16 bits = rrrrrggggggbbbbb
370/// ~~~
371/// for 24 bits each r, g and b are represented by 8 bits.
372///
373/// Since all colors are set with a max of 65535 (16 bits) per r, g, b
374/// we just right shift them by 10, 11 and 10 bits for 16 planes, and
375/// (10, 10, 10 for 15 planes) and by 8 bits for 24 planes.
376/// Returns kFALSE in case color allocation failed.
377
379{
380 if (fRedDiv == -1) {
381 if (XAllocColor((Display*)fDisplay, cmap, color))
382 return kTRUE;
383 } else {
384 color->pixel = (color->red >> fRedDiv) << fRedShift |
385 (color->green >> fGreenDiv) << fGreenShift |
386 (color->blue >> fBlueDiv) << fBlueShift;
387 return kTRUE;
388 }
389 return kFALSE;
390}
391
392////////////////////////////////////////////////////////////////////////////////
393/// Returns the current RGB value for the pixel in the XColor structure.
394
396{
397 if (fRedDiv == -1) {
398 XQueryColors((Display*)fDisplay, cmap, color, ncolors);
399 } else {
400 ULong_t r, g, b;
401 for (Int_t i = 0; i < ncolors; i++) {
402 r = (color[i].pixel & fVisual->red_mask) >> fRedShift;
403 color[i].red = UShort_t(r*kBIGGEST_RGB_VALUE/(fVisual->red_mask >> fRedShift));
404
405 g = (color[i].pixel & fVisual->green_mask) >> fGreenShift;
406 color[i].green = UShort_t(g*kBIGGEST_RGB_VALUE/(fVisual->green_mask >> fGreenShift));
407
408 b = (color[i].pixel & fVisual->blue_mask) >> fBlueShift;
409 color[i].blue = UShort_t(b*kBIGGEST_RGB_VALUE/(fVisual->blue_mask >> fBlueShift));
410
411 color[i].flags = DoRed | DoGreen | DoBlue;
412 }
413 }
414}
415
416
417////////////////////////////////////////////////////////////////////////////////
418/// Clear current window.
419
424
425////////////////////////////////////////////////////////////////////////////////
426/// Clear specified window.
427
429{
430 auto ctxt = (XWindow_t *) wctxt;
431 if (!ctxt)
432 return;
433
434 if (!ctxt->fIsPixmap && !ctxt->fDoubleBuffer) {
435 XSetWindowBackground((Display*)fDisplay, ctxt->fDrawing, GetColor(0).fPixel);
436 XClearWindow((Display*)fDisplay, ctxt->fDrawing);
437 XFlush((Display*)fDisplay);
438 } else {
439 SetColor(&ctxt->fGClist[kGCpxmp], 0);
440 XFillRectangle((Display*)fDisplay, ctxt->fDrawing, ctxt->fGClist[kGCpxmp],
441 0, 0, ctxt->fWidth, ctxt->fHeight);
442 SetColor(&ctxt->fGClist[kGCpxmp], 1);
443 }
444}
445
446////////////////////////////////////////////////////////////////////////////////
447/// Delete current pixmap.
448
450{
451 CloseWindow();
452}
453
454////////////////////////////////////////////////////////////////////////////////
455/// Delete current window.
456
458{
459 if (gCws->fBuffer)
460 XFreePixmap((Display*)fDisplay, gCws->fBuffer);
461
462 if (gCws->fNewColors) {
463 if (fRedDiv == -1)
464 XFreeColors((Display*)fDisplay, fColormap, gCws->fNewColors, gCws->fNcolors, 0);
465 delete [] gCws->fNewColors;
466 gCws->fNewColors = nullptr;
467 }
468
469 if (!gCws->fShared) { // if not QT window
470 if (gCws->fIsPixmap)
471 XFreePixmap((Display*)fDisplay, gCws->fWindow);
472 else
473 XDestroyWindow((Display*)fDisplay, gCws->fWindow);
474
475 XFlush((Display*)fDisplay);
476 }
477
478 for (int i = 0; i < kMAXGC; ++i)
479 XFreeGC((Display*)fDisplay, gCws->fGClist[i]);
480
481 if (gCws->fillPattern != 0) {
482 XFreePixmap((Display*)fDisplay, gCws->fillPattern);
483 gCws->fillPattern = 0;
484 }
485
486 gCws->fOpen = 0;
487
488 for (auto iter = fWindows.begin(); iter != fWindows.end(); ++iter)
489 if (iter->second.get() == gCws) {
490 fWindows.erase(iter);
491 gCws = nullptr;
492 break;
493 }
494
495 if (gCws)
496 Fatal("CloseWindow", "Not found gCws in list of windows");
497
498 // select first from active windows
499 for (auto iter = fWindows.begin(); iter != fWindows.end(); ++iter)
500 if (iter->second && iter->second->fOpen) {
501 gCws = iter->second.get();
502 return;
503 }
504}
505
506////////////////////////////////////////////////////////////////////////////////
507/// Copy the pixmap wid at the position xpos, ypos in the current window.
508
509void TGX11::CopyPixmap(int wid, int xpos, int ypos)
510{
511 gTws = fWindows[wid].get();
512
513 XCopyArea((Display*)fDisplay, gTws->fDrawing, gCws->fDrawing, gTws->fGClist[kGCpxmp], 0, 0, gTws->fWidth,
514 gTws->fHeight, xpos, ypos);
515 XFlush((Display*)fDisplay);
516}
517
518////////////////////////////////////////////////////////////////////////////////
519/// Draw a box.
520///
521/// - mode=0 hollow (kHollow)
522/// - mode=1 solid (kSolid)
523
524void TGX11::DrawBox(int x1, int y1, int x2, int y2, EBoxMode mode)
525{
527}
528
529////////////////////////////////////////////////////////////////////////////////
530/// Draw a box on specified window
531///
532/// - mode=0 hollow (kHollow)
533/// - mode=1 solid (kSolid)
534
536{
537 auto ctxt = (XWindow_t *) wctxt;
538
539 Int_t x = TMath::Min(x1, x2);
540 Int_t y = TMath::Min(y1, y2);
541 Int_t w = TMath::Abs(x2 - x1);
542 Int_t h = TMath::Abs(y2 - y1);
543
544 switch (mode) {
545
546 case kHollow:
547 XDrawRectangle((Display*)fDisplay, ctxt->fDrawing, ctxt->fGClist[kGCline], x, y, w, h);
548 break;
549
550 case kFilled:
551 XFillRectangle((Display*)fDisplay, ctxt->fDrawing, ctxt->fGClist[kGCfill], x, y, w, h);
552 break;
553
554 default:
555 break;
556 }
557}
558
559////////////////////////////////////////////////////////////////////////////////
560/// Draw a cell array.
561//
562/// \param [in] x1,y1 : left down corner
563/// \param [in] x2,y2 : right up corner
564/// \param [in] nx,ny : array size
565/// \param [in] ic : array
566///
567/// Draw a cell array. The drawing is done with the pixel precision
568/// if (X2-X1)/NX (or Y) is not a exact pixel number the position of
569/// the top right corner may be wrong.
570
571void TGX11::DrawCellArray(int x1, int y1, int x2, int y2, int nx, int ny, int *ic)
572{
573 int i, j, icol, ix, iy, w, h, current_icol;
574
575 current_icol = -1;
576 w = TMath::Max((x2-x1)/(nx),1);
577 h = TMath::Max((y1-y2)/(ny),1);
578 ix = x1;
579
580 for (i = 0; i < nx; i++) {
581 iy = y1-h;
582 for (j = 0; j < ny; j++) {
583 icol = ic[i+(nx*j)];
584 if (icol != current_icol) {
585 XSetForeground((Display*)fDisplay, gCws->fGClist[kGCfill], GetColor(icol).fPixel);
587 }
588 XFillRectangle((Display*)fDisplay, gCws->fDrawing, gCws->fGClist[kGCfill], ix, iy, w, h);
589 iy = iy-h;
590 }
591 ix = ix+w;
592 }
593}
594
595////////////////////////////////////////////////////////////////////////////////
596/// Fill area described by polygon.
597///
598/// \param [in] n number of points
599/// \param [in] xy list of points
600
605
606////////////////////////////////////////////////////////////////////////////////
607/// Fill area described by polygon on specified window
608///
609/// \param [in] n number of points
610/// \param [in] xy list of points
611
613{
614 auto ctxt = (XWindow_t *) wctxt;
615 XPoint *xyp = (XPoint *)xy;
616
617 if (ctxt->fillHollow)
618 XDrawLines((Display*)fDisplay, ctxt->fDrawing, ctxt->fGClist[kGCfill], xyp, n, CoordModeOrigin);
619
620 else {
621 XFillPolygon((Display*)fDisplay, ctxt->fDrawing, ctxt->fGClist[kGCfill],
623 }
624}
625
626////////////////////////////////////////////////////////////////////////////////
627/// Draw a line.
628///
629/// \param [in] x1,y1 : begin of line
630/// \param [in] x2,y2 : end of line
631
636
637////////////////////////////////////////////////////////////////////////////////
638/// Draw a line on specified window.
639///
640/// \param [in] x1,y1 : begin of line
641/// \param [in] x2,y2 : end of line
642
644{
645 auto ctxt = (XWindow_t *) wctxt;
646
647 if (ctxt->lineStyle == LineSolid)
648 XDrawLine((Display*)fDisplay, ctxt->fDrawing, ctxt->fGClist[kGCline], x1, y1, x2, y2);
649 else {
650 XSetDashes((Display*)fDisplay, ctxt->fGClist[kGCdash], ctxt->dashOffset, ctxt->dashList.data(), ctxt->dashList.size());
651 XDrawLine((Display*)fDisplay, ctxt->fDrawing, ctxt->fGClist[kGCdash], x1, y1, x2, y2);
652 }
653}
654
655////////////////////////////////////////////////////////////////////////////////
656/// Draw a line through all points.
657///
658/// \param [in] n number of points
659/// \param [in] xy list of points
660
665
666////////////////////////////////////////////////////////////////////////////////
667/// Draw a line through all points on specified window.
668///
669/// \param [in] n number of points
670/// \param [in] xy list of points
671
673{
674 auto ctxt = (XWindow_t *) wctxt;
675 XPoint *xyp = (XPoint*)xy;
676
677 const Int_t kMaxPoints = 1000001;
678
679 if (n > kMaxPoints) {
680 int ibeg = 0;
681 int iend = kMaxPoints - 1;
682 while (iend < n) {
684 ibeg = iend;
685 iend += kMaxPoints - 1;
686 }
687 if (ibeg < n) {
688 int npt = n - ibeg;
690 }
691 } else if (n > 1) {
692 if (ctxt->lineStyle == LineSolid)
693 XDrawLines((Display*)fDisplay, ctxt->fDrawing, ctxt->fGClist[kGCline], xyp, n, CoordModeOrigin);
694 else {
695 XSetDashes((Display*)fDisplay, ctxt->fGClist[kGCdash], ctxt->dashOffset, ctxt->dashList.data(), ctxt->dashList.size());
696 XDrawLines((Display*)fDisplay, ctxt->fDrawing, ctxt->fGClist[kGCdash], xyp, n, CoordModeOrigin);
697
698 // calculate length of line to update dash offset
699 for (int i = 1; i < n; i++) {
700 int dx = xyp[i].x - xyp[i-1].x;
701 int dy = xyp[i].y - xyp[i-1].y;
702 if (dx < 0) dx = - dx;
703 if (dy < 0) dy = - dy;
704 ctxt->dashOffset += dx > dy ? dx : dy;
705 }
706 ctxt->dashOffset %= ctxt->dashLength;
707 }
708 } else {
709 int px = xyp[0].x;
710 int py = xyp[0].y;
711 XDrawPoint((Display*)fDisplay, ctxt->fDrawing,
712 ctxt->lineStyle == LineSolid ? ctxt->fGClist[kGCline] : ctxt->fGClist[kGCdash], px, py);
713 }
714}
715
716////////////////////////////////////////////////////////////////////////////////
717/// Draws N segments between provided points
718///
719/// \param [in] n number of segements
720/// \param [in] xy list of points, size 2*n
721
726
727////////////////////////////////////////////////////////////////////////////////
728/// Draws N segments between provided points on specified windows
729///
730/// \param [in] n number of segements
731/// \param [in] xy list of points, size 2*n
732
734{
735 auto ctxt = (XWindow_t *) wctxt;
736
737 const Int_t kMaxSegments = 500000;
738 if (n > kMaxSegments) {
739 Int_t ibeg = 0;
741 while (ibeg < n) {
743 ibeg = iend;
745 }
746 } else if (n > 0) {
747 if (ctxt->lineStyle == LineSolid)
748 XDrawSegments((Display*)fDisplay, ctxt->fDrawing, ctxt->fGClist[kGCline], (XSegment *) xy, n);
749 else {
750 XSetDashes((Display*)fDisplay, ctxt->fGClist[kGCdash], ctxt->dashOffset, ctxt->dashList.data(), ctxt->dashList.size());
751 XDrawSegments((Display*)fDisplay, ctxt->fDrawing, ctxt->fGClist[kGCdash], (XSegment *) xy, n);
752 }
753 }
754}
755
756
757////////////////////////////////////////////////////////////////////////////////
758/// Draw n markers with the current attributes at position x, y.
759///
760/// \param [in] n number of markers to draw
761/// \param [in] xy x,y coordinates of markers
762
767
768////////////////////////////////////////////////////////////////////////////////
769/// Draw n markers with the current attributes at position x, y on specified window.
770///
771/// \param [in] n number of markers to draw
772/// \param [in] xy x,y coordinates of markers
773
775{
776 auto ctxt = (XWindow_t *) wctxt;
777 XPoint *xyp = (XPoint *) xy;
778
779 if ((ctxt->markerShape.size() == 0) && (ctxt->markerSize <= 0)) {
780 const int kNMAX = 1000000;
781 int nt = n/kNMAX;
782 for (int it=0;it<=nt;it++) {
783 if (it < nt) {
784 XDrawPoints((Display*)fDisplay, ctxt->fDrawing, ctxt->fGClist[kGCmark], &xyp[it*kNMAX], kNMAX, CoordModeOrigin);
785 } else {
786 XDrawPoints((Display*)fDisplay, ctxt->fDrawing, ctxt->fGClist[kGCmark], &xyp[it*kNMAX], n-it*kNMAX, CoordModeOrigin);
787 }
788 }
789 } else {
790 int r = ctxt->markerSize / 2;
791 auto &shape = ctxt->markerShape;
792
793 for (int m = 0; m < n; m++) {
794 if (ctxt->markerType == 0) {
795 // hollow circle
796 XDrawArc((Display*)fDisplay, ctxt->fDrawing, ctxt->fGClist[kGCmark],
797 xyp[m].x - r, xyp[m].y - r, ctxt->markerSize, ctxt->markerSize, 0, 360*64);
798 } else if (ctxt->markerType == 1) {
799 // filled circle
800 XFillArc((Display*)fDisplay, ctxt->fDrawing, ctxt->fGClist[kGCmark],
801 xyp[m].x - r, xyp[m].y - r, ctxt->markerSize, ctxt->markerSize, 0, 360*64);
802 } else {
803 for (size_t i = 0; i < shape.size(); i++) {
804 shape[i].x += xyp[m].x;
805 shape[i].y += xyp[m].y;
806 }
807 switch(ctxt->markerType) {
808 case 2:
809 // hollow polygon
810 XDrawLines((Display*)fDisplay, ctxt->fDrawing, ctxt->fGClist[kGCmark],
811 shape.data(), shape.size(), CoordModeOrigin);
812 break;
813 case 3:
814 // filled polygon
815 XFillPolygon((Display*)fDisplay, ctxt->fDrawing, ctxt->fGClist[kGCmark],
816 shape.data(), shape.size(), Nonconvex, CoordModeOrigin);
817 break;
818 case 4:
819 // segmented line
820 XDrawSegments((Display*)fDisplay, ctxt->fDrawing, ctxt->fGClist[kGCmark],
821 (XSegment *) shape.data(), shape.size()/2);
822 break;
823 }
824 for (size_t i = 0; i < shape.size(); i++) {
825 shape[i].x -= xyp[m].x;
826 shape[i].y -= xyp[m].y;
827 }
828 }
829 }
830 }
831}
832
833////////////////////////////////////////////////////////////////////////////////
834/// Draw a text string using current font.
835///
836/// \param [in] mode : drawing mode
837/// - mode=0 : the background is not drawn (kClear)
838/// - mode=1 : the background is drawn (kOpaque)
839/// \param [in] x,y : text position
840/// \param [in] angle : text angle
841/// \param [in] mgn : magnification factor
842/// \param [in] text : text string
843
849
850////////////////////////////////////////////////////////////////////////////////
851/// Draw a text string using current font.
852///
853/// \param [in] mode : drawing mode
854/// - mode=0 : the background is not drawn (kClear)
855/// - mode=1 : the background is drawn (kOpaque)
856/// \param [in] x,y : text position
857/// \param [in] angle : text angle
858/// \param [in] mgn : magnification factor
859/// \param [in] text : text string
860
866
867////////////////////////////////////////////////////////////////////////////////
868/// Draw a text string using current font on specified window.
869///
870/// \param [in] mode : drawing mode
871/// - mode=0 : the background is not drawn (kClear)
872/// - mode=1 : the background is drawn (kOpaque)
873/// \param [in] x,y : text position
874/// \param [in] angle : text angle
875/// \param [in] mgn : magnification factor
876/// \param [in] text : text string
877
879 const char *text, ETextMode mode)
880{
881 auto ctxt = (XWindow_t *) wctxt;
882
883 if (!text || !ctxt->textFont || ctxt->fAttText.GetTextSize() < 0)
884 return;
885
887
888 switch (mode) {
889
890 case kClear:
891 XRotDrawAlignedString((Display*)fDisplay, ctxt->textFont, angle,
892 ctxt->fDrawing, ctxt->fGClist[kGCtext], x, y, (char*)text, ctxt->textAlign);
893 break;
894
895 case kOpaque:
896 XRotDrawAlignedImageString((Display*)fDisplay, ctxt->textFont, angle,
897 ctxt->fDrawing, ctxt->fGClist[kGCtext], x, y, (char*)text, ctxt->textAlign);
898 break;
899
900 default:
901 break;
902 }
903}
904
905////////////////////////////////////////////////////////////////////////////////
906/// Find best visual, i.e. the one with the most planes and TrueColor or
907/// DirectColor. Sets fVisual, fDepth, fRootWin, fColormap, fBlackPixel
908/// and fWhitePixel.
909
911{
912 Int_t findvis = gEnv->GetValue("X11.FindBestVisual", 1);
913
914 Visual *vis = DefaultVisual((Display*)fDisplay, fScreenNumber);
915 if (((vis->c_class != TrueColor && vis->c_class != DirectColor) ||
916 DefaultDepth((Display*)fDisplay, fScreenNumber) < 15) && findvis) {
917
918 // try to find better visual
919 static XVisualInfo templates[] = {
920 // Visual, visualid, screen, depth, class , red_mask, green_mask, blue_mask, colormap_size, bits_per_rgb
921 { nullptr, 0 , 0 , 24 , TrueColor , 0 , 0 , 0 , 0 , 0 },
922 { nullptr, 0 , 0 , 32 , TrueColor , 0 , 0 , 0 , 0 , 0 },
923 { nullptr, 0 , 0 , 16 , TrueColor , 0 , 0 , 0 , 0 , 0 },
924 { nullptr, 0 , 0 , 15 , TrueColor , 0 , 0 , 0 , 0 , 0 },
925 // no suitable TrueColorMode found - now do the same thing to DirectColor
926 { nullptr, 0 , 0 , 24 , DirectColor, 0 , 0 , 0 , 0 , 0 },
927 { nullptr, 0 , 0 , 32 , DirectColor, 0 , 0 , 0 , 0 , 0 },
928 { nullptr, 0 , 0 , 16 , DirectColor, 0 , 0 , 0 , 0 , 0 },
929 { nullptr, 0 , 0 , 15 , DirectColor, 0 , 0 , 0 , 0 , 0 },
930 { nullptr, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 },
931 };
932
933 Int_t nitems = 0;
934 XVisualInfo *vlist = nullptr;
935 for (Int_t i = 0; templates[i].depth != 0; i++) {
937 templates[i].screen = fScreenNumber;
938 if ((vlist = XGetVisualInfo((Display*)fDisplay, mask, &(templates[i]), &nitems))) {
940 XFree(vlist);
941 vlist = nullptr;
942 if (fVisual)
943 break;
944 }
945 }
946 }
947
949
950 if (!fVisual) {
954 if (fDepth > 1)
958 }
959 if (gDebug > 1)
960 Printf("Selected visual 0x%lx: depth %d, class %d, colormap: %s",
961 fVisual->visualid, fDepth, fVisual->c_class,
962 fColormap == DefaultColormap((Display*)fDisplay, fScreenNumber) ? "default" :
963 "custom");
964}
965
966////////////////////////////////////////////////////////////////////////////////
967/// Dummy error handler for X11. Used by FindUsableVisual().
968
970{
971 return 0;
972}
973
974////////////////////////////////////////////////////////////////////////////////
975/// Check if visual is usable, if so set fVisual, fDepth, fColormap,
976/// fBlackPixel and fWhitePixel.
977
979{
980 Int_t (*oldErrorHandler)(Display *, XErrorEvent *) =
982
984 memset(&attr, 0, sizeof(attr));
985
986 Window root = RootWindow((Display*)fDisplay, fScreenNumber);
987
988 for (Int_t i = 0; i < nitems; i++) {
989 Window w = None, wjunk;
991 Int_t junk;
992
993 // try and use default colormap when possible
994 if (vlist[i].visual == DefaultVisual((Display*)fDisplay, fScreenNumber)) {
995 attr.colormap = DefaultColormap((Display*)fDisplay, fScreenNumber);
996 } else {
997 attr.colormap = XCreateColormap((Display*)fDisplay, root, vlist[i].visual, AllocNone);
998 }
999
1000 static XColor black_xcol = { 0, 0x0000, 0x0000, 0x0000, DoRed|DoGreen|DoBlue, 0 };
1001 static XColor white_xcol = { 0, 0xFFFF, 0xFFFF, 0xFFFF, DoRed|DoGreen|DoBlue, 0 };
1002 XAllocColor((Display*)fDisplay, attr.colormap, &black_xcol);
1003 XAllocColor((Display*)fDisplay, attr.colormap, &white_xcol);
1004 attr.border_pixel = black_xcol.pixel;
1005 attr.override_redirect = True;
1006
1007 w = XCreateWindow((Display*)fDisplay, root, -20, -20, 10, 10, 0, vlist[i].depth,
1010 if (w != None && XGetGeometry((Display*)fDisplay, w, &wjunk, &junk, &junk,
1011 &width, &height, &ujunk, &ujunk)) {
1012 fVisual = (RVisual*)vlist[i].visual;
1013 fDepth = vlist[i].depth;
1014 fColormap = attr.colormap;
1015 fBlackPixel = black_xcol.pixel;
1016 fWhitePixel = white_xcol.pixel;
1017 fVisRootWin = w;
1018 break;
1019 }
1020 if (attr.colormap != DefaultColormap((Display*)fDisplay, fScreenNumber))
1021 XFreeColormap((Display*)fDisplay, attr.colormap);
1022 }
1024}
1025
1026////////////////////////////////////////////////////////////////////////////////
1027/// Return character up vector.
1028
1034
1035////////////////////////////////////////////////////////////////////////////////
1036/// Return reference to internal color structure associated
1037/// to color index cid.
1038
1040{
1042 if (!col) {
1043 col = new XColor_t;
1044 fColors->Add(cid, (Long_t) col);
1045 }
1046 return *col;
1047}
1048
1049////////////////////////////////////////////////////////////////////////////////
1050/// Return current window pointer.
1051
1053{
1054 return (Window_t)(gCws ? gCws->fDrawing : 0);
1055}
1056
1057////////////////////////////////////////////////////////////////////////////////
1058/// Return desired Graphics Context ("which" maps directly on gGCList[]).
1059/// Protected method used by TGX11TTF.
1060
1062{
1063 if (which >= kMAXGC || which < 0) {
1064 Error("GetGC", "trying to get illegal GC (which = %d)", which);
1065 return nullptr;
1066 }
1067 if (!gCws) {
1068 Error("GetGC", "No current window selected");
1069 return nullptr;
1070 }
1071 return &gCws->fGClist[which];
1072}
1073
1074////////////////////////////////////////////////////////////////////////////////
1075/// Return X11 window for specified window context.
1076/// Protected method used by TGX11TTF.
1077
1079{
1080 auto ctxt = (XWindow_t *) wctxt;
1081 return (Window_t) (ctxt ? ctxt->fDrawing : 0);
1082}
1083
1084////////////////////////////////////////////////////////////////////////////////
1085/// Return X11 Graphics Context for specified window context.
1086/// Protected method used by TGX11TTF.
1087
1089{
1090 auto ctxt = (XWindow_t *) wctxt;
1091 if (!ctxt) {
1092 Error("GetGC", "No window context specified");
1093 return nullptr;
1094 }
1095
1096 if (which >= kMAXGC || which < 0) {
1097 Error("GetGC", "trying to get illegal GC (which = %d)", which);
1098 return nullptr;
1099 }
1100 return &ctxt->fGClist[which];
1101}
1102
1103////////////////////////////////////////////////////////////////////////////////
1104/// Return text align value for specified window context.
1105/// Protected method used by TGX11TTF.
1106
1108{
1109 auto ctxt = (XWindow_t *) wctxt;
1110 return ctxt ? ctxt->textAlign : 0;
1111}
1112
1113////////////////////////////////////////////////////////////////////////////////
1114/// Query the double buffer value for the window wid.
1115
1117{
1118 gTws = fWindows[wid].get();
1119 if (!gTws->fOpen)
1120 return -1;
1121 else
1122 return gTws->fDoubleBuffer;
1123}
1124
1125////////////////////////////////////////////////////////////////////////////////
1126/// Return position and size of window wid.
1127///
1128/// \param [in] wid : window identifier
1129/// \param [in] x,y : window position (output)
1130/// \param [in] w,h : window size (output)
1131///
1132/// if wid < 0 the size of the display is returned
1133
1134void TGX11::GetGeometry(int wid, int &x, int &y, unsigned int &w, unsigned int &h)
1135{
1136 Window junkwin=0;
1137
1138 if (wid < 0) {
1139 x = 0;
1140 y = 0;
1141 w = DisplayWidth((Display*)fDisplay,fScreenNumber);
1143 } else {
1144 Window root;
1145 unsigned int border, depth;
1146 unsigned int width, height;
1147
1148 gTws = fWindows[wid].get();
1149 XGetGeometry((Display*)fDisplay, gTws->fWindow, &root, &x, &y,
1150 &width, &height, &border, &depth);
1151 XTranslateCoordinates((Display*)fDisplay, gTws->fWindow, fRootWin,
1152 0, 0, &x, &y, &junkwin);
1153 if (width >= 65535)
1154 width = 1;
1155 if (height >= 65535)
1156 height = 1;
1157 if (width > 0 && height > 0) {
1158 gTws->fWidth = width;
1159 gTws->fHeight = height;
1160 }
1161 w = gTws->fWidth;
1162 h = gTws->fHeight;
1163 }
1164}
1165
1166////////////////////////////////////////////////////////////////////////////////
1167/// Return hostname on which the display is opened.
1168
1169const char *TGX11::DisplayName(const char *dpyName)
1170{
1171 return XDisplayName(dpyName);
1172}
1173
1174////////////////////////////////////////////////////////////////////////////////
1175/// Return pixel value associated to specified ROOT color number.
1176
1178{
1179 TColor *color = gROOT->GetColor(ci);
1180 if (color)
1181 SetRGB(ci, color->GetRed(), color->GetGreen(), color->GetBlue());
1182// else
1183// Warning("GetPixel", "color with index %d not defined", ci);
1184
1185 XColor_t &col = GetColor(ci);
1186 return col.fPixel;
1187}
1188
1189////////////////////////////////////////////////////////////////////////////////
1190/// Get maximum number of planes.
1191
1193{
1194 nplanes = fDepth;
1195}
1196
1197////////////////////////////////////////////////////////////////////////////////
1198/// Get rgb values for color "index".
1199
1200void TGX11::GetRGB(int index, float &r, float &g, float &b)
1201{
1202 if (index == 0) {
1203 r = g = b = 1.0;
1204 } else if (index == 1) {
1205 r = g = b = 0.0;
1206 } else {
1207 XColor_t &col = GetColor(index);
1208 r = ((float) col.fRed) / ((float) kBIGGEST_RGB_VALUE);
1209 g = ((float) col.fGreen) / ((float) kBIGGEST_RGB_VALUE);
1210 b = ((float) col.fBlue) / ((float) kBIGGEST_RGB_VALUE);
1211 }
1212}
1213
1214////////////////////////////////////////////////////////////////////////////////
1215/// Return the size of a character string.
1216///
1217/// \param [in] w : text width
1218/// \param [in] h : text height
1219/// \param [in] mess : message
1220
1222{
1223 w=0; h=0;
1224 if (strlen(mess)==0) return;
1225
1226 XPoint *cBox;
1228 cBox = XRotTextExtents((Display*)fDisplay, gTextFont, 0., 0, 0, mess, 0);
1229 if (cBox) {
1230 w = cBox[2].x;
1231 h = -cBox[2].y;
1232 free((char *)cBox);
1233 }
1234}
1235
1236////////////////////////////////////////////////////////////////////////////////
1237/// Return the X11 window identifier.
1238///
1239/// \param [in] wid : Workstation identifier (input)
1240
1242{
1243 return (Window_t) fWindows[wid]->fWindow;
1244}
1245
1246////////////////////////////////////////////////////////////////////////////////
1247/// Move the window wid.
1248///
1249/// \param [in] wid : Window identifier.
1250/// \param [in] x : x new window position
1251/// \param [in] y : y new window position
1252
1254{
1255 gTws = fWindows[wid].get();
1256 if (!gTws->fOpen) return;
1257
1258 XMoveWindow((Display*)fDisplay, gTws->fWindow, x, y);
1259}
1260
1261////////////////////////////////////////////////////////////////////////////////
1262/// Open the display. Return -1 if the opening fails, 0 when ok.
1263
1265{
1266 Pixmap pixmp1, pixmp2;
1267 XColor fore, back;
1268 char **fontlist;
1269 int fontcount = 0;
1270 int i;
1271
1272 if (fDisplay) return 0;
1273
1274 fDisplay = (void *) disp;
1276
1278
1279 GetColor(1).fDefined = kTRUE; // default foreground
1281 GetColor(0).fDefined = kTRUE; // default background
1283
1284 // Inquire the XServer Vendor
1285 char vendor[132];
1286 strlcpy(vendor, XServerVendor((Display*)fDisplay),132);
1287
1288 // Create primitives graphic contexts
1289 // for (i = 0; i < kMAXGC; i++)
1290 // gGClist[i] = XCreateGC((Display*)fDisplay, fVisRootWin, 0, nullptr);
1291
1292/*
1293 XGCValues values;
1294 if (XGetGCValues((Display*)fDisplay, *gGCtext, GCForeground|GCBackground, &values)) {
1295 XSetForeground((Display*)fDisplay, *gGCinvt, values.background);
1296 XSetBackground((Display*)fDisplay, *gGCinvt, values.foreground);
1297 } else {
1298 Error("OpenDisplay", "cannot get GC values");
1299 }
1300*/
1301
1302 // Create input echo graphic context
1304 echov.foreground = fBlackPixel;
1305 echov.background = fWhitePixel;
1306 if (strstr(vendor,"Hewlett"))
1307 echov.function = GXxor;
1308 else
1309 echov.function = GXinvert;
1310
1313 &echov);
1314
1315 // Load a default Font
1316 static int isdisp = 0;
1317 if (!isdisp) {
1318 for (i = 0; i < kMAXFONT; i++) {
1319 gFont[i].id = nullptr;
1320 strcpy(gFont[i].name, " ");
1321 }
1322 fontlist = XListFonts((Display*)fDisplay, "*courier*", 1, &fontcount);
1323 if (fontlist && fontcount != 0) {
1326 strcpy(gFont[gCurrentFontNumber].name, "*courier*");
1329 } else {
1330 // emergency: try fixed font
1331 fontlist = XListFonts((Display*)fDisplay, "fixed", 1, &fontcount);
1332 if (fontlist && fontcount != 0) {
1338 } else {
1339 Warning("OpenDisplay", "no default font loaded");
1340 }
1341 }
1342 isdisp = 1;
1343 }
1344
1345 // Create a null cursor
1347 null_cursor_bits, 16, 16);
1349 null_cursor_bits, 16, 16);
1350 gNullCursor = XCreatePixmapCursor((Display*)fDisplay,pixmp1,pixmp2,&fore,&back,0,0);
1351
1352 // Create cursors
1372
1373 // Setup color information
1375
1376 if (fVisual->c_class == TrueColor) {
1377 for (i = 0; i < int(sizeof(fVisual->blue_mask)*kBitsPerByte); i++) {
1378 if (fBlueShift == -1 && ((fVisual->blue_mask >> i) & 1))
1379 fBlueShift = i;
1380 if ((fVisual->blue_mask >> i) == 1) {
1381 fBlueDiv = sizeof(UShort_t)*kBitsPerByte - i - 1 + fBlueShift;
1382 break;
1383 }
1384 }
1385 for (i = 0; i < int(sizeof(fVisual->green_mask)*kBitsPerByte); i++) {
1386 if (fGreenShift == -1 && ((fVisual->green_mask >> i) & 1))
1387 fGreenShift = i;
1388 if ((fVisual->green_mask >> i) == 1) {
1389 fGreenDiv = sizeof(UShort_t)*kBitsPerByte - i - 1 + fGreenShift;
1390 break;
1391 }
1392 }
1393 for (i = 0; i < int(sizeof(fVisual->red_mask)*kBitsPerByte); i++) {
1394 if (fRedShift == -1 && ((fVisual->red_mask >> i) & 1))
1395 fRedShift = i;
1396 if ((fVisual->red_mask >> i) == 1) {
1397 fRedDiv = sizeof(UShort_t)*kBitsPerByte - i - 1 + fRedShift;
1398 break;
1399 }
1400 }
1401 //printf("fRedDiv = %d, fGreenDiv = %d, fBlueDiv = %d, fRedShift = %d, fGreenShift = %d, fBlueShift = %d\n",
1402 // fRedDiv, fGreenDiv, fBlueDiv, fRedShift, fGreenShift, fBlueShift);
1403 }
1404
1405 return 0;
1406}
1407
1408
1409////////////////////////////////////////////////////////////////////////////////
1410/// Add new window handle
1411/// Only for private usage
1412
1414{
1415 Int_t maxid = 0;
1416 for (auto & pair : fWindows) {
1417 if (!pair.second->fOpen) {
1418 pair.second->fOpen = 1;
1419 return pair.first;
1420 }
1421 if (pair.first > maxid)
1422 maxid = pair.first;
1423 }
1424
1425 if (fWindows.size() == (size_t) maxid) {
1426 // all ids are in use - just add maximal+1
1427 maxid++;
1428 } else
1429 for (int id = 1; id < maxid; id++) {
1430 if (fWindows.count(id) == 0) {
1431 maxid = id;
1432 break;
1433 }
1434 }
1435
1436 fWindows.emplace(maxid, std::make_unique<XWindow_t>());
1437
1438 auto ctxt = fWindows[maxid].get();
1439 ctxt->fOpen = 1;
1440 ctxt->fDrawMode = TVirtualX::kCopy;
1441 for (int n = 0; n < kMAXGC; ++n)
1442 ctxt->fGClist[n] = XCreateGC((Display*)fDisplay, fVisRootWin, 0, nullptr);
1443
1444 XGCValues values;
1445 if (XGetGCValues((Display*)fDisplay, ctxt->fGClist[kGCtext], GCForeground|GCBackground, &values)) {
1446 XSetForeground((Display*)fDisplay, ctxt->fGClist[kGCinvt], values.background);
1447 XSetBackground((Display*)fDisplay, ctxt->fGClist[kGCinvt], values.foreground);
1448 } else {
1449 Error("AddWindowHandle", "cannot get GC values");
1450 }
1451
1452 // Turn-off GraphicsExpose and NoExpose event reporting for the pixmap
1453 // manipulation GC, this to prevent these events from being stacked up
1454 // without ever being processed and thereby wasting a lot of memory.
1455 XSetGraphicsExposures((Display*)fDisplay, ctxt->fGClist[kGCpxmp], False);
1456
1457 return maxid;
1458}
1459
1460
1461
1462////////////////////////////////////////////////////////////////////////////////
1463/// Open a new pixmap.
1464///
1465/// \param [in] w,h : Width and height of the pixmap.
1466
1467Int_t TGX11::OpenPixmap(unsigned int w, unsigned int h)
1468{
1469 Window root;
1470 unsigned int wval, hval;
1471 int xx, yy;
1472 unsigned int ww, hh, border, depth;
1473 wval = w;
1474 hval = h;
1475
1476 // Select next free window number
1477 int wid = AddWindowHandle();
1478 gCws = fWindows[wid].get();
1479
1480 gCws->fWindow = XCreatePixmap((Display*)fDisplay, fRootWin, wval, hval, fDepth);
1481 XGetGeometry((Display*)fDisplay, gCws->fWindow, &root, &xx, &yy, &ww, &hh, &border, &depth);
1482
1483 for (int i = 0; i < kMAXGC; i++) {
1484 // XSetClipMask((Display*)fDisplay, gGClist[i], None);
1485 XSetClipMask((Display*)fDisplay, gCws->fGClist[i], None);
1486 }
1487
1488 SetColor(&gCws->fGClist[kGCpxmp], 0);
1489 XFillRectangle((Display*)fDisplay, gCws->fWindow, gCws->fGClist[kGCpxmp], 0, 0, ww, hh);
1490 SetColor(&gCws->fGClist[kGCpxmp], 1);
1491
1492 // Initialise the window structure
1493 gCws->fDrawing = gCws->fWindow;
1494 gCws->fBuffer = 0;
1495 gCws->fDoubleBuffer = 0;
1496 gCws->fIsPixmap = 1;
1497 gCws->fClip = 0;
1498 gCws->fWidth = wval;
1499 gCws->fHeight = hval;
1500 gCws->fNewColors = nullptr;
1501 gCws->fShared = kFALSE;
1502
1503 return wid;
1504}
1505
1506////////////////////////////////////////////////////////////////////////////////
1507/// Open window and return window number.
1508///
1509/// \return -1 if window initialization fails.
1510
1512{
1513 XSetWindowAttributes attributes;
1514 ULong_t attr_mask = 0;
1515 int xval, yval;
1516 unsigned int wval, hval, border, depth;
1517 Window root;
1518
1519 Window wind = (Window) win;
1520
1521 XGetGeometry((Display*)fDisplay, wind, &root, &xval, &yval, &wval, &hval, &border, &depth);
1522
1523 // Select next free window number
1524
1525 int wid = AddWindowHandle();
1526 gCws = fWindows[wid].get();
1527 gCws->fDoubleBuffer = 0;
1528
1529 // Create window
1530
1531 attributes.background_pixel = GetColor(0).fPixel;
1533 attributes.border_pixel = GetColor(1).fPixel;
1535 attributes.event_mask = NoEventMask;
1537 attributes.backing_store = Always;
1539 attributes.bit_gravity = NorthWestGravity;
1541 if (fColormap) {
1542 attributes.colormap = fColormap;
1544 }
1545
1546 gCws->fWindow = XCreateWindow((Display*)fDisplay, wind,
1547 xval, yval, wval, hval, 0, fDepth,
1549 attr_mask, &attributes);
1550
1551 XMapWindow((Display*)fDisplay, gCws->fWindow);
1552 XFlush((Display*)fDisplay);
1553
1554 // Initialise the window structure
1555
1556 gCws->fDrawing = gCws->fWindow;
1557 gCws->fBuffer = 0;
1558 gCws->fDoubleBuffer = 0;
1559 gCws->fIsPixmap = 0;
1560 gCws->fClip = 0;
1561 gCws->fWidth = wval;
1562 gCws->fHeight = hval;
1563 gCws->fNewColors = nullptr;
1564 gCws->fShared = kFALSE;
1565
1566 return wid;
1567}
1568
1569////////////////////////////////////////////////////////////////////////////////
1570/// Register a window created by Qt as a ROOT window (like InitWindow()).
1571
1573{
1574 // Select next free window number
1575 int wid = AddWindowHandle();
1576 gCws = fWindows[wid].get();
1577 gCws->fDoubleBuffer = 0;
1578
1579 gCws->fWindow = qwid;
1580
1581 //init Xwindow_t struct
1582 gCws->fDrawing = gCws->fWindow;
1583 gCws->fBuffer = 0;
1584 gCws->fDoubleBuffer = 0;
1585 gCws->fIsPixmap = 0;
1586 gCws->fClip = 0;
1587 gCws->fWidth = w;
1588 gCws->fHeight = h;
1589 gCws->fNewColors = nullptr;
1590 gCws->fShared = kTRUE;
1591
1592 return wid;
1593}
1594
1595////////////////////////////////////////////////////////////////////////////////
1596/// Remove a window created by Qt (like CloseWindow()).
1597
1599{
1600 SelectWindow((int) qwid);
1601
1602 CloseWindow();
1603}
1604
1605////////////////////////////////////////////////////////////////////////////////
1606/// Query pointer position.
1607///
1608/// \param [in] ix : X coordinate of pointer
1609/// \param [in] iy : Y coordinate of pointer
1610/// (both coordinates are relative to the origin of the root window)
1611
1613{
1617 unsigned int mask_return;
1618
1619 XQueryPointer((Display*)fDisplay,gCws->fWindow, &root_return,
1622
1623 ix = root_x_return;
1624 iy = root_y_return;
1625}
1626
1627
1628////////////////////////////////////////////////////////////////////////////////
1629/// Request Locator position.
1630///
1631/// \param [in] x,y : cursor position at moment of button press (output)
1632/// \param [in] ctyp : cursor type (input)
1633/// - ctyp=1 tracking cross
1634/// - ctyp=2 cross-hair
1635/// - ctyp=3 rubber circle
1636/// - ctyp=4 rubber band
1637/// - ctyp=5 rubber rectangle
1638///
1639/// \param [in] mode : input mode
1640/// - mode=0 request
1641/// - mode=1 sample
1642///
1643/// Request locator:
1644/// return button number:
1645/// - 1 = left is pressed
1646/// - 2 = middle is pressed
1647/// - 3 = right is pressed
1648/// in sample mode:
1649/// - 11 = left is released
1650/// - 12 = middle is released
1651/// - 13 = right is released
1652/// - -1 = nothing is pressed or released
1653/// - -2 = leave the window
1654/// - else = keycode (keyboard is pressed)
1655
1657{
1658 static int xloc = 0;
1659 static int yloc = 0;
1660 static int xlocp = 0;
1661 static int ylocp = 0;
1662 static Cursor cursor = 0;
1663
1664 XEvent event;
1665 int button_press;
1666 int radius;
1667
1668 // Change the cursor shape
1669 if (cursor == 0) {
1670 if (ctyp > 1) {
1671 XDefineCursor((Display*)fDisplay, gCws->fWindow, gNullCursor);
1672 XSetForeground((Display*)fDisplay, gGCecho, GetColor(0).fPixel);
1673 } else {
1675 XDefineCursor((Display*)fDisplay, gCws->fWindow, cursor);
1676 }
1677 }
1678
1679 // Event loop
1680
1681 button_press = 0;
1682
1683 while (button_press == 0) {
1684
1685 switch (ctyp) {
1686
1687 case 1 :
1688 break;
1689
1690 case 2 :
1691 XDrawLine((Display*)fDisplay, gCws->fWindow, gGCecho,
1692 xloc, 0, xloc, gCws->fHeight);
1693 XDrawLine((Display*)fDisplay, gCws->fWindow, gGCecho,
1694 0, yloc, gCws->fWidth, yloc);
1695 break;
1696
1697 case 3 :
1698 radius = (int) TMath::Sqrt((double)((xloc-xlocp)*(xloc-xlocp) +
1699 (yloc-ylocp)*(yloc-ylocp)));
1700 XDrawArc((Display*)fDisplay, gCws->fWindow, gGCecho,
1702 2*radius, 2*radius, 0, 23040);
1703 break;
1704
1705 case 4 :
1706 XDrawLine((Display*)fDisplay, gCws->fWindow, gGCecho,
1707 xlocp, ylocp, xloc, yloc);
1708 break;
1709
1710 case 5 :
1711 XDrawRectangle((Display*)fDisplay, gCws->fWindow, gGCecho,
1714 break;
1715
1716 default:
1717 break;
1718 }
1719
1720 while (XEventsQueued( (Display*)fDisplay, QueuedAlready) > 1) {
1721 XNextEvent((Display*)fDisplay, &event);
1722 }
1723 XWindowEvent((Display*)fDisplay, gCws->fWindow, gMouseMask, &event);
1724
1725 switch (ctyp) {
1726
1727 case 1 :
1728 break;
1729
1730 case 2 :
1731 XDrawLine((Display*)fDisplay, gCws->fWindow, gGCecho,
1732 xloc, 0, xloc, gCws->fHeight);
1733 XDrawLine((Display*)fDisplay, gCws->fWindow, gGCecho,
1734 0, yloc, gCws->fWidth, yloc);
1735 break;
1736
1737 case 3 :
1738 radius = (int) TMath::Sqrt((double)((xloc-xlocp)*(xloc-xlocp) +
1739 (yloc-ylocp)*(yloc-ylocp)));
1740 XDrawArc((Display*)fDisplay, gCws->fWindow, gGCecho,
1742 2*radius, 2*radius, 0, 23040);
1743 break;
1744
1745 case 4 :
1746 XDrawLine((Display*)fDisplay, gCws->fWindow, gGCecho,
1747 xlocp, ylocp, xloc, yloc);
1748 break;
1749
1750 case 5 :
1751 XDrawRectangle((Display*)fDisplay, gCws->fWindow, gGCecho,
1754 break;
1755
1756 default:
1757 break;
1758 }
1759
1760 xloc = event.xbutton.x;
1761 yloc = event.xbutton.y;
1762
1763 switch (event.type) {
1764
1765 case LeaveNotify :
1766 if (mode == 0) {
1767 while (true) {
1768 XNextEvent((Display*)fDisplay, &event);
1769 if (event.type == EnterNotify) break;
1770 }
1771 } else {
1772 button_press = -2;
1773 }
1774 break;
1775
1776 case ButtonPress :
1777 button_press = event.xbutton.button ;
1778 xlocp = event.xbutton.x;
1779 ylocp = event.xbutton.y;
1780 XUndefineCursor( (Display*)fDisplay, gCws->fWindow );
1781 cursor = 0;
1782 break;
1783
1784 case ButtonRelease :
1785 if (mode == 1) {
1786 button_press = 10+event.xbutton.button ;
1787 xlocp = event.xbutton.x;
1788 ylocp = event.xbutton.y;
1789 }
1790 break;
1791
1792 case KeyPress :
1793 if (mode == 1) {
1794 button_press = event.xkey.keycode;
1795 xlocp = event.xbutton.x;
1796 ylocp = event.xbutton.y;
1797 }
1798 break;
1799
1800 case KeyRelease :
1801 if (mode == 1) {
1802 button_press = -event.xkey.keycode;
1803 xlocp = event.xbutton.x;
1804 ylocp = event.xbutton.y;
1805 }
1806 break;
1807
1808 default :
1809 break;
1810 }
1811
1812 if (mode == 1) {
1813 if (button_press == 0)
1814 button_press = -1;
1815 break;
1816 }
1817 }
1818 x = event.xbutton.x;
1819 y = event.xbutton.y;
1820
1821 return button_press;
1822}
1823
1824////////////////////////////////////////////////////////////////////////////////
1825/// Request a string.
1826///
1827/// \param [in] x,y : position where text is displayed
1828/// \param [in] text : text displayed (input), edited text (output)
1829///
1830/// Request string:
1831/// text is displayed and can be edited with Emacs-like keybinding
1832/// return termination code (0 for ESC, 1 for RETURN)
1833
1835{
1836 static Cursor cursor = 0;
1837 static int percent = 0; // bell volume
1839 int focusrevert;
1840 XEvent event;
1841 KeySym keysym;
1842 int key = -1;
1843 int len_text = strlen(text);
1844 int nt; // defined length of text
1845 int pt; // cursor position in text
1846
1847 // change the cursor shape
1848 if (cursor == 0) {
1852 percent = kbstate.bell_percent;
1853 }
1854 if (cursor != 0)
1855 XDefineCursor((Display*)fDisplay, gCws->fWindow, cursor);
1856 for (nt = len_text; nt > 0 && text[nt-1] == ' '; nt--) { }
1857 pt = nt;
1859 XSetInputFocus((Display*)fDisplay, gCws->fWindow, focusrevert, CurrentTime);
1860 while (key < 0) {
1861 char keybuf[8];
1862 char nbytes;
1863 int dx;
1864 int i;
1865 XDrawImageString((Display*)fDisplay, gCws->fWindow, gCws->fGClist[kGCtext], x, y, text, nt);
1866 dx = XTextWidth(gCws->textFont, text, nt);
1867 XDrawImageString((Display*)fDisplay, gCws->fWindow, gCws->fGClist[kGCtext], x + dx, y, " ", 1);
1868 dx = pt == 0 ? 0 : XTextWidth(gCws->textFont, text, pt);
1869 XDrawImageString((Display*)fDisplay, gCws->fWindow, gCws->fGClist[kGCinvt],
1870 x + dx, y, pt < len_text ? &text[pt] : " ", 1);
1871 XWindowEvent((Display*)fDisplay, gCws->fWindow, gKeybdMask, &event);
1872 switch (event.type) {
1873 case ButtonPress:
1874 case EnterNotify:
1875 XSetInputFocus((Display*)fDisplay, gCws->fWindow, focusrevert, CurrentTime);
1876 break;
1877 case LeaveNotify:
1879 break;
1880 case KeyPress:
1881 nbytes = XLookupString(&event.xkey, keybuf, sizeof(keybuf),
1882 &keysym, nullptr);
1883 switch (keysym) { // map cursor keys
1884 case XK_Left:
1885 keybuf[0] = '\002'; // Control-B
1886 nbytes = 1;
1887 break;
1888 case XK_Right:
1889 keybuf[0] = '\006'; // Control-F
1890 nbytes = 1;
1891 break;
1892 }
1893 if (nbytes == 1) {
1894 if (isascii(keybuf[0]) && isprint(keybuf[0])) {
1895 // insert character
1896 if (nt < len_text)
1897 nt++;
1898 for (i = nt - 1; i > pt; i--)
1899 text[i] = text[i-1];
1900 if (pt < len_text) {
1901 text[pt] = keybuf[0];
1902 pt++;
1903 }
1904 } else
1905 switch (keybuf[0]) {
1906 // Emacs-like editing keys
1907
1908 case '\010': // backspace
1909 case '\177': // delete
1910 // delete backward
1911 if (pt > 0) {
1912 for (i = pt; i < nt; i++)
1913 text[i-1] = text[i];
1914 text[nt-1] = ' ';
1915 nt--;
1916 pt--;
1917 }
1918 break;
1919 case '\001': // ^A
1920 // beginning of line
1921 pt = 0;
1922 break;
1923 case '\002': // ^B
1924 // move backward
1925 if (pt > 0)
1926 pt--;
1927 break;
1928 case '\004': // ^D
1929 // delete forward
1930 if (pt > 0) {
1931 for (i = pt; i < nt; i++)
1932 text[i-1] = text[i];
1933 text[nt-1] = ' ';
1934 pt--;
1935 }
1936 break;
1937 case '\005': // ^E
1938 // end of line
1939 pt = nt;
1940 break;
1941
1942 case '\006': // ^F
1943 // move forward
1944 if (pt < nt)
1945 pt++;
1946 break;
1947 case '\013': // ^K
1948 // delete to end of line
1949 for (i = pt; i < nt; i++)
1950 text[i] = ' ';
1951 nt = pt;
1952 break;
1953 case '\024': // ^T
1954 // transpose
1955 if (pt > 0) {
1956 char c = text[pt];
1957 text[pt] = text[pt-1];
1958 text[pt-1] = c;
1959 }
1960 break;
1961 case '\012': // newline
1962 case '\015': // return
1963 key = 1;
1964 break;
1965 case '\033': // escape
1966 key = 0;
1967 break;
1968
1969 default:
1970 XBell((Display*)fDisplay, percent);
1971 }
1972 }
1973 }
1974 }
1976
1977 if (cursor != 0) {
1978 XUndefineCursor((Display*)fDisplay, gCws->fWindow);
1979 cursor = 0;
1980 }
1981
1982 return key;
1983}
1984
1985////////////////////////////////////////////////////////////////////////////////
1986/// Rescale the window wid.
1987///
1988/// \param [in] wid : Window identifier
1989/// \param [in] w : Width
1990/// \param [in] h : Height
1991
1992void TGX11::RescaleWindow(int wid, unsigned int w, unsigned int h)
1993{
1994 gTws = fWindows[wid].get();
1995 if (!gTws->fOpen) return;
1996
1997 // don't do anything when size did not change
1998 if (gTws->fWidth == w && gTws->fHeight == h) return;
1999
2000 XResizeWindow((Display*)fDisplay, gTws->fWindow, w, h);
2001
2002 if (gTws->fBuffer) {
2003 // don't free and recreate pixmap when new pixmap is smaller
2004 if (gTws->fWidth < w || gTws->fHeight < h) {
2005 XFreePixmap((Display*)fDisplay,gTws->fBuffer);
2006 gTws->fBuffer = XCreatePixmap((Display*)fDisplay, fRootWin, w, h, fDepth);
2007 }
2008 for (int i = 0; i < kMAXGC; i++) {
2009 // XSetClipMask((Display*)fDisplay, gGClist[i], None);
2010 XSetClipMask((Display*)fDisplay, gTws->fGClist[i], None);
2011 }
2012 SetColor(&gTws->fGClist[kGCpxmp], 0);
2013 XFillRectangle((Display*)fDisplay, gTws->fBuffer, gTws->fGClist[kGCpxmp], 0, 0, w, h);
2014 SetColor(&gTws->fGClist[kGCpxmp], 1);
2015 if (gTws->fDoubleBuffer)
2016 gTws->fDrawing = gTws->fBuffer;
2017 }
2018 gTws->fWidth = w;
2019 gTws->fHeight = h;
2020}
2021
2022////////////////////////////////////////////////////////////////////////////////
2023/// Resize a pixmap.
2024///
2025/// \param [in] wid : pixmap to be resized
2026/// \param [in] w,h : Width and height of the pixmap
2027
2028int TGX11::ResizePixmap(int wid, unsigned int w, unsigned int h)
2029{
2030 Window root;
2031 unsigned int wval, hval;
2032 int xx, yy, i;
2033 unsigned int ww, hh, border, depth;
2034 wval = w;
2035 hval = h;
2036
2037 gTws = fWindows[wid].get();
2038
2039 // don't do anything when size did not change
2040 // if (gTws->fWidth == wval && gTws->fHeight == hval) return 0;
2041
2042 // due to round-off errors in TPad::Resize() we might get +/- 1 pixel
2043 // change, in those cases don't resize pixmap
2044 if (gTws->fWidth >= wval-1 && gTws->fWidth <= wval+1 &&
2045 gTws->fHeight >= hval-1 && gTws->fHeight <= hval+1) return 0;
2046
2047 // don't free and recreate pixmap when new pixmap is smaller
2048 if (gTws->fWidth < wval || gTws->fHeight < hval) {
2049 XFreePixmap((Display*)fDisplay, gTws->fWindow);
2050 gTws->fWindow = XCreatePixmap((Display*)fDisplay, fRootWin, wval, hval, fDepth);
2051 }
2052 XGetGeometry((Display*)fDisplay, gTws->fWindow, &root, &xx, &yy, &ww, &hh, &border, &depth);
2053
2054 for (i = 0; i < kMAXGC; i++) {
2055 // XSetClipMask((Display*)fDisplay, gGClist[i], None);
2056 XSetClipMask((Display*)fDisplay, gTws->fGClist[i], None);
2057 }
2058
2059 SetColor(&gTws->fGClist[kGCpxmp], 0);
2060 XFillRectangle((Display*)fDisplay, gTws->fWindow, gTws->fGClist[kGCpxmp], 0, 0, ww, hh);
2061 SetColor(&gTws->fGClist[kGCpxmp], 1);
2062
2063 // Initialise the window structure
2064 gTws->fDrawing = gTws->fWindow;
2065 gTws->fWidth = wval;
2066 gTws->fHeight = hval;
2067
2068 return 1;
2069}
2070
2071////////////////////////////////////////////////////////////////////////////////
2072/// Resize the current window if necessary.
2073
2075{
2076 int xval=0, yval=0;
2077 Window win, root=0;
2078 unsigned int wval=0, hval=0, border=0, depth=0;
2079
2080 gTws = fWindows[wid].get();
2081
2082 win = gTws->fWindow;
2083
2084 XGetGeometry((Display*)fDisplay, win, &root,
2085 &xval, &yval, &wval, &hval, &border, &depth);
2086 if (wval >= 65500) wval = 1;
2087 if (hval >= 65500) hval = 1;
2088
2089 // don't do anything when size did not change
2090 if (gTws->fWidth == wval && gTws->fHeight == hval) return;
2091
2092 XResizeWindow((Display*)fDisplay, gTws->fWindow, wval, hval);
2093
2094 if (gTws->fBuffer) {
2095 if (gTws->fWidth < wval || gTws->fHeight < hval) {
2096 XFreePixmap((Display*)fDisplay,gTws->fBuffer);
2097 gTws->fBuffer = XCreatePixmap((Display*)fDisplay, fRootWin, wval, hval, fDepth);
2098 }
2099 for (int i = 0; i < kMAXGC; i++) {
2100 // XSetClipMask((Display*)fDisplay, gGClist[i], None);
2101 XSetClipMask((Display*)fDisplay, gTws->fGClist[i], None);
2102 }
2103 SetColor(&gTws->fGClist[kGCpxmp], 0);
2104 XFillRectangle((Display*)fDisplay, gTws->fBuffer, gTws->fGClist[kGCpxmp], 0, 0, wval, hval);
2105 SetColor(&gTws->fGClist[kGCpxmp], 1);
2106 if (gTws->fDoubleBuffer)
2107 gTws->fDrawing = gTws->fBuffer;
2108 }
2109 gTws->fWidth = wval;
2110 gTws->fHeight = hval;
2111}
2112
2113////////////////////////////////////////////////////////////////////////////////
2114/// Select window to which subsequent output is directed.
2115
2117{
2118 if ((wid == 0) || (fWindows.count(wid) == 0))
2119 return;
2120
2121 if (!fWindows[wid]->fOpen)
2122 return;
2123
2124 gCws = fWindows[wid].get();
2125
2126 if (gCws->fClip && !gCws->fIsPixmap && !gCws->fDoubleBuffer) {
2128 region.x = gCws->fXclip;
2129 region.y = gCws->fYclip;
2130 region.width = gCws->fWclip;
2131 region.height = gCws->fHclip;
2132 for (int i = 0; i < kMAXGC; i++) {
2133 // XSetClipRectangles((Display*)fDisplay, gGClist[i], 0, 0, &region, 1, YXBanded);
2134 XSetClipRectangles((Display*)fDisplay, gCws->fGClist[i], 0, 0, &region, 1, YXBanded);
2135 }
2136 } else {
2137 for (int i = 0; i < kMAXGC; i++) {
2138 // XSetClipMask((Display*)fDisplay, gGClist[i], None);
2139 XSetClipMask((Display*)fDisplay, gCws->fGClist[i], None);
2140 }
2141 }
2142}
2143
2144////////////////////////////////////////////////////////////////////////////////
2145/// Set character up vector.
2146
2148{
2149 if (chupx == fCharacterUpX && chupy == fCharacterUpY) return;
2150
2151 if (chupx == 0 && chupy == 0) fTextAngle = 0;
2152 else if (chupx == 0 && chupy == 1) fTextAngle = 0;
2153 else if (chupx == -1 && chupy == 0) fTextAngle = 90;
2154 else if (chupx == 0 && chupy == -1) fTextAngle = 180;
2155 else if (chupx == 1 && chupy == 0) fTextAngle = 270;
2156 else {
2158 if (chupy < 0) fTextAngle = 180 - fTextAngle;
2159 if (TMath::Abs(fTextAngle) <= 0.01) fTextAngle = 0;
2160 }
2163}
2164
2165////////////////////////////////////////////////////////////////////////////////
2166/// Turn off the clipping for the window wid.
2167
2169{
2170 gTws = fWindows[wid].get();
2171 gTws->fClip = 0;
2172
2173 for (int i = 0; i < kMAXGC; i++) {
2174 // XSetClipMask( (Display*)fDisplay, gGClist[i], None );
2175 XSetClipMask( (Display*)fDisplay, gTws->fGClist[i], None );
2176 }
2177}
2178
2179////////////////////////////////////////////////////////////////////////////////
2180/// Set clipping region for the window wid.
2181///
2182/// \param [in] wid : Window identifier
2183/// \param [in] x,y : origin of clipping rectangle
2184/// \param [in] w,h : size of clipping rectangle;
2185
2186void TGX11::SetClipRegion(int wid, int x, int y, unsigned int w, unsigned int h)
2187{
2188 gTws = fWindows[wid].get();
2189 gTws->fXclip = x;
2190 gTws->fYclip = y;
2191 gTws->fWclip = w;
2192 gTws->fHclip = h;
2193 gTws->fClip = 1;
2194 if (gTws->fClip && !gTws->fIsPixmap && !gTws->fDoubleBuffer) {
2196 region.x = gTws->fXclip;
2197 region.y = gTws->fYclip;
2198 region.width = gTws->fWclip;
2199 region.height = gTws->fHclip;
2200 for (int i = 0; i < kMAXGC; i++) {
2201 // XSetClipRectangles((Display*)fDisplay, gGClist[i], 0, 0, &region, 1, YXBanded);
2202 XSetClipRectangles((Display*)fDisplay, gTws->fGClist[i], 0, 0, &region, 1, YXBanded);
2203 }
2204 }
2205}
2206
2207////////////////////////////////////////////////////////////////////////////////
2208/// Set the foreground color in GC.
2209
2210void TGX11::SetColor(void *gci, int ci)
2211{
2212 GC gc = *(GC *)gci;
2213
2214 TColor *color = gROOT->GetColor(ci);
2215 if (color)
2216 SetRGB(ci, color->GetRed(), color->GetGreen(), color->GetBlue());
2217
2218 XColor_t &col = GetColor(ci);
2219 if (fColormap && !col.fDefined) {
2220 col = GetColor(0);
2221 } else if (!fColormap && (ci < 0 || ci > 1)) {
2222 col = GetColor(0);
2223 }
2224
2225 if (fDrawMode == kXor) {
2226 XGCValues values;
2227 XGetGCValues((Display*)fDisplay, gc, GCBackground, &values);
2228 XSetForeground((Display*)fDisplay, gc, col.fPixel ^ values.background);
2229 } else {
2230 XSetForeground((Display*)fDisplay, gc, col.fPixel);
2231
2232 // make sure that foreground and background are different
2233 XGCValues values;
2234 XGetGCValues((Display*)fDisplay, gc, GCForeground | GCBackground, &values);
2235 if (values.foreground == values.background)
2236 XSetBackground((Display*)fDisplay, gc, GetColor(!ci).fPixel);
2237 }
2238}
2239
2240////////////////////////////////////////////////////////////////////////////////
2241/// Set the cursor.
2242
2244{
2245 gTws = fWindows[wid].get();
2246 XDefineCursor((Display*)fDisplay, gTws->fWindow, fCursors[cursor]);
2247}
2248
2249////////////////////////////////////////////////////////////////////////////////
2250/// Set the double buffer on/off on window wid.
2251///
2252/// \param [in] wid : Window identifier.
2253/// - 999 means all the opened windows.
2254/// \param [in] mode :
2255/// - 1 double buffer is on
2256/// - 0 double buffer is off
2257
2259{
2260 if (wid == 999) {
2261 for (auto & pair : fWindows) {
2262 gTws = pair.second.get();
2263 if (gTws->fOpen) {
2264 switch (mode) {
2265 case 1 :
2267 break;
2268 default:
2270 break;
2271 }
2272 }
2273 }
2274 } else {
2275 gTws = fWindows[wid].get();
2276 if (!gTws->fOpen)
2277 return;
2278 switch (mode) {
2279 case 1 :
2281 return;
2282 default:
2284 return;
2285 }
2286 }
2287}
2288
2289////////////////////////////////////////////////////////////////////////////////
2290/// Turn double buffer mode off.
2291
2293{
2294 if (!gTws->fDoubleBuffer) return;
2295 gTws->fDoubleBuffer = 0;
2296 gTws->fDrawing = gTws->fWindow;
2297}
2298
2299////////////////////////////////////////////////////////////////////////////////
2300/// Turn double buffer mode on.
2301
2303{
2304 if (gTws->fDoubleBuffer || gTws->fIsPixmap)
2305 return;
2306 if (!gTws->fBuffer) {
2307 gTws->fBuffer = XCreatePixmap((Display*)fDisplay, fRootWin,
2308 gTws->fWidth, gTws->fHeight, fDepth);
2309 SetColor(&gTws->fGClist[kGCpxmp], 0);
2310 XFillRectangle((Display*)fDisplay, gTws->fBuffer, gTws->fGClist[kGCpxmp], 0, 0, gTws->fWidth, gTws->fHeight);
2311 SetColor(&gTws->fGClist[kGCpxmp], 1);
2312 }
2313 for (int i = 0; i < kMAXGC; i++) {
2314 // XSetClipMask((Display*)fDisplay, gGClist[i], None);
2315 XSetClipMask((Display*)fDisplay, gTws->fGClist[i], None);
2316 }
2317 gTws->fDoubleBuffer = 1;
2318 gTws->fDrawing = gTws->fBuffer;
2319}
2320
2321////////////////////////////////////////////////////////////////////////////////
2322/// Set the drawing mode.
2323///
2324/// \param [in] mode : drawing mode
2325/// - mode=1 copy
2326/// - mode=2 xor
2327/// - mode=3 invert
2328/// - mode=4 set the suitable mode for cursor echo according to
2329/// the vendor
2330
2332{
2333 if (fDisplay && gCws) {
2334
2335 switch (mode) {
2336 case kCopy:
2337 for (int i = 0; i < kMAXGC; i++) {
2338 // XSetFunction((Display*)fDisplay, gGClist[i], GXcopy);
2339 XSetFunction((Display*)fDisplay, gCws->fGClist[i], GXcopy);
2340 }
2341 break;
2342
2343 case kXor:
2344 for (int i = 0; i < kMAXGC; i++) {
2345 // XSetFunction((Display*)fDisplay, gGClist[i], GXxor);
2346 XSetFunction((Display*)fDisplay, gCws->fGClist[i], GXxor);
2347 }
2348 break;
2349
2350 case kInvert:
2351 for (int i = 0; i < kMAXGC; i++) {
2352 // XSetFunction((Display*)fDisplay, gGClist[i], GXinvert);
2353 XSetFunction((Display*)fDisplay, gCws->fGClist[i], GXinvert);
2354 }
2355 break;
2356 }
2357 }
2358 fDrawMode = mode;
2359}
2360
2361////////////////////////////////////////////////////////////////////////////////
2362/// Set color index for fill areas.
2363
2365{
2367
2368 TAttFill arg(gCws->fAttFill);
2369 arg.SetFillColor(cindex);
2370
2372
2373/*
2374 if (!gStyle->GetFillColor() && cindex > 1) cindex = 0;
2375 if (cindex >= 0) SetColor(gGCfill, Int_t(cindex));
2376 fFillColor = cindex;
2377
2378 // invalidate fill pattern
2379 if (gFillPattern != 0) {
2380 XFreePixmap((Display*)fDisplay, gFillPattern);
2381 gFillPattern = 0;
2382 }
2383 */
2384}
2385
2386////////////////////////////////////////////////////////////////////////////////
2387/// Set fill area style.
2388///
2389/// \param [in] fstyle : compound fill area interior style
2390/// - fstyle = 1000*interiorstyle + styleindex
2391
2393{
2395
2396 TAttFill arg(gCws->fAttFill);
2397 arg.SetFillStyle(fstyle);
2398
2400
2401/* if (fFillStyle == fstyle) return;
2402 fFillStyle = fstyle;
2403 Int_t style = fstyle/1000;
2404 Int_t fasi = fstyle%1000;
2405 SetFillStyleIndex(style,fasi);
2406 */
2407}
2408
2409////////////////////////////////////////////////////////////////////////////////
2410/// Return current fill style
2411/// FIXME: Only as temporary solution while some code analyze current fill style
2412
2414{
2415 return gCws ? gCws->fAttFill.GetFillStyle() : TAttFill::GetFillStyle();
2416}
2417
2418////////////////////////////////////////////////////////////////////////////////
2419/// Set fill area style index.
2420
2421void TGX11::SetFillStyleIndex(Int_t /* style */, Int_t /* fasi */)
2422{
2423/*
2424 static int current_fasi = 0;
2425
2426 fFillStyle = 1000*style + fasi;
2427
2428 switch (style) {
2429
2430 case 1: // solid
2431 gFillHollow = 0;
2432 XSetFillStyle((Display*)fDisplay, *gGCfill, FillSolid);
2433 break;
2434
2435 case 2: // pattern
2436 gFillHollow = 1;
2437 break;
2438
2439 case 3: // hatch
2440 gFillHollow = 0;
2441 XSetFillStyle((Display*)fDisplay, *gGCfill, FillStippled);
2442 if (fasi != current_fasi) {
2443 if (gFillPattern != 0) {
2444 XFreePixmap((Display*)fDisplay, gFillPattern);
2445 gFillPattern = 0;
2446 }
2447 int stn = (fasi >= 1 && fasi <=25) ? fasi : 2;
2448
2449 gFillPattern = XCreateBitmapFromData((Display*)fDisplay, fRootWin,
2450 (const char*)gStipples[stn], 16, 16);
2451
2452 XSetStipple( (Display*)fDisplay, *gGCfill, gFillPattern );
2453 current_fasi = fasi;
2454 }
2455 break;
2456
2457 default:
2458 gFillHollow = 1;
2459 }
2460*/
2461}
2462
2463////////////////////////////////////////////////////////////////////////////////
2464/// Set input on or off.
2465
2467{
2468 XSetWindowAttributes attributes;
2470
2471 if (inp == 1) {
2472 attributes.event_mask = gMouseMask | gKeybdMask;
2474 XChangeWindowAttributes((Display*)fDisplay, gCws->fWindow, attr_mask, &attributes);
2475 } else {
2476 attributes.event_mask = NoEventMask;
2478 XChangeWindowAttributes((Display*)fDisplay, gCws->fWindow, attr_mask, &attributes);
2479 }
2480}
2481
2482////////////////////////////////////////////////////////////////////////////////
2483/// Set color index for lines.
2484
2486{
2487 if (cindex < 0) return;
2488
2490
2491 TAttLine arg(gCws->fAttLine);
2492 arg.SetLineColor(cindex);
2493
2495
2496 //SetColor(gGCline, Int_t(cindex));
2497 //SetColor(gGCdash, Int_t(cindex));
2498}
2499
2500////////////////////////////////////////////////////////////////////////////////
2501/// Set line type.
2502///
2503/// \param [in] n : length of dash list
2504/// \param [in] dash : dash segment lengths
2505///
2506/// - if n <= 0 use solid lines
2507/// - if n > 0 use dashed lines described by DASH(N)
2508/// e.g. N=4,DASH=(6,3,1,3) gives a dashed-dotted line with dash length 6
2509/// and a gap of 7 between dashes
2510
2511void TGX11::SetLineType(int /* n */, int * /* dash */)
2512{
2513 /*
2514 if (n <= 0) {
2515 gLineStyle = LineSolid;
2516 XSetLineAttributes((Display*)fDisplay, *gGCline, gLineWidth,
2517 gLineStyle, gCapStyle, gJoinStyle);
2518 } else {
2519 gDashSize = TMath::Min((int)sizeof(gDashList),n);
2520 gDashLength = 0;
2521 for (int i = 0; i < gDashSize; i++ ) {
2522 gDashList[i] = dash[i];
2523 gDashLength += gDashList[i];
2524 }
2525 gDashOffset = 0;
2526 gLineStyle = LineOnOffDash;
2527 if (gLineWidth == 0) gLineWidth =1;
2528 XSetLineAttributes((Display*)fDisplay, *gGCline, gLineWidth,
2529 gLineStyle, gCapStyle, gJoinStyle);
2530 XSetLineAttributes((Display*)fDisplay, *gGCdash, gLineWidth,
2531 gLineStyle, gCapStyle, gJoinStyle);
2532 }
2533 */
2534}
2535
2536////////////////////////////////////////////////////////////////////////////////
2537/// Set line style.
2538
2540{
2542
2543 TAttLine arg(gCws->fAttLine);
2544 arg.SetLineStyle(lstyle);
2545
2547/*
2548
2549 static Int_t dashed[2] = {3,3};
2550 static Int_t dotted[2] = {1,2};
2551 static Int_t dasheddotted[4] = {3,4,1,4};
2552
2553 if (fLineStyle != lstyle) { //set style index only if different
2554 fLineStyle = lstyle;
2555 if (lstyle <= 1 ) {
2556 SetLineType(0, nullptr);
2557 } else if (lstyle == 2 ) {
2558 SetLineType(2, dashed);
2559 } else if (lstyle == 3 ) {
2560 SetLineType(2, dotted);
2561 } else if (lstyle == 4 ) {
2562 SetLineType(4, dasheddotted);
2563 } else {
2564 TString st = (TString)gStyle->GetLineStyleString(lstyle);
2565 TObjArray *tokens = st.Tokenize(" ");
2566 Int_t nt;
2567 nt = tokens->GetEntries();
2568 Int_t *linestyle = new Int_t[nt];
2569 for (Int_t j = 0; j<nt; j++) {
2570 Int_t it;
2571 sscanf(((TObjString*)tokens->At(j))->GetName(), "%d", &it);
2572 linestyle[j] = (Int_t)(it/4);
2573 }
2574 SetLineType(nt, linestyle);
2575 delete [] linestyle;
2576 delete tokens;
2577 }
2578 }
2579*/
2580}
2581
2582////////////////////////////////////////////////////////////////////////////////
2583/// Return current line style
2584/// FIXME: Only as temporary solution while some code analyze current line style
2585
2587{
2588 return gCws ? gCws->fAttLine.GetLineStyle() : TAttLine::GetLineStyle();
2589}
2590
2591////////////////////////////////////////////////////////////////////////////////
2592/// Set line width.
2593///
2594/// \param [in] width : line width in pixels
2595
2597{
2599
2600 TAttLine arg(gCws->fAttLine);
2601 arg.SetLineWidth(width);
2602
2604
2605/*
2606
2607 if (fLineWidth == width) return;
2608 fLineWidth = width;
2609
2610 if (width == 1 && gLineStyle == LineSolid) gLineWidth = 0;
2611 else gLineWidth = width;
2612
2613 if (gLineWidth < 0) return;
2614
2615 XSetLineAttributes((Display*)fDisplay, *gGCline, gLineWidth,
2616 gLineStyle, gCapStyle, gJoinStyle);
2617 XSetLineAttributes((Display*)fDisplay, *gGCdash, gLineWidth,
2618 gLineStyle, gCapStyle, gJoinStyle);
2619*/
2620}
2621
2622////////////////////////////////////////////////////////////////////////////////
2623/// Return current line width
2624/// FIXME: Only as temporary solution while some code analyze current line wide
2625
2627{
2628 return gCws ? gCws->fAttLine.GetLineWidth() : TAttLine::GetLineWidth();
2629}
2630
2631////////////////////////////////////////////////////////////////////////////////
2632/// Set color index for markers.
2633
2635{
2636 if (cindex < 0) return;
2637
2639
2640 TAttMarker arg(gCws->fAttMarker);
2642
2644}
2645
2646////////////////////////////////////////////////////////////////////////////////
2647/// Set marker size index.
2648///
2649/// \param [in] msize : marker scale factor
2650
2652{
2654
2655 TAttMarker arg(gCws->fAttMarker);
2656 arg.SetMarkerSize(msize);
2657
2659}
2660
2661////////////////////////////////////////////////////////////////////////////////
2662/// Set marker type.
2663///
2664/// \param [in] type : marker type
2665/// \param [in] n : length of marker description
2666/// \param [in] xy : list of points describing marker shape
2667///
2668/// - if n == 0 marker is a single point
2669/// - if TYPE == 0 marker is hollow circle of diameter N
2670/// - if TYPE == 1 marker is filled circle of diameter N
2671/// - if TYPE == 2 marker is a hollow polygon describe by line XY
2672/// - if TYPE == 3 marker is a filled polygon describe by line XY
2673/// - if TYPE == 4 marker is described by segmented line XY
2674/// e.g. TYPE=4,N=4,XY=(-3,0,3,0,0,-3,0,3) sets a plus shape of 7x7 pixels
2675
2676void TGX11::SetMarkerType(int /* type */, int /* n */, RXPoint * /* xy */)
2677{
2678 /*
2679 gMarker.type = type;
2680 gMarker.n = n < kMAXMK ? n : kMAXMK;
2681 if (gMarker.type >= 2) {
2682 for (int i = 0; i < gMarker.n; i++) {
2683 gMarker.xy[i].x = xy[i].x;
2684 gMarker.xy[i].y = xy[i].y;
2685 }
2686 }
2687 */
2688}
2689
2690////////////////////////////////////////////////////////////////////////////////
2691/// Set marker style.
2692
2694{
2696
2697 TAttMarker arg(gCws->fAttMarker);
2699
2701/*
2702
2703 if (fMarkerStyle == markerstyle) return;
2704 static RXPoint shape[30];
2705 fMarkerStyle = TMath::Abs(markerstyle);
2706 markerstyle = TAttMarker::GetMarkerStyleBase(fMarkerStyle);
2707 gMarkerLineWidth = TAttMarker::GetMarkerLineWidth(fMarkerStyle);
2708
2709 // The fast pixel markers need to be treated separately
2710 if (markerstyle == 1 || markerstyle == 6 || markerstyle == 7) {
2711 XSetLineAttributes((Display*)fDisplay, *gGCmark, 0, LineSolid, CapButt, JoinMiter);
2712 } else {
2713 XSetLineAttributes((Display*)fDisplay, *gGCmark, gMarkerLineWidth,
2714 gMarkerLineStyle, gMarkerCapStyle, gMarkerJoinStyle);
2715 }
2716
2717 Float_t MarkerSizeReduced = fMarkerSize - TMath::Floor(gMarkerLineWidth/2.)/4.;
2718 Int_t im = Int_t(4*MarkerSizeReduced + 0.5);
2719 if (markerstyle == 2) {
2720 // + shaped marker
2721 shape[0].x = -im; shape[0].y = 0;
2722 shape[1].x = im; shape[1].y = 0;
2723 shape[2].x = 0 ; shape[2].y = -im;
2724 shape[3].x = 0 ; shape[3].y = im;
2725 } else if (markerstyle == 3 || markerstyle == 31) {
2726 // * shaped marker
2727 shape[0].x = -im; shape[0].y = 0;
2728 shape[1].x = im; shape[1].y = 0;
2729 shape[2].x = 0 ; shape[2].y = -im;
2730 shape[3].x = 0 ; shape[3].y = im;
2731 im = Int_t(0.707*Float_t(im) + 0.5);
2732 shape[4].x = -im; shape[4].y = -im;
2733 shape[5].x = im; shape[5].y = im;
2734 shape[6].x = -im; shape[6].y = im;
2735 shape[7].x = im; shape[7].y = -im;
2736 } else if (markerstyle == 4 || markerstyle == 24) {
2737 // O shaped marker
2738 SetMarkerType(0,im*2,shape);
2739 } else if (markerstyle == 5) {
2740 // X shaped marker
2741 im = Int_t(0.707*Float_t(im) + 0.5);
2742 shape[0].x = -im; shape[0].y = -im;
2743 shape[1].x = im; shape[1].y = im;
2744 shape[2].x = -im; shape[2].y = im;
2745 shape[3].x = im; shape[3].y = -im;
2746 SetMarkerType(4,4,shape);
2747 } else if (markerstyle == 6) {
2748 // + shaped marker (with 1 pixel)
2749 shape[0].x = -1 ; shape[0].y = 0;
2750 shape[1].x = 1 ; shape[1].y = 0;
2751 shape[2].x = 0 ; shape[2].y = -1;
2752 shape[3].x = 0 ; shape[3].y = 1;
2753 SetMarkerType(4,4,shape);
2754 } else if (markerstyle == 7) {
2755 // . shaped marker (with 9 pixel)
2756 shape[0].x = -1 ; shape[0].y = 1;
2757 shape[1].x = 1 ; shape[1].y = 1;
2758 shape[2].x = -1 ; shape[2].y = 0;
2759 shape[3].x = 1 ; shape[3].y = 0;
2760 shape[4].x = -1 ; shape[4].y = -1;
2761 shape[5].x = 1 ; shape[5].y = -1;
2762 SetMarkerType(4,6,shape);
2763 } else if (markerstyle == 8 || markerstyle == 20) {
2764 // O shaped marker (filled)
2765 SetMarkerType(1,im*2,shape);
2766 } else if (markerstyle == 21) {
2767 // full square
2768 shape[0].x = -im; shape[0].y = -im;
2769 shape[1].x = im; shape[1].y = -im;
2770 shape[2].x = im; shape[2].y = im;
2771 shape[3].x = -im; shape[3].y = im;
2772 shape[4].x = -im; shape[4].y = -im;
2773 SetMarkerType(3,5,shape);
2774 } else if (markerstyle == 22) {
2775 // full triangle up
2776 shape[0].x = -im; shape[0].y = im;
2777 shape[1].x = im; shape[1].y = im;
2778 shape[2].x = 0; shape[2].y = -im;
2779 shape[3].x = -im; shape[3].y = im;
2780 SetMarkerType(3,4,shape);
2781 } else if (markerstyle == 23) {
2782 // full triangle down
2783 shape[0].x = 0; shape[0].y = im;
2784 shape[1].x = im; shape[1].y = -im;
2785 shape[2].x = -im; shape[2].y = -im;
2786 shape[3].x = 0; shape[3].y = im;
2787 SetMarkerType(3,4,shape);
2788 } else if (markerstyle == 25) {
2789 // open square
2790 shape[0].x = -im; shape[0].y = -im;
2791 shape[1].x = im; shape[1].y = -im;
2792 shape[2].x = im; shape[2].y = im;
2793 shape[3].x = -im; shape[3].y = im;
2794 shape[4].x = -im; shape[4].y = -im;
2795 SetMarkerType(2,5,shape);
2796 } else if (markerstyle == 26) {
2797 // open triangle up
2798 shape[0].x = -im; shape[0].y = im;
2799 shape[1].x = im; shape[1].y = im;
2800 shape[2].x = 0; shape[2].y = -im;
2801 shape[3].x = -im; shape[3].y = im;
2802 SetMarkerType(2,4,shape);
2803 } else if (markerstyle == 27) {
2804 // open losange
2805 Int_t imx = Int_t(2.66*MarkerSizeReduced + 0.5);
2806 shape[0].x =-imx; shape[0].y = 0;
2807 shape[1].x = 0; shape[1].y = -im;
2808 shape[2].x = imx; shape[2].y = 0;
2809 shape[3].x = 0; shape[3].y = im;
2810 shape[4].x =-imx; shape[4].y = 0;
2811 SetMarkerType(2,5,shape);
2812 } else if (markerstyle == 28) {
2813 // open cross
2814 Int_t imx = Int_t(1.33*MarkerSizeReduced + 0.5);
2815 shape[0].x = -im; shape[0].y =-imx;
2816 shape[1].x =-imx; shape[1].y =-imx;
2817 shape[2].x =-imx; shape[2].y = -im;
2818 shape[3].x = imx; shape[3].y = -im;
2819 shape[4].x = imx; shape[4].y =-imx;
2820 shape[5].x = im; shape[5].y =-imx;
2821 shape[6].x = im; shape[6].y = imx;
2822 shape[7].x = imx; shape[7].y = imx;
2823 shape[8].x = imx; shape[8].y = im;
2824 shape[9].x =-imx; shape[9].y = im;
2825 shape[10].x=-imx; shape[10].y= imx;
2826 shape[11].x= -im; shape[11].y= imx;
2827 shape[12].x= -im; shape[12].y=-imx;
2828 SetMarkerType(2,13,shape);
2829 } else if (markerstyle == 29) {
2830 // full star pentagone
2831 Int_t im1 = Int_t(0.66*MarkerSizeReduced + 0.5);
2832 Int_t im2 = Int_t(2.00*MarkerSizeReduced + 0.5);
2833 Int_t im3 = Int_t(2.66*MarkerSizeReduced + 0.5);
2834 Int_t im4 = Int_t(1.33*MarkerSizeReduced + 0.5);
2835 shape[0].x = -im; shape[0].y = im4;
2836 shape[1].x =-im2; shape[1].y =-im1;
2837 shape[2].x =-im3; shape[2].y = -im;
2838 shape[3].x = 0; shape[3].y =-im2;
2839 shape[4].x = im3; shape[4].y = -im;
2840 shape[5].x = im2; shape[5].y =-im1;
2841 shape[6].x = im; shape[6].y = im4;
2842 shape[7].x = im4; shape[7].y = im4;
2843 shape[8].x = 0; shape[8].y = im;
2844 shape[9].x =-im4; shape[9].y = im4;
2845 shape[10].x= -im; shape[10].y= im4;
2846 SetMarkerType(3,11,shape);
2847 } else if (markerstyle == 30) {
2848 // open star pentagone
2849 Int_t im1 = Int_t(0.66*MarkerSizeReduced + 0.5);
2850 Int_t im2 = Int_t(2.00*MarkerSizeReduced + 0.5);
2851 Int_t im3 = Int_t(2.66*MarkerSizeReduced + 0.5);
2852 Int_t im4 = Int_t(1.33*MarkerSizeReduced + 0.5);
2853 shape[0].x = -im; shape[0].y = im4;
2854 shape[1].x =-im2; shape[1].y =-im1;
2855 shape[2].x =-im3; shape[2].y = -im;
2856 shape[3].x = 0; shape[3].y =-im2;
2857 shape[4].x = im3; shape[4].y = -im;
2858 shape[5].x = im2; shape[5].y =-im1;
2859 shape[6].x = im; shape[6].y = im4;
2860 shape[7].x = im4; shape[7].y = im4;
2861 shape[8].x = 0; shape[8].y = im;
2862 shape[9].x =-im4; shape[9].y = im4;
2863 shape[10].x= -im; shape[10].y= im4;
2864 SetMarkerType(2,11,shape);
2865 } else if (markerstyle == 32) {
2866 // open triangle down
2867 shape[0].x = 0; shape[0].y = im;
2868 shape[1].x = im; shape[1].y = -im;
2869 shape[2].x = -im; shape[2].y = -im;
2870 shape[3].x = 0; shape[3].y = im;
2871 SetMarkerType(2,4,shape);
2872 } else if (markerstyle == 33) {
2873 // full losange
2874 Int_t imx = Int_t(2.66*MarkerSizeReduced + 0.5);
2875 shape[0].x =-imx; shape[0].y = 0;
2876 shape[1].x = 0; shape[1].y = -im;
2877 shape[2].x = imx; shape[2].y = 0;
2878 shape[3].x = 0; shape[3].y = im;
2879 shape[4].x =-imx; shape[4].y = 0;
2880 SetMarkerType(3,5,shape);
2881 } else if (markerstyle == 34) {
2882 // full cross
2883 Int_t imx = Int_t(1.33*MarkerSizeReduced + 0.5);
2884 shape[0].x = -im; shape[0].y =-imx;
2885 shape[1].x =-imx; shape[1].y =-imx;
2886 shape[2].x =-imx; shape[2].y = -im;
2887 shape[3].x = imx; shape[3].y = -im;
2888 shape[4].x = imx; shape[4].y =-imx;
2889 shape[5].x = im; shape[5].y =-imx;
2890 shape[6].x = im; shape[6].y = imx;
2891 shape[7].x = imx; shape[7].y = imx;
2892 shape[8].x = imx; shape[8].y = im;
2893 shape[9].x =-imx; shape[9].y = im;
2894 shape[10].x=-imx; shape[10].y= imx;
2895 shape[11].x= -im; shape[11].y= imx;
2896 shape[12].x= -im; shape[12].y=-imx;
2897 SetMarkerType(3,13,shape);
2898 } else if (markerstyle == 35) {
2899 // diamond with cross
2900 shape[0].x =-im; shape[0].y = 0;
2901 shape[1].x = 0; shape[1].y = -im;
2902 shape[2].x = im; shape[2].y = 0;
2903 shape[3].x = 0; shape[3].y = im;
2904 shape[4].x =-im; shape[4].y = 0;
2905 shape[5].x = im; shape[5].y = 0;
2906 shape[6].x = 0; shape[6].y = im;
2907 shape[7].x = 0; shape[7].y =-im;
2908 SetMarkerType(2,8,shape);
2909 } else if (markerstyle == 36) {
2910 // square with diagonal cross
2911 shape[0].x = -im; shape[0].y = -im;
2912 shape[1].x = im; shape[1].y = -im;
2913 shape[2].x = im; shape[2].y = im;
2914 shape[3].x = -im; shape[3].y = im;
2915 shape[4].x = -im; shape[4].y = -im;
2916 shape[5].x = im; shape[5].y = im;
2917 shape[6].x = -im; shape[6].y = im;
2918 shape[7].x = im; shape[7].y = -im;
2919 SetMarkerType(2,8,shape);
2920 } else if (markerstyle == 37) {
2921 // open three triangles
2922 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
2923 shape[0].x = 0; shape[0].y = 0;
2924 shape[1].x =-im2; shape[1].y = im;
2925 shape[2].x = im2; shape[2].y = im;
2926 shape[3].x = 0; shape[3].y = 0;
2927 shape[4].x =-im2; shape[4].y = -im;
2928 shape[5].x = -im; shape[5].y = 0;
2929 shape[6].x = 0; shape[6].y = 0;
2930 shape[7].x = im; shape[7].y = 0;
2931 shape[8].x = im2; shape[8].y = -im;
2932 shape[9].x = 0; shape[9].y = 0;
2933 SetMarkerType(2, 10,shape);
2934 } else if (markerstyle == 38) {
2935 // + shaped marker with octagon
2936 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
2937 shape[0].x = -im; shape[0].y = 0;
2938 shape[1].x = -im; shape[1].y =-im2;
2939 shape[2].x =-im2; shape[2].y = -im;
2940 shape[3].x = im2; shape[3].y = -im;
2941 shape[4].x = im; shape[4].y =-im2;
2942 shape[5].x = im; shape[5].y = im2;
2943 shape[6].x = im2; shape[6].y = im;
2944 shape[7].x =-im2; shape[7].y = im;
2945 shape[8].x = -im; shape[8].y = im2;
2946 shape[9].x = -im; shape[9].y = 0;
2947 shape[10].x = im; shape[10].y = 0;
2948 shape[11].x = 0; shape[11].y = 0;
2949 shape[12].x = 0; shape[12].y = -im;
2950 shape[13].x = 0; shape[13].y = im;
2951 shape[14].x = 0; shape[14].y = 0;
2952 SetMarkerType(2,15,shape);
2953 } else if (markerstyle == 39) {
2954 // filled three triangles
2955 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
2956 shape[0].x = 0; shape[0].y = 0;
2957 shape[1].x =-im2; shape[1].y = im;
2958 shape[2].x = im2; shape[2].y = im;
2959 shape[3].x = 0; shape[3].y = 0;
2960 shape[4].x =-im2; shape[4].y = -im;
2961 shape[5].x = -im; shape[5].y = 0;
2962 shape[6].x = 0; shape[6].y = 0;
2963 shape[7].x = im; shape[7].y = 0;
2964 shape[8].x = im2; shape[8].y = -im;
2965 SetMarkerType(3,9,shape);
2966 } else if (markerstyle == 40) {
2967 // four open triangles X
2968 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
2969 shape[0].x = 0; shape[0].y = 0;
2970 shape[1].x = im2; shape[1].y = im;
2971 shape[2].x = im; shape[2].y = im2;
2972 shape[3].x = 0; shape[3].y = 0;
2973 shape[4].x = im; shape[4].y = -im2;
2974 shape[5].x = im2; shape[5].y = -im;
2975 shape[6].x = 0; shape[6].y = 0;
2976 shape[7].x = -im2; shape[7].y = -im;
2977 shape[8].x = -im; shape[8].y = -im2;
2978 shape[9].x = 0; shape[9].y = 0;
2979 shape[10].x = -im; shape[10].y = im2;
2980 shape[11].x = -im2; shape[11].y = im;
2981 shape[12].x = 0; shape[12].y = 0;
2982 SetMarkerType(2,13,shape);
2983 } else if (markerstyle == 41) {
2984 // four filled triangles X
2985 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
2986 shape[0].x = 0; shape[0].y = 0;
2987 shape[1].x = im2; shape[1].y = im;
2988 shape[2].x = im; shape[2].y = im2;
2989 shape[3].x = 0; shape[3].y = 0;
2990 shape[4].x = im; shape[4].y = -im2;
2991 shape[5].x = im2; shape[5].y = -im;
2992 shape[6].x = 0; shape[6].y = 0;
2993 shape[7].x = -im2; shape[7].y = -im;
2994 shape[8].x = -im; shape[8].y = -im2;
2995 shape[9].x = 0; shape[9].y = 0;
2996 shape[10].x = -im; shape[10].y = im2;
2997 shape[11].x = -im2; shape[11].y = im;
2998 shape[12].x = 0; shape[12].y = 0;
2999 SetMarkerType(3,13,shape);
3000 } else if (markerstyle == 42) {
3001 // open double diamonds
3002 Int_t imx = Int_t(MarkerSizeReduced + 0.5);
3003 shape[0].x= 0; shape[0].y= im;
3004 shape[1].x= -imx; shape[1].y= imx;
3005 shape[2].x = -im; shape[2].y = 0;
3006 shape[3].x = -imx; shape[3].y = -imx;
3007 shape[4].x = 0; shape[4].y = -im;
3008 shape[5].x = imx; shape[5].y = -imx;
3009 shape[6].x = im; shape[6].y = 0;
3010 shape[7].x= imx; shape[7].y= imx;
3011 shape[8].x= 0; shape[8].y= im;
3012 SetMarkerType(2,9,shape);
3013 } else if (markerstyle == 43) {
3014 // filled double diamonds
3015 Int_t imx = Int_t(MarkerSizeReduced + 0.5);
3016 shape[0].x = 0; shape[0].y = im;
3017 shape[1].x = -imx; shape[1].y = imx;
3018 shape[2].x = -im; shape[2].y = 0;
3019 shape[3].x = -imx; shape[3].y = -imx;
3020 shape[4].x = 0; shape[4].y = -im;
3021 shape[5].x = imx; shape[5].y = -imx;
3022 shape[6].x = im; shape[6].y = 0;
3023 shape[7].x = imx; shape[7].y = imx;
3024 shape[8].x = 0; shape[8].y = im;
3025 SetMarkerType(3,9,shape);
3026 } else if (markerstyle == 44) {
3027 // open four triangles plus
3028 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
3029 shape[0].x = 0; shape[0].y = 0;
3030 shape[1].x = im2; shape[1].y = im;
3031 shape[2].x = -im2; shape[2].y = im;
3032 shape[3].x = im2; shape[3].y = -im;
3033 shape[4].x = -im2; shape[4].y = -im;
3034 shape[5].x = 0; shape[5].y = 0;
3035 shape[6].x = im; shape[6].y = im2;
3036 shape[7].x = im; shape[7].y = -im2;
3037 shape[8].x = -im; shape[8].y = im2;
3038 shape[9].x = -im; shape[9].y = -im2;
3039 shape[10].x = 0; shape[10].y = 0;
3040 SetMarkerType(2,11,shape);
3041 } else if (markerstyle == 45) {
3042 // filled four triangles plus
3043 Int_t im0 = Int_t(0.4*MarkerSizeReduced + 0.5);
3044 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
3045 shape[0].x = im0; shape[0].y = im0;
3046 shape[1].x = im2; shape[1].y = im;
3047 shape[2].x = -im2; shape[2].y = im;
3048 shape[3].x = -im0; shape[3].y = im0;
3049 shape[4].x = -im; shape[4].y = im2;
3050 shape[5].x = -im; shape[5].y = -im2;
3051 shape[6].x = -im0; shape[6].y = -im0;
3052 shape[7].x = -im2; shape[7].y = -im;
3053 shape[8].x = im2; shape[8].y = -im;
3054 shape[9].x = im0; shape[9].y = -im0;
3055 shape[10].x = im; shape[10].y = -im2;
3056 shape[11].x = im; shape[11].y = im2;
3057 shape[12].x = im0; shape[12].y = im0;
3058 SetMarkerType(3,13,shape);
3059 } else if (markerstyle == 46) {
3060 // open four triangles X
3061 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
3062 shape[0].x = 0; shape[0].y = im2;
3063 shape[1].x = -im2; shape[1].y = im;
3064 shape[2].x = -im; shape[2].y = im2;
3065 shape[3].x = -im2; shape[3].y = 0;
3066 shape[4].x = -im; shape[4].y = -im2;
3067 shape[5].x = -im2; shape[5].y = -im;
3068 shape[6].x = 0; shape[6].y = -im2;
3069 shape[7].x = im2; shape[7].y = -im;
3070 shape[8].x = im; shape[8].y = -im2;
3071 shape[9].x = im2; shape[9].y = 0;
3072 shape[10].x = im; shape[10].y = im2;
3073 shape[11].x = im2; shape[11].y = im;
3074 shape[12].x = 0; shape[12].y = im2;
3075 SetMarkerType(2,13,shape);
3076 } else if (markerstyle == 47) {
3077 // filled four triangles X
3078 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
3079 shape[0].x = 0; shape[0].y = im2;
3080 shape[1].x = -im2; shape[1].y = im;
3081 shape[2].x = -im; shape[2].y = im2;
3082 shape[3].x = -im2; shape[3].y = 0;
3083 shape[4].x = -im; shape[4].y = -im2;
3084 shape[5].x = -im2; shape[5].y = -im;
3085 shape[6].x = 0; shape[6].y = -im2;
3086 shape[7].x = im2; shape[7].y = -im;
3087 shape[8].x = im; shape[8].y = -im2;
3088 shape[9].x = im2; shape[9].y = 0;
3089 shape[10].x = im; shape[10].y = im2;
3090 shape[11].x = im2; shape[11].y = im;
3091 shape[12].x = 0; shape[12].y = im2;
3092 SetMarkerType(3,13,shape);
3093 } else if (markerstyle == 48) {
3094 // four filled squares X
3095 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
3096 shape[0].x = 0; shape[0].y = im2*1.005;
3097 shape[1].x = -im2; shape[1].y = im;
3098 shape[2].x = -im; shape[2].y = im2;
3099 shape[3].x = -im2; shape[3].y = 0;
3100 shape[4].x = -im; shape[4].y = -im2;
3101 shape[5].x = -im2; shape[5].y = -im;
3102 shape[6].x = 0; shape[6].y = -im2;
3103 shape[7].x = im2; shape[7].y = -im;
3104 shape[8].x = im; shape[8].y = -im2;
3105 shape[9].x = im2; shape[9].y = 0;
3106 shape[10].x = im; shape[10].y = im2;
3107 shape[11].x = im2; shape[11].y = im;
3108 shape[12].x = 0; shape[12].y = im2*0.995;
3109 shape[13].x = im2*0.995; shape[13].y = 0;
3110 shape[14].x = 0; shape[14].y = -im2*0.995;
3111 shape[15].x = -im2*0.995; shape[15].y = 0;
3112 shape[16].x = 0; shape[16].y = im2*0.995;
3113 SetMarkerType(3,16,shape);
3114 } else if (markerstyle == 49) {
3115 // four filled squares plus
3116 Int_t imx = Int_t(1.33*MarkerSizeReduced + 0.5);
3117 shape[0].x =-imx; shape[0].y =-imx*1.005;
3118 shape[1].x =-imx; shape[1].y = -im;
3119 shape[2].x = imx; shape[2].y = -im;
3120 shape[3].x = imx; shape[3].y =-imx;
3121 shape[4].x = im; shape[4].y =-imx;
3122 shape[5].x = im; shape[5].y = imx;
3123 shape[6].x = imx; shape[6].y = imx;
3124 shape[7].x = imx; shape[7].y = im;
3125 shape[8].x =-imx; shape[8].y = im;
3126 shape[9].x =-imx; shape[9].y = imx;
3127 shape[10].x = -im; shape[10].y = imx;
3128 shape[11].x = -im; shape[11].y =-imx;
3129 shape[12].x =-imx; shape[12].y =-imx*0.995;
3130 shape[13].x =-imx; shape[13].y = imx;
3131 shape[14].x = imx; shape[14].y = imx;
3132 shape[15].x = imx; shape[15].y =-imx;
3133 shape[16].x =-imx; shape[16].y =-imx*1.005;
3134 SetMarkerType(3,17,shape);
3135 } else {
3136 // single dot
3137 SetMarkerType(0,0,shape);
3138 }
3139*/
3140}
3141
3142////////////////////////////////////////////////////////////////////////////////
3143/// Set opacity of a window. This image manipulation routine works
3144/// by adding to a percent amount of neutral to each pixels RGB.
3145/// Since it requires quite some additional color map entries is it
3146/// only supported on displays with more than > 8 color planes (> 256
3147/// colors).
3148
3150{
3151 if (fDepth <= 8) return;
3152 if (percent == 0) return;
3153 // if 100 percent then just make white
3154
3155 ULong_t *orgcolors = nullptr, *tmpc = nullptr;
3156 Int_t maxcolors = 0, ncolors = 0, ntmpc = 0;
3157
3158 // save previous allocated colors, delete at end when not used anymore
3159 if (gCws->fNewColors) {
3160 tmpc = gCws->fNewColors;
3161 ntmpc = gCws->fNcolors;
3162 }
3163
3164 // get pixmap from server as image
3165 XImage *image = XGetImage((Display*)fDisplay, gCws->fDrawing, 0, 0, gCws->fWidth,
3166 gCws->fHeight, AllPlanes, ZPixmap);
3167 if (!image) return;
3168 // collect different image colors
3169 int x, y;
3170 for (y = 0; y < (int) gCws->fHeight; y++) {
3171 for (x = 0; x < (int) gCws->fWidth; x++) {
3174 }
3175 }
3176 if (ncolors == 0) {
3178 ::operator delete(orgcolors);
3179 return;
3180 }
3181
3182 // create opaque counter parts
3184
3185 if (gCws->fNewColors) {
3186 // put opaque colors in image
3187 for (y = 0; y < (int) gCws->fHeight; y++) {
3188 for (x = 0; x < (int) gCws->fWidth; x++) {
3190 Int_t idx = FindColor(pixel, orgcolors, ncolors);
3191 XPutPixel(image, x, y, gCws->fNewColors[idx]);
3192 }
3193 }
3194 }
3195
3196 // put image back in pixmap on server
3197 XPutImage((Display*)fDisplay, gCws->fDrawing, gCws->fGClist[kGCpxmp], image, 0, 0, 0, 0,
3198 gCws->fWidth, gCws->fHeight);
3199 XFlush((Display*)fDisplay);
3200
3201 // clean up
3202 if (tmpc) {
3203 if (fRedDiv == -1)
3204 XFreeColors((Display*)fDisplay, fColormap, tmpc, ntmpc, 0);
3205 delete [] tmpc;
3206 }
3208 ::operator delete(orgcolors);
3209}
3210
3211////////////////////////////////////////////////////////////////////////////////
3212/// Collect in orgcolors all different original image colors.
3213
3216{
3217 if (maxcolors == 0) {
3218 ncolors = 0;
3219 maxcolors = 100;
3220 orgcolors = (ULong_t*) ::operator new(maxcolors*sizeof(ULong_t));
3221 }
3222
3223 for (int i = 0; i < ncolors; i++)
3224 if (pixel == orgcolors[i]) return;
3225
3226 if (ncolors >= maxcolors) {
3228 maxcolors*2*sizeof(ULong_t), maxcolors*sizeof(ULong_t));
3229 maxcolors *= 2;
3230 }
3231
3232 orgcolors[ncolors++] = pixel;
3233}
3234
3235////////////////////////////////////////////////////////////////////////////////
3236/// Get RGB values for orgcolors, add percent neutral to the RGB and
3237/// allocate fNewColors.
3238
3240{
3241 if (ncolors == 0) return;
3242
3243 RXColor *xcol = new RXColor[ncolors];
3244
3245 int i;
3246 for (i = 0; i < ncolors; i++) {
3247 xcol[i].pixel = orgcolors[i];
3248 xcol[i].red = xcol[i].green = xcol[i].blue = 0;
3249 xcol[i].flags = DoRed | DoGreen | DoBlue;
3250 }
3251 QueryColors(fColormap, xcol, ncolors);
3252
3253 UShort_t add = percent * kBIGGEST_RGB_VALUE / 100;
3254
3255 Int_t val;
3256 for (i = 0; i < ncolors; i++) {
3257 val = xcol[i].red + add;
3258 if (val > kBIGGEST_RGB_VALUE) val = kBIGGEST_RGB_VALUE;
3259 xcol[i].red = (UShort_t) val;
3260 val = xcol[i].green + add;
3261 if (val > kBIGGEST_RGB_VALUE) val = kBIGGEST_RGB_VALUE;
3262 xcol[i].green = (UShort_t) val;
3263 val = xcol[i].blue + add;
3264 if (val > kBIGGEST_RGB_VALUE) val = kBIGGEST_RGB_VALUE;
3265 xcol[i].blue = (UShort_t) val;
3266 if (!AllocColor(fColormap, &xcol[i]))
3267 Warning("MakeOpaqueColors", "failed to allocate color %hd, %hd, %hd",
3268 xcol[i].red, xcol[i].green, xcol[i].blue);
3269 // assumes that in case of failure xcol[i].pixel is not changed
3270 }
3271
3272 gCws->fNewColors = new ULong_t[ncolors];
3273 gCws->fNcolors = ncolors;
3274
3275 for (i = 0; i < ncolors; i++)
3276 gCws->fNewColors[i] = xcol[i].pixel;
3277
3278 delete [] xcol;
3279}
3280
3281////////////////////////////////////////////////////////////////////////////////
3282/// Returns index in orgcolors (and fNewColors) for pixel.
3283
3285{
3286 for (int i = 0; i < ncolors; i++)
3287 if (pixel == orgcolors[i]) return i;
3288
3289 Error("FindColor", "did not find color, should never happen!");
3290
3291 return 0;
3292}
3293
3294////////////////////////////////////////////////////////////////////////////////
3295/// Set color intensities for given color index.
3296///
3297/// \param [in] cindex : color index
3298/// \param [in] r,g,b : red, green, blue intensities between 0.0 and 1.0
3299
3300void TGX11::SetRGB(int cindex, float r, float g, float b)
3301{
3302 if (fColormap) {
3303 RXColor xcol;
3304 xcol.red = (UShort_t)(r * kBIGGEST_RGB_VALUE);
3305 xcol.green = (UShort_t)(g * kBIGGEST_RGB_VALUE);
3306 xcol.blue = (UShort_t)(b * kBIGGEST_RGB_VALUE);
3307 xcol.flags = DoRed | DoGreen | DoBlue;
3308 XColor_t &col = GetColor(cindex);
3309 if (col.fDefined) {
3310 // if color is already defined with same rgb just return
3311 if (col.fRed == xcol.red && col.fGreen == xcol.green &&
3312 col.fBlue == xcol.blue)
3313 return;
3314 col.fDefined = kFALSE;
3315 if (fRedDiv == -1)
3316 XFreeColors((Display*)fDisplay, fColormap, &col.fPixel, 1, 0);
3317 }
3318 if (AllocColor(fColormap, &xcol)) {
3319 col.fDefined = kTRUE;
3320 col.fPixel = xcol.pixel;
3321 col.fRed = xcol.red;
3322 col.fGreen = xcol.green;
3323 col.fBlue = xcol.blue;
3324 }
3325 }
3326}
3327
3328////////////////////////////////////////////////////////////////////////////////
3329/// Set text alignment.
3330///
3331/// \param [in] talign text alignment
3332
3334{
3335/* Int_t txalh = talign/10;
3336 Int_t txalv = talign%10;
3337 fTextAlignH = txalh;
3338 fTextAlignV = txalv;
3339
3340 switch (txalh) {
3341
3342 case 0 :
3343 case 1 :
3344 switch (txalv) { //left
3345 case 1 :
3346 fTextAlign = 7; //bottom
3347 break;
3348 case 2 :
3349 fTextAlign = 4; //center
3350 break;
3351 case 3 :
3352 fTextAlign = 1; //top
3353 break;
3354 }
3355 break;
3356 case 2 :
3357 switch (txalv) { //center
3358 case 1 :
3359 fTextAlign = 8; //bottom
3360 break;
3361 case 2 :
3362 fTextAlign = 5; //center
3363 break;
3364 case 3 :
3365 fTextAlign = 2; //top
3366 break;
3367 }
3368 break;
3369 case 3 :
3370 switch (txalv) { //right
3371 case 1 :
3372 fTextAlign = 9; //bottom
3373 break;
3374 case 2 :
3375 fTextAlign = 6; //center
3376 break;
3377 case 3 :
3378 fTextAlign = 3; //top
3379 break;
3380 }
3381 break;
3382 }
3383 */
3384
3386
3387 TAttText arg(gCws->fAttText);
3388 arg.SetTextAlign(talign);
3389
3391
3392 // FIXME: member fTextAlign conflicts with TAttText::fTextAlign
3393 fTextAlign = gCws->textAlign;
3394}
3395
3396////////////////////////////////////////////////////////////////////////////////
3397/// Set color index for text.
3398
3400{
3401 if (cindex < 0) return;
3402
3404
3405 TAttText arg(gCws->fAttText);
3406 arg.SetTextColor(cindex);
3407
3409
3410 /*
3411 SetColor(gGCtext, Int_t(cindex));
3412
3413 XGCValues values;
3414 if (XGetGCValues((Display*)fDisplay, *gGCtext, GCForeground | GCBackground, &values)) {
3415 XSetForeground( (Display*)fDisplay, *gGCinvt, values.background );
3416 XSetBackground( (Display*)fDisplay, *gGCinvt, values.foreground );
3417 } else {
3418 Error("SetTextColor", "cannot get GC values");
3419 }
3420 XSetBackground((Display*)fDisplay, *gGCtext, GetColor(0).fPixel);
3421 */
3422}
3423
3424////////////////////////////////////////////////////////////////////////////////
3425/// Set text font to specified name.
3426///
3427/// \param [in] fontname font name
3428/// \param [in] mode loading flag
3429/// - mode=0 search if the font exist (kCheck)
3430/// - mode=1 search the font and load it if it exists (kLoad)
3431///
3432/// Set text font to specified name. This function returns 0 if
3433/// the specified font is found, 1 if not.
3434
3436{
3437 char **fontlist;
3438 int fontcount;
3439
3440 if (mode == kLoad) {
3441 for (int i = 0; i < kMAXFONT; i++) {
3442 if (strcmp(fontname, gFont[i].name) == 0) {
3443 gTextFont = gFont[i].id;
3444 if (gCws) {
3445 gCws->textFont = gTextFont;
3446 XSetFont((Display*)fDisplay, gCws->fGClist[kGCtext], gCws->textFont->fid);
3447 XSetFont((Display*)fDisplay, gCws->fGClist[kGCinvt], gCws->textFont->fid);
3448 }
3449 return 0;
3450 }
3451 }
3452 }
3453
3454 fontlist = XListFonts((Display*)fDisplay, fontname, 1, &fontcount);
3455
3456 if (fontlist && fontcount != 0) {
3457 if (mode == kLoad) {
3458 if (gFont[gCurrentFontNumber].id)
3460 gTextFont = XLoadQueryFont((Display*)fDisplay, fontlist[0]);
3465 }
3467 return 0;
3468 } else {
3469 return 1;
3470 }
3471}
3472
3473////////////////////////////////////////////////////////////////////////////////
3474/// Set current text font number.
3475
3477{
3479
3480 TAttText arg(gCws->fAttText);
3482
3484}
3485
3486////////////////////////////////////////////////////////////////////////////////
3487/// Set current text size.
3488
3490{
3492
3493 TAttText arg(gCws->fAttText);
3494 arg.SetTextSize(textsize);
3495
3497}
3498
3499////////////////////////////////////////////////////////////////////////////////
3500/// Set synchronisation on or off.
3501///
3502/// \param [in] mode : synchronisation on/off
3503/// - mode=1 on
3504/// - mode<>0 off
3505
3507{
3508 switch (mode) {
3509
3510 case 1 :
3511 XSynchronize((Display*)fDisplay,1);
3512 break;
3513
3514 default:
3515 XSynchronize((Display*)fDisplay,0);
3516 break;
3517 }
3518}
3519
3520////////////////////////////////////////////////////////////////////////////////
3521/// Update display.
3522///
3523/// \param [in] mode : (1) update (0) sync
3524///
3525/// Synchronise client and server once (not permanent).
3526/// Copy the pixmap gCws->fDrawing on the window gCws->fWindow
3527/// if the double buffer is on.
3528
3533
3534////////////////////////////////////////////////////////////////////////////////
3535/// Update display for specified window.
3536///
3537/// \param [in] mode : (1) update (0) sync
3538///
3539/// Synchronise client and server once (not permanent).
3540/// Copy the pixmap gCws->fDrawing on the window gCws->fWindow
3541/// if the double buffer is on.
3542
3544{
3545 auto ctxt = (XWindow_t *) wctxt;
3546 if (!ctxt)
3547 return;
3548
3549 if (ctxt->fDoubleBuffer) {
3550 XCopyArea((Display*)fDisplay, ctxt->fDrawing, ctxt->fWindow,
3551 ctxt->fGClist[kGCpxmp], 0, 0, ctxt->fWidth, ctxt->fHeight, 0, 0);
3552 }
3553 if (mode == 1) {
3554 XFlush((Display*)fDisplay);
3555 } else {
3556 XSync((Display*)fDisplay, False);
3557 }
3558}
3559
3560////////////////////////////////////////////////////////////////////////////////
3561/// Set pointer position.
3562///
3563/// \param [in] ix New X coordinate of pointer
3564/// \param [in] iy New Y coordinate of pointer
3565/// \param [in] id Window identifier
3566///
3567/// Coordinates are relative to the origin of the window id
3568/// or to the origin of the current window if id == 0.
3569
3571{
3572 if (!id) {
3573 // Causes problems when calling ProcessEvents()... BadWindow
3574 //XWarpPointer((Display*)fDisplay, None, gCws->fWindow, 0, 0, 0, 0, ix, iy);
3575 } else {
3576 XWarpPointer((Display*)fDisplay, None, (Window) id, 0, 0, 0, 0, ix, iy);
3577 }
3578}
3579
3580////////////////////////////////////////////////////////////////////////////////
3581/// Write the pixmap wid in the bitmap file pxname.
3582///
3583/// \param [in] wid : Pixmap address
3584/// \param [in] w,h : Width and height of the pixmap.
3585/// \param [in] pxname : pixmap name
3586
3587void TGX11::WritePixmap(int wid, unsigned int w, unsigned int h, char *pxname)
3588{
3589 unsigned int wval, hval;
3590 wval = w;
3591 hval = h;
3592
3593 gTws = fWindows[wid].get();
3594 XWriteBitmapFile((Display*)fDisplay, pxname, gTws->fDrawing, wval, hval, -1, -1);
3595}
3596
3597
3598//
3599// Functions for GIFencode()
3600//
3601
3602static FILE *gOut; // output unit used WriteGIF and PutByte
3603static XImage *gXimage = nullptr; // image used in WriteGIF and GetPixel
3604
3605extern "C" {
3608 long GIFencode(int Width, int Height, Int_t Ncol, Byte_t R[], Byte_t G[], Byte_t B[], Byte_t ScLine[],
3609 void (*get_scline) (int, int, Byte_t *), void (*pb)(Byte_t));
3610 int GIFdecode(Byte_t *gifArr, Byte_t *pixArr, int *Width, int *Height, int *Ncols, Byte_t *R, Byte_t *G, Byte_t *B);
3611 int GIFinfo(Byte_t *gifArr, int *Width, int *Height, int *Ncols);
3612}
3613
3614////////////////////////////////////////////////////////////////////////////////
3615/// Get pixels in line y and put in array scline.
3616
3617static void GetPixel(int y, int width, Byte_t *scline)
3618{
3619 for (int i = 0; i < width; i++)
3620 scline[i] = Byte_t(XGetPixel(gXimage, i, y));
3621}
3622
3623////////////////////////////////////////////////////////////////////////////////
3624/// Put byte b in output stream.
3625
3626static void PutByte(Byte_t b)
3627{
3628 if (ferror(gOut) == 0) fputc(b, gOut);
3629}
3630
3631////////////////////////////////////////////////////////////////////////////////
3632/// Returns in R G B the ncol colors of the palette used by the image.
3633/// The image pixels are changed to index values in these R G B arrays.
3634/// This produces a colormap with only the used colors (so even on displays
3635/// with more than 8 planes we will be able to create GIF's when the image
3636/// contains no more than 256 different colors). If it does contain more
3637/// colors we will have to use GIFquantize to reduce the number of colors.
3638/// The R G B arrays must be deleted by the caller.
3639
3641{
3642 ULong_t *orgcolors = nullptr;
3643 Int_t maxcolors = 0, ncolors = 0;
3644
3645 // collect different image colors
3646 int x, y;
3647 for (x = 0; x < (int) gCws->fWidth; x++) {
3648 for (y = 0; y < (int) gCws->fHeight; y++) {
3651 }
3652 }
3653
3654 // get RGB values belonging to pixels
3655 RXColor *xcol = new RXColor[ncolors];
3656
3657 int i;
3658 for (i = 0; i < ncolors; i++) {
3659 xcol[i].pixel = orgcolors[i];
3660 xcol[i].red = xcol[i].green = xcol[i].blue = 0;
3661 xcol[i].flags = DoRed | DoGreen | DoBlue;
3662 }
3663 QueryColors(fColormap, xcol, ncolors);
3664
3665 // create RGB arrays and store RGB's for each color and set number of colors
3666 // (space must be delete by caller)
3667 R = new Int_t[ncolors];
3668 G = new Int_t[ncolors];
3669 B = new Int_t[ncolors];
3670
3671 for (i = 0; i < ncolors; i++) {
3672 R[i] = xcol[i].red;
3673 G[i] = xcol[i].green;
3674 B[i] = xcol[i].blue;
3675 }
3676 ncol = ncolors;
3677
3678 // update image with indices (pixels) into the new RGB colormap
3679 for (x = 0; x < (int) gCws->fWidth; x++) {
3680 for (y = 0; y < (int) gCws->fHeight; y++) {
3682 Int_t idx = FindColor(pixel, orgcolors, ncolors);
3683 XPutPixel(image, x, y, idx);
3684 }
3685 }
3686
3687 // cleanup
3688 delete [] xcol;
3689 ::operator delete(orgcolors);
3690}
3691
3692////////////////////////////////////////////////////////////////////////////////
3693/// Writes the current window into GIF file. Returns 1 in case of success,
3694/// 0 otherwise.
3695
3697{
3698 Byte_t scline[2000], r[256], b[256], g[256];
3699 Int_t *red, *green, *blue;
3700 Int_t ncol, maxcol, i;
3701
3702 if (gXimage) {
3704 gXimage = nullptr;
3705 }
3706
3707 gXimage = XGetImage((Display*)fDisplay, gCws->fDrawing, 0, 0,
3708 gCws->fWidth, gCws->fHeight,
3710
3712
3713 if (ncol > 256) {
3714 //GIFquantize(...);
3715 Error("WriteGIF", "Cannot create GIF of image containing more than 256 colors. Try in batch mode.");
3716 delete [] red;
3717 delete [] green;
3718 delete [] blue;
3719 return 0;
3720 }
3721
3722 maxcol = 0;
3723 for (i = 0; i < ncol; i++) {
3724 if (maxcol < red[i] ) maxcol = red[i];
3725 if (maxcol < green[i] ) maxcol = green[i];
3726 if (maxcol < blue[i] ) maxcol = blue[i];
3727 r[i] = 0;
3728 g[i] = 0;
3729 b[i] = 0;
3730 }
3731 if (maxcol != 0) {
3732 for (i = 0; i < ncol; i++) {
3733 r[i] = red[i] * 255/maxcol;
3734 g[i] = green[i] * 255/maxcol;
3735 b[i] = blue[i] * 255/maxcol;
3736 }
3737 }
3738
3739 gOut = fopen(name, "w+");
3740
3741 if (gOut) {
3742 GIFencode(gCws->fWidth, gCws->fHeight,
3743 ncol, r, g, b, scline, ::GetPixel, PutByte);
3744 fclose(gOut);
3745 i = 1;
3746 } else {
3747 Error("WriteGIF","cannot write file: %s",name);
3748 i = 0;
3749 }
3750 delete [] red;
3751 delete [] green;
3752 delete [] blue;
3753 return i;
3754}
3755
3756////////////////////////////////////////////////////////////////////////////////
3757/// Draw image.
3758/// Not used, keep for backward compatibility
3759
3762{
3763 const int maxSegment = 20;
3764 int i, n, x, y, xcur, x1, x2, y1, y2;
3765 unsigned char *jimg, *jbase, icol;
3766 int nlines[256];
3768 Drawable_t id;
3769 GC lineGC;
3770
3771 if (wid) {
3772 id = wid;
3773 lineGC = XCreateGC((Display*)fDisplay, fVisRootWin, 0, nullptr);
3774 } else {
3775 id = gCws->fDrawing;
3776 lineGC = gCws->fGClist[kGCline];
3777 }
3778
3779 for (i = 0; i < 256; i++) nlines[i] = 0;
3780
3781 x1 = x0 + xmin; y1 = y0 + ny - ymax - 1;
3782 x2 = x0 + xmax; y2 = y0 + ny - ymin - 1;
3783 jbase = image + (ymin-1)*nx + xmin;
3784
3785 for (y = y2; y >= y1; y--) {
3786 xcur = x1; jbase += nx;
3787 for (jimg = jbase, icol = *jimg++, x = x1+1; x <= x2; jimg++, x++) {
3788 if (icol != *jimg) {
3789 if (icol != itran) {
3790 n = nlines[icol]++;
3791 lines[icol][n].x1 = xcur; lines[icol][n].y1 = y;
3792 lines[icol][n].x2 = x-1; lines[icol][n].y2 = y;
3793 if (nlines[icol] == maxSegment) {
3794 SetColor(&lineGC, (int)icol+offset);
3795 XDrawSegments((Display*)fDisplay,id,lineGC,&lines[icol][0],
3796 maxSegment);
3797 nlines[icol] = 0;
3798 }
3799 }
3800 icol = *jimg; xcur = x;
3801 }
3802 }
3803 if (icol != itran) {
3804 n = nlines[icol]++;
3805 lines[icol][n].x1 = xcur; lines[icol][n].y1 = y;
3806 lines[icol][n].x2 = x-1; lines[icol][n].y2 = y;
3807 if (nlines[icol] == maxSegment) {
3808 SetColor(&lineGC, (int)icol+offset);
3809 XDrawSegments((Display*)fDisplay,id,lineGC,&lines[icol][0],
3810 maxSegment);
3811 nlines[icol] = 0;
3812 }
3813 }
3814 }
3815
3816 for (i = 0; i < 256; i++) {
3817 if (nlines[i] != 0) {
3819 XDrawSegments((Display*)fDisplay,id,lineGC,&lines[i][0],nlines[i]);
3820 }
3821 }
3822
3823 if (wid)
3824 XFreeGC((Display*)fDisplay, lineGC);
3825}
3826
3827////////////////////////////////////////////////////////////////////////////////
3828/// If id is NULL - loads the specified gif file at position [x0,y0] in the
3829/// current window. Otherwise creates pixmap from gif file
3830
3831Pixmap_t TGX11::ReadGIF(int x0, int y0, const char *file, Window_t id)
3832{
3833 FILE *fd;
3834 Seek_t filesize = 0;
3835 unsigned char *gifArr, *pixArr, red[256], green[256], blue[256], *j1, *j2, icol;
3836 int i, j, k, width, height, ncolor, irep, offset;
3837 float rr, gg, bb;
3838 Pixmap_t pic = 0;
3839
3840 fd = fopen(file, "r");
3841 if (!fd) {
3842 Error("ReadGIF", "unable to open GIF file");
3843 return pic;
3844 }
3845
3846 fseek(fd, 0L, 2);
3847 long ft = ftell(fd);
3848 if (ft <=0) {
3849 Error("ReadGIF", "unable to open GIF file");
3850 fclose(fd);
3851 return pic;
3852 } else {
3853 filesize = Seek_t(ft);
3854 }
3855 fseek(fd, 0L, 0);
3856
3857 if (!(gifArr = (unsigned char *) calloc(filesize+256,1))) {
3858 Error("ReadGIF", "unable to allocate array for gif");
3859 fclose(fd);
3860 return pic;
3861 }
3862
3863 if (fread(gifArr, filesize, 1, fd) != 1) {
3864 Error("ReadGIF", "GIF file read failed");
3865 free(gifArr);
3866 fclose(fd);
3867 return pic;
3868 }
3869 fclose(fd);
3870
3872 if (irep != 0) {
3873 free(gifArr);
3874 return pic;
3875 }
3876
3877 if (!(pixArr = (unsigned char *) calloc((width*height),1))) {
3878 Error("ReadGIF", "unable to allocate array for image");
3879 free(gifArr);
3880 return pic;
3881 }
3882
3884 if (irep != 0) {
3885 free(gifArr);
3886 free(pixArr);
3887 return pic;
3888 }
3889
3890 // S E T P A L E T T E
3891
3892 offset = 8;
3893
3894 for (i = 0; i < ncolor; i++) {
3895 rr = red[i]/255.;
3896 gg = green[i]/255.;
3897 bb = blue[i]/255.;
3898 j = i+offset;
3899 SetRGB(j,rr,gg,bb);
3900 }
3901
3902 // O U T P U T I M A G E
3903
3904 for (i = 1; i <= height/2; i++) {
3905 j1 = pixArr + (i-1)*width;
3906 j2 = pixArr + (height-i)*width;
3907 for (k = 0; k < width; k++) {
3908 icol = *j1; *j1++ = *j2; *j2++ = icol;
3909 }
3910 }
3911 if (id) pic = CreatePixmap(id, width, height);
3913
3914 free(gifArr);
3915 free(pixArr);
3916
3917 if (pic)
3918 return pic;
3919 else if (gCws->fDrawing)
3920 return (Pixmap_t)gCws->fDrawing;
3921 return 0;
3922}
3923
3924////////////////////////////////////////////////////////////////////////////////
3925/// Returns an array of pixels created from a part of drawable
3926/// (defined by x, y, w, h) in format:
3927/// `b1, g1, r1, 0, b2, g2, r2, 0, ..., bn, gn, rn, 0`.
3928///
3929/// Pixels are numbered from left to right and from top to bottom.
3930/// By default all pixels from the whole drawable are returned.
3931///
3932/// Note that return array is 32-bit aligned
3933
3934unsigned char *TGX11::GetColorBits(Drawable_t /*wid*/, Int_t /*x*/, Int_t /*y*/,
3935 UInt_t /*w*/, UInt_t /*h*/)
3936{
3937 return nullptr;
3938}
3939
3940////////////////////////////////////////////////////////////////////////////////
3941/// create pixmap from RGB data. RGB data is in format :
3942/// b1, g1, r1, 0, b2, g2, r2, 0 ... bn, gn, rn, 0 ..
3943///
3944/// Pixels are numbered from left to right and from top to bottom.
3945/// Note that data must be 32-bit aligned
3946
3947Pixmap_t TGX11::CreatePixmapFromData(unsigned char * /*bits*/, UInt_t /*width*/,
3948 UInt_t /*height*/)
3949{
3950 return (Pixmap_t)0;
3951}
3952
3953////////////////////////////////////////////////////////////////////////////////
3954/// Register pixmap created by gVirtualGL
3955///
3956/// \param [in] pixid Pixmap identifier
3957/// \param [in] w,h Width and height of the pixmap
3958///
3959/// register new pixmap
3960
3962{
3964
3965 gCws = fWindows[wid].get();
3966 gCws->fWindow = pixid;
3967 gCws->fDrawing = gCws->fWindow;
3968 gCws->fBuffer = 0;
3969 gCws->fDoubleBuffer = 0;
3970 gCws->fIsPixmap = 1;
3971 gCws->fClip = 0;
3972 gCws->fWidth = w;
3973 gCws->fHeight = h;
3974 gCws->fNewColors = nullptr;
3975 gCws->fShared = kFALSE;
3976
3977 return wid;
3978}
3979
3980////////////////////////////////////////////////////////////////////////////////
3981/// Returns 1 if window system server supports extension given by the
3982/// argument, returns 0 in case extension is not supported and returns -1
3983/// in case of error (like server not initialized).
3984/// Examples:
3985/// - "Apple-WM" - does server run on MacOS X;
3986/// - "XINERAMA" - does server support Xinerama.
3987/// See also the output of xdpyinfo.
3988
3990{
3992 if (!(Display*)fDisplay)
3993 return -1;
3995}
3996
3997
4002
4004{
4005 auto ctxt = (XWindow_t *) wctxt;
4006 if (!ctxt)
4007 return;
4008
4009 Int_t cindex = att.GetFillColor();
4010 if (!gStyle->GetFillColor() && cindex > 1)
4011 cindex = 0;
4012 if (cindex >= 0)
4013 SetColor(&ctxt->fGClist[kGCfill], Int_t(cindex));
4014 ctxt->fAttFill.SetFillColor(cindex);
4015
4016 Int_t style = att.GetFillStyle() / 1000;
4017 Int_t fasi = att.GetFillStyle() % 1000;
4018 Int_t stn = (fasi >= 1 && fasi <=25) ? fasi : 2;
4019 ctxt->fAttFill.SetFillStyle(style * 1000 + fasi);
4020
4021 switch (style) {
4022 case 1: // solid
4023 ctxt->fillHollow = 0;
4024 XSetFillStyle((Display*)fDisplay, ctxt->fGClist[kGCfill], FillSolid);
4025 break;
4026
4027 case 2: // pattern
4028 ctxt->fillHollow = 1;
4029 break;
4030
4031 case 3: // hatch
4032 ctxt->fillHollow = 0;
4033 XSetFillStyle((Display*)fDisplay, ctxt->fGClist[kGCfill], FillStippled);
4034
4035 if (stn != ctxt->fillFasi) {
4036 if (ctxt->fillPattern != 0)
4037 XFreePixmap((Display*)fDisplay, ctxt->fillPattern);
4038
4039 ctxt->fillPattern = XCreateBitmapFromData((Display*)fDisplay, fRootWin,
4040 (const char*)gStipples[stn], 16, 16);
4041
4042 XSetStipple((Display*)fDisplay, ctxt->fGClist[kGCfill], ctxt->fillPattern);
4043 ctxt->fillFasi = stn;
4044 }
4045 break;
4046
4047 default:
4048 ctxt->fillHollow = 1;
4049 }
4050}
4051
4053{
4054 auto ctxt = (XWindow_t *) wctxt;
4055 if (!ctxt)
4056 return;
4057
4058 if (ctxt->fAttLine.GetLineStyle() != att.GetLineStyle()) { //set style index only if different
4059 if (att.GetLineStyle() <= 1)
4060 ctxt->dashList.clear();
4061 else if (att.GetLineStyle() == 2)
4062 ctxt->dashList = { 3, 3 };
4063 else if (att.GetLineStyle() == 3)
4064 ctxt->dashList = { 1, 2 };
4065 else if (att.GetLineStyle() == 4) {
4066 ctxt->dashList = { 3, 4, 1, 4} ;
4067 } else {
4068 TString st = (TString)gStyle->GetLineStyleString(att.GetLineStyle());
4069 auto tokens = st.Tokenize(" ");
4070 Int_t nt = tokens->GetEntries();
4071 ctxt->dashList.resize(nt);
4072 for (Int_t j = 0; j < nt; ++j) {
4073 Int_t it;
4074 sscanf(tokens->At(j)->GetName(), "%d", &it);
4075 ctxt->dashList[j] = (Int_t) (it/4);
4076 }
4077 delete tokens;
4078 }
4079 ctxt->dashLength = 0;
4080 for (auto elem : ctxt->dashList)
4081 ctxt->dashLength += elem;
4082 ctxt->dashOffset = 0;
4083 ctxt->lineStyle = ctxt->dashList.size() == 0 ? LineSolid : LineOnOffDash;
4084 }
4085
4086 if (ctxt->fAttLine.GetLineWidth() != att.GetLineWidth()) {
4087 ctxt->lineWidth = att.GetLineWidth();
4088 if (ctxt->lineStyle == LineSolid) {
4089 if (ctxt->lineWidth == 1)
4090 ctxt->lineWidth = 0;
4091 } else {
4092 if (ctxt->lineWidth == 0)
4093 ctxt->lineWidth = 1;
4094 }
4095 }
4096
4097 if (ctxt->lineWidth >= 0) {
4098 XSetLineAttributes((Display*)fDisplay, ctxt->fGClist[kGCline], ctxt->lineWidth,
4099 ctxt->lineStyle, gCapStyle, gJoinStyle);
4100 if (ctxt->lineStyle == LineOnOffDash)
4101 XSetLineAttributes((Display*)fDisplay, ctxt->fGClist[kGCdash], ctxt->lineWidth,
4102 ctxt->lineStyle, gCapStyle, gJoinStyle);
4103 }
4104
4105 if (att.GetLineColor() >= 0) {
4106 SetColor(&ctxt->fGClist[kGCline], (Int_t) att.GetLineColor());
4107 SetColor(&ctxt->fGClist[kGCdash], (Int_t) att.GetLineColor());
4108 }
4109
4110 ctxt->fAttLine = att;
4111}
4112
4114{
4115 auto ctxt = (XWindow_t *) wctxt;
4116 if (!ctxt)
4117 return;
4118
4119 SetColor(&ctxt->fGClist[kGCmark], att.GetMarkerColor());
4120
4121 Bool_t changed = (att.GetMarkerSize() != ctxt->fAttMarker.GetMarkerSize()) ||
4122 (att.GetMarkerStyle() != ctxt->fAttMarker.GetMarkerStyle());
4123
4124 ctxt->fAttMarker = att;
4125
4126 if (!changed)
4127 return;
4128
4130 ctxt->markerLineWidth = TAttMarker::GetMarkerLineWidth(att.GetMarkerStyle());
4131
4132 // The fast pixel markers need to be treated separately
4133 if (markerstyle == 1 || markerstyle == 6 || markerstyle == 7) {
4135 } else {
4136 XSetLineAttributes((Display*)fDisplay, ctxt->fGClist[kGCmark], ctxt->markerLineWidth,
4138 }
4139
4140 Float_t MarkerSizeReduced = att.GetMarkerSize() - TMath::Floor(ctxt->markerLineWidth/2.)/4.;
4141 Int_t im = Int_t(4*MarkerSizeReduced + 0.5);
4142 auto &shape = ctxt->markerShape;
4143 ctxt->markerSize = 0;
4144 ctxt->markerType = 0;
4145 if (markerstyle == 2) {
4146 // + shaped marker
4147 shape.resize(4);
4148 shape[0].x = -im; shape[0].y = 0;
4149 shape[1].x = im; shape[1].y = 0;
4150 shape[2].x = 0 ; shape[2].y = -im;
4151 shape[3].x = 0 ; shape[3].y = im;
4152 ctxt->markerType = 4;
4153 } else if (markerstyle == 3 || markerstyle == 31) {
4154 // * shaped marker
4155 shape.resize(8);
4156 shape[0].x = -im; shape[0].y = 0;
4157 shape[1].x = im; shape[1].y = 0;
4158 shape[2].x = 0 ; shape[2].y = -im;
4159 shape[3].x = 0 ; shape[3].y = im;
4160 im = Int_t(0.707*Float_t(im) + 0.5);
4161 shape[4].x = -im; shape[4].y = -im;
4162 shape[5].x = im; shape[5].y = im;
4163 shape[6].x = -im; shape[6].y = im;
4164 shape[7].x = im; shape[7].y = -im;
4165 ctxt->markerType = 4;
4166 } else if (markerstyle == 4 || markerstyle == 24) {
4167 // O shaped marker
4168 ctxt->markerType = 0;
4169 ctxt->markerSize = im*2;
4170 } else if (markerstyle == 5) {
4171 // X shaped marker
4172 shape.resize(4);
4173 im = Int_t(0.707*Float_t(im) + 0.5);
4174 shape[0].x = -im; shape[0].y = -im;
4175 shape[1].x = im; shape[1].y = im;
4176 shape[2].x = -im; shape[2].y = im;
4177 shape[3].x = im; shape[3].y = -im;
4178 ctxt->markerType = 4;
4179 } else if (markerstyle == 6) {
4180 // + shaped marker (with 1 pixel)
4181 shape.resize(4);
4182 shape[0].x = -1 ; shape[0].y = 0;
4183 shape[1].x = 1 ; shape[1].y = 0;
4184 shape[2].x = 0 ; shape[2].y = -1;
4185 shape[3].x = 0 ; shape[3].y = 1;
4186 ctxt->markerType = 4;
4187 } else if (markerstyle == 7) {
4188 // . shaped marker (with 9 pixel)
4189 shape.resize(6);
4190 shape[0].x = -1 ; shape[0].y = 1;
4191 shape[1].x = 1 ; shape[1].y = 1;
4192 shape[2].x = -1 ; shape[2].y = 0;
4193 shape[3].x = 1 ; shape[3].y = 0;
4194 shape[4].x = -1 ; shape[4].y = -1;
4195 shape[5].x = 1 ; shape[5].y = -1;
4196 ctxt->markerType = 4;
4197 } else if (markerstyle == 8 || markerstyle == 20) {
4198 // O shaped marker (filled)
4199 ctxt->markerType = 1;
4200 ctxt->markerSize = im*2;
4201 } else if (markerstyle == 21) {
4202 // full square
4203 shape.resize(5);
4204 shape[0].x = -im; shape[0].y = -im;
4205 shape[1].x = im; shape[1].y = -im;
4206 shape[2].x = im; shape[2].y = im;
4207 shape[3].x = -im; shape[3].y = im;
4208 shape[4].x = -im; shape[4].y = -im;
4209 ctxt->markerType = 3;
4210 } else if (markerstyle == 22) {
4211 // full triangle up
4212 shape.resize(4);
4213 shape[0].x = -im; shape[0].y = im;
4214 shape[1].x = im; shape[1].y = im;
4215 shape[2].x = 0; shape[2].y = -im;
4216 shape[3].x = -im; shape[3].y = im;
4217 ctxt->markerType = 3;
4218 } else if (markerstyle == 23) {
4219 // full triangle down
4220 shape.resize(4);
4221 shape[0].x = 0; shape[0].y = im;
4222 shape[1].x = im; shape[1].y = -im;
4223 shape[2].x = -im; shape[2].y = -im;
4224 shape[3].x = 0; shape[3].y = im;
4225 ctxt->markerType = 3;
4226 } else if (markerstyle == 25) {
4227 // open square
4228 shape.resize(5);
4229 shape[0].x = -im; shape[0].y = -im;
4230 shape[1].x = im; shape[1].y = -im;
4231 shape[2].x = im; shape[2].y = im;
4232 shape[3].x = -im; shape[3].y = im;
4233 shape[4].x = -im; shape[4].y = -im;
4234 ctxt->markerType = 2;
4235 } else if (markerstyle == 26) {
4236 // open triangle up
4237 shape.resize(4);
4238 shape[0].x = -im; shape[0].y = im;
4239 shape[1].x = im; shape[1].y = im;
4240 shape[2].x = 0; shape[2].y = -im;
4241 shape[3].x = -im; shape[3].y = im;
4242 ctxt->markerType = 2;
4243 } else if (markerstyle == 27) {
4244 // open losange
4245 shape.resize(5);
4246 Int_t imx = Int_t(2.66*MarkerSizeReduced + 0.5);
4247 shape[0].x =-imx; shape[0].y = 0;
4248 shape[1].x = 0; shape[1].y = -im;
4249 shape[2].x = imx; shape[2].y = 0;
4250 shape[3].x = 0; shape[3].y = im;
4251 shape[4].x =-imx; shape[4].y = 0;
4252 ctxt->markerType = 2;
4253 } else if (markerstyle == 28) {
4254 // open cross
4255 shape.resize(13);
4256 Int_t imx = Int_t(1.33*MarkerSizeReduced + 0.5);
4257 shape[0].x = -im; shape[0].y =-imx;
4258 shape[1].x =-imx; shape[1].y =-imx;
4259 shape[2].x =-imx; shape[2].y = -im;
4260 shape[3].x = imx; shape[3].y = -im;
4261 shape[4].x = imx; shape[4].y =-imx;
4262 shape[5].x = im; shape[5].y =-imx;
4263 shape[6].x = im; shape[6].y = imx;
4264 shape[7].x = imx; shape[7].y = imx;
4265 shape[8].x = imx; shape[8].y = im;
4266 shape[9].x =-imx; shape[9].y = im;
4267 shape[10].x=-imx; shape[10].y= imx;
4268 shape[11].x= -im; shape[11].y= imx;
4269 shape[12].x= -im; shape[12].y=-imx;
4270 ctxt->markerType = 2;
4271 } else if (markerstyle == 29) {
4272 // full star pentagone
4273 shape.resize(11);
4274 Int_t im1 = Int_t(0.66*MarkerSizeReduced + 0.5);
4275 Int_t im2 = Int_t(2.00*MarkerSizeReduced + 0.5);
4276 Int_t im3 = Int_t(2.66*MarkerSizeReduced + 0.5);
4277 Int_t im4 = Int_t(1.33*MarkerSizeReduced + 0.5);
4278 shape[0].x = -im; shape[0].y = im4;
4279 shape[1].x =-im2; shape[1].y =-im1;
4280 shape[2].x =-im3; shape[2].y = -im;
4281 shape[3].x = 0; shape[3].y =-im2;
4282 shape[4].x = im3; shape[4].y = -im;
4283 shape[5].x = im2; shape[5].y =-im1;
4284 shape[6].x = im; shape[6].y = im4;
4285 shape[7].x = im4; shape[7].y = im4;
4286 shape[8].x = 0; shape[8].y = im;
4287 shape[9].x =-im4; shape[9].y = im4;
4288 shape[10].x= -im; shape[10].y= im4;
4289 ctxt->markerType = 3;
4290 } else if (markerstyle == 30) {
4291 // open star pentagone
4292 shape.resize(11);
4293 Int_t im1 = Int_t(0.66*MarkerSizeReduced + 0.5);
4294 Int_t im2 = Int_t(2.00*MarkerSizeReduced + 0.5);
4295 Int_t im3 = Int_t(2.66*MarkerSizeReduced + 0.5);
4296 Int_t im4 = Int_t(1.33*MarkerSizeReduced + 0.5);
4297 shape[0].x = -im; shape[0].y = im4;
4298 shape[1].x =-im2; shape[1].y =-im1;
4299 shape[2].x =-im3; shape[2].y = -im;
4300 shape[3].x = 0; shape[3].y =-im2;
4301 shape[4].x = im3; shape[4].y = -im;
4302 shape[5].x = im2; shape[5].y =-im1;
4303 shape[6].x = im; shape[6].y = im4;
4304 shape[7].x = im4; shape[7].y = im4;
4305 shape[8].x = 0; shape[8].y = im;
4306 shape[9].x =-im4; shape[9].y = im4;
4307 shape[10].x= -im; shape[10].y= im4;
4308 ctxt->markerType = 2;
4309 } else if (markerstyle == 32) {
4310 // open triangle down
4311 shape.resize(4);
4312 shape[0].x = 0; shape[0].y = im;
4313 shape[1].x = im; shape[1].y = -im;
4314 shape[2].x = -im; shape[2].y = -im;
4315 shape[3].x = 0; shape[3].y = im;
4316 ctxt->markerType = 2;
4317 } else if (markerstyle == 33) {
4318 // full losange
4319 shape.resize(5);
4320 Int_t imx = Int_t(2.66*MarkerSizeReduced + 0.5);
4321 shape[0].x =-imx; shape[0].y = 0;
4322 shape[1].x = 0; shape[1].y = -im;
4323 shape[2].x = imx; shape[2].y = 0;
4324 shape[3].x = 0; shape[3].y = im;
4325 shape[4].x =-imx; shape[4].y = 0;
4326 ctxt->markerType = 3;
4327 } else if (markerstyle == 34) {
4328 // full cross
4329 shape.resize(13);
4330 Int_t imx = Int_t(1.33*MarkerSizeReduced + 0.5);
4331 shape[0].x = -im; shape[0].y =-imx;
4332 shape[1].x =-imx; shape[1].y =-imx;
4333 shape[2].x =-imx; shape[2].y = -im;
4334 shape[3].x = imx; shape[3].y = -im;
4335 shape[4].x = imx; shape[4].y =-imx;
4336 shape[5].x = im; shape[5].y =-imx;
4337 shape[6].x = im; shape[6].y = imx;
4338 shape[7].x = imx; shape[7].y = imx;
4339 shape[8].x = imx; shape[8].y = im;
4340 shape[9].x =-imx; shape[9].y = im;
4341 shape[10].x=-imx; shape[10].y= imx;
4342 shape[11].x= -im; shape[11].y= imx;
4343 shape[12].x= -im; shape[12].y=-imx;
4344 ctxt->markerType = 3;
4345 } else if (markerstyle == 35) {
4346 // diamond with cross
4347 shape.resize(8);
4348 shape[0].x =-im; shape[0].y = 0;
4349 shape[1].x = 0; shape[1].y = -im;
4350 shape[2].x = im; shape[2].y = 0;
4351 shape[3].x = 0; shape[3].y = im;
4352 shape[4].x =-im; shape[4].y = 0;
4353 shape[5].x = im; shape[5].y = 0;
4354 shape[6].x = 0; shape[6].y = im;
4355 shape[7].x = 0; shape[7].y =-im;
4356 ctxt->markerType = 2;
4357 } else if (markerstyle == 36) {
4358 // square with diagonal cross
4359 shape.resize(8);
4360 shape[0].x = -im; shape[0].y = -im;
4361 shape[1].x = im; shape[1].y = -im;
4362 shape[2].x = im; shape[2].y = im;
4363 shape[3].x = -im; shape[3].y = im;
4364 shape[4].x = -im; shape[4].y = -im;
4365 shape[5].x = im; shape[5].y = im;
4366 shape[6].x = -im; shape[6].y = im;
4367 shape[7].x = im; shape[7].y = -im;
4368 ctxt->markerType = 2;
4369 } else if (markerstyle == 37) {
4370 // open three triangles
4371 shape.resize(10);
4372 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
4373 shape[0].x = 0; shape[0].y = 0;
4374 shape[1].x =-im2; shape[1].y = im;
4375 shape[2].x = im2; shape[2].y = im;
4376 shape[3].x = 0; shape[3].y = 0;
4377 shape[4].x =-im2; shape[4].y = -im;
4378 shape[5].x = -im; shape[5].y = 0;
4379 shape[6].x = 0; shape[6].y = 0;
4380 shape[7].x = im; shape[7].y = 0;
4381 shape[8].x = im2; shape[8].y = -im;
4382 shape[9].x = 0; shape[9].y = 0;
4383 ctxt->markerType = 2;
4384 } else if (markerstyle == 38) {
4385 // + shaped marker with octagon
4386 shape.resize(15);
4387 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
4388 shape[0].x = -im; shape[0].y = 0;
4389 shape[1].x = -im; shape[1].y =-im2;
4390 shape[2].x =-im2; shape[2].y = -im;
4391 shape[3].x = im2; shape[3].y = -im;
4392 shape[4].x = im; shape[4].y =-im2;
4393 shape[5].x = im; shape[5].y = im2;
4394 shape[6].x = im2; shape[6].y = im;
4395 shape[7].x =-im2; shape[7].y = im;
4396 shape[8].x = -im; shape[8].y = im2;
4397 shape[9].x = -im; shape[9].y = 0;
4398 shape[10].x = im; shape[10].y = 0;
4399 shape[11].x = 0; shape[11].y = 0;
4400 shape[12].x = 0; shape[12].y = -im;
4401 shape[13].x = 0; shape[13].y = im;
4402 shape[14].x = 0; shape[14].y = 0;
4403 ctxt->markerType = 2;
4404 } else if (markerstyle == 39) {
4405 // filled three triangles
4406 shape.resize(9);
4407 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
4408 shape[0].x = 0; shape[0].y = 0;
4409 shape[1].x =-im2; shape[1].y = im;
4410 shape[2].x = im2; shape[2].y = im;
4411 shape[3].x = 0; shape[3].y = 0;
4412 shape[4].x =-im2; shape[4].y = -im;
4413 shape[5].x = -im; shape[5].y = 0;
4414 shape[6].x = 0; shape[6].y = 0;
4415 shape[7].x = im; shape[7].y = 0;
4416 shape[8].x = im2; shape[8].y = -im;
4417 ctxt->markerType = 3;
4418 } else if (markerstyle == 40) {
4419 // four open triangles X
4420 shape.resize(13);
4421 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
4422 shape[0].x = 0; shape[0].y = 0;
4423 shape[1].x = im2; shape[1].y = im;
4424 shape[2].x = im; shape[2].y = im2;
4425 shape[3].x = 0; shape[3].y = 0;
4426 shape[4].x = im; shape[4].y = -im2;
4427 shape[5].x = im2; shape[5].y = -im;
4428 shape[6].x = 0; shape[6].y = 0;
4429 shape[7].x = -im2; shape[7].y = -im;
4430 shape[8].x = -im; shape[8].y = -im2;
4431 shape[9].x = 0; shape[9].y = 0;
4432 shape[10].x = -im; shape[10].y = im2;
4433 shape[11].x = -im2; shape[11].y = im;
4434 shape[12].x = 0; shape[12].y = 0;
4435 ctxt->markerType = 2;
4436 } else if (markerstyle == 41) {
4437 // four filled triangles X
4438 shape.resize(13);
4439 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
4440 shape[0].x = 0; shape[0].y = 0;
4441 shape[1].x = im2; shape[1].y = im;
4442 shape[2].x = im; shape[2].y = im2;
4443 shape[3].x = 0; shape[3].y = 0;
4444 shape[4].x = im; shape[4].y = -im2;
4445 shape[5].x = im2; shape[5].y = -im;
4446 shape[6].x = 0; shape[6].y = 0;
4447 shape[7].x = -im2; shape[7].y = -im;
4448 shape[8].x = -im; shape[8].y = -im2;
4449 shape[9].x = 0; shape[9].y = 0;
4450 shape[10].x = -im; shape[10].y = im2;
4451 shape[11].x = -im2; shape[11].y = im;
4452 shape[12].x = 0; shape[12].y = 0;
4453 ctxt->markerType = 3;
4454 } else if (markerstyle == 42) {
4455 // open double diamonds
4456 shape.resize(9);
4458 shape[0].x= 0; shape[0].y= im;
4459 shape[1].x= -imx; shape[1].y= imx;
4460 shape[2].x = -im; shape[2].y = 0;
4461 shape[3].x = -imx; shape[3].y = -imx;
4462 shape[4].x = 0; shape[4].y = -im;
4463 shape[5].x = imx; shape[5].y = -imx;
4464 shape[6].x = im; shape[6].y = 0;
4465 shape[7].x= imx; shape[7].y= imx;
4466 shape[8].x= 0; shape[8].y= im;
4467 ctxt->markerType = 2;
4468 } else if (markerstyle == 43) {
4469 // filled double diamonds
4470 shape.resize(9);
4472 shape[0].x = 0; shape[0].y = im;
4473 shape[1].x = -imx; shape[1].y = imx;
4474 shape[2].x = -im; shape[2].y = 0;
4475 shape[3].x = -imx; shape[3].y = -imx;
4476 shape[4].x = 0; shape[4].y = -im;
4477 shape[5].x = imx; shape[5].y = -imx;
4478 shape[6].x = im; shape[6].y = 0;
4479 shape[7].x = imx; shape[7].y = imx;
4480 shape[8].x = 0; shape[8].y = im;
4481 ctxt->markerType = 3;
4482 } else if (markerstyle == 44) {
4483 // open four triangles plus
4484 shape.resize(11);
4485 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
4486 shape[0].x = 0; shape[0].y = 0;
4487 shape[1].x = im2; shape[1].y = im;
4488 shape[2].x = -im2; shape[2].y = im;
4489 shape[3].x = im2; shape[3].y = -im;
4490 shape[4].x = -im2; shape[4].y = -im;
4491 shape[5].x = 0; shape[5].y = 0;
4492 shape[6].x = im; shape[6].y = im2;
4493 shape[7].x = im; shape[7].y = -im2;
4494 shape[8].x = -im; shape[8].y = im2;
4495 shape[9].x = -im; shape[9].y = -im2;
4496 shape[10].x = 0; shape[10].y = 0;
4497 ctxt->markerType = 2;
4498 } else if (markerstyle == 45) {
4499 // filled four triangles plus
4500 shape.resize(13);
4501 Int_t im0 = Int_t(0.4*MarkerSizeReduced + 0.5);
4502 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
4503 shape[0].x = im0; shape[0].y = im0;
4504 shape[1].x = im2; shape[1].y = im;
4505 shape[2].x = -im2; shape[2].y = im;
4506 shape[3].x = -im0; shape[3].y = im0;
4507 shape[4].x = -im; shape[4].y = im2;
4508 shape[5].x = -im; shape[5].y = -im2;
4509 shape[6].x = -im0; shape[6].y = -im0;
4510 shape[7].x = -im2; shape[7].y = -im;
4511 shape[8].x = im2; shape[8].y = -im;
4512 shape[9].x = im0; shape[9].y = -im0;
4513 shape[10].x = im; shape[10].y = -im2;
4514 shape[11].x = im; shape[11].y = im2;
4515 shape[12].x = im0; shape[12].y = im0;
4516 ctxt->markerType = 3;
4517 } else if (markerstyle == 46) {
4518 // open four triangles X
4519 shape.resize(13);
4520 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
4521 shape[0].x = 0; shape[0].y = im2;
4522 shape[1].x = -im2; shape[1].y = im;
4523 shape[2].x = -im; shape[2].y = im2;
4524 shape[3].x = -im2; shape[3].y = 0;
4525 shape[4].x = -im; shape[4].y = -im2;
4526 shape[5].x = -im2; shape[5].y = -im;
4527 shape[6].x = 0; shape[6].y = -im2;
4528 shape[7].x = im2; shape[7].y = -im;
4529 shape[8].x = im; shape[8].y = -im2;
4530 shape[9].x = im2; shape[9].y = 0;
4531 shape[10].x = im; shape[10].y = im2;
4532 shape[11].x = im2; shape[11].y = im;
4533 shape[12].x = 0; shape[12].y = im2;
4534 ctxt->markerType = 2;
4535 } else if (markerstyle == 47) {
4536 // filled four triangles X
4537 shape.resize(13);
4538 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
4539 shape[0].x = 0; shape[0].y = im2;
4540 shape[1].x = -im2; shape[1].y = im;
4541 shape[2].x = -im; shape[2].y = im2;
4542 shape[3].x = -im2; shape[3].y = 0;
4543 shape[4].x = -im; shape[4].y = -im2;
4544 shape[5].x = -im2; shape[5].y = -im;
4545 shape[6].x = 0; shape[6].y = -im2;
4546 shape[7].x = im2; shape[7].y = -im;
4547 shape[8].x = im; shape[8].y = -im2;
4548 shape[9].x = im2; shape[9].y = 0;
4549 shape[10].x = im; shape[10].y = im2;
4550 shape[11].x = im2; shape[11].y = im;
4551 shape[12].x = 0; shape[12].y = im2;
4552 ctxt->markerType = 3;
4553 } else if (markerstyle == 48) {
4554 // four filled squares X
4555 shape.resize(17);
4556 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
4557 shape[0].x = 0; shape[0].y = im2*1.005;
4558 shape[1].x = -im2; shape[1].y = im;
4559 shape[2].x = -im; shape[2].y = im2;
4560 shape[3].x = -im2; shape[3].y = 0;
4561 shape[4].x = -im; shape[4].y = -im2;
4562 shape[5].x = -im2; shape[5].y = -im;
4563 shape[6].x = 0; shape[6].y = -im2;
4564 shape[7].x = im2; shape[7].y = -im;
4565 shape[8].x = im; shape[8].y = -im2;
4566 shape[9].x = im2; shape[9].y = 0;
4567 shape[10].x = im; shape[10].y = im2;
4568 shape[11].x = im2; shape[11].y = im;
4569 shape[12].x = 0; shape[12].y = im2*0.995;
4570 shape[13].x = im2*0.995; shape[13].y = 0;
4571 shape[14].x = 0; shape[14].y = -im2*0.995;
4572 shape[15].x = -im2*0.995; shape[15].y = 0;
4573 shape[16].x = 0; shape[16].y = im2*0.995;
4574 ctxt->markerType = 3;
4575 } else if (markerstyle == 49) {
4576 // four filled squares plus
4577 shape.resize(17);
4578 Int_t imx = Int_t(1.33*MarkerSizeReduced + 0.5);
4579 shape[0].x =-imx; shape[0].y =-imx*1.005;
4580 shape[1].x =-imx; shape[1].y = -im;
4581 shape[2].x = imx; shape[2].y = -im;
4582 shape[3].x = imx; shape[3].y =-imx;
4583 shape[4].x = im; shape[4].y =-imx;
4584 shape[5].x = im; shape[5].y = imx;
4585 shape[6].x = imx; shape[6].y = imx;
4586 shape[7].x = imx; shape[7].y = im;
4587 shape[8].x =-imx; shape[8].y = im;
4588 shape[9].x =-imx; shape[9].y = imx;
4589 shape[10].x = -im; shape[10].y = imx;
4590 shape[11].x = -im; shape[11].y =-imx;
4591 shape[12].x =-imx; shape[12].y =-imx*0.995;
4592 shape[13].x =-imx; shape[13].y = imx;
4593 shape[14].x = imx; shape[14].y = imx;
4594 shape[15].x = imx; shape[15].y =-imx;
4595 shape[16].x =-imx; shape[16].y =-imx*1.005;
4596 ctxt->markerType = 3;
4597 } else {
4598 // single dot
4599 shape.resize(0);
4600 ctxt->markerType = 0;
4601 ctxt->markerSize = 0;
4602 }
4603}
4604
4606{
4607 auto ctxt = (XWindow_t *) wctxt;
4608 if (!ctxt)
4609 return;
4610
4611 Int_t txalh = att.GetTextAlign() / 10;
4612 Int_t txalv = att.GetTextAlign() % 10;
4613
4614 switch (txalh) {
4615 case 0 :
4616 case 1 :
4617 switch (txalv) { //left
4618 case 1 :
4619 ctxt->textAlign = 7; //bottom
4620 break;
4621 case 2 :
4622 ctxt->textAlign = 4; //center
4623 break;
4624 case 3 :
4625 ctxt->textAlign = 1; //top
4626 break;
4627 }
4628 break;
4629 case 2 :
4630 switch (txalv) { //center
4631 case 1 :
4632 ctxt->textAlign = 8; //bottom
4633 break;
4634 case 2 :
4635 ctxt->textAlign = 5; //center
4636 break;
4637 case 3 :
4638 ctxt->textAlign = 2; //top
4639 break;
4640 }
4641 break;
4642 case 3 :
4643 switch (txalv) { //right
4644 case 1 :
4645 ctxt->textAlign = 9; //bottom
4646 break;
4647 case 2 :
4648 ctxt->textAlign = 6; //center
4649 break;
4650 case 3 :
4651 ctxt->textAlign = 3; //top
4652 break;
4653 }
4654 break;
4655 }
4656
4657 SetColor(&ctxt->fGClist[kGCtext], att.GetTextColor());
4658
4659 XGCValues values;
4660 if (XGetGCValues((Display*)fDisplay, ctxt->fGClist[kGCtext], GCForeground | GCBackground, &values)) {
4661 XSetForeground( (Display*)fDisplay, ctxt->fGClist[kGCinvt], values.background );
4662 XSetBackground( (Display*)fDisplay, ctxt->fGClist[kGCinvt], values.foreground );
4663 } else {
4664 Error("SetAttText", "cannot get GC values");
4665 }
4666 XSetBackground((Display*)fDisplay, ctxt->fGClist[kGCtext], GetColor(0).fPixel);
4667
4668 // use first existing font
4669 for (int i = 0; i < kMAXFONT; i++)
4670 if (gFont[i].id) {
4671 gCws->textFont = gFont[i].id;
4672 XSetFont((Display*)fDisplay, gCws->fGClist[kGCtext], gCws->textFont->fid);
4673 XSetFont((Display*)fDisplay, gCws->fGClist[kGCinvt], gCws->textFont->fid);
4674 break;
4675 }
4676
4677 ctxt->fAttText = att;
4678}
4679
4680////////////////////////////////////////////////////////////////////////////////
4681/// Set window draw mode
4682
4684{
4685 auto ctxt = (XWindow_t *) wctxt;
4686 if (!ctxt)
4687 return;
4688
4689 auto gxmode = GXcopy;
4690 if (mode == kXor)
4691 gxmode = GXxor;
4692 else if (mode == kInvert)
4693 gxmode = GXinvert;
4694 for (int i = 0; i < kMAXGC; i++)
4695 XSetFunction((Display*)fDisplay, ctxt->fGClist[i], gxmode);
4696
4697 ctxt->fDrawMode = mode;
4698}
4699
4700////////////////////////////////////////////////////////////////////////////////
4701/// Returns window draw mode
4702
4704{
4705 auto ctxt = (XWindow_t *) wctxt;
4706 return ctxt ? ctxt->fDrawMode : kCopy;
4707}
Handle_t WinContext_t
Window drawing context.
Definition GuiTypes.h:30
ECursor
Definition GuiTypes.h:373
@ kRightSide
Definition GuiTypes.h:374
@ kBottomSide
Definition GuiTypes.h:374
@ kArrowRight
Definition GuiTypes.h:376
@ kTopLeft
Definition GuiTypes.h:373
@ kBottomRight
Definition GuiTypes.h:373
@ kArrowVer
Definition GuiTypes.h:375
@ kCaret
Definition GuiTypes.h:376
@ kTopSide
Definition GuiTypes.h:374
@ kLeftSide
Definition GuiTypes.h:374
@ kWatch
Definition GuiTypes.h:376
@ kMove
Definition GuiTypes.h:375
@ kTopRight
Definition GuiTypes.h:373
@ kBottomLeft
Definition GuiTypes.h:373
@ kHand
Definition GuiTypes.h:375
@ kCross
Definition GuiTypes.h:375
@ kRotate
Definition GuiTypes.h:375
@ kNoDrop
Definition GuiTypes.h:376
@ kArrowHor
Definition GuiTypes.h:375
@ kPointer
Definition GuiTypes.h:376
Handle_t Pixmap_t
Pixmap handle.
Definition GuiTypes.h:31
Handle_t Window_t
Window handle.
Definition GuiTypes.h:29
Handle_t Drawable_t
Drawable handle.
Definition GuiTypes.h:32
const int kNumCursors
Definition GuiTypes.h:372
#define b(i)
Definition RSha256.hxx:100
#define c(i)
Definition RSha256.hxx:101
#define g(i)
Definition RSha256.hxx:105
#define h(i)
Definition RSha256.hxx:106
const unsigned char gStipples[26][32]
Definition RStipples.h:24
int XRotDrawAlignedImageString(Display *, XFontStruct *, float, Drawable, GC, int, int, char *, int)
A front end to XRotPaintAlignedString: -does alignment, paints background.
Definition Rotated.cxx:316
int XRotDrawAlignedString(Display *, XFontStruct *, float, Drawable, GC, int, int, char *, int)
A front end to XRotPaintAlignedString: -does alignment, no background.
Definition Rotated.cxx:305
XPoint * XRotTextExtents(Display *, XFontStruct *, float, int, int, char *, int)
Calculate the bounding box some text will have when painted.
Definition Rotated.cxx:1337
void XRotSetMagnification(float)
Set the font magnification factor for all subsequent operations.
Definition Rotated.cxx:242
short Style_t
Style number (short)
Definition RtypesCore.h:96
unsigned short UShort_t
Unsigned Short integer 2 bytes (unsigned short)
Definition RtypesCore.h:54
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
unsigned char Byte_t
Byte (8 bits) (unsigned char)
Definition RtypesCore.h:78
short Color_t
Color number (short)
Definition RtypesCore.h:99
unsigned char UChar_t
Unsigned Character 1 byte (unsigned char)
Definition RtypesCore.h:52
constexpr ULong_t kBitsPerByte
Definition RtypesCore.h:130
int Seek_t
File pointer (int).
Definition RtypesCore.h:67
unsigned long ULong_t
Unsigned long integer 4 bytes (unsigned long). Size depends on architecture.
Definition RtypesCore.h:69
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
Definition RtypesCore.h:68
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int)
Definition RtypesCore.h:60
short Width_t
Line width (short)
Definition RtypesCore.h:98
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:71
short Font_t
Font number (short)
Definition RtypesCore.h:95
short Short_t
Signed Short integer 2 bytes (short)
Definition RtypesCore.h:53
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
R__EXTERN TEnv * gEnv
Definition TEnv.h:170
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void chupy
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t mask
Option_t Option_t cindex
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t cursor
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void cmap
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void pixel
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize wid
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height qwid
Option_t Option_t mgn
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t fontnumber
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
Option_t Option_t markerstyle
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void chupx
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text CreatePixmap
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char pxname
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t nitems
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t textsize
Option_t Option_t TPoint TPoint angle
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t win
Option_t Option_t TPoint xy
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void xpos
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t attr
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t org
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char fontname
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void ypos
Option_t Option_t width
Option_t Option_t TPoint TPoint percent
Option_t Option_t style
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void gc
Option_t Option_t TPoint TPoint const char text
Option_t Option_t TPoint TPoint const char y1
static void PutByte(Byte_t b)
Put byte b in output stream.
Definition TGWin32.cxx:4311
unsigned long KeySym
Definition TGWin32.h:50
XPoint * XRotTextExtents(Display *, XFontStruct *, float, int, int, char *, int)
Calculate the bounding box some text will have when painted.
Definition Rotated.cxx:1337
static int gMarkerJoinStyle
Definition TGX11.cxx:175
const int kGCpxmp
Definition TGX11.cxx:86
static FILE * gOut
Definition TGX11.cxx:3602
static int gMarkerLineStyle
Definition TGX11.cxx:173
float XRotVersion(char *, int)
Return version/copyright information.
Definition Rotated.cxx:232
int GIFquantize(UInt_t width, UInt_t height, Int_t *ncol, Byte_t *red, Byte_t *green, Byte_t *blue, Byte_t *outputBuf, Byte_t *outputCmap)
static ULong_t gKeybdMask
Definition TGX11.cxx:196
void XRotSetMagnification(float)
Set the font magnification factor for all subsequent operations.
Definition Rotated.cxx:242
static struct @56 gFont[kMAXFONT]
static int gCapStyle
Definition TGX11.cxx:182
static GC gGCecho
Definition TGX11.cxx:96
XFontStruct * id
Definition TGX11.cxx:156
static void GetPixel(int y, int width, Byte_t *scline)
Get pixels in line y and put in array scline.
Definition TGX11.cxx:3617
static Cursor gNullCursor
Definition TGX11.cxx:206
char name[80]
Definition TGX11.cxx:157
static XWindow_t * gTws
Definition TGX11.cxx:143
const int kMAXGC
Definition TGX11.cxx:84
const int kGCline
Definition TGX11.cxx:85
int GIFdecode(Byte_t *gifArr, Byte_t *pixArr, int *Width, int *Height, int *Ncols, Byte_t *R, Byte_t *G, Byte_t *B)
Definition gifdecode.c:149
const Int_t kMAXFONT
Definition TGX11.cxx:154
const char null_cursor_bits[]
Definition TGX11.cxx:202
int XRotDrawString(Display *, XFontStruct *, float, Drawable, GC, int, int, char *)
A front end to XRotPaintAlignedString: -no alignment, no background.
Definition Rotated.cxx:283
const int kGCinvt
Definition TGX11.cxx:86
const int kGCtext
Definition TGX11.cxx:86
const Int_t kBIGGEST_RGB_VALUE
Definition TGX11.cxx:145
static void PutByte(Byte_t b)
Put byte b in output stream.
Definition TGX11.cxx:3626
long GIFencode(int Width, int Height, Int_t Ncol, Byte_t R[], Byte_t G[], Byte_t B[], Byte_t ScLine[], void(*get_scline)(int, int, Byte_t *), void(*pb)(Byte_t))
int XRotDrawAlignedImageString(Display *, XFontStruct *, float, Drawable, GC, int, int, char *, int)
A front end to XRotPaintAlignedString: -does alignment, paints background.
Definition Rotated.cxx:316
static ULong_t gMouseMask
Definition TGX11.cxx:192
static Int_t gCurrentFontNumber
Definition TGX11.cxx:161
static int gJoinStyle
Definition TGX11.cxx:183
int XRotDrawAlignedString(Display *, XFontStruct *, float, Drawable, GC, int, int, char *, int)
A front end to XRotPaintAlignedString: -does alignment, no background.
Definition Rotated.cxx:305
int XRotDrawImageString(Display *, XFontStruct *, float, Drawable, GC, int, int, char *)
A front end to XRotPaintAlignedString: -no alignment, paints background.
Definition Rotated.cxx:294
const int kGCmark
Definition TGX11.cxx:85
static XImage * gXimage
Definition TGX11.cxx:3603
static int gMarkerCapStyle
Definition TGX11.cxx:174
const int kGCfill
Definition TGX11.cxx:85
const int kGCdash
Definition TGX11.cxx:86
static XFontStruct * gTextFont
Definition TGX11.cxx:160
void XRotSetBoundingBoxPad(int)
Set the padding used when calculating bounding boxes.
Definition Rotated.cxx:251
static Int_t DummyX11ErrorHandler(Display *, XErrorEvent *)
Dummy error handler for X11. Used by FindUsableVisual().
Definition TGX11.cxx:969
static XWindow_t * gCws
Definition TGX11.cxx:142
int GIFinfo(Byte_t *gifArr, int *Width, int *Height, int *Ncols)
Definition gifdecode.c:80
XID Colormap
Definition TGX11.h:37
XID Window
Definition TGX11.h:38
XID Drawable
Definition TGX11.h:35
XID Cursor
Definition TGX11.h:36
float xmin
float ymin
float xmax
float ymax
const Int_t kNMAX
Int_t gDebug
Global variable setting the debug level. Set to 0 to disable, increase it in steps of 1 to increase t...
Definition TROOT.cxx:627
#define gROOT
Definition TROOT.h:414
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
Definition TString.cxx:2509
R__EXTERN TStyle * gStyle
Definition TStyle.h:442
#define free
Definition civetweb.c:1578
#define calloc
Definition civetweb.c:1576
Fill Area Attributes class.
Definition TAttFill.h:21
virtual Color_t GetFillColor() const
Return the fill area color.
Definition TAttFill.h:32
virtual Style_t GetFillStyle() const
Return the fill area style.
Definition TAttFill.h:33
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition TAttFill.h:40
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
Definition TAttFill.h:42
Line Attributes class.
Definition TAttLine.h:21
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
Definition TAttLine.h:46
virtual Width_t GetLineWidth() const
Return the line width.
Definition TAttLine.h:38
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition TAttLine.h:47
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition TAttLine.h:44
virtual Style_t GetLineStyle() const
Return the line style.
Definition TAttLine.h:37
Marker Attributes class.
Definition TAttMarker.h:21
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
Definition TAttMarker.h:41
static Width_t GetMarkerLineWidth(Style_t style)
Internal helper function that returns the line width of the given marker style (0 = filled marker)
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
Definition TAttMarker.h:43
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
Definition TAttMarker.h:48
static Style_t GetMarkerStyleBase(Style_t style)
Internal helper function that returns the corresponding marker style with line width 1 for the given ...
Text Attributes class.
Definition TAttText.h:21
virtual void SetTextAlign(Short_t align=11)
Set the text alignment.
Definition TAttText.h:46
Float_t fTextAngle
Text angle.
Definition TAttText.h:24
virtual void SetTextColor(Color_t tcolor=1)
Set the text color.
Definition TAttText.h:48
virtual void SetTextFont(Font_t tfont=62)
Set the text font.
Definition TAttText.h:50
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
Definition TAttText.h:51
The color creation and management class.
Definition TColor.h:22
Float_t GetRed() const
Definition TColor.h:61
static Int_t GetColor(const char *hexcolor)
Static method returning color number for color specified by hex color string of form: "#rrggbb",...
Definition TColor.cxx:1926
Float_t GetBlue() const
Definition TColor.h:63
Float_t GetGreen() const
Definition TColor.h:62
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition TEnv.cxx:503
Bool_t Next(ULong64_t &hash, Long64_t &key, Long64_t &value)
Get next entry from TExMap. Returns kFALSE at end of map.
Definition TExMap.cxx:410
This class stores a (key,value) pair using an external hash.
Definition TExMap.h:33
void Add(ULong64_t hash, Long64_t key, Long64_t value)
Add an (key,value) pair to the table. The key should be unique.
Definition TExMap.cxx:87
Long64_t GetValue(ULong64_t hash, Long64_t key)
Return the value belonging to specified key and hash value.
Definition TExMap.cxx:173
This class is the basic interface to the X11 (Xlib) graphics system.
Definition TGX11.h:64
void DrawFillArea(Int_t n, TPoint *xy) override
Fill area described by polygon.
Definition TGX11.cxx:601
void * fDisplay
Pointer to display.
Definition TGX11.h:105
void DrawBoxW(WinContext_t wctxt, Int_t x1, Int_t y1, Int_t x2, Int_t y2, EBoxMode mode) override
Draw a box on specified window.
Definition TGX11.cxx:535
Int_t GetTextAlignW(WinContext_t wctxt) const
Return text align value for specified window context.
Definition TGX11.cxx:1107
void MakeOpaqueColors(Int_t percent, ULong_t *orgcolors, Int_t ncolors)
Get RGB values for orgcolors, add percent neutral to the RGB and allocate fNewColors.
Definition TGX11.cxx:3239
void SetLineColor(Color_t cindex) override
Set color index for lines.
Definition TGX11.cxx:2485
void GetGeometry(Int_t wid, Int_t &x, Int_t &y, UInt_t &w, UInt_t &h) override
Return position and size of window wid.
Definition TGX11.cxx:1134
Colormap fColormap
Default colormap, 0 if b/w.
Definition TGX11.h:109
std::unordered_map< Int_t, std::unique_ptr< XWindow_t > > fWindows
Definition TGX11.h:67
Window_t GetWindowID(Int_t wid) override
Return the X11 window identifier.
Definition TGX11.cxx:1241
Int_t WriteGIF(char *name) override
Writes the current window into GIF file.
Definition TGX11.cxx:3696
void SetFillColor(Color_t cindex) override
Set color index for fill areas.
Definition TGX11.cxx:2364
void ResizeWindow(Int_t wid) override
Resize the current window if necessary.
Definition TGX11.cxx:2074
void SetTextAlign(Short_t talign=11) override
Set text alignment.
Definition TGX11.cxx:3333
void RescaleWindow(Int_t wid, UInt_t w, UInt_t h) override
Rescale the window wid.
Definition TGX11.cxx:1992
void SetCursor(Int_t win, ECursor cursor) override
Set the cursor.
Definition TGX11.cxx:2243
Int_t fScreenNumber
Screen number.
Definition TGX11.h:112
void Sync(Int_t mode) override
Set synchronisation on or off.
Definition TGX11.cxx:3506
Pixmap_t CreatePixmapFromData(unsigned char *bits, UInt_t width, UInt_t height) override
create pixmap from RGB data.
Definition TGX11.cxx:3947
WinContext_t GetWindowContext(Int_t wid) override
Get window drawing context Should remain valid until window exists.
Definition TGX11.cxx:3998
unsigned char * GetColorBits(Drawable_t wid, Int_t x=0, Int_t y=0, UInt_t w=0, UInt_t h=0) override
Returns an array of pixels created from a part of drawable (defined by x, y, w, h) in format: b1,...
Definition TGX11.cxx:3934
void CollectImageColors(ULong_t pixel, ULong_t *&orgcolors, Int_t &ncolors, Int_t &maxcolors)
Collect in orgcolors all different original image colors.
Definition TGX11.cxx:3214
ULong_t fWhitePixel
Value of white pixel in colormap.
Definition TGX11.h:111
Cursor fCursors[kNumCursors]
List of cursors.
Definition TGX11.h:69
Bool_t AllocColor(Colormap cmap, RXColor *color)
Allocate color in colormap.
Definition TGX11.cxx:378
Int_t fTextAlignV
Text Alignment Vertical.
Definition TGX11.h:114
void DrawText(Int_t x, Int_t y, Float_t angle, Float_t mgn, const char *text, ETextMode mode) override
Draw a text string using current font.
Definition TGX11.cxx:844
void QueryColors(Colormap cmap, RXColor *colors, Int_t ncolors)
Returns the current RGB value for the pixel in the XColor structure.
Definition TGX11.cxx:395
Int_t fBlueShift
Bits to left shift blue.
Definition TGX11.h:125
void SetMarkerColor(Color_t cindex) override
Set color index for markers.
Definition TGX11.cxx:2634
void DrawFillAreaW(WinContext_t wctxt, Int_t n, TPoint *xy) override
Fill area described by polygon on specified window.
Definition TGX11.cxx:612
void SetAttText(WinContext_t wctxt, const TAttText &att) override
Set text attributes for specified window.
Definition TGX11.cxx:4605
void Warp(Int_t ix, Int_t iy, Window_t id=0) override
Set pointer position.
Definition TGX11.cxx:3570
void * GetGC(Int_t which) const
Return desired Graphics Context ("which" maps directly on gGCList[]).
Definition TGX11.cxx:1061
void SetClipOFF(Int_t wid) override
Turn off the clipping for the window wid.
Definition TGX11.cxx:2168
Int_t ResizePixmap(Int_t wid, UInt_t w, UInt_t h) override
Resize a pixmap.
Definition TGX11.cxx:2028
void SetDoubleBufferOFF() override
Turn double buffer mode off.
Definition TGX11.cxx:2292
void DrawTextW(WinContext_t wctxt, Int_t x, Int_t y, Float_t angle, Float_t mgn, const char *text, ETextMode mode) override
Draw a text string using current font on specified window.
Definition TGX11.cxx:878
void SetTextColor(Color_t cindex) override
Set color index for text.
Definition TGX11.cxx:3399
void UpdateWindow(Int_t mode) override
Update display.
Definition TGX11.cxx:3529
Bool_t fHasXft
True when XftFonts are used.
Definition TGX11.h:127
Int_t SupportsExtension(const char *ext) const override
Returns 1 if window system server supports extension given by the argument, returns 0 in case extensi...
Definition TGX11.cxx:3989
Int_t InitWindow(ULong_t window) override
Open window and return window number.
Definition TGX11.cxx:1511
Style_t GetLineStyle() const override
Return current line style FIXME: Only as temporary solution while some code analyze current line styl...
Definition TGX11.cxx:2586
~TGX11() override
Destructor.
Definition TGX11.cxx:330
void MoveWindow(Int_t wid, Int_t x, Int_t y) override
Move the window wid.
Definition TGX11.cxx:1253
Int_t SetTextFont(char *fontname, ETextSetMode mode) override
Set text font to specified name.
Definition TGX11.cxx:3435
void SetFillStyle(Style_t style) override
Set fill area style.
Definition TGX11.cxx:2392
Float_t fTextMagnitude
Text Magnitude.
Definition TGX11.h:118
void SetCharacterUp(Float_t chupx, Float_t chupy) override
Set character up vector.
Definition TGX11.cxx:2147
Drawable fRootWin
Root window used as parent of all windows.
Definition TGX11.h:107
void WritePixmap(Int_t wid, UInt_t w, UInt_t h, char *pxname) override
Write the pixmap wid in the bitmap file pxname.
Definition TGX11.cxx:3587
void DrawPolyLineW(WinContext_t wctxt, Int_t n, TPoint *xy) override
Draw a line through all points on specified window.
Definition TGX11.cxx:672
void SetInput(Int_t inp)
Set input on or off.
Definition TGX11.cxx:2466
void GetPlanes(Int_t &nplanes) override
Get maximum number of planes.
Definition TGX11.cxx:1192
Int_t fTextAlignH
Text Alignment Horizontal.
Definition TGX11.h:113
void ClearWindow() override
Clear current window.
Definition TGX11.cxx:420
void * fXEvent
Current native (X11) event.
Definition TGX11.h:70
Int_t fGreenShift
Bits to left shift green.
Definition TGX11.h:124
void DrawBox(Int_t x1, Int_t y1, Int_t x2, Int_t y2, EBoxMode mode) override
Draw a box.
Definition TGX11.cxx:524
void CopyPixmap(Int_t wid, Int_t xpos, Int_t ypos) override
Copy the pixmap wid at the position xpos, ypos in the current window.
Definition TGX11.cxx:509
void SetOpacity(Int_t percent) override
Set opacity of a window.
Definition TGX11.cxx:3149
Style_t GetFillStyle() const override
Return current fill style FIXME: Only as temporary solution while some code analyze current fill styl...
Definition TGX11.cxx:2413
void DrawPolyMarkerW(WinContext_t wctxt, Int_t n, TPoint *xy) override
Draw n markers with the current attributes at position x, y on specified window.
Definition TGX11.cxx:774
Int_t OpenPixmap(UInt_t w, UInt_t h) override
Open a new pixmap.
Definition TGX11.cxx:1467
XColor_t & GetColor(Int_t cid)
Return reference to internal color structure associated to color index cid.
Definition TGX11.cxx:1039
void * GetGCW(WinContext_t wctxt, Int_t which) const
Return X11 Graphics Context for specified window context.
Definition TGX11.cxx:1088
void SetAttMarker(WinContext_t wctxt, const TAttMarker &att) override
Set marker attributes for specified window.
Definition TGX11.cxx:4113
Int_t fBlueDiv
Blue value divider.
Definition TGX11.h:122
void DrawPolyMarker(Int_t n, TPoint *xy) override
Draw n markers with the current attributes at position x, y.
Definition TGX11.cxx:763
void UpdateWindowW(WinContext_t wctxt, Int_t mode) override
Update display for specified window.
Definition TGX11.cxx:3543
void CloseWindow() override
Delete current window.
Definition TGX11.cxx:457
void SetMarkerSize(Float_t markersize) override
Set marker size index.
Definition TGX11.cxx:2651
void SetAttLine(WinContext_t wctxt, const TAttLine &att) override
Set line attributes for specified window.
Definition TGX11.cxx:4052
Drawable fVisRootWin
Root window with fVisual to be used to create GC's and XImages.
Definition TGX11.h:108
void SetDoubleBufferON() override
Turn double buffer mode on.
Definition TGX11.cxx:2302
TExMap * fColors
Hash list of colors.
Definition TGX11.h:68
void DrawLinesSegments(Int_t n, TPoint *xy) override
Draws N segments between provided points.
Definition TGX11.cxx:722
void SetAttFill(WinContext_t wctxt, const TAttFill &att) override
Set fill attributes for specified window.
Definition TGX11.cxx:4003
void SetDrawModeW(WinContext_t wctxt, EDrawMode mode) override
Set window draw mode.
Definition TGX11.cxx:4683
Int_t fTextAlign
Text alignment (set in SetTextAlign) !!! conflict with TAttText.
Definition TGX11.h:115
void SetMarkerType(Int_t type, Int_t n, RXPoint *xy)
Set marker type.
Definition TGX11.cxx:2676
Int_t fRedDiv
Red value divider, -1 if no TrueColor visual.
Definition TGX11.h:120
Int_t fDepth
Number of color planes.
Definition TGX11.h:119
Bool_t Init(void *display) override
Initialize X11 system. Returns kFALSE in case of failure.
Definition TGX11.cxx:353
void SetLineType(Int_t n, Int_t *dash) override
Set line type.
Definition TGX11.cxx:2511
Window_t GetWindow(WinContext_t wctxt) const
Return X11 window for specified window context.
Definition TGX11.cxx:1078
ULong_t fBlackPixel
Value of black pixel in colormap.
Definition TGX11.h:110
void SetTextSize(Float_t textsize) override
Set current text size.
Definition TGX11.cxx:3489
Float_t fCharacterUpX
Character Up vector along X.
Definition TGX11.h:116
void DrawCellArray(Int_t x1, Int_t y1, Int_t x2, Int_t y2, Int_t nx, Int_t ny, Int_t *ic) override
Draw a cell array.
Definition TGX11.cxx:571
void SetLineStyle(Style_t linestyle) override
Set line style.
Definition TGX11.cxx:2539
Int_t fGreenDiv
Green value divider.
Definition TGX11.h:121
EDrawMode GetDrawModeW(WinContext_t wctxt) override
Returns window draw mode.
Definition TGX11.cxx:4703
void QueryPointer(Int_t &ix, Int_t &iy) override
Query pointer position.
Definition TGX11.cxx:1612
ULong_t GetPixel(Color_t cindex) override
Return pixel value associated to specified ROOT color number.
Definition TGX11.cxx:1177
TGX11()
Default constructor.
Definition TGX11.cxx:219
void GetTextExtent(UInt_t &w, UInt_t &h, char *mess) override
Return the size of a character string.
Definition TGX11.cxx:1221
void ClosePixmap() override
Delete current pixmap.
Definition TGX11.cxx:449
Int_t fRedShift
Bits to left shift red, -1 if no TrueColor visual.
Definition TGX11.h:123
Int_t RequestLocator(Int_t mode, Int_t ctyp, Int_t &x, Int_t &y) override
Request Locator position.
Definition TGX11.cxx:1656
Int_t OpenDisplay(void *display)
Open the display. Return -1 if the opening fails, 0 when ok.
Definition TGX11.cxx:1264
void DrawPolyLine(Int_t n, TPoint *xy) override
Draw a line through all points.
Definition TGX11.cxx:661
void SetClipRegion(Int_t wid, Int_t x, Int_t y, UInt_t w, UInt_t h) override
Set clipping region for the window wid.
Definition TGX11.cxx:2186
Int_t AddPixmap(ULong_t pixid, UInt_t w, UInt_t h) override
Register pixmap created by gVirtualGL.
Definition TGX11.cxx:3961
void SetRGB(Int_t cindex, Float_t r, Float_t g, Float_t b) override
Set color intensities for given color index.
Definition TGX11.cxx:3300
void FindUsableVisual(RXVisualInfo *vlist, Int_t nitems)
Check if visual is usable, if so set fVisual, fDepth, fColormap, fBlackPixel and fWhitePixel.
Definition TGX11.cxx:978
void DrawLineW(WinContext_t wctxt, Int_t x1, Int_t y1, Int_t x2, Int_t y2) override
Draw a line on specified window.
Definition TGX11.cxx:643
void GetCharacterUp(Float_t &chupx, Float_t &chupy) override
Return character up vector.
Definition TGX11.cxx:1029
void SetDoubleBuffer(Int_t wid, Int_t mode) override
Set the double buffer on/off on window wid.
Definition TGX11.cxx:2258
void DrawLinesSegmentsW(WinContext_t wctxt, Int_t n, TPoint *xy) override
Draws N segments between provided points on specified windows.
Definition TGX11.cxx:733
void SetMarkerStyle(Style_t markerstyle) override
Set marker style.
Definition TGX11.cxx:2693
void GetRGB(Int_t index, Float_t &r, Float_t &g, Float_t &b) override
Get rgb values for color "index".
Definition TGX11.cxx:1200
void ImgPickPalette(RXImage *image, Int_t &ncol, Int_t *&R, Int_t *&G, Int_t *&B)
Returns in R G B the ncol colors of the palette used by the image.
Definition TGX11.cxx:3640
void ClearWindowW(WinContext_t wctxt) override
Clear specified window.
Definition TGX11.cxx:428
Int_t FindColor(ULong_t pixel, ULong_t *orgcolors, Int_t ncolors)
Returns index in orgcolors (and fNewColors) for pixel.
Definition TGX11.cxx:3284
void SetFillStyleIndex(Int_t style, Int_t fasi)
Set fill area style index.
Definition TGX11.cxx:2421
RVisual * fVisual
Pointer to visual used by all windows.
Definition TGX11.h:106
Width_t GetLineWidth() const override
Return current line width FIXME: Only as temporary solution while some code analyze current line wide...
Definition TGX11.cxx:2626
void DrawLine(Int_t x1, Int_t y1, Int_t x2, Int_t y2) override
Draw a line.
Definition TGX11.cxx:632
Window_t GetCurrentWindow() const override
Return current window pointer.
Definition TGX11.cxx:1052
void RemoveWindow(ULong_t qwid) override
Remove a window created by Qt (like CloseWindow()).
Definition TGX11.cxx:1598
Int_t RequestString(Int_t x, Int_t y, char *text) override
Request a string.
Definition TGX11.cxx:1834
void SetLineWidth(Width_t width) override
Set line width.
Definition TGX11.cxx:2596
void PutImage(Int_t offset, Int_t itran, Int_t x0, Int_t y0, Int_t nx, Int_t ny, Int_t xmin, Int_t ymin, Int_t xmax, Int_t ymax, UChar_t *image, Drawable_t id)
Draw image.
Definition TGX11.cxx:3760
Int_t GetDoubleBuffer(Int_t wid) override
Query the double buffer value for the window wid.
Definition TGX11.cxx:1116
void FindBestVisual()
Find best visual, i.e.
Definition TGX11.cxx:910
void SetDrawMode(EDrawMode mode) override
Set the drawing mode.
Definition TGX11.cxx:2331
void SetColor(void *gc, Int_t ci)
Set the foreground color in GC.
Definition TGX11.cxx:2210
const char * DisplayName(const char *dpyName=nullptr) override
Return hostname on which the display is opened.
Definition TGX11.cxx:1169
Pixmap_t ReadGIF(Int_t x0, Int_t y0, const char *file, Window_t id=0) override
If id is NULL - loads the specified gif file at position [x0,y0] in the current window.
Definition TGX11.cxx:3831
Int_t AddWindow(ULong_t qwid, UInt_t w, UInt_t h) override
Register a window created by Qt as a ROOT window (like InitWindow()).
Definition TGX11.cxx:1572
Int_t AddWindowHandle()
Add new window handle Only for private usage.
Definition TGX11.cxx:1413
Float_t fCharacterUpY
Character Up vector along Y.
Definition TGX11.h:117
Bool_t fHasTTFonts
True when TrueType fonts are used.
Definition TGX11.h:126
void SelectWindow(Int_t wid) override
Select window to which subsequent output is directed.
Definition TGX11.cxx:2116
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:1081
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1095
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
Definition TObject.cxx:1123
static void * ReAlloc(void *vp, size_t size, size_t oldsize)
Reallocate (i.e.
Definition TStorage.cxx:182
Basic string class.
Definition TString.h:138
const char * GetLineStyleString(Int_t i=1) const
Return line style string (used by PostScript).
Definition TStyle.cxx:1167
Semi-Abstract base class defining a generic interface to the underlying, low level,...
Definition TVirtualX.h:46
EDrawMode fDrawMode
Definition TVirtualX.h:55
TPaveText * pt
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
#define G(x, y, z)
Double_t ACos(Double_t)
Returns the principal value of the arc cosine of x, expressed in radians.
Definition TMath.h:643
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Definition TMathBase.h:249
Double_t Floor(Double_t x)
Rounds x downward, returning the largest integral value that is not greater than x.
Definition TMath.h:691
Double_t Sqrt(Double_t x)
Returns the square root of x.
Definition TMath.h:673
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Definition TMathBase.h:197
constexpr Double_t Pi()
Definition TMath.h:40
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Definition TMathBase.h:122
Description of a X11 color.
Definition TGWin32.h:56
Bool_t fDefined
true if pixel value is defined
Definition TGWin32.h:58
UShort_t fBlue
blue value
Definition TGX11.h:54
UShort_t fRed
red value in range [0,kBIGGEST_RGB_VALUE]
Definition TGX11.h:52
UShort_t fGreen
green value
Definition TGX11.h:53
ULong_t fPixel
color pixel value
Definition TGX11.h:51
Description of a X11 window.
Definition TGWin32.cxx:121
Int_t fOpen
1 if the window is open, 0 if not
Definition TGX11.cxx:101
TAttText fAttText
current text attribute
Definition TGX11.cxx:134
Int_t fClip
1 if the clipping is on
Definition TGX11.cxx:109
Drawable fWindow
X11 window.
Definition TGX11.cxx:105
ULong_t * fNewColors
new image colors (after processing)
Definition TGX11.cxx:114
Int_t fNcolors
number of different colors
Definition TGX11.cxx:115
Int_t textAlign
selected text align
Definition TGX11.cxx:135
Int_t lineWidth
X11 line width.
Definition TGX11.cxx:120
Int_t dashOffset
current dash offset
Definition TGX11.cxx:124
Int_t fillFasi
selected fasi pattern
Definition TGX11.cxx:127
Drawable fDrawing
drawing area, equal to window or buffer
Definition TGX11.cxx:104
Int_t markerLineWidth
line width used for marker
Definition TGX11.cxx:133
Int_t fDoubleBuffer
1 if the double buffer is on, 0 if not
Definition TGX11.cxx:102
std::vector< char > dashList
X11 array for dashes.
Definition TGX11.cxx:122
XFontStruct * textFont
selected text font
Definition TGX11.cxx:136
UInt_t fHeight
height of the window
Definition TGX11.cxx:108
Int_t fIsPixmap
1 if pixmap, 0 if not
Definition TGX11.cxx:103
Int_t fillHollow
X11 fill method.
Definition TGX11.cxx:126
std::vector< XPoint > markerShape
marker shape points
Definition TGX11.cxx:132
UInt_t fWidth
width of the window
Definition TGX11.cxx:107
UInt_t fHclip
height of the clipping rectangle
Definition TGX11.cxx:113
Int_t dashLength
total length of dashes
Definition TGX11.cxx:123
Bool_t fShared
notify when window is shared
Definition TGX11.cxx:116
TVirtualX::EDrawMode fDrawMode
current draw mode
Definition TGX11.cxx:118
Drawable fBuffer
pixmap used for double buffer
Definition TGX11.cxx:106
Int_t markerSize
size of simple markers
Definition TGX11.cxx:131
Pixmap fillPattern
current initialized fill pattern
Definition TGX11.cxx:128
TAttLine fAttLine
current line attributes
Definition TGX11.cxx:119
Int_t markerType
4 differen kinds of marker
Definition TGX11.cxx:130
TAttMarker fAttMarker
current marker attribute
Definition TGX11.cxx:129
GC fGClist[kMAXGC]
list of GC object, individual for each window
Definition TGX11.cxx:117
Int_t fXclip
x coordinate of the clipping rectangle
Definition TGX11.cxx:110
TAttFill fAttFill
current fill attributes
Definition TGX11.cxx:125
UInt_t fWclip
width of the clipping rectangle
Definition TGX11.cxx:112
Int_t lineStyle
X11 line style.
Definition TGX11.cxx:121
Int_t fYclip
y coordinate of the clipping rectangle
Definition TGX11.cxx:111
TMarker m
Definition textangle.C:8
int GIFdecode(byte *GIFarr, byte *PIXarr, int *Width, int *Height, int *Ncols, byte *R, byte *G, byte *B)
Definition gifdecode.c:149
int GIFinfo(byte *GIFarr, int *Width, int *Height, int *Ncols)
Definition gifdecode.c:80
long GIFencode(int Width, int Height, int Ncol, R, G, B, ScLine, void *get_scline, pb)
Definition gifencode.c:63