TGLLightSetEditor.cxx

Go to the documentation of this file.
00001 // @(#)root/gl:$Id: TGLLightSetEditor.cxx 27157 2009-01-15 14:05:12Z brun $
00002 // Author:  Matevz Tadel, Feb 2007
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
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 // TGLLightSetSubEditor
00026 //
00027 // Sub-editor for TGLLightSet.
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    // Constructor.
00045 
00046    fLightFrame = new TGGroupFrame(this, "Light sources:", kVerticalFrame);//, kLHintsTop | kLHintsCenterX);
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    // Create a button for given lamp and set it up.
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    // New model was set, refresh data.
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    // Data in sub-editor has been changed, emit "Changed()" signal.
00101 
00102    Emit("Changed()");
00103 }
00104 
00105 //______________________________________________________________________________
00106 void TGLLightSetSubEditor::DoButton()
00107 {
00108    // Lights radio button was clicked.
00109 
00110    TGButton* b = (TGButton*) gTQSender;
00111    fM->SetLight(TGLLightSet::ELight(b->WidgetId()), b->IsOn());
00112    Changed();
00113 }
00114 
00115 
00116 //______________________________________________________________________________
00117 // TGLLightSetEditor
00118 //
00119 // Editor for TGLLightSet.
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    // Constructor.
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    // Destructor.
00144 }
00145 
00146 //______________________________________________________________________________
00147 void TGLLightSetEditor::SetModel(TObject* obj)
00148 {
00149    // SetModel ... forward to sub-editor.
00150 
00151    fM = dynamic_cast<TGLLightSet*>(obj);
00152    fSE->SetModel(fM);
00153 }

Generated on Tue Jul 5 14:18:07 2011 for ROOT_528-00b_version by  doxygen 1.5.1