Logo ROOT   6.16/01
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
25/** \class TEveGedEditor
26\ingroup TEve
27Specialization of TGedEditor for proper update propagation to TEveManager.
28*/
29
31
34
36
37////////////////////////////////////////////////////////////////////////////////
38/// Constructor.
39
41 TGedEditor(canvas, width, height),
42 fElement (0),
43 fObject (0)
44{
45 // Remove old name-frame -- it is created in TGedEditor constructor
46 // so virtuals are not active yet.
49 nf->SetGedEditor(this);
50 nf->SetModelClass(0);
52
53 // Fix priority for TAttMarkerEditor.
54 TClass* amClass = TClass::GetClass("TAttMarker");
55 TClass* edClass = TClass::GetClass("TAttMarkerEditor");
56 TGWindow *exroot = (TGWindow*) fClient->GetRoot();
58 SetFrameCreator(this);
59 TGedFrame *frame = reinterpret_cast<TGedFrame*>(edClass->New());
60 frame->SetModelClass(amClass);
61 {
62 Int_t off = edClass->GetDataMemberOffset("fPriority");
63 if (off == 0)
64 Warning("TEveGedEditor::TEveGedEditor", "Can't fix priority for TAttMarkerEditor.\n");
65 else
66 * (Int_t*) (((char*)frame) + off) = 1;
67 }
69 fClient->SetRoot(exroot);
70 fFrameMap.Add(amClass, frame);
71}
72
73////////////////////////////////////////////////////////////////////////////////
74/// Destructor.
75
77{
78 if (gDebug > 0)
79 Info("TEveGedEditor::~TEveGedEditor", "%p going down.", this);
80}
81
82////////////////////////////////////////////////////////////////////////////////
83/// Called from window-manger close button.
84/// Unregister from global list and delete the window.
85
87{
88 if (gDebug > 0)
89 Info("TEveGedEditor::CloseWindow", "%p closing.", this);
90
92
94
95 if (gDNDManager) {
96 if (gDNDManager->GetMainFrame() == this)
98 }
100}
101
102////////////////////////////////////////////////////////////////////////////////
103/// Create name-frame for a tab.
104
105TGedFrame* TEveGedEditor::CreateNameFrame(const TGWindow* parent, const char* /*tab_name*/)
106{
107 return new TEveGedNameFrame(parent);
108}
109
110////////////////////////////////////////////////////////////////////////////////
111/// Return eve-element if it is the model object.
112
114{
115 return (fModel == fObject) ? fElement : 0;
116}
117
118////////////////////////////////////////////////////////////////////////////////
119/// Show a TEveElement in editor.
120
122{
123 static const TEveException eh("TEveGedEditor::DisplayElement ");
124
125 fElement = re;
128}
129
130////////////////////////////////////////////////////////////////////////////////
131/// Show a TObject in editor.
132
134{
135 fElement = dynamic_cast<TEveElement*>(obj);
136 fObject = obj;
138}
139
140////////////////////////////////////////////////////////////////////////////////
141/// Set model object.
142
144{
145 fElement = dynamic_cast<TEveElement*>(obj);
146 fObject = obj;
147 TGedEditor::SetModel(pad, obj, event, force);
148}
149
150////////////////////////////////////////////////////////////////////////////////
151/// Virtual method from TGedEditor, called on every change.
152/// Propagates changes to TEveElement and TEveManager.
153
155{
156 if (fElement)
157 {
160 }
161
162 gEve->Redraw3D();
163}
164
165////////////////////////////////////////////////////////////////////////////////
166/// Static function to create a new extra editor.
167
169{
171 {
172 new TGMsgBox(gClient->GetDefaultRoot(), gEve->GetMainWindow(),
173 "Clutter warning",
174 "Maximum number of extra editors reached.",
176 }
177
178 if (obj)
179 {
180 TEveGedEditor *ed = new TEveGedEditor();
181 ed->DisplayObject(obj);
182 ed->SetWindowName(Form("GED %s", obj->GetName()));
183
184 fgExtraEditors->Add(ed);
185 }
186}
187
188////////////////////////////////////////////////////////////////////////////////
189/// Element was changed. Update editors showing it.
190
192{
193 TObject *eobj = el->GetEditorObject("TEveGedEditor::ElementChanged ");
195 while (lnk)
196 {
197 TEveGedEditor *ed = (TEveGedEditor*) lnk->GetObject();
198 if (ed->GetModel() == eobj)
199 ed->DisplayElement(el);
200 lnk = lnk->Next();
201 }
202}
203
204////////////////////////////////////////////////////////////////////////////////
205/// Element is being deleted. Close editors showing it.
206
208{
209 TObject *eobj = el->GetEditorObject("TEveGedEditor::ElementChanged ");
211 while (lnk)
212 {
213 TEveGedEditor *ed = (TEveGedEditor*) lnk->GetObject();
214 if (ed->GetModel() == eobj)
215 {
216 TObjLink *next = lnk->Next();
217 ed->DeleteWindow();
219 lnk = next;
220 }
221 else
222 {
223 lnk = lnk->Next();
224 }
225 }
226}
227
228////////////////////////////////////////////////////////////////////////////////
229/// Destroys all editors. Called from EVE termination.
230
232{
233 while ( ! fgExtraEditors->IsEmpty())
234 {
236 ed->DeleteWindow();
238 }
239}
240
241////////////////////////////////////////////////////////////////////////////////
242/// Return context menu object shared among eve-ged-editors.
243
245{
246 if (fgContextMenu == 0)
247 fgContextMenu = new TContextMenu("", "");
248 return fgContextMenu;
249}
250
251/** \class TEveGedNameFrame
252\ingroup TEve
253Specialization of TGedNameFrame used in EVE.
254It provides the ability to undock given editor for easier use.
255Support for that is also provided from the TEveManager.
256*/
257
259
260////////////////////////////////////////////////////////////////////////////////
261/// Constructor.
262
264 UInt_t options) :
265 TGedFrame(p, width, height, options),
266 fNCButton(0)
267{
269 fNCButton->SetTextColor(0x0020a0);
271 fNCButton->Connect("Clicked()", "TEveGedNameFrame", this, "SpawnEditorClone()");
272}
273
274////////////////////////////////////////////////////////////////////////////////
275/// Destructor.
276
278{
279}
280
281////////////////////////////////////////////////////////////////////////////////
282/// Set model object.
283
285{
286 if (obj)
287 {
288 fNCButton->SetText(Form("%s [%s]", obj->GetName(), obj->ClassName()));
291 }
292 else
293 {
294 fNCButton->SetText("No object selected.");
297 }
298}
299
300////////////////////////////////////////////////////////////////////////////////
301/// Create a new floating editor with current object.
302
304{
306}
307
308/** \class TEveGedNameTextButton
309\ingroup TEve
310Specialization of TGTextButton for EVE name frame.
311It opens a context-menu on right-click.
312*/
313
315
316////////////////////////////////////////////////////////////////////////////////
317/// Constructor.
318
320 TGTextButton(p, ""),
321 fFrame(p)
322{
323 gVirtualX->GrabButton(fId, kAnyButton, kAnyModifier,
325 kNone, kNone);
326}
327
328////////////////////////////////////////////////////////////////////////////////
329/// Destructor.
330
332{
333}
334
335////////////////////////////////////////////////////////////////////////////////
336/// Handle button.
337
339{
340 static const TEveException eh("TEveGedNameTextButton::HandleButton ");
341
342 if (fTip) fTip->Hide();
343 if (fState == kButtonDisabled) return kTRUE;
344
345 if (event->fCode == kButton3 && event->fType == kButtonPress)
346 {
348 TEveElement *el = eged->GetEveElement();
349 if (el)
351 el->GetObject(eh));
352 return 1;
353 }
354 else if (event->fCode == kButton1)
355 {
356 return TGTextButton::HandleButton(event);
357 }
358 else
359 {
360 return 0;
361 }
362}
@ 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:41
unsigned int UInt_t
Definition: RtypesCore.h:42
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kTRUE
Definition: RtypesCore.h:87
#define ClassImp(name)
Definition: Rtypes.h:363
R__EXTERN Int_t gDebug
Definition: Rtypes.h:90
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:345
The Canvas class.
Definition: TCanvas.h:31
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:75
void * New(ENewType defConstructor=kClassNew, Bool_t quiet=kFALSE) const
Return a pointer to a newly allocated object of this class.
Definition: TClass.cxx:4824
Long_t GetDataMemberOffset(const char *membername) const
return offset for member name.
Definition: TClass.cxx:3306
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:2885
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=0, TVirtualPad *p=0)
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:103
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:395
EButtonState fState
Definition: TGButton.h:75
virtual void SetEnabled(Bool_t e=kTRUE)
Set enabled or disabled state of button.
Definition: TGButton.cxx:409
TGToolTip * fTip
Definition: TGButton.h:79
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event.
Definition: TGButton.cxx:280
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:1099
virtual void RemoveAll()
Remove all frames from composite frame.
Definition: TGFrame.cxx:1113
void SetMainFrame(TGFrame *main)
Definition: TGDNDManager.h:164
TGFrame * GetMainFrame() const
Definition: TGDNDManager.h:163
virtual void DeleteWindow()
Delete window.
Definition: TGFrame.cxx:258
void SetWindowName(const char *name=0)
Set window name. This is typically done via the window manager.
Definition: TGFrame.cxx:1746
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:594
virtual void SetTextColor(Pixel_t color, Bool_t global=kFALSE)
Changes text color.
Definition: TGButton.cxx:868
void Hide()
Hide tool tip window.
Definition: TGToolTip.cxx:246
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:349
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:93
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:818
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:655
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:53
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:866
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:854
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:867
virtual void RemoveFirst()
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition: TVirtualPad.h:50
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