37 ClassImp(TGeoPgonEditor);
46 TGeoPgonEditor::TGeoPgonEditor(
const TGWindow *p, Int_t width,
47 Int_t height, UInt_t options, Pixel_t back)
48 : TGeoPconEditor(p, width, height, options | kVerticalFrame, back)
52 TGeoTabManager::MoveFrame(fDFrame,
this);
53 TGeoTabManager::MoveFrame(fBFrame,
this);
54 fENedges->Connect(
"ValueSet(Long_t)",
"TGeoPgonEditor",
this,
"DoNedges()");
55 fENedges->GetNumberEntry()->Connect(
"TextChanged(const char *)",
"TGeoPgonEditor",
this,
"DoModified()");
61 TGeoPgonEditor::~TGeoPgonEditor()
64 TIter next(GetList());
65 while ((el = (TGFrameElement *)next())) {
66 if (el->fFrame->IsComposite())
67 TGeoTabManager::Cleanup((TGCompositeFrame*)el->fFrame);
75 void TGeoPgonEditor::SetModel(TObject* obj)
77 if (obj == 0 || (obj->IsA()!=TGeoPgon::Class())) {
81 fShape = (TGeoPcon*)obj;
82 const char *sname = fShape->GetName();
83 if (!strcmp(sname, fShape->ClassName())) fShapeName->SetText(
"-no_name");
84 else fShapeName->SetText(sname);
86 Int_t nsections = fShape->GetNz();
88 fNedgesi = ((TGeoPgon*)fShape)->GetNedges();
89 fENz->SetNumber(nsections);
90 fENedges->SetNumber(fNedgesi);
91 fEPhi1->SetNumber(fShape->GetPhi1());
92 fPhi1i = fShape->GetPhi1();
93 fEDPhi->SetNumber(fShape->GetDphi());
94 fDPhii = fShape->GetDphi();
95 CreateSections(nsections);
98 fApply->SetEnabled(kFALSE);
99 fUndo->SetEnabled(kFALSE);
101 if (fInit) ConnectSignals2Slots();
108 void TGeoPgonEditor::DoApply()
110 TGeoPgon *shape = (TGeoPgon*)fShape;
111 const char *name = fShapeName->GetText();
112 if (strcmp(name,fShape->GetName())) fShape->SetName(name);
113 fApply->SetEnabled(kFALSE);
115 if (!CheckSections())
return;
117 Bool_t recreate = kFALSE;
118 Int_t nz = fENz->GetIntNumber();
119 Int_t nedges = fENedges->GetIntNumber();
120 Double_t phi1 = fEPhi1->GetNumber();
121 Double_t dphi = fEDPhi->GetNumber();
122 if (nz != fShape->GetNz()) recreate = kTRUE;
123 TGeoPconSection *sect;
126 Double_t *array =
new Double_t[3*(nz+1)+1];
131 for (isect=0; isect<nz; isect++) {
132 sect = (TGeoPconSection*)fSections->At(isect);
133 array[4+3*isect] = sect->GetZ();
134 array[5+3*isect] = sect->GetRmin();
135 array[6+3*isect] = sect->GetRmax();
137 shape->SetDimensions(array);
140 if (gGeoManager && gGeoManager->GetPainter() && gGeoManager->GetPainter()->IsPaintingShape()) {
141 TView *view = fPad->GetView();
144 fPad->GetView()->ShowAxis();
146 const Double_t *orig = fShape->GetOrigin();
147 view->SetRange(orig[0]-fShape->GetDX(), orig[1]-fShape->GetDY(), orig[2]-fShape->GetDZ(),
148 orig[0]+fShape->GetDX(), orig[1]+fShape->GetDY(), orig[2]+fShape->GetDZ());
156 if (TMath::Abs(phi1-fShape->GetPhi1())>1.e-6) fShape->Phi1() = phi1;
157 if (TMath::Abs(dphi-fShape->GetDphi())>1.e-6) fShape->Dphi() = dphi;
158 if (nedges != shape->GetNedges()) shape->SetNedges(nedges);
159 for (isect=0; isect<fNsections; isect++) {
160 sect = (TGeoPconSection*)fSections->At(isect);
161 fShape->Z(isect) = sect->GetZ();
162 fShape->Rmin(isect) = sect->GetRmin();
163 fShape->Rmax(isect) = sect->GetRmax();
165 shape->ComputeBBox();
167 if (gGeoManager && gGeoManager->GetPainter() && gGeoManager->GetPainter()->IsPaintingShape()) {
168 TView *view = fPad->GetView();
171 fPad->GetView()->ShowAxis();
173 const Double_t *orig = fShape->GetOrigin();
174 view->SetRange(orig[0]-fShape->GetDX(), orig[1]-fShape->GetDY(), orig[2]-fShape->GetDZ(),
175 orig[0]+fShape->GetDX(), orig[1]+fShape->GetDY(), orig[2]+fShape->GetDZ());
185 void TGeoPgonEditor::DoUndo()
187 fENedges->SetNumber(fNedgesi);
188 TGeoPconEditor::DoUndo();
194 void TGeoPgonEditor::CreateEdges()
197 TGCompositeFrame *f1 =
new TGCompositeFrame(
this, 155, 10, kHorizontalFrame | kFixedWidth);
198 f1->AddFrame(
new TGLabel(f1,
"Nedges"),
new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
199 fENedges =
new TGNumberEntry(f1, 0., 5, kPGON_NEDGES);
200 fENedges->SetNumAttr(TGNumberFormat::kNEAPositive);
201 fENedges->SetNumStyle(TGNumberFormat::kNESInteger);
202 fENedges->Resize(100,fENedges->GetDefaultHeight());
203 nef = (TGTextEntry*)fENedges->GetNumberEntry();
204 nef->SetToolTipText(
"Enter the number of edges of the polygon");
205 fENedges->Associate(
this);
206 f1->AddFrame(fENedges,
new TGLayoutHints(kLHintsRight, 2, 2, 2, 2));
207 AddFrame(f1,
new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
213 void TGeoPgonEditor::DoNedges()
215 Int_t nedges = fENedges->GetIntNumber();
218 fENedges->SetNumber(nedges);
221 if (!IsDelayed()) DoApply();