00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "TEveShapeEditor.h"
00013 #include "TEveShape.h"
00014
00015 #include "TColor.h"
00016
00017
00018 #include "TGLabel.h"
00019 #include "TGButton.h"
00020 #include "TGNumberEntry.h"
00021 #include "TGColorSelect.h"
00022 #include "TGColorDialog.h"
00023
00024
00025
00026
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
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
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
00099
00100 fM->SetLineWidth(fLineWidth->GetNumber());
00101 Update();
00102 }
00103
00104
00105 void TEveShapeEditor::DoLineColor(Pixel_t pixel)
00106 {
00107
00108
00109 fM->SetLineColor(TColor::GetColor(pixel));
00110 Update();
00111 }
00112
00113
00114 void TEveShapeEditor::DoDrawFrame()
00115 {
00116
00117
00118 fM->SetDrawFrame(fDrawFrame->IsOn());
00119 Update();
00120 }
00121
00122
00123 void TEveShapeEditor::DoHighlightFrame()
00124 {
00125
00126
00127 fM->SetHighlightFrame(fHighlightFrame->IsOn());
00128 Update();
00129 }