TEveShapeEditor.cxx

Go to the documentation of this file.
00001 // @(#)root/eve:$Id: TEveShapeEditor.cxx 32483 2010-03-05 19:31:54Z matevz $
00002 // Author: Matevz Tadel 2007
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2007, 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 "TEveShapeEditor.h"
00013 #include "TEveShape.h"
00014 
00015 #include "TColor.h"
00016 
00017 // Cleanup these includes:
00018 #include "TGLabel.h"
00019 #include "TGButton.h"
00020 #include "TGNumberEntry.h"
00021 #include "TGColorSelect.h"
00022 #include "TGColorDialog.h"
00023 
00024 
00025 //______________________________________________________________________________
00026 // GUI editor for TEveShape.
00027 //
00028 
00029 ClassImp(TEveShapeEditor);
00030 
00031 //______________________________________________________________________________
00032 TEveShapeEditor::TEveShapeEditor(const TGWindow *p, Int_t width, Int_t height,
00033              UInt_t options, Pixel_t back) :
00034    TGedFrame(p, width, height, options | kVerticalFrame, back),
00035    fM(0),
00036    fLineWidth(0),
00037    fLineColor(0),
00038    fDrawFrame(0),
00039    fHighlightFrame(0)
00040 {
00041    // Constructor.
00042 
00043    MakeTitle("TEveShape");
00044 
00045    {
00046       TGCompositeFrame *f = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
00047 
00048       TGLabel *l = new TGLabel(f, "LineColor:");
00049       f->AddFrame(l, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 0));
00050       fLineColor = new TGColorSelect(f, 0, -1);
00051       fLineColor->Connect("ColorSelected(Pixel_t)", "TEveShapeEditor", this, "DoLineColor(Pixel_t)");
00052       f->AddFrame(fLineColor, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
00053 
00054       fLineWidth = new TGNumberEntry(f, 0., 4, -1,
00055                                      TGNumberFormat::kNESRealOne, TGNumberFormat::kNEAPositive,
00056                                      TGNumberFormat::kNELLimitMinMax, 0.1, 20.0);
00057       fLineWidth->GetNumberEntry()->SetToolTipText("Line width of outline.");
00058       fLineWidth->Connect("ValueSet(Long_t)", "TEveShapeEditor", this, "DoLineWidth()");
00059       f->AddFrame(fLineWidth, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
00060 
00061       AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
00062    }
00063    {
00064       TGHorizontalFrame* f = new TGHorizontalFrame(this);
00065 
00066       fDrawFrame  = new TGCheckButton(f, "Draw Frame");
00067       f->AddFrame(fDrawFrame, new TGLayoutHints(kLHintsLeft, 1,2,0,0));
00068       fDrawFrame->Connect("Toggled(Bool_t)", "TEveShapeEditor", this, "DoDrawFrame()");
00069 
00070       fHighlightFrame = new TGCheckButton(f, "Highlight Frame");
00071       f->AddFrame(fHighlightFrame, new TGLayoutHints(kLHintsLeft, 2,1,0,0));
00072       fHighlightFrame->Connect("Toggled(Bool_t)"," TEveShapeEditor", this, "DoHighlightFrame()");
00073 
00074       AddFrame(f, new TGLayoutHints(kLHintsTop, 0,0,2,1));
00075    }
00076 }
00077 
00078 //==============================================================================
00079 
00080 //______________________________________________________________________________
00081 void TEveShapeEditor::SetModel(TObject* obj)
00082 {
00083    // Set model object.
00084 
00085    fM = dynamic_cast<TEveShape*>(obj);
00086 
00087    fLineWidth->SetNumber(fM->fLineWidth);
00088    fLineColor->SetColor(TColor::Number2Pixel(fM->fLineColor), kFALSE);
00089    fDrawFrame     ->SetState(fM->fDrawFrame      ? kButtonDown : kButtonUp);
00090    fHighlightFrame->SetState(fM->fHighlightFrame ? kButtonDown : kButtonUp);
00091 }
00092 
00093 //==============================================================================
00094 
00095 //______________________________________________________________________________
00096 void TEveShapeEditor::DoLineWidth()
00097 {
00098    // Slot for setting line with of polygon outline.
00099 
00100    fM->SetLineWidth(fLineWidth->GetNumber());
00101    Update();
00102 }
00103 
00104 //______________________________________________________________________________
00105 void TEveShapeEditor::DoLineColor(Pixel_t pixel)
00106 {
00107    // Slot for setting line color of polygon outline.
00108 
00109    fM->SetLineColor(TColor::GetColor(pixel));
00110    Update();
00111 }
00112 
00113 //______________________________________________________________________________
00114 void TEveShapeEditor::DoDrawFrame()
00115 {
00116    // Slot for DrawFrame.
00117 
00118    fM->SetDrawFrame(fDrawFrame->IsOn());
00119    Update();
00120 }
00121 
00122 //______________________________________________________________________________
00123 void TEveShapeEditor::DoHighlightFrame()
00124 {
00125    // Slot for HighlightFrame.
00126 
00127    fM->SetHighlightFrame(fHighlightFrame->IsOn());
00128    Update();
00129 }

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