1 | #include <iostream.h>
|
---|
2 |
|
---|
3 | #include <TGFrame.h>
|
---|
4 | #include <TGLabel.h>
|
---|
5 | #include <TGButton.h>
|
---|
6 |
|
---|
7 | #include "MGList.h"
|
---|
8 |
|
---|
9 |
|
---|
10 | class MFit : public TGMainFrame
|
---|
11 | {
|
---|
12 | private:
|
---|
13 | enum {
|
---|
14 | kCbIA,
|
---|
15 | kCbIE,
|
---|
16 | kCbNPAE,
|
---|
17 | kCbCA,
|
---|
18 | kCbAN,
|
---|
19 | kCbAW,
|
---|
20 | kCbCRX,
|
---|
21 | kCbCRY,
|
---|
22 | kCbNRX,
|
---|
23 | kCbNRY
|
---|
24 | };
|
---|
25 |
|
---|
26 | MGList *list;
|
---|
27 |
|
---|
28 | Bool_t ProcessMessage(Long_t msg, Long_t mp1, Long_t mp2)
|
---|
29 | {
|
---|
30 | cout << "Msg: " << hex << GET_MSG(msg) << endl;
|
---|
31 | cout << "SubMsg: " << hex << GET_SUBMSG(msg) << endl;
|
---|
32 | switch (GET_MSG(msg))
|
---|
33 | {
|
---|
34 | case kC_COMMAND:
|
---|
35 | switch (GET_SUBMSG(msg))
|
---|
36 | {
|
---|
37 | case kCM_CHECKBUTTON:
|
---|
38 | /*
|
---|
39 | TGCheckButton *but = (TGCheckButton*)list->FindWidget(mp1);
|
---|
40 | cout << hex << but->GetName() << " " << mp2 << endl;
|
---|
41 | */
|
---|
42 | return kTRUE;
|
---|
43 | }
|
---|
44 | return kTRUE;
|
---|
45 | }
|
---|
46 | return kTRUE;
|
---|
47 | }
|
---|
48 |
|
---|
49 | void AddTextButton(TGCompositeFrame *f, TString txt, Int_t id=-1, TGLayoutHints *h=0)
|
---|
50 | {
|
---|
51 | TGButton *but = new TGTextButton(f, txt, id);
|
---|
52 | but->Associate(this);
|
---|
53 | f->AddFrame(but, h);
|
---|
54 | list->Add(but);
|
---|
55 |
|
---|
56 | }
|
---|
57 |
|
---|
58 | void AddCheckButton(TGCompositeFrame *f, TString txt, Int_t id=-1, TGLayoutHints *h=0)
|
---|
59 | {
|
---|
60 | TGButton *but = new TGCheckButton(f, txt, id);
|
---|
61 | but->Associate(this);
|
---|
62 | f->AddFrame(but, h);
|
---|
63 | list->Add(but);
|
---|
64 | }
|
---|
65 |
|
---|
66 | void AddLabel(TGCompositeFrame *f, TString txt, TGLayoutHints *h=0, TList *label=0)
|
---|
67 | {
|
---|
68 | TGLabel *l = new TGLabel(f, txt);
|
---|
69 | f->AddFrame(l, h);
|
---|
70 | list->Add(l);
|
---|
71 | if (label)
|
---|
72 | label->Add(l);
|
---|
73 | }
|
---|
74 |
|
---|
75 | public:
|
---|
76 | MFit() : TGMainFrame(gClient->GetRoot(), 550, 350, kHorizontalFrame)
|
---|
77 | {
|
---|
78 | list = new MGList;
|
---|
79 | list->SetOwner();
|
---|
80 |
|
---|
81 | TGLayoutHints *hints0 = new TGLayoutHints(kLHintsExpandY, 7, 5, 5, 6);
|
---|
82 | TGLayoutHints *hints1 = new TGLayoutHints(kLHintsExpandX|kLHintsExpandY, 5, 7, 5, 6);
|
---|
83 | TGLayoutHints *hints2 = new TGLayoutHints(kLHintsCenterX|kLHintsCenterY, 5, 5, 5, 5);
|
---|
84 | list->Add(hints0);
|
---|
85 | list->Add(hints1);
|
---|
86 | list->Add(hints2);
|
---|
87 |
|
---|
88 | TGGroupFrame *grp1 = new TGGroupFrame(this, "Control", kVerticalFrame);
|
---|
89 | AddFrame(grp1, hints0);
|
---|
90 | list->Add(grp1);
|
---|
91 |
|
---|
92 | TGGroupFrame *grp2 = new TGGroupFrame(this, "Parameters", kHorizontalFrame);
|
---|
93 | AddFrame(grp2, hints1);
|
---|
94 | list->Add(grp2);
|
---|
95 |
|
---|
96 |
|
---|
97 |
|
---|
98 | TGLayoutHints *hints4 = new TGLayoutHints(kLHintsExpandX, 5, 5, 10);
|
---|
99 | AddTextButton(grp1, "Load Bending Model", -1, hints4);
|
---|
100 | AddTextButton(grp1, "Save Bending Model", -1, hints4);
|
---|
101 | AddTextButton(grp1, "Load Observations", -1, hints4);
|
---|
102 | AddTextButton(grp1, "Fit Parameters", -1, hints4);
|
---|
103 | AddTextButton(grp1, "Reset Parameters", -1, hints4);
|
---|
104 |
|
---|
105 |
|
---|
106 | TGHorizontalFrame *comp = new TGHorizontalFrame(grp2, 1, 1);
|
---|
107 | grp2->AddFrame(comp);
|
---|
108 | list->Add(comp);
|
---|
109 |
|
---|
110 | TGLayoutHints *hints3 = new TGLayoutHints(kLHintsLeft|kLHintsTop, 0, 20, 5, 0);
|
---|
111 | list->Add(hints3);
|
---|
112 |
|
---|
113 | TGLabel *l;
|
---|
114 |
|
---|
115 | TGVerticalFrame *vframe = new TGVerticalFrame(comp, 1, 1);
|
---|
116 | comp->AddFrame(vframe, hints3);
|
---|
117 | list->Add(vframe);
|
---|
118 |
|
---|
119 | AddCheckButton(vframe, "IA", kCbIA);
|
---|
120 | AddCheckButton(vframe, "IE", kCbIE);
|
---|
121 | AddCheckButton(vframe, "NPAE", kCbNPAE);
|
---|
122 | AddCheckButton(vframe, "CA", kCbCA);
|
---|
123 | AddCheckButton(vframe, "AN", kCbAN);
|
---|
124 | AddCheckButton(vframe, "AW", kCbAW);
|
---|
125 | AddCheckButton(vframe, "CRX", kCbCRX);
|
---|
126 | AddCheckButton(vframe, "CRY", kCbCRY);
|
---|
127 | AddCheckButton(vframe, "NRX", kCbNRX);
|
---|
128 | AddCheckButton(vframe, "NRY", kCbNRY);
|
---|
129 |
|
---|
130 | vframe = new TGVerticalFrame(comp, 1, 1);
|
---|
131 | comp->AddFrame(vframe, hints3);
|
---|
132 | list->Add(vframe);
|
---|
133 |
|
---|
134 |
|
---|
135 | TList label;
|
---|
136 |
|
---|
137 | l = new TGLabel(vframe, "0");
|
---|
138 | list->Add(l);
|
---|
139 | label.Add(l);
|
---|
140 |
|
---|
141 | TGButton *but = (TGButton*)list->FindWidget(kCbIA);
|
---|
142 |
|
---|
143 | TGLayoutHints *h = new TGLayoutHints(kLHintsCenterY, 0, 0, but->GetHeight()-l->GetHeight());
|
---|
144 | list->Add(h);
|
---|
145 |
|
---|
146 | vframe->AddFrame(l,h);
|
---|
147 |
|
---|
148 | AddLabel(vframe, "0", h, &label);
|
---|
149 | AddLabel(vframe, "0", h, &label);
|
---|
150 | AddLabel(vframe, "0", h, &label);
|
---|
151 | AddLabel(vframe, "0", h, &label);
|
---|
152 | AddLabel(vframe, "0", h, &label);
|
---|
153 | AddLabel(vframe, "0", h, &label);
|
---|
154 | AddLabel(vframe, "0", h, &label);
|
---|
155 | AddLabel(vframe, "0", h, &label);
|
---|
156 | AddLabel(vframe, "0", h, &label);
|
---|
157 |
|
---|
158 | vframe = new TGVerticalFrame(comp, 1, 1);
|
---|
159 | comp->AddFrame(vframe, hints3);
|
---|
160 | list->Add(vframe);
|
---|
161 |
|
---|
162 | AddLabel(vframe, "Offset Azimuth", h, &label);
|
---|
163 | AddLabel(vframe, "Offset Zenith Distance", h, &label);
|
---|
164 | AddLabel(vframe, "0", h, &label);
|
---|
165 | AddLabel(vframe, "0", h, &label);
|
---|
166 | AddLabel(vframe, "0", h, &label);
|
---|
167 | AddLabel(vframe, "0", h, &label);
|
---|
168 | AddLabel(vframe, "0", h, &label);
|
---|
169 | AddLabel(vframe, "0", h, &label);
|
---|
170 | AddLabel(vframe, "0", h, &label);
|
---|
171 |
|
---|
172 | Layout();
|
---|
173 |
|
---|
174 | MapSubwindows();
|
---|
175 | MapWindow();
|
---|
176 |
|
---|
177 |
|
---|
178 |
|
---|
179 |
|
---|
180 | l = (TGLabel*)label.At(0);
|
---|
181 | l->SetText("221.4567");
|
---|
182 |
|
---|
183 | l = (TGLabel*)label.At(1);
|
---|
184 | l->SetText("-1.65423");
|
---|
185 |
|
---|
186 | Layout();
|
---|
187 | }
|
---|
188 | };
|
---|
189 |
|
---|
190 | void gui()
|
---|
191 | {
|
---|
192 | new MFit;
|
---|
193 | }
|
---|
194 | |
---|