]>
Commit | Line | Data |
---|---|---|
5a5a1232 | 1 | // $Header$ |
2 | ||
3 | #include "RenderElementEditor.h" | |
4 | #include <Reve/RenderElement.h> | |
5 | ||
6 | #include <TVirtualPad.h> | |
7 | #include <TColor.h> | |
8 | ||
9 | #include <TGLabel.h> | |
10 | #include <TGButton.h> | |
11 | #include <TGNumberEntry.h> | |
12 | #include <TGColorSelect.h> | |
13 | #include <TGDoubleSlider.h> | |
14 | ||
15 | using namespace Reve; | |
16 | ||
17 | //______________________________________________________________________ | |
18 | // RenderElementEditor | |
19 | // | |
20 | ||
21 | ClassImp(RenderElementEditor) | |
22 | ||
265ecb21 | 23 | RenderElementEditor::RenderElementEditor(const TGWindow *p, Int_t id, |
24 | Int_t width, Int_t height, | |
25 | UInt_t options, Pixel_t back) : | |
26 | TGedFrame(p, id, width, height, options | kVerticalFrame, back), | |
27 | ||
28 | fRE (0), | |
29 | fHFrame (0), | |
30 | fRnrElement (0), | |
31 | fMainColor (0) | |
5a5a1232 | 32 | { |
5a5a1232 | 33 | MakeTitle("RenderElement"); |
34 | ||
35 | fHFrame = new TGHorizontalFrame(this); | |
36 | ||
37 | fMainColor = new TGColorSelect(fHFrame, 0, -1); | |
38 | fHFrame->AddFrame(fMainColor, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1)); | |
39 | fMainColor->Associate(fHFrame); | |
40 | fMainColor->Connect | |
41 | ("ColorSelected(Pixel_t)", | |
42 | "Reve::RenderElementEditor", this, "DoMainColor(Pixel_t)"); | |
43 | ||
44 | fRnrElement = new TGCheckButton(fHFrame, "Render element"); | |
45 | fHFrame->AddFrame(fRnrElement, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1)); | |
46 | fRnrElement->Connect | |
47 | ("Toggled(Bool_t)", | |
48 | "Reve::RenderElementEditor", this, "DoRnrElement()"); | |
49 | ||
50 | AddFrame(fHFrame, new TGLayoutHints(kLHintsTop, 0, 0, 1, 1)); | |
51 | ||
52 | // Register the editor. | |
53 | TClass *cl = RenderElement::Class(); | |
54 | TGedElement *ge = new TGedElement; | |
55 | ge->fGedFrame = this; | |
56 | ge->fCanvas = 0; | |
57 | cl->GetEditorList()->Add(ge); | |
58 | } | |
59 | ||
60 | RenderElementEditor::~RenderElementEditor() | |
61 | {} | |
62 | ||
63 | /**************************************************************************/ | |
64 | ||
65 | void RenderElementEditor::SetModel(TVirtualPad* pad, TObject* obj, Int_t ) | |
66 | { | |
67 | fModel = 0; | |
68 | fPad = 0; | |
69 | ||
70 | if (!obj || !obj->InheritsFrom(RenderElement::Class()) || obj->InheritsFrom(TVirtualPad::Class())) { | |
71 | SetActive(kFALSE); | |
72 | return; | |
73 | } | |
74 | ||
75 | fModel = obj; | |
76 | fPad = pad; | |
77 | ||
78 | fRE = dynamic_cast<RenderElement*>(fModel); | |
79 | ||
80 | if (fRE->CanEditRnrElement()) { | |
81 | fRnrElement->SetState(fRE->GetRnrElement() ? kButtonDown : kButtonUp); | |
82 | fRnrElement->MapWindow(); | |
83 | } else { | |
84 | fRnrElement->UnmapWindow(); | |
85 | } | |
86 | ||
87 | if (fRE->CanEditMainColor()) { | |
88 | fMainColor->SetColor(TColor::Number2Pixel(fRE->GetMainColor()), kFALSE); | |
89 | fMainColor->MapWindow(); | |
90 | } else { | |
91 | fMainColor->UnmapWindow(); | |
92 | } | |
93 | ||
94 | fHFrame->Layout(); | |
95 | ||
96 | SetActive(); | |
97 | } | |
98 | ||
99 | /**************************************************************************/ | |
100 | ||
101 | ||
102 | void RenderElementEditor::DoRnrElement() | |
103 | { | |
104 | Bool_t fd = fRnrElement->IsOn(); | |
105 | fRE->SetRnrElement(fd); | |
106 | Update(); | |
107 | } | |
108 | ||
109 | void RenderElementEditor::DoMainColor(Pixel_t color) | |
110 | { | |
111 | // Slot connected to the axis color. | |
112 | ||
113 | fRE->SetMainColor(color); | |
114 | Update(); | |
115 | } |