1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
#include <iostream>
using namespace std;
#include "MEPlotWindow.hh"
#include "MusEcalGUI.hh"
#include "MEClickableCanvas.hh"
#include <TMath.h>
#include <TRootEmbeddedCanvas.h>
ClassImp(MEPlotWindow);
MEPlotWindow::MEPlotWindow( const TGWindow *p, MusEcalGUI* main, const char* name, UInt_t w, UInt_t h, const char* str1,
const char* str2,
const char* str3,
const char* str4
)
: _gui( main ), _name(name), _printName(name)
{
unsigned width = w;
unsigned height = h;
unsigned margin = 2;
fClose = kTRUE;
fMain = new TGTransientFrame( p, main, width, height );
fMain->Connect("CloseWindow()", "MEPlotWindow", this, "DoClose()");
fMain->DontCallClose();
fMain->SetCleanup(kDeepCleanup);
fMain->ChangeOptions( (fMain->GetOptions() & ~kVerticalFrame) | kHorizontalFrame );
fHFrame = new TGHorizontalFrame( fMain, width, height );
// fEcanvas = new TRootEmbeddedCanvas( name, fHFrame, width-margin, height-margin );
// fEcanvas = new MEClickableCanvas( name, fHFrame, width-margin, height-margin, main );
fEcanvas = new MEClickableCanvas( name, fHFrame, width-margin, height-margin, this );
TGLayoutHints* fL = new TGLayoutHints(kLHintsRight | kLHintsExpandX | kLHintsExpandY,5,5,5,0);
fHFrame->AddFrame( fEcanvas, fL );
fMain->AddFrame( fHFrame );
fMain->SetWindowName( name );
TGDimension size = fMain->GetDefaultSize();
fMain->Resize(size);
fMain->SetWMPosition(100,100);
fMain->MapSubwindows();
fMain->MapWindow();
SetCanvas( fEcanvas->GetCanvas(), str1, str2, str3, str4 );
}
void
MEPlotWindow::setPrintName( TString printName )
{
_printName = printName;
}
void
MEPlotWindow::write()
{
TString fn_ = _printName;
// fn_ += ".ps";
fPad->Print( fn_ );
}
MEPlotWindow::~MEPlotWindow()
{
_gui->_window.erase( _name );
fMain->DeleteWindow();
// _gui->setPad();
// _gui->_curPad = _gui->fPad;
}
void
MEPlotWindow::CloseWindow()
{
delete this;
}
void
MEPlotWindow::DoClose()
{
if (fClose)
CloseWindow();
else {
fClose = kTRUE;
TTimer::SingleShot(150, "MEPlotWindow", this, "CloseWindow()");
}
}
void
MEPlotWindow::setPxAndPy( int px, int py )
{
MECanvasHolder::setPxAndPy( px, py );
_gui->windowClicked( this );
}
// XtoPad does not convert user coordinates to NDC !! (it takes care only of lin/log user coordinates
// to pad coordinates. If linear coordinates double x = pad->XtoPad(y); returns y otherwise it returns log(y). To convert from user coordinates to NDC, to, eg
// Double_t dpx = gPad->GetX2() - gPad->GetX1();
// Double_t dpy = gPad->GetY2() - gPad->GetY1();
// Double_t xp1 = gPad->GetX1();
// Double_t yp1 = gPad->GetY1();
// Double_t xndc = (x-xp1)/dpx
// Double_t yndc = (y-yp1)/dpy
|