Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TEveShapeEditor.cxx
Go to the documentation of this file.
1 // @(#)root/eve:$Id$
2 // Author: Matevz Tadel 2007
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #include "TEveShapeEditor.h"
13 #include "TEveShape.h"
14 
15 #include "TColor.h"
16 
17 // Cleanup these includes:
18 #include "TGLabel.h"
19 #include "TGButton.h"
20 #include "TGNumberEntry.h"
21 #include "TGColorSelect.h"
22 #include "TGColorDialog.h"
23 
24 
25 /** \class TEveShapeEditor
26 \ingroup TEve
27 GUI editor for TEveShape.
28 */
29 
30 ClassImp(TEveShapeEditor);
31 
32 ////////////////////////////////////////////////////////////////////////////////
33 /// Constructor.
34 
35 TEveShapeEditor::TEveShapeEditor(const TGWindow *p, Int_t width, Int_t height,
36  UInt_t options, Pixel_t back) :
37  TGedFrame(p, width, height, options | kVerticalFrame, back),
38  fM(0),
39  fLineWidth(0),
40  fLineColor(0),
41  fDrawFrame(0),
42  fHighlightFrame(0)
43 {
44  MakeTitle("TEveShape");
45 
46  {
47  TGCompositeFrame *f = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
48 
49  TGLabel *l = new TGLabel(f, "LineColor:");
50  f->AddFrame(l, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 0));
51  fLineColor = new TGColorSelect(f, 0, -1);
52  fLineColor->Connect("ColorSelected(Pixel_t)", "TEveShapeEditor", this, "DoLineColor(Pixel_t)");
53  f->AddFrame(fLineColor, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
54 
55  fLineWidth = new TGNumberEntry(f, 0., 4, -1,
56  TGNumberFormat::kNESRealOne, TGNumberFormat::kNEAPositive,
57  TGNumberFormat::kNELLimitMinMax, 0.1, 20.0);
58  fLineWidth->GetNumberEntry()->SetToolTipText("Line width of outline.");
59  fLineWidth->Connect("ValueSet(Long_t)", "TEveShapeEditor", this, "DoLineWidth()");
60  f->AddFrame(fLineWidth, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
61 
62  AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
63  }
64  {
65  TGHorizontalFrame* f = new TGHorizontalFrame(this);
66 
67  fDrawFrame = new TGCheckButton(f, "Draw Frame");
68  f->AddFrame(fDrawFrame, new TGLayoutHints(kLHintsLeft, 1,2,0,0));
69  fDrawFrame->Connect("Toggled(Bool_t)", "TEveShapeEditor", this, "DoDrawFrame()");
70 
71  fHighlightFrame = new TGCheckButton(f, "Highlight Frame");
72  f->AddFrame(fHighlightFrame, new TGLayoutHints(kLHintsLeft, 2,1,0,0));
73  fHighlightFrame->Connect("Toggled(Bool_t)", "TEveShapeEditor", this, "DoHighlightFrame()");
74 
75  AddFrame(f, new TGLayoutHints(kLHintsTop, 0,0,2,1));
76  }
77 }
78 
79 ////////////////////////////////////////////////////////////////////////////////
80 /// Set model object.
81 
82 void TEveShapeEditor::SetModel(TObject* obj)
83 {
84  fM = dynamic_cast<TEveShape*>(obj);
85 
86  fLineWidth->SetNumber(fM->fLineWidth);
87  fLineColor->SetColor(TColor::Number2Pixel(fM->fLineColor), kFALSE);
88  fDrawFrame ->SetState(fM->fDrawFrame ? kButtonDown : kButtonUp);
89  fHighlightFrame->SetState(fM->fHighlightFrame ? kButtonDown : kButtonUp);
90 }
91 
92 ////////////////////////////////////////////////////////////////////////////////
93 /// Slot for setting line with of polygon outline.
94 
95 void TEveShapeEditor::DoLineWidth()
96 {
97  fM->SetLineWidth(fLineWidth->GetNumber());
98  Update();
99 }
100 
101 ////////////////////////////////////////////////////////////////////////////////
102 /// Slot for setting line color of polygon outline.
103 
104 void TEveShapeEditor::DoLineColor(Pixel_t pixel)
105 {
106  fM->SetLineColor(TColor::GetColor(pixel));
107  Update();
108 }
109 
110 ////////////////////////////////////////////////////////////////////////////////
111 /// Slot for DrawFrame.
112 
113 void TEveShapeEditor::DoDrawFrame()
114 {
115  fM->SetDrawFrame(fDrawFrame->IsOn());
116  Update();
117 }
118 
119 ////////////////////////////////////////////////////////////////////////////////
120 /// Slot for HighlightFrame.
121 
122 void TEveShapeEditor::DoHighlightFrame()
123 {
124  fM->SetHighlightFrame(fHighlightFrame->IsOn());
125  Update();
126 }