28 ClassImp(TGLClipSetSubEditor);
33 TGLClipSetSubEditor::TGLClipSetSubEditor(
const TGWindow *p) :
36 fCurrentClip(TGLClip::kClipNone),
49 fTypeButtons =
new TGButtonGroup(
this,
"Clip Type", kChildFrame|kHorizontalFrame);
50 new TGRadioButton(fTypeButtons,
"None ");
51 new TGRadioButton(fTypeButtons,
"Plane ");
52 new TGRadioButton(fTypeButtons,
"Box");
53 fTypeButtons->SetLayoutHints(
new TGLayoutHints(kLHintsLeft|kLHintsBottom, 0, 0, 2, -10));
54 AddFrame(fTypeButtons,
new TGLayoutHints(kLHintsTop | kLHintsCenterX | kLHintsExpandX, 2, 3, 2, 2));
56 fClipInside =
new TGCheckButton(
this,
"Clip away inside");
57 AddFrame(fClipInside,
new TGLayoutHints(kLHintsTop | kLHintsCenterX | kLHintsExpandX, 2, 3, 2, 2));
58 fAutoUpdate =
new TGCheckButton(
this,
"Auto update clip");
59 AddFrame(fAutoUpdate,
new TGLayoutHints(kLHintsTop | kLHintsCenterX | kLHintsExpandX, 2, 3, 2, 2));
60 fClipEdit =
new TGCheckButton(
this,
"Edit In Viewer");
61 AddFrame(fClipEdit,
new TGLayoutHints(kLHintsTop | kLHintsCenterX | kLHintsExpandX, 2, 3, 2, 2));
62 fClipShow =
new TGCheckButton(
this,
"Show In Viewer");
63 AddFrame(fClipShow,
new TGLayoutHints(kLHintsTop | kLHintsCenterX | kLHintsExpandX, 2, 3, 2, 2));
66 fPlanePropFrame =
new TGCompositeFrame(
this);
67 AddFrame(fPlanePropFrame,
new TGLayoutHints(kLHintsTop | kLHintsCenterX | kLHintsExpandX, 2, 3, 2, 2));
69 static const char *
const planeStr[] = {
"aX + ",
"bY +",
"cZ + ",
"d = 0" };
71 for (Int_t i = 0; i < 4; ++i)
72 fPlaneProp[i] = TGLViewerEditor::MakeLabeledNEntry(fPlanePropFrame, planeStr[i] , 40);
75 fBoxPropFrame =
new TGCompositeFrame(
this);
76 AddFrame(fBoxPropFrame,
new TGLayoutHints(kLHintsTop | kLHintsCenterX | kLHintsExpandX, 2, 3, 2, 2));
78 static const char *
const boxStr[] = {
"Center X",
"Center Y",
"Center Z",
"Length X",
"Length Y",
"Length Z" };
80 for (Int_t i = 0; i < 6; ++i)
81 fBoxProp[i] = TGLViewerEditor::MakeLabeledNEntry(fBoxPropFrame, boxStr[i] , 60);
84 fApplyButton =
new TGTextButton(
this,
"Apply");
85 AddFrame(fApplyButton,
new TGLayoutHints(kLHintsTop | kLHintsCenterX | kLHintsExpandX, 2, 3, 2, 2));
87 fResetButton =
new TGTextButton(
this,
"Reset");
88 AddFrame(fResetButton,
new TGLayoutHints(kLHintsTop | kLHintsCenterX | kLHintsExpandX, 2, 3, 2, 2));
90 fTypeButtons->Connect(
"Clicked(Int_t)",
"TGLClipSetSubEditor",
this,
"ClipTypeChanged(Int_t)");
91 fClipInside->Connect(
"Clicked()",
"TGLClipSetSubEditor",
this,
"UpdateViewerClip()");
92 fAutoUpdate->Connect(
"Clicked()",
"TGLClipSetSubEditor",
this,
"UpdateViewerClip()");
93 fClipEdit->Connect(
"Clicked()",
"TGLClipSetSubEditor",
this,
"UpdateViewerClip()");
94 fClipShow->Connect(
"Clicked()",
"TGLClipSetSubEditor",
this,
"UpdateViewerClip()");
96 for (Int_t i = 0; i < 4; ++i)
97 fPlaneProp[i]->Connect(
"ValueSet(Long_t)",
"TGLClipSetSubEditor",
this,
"ClipValueChanged()");
99 for (Int_t i = 0; i < 6; ++i)
100 fBoxProp[i]->Connect(
"ValueSet(Long_t)",
"TGLClipSetSubEditor",
this,
"ClipValueChanged()");
102 fApplyButton->Connect(
"Pressed()",
"TGLClipSetSubEditor",
this,
"UpdateViewerClip()");
103 fResetButton->Connect(
"Pressed()",
"TGLClipSetSubEditor",
this,
"ResetViewerClip()");
109 void TGLClipSetSubEditor::SetModel(TGLClipSet* m)
113 fTypeButtons->GetButton(fCurrentClip+1)->SetDown(kFALSE);
114 fCurrentClip = fM->GetClipType();
116 Double_t clip[6] = {0.};
117 fM->GetClipState(fCurrentClip, clip);
119 fApplyButton->SetState(kButtonDisabled);
122 if (TGButton *btn = fTypeButtons->GetButton(fCurrentClip+1)) {
124 fTypeButtons->SetButton(fCurrentClip+1);
126 Bool_t active = (fCurrentClip != TGLClip::kClipNone);
127 fClipInside->SetEnabled(active);
128 fAutoUpdate->SetEnabled(active);
129 fClipEdit ->SetEnabled(active);
130 fClipShow ->SetEnabled(active);
132 fClipEdit->SetDown(fM->GetShowManip());
133 fClipShow->SetDown(fM->GetShowClip());
134 fClipInside->SetDown(fM->GetCurrentClip()->GetMode() == TGLClip::kInside);
135 fAutoUpdate->SetDown(fM->GetAutoUpdate());
137 if (fCurrentClip == TGLClip::kClipPlane) {
138 HideFrame(fBoxPropFrame);
139 ShowFrame(fPlanePropFrame);
140 for (Int_t i = 0; i < 4; ++i)
141 fPlaneProp[i]->SetNumber(clip[i]);
142 }
else if (fCurrentClip == TGLClip::kClipBox) {
143 HideFrame(fPlanePropFrame);
144 ShowFrame(fBoxPropFrame);
145 for (Int_t i = 0; i < 6; ++i)
146 fBoxProp[i]->SetNumber(clip[i]);
149 fResetButton->SetState(kButtonUp);
151 HideFrame(fPlanePropFrame);
152 HideFrame(fBoxPropFrame);
154 fResetButton->SetState(kButtonDisabled);
161 void TGLClipSetSubEditor::Changed()
169 void TGLClipSetSubEditor::ClipValueChanged()
171 fApplyButton->SetState(kButtonUp);
177 void TGLClipSetSubEditor::ClipTypeChanged(Int_t
id)
181 case 2: fCurrentClip = TGLClip::kClipPlane;
break;
182 case 3: fCurrentClip = TGLClip::kClipBox;
break;
183 default: fCurrentClip = TGLClip::kClipNone;
break;
185 fM->SetClipType(fCurrentClip);
187 ((TGMainFrame*)GetMainFrame())->Layout();
194 void TGLClipSetSubEditor::UpdateViewerClip()
196 Double_t data[6] = {0.};
198 if (fCurrentClip == TGLClip::kClipPlane)
199 for (Int_t i = 0; i < 4; ++i)
200 data[i] = fPlaneProp[i]->GetNumber();
201 else if (fCurrentClip == TGLClip::kClipBox)
202 for (Int_t i = 0; i < 6; ++i)
203 data[i] = fBoxProp[i]->GetNumber();
205 fApplyButton->SetState(kButtonDisabled);
207 fM->SetClipState(fCurrentClip, data);
208 fM->SetShowManip(fClipEdit->IsDown());
209 fM->SetShowClip (fClipShow->IsDown());
210 if (fCurrentClip != TGLClip::kClipNone)
211 fM->GetCurrentClip()->SetMode(fClipInside->IsDown() ? TGLClip::kInside : TGLClip::kOutside);
212 fM->SetAutoUpdate(fAutoUpdate->IsDown());
220 void TGLClipSetSubEditor::ResetViewerClip()
222 if (fCurrentClip != TGLClip::kClipNone) {
223 if (fM->GetClipType() == TGLClip::kClipPlane) {
224 TGLPlane plane(0.0, -1.0, 0.0, 0.0);
225 dynamic_cast<TGLClipPlane*
>(fM->GetCurrentClip())->Set(plane);
226 }
else if (fM->GetClipType() == TGLClip::kClipBox) {
227 fM->GetCurrentClip()->SetTransform(TGLMatrix());
239 ClassImp(TGLClipSetEditor);
244 TGLClipSetEditor::TGLClipSetEditor(
const TGWindow *p, Int_t width, Int_t height,
245 UInt_t options, Pixel_t back) :
246 TGedFrame(p, width, height, options | kVerticalFrame, back),
250 MakeTitle(
"TGLClipSet");
252 fSE =
new TGLClipSetSubEditor(
this);
253 AddFrame(fSE,
new TGLayoutHints(kLHintsTop, 2, 0, 2, 2));
254 fSE->Connect(
"Changed()",
"TGLClipSetEditor",
this,
"Update()");
261 void TGLClipSetEditor::SetModel(TObject* obj)
263 fM =
dynamic_cast<TGLClipSet*
>(obj);