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//---- globals
80
81static XWindow_t *gCws; // gCws: pointer to the current window
82static XWindow_t *gTws; // gTws: temporary pointer
83
85
86//
87// Primitives Graphic Contexts global for all windows
88//
89const int kMAXGC = 7;
90static GC gGClist[kMAXGC];
91static GC *gGCline = &gGClist[0]; // PolyLines
92static GC *gGCmark = &gGClist[1]; // PolyMarker
93static GC *gGCfill = &gGClist[2]; // Fill areas
94static GC *gGCtext = &gGClist[3]; // Text
95static GC *gGCinvt = &gGClist[4]; // Inverse text
96static GC *gGCdash = &gGClist[5]; // Dashed lines
97static GC *gGCpxmp = &gGClist[6]; // Pixmap management
98
99static GC gGCecho; // Input echo
100
101static Int_t gFillHollow; // Flag if fill style is hollow
102static Pixmap gFillPattern = 0; // Fill pattern
103
104//
105// Text management
106//
107const Int_t kMAXFONT = 4;
108static struct {
110 char name[80]; // Font name
111} gFont[kMAXFONT]; // List of fonts loaded
112
113static XFontStruct *gTextFont; // Current font
114static Int_t gCurrentFontNumber = 0; // Current font number in gFont[]
115
116//
117// Markers
118//
119const Int_t kMAXMK = 100;
120static struct {
121 int type;
122 int n;
123 XPoint xy[kMAXMK];
124} gMarker; // Point list to draw marker
125static int gMarkerLineWidth = 0;
129
130//
131// Keep style values for line GC
132//
133static int gLineWidth = 0;
135static int gCapStyle = CapButt;
137static char gDashList[10];
138static int gDashLength = 0;
139static int gDashOffset = 0;
140static int gDashSize = 0;
141
142//
143// Event masks
144//
151
152//
153// Data to create an invisible cursor
154//
155const char null_cursor_bits[] = {
1560x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1570x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1580x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
160
161struct RXGCValues:XGCValues{};
162struct RXColor:XColor{};
164struct RXPoint:XPoint{};
166struct RVisual:Visual{};
167
168
169////////////////////////////////////////////////////////////////////////////////
170/// Default constructor.
171
173{
174 int i;
175 fDisplay = nullptr;
176 fScreenNumber = 0;
177 fVisual = nullptr;
178 fRootWin = 0;
179 fVisRootWin = 0;
180 fColormap = 0;
181 fBlackPixel = 0;
182 fWhitePixel = 0;
183 fWindows = nullptr;
184 fColors = nullptr;
185 fXEvent = new XEvent;
186 fRedDiv = -1;
187 fGreenDiv = -1;
188 fBlueDiv = -1;
189 fRedShift = -1;
190 fGreenShift = -1;
191 fBlueShift = -1;
192 fCharacterUpX = 1;
193 fCharacterUpY = 1;
194 fDepth = 0;
196 fHasXft = kFALSE;
198 fTextAlignH = 1;
199 fTextAlignV = 1;
200 fTextAlign = 7;
201 fTextMagnitude = 1;
202 for (i = 0; i < kNumCursors; i++) fCursors[i] = 0;
203}
204
205////////////////////////////////////////////////////////////////////////////////
206/// Normal Constructor.
207
208TGX11::TGX11(const char *name, const char *title) : TVirtualX(name, title)
209{
210 int i;
211 fDisplay = nullptr;
212 fScreenNumber = 0;
213 fVisual = nullptr;
214 fRootWin = 0;
215 fVisRootWin = 0;
216 fColormap = 0;
217 fBlackPixel = 0;
218 fWhitePixel = 0;
220 fXEvent = new XEvent;
221 fRedDiv = -1;
222 fGreenDiv = -1;
223 fBlueDiv = -1;
224 fRedShift = -1;
225 fGreenShift = -1;
226 fBlueShift = -1;
227 fCharacterUpX = 1;
228 fCharacterUpY = 1;
229 fDepth = 0;
231 fHasXft = kFALSE;
233 fTextAlignH = 1;
234 fTextAlignV = 1;
235 fTextAlign = 7;
236 fTextMagnitude = 1;
237 for (i = 0; i < kNumCursors; i++) fCursors[i] = 0;
238
239 //fWindows = new XWindow_t[fMaxNumberOfWindows];
241 for (i = 0; i < fMaxNumberOfWindows; i++)
242 fWindows[i].fOpen = 0;
243
244 fColors = new TExMap;
245}
246
247////////////////////////////////////////////////////////////////////////////////
248/// Copy constructor. Currently only used by TGX11TTF.
249
251{
252 int i;
253
254 fDisplay = org.fDisplay;
255 fScreenNumber = org.fScreenNumber;
256 fVisual = org.fVisual;
257 fRootWin = org.fRootWin;
258 fVisRootWin = org.fVisRootWin;
259 fColormap = org.fColormap;
260 fBlackPixel = org.fBlackPixel;
261 fWhitePixel = org.fWhitePixel;
262 fHasTTFonts = org.fHasTTFonts;
263 fHasXft = org.fHasXft;
264 fTextAlignH = org.fTextAlignH;
265 fTextAlignV = org.fTextAlignV;
266 fTextAlign = org.fTextAlign;
267 fTextMagnitude = org.fTextMagnitude;
268 fCharacterUpX = org.fCharacterUpX;
269 fCharacterUpY = org.fCharacterUpY;
270 fDepth = org.fDepth;
271 fRedDiv = org.fRedDiv;
272 fGreenDiv = org.fGreenDiv;
273 fBlueDiv = org.fBlueDiv;
274 fRedShift = org.fRedShift;
275 fGreenShift = org.fGreenShift;
276 fBlueShift = org.fBlueShift;
277 fDrawMode = org.fDrawMode;
278 fXEvent = new XEvent;
279
280 fMaxNumberOfWindows = org.fMaxNumberOfWindows;
281 //fWindows = new XWindow_t[fMaxNumberOfWindows];
283 for (i = 0; i < fMaxNumberOfWindows; i++) {
284 fWindows[i].fOpen = org.fWindows[i].fOpen;
285 fWindows[i].fDoubleBuffer = org.fWindows[i].fDoubleBuffer;
286 fWindows[i].fIsPixmap = org.fWindows[i].fIsPixmap;
287 fWindows[i].fDrawing = org.fWindows[i].fDrawing;
288 fWindows[i].fWindow = org.fWindows[i].fWindow;
289 fWindows[i].fBuffer = org.fWindows[i].fBuffer;
290 fWindows[i].fWidth = org.fWindows[i].fWidth;
291 fWindows[i].fHeight = org.fWindows[i].fHeight;
292 fWindows[i].fClip = org.fWindows[i].fClip;
293 fWindows[i].fXclip = org.fWindows[i].fXclip;
294 fWindows[i].fYclip = org.fWindows[i].fYclip;
295 fWindows[i].fWclip = org.fWindows[i].fWclip;
296 fWindows[i].fHclip = org.fWindows[i].fHclip;
297 fWindows[i].fNewColors = org.fWindows[i].fNewColors;
298 fWindows[i].fNcolors = org.fWindows[i].fNcolors;
299 fWindows[i].fShared = org.fWindows[i].fShared;
300 }
301
302 for (i = 0; i < kNumCursors; i++)
303 fCursors[i] = org.fCursors[i];
304
305 fColors = new TExMap;
306 Long64_t key, value;
307 TExMapIter it(org.fColors);
308 while (it.Next(key, value)) {
310 XColor_t *col = new XColor_t;
311 col->fPixel = colo->fPixel;
312 col->fRed = colo->fRed;
313 col->fGreen = colo->fGreen;
314 col->fBlue = colo->fBlue;
315 col->fDefined = colo->fDefined;
316 fColors->Add(key, (Long_t) col);
317 }
318}
319
320////////////////////////////////////////////////////////////////////////////////
321/// Destructor.
322
324{
325 delete (XEvent*)fXEvent;
327
328 if (!fColors) return;
329 Long64_t key, value;
331 while (it.Next(key, value)) {
332 XColor_t *col = (XColor_t *) (Long_t)value;
333 delete col;
334 }
335 delete fColors;
336}
337
338////////////////////////////////////////////////////////////////////////////////
339/// Initialize X11 system. Returns kFALSE in case of failure.
340
341Bool_t TGX11::Init(void *display)
342{
343 if (OpenDisplay(display) == -1) return kFALSE;
344 return kTRUE;
345}
346
347////////////////////////////////////////////////////////////////////////////////
348/// Allocate color in colormap. If we are on an <= 8 plane machine
349/// we will use XAllocColor. If we are on a >= 15 (15, 16 or 24) plane
350/// true color machine we will calculate the pixel value using:
351/// for 15 and 16 bit true colors have 6 bits precision per color however
352/// only the 5 most significant bits are used in the color index.
353/// Except for 16 bits where green uses all 6 bits. I.e.:
354/// ~~~ {.cpp}
355/// 15 bits = rrrrrgggggbbbbb
356/// 16 bits = rrrrrggggggbbbbb
357/// ~~~
358/// for 24 bits each r, g and b are represented by 8 bits.
359///
360/// Since all colors are set with a max of 65535 (16 bits) per r, g, b
361/// we just right shift them by 10, 11 and 10 bits for 16 planes, and
362/// (10, 10, 10 for 15 planes) and by 8 bits for 24 planes.
363/// Returns kFALSE in case color allocation failed.
364
366{
367 if (fRedDiv == -1) {
368 if (XAllocColor((Display*)fDisplay, cmap, color))
369 return kTRUE;
370 } else {
371 color->pixel = (color->red >> fRedDiv) << fRedShift |
372 (color->green >> fGreenDiv) << fGreenShift |
373 (color->blue >> fBlueDiv) << fBlueShift;
374 return kTRUE;
375 }
376 return kFALSE;
377}
378
379////////////////////////////////////////////////////////////////////////////////
380/// Returns the current RGB value for the pixel in the XColor structure.
381
383{
384 if (fRedDiv == -1) {
385 XQueryColors((Display*)fDisplay, cmap, color, ncolors);
386 } else {
387 ULong_t r, g, b;
388 for (Int_t i = 0; i < ncolors; i++) {
389 r = (color[i].pixel & fVisual->red_mask) >> fRedShift;
390 color[i].red = UShort_t(r*kBIGGEST_RGB_VALUE/(fVisual->red_mask >> fRedShift));
391
392 g = (color[i].pixel & fVisual->green_mask) >> fGreenShift;
393 color[i].green = UShort_t(g*kBIGGEST_RGB_VALUE/(fVisual->green_mask >> fGreenShift));
394
395 b = (color[i].pixel & fVisual->blue_mask) >> fBlueShift;
396 color[i].blue = UShort_t(b*kBIGGEST_RGB_VALUE/(fVisual->blue_mask >> fBlueShift));
397
398 color[i].flags = DoRed | DoGreen | DoBlue;
399 }
400 }
401}
402
403////////////////////////////////////////////////////////////////////////////////
404/// Clear the pixmap pix.
405
407{
408 Window root;
409 int xx, yy;
410 unsigned int ww, hh, border, depth;
411 XGetGeometry((Display*)fDisplay, *pix, &root, &xx, &yy, &ww, &hh, &border, &depth);
412 SetColor(gGCpxmp, 0);
413 XFillRectangle((Display*)fDisplay, *pix, *gGCpxmp, 0 ,0 ,ww ,hh);
414 SetColor(gGCpxmp, 1);
415 XFlush((Display*)fDisplay);
416}
417
418////////////////////////////////////////////////////////////////////////////////
419/// Clear current window.
420
422{
423 if (!gCws) return;
424
425 if (!gCws->fIsPixmap && !gCws->fDoubleBuffer) {
426 XSetWindowBackground((Display*)fDisplay, gCws->fDrawing, GetColor(0).fPixel);
427 XClearWindow((Display*)fDisplay, gCws->fDrawing);
428 XFlush((Display*)fDisplay);
429 } else {
430 SetColor(gGCpxmp, 0);
431 XFillRectangle((Display*)fDisplay, gCws->fDrawing, *gGCpxmp,
432 0, 0, gCws->fWidth, gCws->fHeight);
433 SetColor(gGCpxmp, 1);
434 }
435}
436
437////////////////////////////////////////////////////////////////////////////////
438/// Delete current pixmap.
439
441{
442 CloseWindow1();
443}
444
445////////////////////////////////////////////////////////////////////////////////
446/// Delete current window.
447
449{
450 if (gCws->fShared)
451 gCws->fOpen = 0;
452 else
453 CloseWindow1();
454
455 // Never close connection. TApplication takes care of that
456 // if (!gCws) Close(); // close X when no open window left
457}
458
459////////////////////////////////////////////////////////////////////////////////
460/// Delete current window.
461
463{
464 int wid;
465
466 if (gCws->fIsPixmap)
467 XFreePixmap((Display*)fDisplay, gCws->fWindow);
468 else
469 XDestroyWindow((Display*)fDisplay, gCws->fWindow);
470
471 if (gCws->fBuffer) XFreePixmap((Display*)fDisplay, gCws->fBuffer);
472
473 if (gCws->fNewColors) {
474 if (fRedDiv == -1)
475 XFreeColors((Display*)fDisplay, fColormap, gCws->fNewColors, gCws->fNcolors, 0);
476 delete [] gCws->fNewColors;
477 gCws->fNewColors = nullptr;
478 }
479
480 XFlush((Display*)fDisplay);
481
482 gCws->fOpen = 0;
483
484 // make first window in list the current window
485 for (wid = 0; wid < fMaxNumberOfWindows; wid++)
486 if (fWindows[wid].fOpen) {
487 gCws = &fWindows[wid];
488 return;
489 }
490
491 gCws = nullptr;
492}
493
494////////////////////////////////////////////////////////////////////////////////
495/// Copy the pixmap wid at the position xpos, ypos in the current window.
496
497void TGX11::CopyPixmap(int wid, int xpos, int ypos)
498{
499 gTws = &fWindows[wid];
500
501 XCopyArea((Display*)fDisplay, gTws->fDrawing, gCws->fDrawing, *gGCpxmp, 0, 0, gTws->fWidth,
502 gTws->fHeight, xpos, ypos);
503 XFlush((Display*)fDisplay);
504}
505
506////////////////////////////////////////////////////////////////////////////////
507/// Copy area of current window in the pixmap pix.
508
510{
511 Window root;
512 int xx, yy;
513 unsigned int ww, hh, border, depth;
514
515 XGetGeometry((Display*)fDisplay, *pix, &root, &xx, &yy, &ww, &hh, &border, &depth);
516 XCopyArea((Display*)fDisplay, gCws->fDrawing, *pix, *gGCpxmp, xpos, ypos, ww, hh, 0, 0);
517 XFlush((Display*)fDisplay);
518}
519
520////////////////////////////////////////////////////////////////////////////////
521/// Draw a box.
522///
523/// - mode=0 hollow (kHollow)
524/// - mode=1 solid (kSolid)
525
526void TGX11::DrawBox(int x1, int y1, int x2, int y2, EBoxMode mode)
527{
528 Int_t x = TMath::Min(x1, x2);
529 Int_t y = TMath::Min(y1, y2);
530 Int_t w = TMath::Abs(x2 - x1);
531 Int_t h = TMath::Abs(y2 - y1);
532
533 switch (mode) {
534
535 case kHollow:
536 XDrawRectangle((Display*)fDisplay, gCws->fDrawing, *gGCline, x, y, w, h);
537 break;
538
539 case kFilled:
540 XFillRectangle((Display*)fDisplay, gCws->fDrawing, *gGCfill, x, y, w, h);
541 break;
542
543 default:
544 break;
545 }
546}
547
548////////////////////////////////////////////////////////////////////////////////
549/// Draw a cell array.
550//
551/// \param [in] x1,y1 : left down corner
552/// \param [in] x2,y2 : right up corner
553/// \param [in] nx,ny : array size
554/// \param [in] ic : array
555///
556/// Draw a cell array. The drawing is done with the pixel precision
557/// if (X2-X1)/NX (or Y) is not a exact pixel number the position of
558/// the top right corner may be wrong.
559
560void TGX11::DrawCellArray(int x1, int y1, int x2, int y2, int nx, int ny, int *ic)
561{
562 int i, j, icol, ix, iy, w, h, current_icol;
563
564 current_icol = -1;
565 w = TMath::Max((x2-x1)/(nx),1);
566 h = TMath::Max((y1-y2)/(ny),1);
567 ix = x1;
568
569 for (i = 0; i < nx; i++) {
570 iy = y1-h;
571 for (j = 0; j < ny; j++) {
572 icol = ic[i+(nx*j)];
573 if (icol != current_icol) {
574 XSetForeground((Display*)fDisplay, *gGCfill, GetColor(icol).fPixel);
576 }
577 XFillRectangle((Display*)fDisplay, gCws->fDrawing, *gGCfill, ix, iy, w, h);
578 iy = iy-h;
579 }
580 ix = ix+w;
581 }
582}
583
584////////////////////////////////////////////////////////////////////////////////
585/// Fill area described by polygon.
586///
587/// \param [in] n number of points
588/// \param [in] xy list of points
589
591{
592 XPoint *xyp = (XPoint*)xy;
593
594 if (gFillHollow)
595 XDrawLines((Display*)fDisplay, gCws->fDrawing, *gGCfill, xyp, n, CoordModeOrigin);
596
597 else {
598 XFillPolygon((Display*)fDisplay, gCws->fDrawing, *gGCfill,
600 }
601}
602
603////////////////////////////////////////////////////////////////////////////////
604/// Draw a line.
605///
606/// \param [in] x1,y1 : begin of line
607/// \param [in] x2,y2 : end of line
608
610{
611 if (gLineStyle == LineSolid)
612 XDrawLine((Display*)fDisplay, gCws->fDrawing, *gGCline, x1, y1, x2, y2);
613 else {
615 XDrawLine((Display*)fDisplay, gCws->fDrawing, *gGCdash, x1, y1, x2, y2);
616 }
617}
618
619////////////////////////////////////////////////////////////////////////////////
620/// Draw a line through all points.
621///
622/// \param [in] n number of points
623/// \param [in] xy list of points
624
626{
627 XPoint *xyp = (XPoint*)xy;
628
629 const Int_t kMaxPoints = 1000001;
630
631 if (n > kMaxPoints) {
632 int ibeg = 0;
633 int iend = kMaxPoints - 1;
634 while (iend < n) {
636 ibeg = iend;
637 iend += kMaxPoints - 1;
638 }
639 if (ibeg < n) {
640 int npt = n - ibeg;
641 DrawPolyLine( npt, &xy[ibeg] );
642 }
643 } else if (n > 1) {
644 if (gLineStyle == LineSolid)
645 XDrawLines((Display*)fDisplay, gCws->fDrawing, *gGCline, xyp, n, CoordModeOrigin);
646 else {
647 int i;
648 XSetDashes((Display*)fDisplay, *gGCdash,
650 XDrawLines((Display*)fDisplay, gCws->fDrawing, *gGCdash, xyp, n, CoordModeOrigin);
651
652 // calculate length of line to update dash offset
653 for (i = 1; i < n; i++) {
654 int dx = xyp[i].x - xyp[i-1].x;
655 int dy = xyp[i].y - xyp[i-1].y;
656 if (dx < 0) dx = - dx;
657 if (dy < 0) dy = - dy;
658 gDashOffset += dx > dy ? dx : dy;
659 }
661 }
662 } else {
663 int px,py;
664 px=xyp[0].x;
665 py=xyp[0].y;
666 XDrawPoint((Display*)fDisplay, gCws->fDrawing,
667 gLineStyle == LineSolid ? *gGCline : *gGCdash, px, py);
668 }
669}
670
671////////////////////////////////////////////////////////////////////////////////
672/// Draw n markers with the current attributes at position x, y.
673///
674/// \param [in] n number of markers to draw
675/// \param [in] xy x,y coordinates of markers
676
678{
679 XPoint *xyp = (XPoint*)xy;
680
681 if (gMarker.n <= 0) {
682 const int kNMAX = 1000000;
683 int nt = n/kNMAX;
684 for (int it=0;it<=nt;it++) {
685 if (it < nt) {
686 XDrawPoints((Display*)fDisplay, gCws->fDrawing, *gGCmark, &xyp[it*kNMAX], kNMAX, CoordModeOrigin);
687 } else {
688 XDrawPoints((Display*)fDisplay, gCws->fDrawing, *gGCmark, &xyp[it*kNMAX], n-it*kNMAX, CoordModeOrigin);
689 }
690 }
691 } else {
692 int r = gMarker.n / 2;
693 int m;
694
695 for (m = 0; m < n; m++) {
696 int hollow = 0;
697
698 switch (gMarker.type) {
699 int i;
700
701 case 0: // hollow circle
702 XDrawArc((Display*)fDisplay, gCws->fDrawing, *gGCmark,
703 xyp[m].x - r, xyp[m].y - r, gMarker.n, gMarker.n, 0, 360*64);
704 break;
705
706 case 1: // filled circle
707 XFillArc((Display*)fDisplay, gCws->fDrawing, *gGCmark,
708 xyp[m].x - r, xyp[m].y - r, gMarker.n, gMarker.n, 0, 360*64);
709 break;
710
711 case 2: // hollow polygon
712 hollow = 1;
713 case 3: // filled polygon
714 for (i = 0; i < gMarker.n; i++) {
715 gMarker.xy[i].x += xyp[m].x;
716 gMarker.xy[i].y += xyp[m].y;
717 }
718 if (hollow)
719 XDrawLines((Display*)fDisplay, gCws->fDrawing, *gGCmark,
721 else
722 XFillPolygon((Display*)fDisplay, gCws->fDrawing, *gGCmark,
724 for (i = 0; i < gMarker.n; i++) {
725 gMarker.xy[i].x -= xyp[m].x;
726 gMarker.xy[i].y -= xyp[m].y;
727 }
728 break;
729
730 case 4: // segmented line
731 for (i = 0; i < gMarker.n; i += 2)
732 XDrawLine((Display*)fDisplay, gCws->fDrawing, *gGCmark,
733 xyp[m].x + gMarker.xy[i].x, xyp[m].y + gMarker.xy[i].y,
734 xyp[m].x + gMarker.xy[i+1].x, xyp[m].y + gMarker.xy[i+1].y);
735 break;
736 }
737 }
738 }
739}
740
741////////////////////////////////////////////////////////////////////////////////
742/// Draw a text string using current font.
743///
744/// \param [in] mode : drawing mode
745/// - mode=0 : the background is not drawn (kClear)
746/// - mode=1 : the background is drawn (kOpaque)
747/// \param [in] x,y : text position
748/// \param [in] angle : text angle
749/// \param [in] mgn : magnification factor
750/// \param [in] text : text string
751
753 const char *text, ETextMode mode)
754{
756
757 if (!text) return;
758
759 switch (mode) {
760
761 case kClear:
763 gCws->fDrawing, *gGCtext, x, y, (char*)text, fTextAlign);
764 break;
765
766 case kOpaque:
768 gCws->fDrawing, *gGCtext, x, y, (char*)text, fTextAlign);
769 break;
770
771 default:
772 break;
773 }
774}
775
776////////////////////////////////////////////////////////////////////////////////
777/// Find best visual, i.e. the one with the most planes and TrueColor or
778/// DirectColor. Sets fVisual, fDepth, fRootWin, fColormap, fBlackPixel
779/// and fWhitePixel.
780
782{
783 Int_t findvis = gEnv->GetValue("X11.FindBestVisual", 1);
784
785 Visual *vis = DefaultVisual((Display*)fDisplay, fScreenNumber);
786 if (((vis->c_class != TrueColor && vis->c_class != DirectColor) ||
787 DefaultDepth((Display*)fDisplay, fScreenNumber) < 15) && findvis) {
788
789 // try to find better visual
790 static XVisualInfo templates[] = {
791 // Visual, visualid, screen, depth, class , red_mask, green_mask, blue_mask, colormap_size, bits_per_rgb
792 { nullptr, 0 , 0 , 24 , TrueColor , 0 , 0 , 0 , 0 , 0 },
793 { nullptr, 0 , 0 , 32 , TrueColor , 0 , 0 , 0 , 0 , 0 },
794 { nullptr, 0 , 0 , 16 , TrueColor , 0 , 0 , 0 , 0 , 0 },
795 { nullptr, 0 , 0 , 15 , TrueColor , 0 , 0 , 0 , 0 , 0 },
796 // no suitable TrueColorMode found - now do the same thing to DirectColor
797 { nullptr, 0 , 0 , 24 , DirectColor, 0 , 0 , 0 , 0 , 0 },
798 { nullptr, 0 , 0 , 32 , DirectColor, 0 , 0 , 0 , 0 , 0 },
799 { nullptr, 0 , 0 , 16 , DirectColor, 0 , 0 , 0 , 0 , 0 },
800 { nullptr, 0 , 0 , 15 , DirectColor, 0 , 0 , 0 , 0 , 0 },
801 { nullptr, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 },
802 };
803
804 Int_t nitems = 0;
805 XVisualInfo *vlist = nullptr;
806 for (Int_t i = 0; templates[i].depth != 0; i++) {
808 templates[i].screen = fScreenNumber;
809 if ((vlist = XGetVisualInfo((Display*)fDisplay, mask, &(templates[i]), &nitems))) {
811 XFree(vlist);
812 vlist = nullptr;
813 if (fVisual)
814 break;
815 }
816 }
817 }
818
820
821 if (!fVisual) {
825 if (fDepth > 1)
829 }
830 if (gDebug > 1)
831 Printf("Selected visual 0x%lx: depth %d, class %d, colormap: %s",
832 fVisual->visualid, fDepth, fVisual->c_class,
833 fColormap == DefaultColormap((Display*)fDisplay, fScreenNumber) ? "default" :
834 "custom");
835}
836
837////////////////////////////////////////////////////////////////////////////////
838/// Dummy error handler for X11. Used by FindUsableVisual().
839
841{
842 return 0;
843}
844
845////////////////////////////////////////////////////////////////////////////////
846/// Check if visual is usable, if so set fVisual, fDepth, fColormap,
847/// fBlackPixel and fWhitePixel.
848
850{
851 Int_t (*oldErrorHandler)(Display *, XErrorEvent *) =
853
855 memset(&attr, 0, sizeof(attr));
856
857 Window root = RootWindow((Display*)fDisplay, fScreenNumber);
858
859 for (Int_t i = 0; i < nitems; i++) {
860 Window w = None, wjunk;
862 Int_t junk;
863
864 // try and use default colormap when possible
865 if (vlist[i].visual == DefaultVisual((Display*)fDisplay, fScreenNumber)) {
866 attr.colormap = DefaultColormap((Display*)fDisplay, fScreenNumber);
867 } else {
868 attr.colormap = XCreateColormap((Display*)fDisplay, root, vlist[i].visual, AllocNone);
869 }
870
871 static XColor black_xcol = { 0, 0x0000, 0x0000, 0x0000, DoRed|DoGreen|DoBlue, 0 };
872 static XColor white_xcol = { 0, 0xFFFF, 0xFFFF, 0xFFFF, DoRed|DoGreen|DoBlue, 0 };
873 XAllocColor((Display*)fDisplay, attr.colormap, &black_xcol);
874 XAllocColor((Display*)fDisplay, attr.colormap, &white_xcol);
875 attr.border_pixel = black_xcol.pixel;
876 attr.override_redirect = True;
877
878 w = XCreateWindow((Display*)fDisplay, root, -20, -20, 10, 10, 0, vlist[i].depth,
881 if (w != None && XGetGeometry((Display*)fDisplay, w, &wjunk, &junk, &junk,
882 &width, &height, &ujunk, &ujunk)) {
884 fDepth = vlist[i].depth;
885 fColormap = attr.colormap;
886 fBlackPixel = black_xcol.pixel;
887 fWhitePixel = white_xcol.pixel;
888 fVisRootWin = w;
889 break;
890 }
891 if (attr.colormap != DefaultColormap((Display*)fDisplay, fScreenNumber))
892 XFreeColormap((Display*)fDisplay, attr.colormap);
893 }
895}
896
897////////////////////////////////////////////////////////////////////////////////
898/// Return character up vector.
899
905
906////////////////////////////////////////////////////////////////////////////////
907/// Return reference to internal color structure associated
908/// to color index cid.
909
911{
913 if (!col) {
914 col = new XColor_t;
915 fColors->Add(cid, (Long_t) col);
916 }
917 return *col;
918}
919
920////////////////////////////////////////////////////////////////////////////////
921/// Return current window pointer. Protected method used by TGX11TTF.
922
924{
925 return (Window_t)(gCws ? gCws->fDrawing : 0);
926}
927
928////////////////////////////////////////////////////////////////////////////////
929/// Return desired Graphics Context ("which" maps directly on gGCList[]).
930/// Protected method used by TGX11TTF.
931
933{
934 if (which >= kMAXGC || which < 0) {
935 Error("GetGC", "trying to get illegal GC (which = %d)", which);
936 return nullptr;
937 }
938 return &gGClist[which];
939}
940
941////////////////////////////////////////////////////////////////////////////////
942/// Query the double buffer value for the window wid.
943
945{
946 gTws = &fWindows[wid];
947 if (!gTws->fOpen)
948 return -1;
949 else
950 return gTws->fDoubleBuffer;
951}
952
953////////////////////////////////////////////////////////////////////////////////
954/// Return position and size of window wid.
955///
956/// \param [in] wid : window identifier
957/// \param [in] x,y : window position (output)
958/// \param [in] w,h : window size (output)
959///
960/// if wid < 0 the size of the display is returned
961
962void TGX11::GetGeometry(int wid, int &x, int &y, unsigned int &w, unsigned int &h)
963{
964 Window junkwin=0;
965
966 if (wid < 0) {
967 x = 0;
968 y = 0;
971 } else {
972 Window root;
973 unsigned int border, depth;
974 unsigned int width, height;
975
976 gTws = &fWindows[wid];
977 XGetGeometry((Display*)fDisplay, gTws->fWindow, &root, &x, &y,
978 &width, &height, &border, &depth);
979 XTranslateCoordinates((Display*)fDisplay, gTws->fWindow, fRootWin,
980 0, 0, &x, &y, &junkwin);
981 if (width >= 65535)
982 width = 1;
983 if (height >= 65535)
984 height = 1;
985 if (width > 0 && height > 0) {
986 gTws->fWidth = width;
987 gTws->fHeight = height;
988 }
989 w = gTws->fWidth;
990 h = gTws->fHeight;
991 }
992}
993
994////////////////////////////////////////////////////////////////////////////////
995/// Return hostname on which the display is opened.
996
997const char *TGX11::DisplayName(const char *dpyName)
998{
999 return XDisplayName(dpyName);
1000}
1001
1002////////////////////////////////////////////////////////////////////////////////
1003/// Return pixel value associated to specified ROOT color number.
1004
1006{
1007 TColor *color = gROOT->GetColor(ci);
1008 if (color)
1009 SetRGB(ci, color->GetRed(), color->GetGreen(), color->GetBlue());
1010// else
1011// Warning("GetPixel", "color with index %d not defined", ci);
1012
1013 XColor_t &col = GetColor(ci);
1014 return col.fPixel;
1015}
1016
1017////////////////////////////////////////////////////////////////////////////////
1018/// Get maximum number of planes.
1019
1021{
1022 nplanes = fDepth;
1023}
1024
1025////////////////////////////////////////////////////////////////////////////////
1026/// Get rgb values for color "index".
1027
1028void TGX11::GetRGB(int index, float &r, float &g, float &b)
1029{
1030 if (index == 0) {
1031 r = g = b = 1.0;
1032 } else if (index == 1) {
1033 r = g = b = 0.0;
1034 } else {
1035 XColor_t &col = GetColor(index);
1036 r = ((float) col.fRed) / ((float) kBIGGEST_RGB_VALUE);
1037 g = ((float) col.fGreen) / ((float) kBIGGEST_RGB_VALUE);
1038 b = ((float) col.fBlue) / ((float) kBIGGEST_RGB_VALUE);
1039 }
1040}
1041
1042////////////////////////////////////////////////////////////////////////////////
1043/// Return the size of a character string.
1044///
1045/// \param [in] w : text width
1046/// \param [in] h : text height
1047/// \param [in] mess : message
1048
1050{
1051 w=0; h=0;
1052 if (strlen(mess)==0) return;
1053
1054 XPoint *cBox;
1056 cBox = XRotTextExtents((Display*)fDisplay, gTextFont, 0., 0, 0, mess, 0);
1057 if (cBox) {
1058 w = cBox[2].x;
1059 h = -cBox[2].y;
1060 free((char *)cBox);
1061 }
1062}
1063
1064////////////////////////////////////////////////////////////////////////////////
1065/// Return the X11 window identifier.
1066///
1067/// \param [in] wid : Workstation identifier (input)
1068
1070{
1071 return (Window_t) fWindows[wid].fWindow;
1072}
1073
1074////////////////////////////////////////////////////////////////////////////////
1075/// Move the window wid.
1076///
1077/// \param [in] wid : Window identifier.
1078/// \param [in] x : x new window position
1079/// \param [in] y : y new window position
1080
1082{
1083 gTws = &fWindows[wid];
1084 if (!gTws->fOpen) return;
1085
1086 XMoveWindow((Display*)fDisplay, gTws->fWindow, x, y);
1087}
1088
1089////////////////////////////////////////////////////////////////////////////////
1090/// Open the display. Return -1 if the opening fails, 0 when ok.
1091
1093{
1094 Pixmap pixmp1, pixmp2;
1095 XColor fore, back;
1096 char **fontlist;
1097 int fontcount = 0;
1098 int i;
1099
1100 if (fDisplay) return 0;
1101
1102 fDisplay = (void *) disp;
1104
1106
1107 GetColor(1).fDefined = kTRUE; // default foreground
1109 GetColor(0).fDefined = kTRUE; // default background
1111
1112 // Inquire the XServer Vendor
1113 char vendor[132];
1114 strlcpy(vendor, XServerVendor((Display*)fDisplay),132);
1115
1116 // Create primitives graphic contexts
1117 for (i = 0; i < kMAXGC; i++)
1118 gGClist[i] = XCreateGC((Display*)fDisplay, fVisRootWin, 0, nullptr);
1119
1120 XGCValues values;
1121 if (XGetGCValues((Display*)fDisplay, *gGCtext, GCForeground|GCBackground, &values)) {
1122 XSetForeground((Display*)fDisplay, *gGCinvt, values.background);
1123 XSetBackground((Display*)fDisplay, *gGCinvt, values.foreground);
1124 } else {
1125 Error("OpenDisplay", "cannot get GC values");
1126 }
1127
1128 // Turn-off GraphicsExpose and NoExpose event reporting for the pixmap
1129 // manipulation GC, this to prevent these events from being stacked up
1130 // without ever being processed and thereby wasting a lot of memory.
1131 XSetGraphicsExposures((Display*)fDisplay, *gGCpxmp, False);
1132
1133 // Create input echo graphic context
1135 echov.foreground = fBlackPixel;
1136 echov.background = fWhitePixel;
1137 if (strstr(vendor,"Hewlett"))
1138 echov.function = GXxor;
1139 else
1140 echov.function = GXinvert;
1141
1144 &echov);
1145
1146 // Load a default Font
1147 static int isdisp = 0;
1148 if (!isdisp) {
1149 for (i = 0; i < kMAXFONT; i++) {
1150 gFont[i].id = nullptr;
1151 strcpy(gFont[i].name, " ");
1152 }
1153 fontlist = XListFonts((Display*)fDisplay, "*courier*", 1, &fontcount);
1154 if (fontlist && fontcount != 0) {
1157 strcpy(gFont[gCurrentFontNumber].name, "*courier*");
1160 } else {
1161 // emergency: try fixed font
1162 fontlist = XListFonts((Display*)fDisplay, "fixed", 1, &fontcount);
1163 if (fontlist && fontcount != 0) {
1169 } else {
1170 Warning("OpenDisplay", "no default font loaded");
1171 }
1172 }
1173 isdisp = 1;
1174 }
1175
1176 // Create a null cursor
1178 null_cursor_bits, 16, 16);
1180 null_cursor_bits, 16, 16);
1181 gNullCursor = XCreatePixmapCursor((Display*)fDisplay,pixmp1,pixmp2,&fore,&back,0,0);
1182
1183 // Create cursors
1203
1204 // Setup color information
1206
1207 if (fVisual->c_class == TrueColor) {
1208 for (i = 0; i < int(sizeof(fVisual->blue_mask)*kBitsPerByte); i++) {
1209 if (fBlueShift == -1 && ((fVisual->blue_mask >> i) & 1))
1210 fBlueShift = i;
1211 if ((fVisual->blue_mask >> i) == 1) {
1212 fBlueDiv = sizeof(UShort_t)*kBitsPerByte - i - 1 + fBlueShift;
1213 break;
1214 }
1215 }
1216 for (i = 0; i < int(sizeof(fVisual->green_mask)*kBitsPerByte); i++) {
1217 if (fGreenShift == -1 && ((fVisual->green_mask >> i) & 1))
1218 fGreenShift = i;
1219 if ((fVisual->green_mask >> i) == 1) {
1220 fGreenDiv = sizeof(UShort_t)*kBitsPerByte - i - 1 + fGreenShift;
1221 break;
1222 }
1223 }
1224 for (i = 0; i < int(sizeof(fVisual->red_mask)*kBitsPerByte); i++) {
1225 if (fRedShift == -1 && ((fVisual->red_mask >> i) & 1))
1226 fRedShift = i;
1227 if ((fVisual->red_mask >> i) == 1) {
1228 fRedDiv = sizeof(UShort_t)*kBitsPerByte - i - 1 + fRedShift;
1229 break;
1230 }
1231 }
1232 //printf("fRedDiv = %d, fGreenDiv = %d, fBlueDiv = %d, fRedShift = %d, fGreenShift = %d, fBlueShift = %d\n",
1233 // fRedDiv, fGreenDiv, fBlueDiv, fRedShift, fGreenShift, fBlueShift);
1234 }
1235
1236 return 0;
1237}
1238
1239////////////////////////////////////////////////////////////////////////////////
1240/// Open a new pixmap.
1241///
1242/// \param [in] w,h : Width and height of the pixmap.
1243
1244Int_t TGX11::OpenPixmap(unsigned int w, unsigned int h)
1245{
1246 Window root;
1247 unsigned int wval, hval;
1248 int xx, yy, i, wid;
1249 unsigned int ww, hh, border, depth;
1250 wval = w;
1251 hval = h;
1252
1253 // Select next free window number
1254
1255again:
1256 for (wid = 0; wid < fMaxNumberOfWindows; wid++)
1257 if (!fWindows[wid].fOpen) {
1258 fWindows[wid].fOpen = 1;
1259 gCws = &fWindows[wid];
1260 break;
1261 }
1262
1263 if (wid == fMaxNumberOfWindows) {
1264 int newsize = fMaxNumberOfWindows + 10;
1267 for (i = fMaxNumberOfWindows; i < newsize; i++)
1268 fWindows[i].fOpen = 0;
1270 goto again;
1271 }
1272
1273 gCws->fWindow = XCreatePixmap((Display*)fDisplay, fRootWin, wval, hval, fDepth);
1274 XGetGeometry((Display*)fDisplay, gCws->fWindow, &root, &xx, &yy, &ww, &hh, &border, &depth);
1275
1276 for (i = 0; i < kMAXGC; i++)
1277 XSetClipMask((Display*)fDisplay, gGClist[i], None);
1278
1279 SetColor(gGCpxmp, 0);
1280 XFillRectangle((Display*)fDisplay, gCws->fWindow, *gGCpxmp, 0, 0, ww, hh);
1281 SetColor(gGCpxmp, 1);
1282
1283 // Initialise the window structure
1284 gCws->fDrawing = gCws->fWindow;
1285 gCws->fBuffer = 0;
1286 gCws->fDoubleBuffer = 0;
1287 gCws->fIsPixmap = 1;
1288 gCws->fClip = 0;
1289 gCws->fWidth = wval;
1290 gCws->fHeight = hval;
1291 gCws->fNewColors = nullptr;
1292 gCws->fShared = kFALSE;
1293
1294 return wid;
1295}
1296
1297////////////////////////////////////////////////////////////////////////////////
1298/// Open window and return window number.
1299///
1300/// \return -1 if window initialization fails.
1301
1303{
1304 XSetWindowAttributes attributes;
1305 ULong_t attr_mask = 0;
1306 int wid;
1307 int xval, yval;
1308 unsigned int wval, hval, border, depth;
1309 Window root;
1310
1311 Window wind = (Window) win;
1312
1313 XGetGeometry((Display*)fDisplay, wind, &root, &xval, &yval, &wval, &hval, &border, &depth);
1314
1315 // Select next free window number
1316
1317again:
1318 for (wid = 0; wid < fMaxNumberOfWindows; wid++)
1319 if (!fWindows[wid].fOpen) {
1320 fWindows[wid].fOpen = 1;
1322 gCws = &fWindows[wid];
1323 break;
1324 }
1325
1326 if (wid == fMaxNumberOfWindows) {
1327 int newsize = fMaxNumberOfWindows + 10;
1330 for (int i = fMaxNumberOfWindows; i < newsize; i++)
1331 fWindows[i].fOpen = 0;
1333 goto again;
1334 }
1335
1336 // Create window
1337
1338 attributes.background_pixel = GetColor(0).fPixel;
1340 attributes.border_pixel = GetColor(1).fPixel;
1342 attributes.event_mask = NoEventMask;
1344 attributes.backing_store = Always;
1346 attributes.bit_gravity = NorthWestGravity;
1348 if (fColormap) {
1349 attributes.colormap = fColormap;
1351 }
1352
1353 gCws->fWindow = XCreateWindow((Display*)fDisplay, wind,
1354 xval, yval, wval, hval, 0, fDepth,
1356 attr_mask, &attributes);
1357
1358 XMapWindow((Display*)fDisplay, gCws->fWindow);
1359 XFlush((Display*)fDisplay);
1360
1361 // Initialise the window structure
1362
1363 gCws->fDrawing = gCws->fWindow;
1364 gCws->fBuffer = 0;
1365 gCws->fDoubleBuffer = 0;
1366 gCws->fIsPixmap = 0;
1367 gCws->fClip = 0;
1368 gCws->fWidth = wval;
1369 gCws->fHeight = hval;
1370 gCws->fNewColors = nullptr;
1371 gCws->fShared = kFALSE;
1372
1373 return wid;
1374}
1375
1376////////////////////////////////////////////////////////////////////////////////
1377/// Register a window created by Qt as a ROOT window (like InitWindow()).
1378
1380{
1381 Int_t wid;
1382
1383 // Select next free window number
1384
1385again:
1386 for (wid = 0; wid < fMaxNumberOfWindows; wid++)
1387 if (!fWindows[wid].fOpen) {
1388 fWindows[wid].fOpen = 1;
1390 gCws = &fWindows[wid];
1391 break;
1392 }
1393
1394 if (wid == fMaxNumberOfWindows) {
1395 int newsize = fMaxNumberOfWindows + 10;
1398 for (int i = fMaxNumberOfWindows; i < newsize; i++)
1399 fWindows[i].fOpen = 0;
1401 goto again;
1402 }
1403
1404 gCws->fWindow = qwid;
1405
1406 //init Xwindow_t struct
1407 gCws->fDrawing = gCws->fWindow;
1408 gCws->fBuffer = 0;
1409 gCws->fDoubleBuffer = 0;
1410 gCws->fIsPixmap = 0;
1411 gCws->fClip = 0;
1412 gCws->fWidth = w;
1413 gCws->fHeight = h;
1414 gCws->fNewColors = nullptr;
1415 gCws->fShared = kTRUE;
1416
1417 return wid;
1418}
1419
1420////////////////////////////////////////////////////////////////////////////////
1421/// Remove a window created by Qt (like CloseWindow1()).
1422
1424{
1425 SelectWindow((int)qwid);
1426
1427 if (gCws->fBuffer) XFreePixmap((Display*)fDisplay, gCws->fBuffer);
1428
1429 if (gCws->fNewColors) {
1430 if (fRedDiv == -1)
1431 XFreeColors((Display*)fDisplay, fColormap, gCws->fNewColors, gCws->fNcolors, 0);
1432 delete [] gCws->fNewColors;
1433 gCws->fNewColors = nullptr;
1434 }
1435
1436 gCws->fOpen = 0;
1437
1438 // make first window in list the current window
1439 for (Int_t wid = 0; wid < fMaxNumberOfWindows; wid++)
1440 if (fWindows[wid].fOpen) {
1441 gCws = &fWindows[wid];
1442 return;
1443 }
1444
1445 gCws = nullptr;
1446}
1447
1448////////////////////////////////////////////////////////////////////////////////
1449/// Query pointer position.
1450///
1451/// \param [in] ix : X coordinate of pointer
1452/// \param [in] iy : Y coordinate of pointer
1453/// (both coordinates are relative to the origin of the root window)
1454
1456{
1460 unsigned int mask_return;
1461
1462 XQueryPointer((Display*)fDisplay,gCws->fWindow, &root_return,
1465
1466 ix = root_x_return;
1467 iy = root_y_return;
1468}
1469
1470////////////////////////////////////////////////////////////////////////////////
1471/// Remove the pixmap pix.
1472
1474{
1475 XFreePixmap((Display*)fDisplay,*pix);
1476}
1477
1478////////////////////////////////////////////////////////////////////////////////
1479/// Request Locator position.
1480///
1481/// \param [in] x,y : cursor position at moment of button press (output)
1482/// \param [in] ctyp : cursor type (input)
1483/// - ctyp=1 tracking cross
1484/// - ctyp=2 cross-hair
1485/// - ctyp=3 rubber circle
1486/// - ctyp=4 rubber band
1487/// - ctyp=5 rubber rectangle
1488///
1489/// \param [in] mode : input mode
1490/// - mode=0 request
1491/// - mode=1 sample
1492///
1493/// Request locator:
1494/// return button number:
1495/// - 1 = left is pressed
1496/// - 2 = middle is pressed
1497/// - 3 = right is pressed
1498/// in sample mode:
1499/// - 11 = left is released
1500/// - 12 = middle is released
1501/// - 13 = right is released
1502/// - -1 = nothing is pressed or released
1503/// - -2 = leave the window
1504/// - else = keycode (keyboard is pressed)
1505
1507{
1508 static int xloc = 0;
1509 static int yloc = 0;
1510 static int xlocp = 0;
1511 static int ylocp = 0;
1512 static Cursor cursor = 0;
1513
1514 XEvent event;
1515 int button_press;
1516 int radius;
1517
1518 // Change the cursor shape
1519 if (cursor == 0) {
1520 if (ctyp > 1) {
1521 XDefineCursor((Display*)fDisplay, gCws->fWindow, gNullCursor);
1522 XSetForeground((Display*)fDisplay, gGCecho, GetColor(0).fPixel);
1523 } else {
1525 XDefineCursor((Display*)fDisplay, gCws->fWindow, cursor);
1526 }
1527 }
1528
1529 // Event loop
1530
1531 button_press = 0;
1532
1533 while (button_press == 0) {
1534
1535 switch (ctyp) {
1536
1537 case 1 :
1538 break;
1539
1540 case 2 :
1541 XDrawLine((Display*)fDisplay, gCws->fWindow, gGCecho,
1542 xloc, 0, xloc, gCws->fHeight);
1543 XDrawLine((Display*)fDisplay, gCws->fWindow, gGCecho,
1544 0, yloc, gCws->fWidth, yloc);
1545 break;
1546
1547 case 3 :
1548 radius = (int) TMath::Sqrt((double)((xloc-xlocp)*(xloc-xlocp) +
1549 (yloc-ylocp)*(yloc-ylocp)));
1550 XDrawArc((Display*)fDisplay, gCws->fWindow, gGCecho,
1552 2*radius, 2*radius, 0, 23040);
1553 break;
1554
1555 case 4 :
1556 XDrawLine((Display*)fDisplay, gCws->fWindow, gGCecho,
1557 xlocp, ylocp, xloc, yloc);
1558 break;
1559
1560 case 5 :
1561 XDrawRectangle((Display*)fDisplay, gCws->fWindow, gGCecho,
1564 break;
1565
1566 default:
1567 break;
1568 }
1569
1570 while (XEventsQueued( (Display*)fDisplay, QueuedAlready) > 1) {
1571 XNextEvent((Display*)fDisplay, &event);
1572 }
1573 XWindowEvent((Display*)fDisplay, gCws->fWindow, gMouseMask, &event);
1574
1575 switch (ctyp) {
1576
1577 case 1 :
1578 break;
1579
1580 case 2 :
1581 XDrawLine((Display*)fDisplay, gCws->fWindow, gGCecho,
1582 xloc, 0, xloc, gCws->fHeight);
1583 XDrawLine((Display*)fDisplay, gCws->fWindow, gGCecho,
1584 0, yloc, gCws->fWidth, yloc);
1585 break;
1586
1587 case 3 :
1588 radius = (int) TMath::Sqrt((double)((xloc-xlocp)*(xloc-xlocp) +
1589 (yloc-ylocp)*(yloc-ylocp)));
1590 XDrawArc((Display*)fDisplay, gCws->fWindow, gGCecho,
1592 2*radius, 2*radius, 0, 23040);
1593 break;
1594
1595 case 4 :
1596 XDrawLine((Display*)fDisplay, gCws->fWindow, gGCecho,
1597 xlocp, ylocp, xloc, yloc);
1598 break;
1599
1600 case 5 :
1601 XDrawRectangle((Display*)fDisplay, gCws->fWindow, gGCecho,
1604 break;
1605
1606 default:
1607 break;
1608 }
1609
1610 xloc = event.xbutton.x;
1611 yloc = event.xbutton.y;
1612
1613 switch (event.type) {
1614
1615 case LeaveNotify :
1616 if (mode == 0) {
1617 while (true) {
1618 XNextEvent((Display*)fDisplay, &event);
1619 if (event.type == EnterNotify) break;
1620 }
1621 } else {
1622 button_press = -2;
1623 }
1624 break;
1625
1626 case ButtonPress :
1627 button_press = event.xbutton.button ;
1628 xlocp = event.xbutton.x;
1629 ylocp = event.xbutton.y;
1630 XUndefineCursor( (Display*)fDisplay, gCws->fWindow );
1631 cursor = 0;
1632 break;
1633
1634 case ButtonRelease :
1635 if (mode == 1) {
1636 button_press = 10+event.xbutton.button ;
1637 xlocp = event.xbutton.x;
1638 ylocp = event.xbutton.y;
1639 }
1640 break;
1641
1642 case KeyPress :
1643 if (mode == 1) {
1644 button_press = event.xkey.keycode;
1645 xlocp = event.xbutton.x;
1646 ylocp = event.xbutton.y;
1647 }
1648 break;
1649
1650 case KeyRelease :
1651 if (mode == 1) {
1652 button_press = -event.xkey.keycode;
1653 xlocp = event.xbutton.x;
1654 ylocp = event.xbutton.y;
1655 }
1656 break;
1657
1658 default :
1659 break;
1660 }
1661
1662 if (mode == 1) {
1663 if (button_press == 0)
1664 button_press = -1;
1665 break;
1666 }
1667 }
1668 x = event.xbutton.x;
1669 y = event.xbutton.y;
1670
1671 return button_press;
1672}
1673
1674////////////////////////////////////////////////////////////////////////////////
1675/// Request a string.
1676///
1677/// \param [in] x,y : position where text is displayed
1678/// \param [in] text : text displayed (input), edited text (output)
1679///
1680/// Request string:
1681/// text is displayed and can be edited with Emacs-like keybinding
1682/// return termination code (0 for ESC, 1 for RETURN)
1683
1685{
1686 static Cursor cursor = 0;
1687 static int percent = 0; // bell volume
1689 int focusrevert;
1690 XEvent event;
1691 KeySym keysym;
1692 int key = -1;
1693 int len_text = strlen(text);
1694 int nt; // defined length of text
1695 int pt; // cursor position in text
1696
1697 // change the cursor shape
1698 if (cursor == 0) {
1702 percent = kbstate.bell_percent;
1703 }
1704 if (cursor != 0)
1705 XDefineCursor((Display*)fDisplay, gCws->fWindow, cursor);
1706 for (nt = len_text; nt > 0 && text[nt-1] == ' '; nt--) { }
1707 pt = nt;
1709 XSetInputFocus((Display*)fDisplay, gCws->fWindow, focusrevert, CurrentTime);
1710 while (key < 0) {
1711 char keybuf[8];
1712 char nbytes;
1713 int dx;
1714 int i;
1715 XDrawImageString((Display*)fDisplay, gCws->fWindow, *gGCtext, x, y, text, nt);
1716 dx = XTextWidth(gTextFont, text, nt);
1717 XDrawImageString((Display*)fDisplay, gCws->fWindow, *gGCtext, x + dx, y, " ", 1);
1718 dx = pt == 0 ? 0 : XTextWidth(gTextFont, text, pt);
1719 XDrawImageString((Display*)fDisplay, gCws->fWindow, *gGCinvt,
1720 x + dx, y, pt < len_text ? &text[pt] : " ", 1);
1721 XWindowEvent((Display*)fDisplay, gCws->fWindow, gKeybdMask, &event);
1722 switch (event.type) {
1723 case ButtonPress:
1724 case EnterNotify:
1725 XSetInputFocus((Display*)fDisplay, gCws->fWindow, focusrevert, CurrentTime);
1726 break;
1727 case LeaveNotify:
1729 break;
1730 case KeyPress:
1731 nbytes = XLookupString(&event.xkey, keybuf, sizeof(keybuf),
1732 &keysym, nullptr);
1733 switch (keysym) { // map cursor keys
1734 case XK_Left:
1735 keybuf[0] = '\002'; // Control-B
1736 nbytes = 1;
1737 break;
1738 case XK_Right:
1739 keybuf[0] = '\006'; // Control-F
1740 nbytes = 1;
1741 break;
1742 }
1743 if (nbytes == 1) {
1744 if (isascii(keybuf[0]) && isprint(keybuf[0])) {
1745 // insert character
1746 if (nt < len_text)
1747 nt++;
1748 for (i = nt - 1; i > pt; i--)
1749 text[i] = text[i-1];
1750 if (pt < len_text) {
1751 text[pt] = keybuf[0];
1752 pt++;
1753 }
1754 } else
1755 switch (keybuf[0]) {
1756 // Emacs-like editing keys
1757
1758 case '\010': // backspace
1759 case '\177': // delete
1760 // delete backward
1761 if (pt > 0) {
1762 for (i = pt; i < nt; i++)
1763 text[i-1] = text[i];
1764 text[nt-1] = ' ';
1765 nt--;
1766 pt--;
1767 }
1768 break;
1769 case '\001': // ^A
1770 // beginning of line
1771 pt = 0;
1772 break;
1773 case '\002': // ^B
1774 // move backward
1775 if (pt > 0)
1776 pt--;
1777 break;
1778 case '\004': // ^D
1779 // delete forward
1780 if (pt > 0) {
1781 for (i = pt; i < nt; i++)
1782 text[i-1] = text[i];
1783 text[nt-1] = ' ';
1784 pt--;
1785 }
1786 break;
1787 case '\005': // ^E
1788 // end of line
1789 pt = nt;
1790 break;
1791
1792 case '\006': // ^F
1793 // move forward
1794 if (pt < nt)
1795 pt++;
1796 break;
1797 case '\013': // ^K
1798 // delete to end of line
1799 for (i = pt; i < nt; i++)
1800 text[i] = ' ';
1801 nt = pt;
1802 break;
1803 case '\024': // ^T
1804 // transpose
1805 if (pt > 0) {
1806 char c = text[pt];
1807 text[pt] = text[pt-1];
1808 text[pt-1] = c;
1809 }
1810 break;
1811 case '\012': // newline
1812 case '\015': // return
1813 key = 1;
1814 break;
1815 case '\033': // escape
1816 key = 0;
1817 break;
1818
1819 default:
1820 XBell((Display*)fDisplay, percent);
1821 }
1822 }
1823 }
1824 }
1826
1827 if (cursor != 0) {
1828 XUndefineCursor((Display*)fDisplay, gCws->fWindow);
1829 cursor = 0;
1830 }
1831
1832 return key;
1833}
1834
1835////////////////////////////////////////////////////////////////////////////////
1836/// Rescale the window wid.
1837///
1838/// \param [in] wid : Window identifier
1839/// \param [in] w : Width
1840/// \param [in] h : Height
1841
1842void TGX11::RescaleWindow(int wid, unsigned int w, unsigned int h)
1843{
1844 int i;
1845
1846 gTws = &fWindows[wid];
1847 if (!gTws->fOpen) return;
1848
1849 // don't do anything when size did not change
1850 if (gTws->fWidth == w && gTws->fHeight == h) return;
1851
1852 XResizeWindow((Display*)fDisplay, gTws->fWindow, w, h);
1853
1854 if (gTws->fBuffer) {
1855 // don't free and recreate pixmap when new pixmap is smaller
1856 if (gTws->fWidth < w || gTws->fHeight < h) {
1857 XFreePixmap((Display*)fDisplay,gTws->fBuffer);
1858 gTws->fBuffer = XCreatePixmap((Display*)fDisplay, fRootWin, w, h, fDepth);
1859 }
1860 for (i = 0; i < kMAXGC; i++) XSetClipMask((Display*)fDisplay, gGClist[i], None);
1861 SetColor(gGCpxmp, 0);
1862 XFillRectangle( (Display*)fDisplay, gTws->fBuffer, *gGCpxmp, 0, 0, w, h);
1863 SetColor(gGCpxmp, 1);
1864 if (gTws->fDoubleBuffer) gTws->fDrawing = gTws->fBuffer;
1865 }
1866 gTws->fWidth = w;
1867 gTws->fHeight = h;
1868}
1869
1870////////////////////////////////////////////////////////////////////////////////
1871/// Resize a pixmap.
1872///
1873/// \param [in] wid : pixmap to be resized
1874/// \param [in] w,h : Width and height of the pixmap
1875
1876int TGX11::ResizePixmap(int wid, unsigned int w, unsigned int h)
1877{
1878 Window root;
1879 unsigned int wval, hval;
1880 int xx, yy, i;
1881 unsigned int ww, hh, border, depth;
1882 wval = w;
1883 hval = h;
1884
1885 gTws = &fWindows[wid];
1886
1887 // don't do anything when size did not change
1888 // if (gTws->fWidth == wval && gTws->fHeight == hval) return 0;
1889
1890 // due to round-off errors in TPad::Resize() we might get +/- 1 pixel
1891 // change, in those cases don't resize pixmap
1892 if (gTws->fWidth >= wval-1 && gTws->fWidth <= wval+1 &&
1893 gTws->fHeight >= hval-1 && gTws->fHeight <= hval+1) return 0;
1894
1895 // don't free and recreate pixmap when new pixmap is smaller
1896 if (gTws->fWidth < wval || gTws->fHeight < hval) {
1897 XFreePixmap((Display*)fDisplay, gTws->fWindow);
1898 gTws->fWindow = XCreatePixmap((Display*)fDisplay, fRootWin, wval, hval, fDepth);
1899 }
1900 XGetGeometry((Display*)fDisplay, gTws->fWindow, &root, &xx, &yy, &ww, &hh, &border, &depth);
1901
1902 for (i = 0; i < kMAXGC; i++)
1903 XSetClipMask((Display*)fDisplay, gGClist[i], None);
1904
1905 SetColor(gGCpxmp, 0);
1906 XFillRectangle((Display*)fDisplay, gTws->fWindow, *gGCpxmp, 0, 0, ww, hh);
1907 SetColor(gGCpxmp, 1);
1908
1909 // Initialise the window structure
1910 gTws->fDrawing = gTws->fWindow;
1911 gTws->fWidth = wval;
1912 gTws->fHeight = hval;
1913
1914 return 1;
1915}
1916
1917////////////////////////////////////////////////////////////////////////////////
1918/// Resize the current window if necessary.
1919
1921{
1922 int i;
1923 int xval=0, yval=0;
1924 Window win, root=0;
1925 unsigned int wval=0, hval=0, border=0, depth=0;
1926
1927 gTws = &fWindows[wid];
1928
1929 win = gTws->fWindow;
1930
1931 XGetGeometry((Display*)fDisplay, win, &root,
1932 &xval, &yval, &wval, &hval, &border, &depth);
1933 if (wval >= 65500) wval = 1;
1934 if (hval >= 65500) hval = 1;
1935
1936 // don't do anything when size did not change
1937 if (gTws->fWidth == wval && gTws->fHeight == hval) return;
1938
1939 XResizeWindow((Display*)fDisplay, gTws->fWindow, wval, hval);
1940
1941 if (gTws->fBuffer) {
1942 if (gTws->fWidth < wval || gTws->fHeight < hval) {
1943 XFreePixmap((Display*)fDisplay,gTws->fBuffer);
1944 gTws->fBuffer = XCreatePixmap((Display*)fDisplay, fRootWin, wval, hval, fDepth);
1945 }
1946 for (i = 0; i < kMAXGC; i++) XSetClipMask((Display*)fDisplay, gGClist[i], None);
1947 SetColor(gGCpxmp, 0);
1948 XFillRectangle((Display*)fDisplay, gTws->fBuffer, *gGCpxmp, 0, 0, wval, hval);
1949 SetColor(gGCpxmp, 1);
1950 if (gTws->fDoubleBuffer) gTws->fDrawing = gTws->fBuffer;
1951 }
1952 gTws->fWidth = wval;
1953 gTws->fHeight = hval;
1954}
1955
1956////////////////////////////////////////////////////////////////////////////////
1957/// Select window to which subsequent output is directed.
1958
1960{
1962 int i;
1963
1964 if (wid < 0 || wid >= fMaxNumberOfWindows || !fWindows[wid].fOpen) return;
1965
1966 gCws = &fWindows[wid];
1967
1968 if (gCws->fClip && !gCws->fIsPixmap && !gCws->fDoubleBuffer) {
1969 region.x = gCws->fXclip;
1970 region.y = gCws->fYclip;
1971 region.width = gCws->fWclip;
1972 region.height = gCws->fHclip;
1973 for (i = 0; i < kMAXGC; i++)
1974 XSetClipRectangles((Display*)fDisplay, gGClist[i], 0, 0, &region, 1, YXBanded);
1975 } else {
1976 for (i = 0; i < kMAXGC; i++)
1977 XSetClipMask((Display*)fDisplay, gGClist[i], None);
1978 }
1979}
1980
1981////////////////////////////////////////////////////////////////////////////////
1982/// Set character up vector.
1983
1985{
1986 if (chupx == fCharacterUpX && chupy == fCharacterUpY) return;
1987
1988 if (chupx == 0 && chupy == 0) fTextAngle = 0;
1989 else if (chupx == 0 && chupy == 1) fTextAngle = 0;
1990 else if (chupx == -1 && chupy == 0) fTextAngle = 90;
1991 else if (chupx == 0 && chupy == -1) fTextAngle = 180;
1992 else if (chupx == 1 && chupy == 0) fTextAngle = 270;
1993 else {
1995 if (chupy < 0) fTextAngle = 180 - fTextAngle;
1996 if (TMath::Abs(fTextAngle) <= 0.01) fTextAngle = 0;
1997 }
2000}
2001
2002////////////////////////////////////////////////////////////////////////////////
2003/// Turn off the clipping for the window wid.
2004
2006{
2007 gTws = &fWindows[wid];
2008 gTws->fClip = 0;
2009
2010 for (int i = 0; i < kMAXGC; i++)
2011 XSetClipMask( (Display*)fDisplay, gGClist[i], None );
2012}
2013
2014////////////////////////////////////////////////////////////////////////////////
2015/// Set clipping region for the window wid.
2016///
2017/// \param [in] wid : Window identifier
2018/// \param [in] x,y : origin of clipping rectangle
2019/// \param [in] w,h : size of clipping rectangle;
2020
2021void TGX11::SetClipRegion(int wid, int x, int y, unsigned int w, unsigned int h)
2022{
2023
2024 gTws = &fWindows[wid];
2025 gTws->fXclip = x;
2026 gTws->fYclip = y;
2027 gTws->fWclip = w;
2028 gTws->fHclip = h;
2029 gTws->fClip = 1;
2030 if (gTws->fClip && !gTws->fIsPixmap && !gTws->fDoubleBuffer) {
2032 region.x = gTws->fXclip;
2033 region.y = gTws->fYclip;
2034 region.width = gTws->fWclip;
2035 region.height = gTws->fHclip;
2036 for (int i = 0; i < kMAXGC; i++)
2037 XSetClipRectangles((Display*)fDisplay, gGClist[i], 0, 0, &region, 1, YXBanded);
2038 }
2039}
2040
2041////////////////////////////////////////////////////////////////////////////////
2042/// Set the foreground color in GC.
2043
2044void TGX11::SetColor(void *gci, int ci)
2045{
2046 GC gc = *(GC *)gci;
2047
2048 TColor *color = gROOT->GetColor(ci);
2049 if (color)
2050 SetRGB(ci, color->GetRed(), color->GetGreen(), color->GetBlue());
2051
2052 XColor_t &col = GetColor(ci);
2053 if (fColormap && !col.fDefined) {
2054 col = GetColor(0);
2055 } else if (!fColormap && (ci < 0 || ci > 1)) {
2056 col = GetColor(0);
2057 }
2058
2059 if (fDrawMode == kXor) {
2060 XGCValues values;
2061 XGetGCValues((Display*)fDisplay, gc, GCBackground, &values);
2062 XSetForeground((Display*)fDisplay, gc, col.fPixel ^ values.background);
2063 } else {
2064 XSetForeground((Display*)fDisplay, gc, col.fPixel);
2065
2066 // make sure that foreground and background are different
2067 XGCValues values;
2068 XGetGCValues((Display*)fDisplay, gc, GCForeground | GCBackground, &values);
2069 if (values.foreground == values.background)
2070 XSetBackground((Display*)fDisplay, gc, GetColor(!ci).fPixel);
2071 }
2072}
2073
2074////////////////////////////////////////////////////////////////////////////////
2075/// Set the cursor.
2076
2078{
2079 gTws = &fWindows[wid];
2080 XDefineCursor((Display*)fDisplay, gTws->fWindow, fCursors[cursor]);
2081}
2082
2083////////////////////////////////////////////////////////////////////////////////
2084/// Set the double buffer on/off on window wid.
2085///
2086/// \param [in] wid : Window identifier.
2087/// - 999 means all the opened windows.
2088/// \param [in] mode :
2089/// - 1 double buffer is on
2090/// - 0 double buffer is off
2091
2093{
2094 if (wid == 999) {
2095 for (int i = 0; i < fMaxNumberOfWindows; i++) {
2096 gTws = &fWindows[i];
2097 if (gTws->fOpen) {
2098 switch (mode) {
2099 case 1 :
2101 break;
2102 default:
2104 break;
2105 }
2106 }
2107 }
2108 } else {
2109 gTws = &fWindows[wid];
2110 if (!gTws->fOpen) return;
2111 switch (mode) {
2112 case 1 :
2114 return;
2115 default:
2117 return;
2118 }
2119 }
2120}
2121
2122////////////////////////////////////////////////////////////////////////////////
2123/// Turn double buffer mode off.
2124
2126{
2127 if (!gTws->fDoubleBuffer) return;
2128 gTws->fDoubleBuffer = 0;
2129 gTws->fDrawing = gTws->fWindow;
2130}
2131
2132////////////////////////////////////////////////////////////////////////////////
2133/// Turn double buffer mode on.
2134
2136{
2137 if (gTws->fDoubleBuffer || gTws->fIsPixmap) return;
2138 if (!gTws->fBuffer) {
2139 gTws->fBuffer = XCreatePixmap((Display*)fDisplay, fRootWin,
2140 gTws->fWidth, gTws->fHeight, fDepth);
2141 SetColor(gGCpxmp, 0);
2142 XFillRectangle((Display*)fDisplay, gTws->fBuffer, *gGCpxmp, 0, 0, gTws->fWidth, gTws->fHeight);
2143 SetColor(gGCpxmp, 1);
2144 }
2145 for (int i = 0; i < kMAXGC; i++) XSetClipMask((Display*)fDisplay, gGClist[i], None);
2146 gTws->fDoubleBuffer = 1;
2147 gTws->fDrawing = gTws->fBuffer;
2148}
2149
2150////////////////////////////////////////////////////////////////////////////////
2151/// Set the drawing mode.
2152///
2153/// \param [in] mode : drawing mode
2154/// - mode=1 copy
2155/// - mode=2 xor
2156/// - mode=3 invert
2157/// - mode=4 set the suitable mode for cursor echo according to
2158/// the vendor
2159
2161{
2162 int i;
2163 if (fDisplay) {
2164 switch (mode) {
2165 case kCopy:
2166 for (i = 0; i < kMAXGC; i++) XSetFunction((Display*)fDisplay, gGClist[i], GXcopy);
2167 break;
2168
2169 case kXor:
2170 for (i = 0; i < kMAXGC; i++) XSetFunction((Display*)fDisplay, gGClist[i], GXxor);
2171 break;
2172
2173 case kInvert:
2174 for (i = 0; i < kMAXGC; i++) XSetFunction((Display*)fDisplay, gGClist[i], GXinvert);
2175 break;
2176 }
2177 }
2178 fDrawMode = mode;
2179}
2180
2181////////////////////////////////////////////////////////////////////////////////
2182/// Set color index for fill areas.
2183
2185{
2186 if (!gStyle->GetFillColor() && cindex > 1) cindex = 0;
2187 if (cindex >= 0) SetColor(gGCfill, Int_t(cindex));
2189
2190 // invalidate fill pattern
2191 if (gFillPattern != 0) {
2192 XFreePixmap((Display*)fDisplay, gFillPattern);
2193 gFillPattern = 0;
2194 }
2195}
2196
2197////////////////////////////////////////////////////////////////////////////////
2198/// Set fill area style.
2199///
2200/// \param [in] fstyle : compound fill area interior style
2201/// - fstyle = 1000*interiorstyle + styleindex
2202
2204{
2205 if (fFillStyle == fstyle) return;
2207 Int_t style = fstyle/1000;
2208 Int_t fasi = fstyle%1000;
2210}
2211
2212////////////////////////////////////////////////////////////////////////////////
2213/// Set fill area style index.
2214
2216{
2217 static int current_fasi = 0;
2218
2219 fFillStyle = 1000*style + fasi;
2220
2221 switch (style) {
2222
2223 case 1: // solid
2224 gFillHollow = 0;
2226 break;
2227
2228 case 2: // pattern
2229 gFillHollow = 1;
2230 break;
2231
2232 case 3: // hatch
2233 gFillHollow = 0;
2235 if (fasi != current_fasi) {
2236 if (gFillPattern != 0) {
2237 XFreePixmap((Display*)fDisplay, gFillPattern);
2238 gFillPattern = 0;
2239 }
2240 int stn = (fasi >= 1 && fasi <=25) ? fasi : 2;
2241
2243 (const char*)gStipples[stn], 16, 16);
2244
2245 XSetStipple( (Display*)fDisplay, *gGCfill, gFillPattern );
2247 }
2248 break;
2249
2250 default:
2251 gFillHollow = 1;
2252 }
2253}
2254
2255////////////////////////////////////////////////////////////////////////////////
2256/// Set input on or off.
2257
2259{
2260 XSetWindowAttributes attributes;
2262
2263 if (inp == 1) {
2264 attributes.event_mask = gMouseMask | gKeybdMask;
2266 XChangeWindowAttributes((Display*)fDisplay, gCws->fWindow, attr_mask, &attributes);
2267 } else {
2268 attributes.event_mask = NoEventMask;
2270 XChangeWindowAttributes((Display*)fDisplay, gCws->fWindow, attr_mask, &attributes);
2271 }
2272}
2273
2274////////////////////////////////////////////////////////////////////////////////
2275/// Set color index for lines.
2276
2278{
2279 if (cindex < 0) return;
2280
2282
2285}
2286
2287////////////////////////////////////////////////////////////////////////////////
2288/// Set line type.
2289///
2290/// \param [in] n : length of dash list
2291/// \param [in] dash : dash segment lengths
2292///
2293/// - if n <= 0 use solid lines
2294/// - if n > 0 use dashed lines described by DASH(N)
2295/// e.g. N=4,DASH=(6,3,1,3) gives a dashed-dotted line with dash length 6
2296/// and a gap of 7 between dashes
2297
2299{
2300 if (n <= 0) {
2304 } else {
2305 gDashSize = TMath::Min((int)sizeof(gDashList),n);
2306 gDashLength = 0;
2307 for (int i = 0; i < gDashSize; i++ ) {
2308 gDashList[i] = dash[i];
2309 gDashLength += gDashList[i];
2310 }
2311 gDashOffset = 0;
2313 if (gLineWidth == 0) gLineWidth =1;
2318 }
2319}
2320
2321////////////////////////////////////////////////////////////////////////////////
2322/// Set line style.
2323
2325{
2326 static Int_t dashed[2] = {3,3};
2327 static Int_t dotted[2] = {1,2};
2328 static Int_t dasheddotted[4] = {3,4,1,4};
2329
2330 if (fLineStyle != lstyle) { //set style index only if different
2332 if (lstyle <= 1 ) {
2333 SetLineType(0, nullptr);
2334 } else if (lstyle == 2 ) {
2335 SetLineType(2, dashed);
2336 } else if (lstyle == 3 ) {
2337 SetLineType(2, dotted);
2338 } else if (lstyle == 4 ) {
2340 } else {
2342 TObjArray *tokens = st.Tokenize(" ");
2343 Int_t nt;
2344 nt = tokens->GetEntries();
2345 Int_t *linestyle = new Int_t[nt];
2346 for (Int_t j = 0; j<nt; j++) {
2347 Int_t it;
2348 sscanf(((TObjString*)tokens->At(j))->GetName(), "%d", &it);
2349 linestyle[j] = (Int_t)(it/4);
2350 }
2352 delete [] linestyle;
2353 delete tokens;
2354 }
2355 }
2356}
2357
2358////////////////////////////////////////////////////////////////////////////////
2359/// Set line width.
2360///
2361/// \param [in] width : line width in pixels
2362
2364{
2365 if (fLineWidth == width) return;
2366 fLineWidth = width;
2367
2368 if (width == 1 && gLineStyle == LineSolid) gLineWidth = 0;
2369 else gLineWidth = width;
2370
2371 if (gLineWidth < 0) return;
2372
2377}
2378
2379////////////////////////////////////////////////////////////////////////////////
2380/// Set color index for markers.
2381
2383{
2384 if (cindex < 0) return;
2385
2387
2389}
2390
2391////////////////////////////////////////////////////////////////////////////////
2392/// Set marker size index.
2393///
2394/// \param [in] msize : marker scale factor
2395
2397{
2398 if (msize == fMarkerSize) return;
2399
2401 if (msize < 0) return;
2402
2404}
2405
2406////////////////////////////////////////////////////////////////////////////////
2407/// Set marker type.
2408///
2409/// \param [in] type : marker type
2410/// \param [in] n : length of marker description
2411/// \param [in] xy : list of points describing marker shape
2412///
2413/// - if n == 0 marker is a single point
2414/// - if TYPE == 0 marker is hollow circle of diameter N
2415/// - if TYPE == 1 marker is filled circle of diameter N
2416/// - if TYPE == 2 marker is a hollow polygon describe by line XY
2417/// - if TYPE == 3 marker is a filled polygon describe by line XY
2418/// - if TYPE == 4 marker is described by segmented line XY
2419/// e.g. TYPE=4,N=4,XY=(-3,0,3,0,0,-3,0,3) sets a plus shape of 7x7 pixels
2420
2422{
2423 gMarker.type = type;
2424 gMarker.n = n < kMAXMK ? n : kMAXMK;
2425 if (gMarker.type >= 2) {
2426 for (int i = 0; i < gMarker.n; i++) {
2427 gMarker.xy[i].x = xy[i].x;
2428 gMarker.xy[i].y = xy[i].y;
2429 }
2430 }
2431}
2432
2433////////////////////////////////////////////////////////////////////////////////
2434/// Set marker style.
2435
2437{
2438 if (fMarkerStyle == markerstyle) return;
2439 static RXPoint shape[30];
2443
2444 // The fast pixel markers need to be treated separately
2445 if (markerstyle == 1 || markerstyle == 6 || markerstyle == 7) {
2447 } else {
2450 }
2451
2453 Int_t im = Int_t(4*MarkerSizeReduced + 0.5);
2454 if (markerstyle == 2) {
2455 // + shaped marker
2456 shape[0].x = -im; shape[0].y = 0;
2457 shape[1].x = im; shape[1].y = 0;
2458 shape[2].x = 0 ; shape[2].y = -im;
2459 shape[3].x = 0 ; shape[3].y = im;
2460 SetMarkerType(4,4,shape);
2461 } else if (markerstyle == 3 || markerstyle == 31) {
2462 // * shaped marker
2463 shape[0].x = -im; shape[0].y = 0;
2464 shape[1].x = im; shape[1].y = 0;
2465 shape[2].x = 0 ; shape[2].y = -im;
2466 shape[3].x = 0 ; shape[3].y = im;
2467 im = Int_t(0.707*Float_t(im) + 0.5);
2468 shape[4].x = -im; shape[4].y = -im;
2469 shape[5].x = im; shape[5].y = im;
2470 shape[6].x = -im; shape[6].y = im;
2471 shape[7].x = im; shape[7].y = -im;
2472 SetMarkerType(4,8,shape);
2473 } else if (markerstyle == 4 || markerstyle == 24) {
2474 // O shaped marker
2475 SetMarkerType(0,im*2,shape);
2476 } else if (markerstyle == 5) {
2477 // X shaped marker
2478 im = Int_t(0.707*Float_t(im) + 0.5);
2479 shape[0].x = -im; shape[0].y = -im;
2480 shape[1].x = im; shape[1].y = im;
2481 shape[2].x = -im; shape[2].y = im;
2482 shape[3].x = im; shape[3].y = -im;
2483 SetMarkerType(4,4,shape);
2484 } else if (markerstyle == 6) {
2485 // + shaped marker (with 1 pixel)
2486 shape[0].x = -1 ; shape[0].y = 0;
2487 shape[1].x = 1 ; shape[1].y = 0;
2488 shape[2].x = 0 ; shape[2].y = -1;
2489 shape[3].x = 0 ; shape[3].y = 1;
2490 SetMarkerType(4,4,shape);
2491 } else if (markerstyle == 7) {
2492 // . shaped marker (with 9 pixel)
2493 shape[0].x = -1 ; shape[0].y = 1;
2494 shape[1].x = 1 ; shape[1].y = 1;
2495 shape[2].x = -1 ; shape[2].y = 0;
2496 shape[3].x = 1 ; shape[3].y = 0;
2497 shape[4].x = -1 ; shape[4].y = -1;
2498 shape[5].x = 1 ; shape[5].y = -1;
2499 SetMarkerType(4,6,shape);
2500 } else if (markerstyle == 8 || markerstyle == 20) {
2501 // O shaped marker (filled)
2502 SetMarkerType(1,im*2,shape);
2503 } else if (markerstyle == 21) {
2504 // full square
2505 shape[0].x = -im; shape[0].y = -im;
2506 shape[1].x = im; shape[1].y = -im;
2507 shape[2].x = im; shape[2].y = im;
2508 shape[3].x = -im; shape[3].y = im;
2509 shape[4].x = -im; shape[4].y = -im;
2510 SetMarkerType(3,5,shape);
2511 } else if (markerstyle == 22) {
2512 // full triangle up
2513 shape[0].x = -im; shape[0].y = im;
2514 shape[1].x = im; shape[1].y = im;
2515 shape[2].x = 0; shape[2].y = -im;
2516 shape[3].x = -im; shape[3].y = im;
2517 SetMarkerType(3,4,shape);
2518 } else if (markerstyle == 23) {
2519 // full triangle down
2520 shape[0].x = 0; shape[0].y = im;
2521 shape[1].x = im; shape[1].y = -im;
2522 shape[2].x = -im; shape[2].y = -im;
2523 shape[3].x = 0; shape[3].y = im;
2524 SetMarkerType(3,4,shape);
2525 } else if (markerstyle == 25) {
2526 // open square
2527 shape[0].x = -im; shape[0].y = -im;
2528 shape[1].x = im; shape[1].y = -im;
2529 shape[2].x = im; shape[2].y = im;
2530 shape[3].x = -im; shape[3].y = im;
2531 shape[4].x = -im; shape[4].y = -im;
2532 SetMarkerType(2,5,shape);
2533 } else if (markerstyle == 26) {
2534 // open triangle up
2535 shape[0].x = -im; shape[0].y = im;
2536 shape[1].x = im; shape[1].y = im;
2537 shape[2].x = 0; shape[2].y = -im;
2538 shape[3].x = -im; shape[3].y = im;
2539 SetMarkerType(2,4,shape);
2540 } else if (markerstyle == 27) {
2541 // open losange
2542 Int_t imx = Int_t(2.66*MarkerSizeReduced + 0.5);
2543 shape[0].x =-imx; shape[0].y = 0;
2544 shape[1].x = 0; shape[1].y = -im;
2545 shape[2].x = imx; shape[2].y = 0;
2546 shape[3].x = 0; shape[3].y = im;
2547 shape[4].x =-imx; shape[4].y = 0;
2548 SetMarkerType(2,5,shape);
2549 } else if (markerstyle == 28) {
2550 // open cross
2551 Int_t imx = Int_t(1.33*MarkerSizeReduced + 0.5);
2552 shape[0].x = -im; shape[0].y =-imx;
2553 shape[1].x =-imx; shape[1].y =-imx;
2554 shape[2].x =-imx; shape[2].y = -im;
2555 shape[3].x = imx; shape[3].y = -im;
2556 shape[4].x = imx; shape[4].y =-imx;
2557 shape[5].x = im; shape[5].y =-imx;
2558 shape[6].x = im; shape[6].y = imx;
2559 shape[7].x = imx; shape[7].y = imx;
2560 shape[8].x = imx; shape[8].y = im;
2561 shape[9].x =-imx; shape[9].y = im;
2562 shape[10].x=-imx; shape[10].y= imx;
2563 shape[11].x= -im; shape[11].y= imx;
2564 shape[12].x= -im; shape[12].y=-imx;
2565 SetMarkerType(2,13,shape);
2566 } else if (markerstyle == 29) {
2567 // full star pentagone
2568 Int_t im1 = Int_t(0.66*MarkerSizeReduced + 0.5);
2569 Int_t im2 = Int_t(2.00*MarkerSizeReduced + 0.5);
2570 Int_t im3 = Int_t(2.66*MarkerSizeReduced + 0.5);
2571 Int_t im4 = Int_t(1.33*MarkerSizeReduced + 0.5);
2572 shape[0].x = -im; shape[0].y = im4;
2573 shape[1].x =-im2; shape[1].y =-im1;
2574 shape[2].x =-im3; shape[2].y = -im;
2575 shape[3].x = 0; shape[3].y =-im2;
2576 shape[4].x = im3; shape[4].y = -im;
2577 shape[5].x = im2; shape[5].y =-im1;
2578 shape[6].x = im; shape[6].y = im4;
2579 shape[7].x = im4; shape[7].y = im4;
2580 shape[8].x = 0; shape[8].y = im;
2581 shape[9].x =-im4; shape[9].y = im4;
2582 shape[10].x= -im; shape[10].y= im4;
2583 SetMarkerType(3,11,shape);
2584 } else if (markerstyle == 30) {
2585 // open star pentagone
2586 Int_t im1 = Int_t(0.66*MarkerSizeReduced + 0.5);
2587 Int_t im2 = Int_t(2.00*MarkerSizeReduced + 0.5);
2588 Int_t im3 = Int_t(2.66*MarkerSizeReduced + 0.5);
2589 Int_t im4 = Int_t(1.33*MarkerSizeReduced + 0.5);
2590 shape[0].x = -im; shape[0].y = im4;
2591 shape[1].x =-im2; shape[1].y =-im1;
2592 shape[2].x =-im3; shape[2].y = -im;
2593 shape[3].x = 0; shape[3].y =-im2;
2594 shape[4].x = im3; shape[4].y = -im;
2595 shape[5].x = im2; shape[5].y =-im1;
2596 shape[6].x = im; shape[6].y = im4;
2597 shape[7].x = im4; shape[7].y = im4;
2598 shape[8].x = 0; shape[8].y = im;
2599 shape[9].x =-im4; shape[9].y = im4;
2600 shape[10].x= -im; shape[10].y= im4;
2601 SetMarkerType(2,11,shape);
2602 } else if (markerstyle == 32) {
2603 // open triangle down
2604 shape[0].x = 0; shape[0].y = im;
2605 shape[1].x = im; shape[1].y = -im;
2606 shape[2].x = -im; shape[2].y = -im;
2607 shape[3].x = 0; shape[3].y = im;
2608 SetMarkerType(2,4,shape);
2609 } else if (markerstyle == 33) {
2610 // full losange
2611 Int_t imx = Int_t(2.66*MarkerSizeReduced + 0.5);
2612 shape[0].x =-imx; shape[0].y = 0;
2613 shape[1].x = 0; shape[1].y = -im;
2614 shape[2].x = imx; shape[2].y = 0;
2615 shape[3].x = 0; shape[3].y = im;
2616 shape[4].x =-imx; shape[4].y = 0;
2617 SetMarkerType(3,5,shape);
2618 } else if (markerstyle == 34) {
2619 // full cross
2620 Int_t imx = Int_t(1.33*MarkerSizeReduced + 0.5);
2621 shape[0].x = -im; shape[0].y =-imx;
2622 shape[1].x =-imx; shape[1].y =-imx;
2623 shape[2].x =-imx; shape[2].y = -im;
2624 shape[3].x = imx; shape[3].y = -im;
2625 shape[4].x = imx; shape[4].y =-imx;
2626 shape[5].x = im; shape[5].y =-imx;
2627 shape[6].x = im; shape[6].y = imx;
2628 shape[7].x = imx; shape[7].y = imx;
2629 shape[8].x = imx; shape[8].y = im;
2630 shape[9].x =-imx; shape[9].y = im;
2631 shape[10].x=-imx; shape[10].y= imx;
2632 shape[11].x= -im; shape[11].y= imx;
2633 shape[12].x= -im; shape[12].y=-imx;
2634 SetMarkerType(3,13,shape);
2635 } else if (markerstyle == 35) {
2636 // diamond with cross
2637 shape[0].x =-im; shape[0].y = 0;
2638 shape[1].x = 0; shape[1].y = -im;
2639 shape[2].x = im; shape[2].y = 0;
2640 shape[3].x = 0; shape[3].y = im;
2641 shape[4].x =-im; shape[4].y = 0;
2642 shape[5].x = im; shape[5].y = 0;
2643 shape[6].x = 0; shape[6].y = im;
2644 shape[7].x = 0; shape[7].y =-im;
2645 SetMarkerType(2,8,shape);
2646 } else if (markerstyle == 36) {
2647 // square with diagonal cross
2648 shape[0].x = -im; shape[0].y = -im;
2649 shape[1].x = im; shape[1].y = -im;
2650 shape[2].x = im; shape[2].y = im;
2651 shape[3].x = -im; shape[3].y = im;
2652 shape[4].x = -im; shape[4].y = -im;
2653 shape[5].x = im; shape[5].y = im;
2654 shape[6].x = -im; shape[6].y = im;
2655 shape[7].x = im; shape[7].y = -im;
2656 SetMarkerType(2,8,shape);
2657 } else if (markerstyle == 37) {
2658 // open three triangles
2659 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
2660 shape[0].x = 0; shape[0].y = 0;
2661 shape[1].x =-im2; shape[1].y = im;
2662 shape[2].x = im2; shape[2].y = im;
2663 shape[3].x = 0; shape[3].y = 0;
2664 shape[4].x =-im2; shape[4].y = -im;
2665 shape[5].x = -im; shape[5].y = 0;
2666 shape[6].x = 0; shape[6].y = 0;
2667 shape[7].x = im; shape[7].y = 0;
2668 shape[8].x = im2; shape[8].y = -im;
2669 shape[9].x = 0; shape[9].y = 0;
2670 SetMarkerType(2, 10,shape);
2671 } else if (markerstyle == 38) {
2672 // + shaped marker with octagon
2673 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
2674 shape[0].x = -im; shape[0].y = 0;
2675 shape[1].x = -im; shape[1].y =-im2;
2676 shape[2].x =-im2; shape[2].y = -im;
2677 shape[3].x = im2; shape[3].y = -im;
2678 shape[4].x = im; shape[4].y =-im2;
2679 shape[5].x = im; shape[5].y = im2;
2680 shape[6].x = im2; shape[6].y = im;
2681 shape[7].x =-im2; shape[7].y = im;
2682 shape[8].x = -im; shape[8].y = im2;
2683 shape[9].x = -im; shape[9].y = 0;
2684 shape[10].x = im; shape[10].y = 0;
2685 shape[11].x = 0; shape[11].y = 0;
2686 shape[12].x = 0; shape[12].y = -im;
2687 shape[13].x = 0; shape[13].y = im;
2688 shape[14].x = 0; shape[14].y = 0;
2689 SetMarkerType(2,15,shape);
2690 } else if (markerstyle == 39) {
2691 // filled three triangles
2692 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
2693 shape[0].x = 0; shape[0].y = 0;
2694 shape[1].x =-im2; shape[1].y = im;
2695 shape[2].x = im2; shape[2].y = im;
2696 shape[3].x = 0; shape[3].y = 0;
2697 shape[4].x =-im2; shape[4].y = -im;
2698 shape[5].x = -im; shape[5].y = 0;
2699 shape[6].x = 0; shape[6].y = 0;
2700 shape[7].x = im; shape[7].y = 0;
2701 shape[8].x = im2; shape[8].y = -im;
2702 SetMarkerType(3,9,shape);
2703 } else if (markerstyle == 40) {
2704 // four open triangles X
2705 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
2706 shape[0].x = 0; shape[0].y = 0;
2707 shape[1].x = im2; shape[1].y = im;
2708 shape[2].x = im; shape[2].y = im2;
2709 shape[3].x = 0; shape[3].y = 0;
2710 shape[4].x = im; shape[4].y = -im2;
2711 shape[5].x = im2; shape[5].y = -im;
2712 shape[6].x = 0; shape[6].y = 0;
2713 shape[7].x = -im2; shape[7].y = -im;
2714 shape[8].x = -im; shape[8].y = -im2;
2715 shape[9].x = 0; shape[9].y = 0;
2716 shape[10].x = -im; shape[10].y = im2;
2717 shape[11].x = -im2; shape[11].y = im;
2718 shape[12].x = 0; shape[12].y = 0;
2719 SetMarkerType(2,13,shape);
2720 } else if (markerstyle == 41) {
2721 // four filled triangles X
2722 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
2723 shape[0].x = 0; shape[0].y = 0;
2724 shape[1].x = im2; shape[1].y = im;
2725 shape[2].x = im; shape[2].y = im2;
2726 shape[3].x = 0; shape[3].y = 0;
2727 shape[4].x = im; shape[4].y = -im2;
2728 shape[5].x = im2; shape[5].y = -im;
2729 shape[6].x = 0; shape[6].y = 0;
2730 shape[7].x = -im2; shape[7].y = -im;
2731 shape[8].x = -im; shape[8].y = -im2;
2732 shape[9].x = 0; shape[9].y = 0;
2733 shape[10].x = -im; shape[10].y = im2;
2734 shape[11].x = -im2; shape[11].y = im;
2735 shape[12].x = 0; shape[12].y = 0;
2736 SetMarkerType(3,13,shape);
2737 } else if (markerstyle == 42) {
2738 // open double diamonds
2740 shape[0].x= 0; shape[0].y= im;
2741 shape[1].x= -imx; shape[1].y= imx;
2742 shape[2].x = -im; shape[2].y = 0;
2743 shape[3].x = -imx; shape[3].y = -imx;
2744 shape[4].x = 0; shape[4].y = -im;
2745 shape[5].x = imx; shape[5].y = -imx;
2746 shape[6].x = im; shape[6].y = 0;
2747 shape[7].x= imx; shape[7].y= imx;
2748 shape[8].x= 0; shape[8].y= im;
2749 SetMarkerType(2,9,shape);
2750 } else if (markerstyle == 43) {
2751 // filled double diamonds
2753 shape[0].x = 0; shape[0].y = im;
2754 shape[1].x = -imx; shape[1].y = imx;
2755 shape[2].x = -im; shape[2].y = 0;
2756 shape[3].x = -imx; shape[3].y = -imx;
2757 shape[4].x = 0; shape[4].y = -im;
2758 shape[5].x = imx; shape[5].y = -imx;
2759 shape[6].x = im; shape[6].y = 0;
2760 shape[7].x = imx; shape[7].y = imx;
2761 shape[8].x = 0; shape[8].y = im;
2762 SetMarkerType(3,9,shape);
2763 } else if (markerstyle == 44) {
2764 // open four triangles plus
2765 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
2766 shape[0].x = 0; shape[0].y = 0;
2767 shape[1].x = im2; shape[1].y = im;
2768 shape[2].x = -im2; shape[2].y = im;
2769 shape[3].x = im2; shape[3].y = -im;
2770 shape[4].x = -im2; shape[4].y = -im;
2771 shape[5].x = 0; shape[5].y = 0;
2772 shape[6].x = im; shape[6].y = im2;
2773 shape[7].x = im; shape[7].y = -im2;
2774 shape[8].x = -im; shape[8].y = im2;
2775 shape[9].x = -im; shape[9].y = -im2;
2776 shape[10].x = 0; shape[10].y = 0;
2777 SetMarkerType(2,11,shape);
2778 } else if (markerstyle == 45) {
2779 // filled four triangles plus
2780 Int_t im0 = Int_t(0.4*MarkerSizeReduced + 0.5);
2781 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
2782 shape[0].x = im0; shape[0].y = im0;
2783 shape[1].x = im2; shape[1].y = im;
2784 shape[2].x = -im2; shape[2].y = im;
2785 shape[3].x = -im0; shape[3].y = im0;
2786 shape[4].x = -im; shape[4].y = im2;
2787 shape[5].x = -im; shape[5].y = -im2;
2788 shape[6].x = -im0; shape[6].y = -im0;
2789 shape[7].x = -im2; shape[7].y = -im;
2790 shape[8].x = im2; shape[8].y = -im;
2791 shape[9].x = im0; shape[9].y = -im0;
2792 shape[10].x = im; shape[10].y = -im2;
2793 shape[11].x = im; shape[11].y = im2;
2794 shape[12].x = im0; shape[12].y = im0;
2795 SetMarkerType(3,13,shape);
2796 } else if (markerstyle == 46) {
2797 // open four triangles X
2798 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
2799 shape[0].x = 0; shape[0].y = im2;
2800 shape[1].x = -im2; shape[1].y = im;
2801 shape[2].x = -im; shape[2].y = im2;
2802 shape[3].x = -im2; shape[3].y = 0;
2803 shape[4].x = -im; shape[4].y = -im2;
2804 shape[5].x = -im2; shape[5].y = -im;
2805 shape[6].x = 0; shape[6].y = -im2;
2806 shape[7].x = im2; shape[7].y = -im;
2807 shape[8].x = im; shape[8].y = -im2;
2808 shape[9].x = im2; shape[9].y = 0;
2809 shape[10].x = im; shape[10].y = im2;
2810 shape[11].x = im2; shape[11].y = im;
2811 shape[12].x = 0; shape[12].y = im2;
2812 SetMarkerType(2,13,shape);
2813 } else if (markerstyle == 47) {
2814 // filled four triangles X
2815 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
2816 shape[0].x = 0; shape[0].y = im2;
2817 shape[1].x = -im2; shape[1].y = im;
2818 shape[2].x = -im; shape[2].y = im2;
2819 shape[3].x = -im2; shape[3].y = 0;
2820 shape[4].x = -im; shape[4].y = -im2;
2821 shape[5].x = -im2; shape[5].y = -im;
2822 shape[6].x = 0; shape[6].y = -im2;
2823 shape[7].x = im2; shape[7].y = -im;
2824 shape[8].x = im; shape[8].y = -im2;
2825 shape[9].x = im2; shape[9].y = 0;
2826 shape[10].x = im; shape[10].y = im2;
2827 shape[11].x = im2; shape[11].y = im;
2828 shape[12].x = 0; shape[12].y = im2;
2829 SetMarkerType(3,13,shape);
2830 } else if (markerstyle == 48) {
2831 // four filled squares X
2832 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
2833 shape[0].x = 0; shape[0].y = im2*1.005;
2834 shape[1].x = -im2; shape[1].y = im;
2835 shape[2].x = -im; shape[2].y = im2;
2836 shape[3].x = -im2; shape[3].y = 0;
2837 shape[4].x = -im; shape[4].y = -im2;
2838 shape[5].x = -im2; shape[5].y = -im;
2839 shape[6].x = 0; shape[6].y = -im2;
2840 shape[7].x = im2; shape[7].y = -im;
2841 shape[8].x = im; shape[8].y = -im2;
2842 shape[9].x = im2; shape[9].y = 0;
2843 shape[10].x = im; shape[10].y = im2;
2844 shape[11].x = im2; shape[11].y = im;
2845 shape[12].x = 0; shape[12].y = im2*0.995;
2846 shape[13].x = im2*0.995; shape[13].y = 0;
2847 shape[14].x = 0; shape[14].y = -im2*0.995;
2848 shape[15].x = -im2*0.995; shape[15].y = 0;
2849 shape[16].x = 0; shape[16].y = im2*0.995;
2850 SetMarkerType(3,16,shape);
2851 } else if (markerstyle == 49) {
2852 // four filled squares plus
2853 Int_t imx = Int_t(1.33*MarkerSizeReduced + 0.5);
2854 shape[0].x =-imx; shape[0].y =-imx*1.005;
2855 shape[1].x =-imx; shape[1].y = -im;
2856 shape[2].x = imx; shape[2].y = -im;
2857 shape[3].x = imx; shape[3].y =-imx;
2858 shape[4].x = im; shape[4].y =-imx;
2859 shape[5].x = im; shape[5].y = imx;
2860 shape[6].x = imx; shape[6].y = imx;
2861 shape[7].x = imx; shape[7].y = im;
2862 shape[8].x =-imx; shape[8].y = im;
2863 shape[9].x =-imx; shape[9].y = imx;
2864 shape[10].x = -im; shape[10].y = imx;
2865 shape[11].x = -im; shape[11].y =-imx;
2866 shape[12].x =-imx; shape[12].y =-imx*0.995;
2867 shape[13].x =-imx; shape[13].y = imx;
2868 shape[14].x = imx; shape[14].y = imx;
2869 shape[15].x = imx; shape[15].y =-imx;
2870 shape[16].x =-imx; shape[16].y =-imx*1.005;
2871 SetMarkerType(3,17,shape);
2872 } else {
2873 // single dot
2874 SetMarkerType(0,0,shape);
2875 }
2876}
2877
2878////////////////////////////////////////////////////////////////////////////////
2879/// Set opacity of a window. This image manipulation routine works
2880/// by adding to a percent amount of neutral to each pixels RGB.
2881/// Since it requires quite some additional color map entries is it
2882/// only supported on displays with more than > 8 color planes (> 256
2883/// colors).
2884
2886{
2887 if (fDepth <= 8) return;
2888 if (percent == 0) return;
2889 // if 100 percent then just make white
2890
2891 ULong_t *orgcolors = nullptr, *tmpc = nullptr;
2892 Int_t maxcolors = 0, ncolors = 0, ntmpc = 0;
2893
2894 // save previous allocated colors, delete at end when not used anymore
2895 if (gCws->fNewColors) {
2896 tmpc = gCws->fNewColors;
2897 ntmpc = gCws->fNcolors;
2898 }
2899
2900 // get pixmap from server as image
2901 XImage *image = XGetImage((Display*)fDisplay, gCws->fDrawing, 0, 0, gCws->fWidth,
2902 gCws->fHeight, AllPlanes, ZPixmap);
2903 if (!image) return;
2904 // collect different image colors
2905 int x, y;
2906 for (y = 0; y < (int) gCws->fHeight; y++) {
2907 for (x = 0; x < (int) gCws->fWidth; x++) {
2910 }
2911 }
2912 if (ncolors == 0) {
2914 ::operator delete(orgcolors);
2915 return;
2916 }
2917
2918 // create opaque counter parts
2920
2921 if (gCws->fNewColors) {
2922 // put opaque colors in image
2923 for (y = 0; y < (int) gCws->fHeight; y++) {
2924 for (x = 0; x < (int) gCws->fWidth; x++) {
2926 Int_t idx = FindColor(pixel, orgcolors, ncolors);
2927 XPutPixel(image, x, y, gCws->fNewColors[idx]);
2928 }
2929 }
2930 }
2931
2932 // put image back in pixmap on server
2933 XPutImage((Display*)fDisplay, gCws->fDrawing, *gGCpxmp, image, 0, 0, 0, 0,
2934 gCws->fWidth, gCws->fHeight);
2935 XFlush((Display*)fDisplay);
2936
2937 // clean up
2938 if (tmpc) {
2939 if (fRedDiv == -1)
2940 XFreeColors((Display*)fDisplay, fColormap, tmpc, ntmpc, 0);
2941 delete [] tmpc;
2942 }
2944 ::operator delete(orgcolors);
2945}
2946
2947////////////////////////////////////////////////////////////////////////////////
2948/// Collect in orgcolors all different original image colors.
2949
2952{
2953 if (maxcolors == 0) {
2954 ncolors = 0;
2955 maxcolors = 100;
2956 orgcolors = (ULong_t*) ::operator new(maxcolors*sizeof(ULong_t));
2957 }
2958
2959 for (int i = 0; i < ncolors; i++)
2960 if (pixel == orgcolors[i]) return;
2961
2962 if (ncolors >= maxcolors) {
2964 maxcolors*2*sizeof(ULong_t), maxcolors*sizeof(ULong_t));
2965 maxcolors *= 2;
2966 }
2967
2968 orgcolors[ncolors++] = pixel;
2969}
2970
2971////////////////////////////////////////////////////////////////////////////////
2972/// Get RGB values for orgcolors, add percent neutral to the RGB and
2973/// allocate fNewColors.
2974
2976{
2977 if (ncolors == 0) return;
2978
2979 RXColor *xcol = new RXColor[ncolors];
2980
2981 int i;
2982 for (i = 0; i < ncolors; i++) {
2983 xcol[i].pixel = orgcolors[i];
2984 xcol[i].red = xcol[i].green = xcol[i].blue = 0;
2985 xcol[i].flags = DoRed | DoGreen | DoBlue;
2986 }
2987 QueryColors(fColormap, xcol, ncolors);
2988
2989 UShort_t add = percent * kBIGGEST_RGB_VALUE / 100;
2990
2991 Int_t val;
2992 for (i = 0; i < ncolors; i++) {
2993 val = xcol[i].red + add;
2994 if (val > kBIGGEST_RGB_VALUE) val = kBIGGEST_RGB_VALUE;
2995 xcol[i].red = (UShort_t) val;
2996 val = xcol[i].green + add;
2997 if (val > kBIGGEST_RGB_VALUE) val = kBIGGEST_RGB_VALUE;
2998 xcol[i].green = (UShort_t) val;
2999 val = xcol[i].blue + add;
3000 if (val > kBIGGEST_RGB_VALUE) val = kBIGGEST_RGB_VALUE;
3001 xcol[i].blue = (UShort_t) val;
3002 if (!AllocColor(fColormap, &xcol[i]))
3003 Warning("MakeOpaqueColors", "failed to allocate color %hd, %hd, %hd",
3004 xcol[i].red, xcol[i].green, xcol[i].blue);
3005 // assumes that in case of failure xcol[i].pixel is not changed
3006 }
3007
3008 gCws->fNewColors = new ULong_t[ncolors];
3009 gCws->fNcolors = ncolors;
3010
3011 for (i = 0; i < ncolors; i++)
3012 gCws->fNewColors[i] = xcol[i].pixel;
3013
3014 delete [] xcol;
3015}
3016
3017////////////////////////////////////////////////////////////////////////////////
3018/// Returns index in orgcolors (and fNewColors) for pixel.
3019
3021{
3022 for (int i = 0; i < ncolors; i++)
3023 if (pixel == orgcolors[i]) return i;
3024
3025 Error("FindColor", "did not find color, should never happen!");
3026
3027 return 0;
3028}
3029
3030////////////////////////////////////////////////////////////////////////////////
3031/// Set color intensities for given color index.
3032///
3033/// \param [in] cindex : color index
3034/// \param [in] r,g,b : red, green, blue intensities between 0.0 and 1.0
3035
3036void TGX11::SetRGB(int cindex, float r, float g, float b)
3037{
3038 if (fColormap) {
3039 RXColor xcol;
3040 xcol.red = (UShort_t)(r * kBIGGEST_RGB_VALUE);
3041 xcol.green = (UShort_t)(g * kBIGGEST_RGB_VALUE);
3042 xcol.blue = (UShort_t)(b * kBIGGEST_RGB_VALUE);
3043 xcol.flags = DoRed | DoGreen | DoBlue;
3044 XColor_t &col = GetColor(cindex);
3045 if (col.fDefined) {
3046 // if color is already defined with same rgb just return
3047 if (col.fRed == xcol.red && col.fGreen == xcol.green &&
3048 col.fBlue == xcol.blue)
3049 return;
3050 col.fDefined = kFALSE;
3051 if (fRedDiv == -1)
3052 XFreeColors((Display*)fDisplay, fColormap, &col.fPixel, 1, 0);
3053 }
3054 if (AllocColor(fColormap, &xcol)) {
3055 col.fDefined = kTRUE;
3056 col.fPixel = xcol.pixel;
3057 col.fRed = xcol.red;
3058 col.fGreen = xcol.green;
3059 col.fBlue = xcol.blue;
3060 }
3061 }
3062}
3063
3064////////////////////////////////////////////////////////////////////////////////
3065/// Set text alignment.
3066///
3067/// \param [in] talign text alignment
3068
3070{
3071 Int_t txalh = talign/10;
3072 Int_t txalv = talign%10;
3075
3076 switch (txalh) {
3077
3078 case 0 :
3079 case 1 :
3080 switch (txalv) { //left
3081 case 1 :
3082 fTextAlign = 7; //bottom
3083 break;
3084 case 2 :
3085 fTextAlign = 4; //center
3086 break;
3087 case 3 :
3088 fTextAlign = 1; //top
3089 break;
3090 }
3091 break;
3092 case 2 :
3093 switch (txalv) { //center
3094 case 1 :
3095 fTextAlign = 8; //bottom
3096 break;
3097 case 2 :
3098 fTextAlign = 5; //center
3099 break;
3100 case 3 :
3101 fTextAlign = 2; //top
3102 break;
3103 }
3104 break;
3105 case 3 :
3106 switch (txalv) { //right
3107 case 1 :
3108 fTextAlign = 9; //bottom
3109 break;
3110 case 2 :
3111 fTextAlign = 6; //center
3112 break;
3113 case 3 :
3114 fTextAlign = 3; //top
3115 break;
3116 }
3117 break;
3118 }
3119
3121}
3122
3123////////////////////////////////////////////////////////////////////////////////
3124/// Set color index for text.
3125
3127{
3128 if (cindex < 0) return;
3129
3131
3133
3134 XGCValues values;
3135 if (XGetGCValues((Display*)fDisplay, *gGCtext, GCForeground | GCBackground, &values)) {
3136 XSetForeground( (Display*)fDisplay, *gGCinvt, values.background );
3137 XSetBackground( (Display*)fDisplay, *gGCinvt, values.foreground );
3138 } else {
3139 Error("SetTextColor", "cannot get GC values");
3140 }
3141 XSetBackground((Display*)fDisplay, *gGCtext, GetColor(0).fPixel);
3142}
3143
3144////////////////////////////////////////////////////////////////////////////////
3145/// Set text font to specified name.
3146///
3147/// \param [in] fontname font name
3148/// \param [in] mode loading flag
3149/// - mode=0 search if the font exist (kCheck)
3150/// - mode=1 search the font and load it if it exists (kLoad)
3151///
3152/// Set text font to specified name. This function returns 0 if
3153/// the specified font is found, 1 if not.
3154
3156{
3157 char **fontlist;
3158 int fontcount;
3159 int i;
3160
3161 if (mode == kLoad) {
3162 for (i = 0; i < kMAXFONT; i++) {
3163 if (strcmp(fontname, gFont[i].name) == 0) {
3164 gTextFont = gFont[i].id;
3165 XSetFont((Display*)fDisplay, *gGCtext, gTextFont->fid);
3166 XSetFont((Display*)fDisplay, *gGCinvt, gTextFont->fid);
3167 return 0;
3168 }
3169 }
3170 }
3171
3172 fontlist = XListFonts((Display*)fDisplay, fontname, 1, &fontcount);
3173
3174 if (fontlist && fontcount != 0) {
3175 if (mode == kLoad) {
3176 if (gFont[gCurrentFontNumber].id)
3178 gTextFont = XLoadQueryFont((Display*)fDisplay, fontlist[0]);
3179 XSetFont((Display*)fDisplay, *gGCtext, gTextFont->fid);
3180 XSetFont((Display*)fDisplay, *gGCinvt, gTextFont->fid);
3185 }
3187 return 0;
3188 } else {
3189 return 1;
3190 }
3191}
3192
3193////////////////////////////////////////////////////////////////////////////////
3194/// Set current text font number.
3195
3200
3201////////////////////////////////////////////////////////////////////////////////
3202/// Set current text size.
3203
3208
3209////////////////////////////////////////////////////////////////////////////////
3210/// Set synchronisation on or off.
3211///
3212/// \param [in] mode : synchronisation on/off
3213/// - mode=1 on
3214/// - mode<>0 off
3215
3217{
3218 switch (mode) {
3219
3220 case 1 :
3221 XSynchronize((Display*)fDisplay,1);
3222 break;
3223
3224 default:
3225 XSynchronize((Display*)fDisplay,0);
3226 break;
3227 }
3228}
3229
3230////////////////////////////////////////////////////////////////////////////////
3231/// Update display.
3232///
3233/// \param [in] mode : (1) update (0) sync
3234///
3235/// Synchronise client and server once (not permanent).
3236/// Copy the pixmap gCws->fDrawing on the window gCws->fWindow
3237/// if the double buffer is on.
3238
3240{
3241 if (gCws->fDoubleBuffer) {
3242 XCopyArea((Display*)fDisplay, gCws->fDrawing, gCws->fWindow,
3243 *gGCpxmp, 0, 0, gCws->fWidth, gCws->fHeight, 0, 0);
3244 }
3245 if (mode == 1) {
3246 XFlush((Display*)fDisplay);
3247 } else {
3248 XSync((Display*)fDisplay, False);
3249 }
3250}
3251
3252////////////////////////////////////////////////////////////////////////////////
3253/// Set pointer position.
3254///
3255/// \param [in] ix New X coordinate of pointer
3256/// \param [in] iy New Y coordinate of pointer
3257/// \param [in] id Window identifier
3258///
3259/// Coordinates are relative to the origin of the window id
3260/// or to the origin of the current window if id == 0.
3261
3263{
3264 if (!id) {
3265 // Causes problems when calling ProcessEvents()... BadWindow
3266 //XWarpPointer((Display*)fDisplay, None, gCws->fWindow, 0, 0, 0, 0, ix, iy);
3267 } else {
3268 XWarpPointer((Display*)fDisplay, None, (Window) id, 0, 0, 0, 0, ix, iy);
3269 }
3270}
3271
3272////////////////////////////////////////////////////////////////////////////////
3273/// Write the pixmap wid in the bitmap file pxname.
3274///
3275/// \param [in] wid : Pixmap address
3276/// \param [in] w,h : Width and height of the pixmap.
3277/// \param [in] pxname : pixmap name
3278
3279void TGX11::WritePixmap(int wid, unsigned int w, unsigned int h, char *pxname)
3280{
3281 unsigned int wval, hval;
3282 wval = w;
3283 hval = h;
3284
3285 gTws = &fWindows[wid];
3286 XWriteBitmapFile((Display*)fDisplay, pxname, gTws->fDrawing, wval, hval, -1, -1);
3287}
3288
3289
3290//
3291// Functions for GIFencode()
3292//
3293
3294static FILE *gOut; // output unit used WriteGIF and PutByte
3295static XImage *gXimage = nullptr; // image used in WriteGIF and GetPixel
3296
3297extern "C" {
3300 long GIFencode(int Width, int Height, Int_t Ncol, Byte_t R[], Byte_t G[], Byte_t B[], Byte_t ScLine[],
3301 void (*get_scline) (int, int, Byte_t *), void (*pb)(Byte_t));
3302 int GIFdecode(Byte_t *gifArr, Byte_t *pixArr, int *Width, int *Height, int *Ncols, Byte_t *R, Byte_t *G, Byte_t *B);
3303 int GIFinfo(Byte_t *gifArr, int *Width, int *Height, int *Ncols);
3304}
3305
3306////////////////////////////////////////////////////////////////////////////////
3307/// Get pixels in line y and put in array scline.
3308
3309static void GetPixel(int y, int width, Byte_t *scline)
3310{
3311 for (int i = 0; i < width; i++)
3312 scline[i] = Byte_t(XGetPixel(gXimage, i, y));
3313}
3314
3315////////////////////////////////////////////////////////////////////////////////
3316/// Put byte b in output stream.
3317
3318static void PutByte(Byte_t b)
3319{
3320 if (ferror(gOut) == 0) fputc(b, gOut);
3321}
3322
3323////////////////////////////////////////////////////////////////////////////////
3324/// Returns in R G B the ncol colors of the palette used by the image.
3325/// The image pixels are changed to index values in these R G B arrays.
3326/// This produces a colormap with only the used colors (so even on displays
3327/// with more than 8 planes we will be able to create GIF's when the image
3328/// contains no more than 256 different colors). If it does contain more
3329/// colors we will have to use GIFquantize to reduce the number of colors.
3330/// The R G B arrays must be deleted by the caller.
3331
3333{
3334 ULong_t *orgcolors = nullptr;
3335 Int_t maxcolors = 0, ncolors = 0;
3336
3337 // collect different image colors
3338 int x, y;
3339 for (x = 0; x < (int) gCws->fWidth; x++) {
3340 for (y = 0; y < (int) gCws->fHeight; y++) {
3343 }
3344 }
3345
3346 // get RGB values belonging to pixels
3347 RXColor *xcol = new RXColor[ncolors];
3348
3349 int i;
3350 for (i = 0; i < ncolors; i++) {
3351 xcol[i].pixel = orgcolors[i];
3352 xcol[i].red = xcol[i].green = xcol[i].blue = 0;
3353 xcol[i].flags = DoRed | DoGreen | DoBlue;
3354 }
3355 QueryColors(fColormap, xcol, ncolors);
3356
3357 // create RGB arrays and store RGB's for each color and set number of colors
3358 // (space must be delete by caller)
3359 R = new Int_t[ncolors];
3360 G = new Int_t[ncolors];
3361 B = new Int_t[ncolors];
3362
3363 for (i = 0; i < ncolors; i++) {
3364 R[i] = xcol[i].red;
3365 G[i] = xcol[i].green;
3366 B[i] = xcol[i].blue;
3367 }
3368 ncol = ncolors;
3369
3370 // update image with indices (pixels) into the new RGB colormap
3371 for (x = 0; x < (int) gCws->fWidth; x++) {
3372 for (y = 0; y < (int) gCws->fHeight; y++) {
3374 Int_t idx = FindColor(pixel, orgcolors, ncolors);
3375 XPutPixel(image, x, y, idx);
3376 }
3377 }
3378
3379 // cleanup
3380 delete [] xcol;
3381 ::operator delete(orgcolors);
3382}
3383
3384////////////////////////////////////////////////////////////////////////////////
3385/// Writes the current window into GIF file. Returns 1 in case of success,
3386/// 0 otherwise.
3387
3389{
3390 Byte_t scline[2000], r[256], b[256], g[256];
3391 Int_t *red, *green, *blue;
3392 Int_t ncol, maxcol, i;
3393
3394 if (gXimage) {
3396 gXimage = nullptr;
3397 }
3398
3399 gXimage = XGetImage((Display*)fDisplay, gCws->fDrawing, 0, 0,
3400 gCws->fWidth, gCws->fHeight,
3402
3404
3405 if (ncol > 256) {
3406 //GIFquantize(...);
3407 Error("WriteGIF", "Cannot create GIF of image containing more than 256 colors. Try in batch mode.");
3408 delete [] red;
3409 delete [] green;
3410 delete [] blue;
3411 return 0;
3412 }
3413
3414 maxcol = 0;
3415 for (i = 0; i < ncol; i++) {
3416 if (maxcol < red[i] ) maxcol = red[i];
3417 if (maxcol < green[i] ) maxcol = green[i];
3418 if (maxcol < blue[i] ) maxcol = blue[i];
3419 r[i] = 0;
3420 g[i] = 0;
3421 b[i] = 0;
3422 }
3423 if (maxcol != 0) {
3424 for (i = 0; i < ncol; i++) {
3425 r[i] = red[i] * 255/maxcol;
3426 g[i] = green[i] * 255/maxcol;
3427 b[i] = blue[i] * 255/maxcol;
3428 }
3429 }
3430
3431 gOut = fopen(name, "w+");
3432
3433 if (gOut) {
3434 GIFencode(gCws->fWidth, gCws->fHeight,
3435 ncol, r, g, b, scline, ::GetPixel, PutByte);
3436 fclose(gOut);
3437 i = 1;
3438 } else {
3439 Error("WriteGIF","cannot write file: %s",name);
3440 i = 0;
3441 }
3442 delete [] red;
3443 delete [] green;
3444 delete [] blue;
3445 return i;
3446}
3447
3448////////////////////////////////////////////////////////////////////////////////
3449/// Draw image.
3450
3453{
3454 const int maxSegment = 20;
3455 int i, n, x, y, xcur, x1, x2, y1, y2;
3456 unsigned char *jimg, *jbase, icol;
3457 int nlines[256];
3459 Drawable_t id;
3460
3461 if (wid) {
3462 id = wid;
3463 } else {
3464 id = gCws->fDrawing;
3465 }
3466
3467 for (i = 0; i < 256; i++) nlines[i] = 0;
3468
3469 x1 = x0 + xmin; y1 = y0 + ny - ymax - 1;
3470 x2 = x0 + xmax; y2 = y0 + ny - ymin - 1;
3471 jbase = image + (ymin-1)*nx + xmin;
3472
3473 for (y = y2; y >= y1; y--) {
3474 xcur = x1; jbase += nx;
3475 for (jimg = jbase, icol = *jimg++, x = x1+1; x <= x2; jimg++, x++) {
3476 if (icol != *jimg) {
3477 if (icol != itran) {
3478 n = nlines[icol]++;
3479 lines[icol][n].x1 = xcur; lines[icol][n].y1 = y;
3480 lines[icol][n].x2 = x-1; lines[icol][n].y2 = y;
3481 if (nlines[icol] == maxSegment) {
3483 XDrawSegments((Display*)fDisplay,id,*gGCline,&lines[icol][0],
3484 maxSegment);
3485 nlines[icol] = 0;
3486 }
3487 }
3488 icol = *jimg; xcur = x;
3489 }
3490 }
3491 if (icol != itran) {
3492 n = nlines[icol]++;
3493 lines[icol][n].x1 = xcur; lines[icol][n].y1 = y;
3494 lines[icol][n].x2 = x-1; lines[icol][n].y2 = y;
3495 if (nlines[icol] == maxSegment) {
3497 XDrawSegments((Display*)fDisplay,id,*gGCline,&lines[icol][0],
3498 maxSegment);
3499 nlines[icol] = 0;
3500 }
3501 }
3502 }
3503
3504 for (i = 0; i < 256; i++) {
3505 if (nlines[i] != 0) {
3507 XDrawSegments((Display*)fDisplay,id,*gGCline,&lines[i][0],nlines[i]);
3508 }
3509 }
3510}
3511
3512////////////////////////////////////////////////////////////////////////////////
3513/// If id is NULL - loads the specified gif file at position [x0,y0] in the
3514/// current window. Otherwise creates pixmap from gif file
3515
3516Pixmap_t TGX11::ReadGIF(int x0, int y0, const char *file, Window_t id)
3517{
3518 FILE *fd;
3519 Seek_t filesize = 0;
3520 unsigned char *gifArr, *pixArr, red[256], green[256], blue[256], *j1, *j2, icol;
3521 int i, j, k, width, height, ncolor, irep, offset;
3522 float rr, gg, bb;
3523 Pixmap_t pic = 0;
3524
3525 fd = fopen(file, "r");
3526 if (!fd) {
3527 Error("ReadGIF", "unable to open GIF file");
3528 return pic;
3529 }
3530
3531 fseek(fd, 0L, 2);
3532 long ft = ftell(fd);
3533 if (ft <=0) {
3534 Error("ReadGIF", "unable to open GIF file");
3535 fclose(fd);
3536 return pic;
3537 } else {
3538 filesize = Seek_t(ft);
3539 }
3540 fseek(fd, 0L, 0);
3541
3542 if (!(gifArr = (unsigned char *) calloc(filesize+256,1))) {
3543 Error("ReadGIF", "unable to allocate array for gif");
3544 fclose(fd);
3545 return pic;
3546 }
3547
3548 if (fread(gifArr, filesize, 1, fd) != 1) {
3549 Error("ReadGIF", "GIF file read failed");
3550 free(gifArr);
3551 fclose(fd);
3552 return pic;
3553 }
3554 fclose(fd);
3555
3557 if (irep != 0) {
3558 free(gifArr);
3559 return pic;
3560 }
3561
3562 if (!(pixArr = (unsigned char *) calloc((width*height),1))) {
3563 Error("ReadGIF", "unable to allocate array for image");
3564 free(gifArr);
3565 return pic;
3566 }
3567
3569 if (irep != 0) {
3570 free(gifArr);
3571 free(pixArr);
3572 return pic;
3573 }
3574
3575 // S E T P A L E T T E
3576
3577 offset = 8;
3578
3579 for (i = 0; i < ncolor; i++) {
3580 rr = red[i]/255.;
3581 gg = green[i]/255.;
3582 bb = blue[i]/255.;
3583 j = i+offset;
3584 SetRGB(j,rr,gg,bb);
3585 }
3586
3587 // O U T P U T I M A G E
3588
3589 for (i = 1; i <= height/2; i++) {
3590 j1 = pixArr + (i-1)*width;
3591 j2 = pixArr + (height-i)*width;
3592 for (k = 0; k < width; k++) {
3593 icol = *j1; *j1++ = *j2; *j2++ = icol;
3594 }
3595 }
3596 if (id) pic = CreatePixmap(id, width, height);
3598
3599 free(gifArr);
3600 free(pixArr);
3601
3602 if (pic)
3603 return pic;
3604 else if (gCws->fDrawing)
3605 return (Pixmap_t)gCws->fDrawing;
3606 return 0;
3607}
3608
3609////////////////////////////////////////////////////////////////////////////////
3610/// Returns an array of pixels created from a part of drawable
3611/// (defined by x, y, w, h) in format:
3612/// `b1, g1, r1, 0, b2, g2, r2, 0, ..., bn, gn, rn, 0`.
3613///
3614/// Pixels are numbered from left to right and from top to bottom.
3615/// By default all pixels from the whole drawable are returned.
3616///
3617/// Note that return array is 32-bit aligned
3618
3619unsigned char *TGX11::GetColorBits(Drawable_t /*wid*/, Int_t /*x*/, Int_t /*y*/,
3620 UInt_t /*w*/, UInt_t /*h*/)
3621{
3622 return nullptr;
3623}
3624
3625////////////////////////////////////////////////////////////////////////////////
3626/// create pixmap from RGB data. RGB data is in format :
3627/// b1, g1, r1, 0, b2, g2, r2, 0 ... bn, gn, rn, 0 ..
3628///
3629/// Pixels are numbered from left to right and from top to bottom.
3630/// Note that data must be 32-bit aligned
3631
3632Pixmap_t TGX11::CreatePixmapFromData(unsigned char * /*bits*/, UInt_t /*width*/,
3633 UInt_t /*height*/)
3634{
3635 return (Pixmap_t)0;
3636}
3637
3638////////////////////////////////////////////////////////////////////////////////
3639/// Register pixmap created by gVirtualGL
3640///
3641/// \param [in] pixid Pixmap identifier
3642/// \param [in] w,h Width and height of the pixmap
3643///
3644/// register new pixmap
3645
3647{
3648 Int_t wid = 0;
3649
3650 // Select next free window number
3651 for (; wid < fMaxNumberOfWindows; ++wid)
3652 if (!fWindows[wid].fOpen)
3653 break;
3654
3655 if (wid == fMaxNumberOfWindows) {
3658 fWindows, newsize * sizeof(XWindow_t),
3660 );
3661
3662 for (Int_t i = fMaxNumberOfWindows; i < newsize; ++i)
3663 fWindows[i].fOpen = 0;
3664
3666 }
3667
3668 fWindows[wid].fOpen = 1;
3669 gCws = fWindows + wid;
3670 gCws->fWindow = pixid;
3671 gCws->fDrawing = gCws->fWindow;
3672 gCws->fBuffer = 0;
3673 gCws->fDoubleBuffer = 0;
3674 gCws->fIsPixmap = 1;
3675 gCws->fClip = 0;
3676 gCws->fWidth = w;
3677 gCws->fHeight = h;
3678 gCws->fNewColors = nullptr;
3679 gCws->fShared = kFALSE;
3680
3681 return wid;
3682}
3683
3684////////////////////////////////////////////////////////////////////////////////
3685/// Returns 1 if window system server supports extension given by the
3686/// argument, returns 0 in case extension is not supported and returns -1
3687/// in case of error (like server not initialized).
3688/// Examples:
3689/// - "Apple-WM" - does server run on MacOS X;
3690/// - "XINERAMA" - does server support Xinerama.
3691/// See also the output of xdpyinfo.
3692
3694{
3696 if (!(Display*)fDisplay)
3697 return -1;
3699}
ECursor
Definition GuiTypes.h:372
@ kRightSide
Definition GuiTypes.h:373
@ kBottomSide
Definition GuiTypes.h:373
@ kArrowRight
Definition GuiTypes.h:375
@ kTopLeft
Definition GuiTypes.h:372
@ kBottomRight
Definition GuiTypes.h:372
@ kArrowVer
Definition GuiTypes.h:374
@ kCaret
Definition GuiTypes.h:375
@ kTopSide
Definition GuiTypes.h:373
@ kLeftSide
Definition GuiTypes.h:373
@ kWatch
Definition GuiTypes.h:375
@ kMove
Definition GuiTypes.h:374
@ kTopRight
Definition GuiTypes.h:372
@ kBottomLeft
Definition GuiTypes.h:372
@ kHand
Definition GuiTypes.h:374
@ kCross
Definition GuiTypes.h:374
@ kRotate
Definition GuiTypes.h:374
@ kNoDrop
Definition GuiTypes.h:375
@ kArrowHor
Definition GuiTypes.h:374
@ kPointer
Definition GuiTypes.h:375
Handle_t Pixmap_t
Pixmap handle.
Definition GuiTypes.h:30
Handle_t Window_t
Window handle.
Definition GuiTypes.h:29
Handle_t Drawable_t
Drawable handle.
Definition GuiTypes.h:31
const int kNumCursors
Definition GuiTypes.h:371
#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:1335
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 pix
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 SetMarkerStyle
Option_t Option_t width
Option_t Option_t TPoint TPoint percent
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 ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
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:1335
static Int_t gFillHollow
Definition TGX11.cxx:101
static int gMarkerJoinStyle
Definition TGX11.cxx:128
static FILE * gOut
Definition TGX11.cxx:3294
static int gMarkerLineStyle
Definition TGX11.cxx:126
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:149
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:135
static GC * gGCfill
Definition TGX11.cxx:93
static GC gGCecho
Definition TGX11.cxx:99
XFontStruct * id
Definition TGX11.cxx:109
static GC * gGCinvt
Definition TGX11.cxx:95
static void GetPixel(int y, int width, Byte_t *scline)
Get pixels in line y and put in array scline.
Definition TGX11.cxx:3309
static Pixmap gFillPattern
Definition TGX11.cxx:102
static Cursor gNullCursor
Definition TGX11.cxx:159
char name[80]
Definition TGX11.cxx:110
static XWindow_t * gTws
Definition TGX11.cxx:82
static struct @57 gMarker
const int kMAXGC
Definition TGX11.cxx:89
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:107
static int gLineStyle
Definition TGX11.cxx:134
const char null_cursor_bits[]
Definition TGX11.cxx:155
int XRotDrawString(Display *, XFontStruct *, float, Drawable, GC, int, int, char *)
A front end to XRotPaintAlignedString: -no alignment, no background.
Definition Rotated.cxx:283
int n
Definition TGX11.cxx:122
static char gDashList[10]
Definition TGX11.cxx:137
static int gDashOffset
Definition TGX11.cxx:139
const Int_t kBIGGEST_RGB_VALUE
Definition TGX11.cxx:84
const Int_t kMAXMK
Definition TGX11.cxx:119
static void PutByte(Byte_t b)
Put byte b in output stream.
Definition TGX11.cxx:3318
static GC * gGCpxmp
Definition TGX11.cxx:97
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))
static GC * gGCline
Definition TGX11.cxx:91
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:145
static Int_t gCurrentFontNumber
Definition TGX11.cxx:114
static int gJoinStyle
Definition TGX11.cxx:136
static GC gGClist[kMAXGC]
Definition TGX11.cxx:90
static int gMarkerLineWidth
Definition TGX11.cxx:125
static int gDashLength
Definition TGX11.cxx:138
static GC * gGCdash
Definition TGX11.cxx:96
static GC * gGCmark
Definition TGX11.cxx:92
int type
Definition TGX11.cxx:121
static GC * gGCtext
Definition TGX11.cxx:94
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
static int gDashSize
Definition TGX11.cxx:140
static int gLineWidth
Definition TGX11.cxx:133
static XImage * gXimage
Definition TGX11.cxx:3295
XPoint xy[kMAXMK]
Definition TGX11.cxx:123
static int gMarkerCapStyle
Definition TGX11.cxx:127
static XFontStruct * gTextFont
Definition TGX11.cxx:113
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:840
static XWindow_t * gCws
Definition TGX11.cxx:81
int GIFinfo(Byte_t *gifArr, int *Width, int *Height, int *Ncols)
Definition gifdecode.c:80
XID Colormap
Definition TGX11.h:35
XID Window
Definition TGX11.h:36
XID Drawable
Definition TGX11.h:33
XID Cursor
Definition TGX11.h:34
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:411
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
virtual Color_t GetFillColor() const
Return the fill area color.
Definition TAttFill.h:31
Style_t fFillStyle
Fill area style.
Definition TAttFill.h:24
Color_t fFillColor
Fill area color.
Definition TAttFill.h:23
Width_t fLineWidth
Line width.
Definition TAttLine.h:25
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition TAttLine.h:42
Style_t fLineStyle
Line style.
Definition TAttLine.h:24
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
Definition TAttMarker.h:39
static Width_t GetMarkerLineWidth(Style_t style)
Internal helper function that returns the line width of the given marker style (0 = filled marker)
Size_t fMarkerSize
Marker size.
Definition TAttMarker.h:25
Style_t fMarkerStyle
Marker style.
Definition TAttMarker.h:24
static Style_t GetMarkerStyleBase(Style_t style)
Internal helper function that returns the corresponding marker style with line width 1 for the given ...
virtual void SetTextAlign(Short_t align=11)
Set the text alignment.
Definition TAttText.h:44
Float_t fTextAngle
Text angle.
Definition TAttText.h:23
virtual void SetTextColor(Color_t tcolor=1)
Set the text color.
Definition TAttText.h:46
Font_t fTextFont
Text font.
Definition TAttText.h:27
Float_t fTextSize
Text size.
Definition TAttText.h:24
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:505
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:80
void DrawFillArea(Int_t n, TPoint *xy) override
Fill area described by polygon.
Definition TGX11.cxx:590
void * fDisplay
Pointer to display.
Definition TGX11.h:125
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:2975
void SetLineColor(Color_t cindex) override
Set color index for lines.
Definition TGX11.cxx:2277
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:962
Colormap fColormap
Default colormap, 0 if b/w.
Definition TGX11.h:129
Window_t GetWindowID(Int_t wid) override
Return the X11 window identifier.
Definition TGX11.cxx:1069
Int_t WriteGIF(char *name) override
Writes the current window into GIF file.
Definition TGX11.cxx:3388
void SetFillColor(Color_t cindex) override
Set color index for fill areas.
Definition TGX11.cxx:2184
void ResizeWindow(Int_t wid) override
Resize the current window if necessary.
Definition TGX11.cxx:1920
void SetTextAlign(Short_t talign=11) override
Set text alignment.
Definition TGX11.cxx:3069
void RescaleWindow(Int_t wid, UInt_t w, UInt_t h) override
Rescale the window wid.
Definition TGX11.cxx:1842
void SetCursor(Int_t win, ECursor cursor) override
Set the cursor.
Definition TGX11.cxx:2077
Int_t fScreenNumber
Screen number.
Definition TGX11.h:132
void Sync(Int_t mode) override
Set synchronisation on or off.
Definition TGX11.cxx:3216
Pixmap_t CreatePixmapFromData(unsigned char *bits, UInt_t width, UInt_t height) override
create pixmap from RGB data.
Definition TGX11.cxx:3632
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:3619
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:2950
ULong_t fWhitePixel
Value of white pixel in colormap.
Definition TGX11.h:131
Cursor fCursors[kNumCursors]
List of cursors.
Definition TGX11.h:86
Bool_t AllocColor(Colormap cmap, RXColor *color)
Allocate color in colormap.
Definition TGX11.cxx:365
Int_t fTextAlignV
Text Alignment Vertical.
Definition TGX11.h:134
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:752
void QueryColors(Colormap cmap, RXColor *colors, Int_t ncolors)
Returns the current RGB value for the pixel in the XColor structure.
Definition TGX11.cxx:382
Int_t fBlueShift
Bits to left shift blue.
Definition TGX11.h:145
void SetMarkerColor(Color_t cindex) override
Set color index for markers.
Definition TGX11.cxx:2382
void Warp(Int_t ix, Int_t iy, Window_t id=0) override
Set pointer position.
Definition TGX11.cxx:3262
void * GetGC(Int_t which) const
Return desired Graphics Context ("which" maps directly on gGCList[]).
Definition TGX11.cxx:932
void SetClipOFF(Int_t wid) override
Turn off the clipping for the window wid.
Definition TGX11.cxx:2005
Int_t ResizePixmap(Int_t wid, UInt_t w, UInt_t h) override
Resize a pixmap.
Definition TGX11.cxx:1876
void SetDoubleBufferOFF() override
Turn double buffer mode off.
Definition TGX11.cxx:2125
void SetTextColor(Color_t cindex) override
Set color index for text.
Definition TGX11.cxx:3126
void UpdateWindow(Int_t mode) override
Update display.
Definition TGX11.cxx:3239
Bool_t fHasXft
True when XftFonts are used.
Definition TGX11.h:147
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:3693
Int_t InitWindow(ULong_t window) override
Open window and return window number.
Definition TGX11.cxx:1302
~TGX11() override
Destructor.
Definition TGX11.cxx:323
void MoveWindow(Int_t wid, Int_t x, Int_t y) override
Move the window wid.
Definition TGX11.cxx:1081
Int_t SetTextFont(char *fontname, ETextSetMode mode) override
Set text font to specified name.
Definition TGX11.cxx:3155
void SetFillStyle(Style_t style) override
Set fill area style.
Definition TGX11.cxx:2203
void ClearPixmap(Drawable *pix)
Clear the pixmap pix.
Definition TGX11.cxx:406
Float_t fTextMagnitude
Text Magnitude.
Definition TGX11.h:138
void SetCharacterUp(Float_t chupx, Float_t chupy) override
Set character up vector.
Definition TGX11.cxx:1984
Drawable fRootWin
Root window used as parent of all windows.
Definition TGX11.h:127
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:3279
void SetInput(Int_t inp)
Set input on or off.
Definition TGX11.cxx:2258
void GetPlanes(Int_t &nplanes) override
Get maximum number of planes.
Definition TGX11.cxx:1020
Int_t fTextAlignH
Text Alignment Horizontal.
Definition TGX11.h:133
void ClearWindow() override
Clear current window.
Definition TGX11.cxx:421
void * fXEvent
Current native (X11) event.
Definition TGX11.h:87
Int_t fGreenShift
Bits to left shift green.
Definition TGX11.h:144
void DrawBox(Int_t x1, Int_t y1, Int_t x2, Int_t y2, EBoxMode mode) override
Draw a box.
Definition TGX11.cxx:526
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:497
void SetOpacity(Int_t percent) override
Set opacity of a window.
Definition TGX11.cxx:2885
Int_t OpenPixmap(UInt_t w, UInt_t h) override
Open a new pixmap.
Definition TGX11.cxx:1244
XColor_t & GetColor(Int_t cid)
Return reference to internal color structure associated to color index cid.
Definition TGX11.cxx:910
Int_t fBlueDiv
Blue value divider.
Definition TGX11.h:142
void DrawPolyMarker(Int_t n, TPoint *xy) override
Draw n markers with the current attributes at position x, y.
Definition TGX11.cxx:677
void CloseWindow() override
Delete current window.
Definition TGX11.cxx:448
void SetMarkerSize(Float_t markersize) override
Set marker size index.
Definition TGX11.cxx:2396
void CopyWindowtoPixmap(Drawable *pix, Int_t xpos, Int_t ypos)
Copy area of current window in the pixmap pix.
Definition TGX11.cxx:509
Drawable fVisRootWin
Root window with fVisual to be used to create GC's and XImages.
Definition TGX11.h:128
void SetDoubleBufferON() override
Turn double buffer mode on.
Definition TGX11.cxx:2135
TExMap * fColors
Hash list of colors.
Definition TGX11.h:85
Int_t fTextAlign
Text alignment (set in SetTextAlign)
Definition TGX11.h:135
void SetMarkerType(Int_t type, Int_t n, RXPoint *xy)
Set marker type.
Definition TGX11.cxx:2421
Int_t fRedDiv
Red value divider, -1 if no TrueColor visual.
Definition TGX11.h:140
Int_t fDepth
Number of color planes.
Definition TGX11.h:139
Bool_t Init(void *display) override
Initialize X11 system. Returns kFALSE in case of failure.
Definition TGX11.cxx:341
void SetLineType(Int_t n, Int_t *dash) override
Set line type.
Definition TGX11.cxx:2298
void CloseWindow1()
Delete current window.
Definition TGX11.cxx:462
ULong_t fBlackPixel
Value of black pixel in colormap.
Definition TGX11.h:130
void SetTextSize(Float_t textsize) override
Set current text size.
Definition TGX11.cxx:3204
Float_t fCharacterUpX
Character Up vector along X.
Definition TGX11.h:136
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:560
void SetLineStyle(Style_t linestyle) override
Set line style.
Definition TGX11.cxx:2324
Int_t fGreenDiv
Green value divider.
Definition TGX11.h:141
void QueryPointer(Int_t &ix, Int_t &iy) override
Query pointer position.
Definition TGX11.cxx:1455
ULong_t GetPixel(Color_t cindex) override
Return pixel value associated to specified ROOT color number.
Definition TGX11.cxx:1005
TGX11()
Default constructor.
Definition TGX11.cxx:172
void GetTextExtent(UInt_t &w, UInt_t &h, char *mess) override
Return the size of a character string.
Definition TGX11.cxx:1049
void ClosePixmap() override
Delete current pixmap.
Definition TGX11.cxx:440
Int_t fRedShift
Bits to left shift red, -1 if no TrueColor visual.
Definition TGX11.h:143
Int_t RequestLocator(Int_t mode, Int_t ctyp, Int_t &x, Int_t &y) override
Request Locator position.
Definition TGX11.cxx:1506
Int_t OpenDisplay(void *display)
Open the display. Return -1 if the opening fails, 0 when ok.
Definition TGX11.cxx:1092
void DrawPolyLine(Int_t n, TPoint *xy) override
Draw a line through all points.
Definition TGX11.cxx:625
void RemovePixmap(Drawable *pix)
Remove the pixmap pix.
Definition TGX11.cxx:1473
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:2021
Int_t AddPixmap(ULong_t pixid, UInt_t w, UInt_t h) override
Register pixmap created by gVirtualGL.
Definition TGX11.cxx:3646
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:3036
void FindUsableVisual(RXVisualInfo *vlist, Int_t nitems)
Check if visual is usable, if so set fVisual, fDepth, fColormap, fBlackPixel and fWhitePixel.
Definition TGX11.cxx:849
void GetCharacterUp(Float_t &chupx, Float_t &chupy) override
Return character up vector.
Definition TGX11.cxx:900
void SetDoubleBuffer(Int_t wid, Int_t mode) override
Set the double buffer on/off on window wid.
Definition TGX11.cxx:2092
Int_t fMaxNumberOfWindows
Maximum number of windows.
Definition TGX11.h:83
void SetMarkerStyle(Style_t markerstyle) override
Set marker style.
Definition TGX11.cxx:2436
void GetRGB(Int_t index, Float_t &r, Float_t &g, Float_t &b) override
Get rgb values for color "index".
Definition TGX11.cxx:1028
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:3332
Int_t FindColor(ULong_t pixel, ULong_t *orgcolors, Int_t ncolors)
Returns index in orgcolors (and fNewColors) for pixel.
Definition TGX11.cxx:3020
void SetFillStyleIndex(Int_t style, Int_t fasi)
Set fill area style index.
Definition TGX11.cxx:2215
RVisual * fVisual
Pointer to visual used by all windows.
Definition TGX11.h:126
void DrawLine(Int_t x1, Int_t y1, Int_t x2, Int_t y2) override
Draw a line.
Definition TGX11.cxx:609
Window_t GetCurrentWindow() const override
Return current window pointer. Protected method used by TGX11TTF.
Definition TGX11.cxx:923
void RemoveWindow(ULong_t qwid) override
Remove a window created by Qt (like CloseWindow1()).
Definition TGX11.cxx:1423
Int_t RequestString(Int_t x, Int_t y, char *text) override
Request a string.
Definition TGX11.cxx:1684
void SetLineWidth(Width_t width) override
Set line width.
Definition TGX11.cxx:2363
XWindow_t * fWindows
List of windows.
Definition TGX11.h:84
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:3451
Int_t GetDoubleBuffer(Int_t wid) override
Query the double buffer value for the window wid.
Definition TGX11.cxx:944
void FindBestVisual()
Find best visual, i.e.
Definition TGX11.cxx:781
void SetDrawMode(EDrawMode mode) override
Set the drawing mode.
Definition TGX11.cxx:2160
void SetColor(void *gc, Int_t ci)
Set the foreground color in GC.
Definition TGX11.cxx:2044
const char * DisplayName(const char *dpyName=nullptr) override
Return hostname on which the display is opened.
Definition TGX11.cxx:997
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:3516
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:1379
Float_t fCharacterUpY
Character Up vector along Y.
Definition TGX11.h:137
Bool_t fHasTTFonts
True when TrueType fonts are used.
Definition TGX11.h:146
void SelectWindow(Int_t wid) override
Select window to which subsequent output is directed.
Definition TGX11.cxx:1959
An array of TObjects.
Definition TObjArray.h:31
Collectable string class.
Definition TObjString.h:28
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:1057
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1071
static void * Alloc(size_t size)
Allocate a block of memory, that later can be resized using TStorage::ReAlloc().
Definition TStorage.cxx:151
static void Dealloc(void *ptr)
De-allocate block of memory, that was allocated via TStorage::Alloc().
Definition TStorage.cxx:169
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:251
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:199
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:124
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:72
UShort_t fRed
red value in range [0,kBIGGEST_RGB_VALUE]
Definition TGX11.h:70
UShort_t fGreen
green value
Definition TGX11.h:71
ULong_t fPixel
color pixel value
Definition TGX11.h:69
Description of a X11 window.
Definition TGWin32.cxx:121
Int_t fOpen
1 if the window is open, 0 if not
Definition TGX11.h:49
Int_t fClip
1 if the clipping is on
Definition TGX11.h:57
Drawable fWindow
X11 window.
Definition TGX11.h:53
ULong_t * fNewColors
new image colors (after processing)
Definition TGX11.h:62
Int_t fNcolors
number of different colors
Definition TGX11.h:63
Drawable fDrawing
drawing area, equal to window or buffer
Definition TGX11.h:52
Int_t fDoubleBuffer
1 if the double buffer is on, 0 if not
Definition TGX11.h:50
UInt_t fHeight
height of the window
Definition TGX11.h:56
Int_t fIsPixmap
1 if pixmap, 0 if not
Definition TGX11.h:51
UInt_t fWidth
width of the window
Definition TGX11.h:55
UInt_t fHclip
height of the clipping rectangle
Definition TGX11.h:61
Bool_t fShared
notify when window is shared
Definition TGX11.h:64
Drawable fBuffer
pixmap used for double buffer
Definition TGX11.h:54
Int_t fXclip
x coordinate of the clipping rectangle
Definition TGX11.h:58
UInt_t fWclip
width of the clipping rectangle
Definition TGX11.h:60
Int_t fYclip
y coordinate of the clipping rectangle
Definition TGX11.h:59
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