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/// Draws N segments between provided points
673///
674/// \param [in] n number of segements
675/// \param [in] xy list of points, size 2*n
676
678{
679 const Int_t kMaxSegments = 500000;
680 if (n > kMaxSegments) {
681 Int_t ibeg = 0;
683 while (ibeg < n) {
685 ibeg = iend;
687 }
688 } else if (n > 0) {
689 if (gLineStyle == LineSolid)
690 XDrawSegments((Display*)fDisplay, gCws->fDrawing, *gGCline, (XSegment *) xy, n);
691 else {
693 XDrawSegments((Display*)fDisplay, gCws->fDrawing, *gGCdash, (XSegment *) xy, n);
694 }
695 }
696}
697
698
699////////////////////////////////////////////////////////////////////////////////
700/// Draw n markers with the current attributes at position x, y.
701///
702/// \param [in] n number of markers to draw
703/// \param [in] xy x,y coordinates of markers
704
706{
707 XPoint *xyp = (XPoint*)xy;
708
709 if (gMarker.n <= 0) {
710 const int kNMAX = 1000000;
711 int nt = n/kNMAX;
712 for (int it=0;it<=nt;it++) {
713 if (it < nt) {
714 XDrawPoints((Display*)fDisplay, gCws->fDrawing, *gGCmark, &xyp[it*kNMAX], kNMAX, CoordModeOrigin);
715 } else {
716 XDrawPoints((Display*)fDisplay, gCws->fDrawing, *gGCmark, &xyp[it*kNMAX], n-it*kNMAX, CoordModeOrigin);
717 }
718 }
719 } else {
720 int r = gMarker.n / 2;
721 int m;
722
723 for (m = 0; m < n; m++) {
724 int hollow = 0;
725
726 switch (gMarker.type) {
727 int i;
728
729 case 0: // hollow circle
730 XDrawArc((Display*)fDisplay, gCws->fDrawing, *gGCmark,
731 xyp[m].x - r, xyp[m].y - r, gMarker.n, gMarker.n, 0, 360*64);
732 break;
733
734 case 1: // filled circle
735 XFillArc((Display*)fDisplay, gCws->fDrawing, *gGCmark,
736 xyp[m].x - r, xyp[m].y - r, gMarker.n, gMarker.n, 0, 360*64);
737 break;
738
739 case 2: // hollow polygon
740 hollow = 1;
741 case 3: // filled polygon
742 for (i = 0; i < gMarker.n; i++) {
743 gMarker.xy[i].x += xyp[m].x;
744 gMarker.xy[i].y += xyp[m].y;
745 }
746 if (hollow)
747 XDrawLines((Display*)fDisplay, gCws->fDrawing, *gGCmark,
749 else
750 XFillPolygon((Display*)fDisplay, gCws->fDrawing, *gGCmark,
752 for (i = 0; i < gMarker.n; i++) {
753 gMarker.xy[i].x -= xyp[m].x;
754 gMarker.xy[i].y -= xyp[m].y;
755 }
756 break;
757
758 case 4: // segmented line
759 for (i = 0; i < gMarker.n; i += 2)
760 XDrawLine((Display*)fDisplay, gCws->fDrawing, *gGCmark,
761 xyp[m].x + gMarker.xy[i].x, xyp[m].y + gMarker.xy[i].y,
762 xyp[m].x + gMarker.xy[i+1].x, xyp[m].y + gMarker.xy[i+1].y);
763 break;
764 }
765 }
766 }
767}
768
769////////////////////////////////////////////////////////////////////////////////
770/// Draw a text string using current font.
771///
772/// \param [in] mode : drawing mode
773/// - mode=0 : the background is not drawn (kClear)
774/// - mode=1 : the background is drawn (kOpaque)
775/// \param [in] x,y : text position
776/// \param [in] angle : text angle
777/// \param [in] mgn : magnification factor
778/// \param [in] text : text string
779
781 const char *text, ETextMode mode)
782{
784
785 if (!text) return;
786
787 switch (mode) {
788
789 case kClear:
791 gCws->fDrawing, *gGCtext, x, y, (char*)text, fTextAlign);
792 break;
793
794 case kOpaque:
796 gCws->fDrawing, *gGCtext, x, y, (char*)text, fTextAlign);
797 break;
798
799 default:
800 break;
801 }
802}
803
804////////////////////////////////////////////////////////////////////////////////
805/// Find best visual, i.e. the one with the most planes and TrueColor or
806/// DirectColor. Sets fVisual, fDepth, fRootWin, fColormap, fBlackPixel
807/// and fWhitePixel.
808
810{
811 Int_t findvis = gEnv->GetValue("X11.FindBestVisual", 1);
812
813 Visual *vis = DefaultVisual((Display*)fDisplay, fScreenNumber);
814 if (((vis->c_class != TrueColor && vis->c_class != DirectColor) ||
815 DefaultDepth((Display*)fDisplay, fScreenNumber) < 15) && findvis) {
816
817 // try to find better visual
818 static XVisualInfo templates[] = {
819 // Visual, visualid, screen, depth, class , red_mask, green_mask, blue_mask, colormap_size, bits_per_rgb
820 { nullptr, 0 , 0 , 24 , TrueColor , 0 , 0 , 0 , 0 , 0 },
821 { nullptr, 0 , 0 , 32 , TrueColor , 0 , 0 , 0 , 0 , 0 },
822 { nullptr, 0 , 0 , 16 , TrueColor , 0 , 0 , 0 , 0 , 0 },
823 { nullptr, 0 , 0 , 15 , TrueColor , 0 , 0 , 0 , 0 , 0 },
824 // no suitable TrueColorMode found - now do the same thing to DirectColor
825 { nullptr, 0 , 0 , 24 , DirectColor, 0 , 0 , 0 , 0 , 0 },
826 { nullptr, 0 , 0 , 32 , DirectColor, 0 , 0 , 0 , 0 , 0 },
827 { nullptr, 0 , 0 , 16 , DirectColor, 0 , 0 , 0 , 0 , 0 },
828 { nullptr, 0 , 0 , 15 , DirectColor, 0 , 0 , 0 , 0 , 0 },
829 { nullptr, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 },
830 };
831
832 Int_t nitems = 0;
833 XVisualInfo *vlist = nullptr;
834 for (Int_t i = 0; templates[i].depth != 0; i++) {
836 templates[i].screen = fScreenNumber;
837 if ((vlist = XGetVisualInfo((Display*)fDisplay, mask, &(templates[i]), &nitems))) {
839 XFree(vlist);
840 vlist = nullptr;
841 if (fVisual)
842 break;
843 }
844 }
845 }
846
848
849 if (!fVisual) {
853 if (fDepth > 1)
857 }
858 if (gDebug > 1)
859 Printf("Selected visual 0x%lx: depth %d, class %d, colormap: %s",
860 fVisual->visualid, fDepth, fVisual->c_class,
861 fColormap == DefaultColormap((Display*)fDisplay, fScreenNumber) ? "default" :
862 "custom");
863}
864
865////////////////////////////////////////////////////////////////////////////////
866/// Dummy error handler for X11. Used by FindUsableVisual().
867
869{
870 return 0;
871}
872
873////////////////////////////////////////////////////////////////////////////////
874/// Check if visual is usable, if so set fVisual, fDepth, fColormap,
875/// fBlackPixel and fWhitePixel.
876
878{
879 Int_t (*oldErrorHandler)(Display *, XErrorEvent *) =
881
883 memset(&attr, 0, sizeof(attr));
884
885 Window root = RootWindow((Display*)fDisplay, fScreenNumber);
886
887 for (Int_t i = 0; i < nitems; i++) {
888 Window w = None, wjunk;
890 Int_t junk;
891
892 // try and use default colormap when possible
893 if (vlist[i].visual == DefaultVisual((Display*)fDisplay, fScreenNumber)) {
894 attr.colormap = DefaultColormap((Display*)fDisplay, fScreenNumber);
895 } else {
896 attr.colormap = XCreateColormap((Display*)fDisplay, root, vlist[i].visual, AllocNone);
897 }
898
899 static XColor black_xcol = { 0, 0x0000, 0x0000, 0x0000, DoRed|DoGreen|DoBlue, 0 };
900 static XColor white_xcol = { 0, 0xFFFF, 0xFFFF, 0xFFFF, DoRed|DoGreen|DoBlue, 0 };
901 XAllocColor((Display*)fDisplay, attr.colormap, &black_xcol);
902 XAllocColor((Display*)fDisplay, attr.colormap, &white_xcol);
903 attr.border_pixel = black_xcol.pixel;
904 attr.override_redirect = True;
905
906 w = XCreateWindow((Display*)fDisplay, root, -20, -20, 10, 10, 0, vlist[i].depth,
909 if (w != None && XGetGeometry((Display*)fDisplay, w, &wjunk, &junk, &junk,
910 &width, &height, &ujunk, &ujunk)) {
912 fDepth = vlist[i].depth;
913 fColormap = attr.colormap;
914 fBlackPixel = black_xcol.pixel;
915 fWhitePixel = white_xcol.pixel;
916 fVisRootWin = w;
917 break;
918 }
919 if (attr.colormap != DefaultColormap((Display*)fDisplay, fScreenNumber))
920 XFreeColormap((Display*)fDisplay, attr.colormap);
921 }
923}
924
925////////////////////////////////////////////////////////////////////////////////
926/// Return character up vector.
927
933
934////////////////////////////////////////////////////////////////////////////////
935/// Return reference to internal color structure associated
936/// to color index cid.
937
939{
941 if (!col) {
942 col = new XColor_t;
943 fColors->Add(cid, (Long_t) col);
944 }
945 return *col;
946}
947
948////////////////////////////////////////////////////////////////////////////////
949/// Return current window pointer. Protected method used by TGX11TTF.
950
952{
953 return (Window_t)(gCws ? gCws->fDrawing : 0);
954}
955
956////////////////////////////////////////////////////////////////////////////////
957/// Return desired Graphics Context ("which" maps directly on gGCList[]).
958/// Protected method used by TGX11TTF.
959
961{
962 if (which >= kMAXGC || which < 0) {
963 Error("GetGC", "trying to get illegal GC (which = %d)", which);
964 return nullptr;
965 }
966 return &gGClist[which];
967}
968
969////////////////////////////////////////////////////////////////////////////////
970/// Query the double buffer value for the window wid.
971
973{
974 gTws = &fWindows[wid];
975 if (!gTws->fOpen)
976 return -1;
977 else
978 return gTws->fDoubleBuffer;
979}
980
981////////////////////////////////////////////////////////////////////////////////
982/// Return position and size of window wid.
983///
984/// \param [in] wid : window identifier
985/// \param [in] x,y : window position (output)
986/// \param [in] w,h : window size (output)
987///
988/// if wid < 0 the size of the display is returned
989
990void TGX11::GetGeometry(int wid, int &x, int &y, unsigned int &w, unsigned int &h)
991{
992 Window junkwin=0;
993
994 if (wid < 0) {
995 x = 0;
996 y = 0;
999 } else {
1000 Window root;
1001 unsigned int border, depth;
1002 unsigned int width, height;
1003
1004 gTws = &fWindows[wid];
1005 XGetGeometry((Display*)fDisplay, gTws->fWindow, &root, &x, &y,
1006 &width, &height, &border, &depth);
1007 XTranslateCoordinates((Display*)fDisplay, gTws->fWindow, fRootWin,
1008 0, 0, &x, &y, &junkwin);
1009 if (width >= 65535)
1010 width = 1;
1011 if (height >= 65535)
1012 height = 1;
1013 if (width > 0 && height > 0) {
1014 gTws->fWidth = width;
1015 gTws->fHeight = height;
1016 }
1017 w = gTws->fWidth;
1018 h = gTws->fHeight;
1019 }
1020}
1021
1022////////////////////////////////////////////////////////////////////////////////
1023/// Return hostname on which the display is opened.
1024
1025const char *TGX11::DisplayName(const char *dpyName)
1026{
1027 return XDisplayName(dpyName);
1028}
1029
1030////////////////////////////////////////////////////////////////////////////////
1031/// Return pixel value associated to specified ROOT color number.
1032
1034{
1035 TColor *color = gROOT->GetColor(ci);
1036 if (color)
1037 SetRGB(ci, color->GetRed(), color->GetGreen(), color->GetBlue());
1038// else
1039// Warning("GetPixel", "color with index %d not defined", ci);
1040
1041 XColor_t &col = GetColor(ci);
1042 return col.fPixel;
1043}
1044
1045////////////////////////////////////////////////////////////////////////////////
1046/// Get maximum number of planes.
1047
1049{
1050 nplanes = fDepth;
1051}
1052
1053////////////////////////////////////////////////////////////////////////////////
1054/// Get rgb values for color "index".
1055
1056void TGX11::GetRGB(int index, float &r, float &g, float &b)
1057{
1058 if (index == 0) {
1059 r = g = b = 1.0;
1060 } else if (index == 1) {
1061 r = g = b = 0.0;
1062 } else {
1063 XColor_t &col = GetColor(index);
1064 r = ((float) col.fRed) / ((float) kBIGGEST_RGB_VALUE);
1065 g = ((float) col.fGreen) / ((float) kBIGGEST_RGB_VALUE);
1066 b = ((float) col.fBlue) / ((float) kBIGGEST_RGB_VALUE);
1067 }
1068}
1069
1070////////////////////////////////////////////////////////////////////////////////
1071/// Return the size of a character string.
1072///
1073/// \param [in] w : text width
1074/// \param [in] h : text height
1075/// \param [in] mess : message
1076
1078{
1079 w=0; h=0;
1080 if (strlen(mess)==0) return;
1081
1082 XPoint *cBox;
1084 cBox = XRotTextExtents((Display*)fDisplay, gTextFont, 0., 0, 0, mess, 0);
1085 if (cBox) {
1086 w = cBox[2].x;
1087 h = -cBox[2].y;
1088 free((char *)cBox);
1089 }
1090}
1091
1092////////////////////////////////////////////////////////////////////////////////
1093/// Return the X11 window identifier.
1094///
1095/// \param [in] wid : Workstation identifier (input)
1096
1098{
1099 return (Window_t) fWindows[wid].fWindow;
1100}
1101
1102////////////////////////////////////////////////////////////////////////////////
1103/// Move the window wid.
1104///
1105/// \param [in] wid : Window identifier.
1106/// \param [in] x : x new window position
1107/// \param [in] y : y new window position
1108
1110{
1111 gTws = &fWindows[wid];
1112 if (!gTws->fOpen) return;
1113
1114 XMoveWindow((Display*)fDisplay, gTws->fWindow, x, y);
1115}
1116
1117////////////////////////////////////////////////////////////////////////////////
1118/// Open the display. Return -1 if the opening fails, 0 when ok.
1119
1121{
1122 Pixmap pixmp1, pixmp2;
1123 XColor fore, back;
1124 char **fontlist;
1125 int fontcount = 0;
1126 int i;
1127
1128 if (fDisplay) return 0;
1129
1130 fDisplay = (void *) disp;
1132
1134
1135 GetColor(1).fDefined = kTRUE; // default foreground
1137 GetColor(0).fDefined = kTRUE; // default background
1139
1140 // Inquire the XServer Vendor
1141 char vendor[132];
1142 strlcpy(vendor, XServerVendor((Display*)fDisplay),132);
1143
1144 // Create primitives graphic contexts
1145 for (i = 0; i < kMAXGC; i++)
1146 gGClist[i] = XCreateGC((Display*)fDisplay, fVisRootWin, 0, nullptr);
1147
1148 XGCValues values;
1149 if (XGetGCValues((Display*)fDisplay, *gGCtext, GCForeground|GCBackground, &values)) {
1150 XSetForeground((Display*)fDisplay, *gGCinvt, values.background);
1151 XSetBackground((Display*)fDisplay, *gGCinvt, values.foreground);
1152 } else {
1153 Error("OpenDisplay", "cannot get GC values");
1154 }
1155
1156 // Turn-off GraphicsExpose and NoExpose event reporting for the pixmap
1157 // manipulation GC, this to prevent these events from being stacked up
1158 // without ever being processed and thereby wasting a lot of memory.
1159 XSetGraphicsExposures((Display*)fDisplay, *gGCpxmp, False);
1160
1161 // Create input echo graphic context
1163 echov.foreground = fBlackPixel;
1164 echov.background = fWhitePixel;
1165 if (strstr(vendor,"Hewlett"))
1166 echov.function = GXxor;
1167 else
1168 echov.function = GXinvert;
1169
1172 &echov);
1173
1174 // Load a default Font
1175 static int isdisp = 0;
1176 if (!isdisp) {
1177 for (i = 0; i < kMAXFONT; i++) {
1178 gFont[i].id = nullptr;
1179 strcpy(gFont[i].name, " ");
1180 }
1181 fontlist = XListFonts((Display*)fDisplay, "*courier*", 1, &fontcount);
1182 if (fontlist && fontcount != 0) {
1185 strcpy(gFont[gCurrentFontNumber].name, "*courier*");
1188 } else {
1189 // emergency: try fixed font
1190 fontlist = XListFonts((Display*)fDisplay, "fixed", 1, &fontcount);
1191 if (fontlist && fontcount != 0) {
1197 } else {
1198 Warning("OpenDisplay", "no default font loaded");
1199 }
1200 }
1201 isdisp = 1;
1202 }
1203
1204 // Create a null cursor
1206 null_cursor_bits, 16, 16);
1208 null_cursor_bits, 16, 16);
1209 gNullCursor = XCreatePixmapCursor((Display*)fDisplay,pixmp1,pixmp2,&fore,&back,0,0);
1210
1211 // Create cursors
1231
1232 // Setup color information
1234
1235 if (fVisual->c_class == TrueColor) {
1236 for (i = 0; i < int(sizeof(fVisual->blue_mask)*kBitsPerByte); i++) {
1237 if (fBlueShift == -1 && ((fVisual->blue_mask >> i) & 1))
1238 fBlueShift = i;
1239 if ((fVisual->blue_mask >> i) == 1) {
1240 fBlueDiv = sizeof(UShort_t)*kBitsPerByte - i - 1 + fBlueShift;
1241 break;
1242 }
1243 }
1244 for (i = 0; i < int(sizeof(fVisual->green_mask)*kBitsPerByte); i++) {
1245 if (fGreenShift == -1 && ((fVisual->green_mask >> i) & 1))
1246 fGreenShift = i;
1247 if ((fVisual->green_mask >> i) == 1) {
1248 fGreenDiv = sizeof(UShort_t)*kBitsPerByte - i - 1 + fGreenShift;
1249 break;
1250 }
1251 }
1252 for (i = 0; i < int(sizeof(fVisual->red_mask)*kBitsPerByte); i++) {
1253 if (fRedShift == -1 && ((fVisual->red_mask >> i) & 1))
1254 fRedShift = i;
1255 if ((fVisual->red_mask >> i) == 1) {
1256 fRedDiv = sizeof(UShort_t)*kBitsPerByte - i - 1 + fRedShift;
1257 break;
1258 }
1259 }
1260 //printf("fRedDiv = %d, fGreenDiv = %d, fBlueDiv = %d, fRedShift = %d, fGreenShift = %d, fBlueShift = %d\n",
1261 // fRedDiv, fGreenDiv, fBlueDiv, fRedShift, fGreenShift, fBlueShift);
1262 }
1263
1264 return 0;
1265}
1266
1267////////////////////////////////////////////////////////////////////////////////
1268/// Open a new pixmap.
1269///
1270/// \param [in] w,h : Width and height of the pixmap.
1271
1272Int_t TGX11::OpenPixmap(unsigned int w, unsigned int h)
1273{
1274 Window root;
1275 unsigned int wval, hval;
1276 int xx, yy, i, wid;
1277 unsigned int ww, hh, border, depth;
1278 wval = w;
1279 hval = h;
1280
1281 // Select next free window number
1282
1283again:
1284 for (wid = 0; wid < fMaxNumberOfWindows; wid++)
1285 if (!fWindows[wid].fOpen) {
1286 fWindows[wid].fOpen = 1;
1287 gCws = &fWindows[wid];
1288 break;
1289 }
1290
1291 if (wid == fMaxNumberOfWindows) {
1292 int newsize = fMaxNumberOfWindows + 10;
1295 for (i = fMaxNumberOfWindows; i < newsize; i++)
1296 fWindows[i].fOpen = 0;
1298 goto again;
1299 }
1300
1301 gCws->fWindow = XCreatePixmap((Display*)fDisplay, fRootWin, wval, hval, fDepth);
1302 XGetGeometry((Display*)fDisplay, gCws->fWindow, &root, &xx, &yy, &ww, &hh, &border, &depth);
1303
1304 for (i = 0; i < kMAXGC; i++)
1305 XSetClipMask((Display*)fDisplay, gGClist[i], None);
1306
1307 SetColor(gGCpxmp, 0);
1308 XFillRectangle((Display*)fDisplay, gCws->fWindow, *gGCpxmp, 0, 0, ww, hh);
1309 SetColor(gGCpxmp, 1);
1310
1311 // Initialise the window structure
1312 gCws->fDrawing = gCws->fWindow;
1313 gCws->fBuffer = 0;
1314 gCws->fDoubleBuffer = 0;
1315 gCws->fIsPixmap = 1;
1316 gCws->fClip = 0;
1317 gCws->fWidth = wval;
1318 gCws->fHeight = hval;
1319 gCws->fNewColors = nullptr;
1320 gCws->fShared = kFALSE;
1321
1322 return wid;
1323}
1324
1325////////////////////////////////////////////////////////////////////////////////
1326/// Open window and return window number.
1327///
1328/// \return -1 if window initialization fails.
1329
1331{
1332 XSetWindowAttributes attributes;
1333 ULong_t attr_mask = 0;
1334 int wid;
1335 int xval, yval;
1336 unsigned int wval, hval, border, depth;
1337 Window root;
1338
1339 Window wind = (Window) win;
1340
1341 XGetGeometry((Display*)fDisplay, wind, &root, &xval, &yval, &wval, &hval, &border, &depth);
1342
1343 // Select next free window number
1344
1345again:
1346 for (wid = 0; wid < fMaxNumberOfWindows; wid++)
1347 if (!fWindows[wid].fOpen) {
1348 fWindows[wid].fOpen = 1;
1350 gCws = &fWindows[wid];
1351 break;
1352 }
1353
1354 if (wid == fMaxNumberOfWindows) {
1355 int newsize = fMaxNumberOfWindows + 10;
1358 for (int i = fMaxNumberOfWindows; i < newsize; i++)
1359 fWindows[i].fOpen = 0;
1361 goto again;
1362 }
1363
1364 // Create window
1365
1366 attributes.background_pixel = GetColor(0).fPixel;
1368 attributes.border_pixel = GetColor(1).fPixel;
1370 attributes.event_mask = NoEventMask;
1372 attributes.backing_store = Always;
1374 attributes.bit_gravity = NorthWestGravity;
1376 if (fColormap) {
1377 attributes.colormap = fColormap;
1379 }
1380
1381 gCws->fWindow = XCreateWindow((Display*)fDisplay, wind,
1382 xval, yval, wval, hval, 0, fDepth,
1384 attr_mask, &attributes);
1385
1386 XMapWindow((Display*)fDisplay, gCws->fWindow);
1387 XFlush((Display*)fDisplay);
1388
1389 // Initialise the window structure
1390
1391 gCws->fDrawing = gCws->fWindow;
1392 gCws->fBuffer = 0;
1393 gCws->fDoubleBuffer = 0;
1394 gCws->fIsPixmap = 0;
1395 gCws->fClip = 0;
1396 gCws->fWidth = wval;
1397 gCws->fHeight = hval;
1398 gCws->fNewColors = nullptr;
1399 gCws->fShared = kFALSE;
1400
1401 return wid;
1402}
1403
1404////////////////////////////////////////////////////////////////////////////////
1405/// Register a window created by Qt as a ROOT window (like InitWindow()).
1406
1408{
1409 Int_t wid;
1410
1411 // Select next free window number
1412
1413again:
1414 for (wid = 0; wid < fMaxNumberOfWindows; wid++)
1415 if (!fWindows[wid].fOpen) {
1416 fWindows[wid].fOpen = 1;
1418 gCws = &fWindows[wid];
1419 break;
1420 }
1421
1422 if (wid == fMaxNumberOfWindows) {
1423 int newsize = fMaxNumberOfWindows + 10;
1426 for (int i = fMaxNumberOfWindows; i < newsize; i++)
1427 fWindows[i].fOpen = 0;
1429 goto again;
1430 }
1431
1432 gCws->fWindow = qwid;
1433
1434 //init Xwindow_t struct
1435 gCws->fDrawing = gCws->fWindow;
1436 gCws->fBuffer = 0;
1437 gCws->fDoubleBuffer = 0;
1438 gCws->fIsPixmap = 0;
1439 gCws->fClip = 0;
1440 gCws->fWidth = w;
1441 gCws->fHeight = h;
1442 gCws->fNewColors = nullptr;
1443 gCws->fShared = kTRUE;
1444
1445 return wid;
1446}
1447
1448////////////////////////////////////////////////////////////////////////////////
1449/// Remove a window created by Qt (like CloseWindow1()).
1450
1452{
1453 SelectWindow((int)qwid);
1454
1455 if (gCws->fBuffer) XFreePixmap((Display*)fDisplay, gCws->fBuffer);
1456
1457 if (gCws->fNewColors) {
1458 if (fRedDiv == -1)
1459 XFreeColors((Display*)fDisplay, fColormap, gCws->fNewColors, gCws->fNcolors, 0);
1460 delete [] gCws->fNewColors;
1461 gCws->fNewColors = nullptr;
1462 }
1463
1464 gCws->fOpen = 0;
1465
1466 // make first window in list the current window
1467 for (Int_t wid = 0; wid < fMaxNumberOfWindows; wid++)
1468 if (fWindows[wid].fOpen) {
1469 gCws = &fWindows[wid];
1470 return;
1471 }
1472
1473 gCws = nullptr;
1474}
1475
1476////////////////////////////////////////////////////////////////////////////////
1477/// Query pointer position.
1478///
1479/// \param [in] ix : X coordinate of pointer
1480/// \param [in] iy : Y coordinate of pointer
1481/// (both coordinates are relative to the origin of the root window)
1482
1484{
1488 unsigned int mask_return;
1489
1490 XQueryPointer((Display*)fDisplay,gCws->fWindow, &root_return,
1493
1494 ix = root_x_return;
1495 iy = root_y_return;
1496}
1497
1498////////////////////////////////////////////////////////////////////////////////
1499/// Remove the pixmap pix.
1500
1502{
1503 XFreePixmap((Display*)fDisplay,*pix);
1504}
1505
1506////////////////////////////////////////////////////////////////////////////////
1507/// Request Locator position.
1508///
1509/// \param [in] x,y : cursor position at moment of button press (output)
1510/// \param [in] ctyp : cursor type (input)
1511/// - ctyp=1 tracking cross
1512/// - ctyp=2 cross-hair
1513/// - ctyp=3 rubber circle
1514/// - ctyp=4 rubber band
1515/// - ctyp=5 rubber rectangle
1516///
1517/// \param [in] mode : input mode
1518/// - mode=0 request
1519/// - mode=1 sample
1520///
1521/// Request locator:
1522/// return button number:
1523/// - 1 = left is pressed
1524/// - 2 = middle is pressed
1525/// - 3 = right is pressed
1526/// in sample mode:
1527/// - 11 = left is released
1528/// - 12 = middle is released
1529/// - 13 = right is released
1530/// - -1 = nothing is pressed or released
1531/// - -2 = leave the window
1532/// - else = keycode (keyboard is pressed)
1533
1535{
1536 static int xloc = 0;
1537 static int yloc = 0;
1538 static int xlocp = 0;
1539 static int ylocp = 0;
1540 static Cursor cursor = 0;
1541
1542 XEvent event;
1543 int button_press;
1544 int radius;
1545
1546 // Change the cursor shape
1547 if (cursor == 0) {
1548 if (ctyp > 1) {
1549 XDefineCursor((Display*)fDisplay, gCws->fWindow, gNullCursor);
1550 XSetForeground((Display*)fDisplay, gGCecho, GetColor(0).fPixel);
1551 } else {
1553 XDefineCursor((Display*)fDisplay, gCws->fWindow, cursor);
1554 }
1555 }
1556
1557 // Event loop
1558
1559 button_press = 0;
1560
1561 while (button_press == 0) {
1562
1563 switch (ctyp) {
1564
1565 case 1 :
1566 break;
1567
1568 case 2 :
1569 XDrawLine((Display*)fDisplay, gCws->fWindow, gGCecho,
1570 xloc, 0, xloc, gCws->fHeight);
1571 XDrawLine((Display*)fDisplay, gCws->fWindow, gGCecho,
1572 0, yloc, gCws->fWidth, yloc);
1573 break;
1574
1575 case 3 :
1576 radius = (int) TMath::Sqrt((double)((xloc-xlocp)*(xloc-xlocp) +
1577 (yloc-ylocp)*(yloc-ylocp)));
1578 XDrawArc((Display*)fDisplay, gCws->fWindow, gGCecho,
1580 2*radius, 2*radius, 0, 23040);
1581 break;
1582
1583 case 4 :
1584 XDrawLine((Display*)fDisplay, gCws->fWindow, gGCecho,
1585 xlocp, ylocp, xloc, yloc);
1586 break;
1587
1588 case 5 :
1589 XDrawRectangle((Display*)fDisplay, gCws->fWindow, gGCecho,
1592 break;
1593
1594 default:
1595 break;
1596 }
1597
1598 while (XEventsQueued( (Display*)fDisplay, QueuedAlready) > 1) {
1599 XNextEvent((Display*)fDisplay, &event);
1600 }
1601 XWindowEvent((Display*)fDisplay, gCws->fWindow, gMouseMask, &event);
1602
1603 switch (ctyp) {
1604
1605 case 1 :
1606 break;
1607
1608 case 2 :
1609 XDrawLine((Display*)fDisplay, gCws->fWindow, gGCecho,
1610 xloc, 0, xloc, gCws->fHeight);
1611 XDrawLine((Display*)fDisplay, gCws->fWindow, gGCecho,
1612 0, yloc, gCws->fWidth, yloc);
1613 break;
1614
1615 case 3 :
1616 radius = (int) TMath::Sqrt((double)((xloc-xlocp)*(xloc-xlocp) +
1617 (yloc-ylocp)*(yloc-ylocp)));
1618 XDrawArc((Display*)fDisplay, gCws->fWindow, gGCecho,
1620 2*radius, 2*radius, 0, 23040);
1621 break;
1622
1623 case 4 :
1624 XDrawLine((Display*)fDisplay, gCws->fWindow, gGCecho,
1625 xlocp, ylocp, xloc, yloc);
1626 break;
1627
1628 case 5 :
1629 XDrawRectangle((Display*)fDisplay, gCws->fWindow, gGCecho,
1632 break;
1633
1634 default:
1635 break;
1636 }
1637
1638 xloc = event.xbutton.x;
1639 yloc = event.xbutton.y;
1640
1641 switch (event.type) {
1642
1643 case LeaveNotify :
1644 if (mode == 0) {
1645 while (true) {
1646 XNextEvent((Display*)fDisplay, &event);
1647 if (event.type == EnterNotify) break;
1648 }
1649 } else {
1650 button_press = -2;
1651 }
1652 break;
1653
1654 case ButtonPress :
1655 button_press = event.xbutton.button ;
1656 xlocp = event.xbutton.x;
1657 ylocp = event.xbutton.y;
1658 XUndefineCursor( (Display*)fDisplay, gCws->fWindow );
1659 cursor = 0;
1660 break;
1661
1662 case ButtonRelease :
1663 if (mode == 1) {
1664 button_press = 10+event.xbutton.button ;
1665 xlocp = event.xbutton.x;
1666 ylocp = event.xbutton.y;
1667 }
1668 break;
1669
1670 case KeyPress :
1671 if (mode == 1) {
1672 button_press = event.xkey.keycode;
1673 xlocp = event.xbutton.x;
1674 ylocp = event.xbutton.y;
1675 }
1676 break;
1677
1678 case KeyRelease :
1679 if (mode == 1) {
1680 button_press = -event.xkey.keycode;
1681 xlocp = event.xbutton.x;
1682 ylocp = event.xbutton.y;
1683 }
1684 break;
1685
1686 default :
1687 break;
1688 }
1689
1690 if (mode == 1) {
1691 if (button_press == 0)
1692 button_press = -1;
1693 break;
1694 }
1695 }
1696 x = event.xbutton.x;
1697 y = event.xbutton.y;
1698
1699 return button_press;
1700}
1701
1702////////////////////////////////////////////////////////////////////////////////
1703/// Request a string.
1704///
1705/// \param [in] x,y : position where text is displayed
1706/// \param [in] text : text displayed (input), edited text (output)
1707///
1708/// Request string:
1709/// text is displayed and can be edited with Emacs-like keybinding
1710/// return termination code (0 for ESC, 1 for RETURN)
1711
1713{
1714 static Cursor cursor = 0;
1715 static int percent = 0; // bell volume
1717 int focusrevert;
1718 XEvent event;
1719 KeySym keysym;
1720 int key = -1;
1721 int len_text = strlen(text);
1722 int nt; // defined length of text
1723 int pt; // cursor position in text
1724
1725 // change the cursor shape
1726 if (cursor == 0) {
1730 percent = kbstate.bell_percent;
1731 }
1732 if (cursor != 0)
1733 XDefineCursor((Display*)fDisplay, gCws->fWindow, cursor);
1734 for (nt = len_text; nt > 0 && text[nt-1] == ' '; nt--) { }
1735 pt = nt;
1737 XSetInputFocus((Display*)fDisplay, gCws->fWindow, focusrevert, CurrentTime);
1738 while (key < 0) {
1739 char keybuf[8];
1740 char nbytes;
1741 int dx;
1742 int i;
1743 XDrawImageString((Display*)fDisplay, gCws->fWindow, *gGCtext, x, y, text, nt);
1744 dx = XTextWidth(gTextFont, text, nt);
1745 XDrawImageString((Display*)fDisplay, gCws->fWindow, *gGCtext, x + dx, y, " ", 1);
1746 dx = pt == 0 ? 0 : XTextWidth(gTextFont, text, pt);
1747 XDrawImageString((Display*)fDisplay, gCws->fWindow, *gGCinvt,
1748 x + dx, y, pt < len_text ? &text[pt] : " ", 1);
1749 XWindowEvent((Display*)fDisplay, gCws->fWindow, gKeybdMask, &event);
1750 switch (event.type) {
1751 case ButtonPress:
1752 case EnterNotify:
1753 XSetInputFocus((Display*)fDisplay, gCws->fWindow, focusrevert, CurrentTime);
1754 break;
1755 case LeaveNotify:
1757 break;
1758 case KeyPress:
1759 nbytes = XLookupString(&event.xkey, keybuf, sizeof(keybuf),
1760 &keysym, nullptr);
1761 switch (keysym) { // map cursor keys
1762 case XK_Left:
1763 keybuf[0] = '\002'; // Control-B
1764 nbytes = 1;
1765 break;
1766 case XK_Right:
1767 keybuf[0] = '\006'; // Control-F
1768 nbytes = 1;
1769 break;
1770 }
1771 if (nbytes == 1) {
1772 if (isascii(keybuf[0]) && isprint(keybuf[0])) {
1773 // insert character
1774 if (nt < len_text)
1775 nt++;
1776 for (i = nt - 1; i > pt; i--)
1777 text[i] = text[i-1];
1778 if (pt < len_text) {
1779 text[pt] = keybuf[0];
1780 pt++;
1781 }
1782 } else
1783 switch (keybuf[0]) {
1784 // Emacs-like editing keys
1785
1786 case '\010': // backspace
1787 case '\177': // delete
1788 // delete backward
1789 if (pt > 0) {
1790 for (i = pt; i < nt; i++)
1791 text[i-1] = text[i];
1792 text[nt-1] = ' ';
1793 nt--;
1794 pt--;
1795 }
1796 break;
1797 case '\001': // ^A
1798 // beginning of line
1799 pt = 0;
1800 break;
1801 case '\002': // ^B
1802 // move backward
1803 if (pt > 0)
1804 pt--;
1805 break;
1806 case '\004': // ^D
1807 // delete forward
1808 if (pt > 0) {
1809 for (i = pt; i < nt; i++)
1810 text[i-1] = text[i];
1811 text[nt-1] = ' ';
1812 pt--;
1813 }
1814 break;
1815 case '\005': // ^E
1816 // end of line
1817 pt = nt;
1818 break;
1819
1820 case '\006': // ^F
1821 // move forward
1822 if (pt < nt)
1823 pt++;
1824 break;
1825 case '\013': // ^K
1826 // delete to end of line
1827 for (i = pt; i < nt; i++)
1828 text[i] = ' ';
1829 nt = pt;
1830 break;
1831 case '\024': // ^T
1832 // transpose
1833 if (pt > 0) {
1834 char c = text[pt];
1835 text[pt] = text[pt-1];
1836 text[pt-1] = c;
1837 }
1838 break;
1839 case '\012': // newline
1840 case '\015': // return
1841 key = 1;
1842 break;
1843 case '\033': // escape
1844 key = 0;
1845 break;
1846
1847 default:
1848 XBell((Display*)fDisplay, percent);
1849 }
1850 }
1851 }
1852 }
1854
1855 if (cursor != 0) {
1856 XUndefineCursor((Display*)fDisplay, gCws->fWindow);
1857 cursor = 0;
1858 }
1859
1860 return key;
1861}
1862
1863////////////////////////////////////////////////////////////////////////////////
1864/// Rescale the window wid.
1865///
1866/// \param [in] wid : Window identifier
1867/// \param [in] w : Width
1868/// \param [in] h : Height
1869
1870void TGX11::RescaleWindow(int wid, unsigned int w, unsigned int h)
1871{
1872 int i;
1873
1874 gTws = &fWindows[wid];
1875 if (!gTws->fOpen) return;
1876
1877 // don't do anything when size did not change
1878 if (gTws->fWidth == w && gTws->fHeight == h) return;
1879
1880 XResizeWindow((Display*)fDisplay, gTws->fWindow, w, h);
1881
1882 if (gTws->fBuffer) {
1883 // don't free and recreate pixmap when new pixmap is smaller
1884 if (gTws->fWidth < w || gTws->fHeight < h) {
1885 XFreePixmap((Display*)fDisplay,gTws->fBuffer);
1886 gTws->fBuffer = XCreatePixmap((Display*)fDisplay, fRootWin, w, h, fDepth);
1887 }
1888 for (i = 0; i < kMAXGC; i++) XSetClipMask((Display*)fDisplay, gGClist[i], None);
1889 SetColor(gGCpxmp, 0);
1890 XFillRectangle( (Display*)fDisplay, gTws->fBuffer, *gGCpxmp, 0, 0, w, h);
1891 SetColor(gGCpxmp, 1);
1892 if (gTws->fDoubleBuffer) gTws->fDrawing = gTws->fBuffer;
1893 }
1894 gTws->fWidth = w;
1895 gTws->fHeight = h;
1896}
1897
1898////////////////////////////////////////////////////////////////////////////////
1899/// Resize a pixmap.
1900///
1901/// \param [in] wid : pixmap to be resized
1902/// \param [in] w,h : Width and height of the pixmap
1903
1904int TGX11::ResizePixmap(int wid, unsigned int w, unsigned int h)
1905{
1906 Window root;
1907 unsigned int wval, hval;
1908 int xx, yy, i;
1909 unsigned int ww, hh, border, depth;
1910 wval = w;
1911 hval = h;
1912
1913 gTws = &fWindows[wid];
1914
1915 // don't do anything when size did not change
1916 // if (gTws->fWidth == wval && gTws->fHeight == hval) return 0;
1917
1918 // due to round-off errors in TPad::Resize() we might get +/- 1 pixel
1919 // change, in those cases don't resize pixmap
1920 if (gTws->fWidth >= wval-1 && gTws->fWidth <= wval+1 &&
1921 gTws->fHeight >= hval-1 && gTws->fHeight <= hval+1) return 0;
1922
1923 // don't free and recreate pixmap when new pixmap is smaller
1924 if (gTws->fWidth < wval || gTws->fHeight < hval) {
1925 XFreePixmap((Display*)fDisplay, gTws->fWindow);
1926 gTws->fWindow = XCreatePixmap((Display*)fDisplay, fRootWin, wval, hval, fDepth);
1927 }
1928 XGetGeometry((Display*)fDisplay, gTws->fWindow, &root, &xx, &yy, &ww, &hh, &border, &depth);
1929
1930 for (i = 0; i < kMAXGC; i++)
1931 XSetClipMask((Display*)fDisplay, gGClist[i], None);
1932
1933 SetColor(gGCpxmp, 0);
1934 XFillRectangle((Display*)fDisplay, gTws->fWindow, *gGCpxmp, 0, 0, ww, hh);
1935 SetColor(gGCpxmp, 1);
1936
1937 // Initialise the window structure
1938 gTws->fDrawing = gTws->fWindow;
1939 gTws->fWidth = wval;
1940 gTws->fHeight = hval;
1941
1942 return 1;
1943}
1944
1945////////////////////////////////////////////////////////////////////////////////
1946/// Resize the current window if necessary.
1947
1949{
1950 int i;
1951 int xval=0, yval=0;
1952 Window win, root=0;
1953 unsigned int wval=0, hval=0, border=0, depth=0;
1954
1955 gTws = &fWindows[wid];
1956
1957 win = gTws->fWindow;
1958
1959 XGetGeometry((Display*)fDisplay, win, &root,
1960 &xval, &yval, &wval, &hval, &border, &depth);
1961 if (wval >= 65500) wval = 1;
1962 if (hval >= 65500) hval = 1;
1963
1964 // don't do anything when size did not change
1965 if (gTws->fWidth == wval && gTws->fHeight == hval) return;
1966
1967 XResizeWindow((Display*)fDisplay, gTws->fWindow, wval, hval);
1968
1969 if (gTws->fBuffer) {
1970 if (gTws->fWidth < wval || gTws->fHeight < hval) {
1971 XFreePixmap((Display*)fDisplay,gTws->fBuffer);
1972 gTws->fBuffer = XCreatePixmap((Display*)fDisplay, fRootWin, wval, hval, fDepth);
1973 }
1974 for (i = 0; i < kMAXGC; i++) XSetClipMask((Display*)fDisplay, gGClist[i], None);
1975 SetColor(gGCpxmp, 0);
1976 XFillRectangle((Display*)fDisplay, gTws->fBuffer, *gGCpxmp, 0, 0, wval, hval);
1977 SetColor(gGCpxmp, 1);
1978 if (gTws->fDoubleBuffer) gTws->fDrawing = gTws->fBuffer;
1979 }
1980 gTws->fWidth = wval;
1981 gTws->fHeight = hval;
1982}
1983
1984////////////////////////////////////////////////////////////////////////////////
1985/// Select window to which subsequent output is directed.
1986
1988{
1990 int i;
1991
1992 if (wid < 0 || wid >= fMaxNumberOfWindows || !fWindows[wid].fOpen) return;
1993
1994 gCws = &fWindows[wid];
1995
1996 if (gCws->fClip && !gCws->fIsPixmap && !gCws->fDoubleBuffer) {
1997 region.x = gCws->fXclip;
1998 region.y = gCws->fYclip;
1999 region.width = gCws->fWclip;
2000 region.height = gCws->fHclip;
2001 for (i = 0; i < kMAXGC; i++)
2002 XSetClipRectangles((Display*)fDisplay, gGClist[i], 0, 0, &region, 1, YXBanded);
2003 } else {
2004 for (i = 0; i < kMAXGC; i++)
2005 XSetClipMask((Display*)fDisplay, gGClist[i], None);
2006 }
2007}
2008
2009////////////////////////////////////////////////////////////////////////////////
2010/// Set character up vector.
2011
2013{
2014 if (chupx == fCharacterUpX && chupy == fCharacterUpY) return;
2015
2016 if (chupx == 0 && chupy == 0) fTextAngle = 0;
2017 else if (chupx == 0 && chupy == 1) fTextAngle = 0;
2018 else if (chupx == -1 && chupy == 0) fTextAngle = 90;
2019 else if (chupx == 0 && chupy == -1) fTextAngle = 180;
2020 else if (chupx == 1 && chupy == 0) fTextAngle = 270;
2021 else {
2023 if (chupy < 0) fTextAngle = 180 - fTextAngle;
2024 if (TMath::Abs(fTextAngle) <= 0.01) fTextAngle = 0;
2025 }
2028}
2029
2030////////////////////////////////////////////////////////////////////////////////
2031/// Turn off the clipping for the window wid.
2032
2034{
2035 gTws = &fWindows[wid];
2036 gTws->fClip = 0;
2037
2038 for (int i = 0; i < kMAXGC; i++)
2039 XSetClipMask( (Display*)fDisplay, gGClist[i], None );
2040}
2041
2042////////////////////////////////////////////////////////////////////////////////
2043/// Set clipping region for the window wid.
2044///
2045/// \param [in] wid : Window identifier
2046/// \param [in] x,y : origin of clipping rectangle
2047/// \param [in] w,h : size of clipping rectangle;
2048
2049void TGX11::SetClipRegion(int wid, int x, int y, unsigned int w, unsigned int h)
2050{
2051
2052 gTws = &fWindows[wid];
2053 gTws->fXclip = x;
2054 gTws->fYclip = y;
2055 gTws->fWclip = w;
2056 gTws->fHclip = h;
2057 gTws->fClip = 1;
2058 if (gTws->fClip && !gTws->fIsPixmap && !gTws->fDoubleBuffer) {
2060 region.x = gTws->fXclip;
2061 region.y = gTws->fYclip;
2062 region.width = gTws->fWclip;
2063 region.height = gTws->fHclip;
2064 for (int i = 0; i < kMAXGC; i++)
2065 XSetClipRectangles((Display*)fDisplay, gGClist[i], 0, 0, &region, 1, YXBanded);
2066 }
2067}
2068
2069////////////////////////////////////////////////////////////////////////////////
2070/// Set the foreground color in GC.
2071
2072void TGX11::SetColor(void *gci, int ci)
2073{
2074 GC gc = *(GC *)gci;
2075
2076 TColor *color = gROOT->GetColor(ci);
2077 if (color)
2078 SetRGB(ci, color->GetRed(), color->GetGreen(), color->GetBlue());
2079
2080 XColor_t &col = GetColor(ci);
2081 if (fColormap && !col.fDefined) {
2082 col = GetColor(0);
2083 } else if (!fColormap && (ci < 0 || ci > 1)) {
2084 col = GetColor(0);
2085 }
2086
2087 if (fDrawMode == kXor) {
2088 XGCValues values;
2089 XGetGCValues((Display*)fDisplay, gc, GCBackground, &values);
2090 XSetForeground((Display*)fDisplay, gc, col.fPixel ^ values.background);
2091 } else {
2092 XSetForeground((Display*)fDisplay, gc, col.fPixel);
2093
2094 // make sure that foreground and background are different
2095 XGCValues values;
2096 XGetGCValues((Display*)fDisplay, gc, GCForeground | GCBackground, &values);
2097 if (values.foreground == values.background)
2098 XSetBackground((Display*)fDisplay, gc, GetColor(!ci).fPixel);
2099 }
2100}
2101
2102////////////////////////////////////////////////////////////////////////////////
2103/// Set the cursor.
2104
2106{
2107 gTws = &fWindows[wid];
2108 XDefineCursor((Display*)fDisplay, gTws->fWindow, fCursors[cursor]);
2109}
2110
2111////////////////////////////////////////////////////////////////////////////////
2112/// Set the double buffer on/off on window wid.
2113///
2114/// \param [in] wid : Window identifier.
2115/// - 999 means all the opened windows.
2116/// \param [in] mode :
2117/// - 1 double buffer is on
2118/// - 0 double buffer is off
2119
2121{
2122 if (wid == 999) {
2123 for (int i = 0; i < fMaxNumberOfWindows; i++) {
2124 gTws = &fWindows[i];
2125 if (gTws->fOpen) {
2126 switch (mode) {
2127 case 1 :
2129 break;
2130 default:
2132 break;
2133 }
2134 }
2135 }
2136 } else {
2137 gTws = &fWindows[wid];
2138 if (!gTws->fOpen) return;
2139 switch (mode) {
2140 case 1 :
2142 return;
2143 default:
2145 return;
2146 }
2147 }
2148}
2149
2150////////////////////////////////////////////////////////////////////////////////
2151/// Turn double buffer mode off.
2152
2154{
2155 if (!gTws->fDoubleBuffer) return;
2156 gTws->fDoubleBuffer = 0;
2157 gTws->fDrawing = gTws->fWindow;
2158}
2159
2160////////////////////////////////////////////////////////////////////////////////
2161/// Turn double buffer mode on.
2162
2164{
2165 if (gTws->fDoubleBuffer || gTws->fIsPixmap) return;
2166 if (!gTws->fBuffer) {
2167 gTws->fBuffer = XCreatePixmap((Display*)fDisplay, fRootWin,
2168 gTws->fWidth, gTws->fHeight, fDepth);
2169 SetColor(gGCpxmp, 0);
2170 XFillRectangle((Display*)fDisplay, gTws->fBuffer, *gGCpxmp, 0, 0, gTws->fWidth, gTws->fHeight);
2171 SetColor(gGCpxmp, 1);
2172 }
2173 for (int i = 0; i < kMAXGC; i++) XSetClipMask((Display*)fDisplay, gGClist[i], None);
2174 gTws->fDoubleBuffer = 1;
2175 gTws->fDrawing = gTws->fBuffer;
2176}
2177
2178////////////////////////////////////////////////////////////////////////////////
2179/// Set the drawing mode.
2180///
2181/// \param [in] mode : drawing mode
2182/// - mode=1 copy
2183/// - mode=2 xor
2184/// - mode=3 invert
2185/// - mode=4 set the suitable mode for cursor echo according to
2186/// the vendor
2187
2189{
2190 int i;
2191 if (fDisplay) {
2192 switch (mode) {
2193 case kCopy:
2194 for (i = 0; i < kMAXGC; i++) XSetFunction((Display*)fDisplay, gGClist[i], GXcopy);
2195 break;
2196
2197 case kXor:
2198 for (i = 0; i < kMAXGC; i++) XSetFunction((Display*)fDisplay, gGClist[i], GXxor);
2199 break;
2200
2201 case kInvert:
2202 for (i = 0; i < kMAXGC; i++) XSetFunction((Display*)fDisplay, gGClist[i], GXinvert);
2203 break;
2204 }
2205 }
2206 fDrawMode = mode;
2207}
2208
2209////////////////////////////////////////////////////////////////////////////////
2210/// Set color index for fill areas.
2211
2213{
2214 if (!gStyle->GetFillColor() && cindex > 1) cindex = 0;
2215 if (cindex >= 0) SetColor(gGCfill, Int_t(cindex));
2217
2218 // invalidate fill pattern
2219 if (gFillPattern != 0) {
2220 XFreePixmap((Display*)fDisplay, gFillPattern);
2221 gFillPattern = 0;
2222 }
2223}
2224
2225////////////////////////////////////////////////////////////////////////////////
2226/// Set fill area style.
2227///
2228/// \param [in] fstyle : compound fill area interior style
2229/// - fstyle = 1000*interiorstyle + styleindex
2230
2232{
2233 if (fFillStyle == fstyle) return;
2235 Int_t style = fstyle/1000;
2236 Int_t fasi = fstyle%1000;
2238}
2239
2240////////////////////////////////////////////////////////////////////////////////
2241/// Set fill area style index.
2242
2244{
2245 static int current_fasi = 0;
2246
2247 fFillStyle = 1000*style + fasi;
2248
2249 switch (style) {
2250
2251 case 1: // solid
2252 gFillHollow = 0;
2254 break;
2255
2256 case 2: // pattern
2257 gFillHollow = 1;
2258 break;
2259
2260 case 3: // hatch
2261 gFillHollow = 0;
2263 if (fasi != current_fasi) {
2264 if (gFillPattern != 0) {
2265 XFreePixmap((Display*)fDisplay, gFillPattern);
2266 gFillPattern = 0;
2267 }
2268 int stn = (fasi >= 1 && fasi <=25) ? fasi : 2;
2269
2271 (const char*)gStipples[stn], 16, 16);
2272
2273 XSetStipple( (Display*)fDisplay, *gGCfill, gFillPattern );
2275 }
2276 break;
2277
2278 default:
2279 gFillHollow = 1;
2280 }
2281}
2282
2283////////////////////////////////////////////////////////////////////////////////
2284/// Set input on or off.
2285
2287{
2288 XSetWindowAttributes attributes;
2290
2291 if (inp == 1) {
2292 attributes.event_mask = gMouseMask | gKeybdMask;
2294 XChangeWindowAttributes((Display*)fDisplay, gCws->fWindow, attr_mask, &attributes);
2295 } else {
2296 attributes.event_mask = NoEventMask;
2298 XChangeWindowAttributes((Display*)fDisplay, gCws->fWindow, attr_mask, &attributes);
2299 }
2300}
2301
2302////////////////////////////////////////////////////////////////////////////////
2303/// Set color index for lines.
2304
2306{
2307 if (cindex < 0) return;
2308
2310
2313}
2314
2315////////////////////////////////////////////////////////////////////////////////
2316/// Set line type.
2317///
2318/// \param [in] n : length of dash list
2319/// \param [in] dash : dash segment lengths
2320///
2321/// - if n <= 0 use solid lines
2322/// - if n > 0 use dashed lines described by DASH(N)
2323/// e.g. N=4,DASH=(6,3,1,3) gives a dashed-dotted line with dash length 6
2324/// and a gap of 7 between dashes
2325
2327{
2328 if (n <= 0) {
2332 } else {
2333 gDashSize = TMath::Min((int)sizeof(gDashList),n);
2334 gDashLength = 0;
2335 for (int i = 0; i < gDashSize; i++ ) {
2336 gDashList[i] = dash[i];
2337 gDashLength += gDashList[i];
2338 }
2339 gDashOffset = 0;
2341 if (gLineWidth == 0) gLineWidth =1;
2346 }
2347}
2348
2349////////////////////////////////////////////////////////////////////////////////
2350/// Set line style.
2351
2353{
2354 static Int_t dashed[2] = {3,3};
2355 static Int_t dotted[2] = {1,2};
2356 static Int_t dasheddotted[4] = {3,4,1,4};
2357
2358 if (fLineStyle != lstyle) { //set style index only if different
2360 if (lstyle <= 1 ) {
2361 SetLineType(0, nullptr);
2362 } else if (lstyle == 2 ) {
2363 SetLineType(2, dashed);
2364 } else if (lstyle == 3 ) {
2365 SetLineType(2, dotted);
2366 } else if (lstyle == 4 ) {
2368 } else {
2370 TObjArray *tokens = st.Tokenize(" ");
2371 Int_t nt;
2372 nt = tokens->GetEntries();
2373 Int_t *linestyle = new Int_t[nt];
2374 for (Int_t j = 0; j<nt; j++) {
2375 Int_t it;
2376 sscanf(((TObjString*)tokens->At(j))->GetName(), "%d", &it);
2377 linestyle[j] = (Int_t)(it/4);
2378 }
2380 delete [] linestyle;
2381 delete tokens;
2382 }
2383 }
2384}
2385
2386////////////////////////////////////////////////////////////////////////////////
2387/// Set line width.
2388///
2389/// \param [in] width : line width in pixels
2390
2392{
2393 if (fLineWidth == width) return;
2394 fLineWidth = width;
2395
2396 if (width == 1 && gLineStyle == LineSolid) gLineWidth = 0;
2397 else gLineWidth = width;
2398
2399 if (gLineWidth < 0) return;
2400
2405}
2406
2407////////////////////////////////////////////////////////////////////////////////
2408/// Set color index for markers.
2409
2411{
2412 if (cindex < 0) return;
2413
2415
2417}
2418
2419////////////////////////////////////////////////////////////////////////////////
2420/// Set marker size index.
2421///
2422/// \param [in] msize : marker scale factor
2423
2425{
2426 if (msize == fMarkerSize) return;
2427
2429 if (msize < 0) return;
2430
2432}
2433
2434////////////////////////////////////////////////////////////////////////////////
2435/// Set marker type.
2436///
2437/// \param [in] type : marker type
2438/// \param [in] n : length of marker description
2439/// \param [in] xy : list of points describing marker shape
2440///
2441/// - if n == 0 marker is a single point
2442/// - if TYPE == 0 marker is hollow circle of diameter N
2443/// - if TYPE == 1 marker is filled circle of diameter N
2444/// - if TYPE == 2 marker is a hollow polygon describe by line XY
2445/// - if TYPE == 3 marker is a filled polygon describe by line XY
2446/// - if TYPE == 4 marker is described by segmented line XY
2447/// e.g. TYPE=4,N=4,XY=(-3,0,3,0,0,-3,0,3) sets a plus shape of 7x7 pixels
2448
2450{
2451 gMarker.type = type;
2452 gMarker.n = n < kMAXMK ? n : kMAXMK;
2453 if (gMarker.type >= 2) {
2454 for (int i = 0; i < gMarker.n; i++) {
2455 gMarker.xy[i].x = xy[i].x;
2456 gMarker.xy[i].y = xy[i].y;
2457 }
2458 }
2459}
2460
2461////////////////////////////////////////////////////////////////////////////////
2462/// Set marker style.
2463
2465{
2466 if (fMarkerStyle == markerstyle) return;
2467 static RXPoint shape[30];
2471
2472 // The fast pixel markers need to be treated separately
2473 if (markerstyle == 1 || markerstyle == 6 || markerstyle == 7) {
2475 } else {
2478 }
2479
2481 Int_t im = Int_t(4*MarkerSizeReduced + 0.5);
2482 if (markerstyle == 2) {
2483 // + shaped marker
2484 shape[0].x = -im; shape[0].y = 0;
2485 shape[1].x = im; shape[1].y = 0;
2486 shape[2].x = 0 ; shape[2].y = -im;
2487 shape[3].x = 0 ; shape[3].y = im;
2488 SetMarkerType(4,4,shape);
2489 } else if (markerstyle == 3 || markerstyle == 31) {
2490 // * shaped marker
2491 shape[0].x = -im; shape[0].y = 0;
2492 shape[1].x = im; shape[1].y = 0;
2493 shape[2].x = 0 ; shape[2].y = -im;
2494 shape[3].x = 0 ; shape[3].y = im;
2495 im = Int_t(0.707*Float_t(im) + 0.5);
2496 shape[4].x = -im; shape[4].y = -im;
2497 shape[5].x = im; shape[5].y = im;
2498 shape[6].x = -im; shape[6].y = im;
2499 shape[7].x = im; shape[7].y = -im;
2500 SetMarkerType(4,8,shape);
2501 } else if (markerstyle == 4 || markerstyle == 24) {
2502 // O shaped marker
2503 SetMarkerType(0,im*2,shape);
2504 } else if (markerstyle == 5) {
2505 // X shaped marker
2506 im = Int_t(0.707*Float_t(im) + 0.5);
2507 shape[0].x = -im; shape[0].y = -im;
2508 shape[1].x = im; shape[1].y = im;
2509 shape[2].x = -im; shape[2].y = im;
2510 shape[3].x = im; shape[3].y = -im;
2511 SetMarkerType(4,4,shape);
2512 } else if (markerstyle == 6) {
2513 // + shaped marker (with 1 pixel)
2514 shape[0].x = -1 ; shape[0].y = 0;
2515 shape[1].x = 1 ; shape[1].y = 0;
2516 shape[2].x = 0 ; shape[2].y = -1;
2517 shape[3].x = 0 ; shape[3].y = 1;
2518 SetMarkerType(4,4,shape);
2519 } else if (markerstyle == 7) {
2520 // . shaped marker (with 9 pixel)
2521 shape[0].x = -1 ; shape[0].y = 1;
2522 shape[1].x = 1 ; shape[1].y = 1;
2523 shape[2].x = -1 ; shape[2].y = 0;
2524 shape[3].x = 1 ; shape[3].y = 0;
2525 shape[4].x = -1 ; shape[4].y = -1;
2526 shape[5].x = 1 ; shape[5].y = -1;
2527 SetMarkerType(4,6,shape);
2528 } else if (markerstyle == 8 || markerstyle == 20) {
2529 // O shaped marker (filled)
2530 SetMarkerType(1,im*2,shape);
2531 } else if (markerstyle == 21) {
2532 // full square
2533 shape[0].x = -im; shape[0].y = -im;
2534 shape[1].x = im; shape[1].y = -im;
2535 shape[2].x = im; shape[2].y = im;
2536 shape[3].x = -im; shape[3].y = im;
2537 shape[4].x = -im; shape[4].y = -im;
2538 SetMarkerType(3,5,shape);
2539 } else if (markerstyle == 22) {
2540 // full triangle up
2541 shape[0].x = -im; shape[0].y = im;
2542 shape[1].x = im; shape[1].y = im;
2543 shape[2].x = 0; shape[2].y = -im;
2544 shape[3].x = -im; shape[3].y = im;
2545 SetMarkerType(3,4,shape);
2546 } else if (markerstyle == 23) {
2547 // full triangle down
2548 shape[0].x = 0; shape[0].y = im;
2549 shape[1].x = im; shape[1].y = -im;
2550 shape[2].x = -im; shape[2].y = -im;
2551 shape[3].x = 0; shape[3].y = im;
2552 SetMarkerType(3,4,shape);
2553 } else if (markerstyle == 25) {
2554 // open square
2555 shape[0].x = -im; shape[0].y = -im;
2556 shape[1].x = im; shape[1].y = -im;
2557 shape[2].x = im; shape[2].y = im;
2558 shape[3].x = -im; shape[3].y = im;
2559 shape[4].x = -im; shape[4].y = -im;
2560 SetMarkerType(2,5,shape);
2561 } else if (markerstyle == 26) {
2562 // open triangle up
2563 shape[0].x = -im; shape[0].y = im;
2564 shape[1].x = im; shape[1].y = im;
2565 shape[2].x = 0; shape[2].y = -im;
2566 shape[3].x = -im; shape[3].y = im;
2567 SetMarkerType(2,4,shape);
2568 } else if (markerstyle == 27) {
2569 // open losange
2570 Int_t imx = Int_t(2.66*MarkerSizeReduced + 0.5);
2571 shape[0].x =-imx; shape[0].y = 0;
2572 shape[1].x = 0; shape[1].y = -im;
2573 shape[2].x = imx; shape[2].y = 0;
2574 shape[3].x = 0; shape[3].y = im;
2575 shape[4].x =-imx; shape[4].y = 0;
2576 SetMarkerType(2,5,shape);
2577 } else if (markerstyle == 28) {
2578 // open cross
2579 Int_t imx = Int_t(1.33*MarkerSizeReduced + 0.5);
2580 shape[0].x = -im; shape[0].y =-imx;
2581 shape[1].x =-imx; shape[1].y =-imx;
2582 shape[2].x =-imx; shape[2].y = -im;
2583 shape[3].x = imx; shape[3].y = -im;
2584 shape[4].x = imx; shape[4].y =-imx;
2585 shape[5].x = im; shape[5].y =-imx;
2586 shape[6].x = im; shape[6].y = imx;
2587 shape[7].x = imx; shape[7].y = imx;
2588 shape[8].x = imx; shape[8].y = im;
2589 shape[9].x =-imx; shape[9].y = im;
2590 shape[10].x=-imx; shape[10].y= imx;
2591 shape[11].x= -im; shape[11].y= imx;
2592 shape[12].x= -im; shape[12].y=-imx;
2593 SetMarkerType(2,13,shape);
2594 } else if (markerstyle == 29) {
2595 // full star pentagone
2596 Int_t im1 = Int_t(0.66*MarkerSizeReduced + 0.5);
2597 Int_t im2 = Int_t(2.00*MarkerSizeReduced + 0.5);
2598 Int_t im3 = Int_t(2.66*MarkerSizeReduced + 0.5);
2599 Int_t im4 = Int_t(1.33*MarkerSizeReduced + 0.5);
2600 shape[0].x = -im; shape[0].y = im4;
2601 shape[1].x =-im2; shape[1].y =-im1;
2602 shape[2].x =-im3; shape[2].y = -im;
2603 shape[3].x = 0; shape[3].y =-im2;
2604 shape[4].x = im3; shape[4].y = -im;
2605 shape[5].x = im2; shape[5].y =-im1;
2606 shape[6].x = im; shape[6].y = im4;
2607 shape[7].x = im4; shape[7].y = im4;
2608 shape[8].x = 0; shape[8].y = im;
2609 shape[9].x =-im4; shape[9].y = im4;
2610 shape[10].x= -im; shape[10].y= im4;
2611 SetMarkerType(3,11,shape);
2612 } else if (markerstyle == 30) {
2613 // open star pentagone
2614 Int_t im1 = Int_t(0.66*MarkerSizeReduced + 0.5);
2615 Int_t im2 = Int_t(2.00*MarkerSizeReduced + 0.5);
2616 Int_t im3 = Int_t(2.66*MarkerSizeReduced + 0.5);
2617 Int_t im4 = Int_t(1.33*MarkerSizeReduced + 0.5);
2618 shape[0].x = -im; shape[0].y = im4;
2619 shape[1].x =-im2; shape[1].y =-im1;
2620 shape[2].x =-im3; shape[2].y = -im;
2621 shape[3].x = 0; shape[3].y =-im2;
2622 shape[4].x = im3; shape[4].y = -im;
2623 shape[5].x = im2; shape[5].y =-im1;
2624 shape[6].x = im; shape[6].y = im4;
2625 shape[7].x = im4; shape[7].y = im4;
2626 shape[8].x = 0; shape[8].y = im;
2627 shape[9].x =-im4; shape[9].y = im4;
2628 shape[10].x= -im; shape[10].y= im4;
2629 SetMarkerType(2,11,shape);
2630 } else if (markerstyle == 32) {
2631 // open triangle down
2632 shape[0].x = 0; shape[0].y = im;
2633 shape[1].x = im; shape[1].y = -im;
2634 shape[2].x = -im; shape[2].y = -im;
2635 shape[3].x = 0; shape[3].y = im;
2636 SetMarkerType(2,4,shape);
2637 } else if (markerstyle == 33) {
2638 // full losange
2639 Int_t imx = Int_t(2.66*MarkerSizeReduced + 0.5);
2640 shape[0].x =-imx; shape[0].y = 0;
2641 shape[1].x = 0; shape[1].y = -im;
2642 shape[2].x = imx; shape[2].y = 0;
2643 shape[3].x = 0; shape[3].y = im;
2644 shape[4].x =-imx; shape[4].y = 0;
2645 SetMarkerType(3,5,shape);
2646 } else if (markerstyle == 34) {
2647 // full cross
2648 Int_t imx = Int_t(1.33*MarkerSizeReduced + 0.5);
2649 shape[0].x = -im; shape[0].y =-imx;
2650 shape[1].x =-imx; shape[1].y =-imx;
2651 shape[2].x =-imx; shape[2].y = -im;
2652 shape[3].x = imx; shape[3].y = -im;
2653 shape[4].x = imx; shape[4].y =-imx;
2654 shape[5].x = im; shape[5].y =-imx;
2655 shape[6].x = im; shape[6].y = imx;
2656 shape[7].x = imx; shape[7].y = imx;
2657 shape[8].x = imx; shape[8].y = im;
2658 shape[9].x =-imx; shape[9].y = im;
2659 shape[10].x=-imx; shape[10].y= imx;
2660 shape[11].x= -im; shape[11].y= imx;
2661 shape[12].x= -im; shape[12].y=-imx;
2662 SetMarkerType(3,13,shape);
2663 } else if (markerstyle == 35) {
2664 // diamond with cross
2665 shape[0].x =-im; shape[0].y = 0;
2666 shape[1].x = 0; shape[1].y = -im;
2667 shape[2].x = im; shape[2].y = 0;
2668 shape[3].x = 0; shape[3].y = im;
2669 shape[4].x =-im; shape[4].y = 0;
2670 shape[5].x = im; shape[5].y = 0;
2671 shape[6].x = 0; shape[6].y = im;
2672 shape[7].x = 0; shape[7].y =-im;
2673 SetMarkerType(2,8,shape);
2674 } else if (markerstyle == 36) {
2675 // square with diagonal cross
2676 shape[0].x = -im; shape[0].y = -im;
2677 shape[1].x = im; shape[1].y = -im;
2678 shape[2].x = im; shape[2].y = im;
2679 shape[3].x = -im; shape[3].y = im;
2680 shape[4].x = -im; shape[4].y = -im;
2681 shape[5].x = im; shape[5].y = im;
2682 shape[6].x = -im; shape[6].y = im;
2683 shape[7].x = im; shape[7].y = -im;
2684 SetMarkerType(2,8,shape);
2685 } else if (markerstyle == 37) {
2686 // open three triangles
2687 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
2688 shape[0].x = 0; shape[0].y = 0;
2689 shape[1].x =-im2; shape[1].y = im;
2690 shape[2].x = im2; shape[2].y = im;
2691 shape[3].x = 0; shape[3].y = 0;
2692 shape[4].x =-im2; shape[4].y = -im;
2693 shape[5].x = -im; shape[5].y = 0;
2694 shape[6].x = 0; shape[6].y = 0;
2695 shape[7].x = im; shape[7].y = 0;
2696 shape[8].x = im2; shape[8].y = -im;
2697 shape[9].x = 0; shape[9].y = 0;
2698 SetMarkerType(2, 10,shape);
2699 } else if (markerstyle == 38) {
2700 // + shaped marker with octagon
2701 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
2702 shape[0].x = -im; shape[0].y = 0;
2703 shape[1].x = -im; shape[1].y =-im2;
2704 shape[2].x =-im2; shape[2].y = -im;
2705 shape[3].x = im2; shape[3].y = -im;
2706 shape[4].x = im; shape[4].y =-im2;
2707 shape[5].x = im; shape[5].y = im2;
2708 shape[6].x = im2; shape[6].y = im;
2709 shape[7].x =-im2; shape[7].y = im;
2710 shape[8].x = -im; shape[8].y = im2;
2711 shape[9].x = -im; shape[9].y = 0;
2712 shape[10].x = im; shape[10].y = 0;
2713 shape[11].x = 0; shape[11].y = 0;
2714 shape[12].x = 0; shape[12].y = -im;
2715 shape[13].x = 0; shape[13].y = im;
2716 shape[14].x = 0; shape[14].y = 0;
2717 SetMarkerType(2,15,shape);
2718 } else if (markerstyle == 39) {
2719 // filled three triangles
2720 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
2721 shape[0].x = 0; shape[0].y = 0;
2722 shape[1].x =-im2; shape[1].y = im;
2723 shape[2].x = im2; shape[2].y = im;
2724 shape[3].x = 0; shape[3].y = 0;
2725 shape[4].x =-im2; shape[4].y = -im;
2726 shape[5].x = -im; shape[5].y = 0;
2727 shape[6].x = 0; shape[6].y = 0;
2728 shape[7].x = im; shape[7].y = 0;
2729 shape[8].x = im2; shape[8].y = -im;
2730 SetMarkerType(3,9,shape);
2731 } else if (markerstyle == 40) {
2732 // four open triangles X
2733 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
2734 shape[0].x = 0; shape[0].y = 0;
2735 shape[1].x = im2; shape[1].y = im;
2736 shape[2].x = im; shape[2].y = im2;
2737 shape[3].x = 0; shape[3].y = 0;
2738 shape[4].x = im; shape[4].y = -im2;
2739 shape[5].x = im2; shape[5].y = -im;
2740 shape[6].x = 0; shape[6].y = 0;
2741 shape[7].x = -im2; shape[7].y = -im;
2742 shape[8].x = -im; shape[8].y = -im2;
2743 shape[9].x = 0; shape[9].y = 0;
2744 shape[10].x = -im; shape[10].y = im2;
2745 shape[11].x = -im2; shape[11].y = im;
2746 shape[12].x = 0; shape[12].y = 0;
2747 SetMarkerType(2,13,shape);
2748 } else if (markerstyle == 41) {
2749 // four filled triangles X
2750 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
2751 shape[0].x = 0; shape[0].y = 0;
2752 shape[1].x = im2; shape[1].y = im;
2753 shape[2].x = im; shape[2].y = im2;
2754 shape[3].x = 0; shape[3].y = 0;
2755 shape[4].x = im; shape[4].y = -im2;
2756 shape[5].x = im2; shape[5].y = -im;
2757 shape[6].x = 0; shape[6].y = 0;
2758 shape[7].x = -im2; shape[7].y = -im;
2759 shape[8].x = -im; shape[8].y = -im2;
2760 shape[9].x = 0; shape[9].y = 0;
2761 shape[10].x = -im; shape[10].y = im2;
2762 shape[11].x = -im2; shape[11].y = im;
2763 shape[12].x = 0; shape[12].y = 0;
2764 SetMarkerType(3,13,shape);
2765 } else if (markerstyle == 42) {
2766 // open double diamonds
2768 shape[0].x= 0; shape[0].y= im;
2769 shape[1].x= -imx; shape[1].y= imx;
2770 shape[2].x = -im; shape[2].y = 0;
2771 shape[3].x = -imx; shape[3].y = -imx;
2772 shape[4].x = 0; shape[4].y = -im;
2773 shape[5].x = imx; shape[5].y = -imx;
2774 shape[6].x = im; shape[6].y = 0;
2775 shape[7].x= imx; shape[7].y= imx;
2776 shape[8].x= 0; shape[8].y= im;
2777 SetMarkerType(2,9,shape);
2778 } else if (markerstyle == 43) {
2779 // filled double diamonds
2781 shape[0].x = 0; shape[0].y = im;
2782 shape[1].x = -imx; shape[1].y = imx;
2783 shape[2].x = -im; shape[2].y = 0;
2784 shape[3].x = -imx; shape[3].y = -imx;
2785 shape[4].x = 0; shape[4].y = -im;
2786 shape[5].x = imx; shape[5].y = -imx;
2787 shape[6].x = im; shape[6].y = 0;
2788 shape[7].x = imx; shape[7].y = imx;
2789 shape[8].x = 0; shape[8].y = im;
2790 SetMarkerType(3,9,shape);
2791 } else if (markerstyle == 44) {
2792 // open four triangles plus
2793 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
2794 shape[0].x = 0; shape[0].y = 0;
2795 shape[1].x = im2; shape[1].y = im;
2796 shape[2].x = -im2; shape[2].y = im;
2797 shape[3].x = im2; shape[3].y = -im;
2798 shape[4].x = -im2; shape[4].y = -im;
2799 shape[5].x = 0; shape[5].y = 0;
2800 shape[6].x = im; shape[6].y = im2;
2801 shape[7].x = im; shape[7].y = -im2;
2802 shape[8].x = -im; shape[8].y = im2;
2803 shape[9].x = -im; shape[9].y = -im2;
2804 shape[10].x = 0; shape[10].y = 0;
2805 SetMarkerType(2,11,shape);
2806 } else if (markerstyle == 45) {
2807 // filled four triangles plus
2808 Int_t im0 = Int_t(0.4*MarkerSizeReduced + 0.5);
2809 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
2810 shape[0].x = im0; shape[0].y = im0;
2811 shape[1].x = im2; shape[1].y = im;
2812 shape[2].x = -im2; shape[2].y = im;
2813 shape[3].x = -im0; shape[3].y = im0;
2814 shape[4].x = -im; shape[4].y = im2;
2815 shape[5].x = -im; shape[5].y = -im2;
2816 shape[6].x = -im0; shape[6].y = -im0;
2817 shape[7].x = -im2; shape[7].y = -im;
2818 shape[8].x = im2; shape[8].y = -im;
2819 shape[9].x = im0; shape[9].y = -im0;
2820 shape[10].x = im; shape[10].y = -im2;
2821 shape[11].x = im; shape[11].y = im2;
2822 shape[12].x = im0; shape[12].y = im0;
2823 SetMarkerType(3,13,shape);
2824 } else if (markerstyle == 46) {
2825 // open four triangles X
2826 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
2827 shape[0].x = 0; shape[0].y = im2;
2828 shape[1].x = -im2; shape[1].y = im;
2829 shape[2].x = -im; shape[2].y = im2;
2830 shape[3].x = -im2; shape[3].y = 0;
2831 shape[4].x = -im; shape[4].y = -im2;
2832 shape[5].x = -im2; shape[5].y = -im;
2833 shape[6].x = 0; shape[6].y = -im2;
2834 shape[7].x = im2; shape[7].y = -im;
2835 shape[8].x = im; shape[8].y = -im2;
2836 shape[9].x = im2; shape[9].y = 0;
2837 shape[10].x = im; shape[10].y = im2;
2838 shape[11].x = im2; shape[11].y = im;
2839 shape[12].x = 0; shape[12].y = im2;
2840 SetMarkerType(2,13,shape);
2841 } else if (markerstyle == 47) {
2842 // filled four triangles X
2843 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
2844 shape[0].x = 0; shape[0].y = im2;
2845 shape[1].x = -im2; shape[1].y = im;
2846 shape[2].x = -im; shape[2].y = im2;
2847 shape[3].x = -im2; shape[3].y = 0;
2848 shape[4].x = -im; shape[4].y = -im2;
2849 shape[5].x = -im2; shape[5].y = -im;
2850 shape[6].x = 0; shape[6].y = -im2;
2851 shape[7].x = im2; shape[7].y = -im;
2852 shape[8].x = im; shape[8].y = -im2;
2853 shape[9].x = im2; shape[9].y = 0;
2854 shape[10].x = im; shape[10].y = im2;
2855 shape[11].x = im2; shape[11].y = im;
2856 shape[12].x = 0; shape[12].y = im2;
2857 SetMarkerType(3,13,shape);
2858 } else if (markerstyle == 48) {
2859 // four filled squares X
2860 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
2861 shape[0].x = 0; shape[0].y = im2*1.005;
2862 shape[1].x = -im2; shape[1].y = im;
2863 shape[2].x = -im; shape[2].y = im2;
2864 shape[3].x = -im2; shape[3].y = 0;
2865 shape[4].x = -im; shape[4].y = -im2;
2866 shape[5].x = -im2; shape[5].y = -im;
2867 shape[6].x = 0; shape[6].y = -im2;
2868 shape[7].x = im2; shape[7].y = -im;
2869 shape[8].x = im; shape[8].y = -im2;
2870 shape[9].x = im2; shape[9].y = 0;
2871 shape[10].x = im; shape[10].y = im2;
2872 shape[11].x = im2; shape[11].y = im;
2873 shape[12].x = 0; shape[12].y = im2*0.995;
2874 shape[13].x = im2*0.995; shape[13].y = 0;
2875 shape[14].x = 0; shape[14].y = -im2*0.995;
2876 shape[15].x = -im2*0.995; shape[15].y = 0;
2877 shape[16].x = 0; shape[16].y = im2*0.995;
2878 SetMarkerType(3,16,shape);
2879 } else if (markerstyle == 49) {
2880 // four filled squares plus
2881 Int_t imx = Int_t(1.33*MarkerSizeReduced + 0.5);
2882 shape[0].x =-imx; shape[0].y =-imx*1.005;
2883 shape[1].x =-imx; shape[1].y = -im;
2884 shape[2].x = imx; shape[2].y = -im;
2885 shape[3].x = imx; shape[3].y =-imx;
2886 shape[4].x = im; shape[4].y =-imx;
2887 shape[5].x = im; shape[5].y = imx;
2888 shape[6].x = imx; shape[6].y = imx;
2889 shape[7].x = imx; shape[7].y = im;
2890 shape[8].x =-imx; shape[8].y = im;
2891 shape[9].x =-imx; shape[9].y = imx;
2892 shape[10].x = -im; shape[10].y = imx;
2893 shape[11].x = -im; shape[11].y =-imx;
2894 shape[12].x =-imx; shape[12].y =-imx*0.995;
2895 shape[13].x =-imx; shape[13].y = imx;
2896 shape[14].x = imx; shape[14].y = imx;
2897 shape[15].x = imx; shape[15].y =-imx;
2898 shape[16].x =-imx; shape[16].y =-imx*1.005;
2899 SetMarkerType(3,17,shape);
2900 } else {
2901 // single dot
2902 SetMarkerType(0,0,shape);
2903 }
2904}
2905
2906////////////////////////////////////////////////////////////////////////////////
2907/// Set opacity of a window. This image manipulation routine works
2908/// by adding to a percent amount of neutral to each pixels RGB.
2909/// Since it requires quite some additional color map entries is it
2910/// only supported on displays with more than > 8 color planes (> 256
2911/// colors).
2912
2914{
2915 if (fDepth <= 8) return;
2916 if (percent == 0) return;
2917 // if 100 percent then just make white
2918
2919 ULong_t *orgcolors = nullptr, *tmpc = nullptr;
2920 Int_t maxcolors = 0, ncolors = 0, ntmpc = 0;
2921
2922 // save previous allocated colors, delete at end when not used anymore
2923 if (gCws->fNewColors) {
2924 tmpc = gCws->fNewColors;
2925 ntmpc = gCws->fNcolors;
2926 }
2927
2928 // get pixmap from server as image
2929 XImage *image = XGetImage((Display*)fDisplay, gCws->fDrawing, 0, 0, gCws->fWidth,
2930 gCws->fHeight, AllPlanes, ZPixmap);
2931 if (!image) return;
2932 // collect different image colors
2933 int x, y;
2934 for (y = 0; y < (int) gCws->fHeight; y++) {
2935 for (x = 0; x < (int) gCws->fWidth; x++) {
2938 }
2939 }
2940 if (ncolors == 0) {
2942 ::operator delete(orgcolors);
2943 return;
2944 }
2945
2946 // create opaque counter parts
2948
2949 if (gCws->fNewColors) {
2950 // put opaque colors in image
2951 for (y = 0; y < (int) gCws->fHeight; y++) {
2952 for (x = 0; x < (int) gCws->fWidth; x++) {
2954 Int_t idx = FindColor(pixel, orgcolors, ncolors);
2955 XPutPixel(image, x, y, gCws->fNewColors[idx]);
2956 }
2957 }
2958 }
2959
2960 // put image back in pixmap on server
2961 XPutImage((Display*)fDisplay, gCws->fDrawing, *gGCpxmp, image, 0, 0, 0, 0,
2962 gCws->fWidth, gCws->fHeight);
2963 XFlush((Display*)fDisplay);
2964
2965 // clean up
2966 if (tmpc) {
2967 if (fRedDiv == -1)
2968 XFreeColors((Display*)fDisplay, fColormap, tmpc, ntmpc, 0);
2969 delete [] tmpc;
2970 }
2972 ::operator delete(orgcolors);
2973}
2974
2975////////////////////////////////////////////////////////////////////////////////
2976/// Collect in orgcolors all different original image colors.
2977
2980{
2981 if (maxcolors == 0) {
2982 ncolors = 0;
2983 maxcolors = 100;
2984 orgcolors = (ULong_t*) ::operator new(maxcolors*sizeof(ULong_t));
2985 }
2986
2987 for (int i = 0; i < ncolors; i++)
2988 if (pixel == orgcolors[i]) return;
2989
2990 if (ncolors >= maxcolors) {
2992 maxcolors*2*sizeof(ULong_t), maxcolors*sizeof(ULong_t));
2993 maxcolors *= 2;
2994 }
2995
2996 orgcolors[ncolors++] = pixel;
2997}
2998
2999////////////////////////////////////////////////////////////////////////////////
3000/// Get RGB values for orgcolors, add percent neutral to the RGB and
3001/// allocate fNewColors.
3002
3004{
3005 if (ncolors == 0) return;
3006
3007 RXColor *xcol = new RXColor[ncolors];
3008
3009 int i;
3010 for (i = 0; i < ncolors; i++) {
3011 xcol[i].pixel = orgcolors[i];
3012 xcol[i].red = xcol[i].green = xcol[i].blue = 0;
3013 xcol[i].flags = DoRed | DoGreen | DoBlue;
3014 }
3015 QueryColors(fColormap, xcol, ncolors);
3016
3017 UShort_t add = percent * kBIGGEST_RGB_VALUE / 100;
3018
3019 Int_t val;
3020 for (i = 0; i < ncolors; i++) {
3021 val = xcol[i].red + add;
3022 if (val > kBIGGEST_RGB_VALUE) val = kBIGGEST_RGB_VALUE;
3023 xcol[i].red = (UShort_t) val;
3024 val = xcol[i].green + add;
3025 if (val > kBIGGEST_RGB_VALUE) val = kBIGGEST_RGB_VALUE;
3026 xcol[i].green = (UShort_t) val;
3027 val = xcol[i].blue + add;
3028 if (val > kBIGGEST_RGB_VALUE) val = kBIGGEST_RGB_VALUE;
3029 xcol[i].blue = (UShort_t) val;
3030 if (!AllocColor(fColormap, &xcol[i]))
3031 Warning("MakeOpaqueColors", "failed to allocate color %hd, %hd, %hd",
3032 xcol[i].red, xcol[i].green, xcol[i].blue);
3033 // assumes that in case of failure xcol[i].pixel is not changed
3034 }
3035
3036 gCws->fNewColors = new ULong_t[ncolors];
3037 gCws->fNcolors = ncolors;
3038
3039 for (i = 0; i < ncolors; i++)
3040 gCws->fNewColors[i] = xcol[i].pixel;
3041
3042 delete [] xcol;
3043}
3044
3045////////////////////////////////////////////////////////////////////////////////
3046/// Returns index in orgcolors (and fNewColors) for pixel.
3047
3049{
3050 for (int i = 0; i < ncolors; i++)
3051 if (pixel == orgcolors[i]) return i;
3052
3053 Error("FindColor", "did not find color, should never happen!");
3054
3055 return 0;
3056}
3057
3058////////////////////////////////////////////////////////////////////////////////
3059/// Set color intensities for given color index.
3060///
3061/// \param [in] cindex : color index
3062/// \param [in] r,g,b : red, green, blue intensities between 0.0 and 1.0
3063
3064void TGX11::SetRGB(int cindex, float r, float g, float b)
3065{
3066 if (fColormap) {
3067 RXColor xcol;
3068 xcol.red = (UShort_t)(r * kBIGGEST_RGB_VALUE);
3069 xcol.green = (UShort_t)(g * kBIGGEST_RGB_VALUE);
3070 xcol.blue = (UShort_t)(b * kBIGGEST_RGB_VALUE);
3071 xcol.flags = DoRed | DoGreen | DoBlue;
3072 XColor_t &col = GetColor(cindex);
3073 if (col.fDefined) {
3074 // if color is already defined with same rgb just return
3075 if (col.fRed == xcol.red && col.fGreen == xcol.green &&
3076 col.fBlue == xcol.blue)
3077 return;
3078 col.fDefined = kFALSE;
3079 if (fRedDiv == -1)
3080 XFreeColors((Display*)fDisplay, fColormap, &col.fPixel, 1, 0);
3081 }
3082 if (AllocColor(fColormap, &xcol)) {
3083 col.fDefined = kTRUE;
3084 col.fPixel = xcol.pixel;
3085 col.fRed = xcol.red;
3086 col.fGreen = xcol.green;
3087 col.fBlue = xcol.blue;
3088 }
3089 }
3090}
3091
3092////////////////////////////////////////////////////////////////////////////////
3093/// Set text alignment.
3094///
3095/// \param [in] talign text alignment
3096
3098{
3099 Int_t txalh = talign/10;
3100 Int_t txalv = talign%10;
3103
3104 switch (txalh) {
3105
3106 case 0 :
3107 case 1 :
3108 switch (txalv) { //left
3109 case 1 :
3110 fTextAlign = 7; //bottom
3111 break;
3112 case 2 :
3113 fTextAlign = 4; //center
3114 break;
3115 case 3 :
3116 fTextAlign = 1; //top
3117 break;
3118 }
3119 break;
3120 case 2 :
3121 switch (txalv) { //center
3122 case 1 :
3123 fTextAlign = 8; //bottom
3124 break;
3125 case 2 :
3126 fTextAlign = 5; //center
3127 break;
3128 case 3 :
3129 fTextAlign = 2; //top
3130 break;
3131 }
3132 break;
3133 case 3 :
3134 switch (txalv) { //right
3135 case 1 :
3136 fTextAlign = 9; //bottom
3137 break;
3138 case 2 :
3139 fTextAlign = 6; //center
3140 break;
3141 case 3 :
3142 fTextAlign = 3; //top
3143 break;
3144 }
3145 break;
3146 }
3147
3149}
3150
3151////////////////////////////////////////////////////////////////////////////////
3152/// Set color index for text.
3153
3155{
3156 if (cindex < 0) return;
3157
3159
3161
3162 XGCValues values;
3163 if (XGetGCValues((Display*)fDisplay, *gGCtext, GCForeground | GCBackground, &values)) {
3164 XSetForeground( (Display*)fDisplay, *gGCinvt, values.background );
3165 XSetBackground( (Display*)fDisplay, *gGCinvt, values.foreground );
3166 } else {
3167 Error("SetTextColor", "cannot get GC values");
3168 }
3169 XSetBackground((Display*)fDisplay, *gGCtext, GetColor(0).fPixel);
3170}
3171
3172////////////////////////////////////////////////////////////////////////////////
3173/// Set text font to specified name.
3174///
3175/// \param [in] fontname font name
3176/// \param [in] mode loading flag
3177/// - mode=0 search if the font exist (kCheck)
3178/// - mode=1 search the font and load it if it exists (kLoad)
3179///
3180/// Set text font to specified name. This function returns 0 if
3181/// the specified font is found, 1 if not.
3182
3184{
3185 char **fontlist;
3186 int fontcount;
3187 int i;
3188
3189 if (mode == kLoad) {
3190 for (i = 0; i < kMAXFONT; i++) {
3191 if (strcmp(fontname, gFont[i].name) == 0) {
3192 gTextFont = gFont[i].id;
3193 XSetFont((Display*)fDisplay, *gGCtext, gTextFont->fid);
3194 XSetFont((Display*)fDisplay, *gGCinvt, gTextFont->fid);
3195 return 0;
3196 }
3197 }
3198 }
3199
3200 fontlist = XListFonts((Display*)fDisplay, fontname, 1, &fontcount);
3201
3202 if (fontlist && fontcount != 0) {
3203 if (mode == kLoad) {
3204 if (gFont[gCurrentFontNumber].id)
3206 gTextFont = XLoadQueryFont((Display*)fDisplay, fontlist[0]);
3207 XSetFont((Display*)fDisplay, *gGCtext, gTextFont->fid);
3208 XSetFont((Display*)fDisplay, *gGCinvt, gTextFont->fid);
3213 }
3215 return 0;
3216 } else {
3217 return 1;
3218 }
3219}
3220
3221////////////////////////////////////////////////////////////////////////////////
3222/// Set current text font number.
3223
3228
3229////////////////////////////////////////////////////////////////////////////////
3230/// Set current text size.
3231
3236
3237////////////////////////////////////////////////////////////////////////////////
3238/// Set synchronisation on or off.
3239///
3240/// \param [in] mode : synchronisation on/off
3241/// - mode=1 on
3242/// - mode<>0 off
3243
3245{
3246 switch (mode) {
3247
3248 case 1 :
3249 XSynchronize((Display*)fDisplay,1);
3250 break;
3251
3252 default:
3253 XSynchronize((Display*)fDisplay,0);
3254 break;
3255 }
3256}
3257
3258////////////////////////////////////////////////////////////////////////////////
3259/// Update display.
3260///
3261/// \param [in] mode : (1) update (0) sync
3262///
3263/// Synchronise client and server once (not permanent).
3264/// Copy the pixmap gCws->fDrawing on the window gCws->fWindow
3265/// if the double buffer is on.
3266
3268{
3269 if (gCws->fDoubleBuffer) {
3270 XCopyArea((Display*)fDisplay, gCws->fDrawing, gCws->fWindow,
3271 *gGCpxmp, 0, 0, gCws->fWidth, gCws->fHeight, 0, 0);
3272 }
3273 if (mode == 1) {
3274 XFlush((Display*)fDisplay);
3275 } else {
3276 XSync((Display*)fDisplay, False);
3277 }
3278}
3279
3280////////////////////////////////////////////////////////////////////////////////
3281/// Set pointer position.
3282///
3283/// \param [in] ix New X coordinate of pointer
3284/// \param [in] iy New Y coordinate of pointer
3285/// \param [in] id Window identifier
3286///
3287/// Coordinates are relative to the origin of the window id
3288/// or to the origin of the current window if id == 0.
3289
3291{
3292 if (!id) {
3293 // Causes problems when calling ProcessEvents()... BadWindow
3294 //XWarpPointer((Display*)fDisplay, None, gCws->fWindow, 0, 0, 0, 0, ix, iy);
3295 } else {
3296 XWarpPointer((Display*)fDisplay, None, (Window) id, 0, 0, 0, 0, ix, iy);
3297 }
3298}
3299
3300////////////////////////////////////////////////////////////////////////////////
3301/// Write the pixmap wid in the bitmap file pxname.
3302///
3303/// \param [in] wid : Pixmap address
3304/// \param [in] w,h : Width and height of the pixmap.
3305/// \param [in] pxname : pixmap name
3306
3307void TGX11::WritePixmap(int wid, unsigned int w, unsigned int h, char *pxname)
3308{
3309 unsigned int wval, hval;
3310 wval = w;
3311 hval = h;
3312
3313 gTws = &fWindows[wid];
3314 XWriteBitmapFile((Display*)fDisplay, pxname, gTws->fDrawing, wval, hval, -1, -1);
3315}
3316
3317
3318//
3319// Functions for GIFencode()
3320//
3321
3322static FILE *gOut; // output unit used WriteGIF and PutByte
3323static XImage *gXimage = nullptr; // image used in WriteGIF and GetPixel
3324
3325extern "C" {
3328 long GIFencode(int Width, int Height, Int_t Ncol, Byte_t R[], Byte_t G[], Byte_t B[], Byte_t ScLine[],
3329 void (*get_scline) (int, int, Byte_t *), void (*pb)(Byte_t));
3330 int GIFdecode(Byte_t *gifArr, Byte_t *pixArr, int *Width, int *Height, int *Ncols, Byte_t *R, Byte_t *G, Byte_t *B);
3331 int GIFinfo(Byte_t *gifArr, int *Width, int *Height, int *Ncols);
3332}
3333
3334////////////////////////////////////////////////////////////////////////////////
3335/// Get pixels in line y and put in array scline.
3336
3337static void GetPixel(int y, int width, Byte_t *scline)
3338{
3339 for (int i = 0; i < width; i++)
3340 scline[i] = Byte_t(XGetPixel(gXimage, i, y));
3341}
3342
3343////////////////////////////////////////////////////////////////////////////////
3344/// Put byte b in output stream.
3345
3346static void PutByte(Byte_t b)
3347{
3348 if (ferror(gOut) == 0) fputc(b, gOut);
3349}
3350
3351////////////////////////////////////////////////////////////////////////////////
3352/// Returns in R G B the ncol colors of the palette used by the image.
3353/// The image pixels are changed to index values in these R G B arrays.
3354/// This produces a colormap with only the used colors (so even on displays
3355/// with more than 8 planes we will be able to create GIF's when the image
3356/// contains no more than 256 different colors). If it does contain more
3357/// colors we will have to use GIFquantize to reduce the number of colors.
3358/// The R G B arrays must be deleted by the caller.
3359
3361{
3362 ULong_t *orgcolors = nullptr;
3363 Int_t maxcolors = 0, ncolors = 0;
3364
3365 // collect different image colors
3366 int x, y;
3367 for (x = 0; x < (int) gCws->fWidth; x++) {
3368 for (y = 0; y < (int) gCws->fHeight; y++) {
3371 }
3372 }
3373
3374 // get RGB values belonging to pixels
3375 RXColor *xcol = new RXColor[ncolors];
3376
3377 int i;
3378 for (i = 0; i < ncolors; i++) {
3379 xcol[i].pixel = orgcolors[i];
3380 xcol[i].red = xcol[i].green = xcol[i].blue = 0;
3381 xcol[i].flags = DoRed | DoGreen | DoBlue;
3382 }
3383 QueryColors(fColormap, xcol, ncolors);
3384
3385 // create RGB arrays and store RGB's for each color and set number of colors
3386 // (space must be delete by caller)
3387 R = new Int_t[ncolors];
3388 G = new Int_t[ncolors];
3389 B = new Int_t[ncolors];
3390
3391 for (i = 0; i < ncolors; i++) {
3392 R[i] = xcol[i].red;
3393 G[i] = xcol[i].green;
3394 B[i] = xcol[i].blue;
3395 }
3396 ncol = ncolors;
3397
3398 // update image with indices (pixels) into the new RGB colormap
3399 for (x = 0; x < (int) gCws->fWidth; x++) {
3400 for (y = 0; y < (int) gCws->fHeight; y++) {
3402 Int_t idx = FindColor(pixel, orgcolors, ncolors);
3403 XPutPixel(image, x, y, idx);
3404 }
3405 }
3406
3407 // cleanup
3408 delete [] xcol;
3409 ::operator delete(orgcolors);
3410}
3411
3412////////////////////////////////////////////////////////////////////////////////
3413/// Writes the current window into GIF file. Returns 1 in case of success,
3414/// 0 otherwise.
3415
3417{
3418 Byte_t scline[2000], r[256], b[256], g[256];
3419 Int_t *red, *green, *blue;
3420 Int_t ncol, maxcol, i;
3421
3422 if (gXimage) {
3424 gXimage = nullptr;
3425 }
3426
3427 gXimage = XGetImage((Display*)fDisplay, gCws->fDrawing, 0, 0,
3428 gCws->fWidth, gCws->fHeight,
3430
3432
3433 if (ncol > 256) {
3434 //GIFquantize(...);
3435 Error("WriteGIF", "Cannot create GIF of image containing more than 256 colors. Try in batch mode.");
3436 delete [] red;
3437 delete [] green;
3438 delete [] blue;
3439 return 0;
3440 }
3441
3442 maxcol = 0;
3443 for (i = 0; i < ncol; i++) {
3444 if (maxcol < red[i] ) maxcol = red[i];
3445 if (maxcol < green[i] ) maxcol = green[i];
3446 if (maxcol < blue[i] ) maxcol = blue[i];
3447 r[i] = 0;
3448 g[i] = 0;
3449 b[i] = 0;
3450 }
3451 if (maxcol != 0) {
3452 for (i = 0; i < ncol; i++) {
3453 r[i] = red[i] * 255/maxcol;
3454 g[i] = green[i] * 255/maxcol;
3455 b[i] = blue[i] * 255/maxcol;
3456 }
3457 }
3458
3459 gOut = fopen(name, "w+");
3460
3461 if (gOut) {
3462 GIFencode(gCws->fWidth, gCws->fHeight,
3463 ncol, r, g, b, scline, ::GetPixel, PutByte);
3464 fclose(gOut);
3465 i = 1;
3466 } else {
3467 Error("WriteGIF","cannot write file: %s",name);
3468 i = 0;
3469 }
3470 delete [] red;
3471 delete [] green;
3472 delete [] blue;
3473 return i;
3474}
3475
3476////////////////////////////////////////////////////////////////////////////////
3477/// Draw image.
3478
3481{
3482 const int maxSegment = 20;
3483 int i, n, x, y, xcur, x1, x2, y1, y2;
3484 unsigned char *jimg, *jbase, icol;
3485 int nlines[256];
3487 Drawable_t id;
3488
3489 if (wid) {
3490 id = wid;
3491 } else {
3492 id = gCws->fDrawing;
3493 }
3494
3495 for (i = 0; i < 256; i++) nlines[i] = 0;
3496
3497 x1 = x0 + xmin; y1 = y0 + ny - ymax - 1;
3498 x2 = x0 + xmax; y2 = y0 + ny - ymin - 1;
3499 jbase = image + (ymin-1)*nx + xmin;
3500
3501 for (y = y2; y >= y1; y--) {
3502 xcur = x1; jbase += nx;
3503 for (jimg = jbase, icol = *jimg++, x = x1+1; x <= x2; jimg++, x++) {
3504 if (icol != *jimg) {
3505 if (icol != itran) {
3506 n = nlines[icol]++;
3507 lines[icol][n].x1 = xcur; lines[icol][n].y1 = y;
3508 lines[icol][n].x2 = x-1; lines[icol][n].y2 = y;
3509 if (nlines[icol] == maxSegment) {
3511 XDrawSegments((Display*)fDisplay,id,*gGCline,&lines[icol][0],
3512 maxSegment);
3513 nlines[icol] = 0;
3514 }
3515 }
3516 icol = *jimg; xcur = x;
3517 }
3518 }
3519 if (icol != itran) {
3520 n = nlines[icol]++;
3521 lines[icol][n].x1 = xcur; lines[icol][n].y1 = y;
3522 lines[icol][n].x2 = x-1; lines[icol][n].y2 = y;
3523 if (nlines[icol] == maxSegment) {
3525 XDrawSegments((Display*)fDisplay,id,*gGCline,&lines[icol][0],
3526 maxSegment);
3527 nlines[icol] = 0;
3528 }
3529 }
3530 }
3531
3532 for (i = 0; i < 256; i++) {
3533 if (nlines[i] != 0) {
3535 XDrawSegments((Display*)fDisplay,id,*gGCline,&lines[i][0],nlines[i]);
3536 }
3537 }
3538}
3539
3540////////////////////////////////////////////////////////////////////////////////
3541/// If id is NULL - loads the specified gif file at position [x0,y0] in the
3542/// current window. Otherwise creates pixmap from gif file
3543
3544Pixmap_t TGX11::ReadGIF(int x0, int y0, const char *file, Window_t id)
3545{
3546 FILE *fd;
3547 Seek_t filesize = 0;
3548 unsigned char *gifArr, *pixArr, red[256], green[256], blue[256], *j1, *j2, icol;
3549 int i, j, k, width, height, ncolor, irep, offset;
3550 float rr, gg, bb;
3551 Pixmap_t pic = 0;
3552
3553 fd = fopen(file, "r");
3554 if (!fd) {
3555 Error("ReadGIF", "unable to open GIF file");
3556 return pic;
3557 }
3558
3559 fseek(fd, 0L, 2);
3560 long ft = ftell(fd);
3561 if (ft <=0) {
3562 Error("ReadGIF", "unable to open GIF file");
3563 fclose(fd);
3564 return pic;
3565 } else {
3566 filesize = Seek_t(ft);
3567 }
3568 fseek(fd, 0L, 0);
3569
3570 if (!(gifArr = (unsigned char *) calloc(filesize+256,1))) {
3571 Error("ReadGIF", "unable to allocate array for gif");
3572 fclose(fd);
3573 return pic;
3574 }
3575
3576 if (fread(gifArr, filesize, 1, fd) != 1) {
3577 Error("ReadGIF", "GIF file read failed");
3578 free(gifArr);
3579 fclose(fd);
3580 return pic;
3581 }
3582 fclose(fd);
3583
3585 if (irep != 0) {
3586 free(gifArr);
3587 return pic;
3588 }
3589
3590 if (!(pixArr = (unsigned char *) calloc((width*height),1))) {
3591 Error("ReadGIF", "unable to allocate array for image");
3592 free(gifArr);
3593 return pic;
3594 }
3595
3597 if (irep != 0) {
3598 free(gifArr);
3599 free(pixArr);
3600 return pic;
3601 }
3602
3603 // S E T P A L E T T E
3604
3605 offset = 8;
3606
3607 for (i = 0; i < ncolor; i++) {
3608 rr = red[i]/255.;
3609 gg = green[i]/255.;
3610 bb = blue[i]/255.;
3611 j = i+offset;
3612 SetRGB(j,rr,gg,bb);
3613 }
3614
3615 // O U T P U T I M A G E
3616
3617 for (i = 1; i <= height/2; i++) {
3618 j1 = pixArr + (i-1)*width;
3619 j2 = pixArr + (height-i)*width;
3620 for (k = 0; k < width; k++) {
3621 icol = *j1; *j1++ = *j2; *j2++ = icol;
3622 }
3623 }
3624 if (id) pic = CreatePixmap(id, width, height);
3626
3627 free(gifArr);
3628 free(pixArr);
3629
3630 if (pic)
3631 return pic;
3632 else if (gCws->fDrawing)
3633 return (Pixmap_t)gCws->fDrawing;
3634 return 0;
3635}
3636
3637////////////////////////////////////////////////////////////////////////////////
3638/// Returns an array of pixels created from a part of drawable
3639/// (defined by x, y, w, h) in format:
3640/// `b1, g1, r1, 0, b2, g2, r2, 0, ..., bn, gn, rn, 0`.
3641///
3642/// Pixels are numbered from left to right and from top to bottom.
3643/// By default all pixels from the whole drawable are returned.
3644///
3645/// Note that return array is 32-bit aligned
3646
3647unsigned char *TGX11::GetColorBits(Drawable_t /*wid*/, Int_t /*x*/, Int_t /*y*/,
3648 UInt_t /*w*/, UInt_t /*h*/)
3649{
3650 return nullptr;
3651}
3652
3653////////////////////////////////////////////////////////////////////////////////
3654/// create pixmap from RGB data. RGB data is in format :
3655/// b1, g1, r1, 0, b2, g2, r2, 0 ... bn, gn, rn, 0 ..
3656///
3657/// Pixels are numbered from left to right and from top to bottom.
3658/// Note that data must be 32-bit aligned
3659
3660Pixmap_t TGX11::CreatePixmapFromData(unsigned char * /*bits*/, UInt_t /*width*/,
3661 UInt_t /*height*/)
3662{
3663 return (Pixmap_t)0;
3664}
3665
3666////////////////////////////////////////////////////////////////////////////////
3667/// Register pixmap created by gVirtualGL
3668///
3669/// \param [in] pixid Pixmap identifier
3670/// \param [in] w,h Width and height of the pixmap
3671///
3672/// register new pixmap
3673
3675{
3676 Int_t wid = 0;
3677
3678 // Select next free window number
3679 for (; wid < fMaxNumberOfWindows; ++wid)
3680 if (!fWindows[wid].fOpen)
3681 break;
3682
3683 if (wid == fMaxNumberOfWindows) {
3686 fWindows, newsize * sizeof(XWindow_t),
3688 );
3689
3690 for (Int_t i = fMaxNumberOfWindows; i < newsize; ++i)
3691 fWindows[i].fOpen = 0;
3692
3694 }
3695
3696 fWindows[wid].fOpen = 1;
3697 gCws = fWindows + wid;
3698 gCws->fWindow = pixid;
3699 gCws->fDrawing = gCws->fWindow;
3700 gCws->fBuffer = 0;
3701 gCws->fDoubleBuffer = 0;
3702 gCws->fIsPixmap = 1;
3703 gCws->fClip = 0;
3704 gCws->fWidth = w;
3705 gCws->fHeight = h;
3706 gCws->fNewColors = nullptr;
3707 gCws->fShared = kFALSE;
3708
3709 return wid;
3710}
3711
3712////////////////////////////////////////////////////////////////////////////////
3713/// Returns 1 if window system server supports extension given by the
3714/// argument, returns 0 in case extension is not supported and returns -1
3715/// in case of error (like server not initialized).
3716/// Examples:
3717/// - "Apple-WM" - does server run on MacOS X;
3718/// - "XINERAMA" - does server support Xinerama.
3719/// See also the output of xdpyinfo.
3720
3722{
3724 if (!(Display*)fDisplay)
3725 return -1;
3727}
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:3322
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:3337
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:3346
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:3323
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:868
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:414
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
Definition TString.cxx:2509
R__EXTERN TStyle * gStyle
Definition TStyle.h:442
#define free
Definition civetweb.c:1578
#define calloc
Definition civetweb.c:1576
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:503
Bool_t Next(ULong64_t &hash, Long64_t &key, Long64_t &value)
Get next entry from TExMap. Returns kFALSE at end of map.
Definition TExMap.cxx:410
This class stores a (key,value) pair using an external hash.
Definition TExMap.h:33
void Add(ULong64_t hash, Long64_t key, Long64_t value)
Add an (key,value) pair to the table. The key should be unique.
Definition TExMap.cxx:87
Long64_t GetValue(ULong64_t hash, Long64_t key)
Return the value belonging to specified key and hash value.
Definition TExMap.cxx:173
This class is the basic interface to the X11 (Xlib) graphics system.
Definition TGX11.h: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:3003
void SetLineColor(Color_t cindex) override
Set color index for lines.
Definition TGX11.cxx:2305
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:990
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:1097
Int_t WriteGIF(char *name) override
Writes the current window into GIF file.
Definition TGX11.cxx:3416
void SetFillColor(Color_t cindex) override
Set color index for fill areas.
Definition TGX11.cxx:2212
void ResizeWindow(Int_t wid) override
Resize the current window if necessary.
Definition TGX11.cxx:1948
void SetTextAlign(Short_t talign=11) override
Set text alignment.
Definition TGX11.cxx:3097
void RescaleWindow(Int_t wid, UInt_t w, UInt_t h) override
Rescale the window wid.
Definition TGX11.cxx:1870
void SetCursor(Int_t win, ECursor cursor) override
Set the cursor.
Definition TGX11.cxx:2105
Int_t fScreenNumber
Screen number.
Definition TGX11.h:132
void Sync(Int_t mode) override
Set synchronisation on or off.
Definition TGX11.cxx:3244
Pixmap_t CreatePixmapFromData(unsigned char *bits, UInt_t width, UInt_t height) override
create pixmap from RGB data.
Definition TGX11.cxx:3660
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:3647
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:2978
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:780
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:2410
void Warp(Int_t ix, Int_t iy, Window_t id=0) override
Set pointer position.
Definition TGX11.cxx:3290
void * GetGC(Int_t which) const
Return desired Graphics Context ("which" maps directly on gGCList[]).
Definition TGX11.cxx:960
void SetClipOFF(Int_t wid) override
Turn off the clipping for the window wid.
Definition TGX11.cxx:2033
Int_t ResizePixmap(Int_t wid, UInt_t w, UInt_t h) override
Resize a pixmap.
Definition TGX11.cxx:1904
void SetDoubleBufferOFF() override
Turn double buffer mode off.
Definition TGX11.cxx:2153
void SetTextColor(Color_t cindex) override
Set color index for text.
Definition TGX11.cxx:3154
void UpdateWindow(Int_t mode) override
Update display.
Definition TGX11.cxx:3267
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:3721
Int_t InitWindow(ULong_t window) override
Open window and return window number.
Definition TGX11.cxx:1330
~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:1109
Int_t SetTextFont(char *fontname, ETextSetMode mode) override
Set text font to specified name.
Definition TGX11.cxx:3183
void SetFillStyle(Style_t style) override
Set fill area style.
Definition TGX11.cxx:2231
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:2012
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:3307
void SetInput(Int_t inp)
Set input on or off.
Definition TGX11.cxx:2286
void GetPlanes(Int_t &nplanes) override
Get maximum number of planes.
Definition TGX11.cxx:1048
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:2913
Int_t OpenPixmap(UInt_t w, UInt_t h) override
Open a new pixmap.
Definition TGX11.cxx:1272
XColor_t & GetColor(Int_t cid)
Return reference to internal color structure associated to color index cid.
Definition TGX11.cxx:938
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:705
void CloseWindow() override
Delete current window.
Definition TGX11.cxx:448
void SetMarkerSize(Float_t markersize) override
Set marker size index.
Definition TGX11.cxx:2424
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:2163
TExMap * fColors
Hash list of colors.
Definition TGX11.h:85
void DrawLinesSegments(Int_t n, TPoint *xy) override
Draws N segments between provided points.
Definition TGX11.cxx:677
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:2449
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:2326
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:3232
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:2352
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:1483
ULong_t GetPixel(Color_t cindex) override
Return pixel value associated to specified ROOT color number.
Definition TGX11.cxx:1033
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:1077
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:1534
Int_t OpenDisplay(void *display)
Open the display. Return -1 if the opening fails, 0 when ok.
Definition TGX11.cxx:1120
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:1501
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:2049
Int_t AddPixmap(ULong_t pixid, UInt_t w, UInt_t h) override
Register pixmap created by gVirtualGL.
Definition TGX11.cxx:3674
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:3064
void FindUsableVisual(RXVisualInfo *vlist, Int_t nitems)
Check if visual is usable, if so set fVisual, fDepth, fColormap, fBlackPixel and fWhitePixel.
Definition TGX11.cxx:877
void GetCharacterUp(Float_t &chupx, Float_t &chupy) override
Return character up vector.
Definition TGX11.cxx:928
void SetDoubleBuffer(Int_t wid, Int_t mode) override
Set the double buffer on/off on window wid.
Definition TGX11.cxx:2120
Int_t fMaxNumberOfWindows
Maximum number of windows.
Definition TGX11.h:83
void SetMarkerStyle(Style_t markerstyle) override
Set marker style.
Definition TGX11.cxx:2464
void GetRGB(Int_t index, Float_t &r, Float_t &g, Float_t &b) override
Get rgb values for color "index".
Definition TGX11.cxx:1056
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:3360
Int_t FindColor(ULong_t pixel, ULong_t *orgcolors, Int_t ncolors)
Returns index in orgcolors (and fNewColors) for pixel.
Definition TGX11.cxx:3048
void SetFillStyleIndex(Int_t style, Int_t fasi)
Set fill area style index.
Definition TGX11.cxx:2243
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:951
void RemoveWindow(ULong_t qwid) override
Remove a window created by Qt (like CloseWindow1()).
Definition TGX11.cxx:1451
Int_t RequestString(Int_t x, Int_t y, char *text) override
Request a string.
Definition TGX11.cxx:1712
void SetLineWidth(Width_t width) override
Set line width.
Definition TGX11.cxx:2391
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:3479
Int_t GetDoubleBuffer(Int_t wid) override
Query the double buffer value for the window wid.
Definition TGX11.cxx:972
void FindBestVisual()
Find best visual, i.e.
Definition TGX11.cxx:809
void SetDrawMode(EDrawMode mode) override
Set the drawing mode.
Definition TGX11.cxx:2188
void SetColor(void *gc, Int_t ci)
Set the foreground color in GC.
Definition TGX11.cxx:2072
const char * DisplayName(const char *dpyName=nullptr) override
Return hostname on which the display is opened.
Definition TGX11.cxx:1025
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:3544
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:1407
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:1987
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:1075
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1089
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:249
Double_t Floor(Double_t x)
Rounds x downward, returning the largest integral value that is not greater than x.
Definition TMath.h:691
Double_t Sqrt(Double_t x)
Returns the square root of x.
Definition TMath.h:673
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Definition TMathBase.h:197
constexpr Double_t Pi()
Definition TMath.h:40
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Definition TMathBase.h:122
Description of a X11 color.
Definition TGWin32.h:56
Bool_t fDefined
true if pixel value is defined
Definition TGWin32.h:58
UShort_t fBlue
blue value
Definition TGX11.h: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