00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "TGLLightSetEditor.h"
00013 #include <TGLLightSet.h>
00014
00015 #include <TVirtualPad.h>
00016 #include <TColor.h>
00017
00018 #include <TGLabel.h>
00019 #include <TGButton.h>
00020 #include <TGNumberEntry.h>
00021 #include <TGColorSelect.h>
00022 #include <TGDoubleSlider.h>
00023
00024
00025
00026
00027
00028
00029 ClassImp(TGLLightSetSubEditor)
00030
00031
00032 TGLLightSetSubEditor::TGLLightSetSubEditor(const TGWindow *p) :
00033 TGVerticalFrame(p),
00034 fM (0),
00035
00036 fLightFrame (0),
00037 fTopLight (0),
00038 fRightLight (0),
00039 fBottomLight (0),
00040 fLeftLight (0),
00041 fFrontLight (0),
00042 fSpecularLight (0)
00043 {
00044
00045
00046 fLightFrame = new TGGroupFrame(this, "Light sources:", kVerticalFrame);
00047 fLightFrame->SetTitlePos(TGGroupFrame::kLeft);
00048 AddFrame(fLightFrame, new TGLayoutHints(kLHintsTop| kLHintsExpandX, 1, 1, 1, 1));
00049 TGCompositeFrame* hf =0;
00050
00051 hf = new TGHorizontalFrame(fLightFrame);
00052 fTopLight = MakeLampButton("Top", TGLLightSet::kLightTop, hf);
00053 fBottomLight = MakeLampButton("Bottom", TGLLightSet::kLightBottom, hf);
00054 fLightFrame->AddFrame(hf, new TGLayoutHints(kLHintsTop|kLHintsExpandX, 0, 0, 2, 2));
00055
00056 hf = new TGHorizontalFrame(fLightFrame);
00057 fLeftLight = MakeLampButton("Left", TGLLightSet::kLightLeft, hf);
00058 fRightLight = MakeLampButton("Right", TGLLightSet::kLightRight, hf);
00059 fLightFrame->AddFrame(hf, new TGLayoutHints(kLHintsTop|kLHintsExpandX , 0, 0, 0, 2));
00060
00061 hf = new TGHorizontalFrame(fLightFrame);
00062 fFrontLight = MakeLampButton("Front", TGLLightSet::kLightFront, hf);
00063 fSpecularLight = MakeLampButton("Specular", TGLLightSet::kLightSpecular, hf);
00064
00065 fLightFrame->AddFrame(hf, new TGLayoutHints(kLHintsTop|kLHintsExpandX, 0, 0, 0, 2));
00066 }
00067
00068
00069 TGButton* TGLLightSetSubEditor::MakeLampButton(const char* name, Int_t wid,
00070 TGCompositeFrame* parent)
00071 {
00072
00073
00074 TGButton* b = new TGCheckButton(parent, name, wid);
00075 parent->AddFrame(b, new TGLayoutHints(kLHintsNormal|kLHintsExpandX, -2, 0, 0, 2));
00076 b->Connect("Clicked()", "TGLLightSetSubEditor", this, "DoButton()");
00077 return b;
00078 }
00079
00080
00081 void TGLLightSetSubEditor::SetModel(TGLLightSet* m)
00082 {
00083
00084
00085 fM = m;
00086 UInt_t als = fM->GetLightState();
00087
00088 fTopLight ->SetState((als & TGLLightSet::kLightTop) ? kButtonDown : kButtonUp);
00089 fRightLight ->SetState((als & TGLLightSet::kLightRight) ? kButtonDown : kButtonUp);
00090 fBottomLight->SetState((als & TGLLightSet::kLightBottom) ? kButtonDown : kButtonUp);
00091 fLeftLight ->SetState((als & TGLLightSet::kLightLeft) ? kButtonDown : kButtonUp);
00092 fFrontLight ->SetState((als & TGLLightSet::kLightFront) ? kButtonDown : kButtonUp);
00093
00094 fSpecularLight->SetState(fM->GetUseSpecular() ? kButtonDown : kButtonUp);
00095 }
00096
00097
00098 void TGLLightSetSubEditor::Changed()
00099 {
00100
00101
00102 Emit("Changed()");
00103 }
00104
00105
00106 void TGLLightSetSubEditor::DoButton()
00107 {
00108
00109
00110 TGButton* b = (TGButton*) gTQSender;
00111 fM->SetLight(TGLLightSet::ELight(b->WidgetId()), b->IsOn());
00112 Changed();
00113 }
00114
00115
00116
00117
00118
00119
00120
00121 ClassImp(TGLLightSetEditor)
00122
00123
00124 TGLLightSetEditor::TGLLightSetEditor(const TGWindow *p,
00125 Int_t width, Int_t height,
00126 UInt_t options, Pixel_t back) :
00127 TGedFrame(p, width, height, options | kVerticalFrame, back),
00128 fM (0),
00129 fSE (0)
00130 {
00131
00132
00133 MakeTitle("TGLLightSet");
00134
00135 fSE = new TGLLightSetSubEditor(this);
00136 AddFrame(fSE, new TGLayoutHints(kLHintsTop, 2, 0, 2, 2));
00137 fSE->Connect("Changed()", "TGLLightSetEditor", this, "Update()");
00138 }
00139
00140
00141 TGLLightSetEditor::~TGLLightSetEditor()
00142 {
00143
00144 }
00145
00146
00147 void TGLLightSetEditor::SetModel(TObject* obj)
00148 {
00149
00150
00151 fM = dynamic_cast<TGLLightSet*>(obj);
00152 fSE->SetModel(fM);
00153 }