Logo ROOT  
Reference Guide
TEveGedEditor.cxx
Go to the documentation of this file.
1// @(#)root/eve:$Id$
2// Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 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 "TEveGedEditor.h"
13#include "TEveElement.h"
14#include "TEveManager.h"
15
16#include "TGButton.h"
17#include "TGLabel.h"
18#include "TGToolTip.h"
19#include "TGDNDManager.h"
20#include "TGMsgBox.h"
21
22#include "TClass.h"
23#include "TContextMenu.h"
24#include "TVirtualX.h"
25
26/** \class TEveGedEditor
27\ingroup TEve
28Specialization of TGedEditor for proper update propagation to TEveManager.
29*/
30
32
35
37
38////////////////////////////////////////////////////////////////////////////////
39/// Constructor.
40
42 TGedEditor(canvas, width, height),
43 fElement (0),
44 fObject (0)
45{
46 // Remove old name-frame -- it is created in TGedEditor constructor
47 // so virtuals are not active yet.
50 nf->SetGedEditor(this);
51 nf->SetModelClass(0);
53
54 // Fix priority for TAttMarkerEditor.
55 TClass* amClass = TClass::GetClass("TAttMarker");
56 TClass* edClass = TClass::GetClass("TAttMarkerEditor");
57 TGWindow *exroot = (TGWindow*) fClient->GetRoot();
59 SetFrameCreator(this);
60 TGedFrame *frame = reinterpret_cast<TGedFrame*>(edClass->New());
61 frame->SetModelClass(amClass);
62 {
63 Int_t off = edClass->GetDataMemberOffset("fPriority");
64 if (off == 0)
65 Warning("TEveGedEditor::TEveGedEditor", "Can't fix priority for TAttMarkerEditor.\n");
66 else
67 * (Int_t*) (((char*)frame) + off) = 1;
68 }
70 fClient->SetRoot(exroot);
71 fFrameMap.Add(amClass, frame);
72}
73
74////////////////////////////////////////////////////////////////////////////////
75/// Destructor.
76
78{
79 if (gDebug > 0)
80 Info("TEveGedEditor::~TEveGedEditor", "%p going down.", this);
81}
82
83////////////////////////////////////////////////////////////////////////////////
84/// Called from window-manger close button.
85/// Unregister from global list and delete the window.
86
88{
89 if (gDebug > 0)
90 Info("TEveGedEditor::CloseWindow", "%p closing.", this);
91
93
95
96 if (gDNDManager) {
97 if (gDNDManager->GetMainFrame() == this)
99 }
100 DeleteWindow();
101}
102
103////////////////////////////////////////////////////////////////////////////////
104/// Create name-frame for a tab.
105
106TGedFrame* TEveGedEditor::CreateNameFrame(const TGWindow* parent, const char* /*tab_name*/)
107{
108 return new TEveGedNameFrame(parent);
109}
110
111////////////////////////////////////////////////////////////////////////////////
112/// Return eve-element if it is the model object.
113
115{
116 return (fModel == fObject) ? fElement : 0;
117}
118
119////////////////////////////////////////////////////////////////////////////////
120/// Show a TEveElement in editor.
121
123{
124 static const TEveException eh("TEveGedEditor::DisplayElement ");
125
126 fElement = re;
129}
130
131////////////////////////////////////////////////////////////////////////////////
132/// Show a TObject in editor.
133
135{
136 fElement = dynamic_cast<TEveElement*>(obj);
137 fObject = obj;
139}
140
141////////////////////////////////////////////////////////////////////////////////
142/// Set model object.
143
145{
146 fElement = dynamic_cast<TEveElement*>(obj);
147 fObject = obj;
148 TGedEditor::SetModel(pad, obj, event, force);
149}
150
151////////////////////////////////////////////////////////////////////////////////
152/// Virtual method from TGedEditor, called on every change.
153/// Propagates changes to TEveElement and TEveManager.
154
156{
157 if (fElement)
158 {
161 }
162
163 gEve->Redraw3D();
164}
165
166////////////////////////////////////////////////////////////////////////////////
167/// Static function to create a new extra editor.
168
170{
172 {
173 new TGMsgBox(gClient->GetDefaultRoot(), gEve->GetMainWindow(),
174 "Clutter warning",
175 "Maximum number of extra editors reached.",
177 }
178
179 if (obj)
180 {
181 TEveGedEditor *ed = new TEveGedEditor();
182 ed->DisplayObject(obj);
183 ed->SetWindowName(Form("GED %s", obj->GetName()));
184
185 fgExtraEditors->Add(ed);
186 }
187}
188
189////////////////////////////////////////////////////////////////////////////////
190/// Element was changed. Update editors showing it.
191
193{
194 TObject *eobj = el->GetEditorObject("TEveGedEditor::ElementChanged ");
196 while (lnk)
197 {
198 TEveGedEditor *ed = (TEveGedEditor*) lnk->GetObject();
199 if (ed->GetModel() == eobj)
200 ed->DisplayElement(el);
201 lnk = lnk->Next();
202 }
203}
204
205////////////////////////////////////////////////////////////////////////////////
206/// Element is being deleted. Close editors showing it.
207
209{
210 TObject *eobj = el->GetEditorObject("TEveGedEditor::ElementChanged ");
212 while (lnk)
213 {
214 TEveGedEditor *ed = (TEveGedEditor*) lnk->GetObject();
215 if (ed->GetModel() == eobj)
216 {
217 TObjLink *next = lnk->Next();
218 ed->DeleteWindow();
220 lnk = next;
221 }
222 else
223 {
224 lnk = lnk->Next();
225 }
226 }
227}
228
229////////////////////////////////////////////////////////////////////////////////
230/// Destroys all editors. Called from EVE termination.
231
233{
234 while ( ! fgExtraEditors->IsEmpty())
235 {
237 ed->DeleteWindow();
239 }
240}
241
242////////////////////////////////////////////////////////////////////////////////
243/// Return context menu object shared among eve-ged-editors.
244
246{
247 if (fgContextMenu == 0)
248 fgContextMenu = new TContextMenu("", "");
249 return fgContextMenu;
250}
251
252/** \class TEveGedNameFrame
253\ingroup TEve
254Specialization of TGedNameFrame used in EVE.
255It provides the ability to undock given editor for easier use.
256Support for that is also provided from the TEveManager.
257*/
258
260
261////////////////////////////////////////////////////////////////////////////////
262/// Constructor.
263
265 UInt_t options) :
266 TGedFrame(p, width, height, options),
267 fNCButton(0)
268{
270 fNCButton->SetTextColor(0x0020a0);
272 fNCButton->Connect("Clicked()", "TEveGedNameFrame", this, "SpawnEditorClone()");
273}
274
275////////////////////////////////////////////////////////////////////////////////
276/// Destructor.
277
279{
280}
281
282////////////////////////////////////////////////////////////////////////////////
283/// Set model object.
284
286{
287 if (obj)
288 {
289 fNCButton->SetText(Form("%s [%s]", obj->GetName(), obj->ClassName()));
292 }
293 else
294 {
295 fNCButton->SetText("No object selected.");
298 }
299}
300
301////////////////////////////////////////////////////////////////////////////////
302/// Create a new floating editor with current object.
303
305{
307}
308
309/** \class TEveGedNameTextButton
310\ingroup TEve
311Specialization of TGTextButton for EVE name frame.
312It opens a context-menu on right-click.
313*/
314
316
317////////////////////////////////////////////////////////////////////////////////
318/// Constructor.
319
321 TGTextButton(p, ""),
322 fFrame(p)
323{
324 gVirtualX->GrabButton(fId, kAnyButton, kAnyModifier,
326 kNone, kNone);
327}
328
329////////////////////////////////////////////////////////////////////////////////
330/// Destructor.
331
333{
334}
335
336////////////////////////////////////////////////////////////////////////////////
337/// Handle button.
338
340{
341 static const TEveException eh("TEveGedNameTextButton::HandleButton ");
342
343 if (fTip) fTip->Hide();
344 if (fState == kButtonDisabled) return kTRUE;
345
346 if (event->fCode == kButton3 && event->fType == kButtonPress)
347 {
349 TEveElement *el = eged->GetEveElement();
350 if (el)
352 el->GetObject(eh));
353 return 1;
354 }
355 else if (event->fCode == kButton1)
356 {
357 return TGTextButton::HandleButton(event);
358 }
359 else
360 {
361 return 0;
362 }
363}
@ kButton1Down
Definition: Buttons.h:17
@ kButtonPress
Definition: GuiTypes.h:59
const Mask_t kButtonPressMask
Definition: GuiTypes.h:160
const Mask_t kAnyModifier
Definition: GuiTypes.h:209
const Handle_t kNone
Definition: GuiTypes.h:87
const Mask_t kButtonReleaseMask
Definition: GuiTypes.h:161
@ kButton3
Definition: GuiTypes.h:213
@ kButton1
Definition: GuiTypes.h:213
@ kAnyButton
Definition: GuiTypes.h:213
int Int_t
Definition: RtypesCore.h:43
const Bool_t kFALSE
Definition: RtypesCore.h:90
R__EXTERN Int_t gDebug
Definition: RtypesCore.h:117
const Bool_t kTRUE
Definition: RtypesCore.h:89
#define ClassImp(name)
Definition: Rtypes.h:361
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
R__EXTERN TEveManager * gEve
Definition: TEveManager.h:243
@ kButtonDisabled
Definition: TGButton.h:56
#define gClient
Definition: TGClient.h:166
R__EXTERN TGDNDManager * gDNDManager
Definition: TGDNDManager.h:203
@ kLHintsNormal
Definition: TGLayout.h:39
@ kLHintsTop
Definition: TGLayout.h:34
@ kLHintsExpandX
Definition: TGLayout.h:37
@ kMBOk
Definition: TGMsgBox.h:44
@ kMBIconStop
Definition: TGMsgBox.h:33
char * Form(const char *fmt,...)
#define gVirtualX
Definition: TVirtualX.h:338
The Canvas class.
Definition: TCanvas.h:27
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition: TClass.h:80
void * New(ENewType defConstructor=kClassNew, Bool_t quiet=kFALSE) const
Return a pointer to a newly allocated object of this class.
Definition: TClass.cxx:4941
Long_t GetDataMemberOffset(const char *membername) const
return offset for member name.
Definition: TClass.cxx:3445
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
Definition: TClass.cxx:2948
virtual Bool_t IsEmpty() const
Definition: TCollection.h:186
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
Definition: TCollection.h:182
This class provides an interface to context sensitive popup menus.
Definition: TContextMenu.h:40
virtual void Popup(Int_t x, Int_t y, TObject *obj, TVirtualPad *c=nullptr, TVirtualPad *p=nullptr)
Popup context menu at given location in canvas c and pad p for selected object.
Base class for TEveUtil visualization elements, providing hierarchy management, rendering control and...
Definition: TEveElement.h:34
virtual TObject * GetEditorObject(const TEveException &eh) const
Definition: TEveElement.h:197
virtual void PropagateVizParamsToProjecteds()
Propagate visualization parameters to dependent elements.
virtual void ElementChanged(Bool_t update_scenes=kTRUE, Bool_t redraw=kFALSE)
Call this after an element has been changed so that the state can be propagated around the framework.
virtual TObject * GetObject(const TEveException &eh) const
Get a TObject associated with this render-element.
Exception class thrown by TEve classes and macros.
Definition: TEveUtil.h:102
Specialization of TGedEditor for proper update propagation to TEveManager.
Definition: TEveGedEditor.h:27
static Int_t fgMaxExtraEditors
Definition: TEveGedEditor.h:40
TEveElement * GetEveElement() const
Return eve-element if it is the model object.
TObject * fObject
Definition: TEveGedEditor.h:36
virtual void Update(TGedFrame *gframe=0)
Virtual method from TGedEditor, called on every change.
virtual void SetModel(TVirtualPad *pad, TObject *obj, Int_t event, Bool_t force=kFALSE)
Set model object.
static void ElementDeleted(TEveElement *el)
Element is being deleted. Close editors showing it.
void DisplayElement(TEveElement *re)
Show a TEveElement in editor.
TEveElement * fElement
Definition: TEveGedEditor.h:35
static TContextMenu * GetContextMenu()
Return context menu object shared among eve-ged-editors.
static TContextMenu * fgContextMenu
Definition: TEveGedEditor.h:43
static TList * fgExtraEditors
Definition: TEveGedEditor.h:41
virtual TGedFrame * CreateNameFrame(const TGWindow *parent, const char *tab_name)
Create name-frame for a tab.
static void DestroyEditors()
Destroys all editors. Called from EVE termination.
virtual void CloseWindow()
Called from window-manger close button.
TEveGedEditor(const TEveGedEditor &)
virtual ~TEveGedEditor()
Destructor.
void DisplayObject(TObject *obj)
Show a TObject in editor.
static void ElementChanged(TEveElement *el)
Element was changed. Update editors showing it.
static void SpawnNewEditor(TObject *obj)
Static function to create a new extra editor.
Specialization of TGedNameFrame used in EVE.
Definition: TEveGedEditor.h:78
void SpawnEditorClone()
Create a new floating editor with current object.
virtual void SetModel(TObject *obj)
Set model object.
TGTextButton * fNCButton
Definition: TEveGedEditor.h:84
virtual ~TEveGedNameFrame()
Destructor.
TEveGedNameFrame(const TEveGedNameFrame &)
Specialization of TGTextButton for EVE name frame.
virtual Bool_t HandleButton(Event_t *event)
Handle button.
TEveGedNameFrame * fFrame
virtual ~TEveGedNameTextButton()
Destructor.
TEveGedNameTextButton(const TEveGedNameTextButton &)
void Redraw3D(Bool_t resetCameras=kFALSE, Bool_t dropLogicals=kFALSE)
Definition: TEveManager.h:168
TGWindow * GetMainWindow() const
Get the main window, i.e. EVE-browser.
virtual void SetToolTipText(const char *text, Long_t delayms=400)
Set tool tip text associated with this button.
Definition: TGButton.cxx:397
EButtonState fState
Definition: TGButton.h:75
virtual void SetEnabled(Bool_t e=kTRUE)
Set enabled or disabled state of button.
Definition: TGButton.cxx:411
TGToolTip * fTip
Definition: TGButton.h:79
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event.
Definition: TGButton.cxx:282
const TGWindow * GetRoot() const
Returns current root (i.e.
Definition: TGClient.cxx:224
void SetRoot(TGWindow *root=0)
Sets the current root (i.e.
Definition: TGClient.cxx:244
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1101
virtual void RemoveAll()
Remove all frames from composite frame.
Definition: TGFrame.cxx:1115
void SetMainFrame(TGFrame *main)
Definition: TGDNDManager.h:164
TGFrame * GetMainFrame() const
Definition: TGDNDManager.h:163
virtual void DeleteWindow()
Delete window.
Definition: TGFrame.cxx:260
void SetWindowName(const char *name=0)
Set window name. This is typically done via the window manager.
Definition: TGFrame.cxx:1748
TGClient * fClient
Definition: TGObject.h:37
Handle_t fId
Definition: TGObject.h:36
virtual void SetText(TGHotString *new_label)
Set new button text.
Definition: TGButton.cxx:596
virtual void SetTextColor(Pixel_t color, Bool_t global=kFALSE)
Changes text color.
Definition: TGButton.cxx:870
void Hide()
Hide tool tip window.
Definition: TGToolTip.cxx:247
TMap fFrameMap
Definition: TGedEditor.h:48
TVirtualPad * fPad
Definition: TGedEditor.h:60
virtual void SetModel(TVirtualPad *pad, TObject *obj, Int_t event, Bool_t force=kFALSE)
Activate object editors according to the selected object.
Definition: TGedEditor.cxx:351
TGCompositeFrame * fTabContainer
Definition: TGedEditor.h:57
TObject * fModel
Definition: TGedEditor.h:59
static void SetFrameCreator(TGedEditor *e)
Set the TGedEditor that currently creates TGedFrames.
Definition: TGedEditor.cxx:95
virtual TObject * GetModel() const
Definition: TGedEditor.h:90
virtual void SetGedEditor(TGedEditor *ed)
Definition: TGedFrame.h:86
TGedEditor * fGedEditor
Definition: TGedFrame.h:54
void SetModelClass(TClass *mcl)
Definition: TGedFrame.h:84
TGedEditor * GetGedEditor()
Definition: TGedFrame.h:77
A doubly linked list.
Definition: TList.h:44
virtual void Add(TObject *obj)
Definition: TList.h:87
virtual TObject * Remove(TObject *obj)
Remove object from the list.
Definition: TList.cxx:821
virtual TObjLink * FirstLink() const
Definition: TList.h:108
virtual TObject * First() const
Return the first object in the list. Returns 0 when list is empty.
Definition: TList.cxx:658
void Add(TObject *obj)
This function may not be used (but we need to provide it since it is a pure virtual in TCollection).
Definition: TMap.cxx:54
Mother of all ROOT objects.
Definition: TObject.h:37
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:357
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:128
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:877
virtual const char * GetTitle() const
Returns title of object.
Definition: TObject.cxx:401
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition: TObject.cxx:865
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot.
Definition: TQObject.cxx:866
virtual void RemoveFirst()
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition: TVirtualPad.h:51
EGEventType fType
Definition: GuiTypes.h:174
Int_t fXRoot
Definition: GuiTypes.h:178
Int_t fYRoot
Definition: GuiTypes.h:178
UInt_t fCode
Definition: GuiTypes.h:179