#include "TVirtualGL.h"
#include "TVirtualX.h"
#include "TGCanvas.h"
#include "TGLayout.h"
#include "TGButton.h"
#include "TGButtonGroup.h"
#include "TGSlider.h"
#include "TGLabel.h"
#include "TGNumberEntry.h"
#include "TGLSAViewer.h"
#include "TGLEditor.h"
class TGLMatView : public TGCompositeFrame {
private:
TGLColorEditor *fOwner;
public:
TGLMatView(const TGWindow *parent, Window_t wid, TGLColorEditor *owner);
Bool_t HandleConfigureNotify(Event_t *event);
Bool_t HandleExpose(Event_t *event);
private:
TGLMatView(const TGLMatView &);
TGLMatView & operator = (const TGLMatView &);
};
TGLMatView::TGLMatView(const TGWindow *parent, Window_t wid, TGLColorEditor *owner)
:TGCompositeFrame(gClient, wid, parent), fOwner(owner)
{
AddInput(kExposureMask | kStructureNotifyMask);
}
Bool_t TGLMatView::HandleConfigureNotify(Event_t *event)
{
return fOwner->HandleContainerNotify(event);
}
Bool_t TGLMatView::HandleExpose(Event_t *event)
{
return fOwner->HandleContainerExpose(event);
}
namespace {
enum EGLEditorIdent {
kCPa = kTBa1 + 1,
kCPd, kCPs, kCPe,
kHSr, kHSg, kHSb,
kHSa, kHSs, kHSe,
kNExc, kNEyc, kNEzc,
kNExs, kNEys, kNEzs,
kNExp, kNEyp, kNEzp,
kNEat
};
}
ClassImp(TGLColorEditor)
TGLColorEditor::TGLColorEditor(const TGWindow *parent, TGLSAViewer *v)
:TGCompositeFrame(parent, 100, 100, kVerticalFrame),
fViewer(v), fRedSlider(0), fGreenSlider(0), fBlueSlider(0),
fAlphaSlider(0), fApplyButton(0), fIsActive(kFALSE),
fIsLight(kFALSE), fRGBA()
{
for (Int_t i = 0; i < 12; ++i) fRGBA[i] = 1.;
fRGBA[12] = 0.f, fRGBA[13] = 0.f, fRGBA[14] = 0.f;
fRGBA[15] = 1.f, fRGBA[16] = 60.f;
CreateMaterialView();
CreateRadioButtons();
CreateSliders();
fApplyButton = new TGTextButton(this, "Apply", kTBa);
AddFrame(fApplyButton, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 2, 2, 5, 0));
fApplyButton->SetState(kButtonDisabled);
fApplyButton->Connect("Pressed()", "TGLColorEditor", this, "DoButton()");
fApplyFamily = new TGTextButton(this, "Apply to family", kTBaf);
AddFrame(fApplyFamily, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 2, 2, 5, 0));
fApplyFamily->SetState(kButtonDisabled);
fApplyFamily->Connect("Pressed()", "TGLColorEditor", this, "DoButton()");
MakeCurrent();
gVirtualGL->NewPRGL();
gVirtualGL->FrustumGL(-0.5, 0.5, -0.5, 0.5, 1., 10.);
gVirtualGL->EnableGL(kLIGHTING);
gVirtualGL->EnableGL(kLIGHT0);
gVirtualGL->EnableGL(kDEPTH_TEST);
gVirtualGL->EnableGL(kCULL_FACE);
gVirtualGL->CullFaceGL(kBACK);
DrawSphere();
}
TGLColorEditor::~TGLColorEditor()
{
delete fMatView;
gVirtualGL->DeleteContext(fCtx);
}
void TGLColorEditor::SetRGBA(const Float_t *rgba)
{
fApplyButton->SetState(kButtonDisabled);
fApplyFamily->SetState(kButtonDisabled);
fIsActive = kTRUE;
for (Int_t i = 0; i < 17; ++i) fRGBA[i] = rgba[i];
if (rgba[16] < 0.f) {
if (fLMode == kEmission) {
fLMode = kDiffuse;
fLightTypes[kDiffuse]->SetState(kButtonDown);
fLightTypes[kEmission]->SetState(kButtonUp);
}
fLightTypes[kEmission]->SetState(kButtonDisabled);
fIsLight = kTRUE;
} else {
fIsLight = kFALSE;
fLightTypes[kEmission]->SetState(kButtonUp);
fAlphaSlider->SetPosition(Int_t(fRGBA[3] * 100));
fShineSlider->SetPosition(Int_t(fRGBA[16]));
}
fRedSlider->SetPosition(Int_t(fRGBA[fLMode * 4] * 100));
fGreenSlider->SetPosition(Int_t(fRGBA[fLMode * 4 + 1] * 100));
fBlueSlider->SetPosition(Int_t(fRGBA[fLMode * 4 + 2] * 100));
DrawSphere();
}
void TGLColorEditor::DoSlider(Int_t val)
{
TGSlider *frm = (TGSlider *)gTQSender;
if (frm) {
Int_t wid = frm->WidgetId();
switch (wid) {
case kHSr:
fRGBA[fLMode * 4] = val / 100.f;
break;
case kHSg:
fRGBA[fLMode * 4 + 1] = val / 100.f;
break;
case kHSb:
fRGBA[fLMode * 4 + 2] = val / 100.f;
break;
case kHSa:
if (!fIsLight) fRGBA[fLMode * 4 + 3] = val / 100.f;
break;
case kHSs:
if (!fIsLight) fRGBA[16] = val;
break;
}
if (!fIsLight || (wid != kHSa && wid != kHSs)) {
if (fIsActive) {
fApplyButton->SetState(kButtonUp);
if (!fIsLight) fApplyFamily->SetState(kButtonUp);
}
DrawSphere();
}
}
}
void TGLColorEditor::DoButton()
{
TGButton *btn = (TGButton *) gTQSender;
Int_t id = btn->WidgetId();
switch (id) {
case kCPd:
fLightTypes[fLMode]->SetState(kButtonUp);
fLMode = kDiffuse;
SetSlidersPos();
break;
case kCPa:
fLightTypes[fLMode]->SetState(kButtonUp);
fLMode = kAmbient;
SetSlidersPos();
break;
case kCPs:
fLightTypes[fLMode]->SetState(kButtonUp);
fLMode = kSpecular;
SetSlidersPos();
break;
case kCPe:
fLightTypes[fLMode]->SetState(kButtonUp);
fLMode = kEmission;
SetSlidersPos();
break;
case kTBa:
case kTBaf:
fApplyButton->SetState(kButtonDisabled);
fApplyFamily->SetState(kButtonDisabled);
fViewer->ProcessGUIEvent(id);
break;
}
DrawSphere();
}
void TGLColorEditor::Disable()
{
fApplyButton->SetState(kButtonDisabled);
fApplyButton->SetState(kButtonDisabled);
fIsActive = kFALSE;
fIsLight = kFALSE;
DrawSphere();
}
void TGLColorEditor::CreateMaterialView()
{
TGCanvas *viewCanvas = new TGCanvas(this, 120, 120, kSunkenFrame | kDoubleBorder);
Window_t wid = viewCanvas->GetViewPort()->GetId();
fGLWin = gVirtualGL->CreateGLWindow(wid);
fMatView = new TGLMatView(viewCanvas->GetViewPort(), fGLWin, this);
fCtx = gVirtualGL->CreateContext(fGLWin);
viewCanvas->SetContainer(fMatView);
AddFrame(viewCanvas, new TGLayoutHints(kLHintsTop | kLHintsCenterX, 2, 0, 2, 2));
}
void TGLColorEditor::CreateRadioButtons()
{
TGGroupFrame *partFrame = new TGGroupFrame(this, "Color components:", kLHintsTop | kLHintsCenterX);
partFrame->SetTitlePos(TGGroupFrame::kLeft);
AddFrame(partFrame, new TGLayoutHints(kLHintsTop | kLHintsCenterX, 2, 0, 2, 2));
TGMatrixLayout *ml = new TGMatrixLayout(partFrame, 0, 1, 10);
partFrame->SetLayoutManager(ml);
fLightTypes[kDiffuse] = new TGRadioButton(partFrame, "Diffuse", kCPd);
fLightTypes[kDiffuse]->Connect("Pressed()", "TGLColorEditor", this, "DoButton()");
fLightTypes[kDiffuse]->SetToolTipText("Diffuse component of color");
partFrame->AddFrame(fLightTypes[kDiffuse]);
fLightTypes[kAmbient] = new TGRadioButton(partFrame, "Ambient", kCPa);
fLightTypes[kAmbient]->Connect("Pressed()", "TGLColorEditor", this, "DoButton()");
fLightTypes[kAmbient]->SetToolTipText("Ambient component of color");
partFrame->AddFrame(fLightTypes[kAmbient]);
fLightTypes[kSpecular] = new TGRadioButton(partFrame, "Specular", kCPs);
fLightTypes[kSpecular]->Connect("Pressed()", "TGLColorEditor", this, "DoButton()");
fLightTypes[kSpecular]->SetToolTipText("Specular component of color");
partFrame->AddFrame(fLightTypes[kSpecular]);
fLightTypes[kEmission] = new TGRadioButton(partFrame, "Emissive", kCPe);
fLightTypes[kEmission]->Connect("Pressed()", "TGLColorEditor", this, "DoButton()");
fLightTypes[kEmission]->SetToolTipText("Emissive component of color");
partFrame->AddFrame(fLightTypes[kEmission]);
fLMode = kDiffuse;
fLightTypes[fLMode]->SetState(kButtonDown);
}
void TGLColorEditor::CreateSliders()
{
fRedSlider = new TGHSlider(this, 100, kSlider1 | kScaleBoth, kHSr);
fRedSlider->Connect("PositionChanged(Int_t)", "TGLColorEditor", this, "DoSlider(Int_t)");
fRedSlider->SetRange(0, 100);
fRedSlider->SetPosition(Int_t(fRGBA[0] * 100));
fGreenSlider = new TGHSlider(this, 100, kSlider1 | kScaleBoth, kHSg);
fGreenSlider->Connect("PositionChanged(Int_t)", "TGLColorEditor", this, "DoSlider(Int_t)");
fGreenSlider->SetRange(0, 100);
fGreenSlider->SetPosition(Int_t(fRGBA[1] * 100));
fBlueSlider = new TGHSlider(this, 100, kSlider1 | kScaleBoth, kHSb);
fBlueSlider->Connect("PositionChanged(Int_t)", "TGLColorEditor", this, "DoSlider(Int_t)");
fBlueSlider->SetRange(0, 100);
fBlueSlider->SetPosition(Int_t(fRGBA[2] * 100));
fAlphaSlider = new TGHSlider(this, 100, kSlider1 | kScaleBoth, kHSa);
fAlphaSlider->Connect("PositionChanged(Int_t)", "TGLColorEditor", this, "DoSlider(Int_t)");
fAlphaSlider->SetRange(0, 100);
fAlphaSlider->SetPosition(Int_t(fRGBA[3] * 100));
fShineSlider = new TGHSlider(this, 100, kSlider1 | kScaleBoth, kHSs);
fShineSlider->Connect("PositionChanged(Int_t)", "TGLColorEditor", this, "DoSlider(Int_t)");
fShineSlider->SetRange(0, 128);
AddFrame(new TGLabel(this, "Red :"), new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 0, 0, 0));
AddFrame(fRedSlider, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 0, 0, 0, 0));
AddFrame(new TGLabel(this, "Green :"), new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 0, 0, 0));
AddFrame(fGreenSlider, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 0, 0, 0, 0));
AddFrame(new TGLabel(this, "Blue :"), new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 0, 0, 0));
AddFrame(fBlueSlider, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 0, 0, 0, 0));
AddFrame(new TGLabel(this, "Opacity :"), new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 0, 0, 0));
AddFrame(fAlphaSlider, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 0, 0, 0, 0));
AddFrame(new TGLabel(this, "Shine :"), new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 0, 0, 0));
AddFrame(fShineSlider, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 0, 0, 0, 0));
}
void TGLColorEditor::SetSlidersPos()
{
fRedSlider->SetPosition(Int_t(fRGBA[fLMode * 4] * 100));
fGreenSlider->SetPosition(Int_t(fRGBA[fLMode * 4 + 1] * 100));
fBlueSlider->SetPosition(Int_t(fRGBA[fLMode * 4 + 2] * 100));
fAlphaSlider->SetPosition(Int_t(fRGBA[fLMode * 4 + 3] * 100));
if (fRGBA[16] >= 0.f)
fShineSlider->SetPosition(Int_t(fRGBA[16]));
}
Bool_t TGLColorEditor::HandleContainerNotify(Event_t *event)
{
gVirtualX->ResizeWindow(fGLWin, event->fWidth, event->fHeight);
DrawSphere();
return kTRUE;
}
Bool_t TGLColorEditor::HandleContainerExpose(Event_t * )
{
DrawSphere();
return kTRUE;
}
void TGLColorEditor::DrawSphere()const
{
MakeCurrent();
gVirtualGL->ClearGL(0);
if (fIsActive) {
gVirtualGL->ViewportGL(0, 0, fMatView->GetWidth(), fMatView->GetHeight());
gVirtualGL->NewMVGL();
Float_t ligPos[] = {0.f, 0.f, 0.f, 1.f};
gVirtualGL->GLLight(kLIGHT0, kPOSITION, ligPos);
gVirtualGL->TranslateGL(0., 0., -3.);
gVirtualGL->DrawSphere(fRGBA);
}
SwapBuffers();
}
void TGLColorEditor::MakeCurrent()const
{
gVirtualGL->MakeCurrent(fGLWin, fCtx);
}
void TGLColorEditor::SwapBuffers()const
{
gVirtualGL->SwapBuffers(fGLWin);
}
ClassImp(TGLGeometryEditor)
TGLGeometryEditor::TGLGeometryEditor(const TGWindow *parent, TGLSAViewer *v)
:TGCompositeFrame(parent, 100, 100, kVerticalFrame),
fViewer(v), fGeomData(), fApplyButton(0), fIsActive(kFALSE)
{
CreateCenterControls();
CreateStretchControls();
fApplyButton = new TGTextButton(this, "Modify object", kTBa1);
AddFrame(fApplyButton, new TGLayoutHints(kLHintsTop | kLHintsCenterX | kLHintsExpandX, 3, 3, 3, 3));
fApplyButton->SetState(kButtonDisabled);
fApplyButton->Connect("Pressed()", "TGLGeometryEditor", this, "DoButton()");
}
TGLGeometryEditor::~TGLGeometryEditor()
{
}
void TGLGeometryEditor::SetCenter(const Double_t *c)
{
fIsActive = kTRUE;
fApplyButton->SetState(kButtonDisabled);
fGeomData[kCenterX]->SetNumber(c[0]);
fGeomData[kCenterY]->SetNumber(c[1]);
fGeomData[kCenterZ]->SetNumber(c[2]);
}
void TGLGeometryEditor::SetScale(const Double_t *s)
{
fIsActive = kTRUE;
fGeomData[kScaleX]->SetNumber(s[0]);
fGeomData[kScaleY]->SetNumber(s[1]);
fGeomData[kScaleZ]->SetNumber(s[2]);
}
void TGLGeometryEditor::Disable()
{
fIsActive = kFALSE;
fApplyButton->SetState(kButtonDisabled);
}
void TGLGeometryEditor::DoButton()
{
if (TGButton *btn = (TGButton *)gTQSender) {
Int_t wid = btn->WidgetId();
fViewer->ProcessGUIEvent(wid);
if (wid == kTBa1) {
fApplyButton->SetState(kButtonDisabled);
}
}
}
void TGLGeometryEditor::GetObjectData(Double_t *center, Double_t *scale)
{
center[0] = fGeomData[kCenterX]->GetNumber();
center[1] = fGeomData[kCenterY]->GetNumber();
center[2] = fGeomData[kCenterZ]->GetNumber();
scale[0] = fGeomData[kScaleX]->GetNumber();
scale[1] = fGeomData[kScaleY]->GetNumber();
scale[2] = fGeomData[kScaleZ]->GetNumber();
}
void TGLGeometryEditor::ValueSet(Long_t)
{
if (!fIsActive)return;
fApplyButton->SetState(kButtonUp);
}
void TGLGeometryEditor::CreateCenterControls()
{
AddFrame(new TGLabel(this, "Object's center, X:"), new TGLayoutHints(kLHintsTop | kLHintsLeft, 3, 3, 3, 3));
fGeomData[kCenterX] = new TGNumberEntry(this, 0.0, 8, kNExc);
AddFrame(fGeomData[kCenterX], new TGLayoutHints(kLHintsTop | kLHintsCenterX | kLHintsExpandX, 3, 3, 3, 3));
fGeomData[kCenterX]->Connect("ValueSet(Long_t)", "TGLGeometryEditor",
this, "ValueSet(Long_t)");
AddFrame(new TGLabel(this, "Object's center, Y:"), new TGLayoutHints(kLHintsTop | kLHintsLeft, 3, 3, 3, 3));
fGeomData[kCenterY] = new TGNumberEntry(this, 0.0, 8, kNEyc);
AddFrame(fGeomData[kCenterY], new TGLayoutHints(kLHintsTop | kLHintsCenterX | kLHintsExpandX, 3, 3, 3, 3));
fGeomData[kCenterY]->Connect("ValueSet(Long_t)", "TGLGeometryEditor",
this, "ValueSet(Long_t)");
AddFrame(new TGLabel(this, "Object's center, Z:"), new TGLayoutHints(kLHintsTop | kLHintsLeft, 3, 3, 3, 3));
fGeomData[kCenterZ] = new TGNumberEntry(this, 0.0, 8, kNEzc);
AddFrame(fGeomData[kCenterZ], new TGLayoutHints(kLHintsTop | kLHintsCenterX | kLHintsExpandX, 3, 3, 3, 3));
fGeomData[kCenterZ]->Connect("ValueSet(Long_t)", "TGLGeometryEditor",
this, "ValueSet(Long_t)");
}
void TGLGeometryEditor::CreateStretchControls()
{
AddFrame(new TGLabel(this, "Object's scale, X:"), new TGLayoutHints(kLHintsTop | kLHintsLeft, 3, 3, 3, 3));
fGeomData[kScaleX] = new TGNumberEntry(this, 1.0, 8, kNExs);
AddFrame(fGeomData[kScaleX], new TGLayoutHints(kLHintsTop | kLHintsCenterX | kLHintsExpandX, 3, 3, 3, 3));
fGeomData[kScaleX]->Connect("ValueSet(Long_t)", "TGLGeometryEditor",
this, "ValueSet(Long_t)");
AddFrame(new TGLabel(this, "Object's scale, Y:"), new TGLayoutHints(kLHintsTop | kLHintsLeft, 3, 3, 3, 3));
fGeomData[kScaleY] = new TGNumberEntry(this, 1.0, 8, kNEys);
AddFrame(fGeomData[kScaleY], new TGLayoutHints(kLHintsTop | kLHintsCenterX | kLHintsExpandX, 3, 3, 3, 3));
fGeomData[kScaleY]->Connect("ValueSet(Long_t)", "TGLGeometryEditor",
this, "ValueSet(Long_t)");
AddFrame(new TGLabel(this, "Object's scale, Z:"), new TGLayoutHints(kLHintsTop | kLHintsLeft, 3, 3, 3, 3));
fGeomData[kScaleZ] = new TGNumberEntry(this, 1.0, 8, kNEzs);
AddFrame(fGeomData[kScaleZ], new TGLayoutHints(kLHintsTop | kLHintsCenterX | kLHintsExpandX, 3, 3, 3, 3));
fGeomData[kScaleZ]->Connect("ValueSet(Long_t)", "TGLGeometryEditor",
this, "ValueSet(Long_t)");
fGeomData[kScaleX]->SetLimits(TGNumberFormat::kNELLimitMin, 0.1);
fGeomData[kScaleY]->SetLimits(TGNumberFormat::kNELLimitMin, 0.1);
fGeomData[kScaleZ]->SetLimits(TGNumberFormat::kNELLimitMin, 0.1);
}
ClassImp(TGLClipEditor)
TGLClipEditor::TGLClipEditor(const TGWindow *parent, TGLSAViewer *v) :
TGCompositeFrame(parent, 100, 100, kVerticalFrame),
fViewer(v), fCurrentClip(kClipNone)
{
fTrash.SetOwner(kTRUE);
fL1 = new TGLayoutHints(kLHintsTop | kLHintsCenterX | kLHintsExpandX, 3, 3, 3, 3);
fTrash.AddLast(fL1);
fL2 = new TGLayoutHints(kLHintsTop | kLHintsLeft, 3, 3, 3, 3);
fTrash.AddLast(fL2);
CreateControls();
}
TGLClipEditor::~TGLClipEditor()
{
}
void TGLClipEditor::CreateControls()
{
fTypeButtons = new TGButtonGroup(this, "Clip Type");
fTrash.AddLast(fTypeButtons);
TGRadioButton * clipNone = new TGRadioButton(fTypeButtons, "None");
fTrash.AddLast(clipNone);
TGRadioButton * clipPlane = new TGRadioButton(fTypeButtons, "Plane");
fTrash.AddLast(clipPlane);
TGRadioButton * clipBox = new TGRadioButton(fTypeButtons, "Box");
fTrash.AddLast(clipBox);
AddFrame(fTypeButtons, fL1);
fTypeButtons->Connect("Pressed(Int_t)", "TGLClipEditor", this, "ClipTypeChanged(Int_t)");
fEdit = new TGCheckButton(this, "Show / Edit In Viewer", kTBda);
fTrash.AddLast(fEdit);
AddFrame(fEdit, fL1);
fEdit->Connect("Clicked()", "TGLClipEditor", this, "UpdateViewer()");
fPlanePropFrame = new TGCompositeFrame(this);
fTrash.AddLast(fPlanePropFrame);
AddFrame(fPlanePropFrame, fL1);
TGLabel * label;
std::string planeStr[4] = { "aX + ", "bY +", "cZ + ", "d = 0" };
UInt_t i;
for (i=0; i<4; i++) {
label = new TGLabel(fPlanePropFrame, planeStr[i].c_str());
fTrash.AddLast(label);
fPlanePropFrame->AddFrame(label, fL2);
fPlaneProp[i] = new TGNumberEntry(fPlanePropFrame, 1., 8);
fTrash.AddLast(fPlaneProp[i]);
fPlanePropFrame->AddFrame(fPlaneProp[i], fL1);
fPlaneProp[i]->Connect("ValueSet(Long_t)", "TGLClipEditor",
this, "ClipValueChanged(Long_t)");
}
fBoxPropFrame = new TGCompositeFrame(this);
fTrash.AddLast(fBoxPropFrame);
AddFrame(fBoxPropFrame, fL1);
std::string boxStr[6] = { "Center X", "Center Y", "Center Y", "Length X", "Length Y", "Length Z" };
for (i=0; i<6; i++) {
label = new TGLabel(fBoxPropFrame, boxStr[i].c_str());
fTrash.AddLast(label);
fBoxPropFrame->AddFrame(label, fL2);
fBoxProp[i] = new TGNumberEntry(fBoxPropFrame, 1., 8);
fTrash.AddLast(fBoxProp[i]);
fBoxPropFrame->AddFrame(fBoxProp[i], fL1);
fBoxProp[i]->Connect("ValueSet(Long_t)", "TGLClipEditor",
this, "ClipValueChanged(Long_t)");
}
fApplyButton = new TGTextButton(this, "Apply", kTBcpm);
fTrash.AddLast(fApplyButton);
AddFrame(fApplyButton, fL1);
fApplyButton->SetState(kButtonDisabled);
fApplyButton->Connect("Pressed()", "TGLClipEditor", this, "UpdateViewer()");
clipNone->SetState(kButtonDown);
}
void TGLClipEditor::HideParts()
{
HideFrame(fPlanePropFrame);
HideFrame(fBoxPropFrame);
}
void TGLClipEditor::ClipValueChanged(Long_t)
{
fApplyButton->SetState(kButtonUp);
}
void TGLClipEditor::ClipTypeChanged(Int_t id)
{
if (id == 1) {
SetCurrent(kClipNone, kFALSE);
fEdit->SetState(kButtonDisabled);
} else {
if (fEdit->GetState() == kButtonDisabled) {
fEdit->SetState(kButtonUp);
}
SetCurrent(id == 2 ? kClipPlane : kClipBox, fEdit->IsDown());
}
UpdateViewer();
}
void TGLClipEditor::UpdateViewer()
{
fViewer->ProcessGUIEvent(kTBcpm);
fApplyButton->SetState(kButtonDisabled);
}
void TGLClipEditor::GetState(EClipType type, Double_t data[6]) const
{
UInt_t i;
if (type == kClipNone) {
} else if (type == kClipPlane) {
for (i=0; i<4; i++) {
data[i] = fPlaneProp[i]->GetNumber();
}
} else if (type == kClipBox) {
for (i=0; i<6; i++) {
data[i] = fBoxProp[i]->GetNumber();
}
} else {
Error("TGLClipEditor::GetClipState", "Invalid clip type");
}
}
void TGLClipEditor::SetState(EClipType type, const Double_t data[6])
{
UInt_t i;
if (type == kClipNone) {
} else if (type == kClipPlane) {
for (i=0; i<4; i++) {
fPlaneProp[i]->SetNumber(data[i]);
}
} else if (type == kClipBox) {
for (i=0; i<6; i++) {
fBoxProp[i]->SetNumber(data[i]);
}
} else {
Error("TGLClipEditor::SetClipState", "Invalid clip type");
}
fApplyButton->SetState(kButtonDisabled);
}
void TGLClipEditor::GetCurrent(EClipType & type, Bool_t & edit) const
{
type = fCurrentClip;
edit = fEdit->IsDown();
}
void TGLClipEditor::SetCurrent(EClipType type, Bool_t edit)
{
fCurrentClip = type;
switch(fCurrentClip) {
case(kClipNone): {
fTypeButtons->SetButton(1);
HideFrame(fPlanePropFrame);
HideFrame(fBoxPropFrame);
break;
}
case(kClipPlane): {
fTypeButtons->SetButton(2);
ShowFrame(fPlanePropFrame);
HideFrame(fBoxPropFrame);
break;
}
case(kClipBox): {
fTypeButtons->SetButton(3);
HideFrame(fPlanePropFrame);
ShowFrame(fBoxPropFrame);
break;
}
default: {
Error("TGLClipEditor::SetCurrentClip", "Invalid clip type");
break;
}
}
fEdit->SetDown(edit);
}
ClassImp(TGLLightEditor)
TGLLightEditor::TGLLightEditor(const TGWindow *parent, TGLSAViewer *v)
:TGCompositeFrame(parent, 100, 100, kVerticalFrame),
fViewer(v)
{
fTrash.SetOwner(kTRUE);
TGGroupFrame *ligFrame = new TGGroupFrame(this, "Sources", kLHintsTop | kLHintsCenterX);
fTrash.AddLast(ligFrame);
ligFrame->SetTitlePos(TGGroupFrame::kLeft);
TGLayoutHints *l = new TGLayoutHints(kLHintsTop | kLHintsCenterX | kLHintsExpandX, 3, 3, 3, 3);
fTrash.AddLast(l);
AddFrame(ligFrame, l);
TGMatrixLayout *ml = new TGMatrixLayout(ligFrame, 0, 1, 10);
ligFrame->SetLayoutManager(ml);
fLights[kTop] = new TGCheckButton(ligFrame, "Top", kTBTop);
fLights[kTop]->Connect("Clicked()", "TGLLightEditor", this, "DoButton()");
fLights[kTop]->SetState(kButtonDown);
fTrash.AddLast(fLights[kTop]);
fLights[kRight] = new TGCheckButton(ligFrame, "Right", kTBRight);
fLights[kRight]->Connect("Clicked()", "TGLLightEditor", this, "DoButton()");
fLights[kRight]->SetState(kButtonDown);
fTrash.AddLast(fLights[kRight]);
fLights[kBottom] = new TGCheckButton(ligFrame, "Bottom", kTBBottom);
fLights[kBottom]->Connect("Clicked()", "TGLLightEditor", this, "DoButton()");
fLights[kBottom]->SetState(kButtonDown);
fTrash.AddLast(fLights[kBottom]);
fLights[kLeft] = new TGCheckButton(ligFrame, "Left", kTBLeft);
fLights[kLeft]->Connect("Clicked()", "TGLLightEditor", this, "DoButton()");
fLights[kLeft]->SetState(kButtonDown);
fTrash.AddLast(fLights[kLeft]);
fLights[kFront] = new TGCheckButton(ligFrame, "Front", kTBFront);
fLights[kFront]->Connect("Clicked()", "TGLLightEditor", this, "DoButton()");
fLights[kFront]->SetState(kButtonDown);
fTrash.AddLast(fLights[kFront]);
ligFrame->AddFrame(fLights[kTop]);
ligFrame->AddFrame(fLights[kRight]);
ligFrame->AddFrame(fLights[kBottom]);
ligFrame->AddFrame(fLights[kLeft]);
ligFrame->AddFrame(fLights[kFront]);
}
TGLLightEditor::~TGLLightEditor()
{
}
void TGLLightEditor::DoButton()
{
TGButton *btn = (TGButton *) gTQSender;
Int_t id = btn->WidgetId();
fViewer->ProcessGUIEvent(id);
}
ClassImp(TGLGuideEditor)
TGLGuideEditor::TGLGuideEditor(const TGWindow *parent, TGLSAViewer *v) :
TGCompositeFrame(parent, 100, 100, kVerticalFrame),
fViewer(v), fAxesContainer(0), fReferenceContainer(0),
fReferenceOn(0),
fL1(0), fL2(0)
{
fTrash.SetOwner(kTRUE);
fL1 = new TGLayoutHints(kLHintsTop | kLHintsCenterX | kLHintsExpandX, 0, 0, 1, 1);
fTrash.AddLast(fL1);
fL2 = new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 0, 3, 3);
fTrash.AddLast(fL2);
fAxesContainer = new TGButtonGroup(this, "Axes");
fTrash.AddLast(fAxesContainer);
AddFrame(fAxesContainer, fL1);
fAxesContainer->Connect("Pressed(Int_t)", "TGLGuideEditor", this, "Update()");
TGRadioButton * axesNone = new TGRadioButton(fAxesContainer, "None");
fTrash.AddLast(axesNone);
TGRadioButton * axesEdge = new TGRadioButton(fAxesContainer, "Edge");
fTrash.AddLast(axesEdge);
TGRadioButton * axesOrigins = new TGRadioButton(fAxesContainer, "Origin");
fTrash.AddLast(axesOrigins);
fReferenceContainer = new TGGroupFrame(this, "Reference Marker");
fTrash.AddLast(fReferenceContainer);
AddFrame(fReferenceContainer, fL1);
fReferenceOn = new TGCheckButton(fReferenceContainer, "Show");
fTrash.AddLast(fReferenceOn);
fReferenceContainer->AddFrame(fReferenceOn, fL1);
fReferenceOn->Connect("Clicked()", "TGLGuideEditor", this, "Update()");
TGLabel * label = new TGLabel(fReferenceContainer, "X");
fTrash.AddLast(label);
fReferenceContainer->AddFrame(label, fL2);
fReferencePos[0] = new TGNumberEntry(fReferenceContainer, 0.0, 8);
fTrash.AddLast(fReferencePos[0]);
fReferenceContainer->AddFrame(fReferencePos[0], fL1);
fReferencePos[0]->Connect("ValueSet(Long_t)", "TGLGuideEditor",
this, "Update()");
label = new TGLabel(fReferenceContainer, "Y");
fTrash.AddLast(label);
fReferenceContainer->AddFrame(label, fL2);
fReferencePos[1] = new TGNumberEntry(fReferenceContainer, 0.0, 8);
fTrash.AddLast(fReferencePos[1]);
fReferenceContainer->AddFrame(fReferencePos[1], fL1);
fReferencePos[1]->Connect("ValueSet(Long_t)", "TGLGuideEditor",
this, "Update()");
label = new TGLabel(fReferenceContainer, "Z");
fTrash.AddLast(label);
fReferenceContainer->AddFrame(label, fL2);
fReferencePos[2] = new TGNumberEntry(fReferenceContainer, 0.0, 8);
fTrash.AddLast(fReferencePos[2]);
fReferenceContainer->AddFrame(fReferencePos[2], fL1);
fReferencePos[2]->Connect("ValueSet(Long_t)", "TGLGuideEditor",
this, "Update()");
axesNone->SetState(kButtonDown);
}
TGLGuideEditor::~TGLGuideEditor()
{
}
void TGLGuideEditor::Update()
{
fViewer->ProcessGUIEvent(kTBGuide);
UpdateReferencePos();
}
void TGLGuideEditor::GetState(TGLViewer::EAxesType & axesType, Bool_t & referenceOn, Double_t referencePos[3]) const
{
for (Int_t i = 1; i < 4; i++) {
TGButton * button = fAxesContainer->GetButton(i);
if (button && button->IsDown()) {
axesType = TGLViewer::EAxesType(i-1);
}
}
referenceOn = fReferenceOn->IsDown();
referencePos[0] = fReferencePos[0]->GetNumber();
referencePos[1] = fReferencePos[1]->GetNumber();
referencePos[2] = fReferencePos[2]->GetNumber();
}
void TGLGuideEditor::SetState(TGLViewer::EAxesType axesType, Bool_t referenceOn, const Double_t referencePos[3])
{
TGButton * button = fAxesContainer->GetButton(axesType+1);
if (button) {
button->SetDown();
}
fReferenceOn->SetDown(referenceOn);
fReferencePos[0]->SetNumber(referencePos[0]);
fReferencePos[1]->SetNumber(referencePos[1]);
fReferencePos[2]->SetNumber(referencePos[2]);
UpdateReferencePos();
}
void TGLGuideEditor::UpdateReferencePos()
{
fReferencePos[0]->SetState(fReferenceOn->IsDown());
fReferencePos[1]->SetState(fReferenceOn->IsDown());
fReferencePos[2]->SetState(fReferenceOn->IsDown());
}
ROOT page - Class index - Class Hierarchy - Top of the page
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.