1 | //
|
---|
2 | // This File contains the definition of the MGCoordinates-class
|
---|
3 | //
|
---|
4 | // Author: Thomas Bretz
|
---|
5 | // Version: V1.0 (1-8-2000)
|
---|
6 |
|
---|
7 | #include "MGEmbeddedCanvas.h"
|
---|
8 |
|
---|
9 | #include <iostream.h>
|
---|
10 |
|
---|
11 | #include <TList.h>
|
---|
12 | #include <TCanvas.h>
|
---|
13 |
|
---|
14 | ClassImp(MGEmbeddedCanvas);
|
---|
15 |
|
---|
16 | MGEmbeddedCanvas::MGEmbeddedCanvas(const char *name, const TGWindow* p,
|
---|
17 | const UInt_t width, Float_t range)
|
---|
18 | : TRootEmbeddedCanvas(name, p, width+1, width+1, 0/*kRaisedFrame*/),
|
---|
19 | fModified(kFALSE), fWidth(width), fRange(range), fPix(2.*range/width)
|
---|
20 | {
|
---|
21 | cout << "MGEmbeddedCanvas: Initializing." << endl;
|
---|
22 | fCanvas = GetCanvas();
|
---|
23 |
|
---|
24 | cout << "MGEmbeddedCanvas: fCanvas = 0x" << fCanvas << endl;
|
---|
25 |
|
---|
26 | cout << "MGEmbeddedCanvas: SetFillColor." << endl;
|
---|
27 | fCanvas->SetFillColor(39); // s. TAttFill
|
---|
28 | cout << "MGEmbeddedCanvas: fRange=" << fRange << endl;
|
---|
29 | if (fRange>0)
|
---|
30 | fCanvas->Range(-fRange, -fRange, fRange, fRange);
|
---|
31 |
|
---|
32 | fList = new TList;
|
---|
33 | fList->SetOwner();
|
---|
34 |
|
---|
35 | cout << "MGEmbeddedCanvas: Initializing done." << endl;
|
---|
36 | }
|
---|
37 |
|
---|
38 | MGEmbeddedCanvas::~MGEmbeddedCanvas()
|
---|
39 | {
|
---|
40 | delete fList;
|
---|
41 | }
|
---|
42 |
|
---|
43 | void MGEmbeddedCanvas::InitCanvas()
|
---|
44 | {
|
---|
45 | MapSubwindows();
|
---|
46 |
|
---|
47 | Resize(fWidth, fWidth); //GetDefaultSize()); // ???
|
---|
48 | MapWindow();
|
---|
49 |
|
---|
50 | fCanvas->SetEditable(kFALSE);
|
---|
51 | }
|
---|
52 |
|
---|
53 | void MGEmbeddedCanvas::UpdateCanvas()
|
---|
54 | {
|
---|
55 | if (!fModified)
|
---|
56 | return;
|
---|
57 |
|
---|
58 | //
|
---|
59 | // FIXME: Sometimes (if the canvas couldn't be created correctly:
|
---|
60 | // X11 Pixmap error) Update hangs the Gui system.
|
---|
61 | //
|
---|
62 | // Fixed: Using root 3.01/06 and doing the update from within the
|
---|
63 | // mainthread.
|
---|
64 | //
|
---|
65 |
|
---|
66 | fCanvas->Modified();
|
---|
67 | fCanvas->Update();
|
---|
68 |
|
---|
69 | fModified = kFALSE;
|
---|
70 | }
|
---|