32 ClassImp(TLineEditor);
47 TLineEditor::TLineEditor(
const TGWindow *p, Int_t width,
48 Int_t height, UInt_t options, Pixel_t back)
49 : TGedFrame(p, width, height, options | kVerticalFrame, back)
55 TGCompositeFrame *f3 =
new TGCompositeFrame(
this, 80, 20, kHorizontalFrame);
56 AddFrame(f3,
new TGLayoutHints(kLHintsTop, 1, 1, 3, 0));
58 TGCompositeFrame *f3a =
new TGCompositeFrame(f3, 80, 20);
59 f3->AddFrame(f3a,
new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
61 TGLabel *fStartPointXLabel =
new TGLabel(f3a,
"Start X:");
62 f3a->AddFrame(fStartPointXLabel,
new TGLayoutHints(kLHintsNormal, 8, 0, 5, 5));
64 TGLabel *fStartPointYLabel =
new TGLabel(f3a,
"Y:");
65 f3a->AddFrame(fStartPointYLabel,
new TGLayoutHints(kLHintsNormal, 37, 0, 5, 5));
67 TGLabel *fEndPointXLabel =
new TGLabel(f3a,
"End X:");
68 f3a->AddFrame(fEndPointXLabel,
new TGLayoutHints(kLHintsNormal, 10, 0, 5, 5));
70 TGLabel *fEndPointYLabel =
new TGLabel(f3a,
"Y:");
71 f3a->AddFrame(fEndPointYLabel,
new TGLayoutHints(kLHintsNormal, 37, 0, 5, 5));
73 TGCompositeFrame *f3b =
new TGCompositeFrame(f3, 80, 20, kFixedWidth);
74 f3->AddFrame(f3b,
new TGLayoutHints(kLHintsNormal, 8, 0, 0, 0));
76 fStartPointX =
new TGNumberEntry(f3b, 0.0, 8, kLine_STAX,
77 TGNumberFormat::kNESRealThree,
78 TGNumberFormat::kNEAAnyNumber,
79 TGNumberFormat::kNELNoLimits);
80 fStartPointX->GetNumberEntry()->SetToolTipText(
"Set start point X coordinate of Line.");
81 f3b->AddFrame(fStartPointX,
new TGLayoutHints(kLHintsExpandX, 1, 1, 1, 1));
83 fStartPointY =
new TGNumberEntry(f3b, 0.0, 8, kLine_STAY,
84 TGNumberFormat::kNESRealThree,
85 TGNumberFormat::kNEAAnyNumber,
86 TGNumberFormat::kNELNoLimits);
87 fStartPointY->GetNumberEntry()->SetToolTipText(
"Set start point Y coordinate of Line.");
88 f3b->AddFrame(fStartPointY,
new TGLayoutHints(kLHintsExpandX, 1, 1, 3, 1));
90 fEndPointX =
new TGNumberEntry(f3b, 0.0, 8, kLine_ENDX,
91 TGNumberFormat::kNESRealThree,
92 TGNumberFormat::kNEAAnyNumber,
93 TGNumberFormat::kNELNoLimits);
94 fEndPointX->GetNumberEntry()->SetToolTipText(
"Set end point X xoordinate of Line.");
95 f3b->AddFrame(fEndPointX,
new TGLayoutHints(kLHintsExpandX, 1, 1, 3, 1));
97 fEndPointY =
new TGNumberEntry(f3b, 0.0, 8, kLine_ENDY,
98 TGNumberFormat::kNESRealThree,
99 TGNumberFormat::kNEAAnyNumber,
100 TGNumberFormat::kNELNoLimits);
101 fEndPointY->GetNumberEntry()->SetToolTipText(
"Set end point Y coordinate of Line.");
102 f3b->AddFrame(fEndPointY,
new TGLayoutHints(kLHintsExpandX, 1, 1, 3, 1));
104 fVertical =
new TGCheckButton(
this,
"Vertical",kLine_VERTICAL);
105 fVertical->SetToolTipText(
"Set vertical");
106 AddFrame(fVertical,
new TGLayoutHints(kLHintsTop, 8, 1, 5, 0));
108 fHorizontal =
new TGCheckButton(
this,
"Horizontal",kLine_HORIZONTAL);
109 fHorizontal->SetToolTipText(
"Set horizontal");
110 AddFrame(fHorizontal,
new TGLayoutHints(kLHintsTop, 8, 1, 3, 0));
116 TLineEditor::~TLineEditor()
123 void TLineEditor::ConnectSignals2Slots()
125 fStartPointX->Connect(
"ValueSet(Long_t)",
"TLineEditor",
this,
"DoStartPoint()");
126 (fStartPointX->GetNumberEntry())->Connect(
"ReturnPressed()",
"TLineEditor",
this,
"DoStartPoint()");
127 fStartPointY->Connect(
"ValueSet(Long_t)",
"TLineEditor",
this,
"DoStartPoint()");
128 (fStartPointY->GetNumberEntry())->Connect(
"ReturnPressed()",
"TLineEditor",
this,
"DoStartPoint()");
129 fEndPointX->Connect(
"ValueSet(Long_t)",
"TLineEditor",
this,
"DoEndPoint()");
130 (fEndPointX->GetNumberEntry())->Connect(
"ReturnPressed()",
"TLineEditor",
this,
"DoEndPoint()");
131 fEndPointY->Connect(
"ValueSet(Long_t)",
"TLineEditor",
this,
"DoEndPoint()");
132 (fEndPointY->GetNumberEntry())->Connect(
"ReturnPressed()",
"TLineEditor",
this,
"DoEndPoint()");
133 fVertical->Connect(
"Clicked()",
"TLineEditor",
this,
"DoLineVertical()");
134 fHorizontal->Connect(
"Clicked()",
"TLineEditor",
this,
"DoLineHorizontal()");
142 void TLineEditor::SetModel(TObject* obj)
144 fLine = (TLine *)obj;
145 fAvoidSignal = kTRUE;
147 Float_t val = fLine->GetX1();
148 fStartPointX->SetNumber(val);
150 val = fLine->GetX2();
151 fEndPointX->SetNumber(val);
153 val = fLine->GetY1();
154 fStartPointY->SetNumber(val);
156 val = fLine->GetY2();
157 fEndPointY->SetNumber(val);
159 if (fLine->IsHorizontal()) fHorizontal->SetState(kButtonDown, kFALSE);
160 else fHorizontal->SetState(kButtonUp, kFALSE);
162 if (fLine->IsVertical()) fVertical->SetState(kButtonDown, kFALSE);
163 else fVertical->SetState(kButtonUp, kFALSE);
165 if (fInit) ConnectSignals2Slots();
167 fAvoidSignal = kFALSE;
173 void TLineEditor::DoStartPoint()
175 if (fAvoidSignal)
return;
176 fLine->SetX1((Double_t)fStartPointX->GetNumber());
177 fLine->SetY1((Double_t)fStartPointY->GetNumber());
178 fLine->Paint(fLine->GetDrawOption());
184 void TLineEditor::DoEndPoint()
186 if (fAvoidSignal)
return;
187 fLine->SetX2((Double_t)fEndPointX->GetNumber());
188 fLine->SetY2((Double_t)fEndPointY->GetNumber());
189 fLine->Paint(fLine->GetDrawOption());
196 void TLineEditor::DoLineVertical()
198 if (fAvoidSignal)
return;
199 if (fVertical->GetState() == kButtonDown) {
200 fLine->SetVertical();
201 fHorizontal->SetState(kButtonUp, kFALSE);
203 fLine->SetVertical(kFALSE);
211 void TLineEditor::DoLineHorizontal()
213 if (fAvoidSignal)
return;
214 if (fHorizontal->GetState() == kButtonDown) {
215 fLine->SetHorizontal();
216 fVertical->SetState(kButtonUp, kFALSE);
218 fLine->SetHorizontal(kFALSE);