Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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 "TGToolTip.h"
17#include "TGDNDManager.h"
18#include "TGMsgBox.h"
19
20#include "TClass.h"
21#include "TContextMenu.h"
22#include "TVirtualX.h"
23
24/** \class TEveGedEditor
25\ingroup TEve
26Specialization of TGedEditor for proper update propagation to TEveManager.
27*/
28
30
33
35
36////////////////////////////////////////////////////////////////////////////////
37/// Constructor.
38
40 TGedEditor(canvas, width, height),
41 fElement (0),
42 fObject (0)
43{
44 // Remove old name-frame -- it is created in TGedEditor constructor
45 // so virtuals are not active yet.
48 nf->SetGedEditor(this);
49 nf->SetModelClass(0);
51
52 // Fix priority for TAttMarkerEditor.
53 TClass* amClass = TClass::GetClass("TAttMarker");
54 TClass* edClass = TClass::GetClass("TAttMarkerEditor");
55 TGWindow *exroot = (TGWindow*) fClient->GetRoot();
57 SetFrameCreator(this);
58 TGedFrame *frame = reinterpret_cast<TGedFrame*>(edClass->New());
59 frame->SetModelClass(amClass);
60 {
61 Int_t off = edClass->GetDataMemberOffset("fPriority");
62 if (off == 0)
63 Warning("TEveGedEditor::TEveGedEditor", "Can't fix priority for TAttMarkerEditor.\n");
64 else
65 * (Int_t*) (((char*)frame) + off) = 1;
66 }
68 fClient->SetRoot(exroot);
69 fFrameMap.Add(amClass, frame);
70}
71
72////////////////////////////////////////////////////////////////////////////////
73/// Destructor.
74
76{
77 if (gDebug > 0)
78 Info("TEveGedEditor::~TEveGedEditor", "%p going down.", this);
79}
80
81////////////////////////////////////////////////////////////////////////////////
82/// Called from window-manger close button.
83/// Unregister from global list and delete the window.
84
86{
87 if (gDebug > 0)
88 Info("TEveGedEditor::CloseWindow", "%p closing.", this);
89
91
93
94 if (gDNDManager) {
95 if (gDNDManager->GetMainFrame() == this)
97 }
99}
100
101////////////////////////////////////////////////////////////////////////////////
102/// Create name-frame for a tab.
103
104TGedFrame* TEveGedEditor::CreateNameFrame(const TGWindow* parent, const char* /*tab_name*/)
105{
106 return new TEveGedNameFrame(parent);
107}
108
109////////////////////////////////////////////////////////////////////////////////
110/// Return eve-element if it is the model object.
111
113{
114 return (fModel == fObject) ? fElement : 0;
115}
116
117////////////////////////////////////////////////////////////////////////////////
118/// Show a TEveElement in editor.
119
121{
122 static const TEveException eh("TEveGedEditor::DisplayElement ");
123
124 fElement = re;
127}
128
129////////////////////////////////////////////////////////////////////////////////
130/// Show a TObject in editor.
131
133{
134 fElement = dynamic_cast<TEveElement*>(obj);
135 fObject = obj;
137}
138
139////////////////////////////////////////////////////////////////////////////////
140/// Set model object.
141
143{
144 fElement = dynamic_cast<TEveElement*>(obj);
145 fObject = obj;
146 TGedEditor::SetModel(pad, obj, event, force);
147}
148
149////////////////////////////////////////////////////////////////////////////////
150/// Virtual method from TGedEditor, called on every change.
151/// Propagates changes to TEveElement and TEveManager.
152
154{
155 if (fElement)
156 {
159 }
160
161 gEve->Redraw3D();
162}
163
164////////////////////////////////////////////////////////////////////////////////
165/// Static function to create a new extra editor.
166
168{
170 {
171 new TGMsgBox(gClient->GetDefaultRoot(), gEve->GetMainWindow(),
172 "Clutter warning",
173 "Maximum number of extra editors reached.",
175 }
176
177 if (obj)
178 {
179 TEveGedEditor *ed = new TEveGedEditor();
180 ed->DisplayObject(obj);
181 ed->SetWindowName(Form("GED %s", obj->GetName()));
182
183 fgExtraEditors->Add(ed);
184 }
185}
186
187////////////////////////////////////////////////////////////////////////////////
188/// Element was changed. Update editors showing it.
189
191{
192 TObject *eobj = el->GetEditorObject("TEveGedEditor::ElementChanged ");
194 while (lnk)
195 {
196 TEveGedEditor *ed = (TEveGedEditor*) lnk->GetObject();
197 if (ed->GetModel() == eobj)
198 ed->DisplayElement(el);
199 lnk = lnk->Next();
200 }
201}
202
203////////////////////////////////////////////////////////////////////////////////
204/// Element is being deleted. Close editors showing it.
205
207{
208 TObject *eobj = el->GetEditorObject("TEveGedEditor::ElementChanged ");
210 while (lnk)
211 {
212 TEveGedEditor *ed = (TEveGedEditor*) lnk->GetObject();
213 if (ed->GetModel() == eobj)
214 {
215 TObjLink *next = lnk->Next();
216 ed->DeleteWindow();
218 lnk = next;
219 }
220 else
221 {
222 lnk = lnk->Next();
223 }
224 }
225}
226
227////////////////////////////////////////////////////////////////////////////////
228/// Destroys all editors. Called from EVE termination.
229
231{
232 while ( ! fgExtraEditors->IsEmpty())
233 {
235 ed->DeleteWindow();
237 }
238}
239
240////////////////////////////////////////////////////////////////////////////////
241/// Return context menu object shared among eve-ged-editors.
242
244{
245 if (fgContextMenu == 0)
246 fgContextMenu = new TContextMenu("", "");
247 return fgContextMenu;
248}
249
250/** \class TEveGedNameFrame
251\ingroup TEve
252Specialization of TGedNameFrame used in EVE.
253It provides the ability to undock given editor for easier use.
254Support for that is also provided from the TEveManager.
255*/
256
258
259////////////////////////////////////////////////////////////////////////////////
260/// Constructor.
261
263 UInt_t options) :
264 TGedFrame(p, width, height, options),
265 fNCButton(0)
266{
268 fNCButton->SetTextColor(0x0020a0);
270 fNCButton->Connect("Clicked()", "TEveGedNameFrame", this, "SpawnEditorClone()");
271}
272
273////////////////////////////////////////////////////////////////////////////////
274/// Destructor.
275
277{
278}
279
280////////////////////////////////////////////////////////////////////////////////
281/// Set model object.
282
284{
285 if (obj)
286 {
287 fNCButton->SetText(Form("%s [%s]", obj->GetName(), obj->ClassName()));
290 }
291 else
292 {
293 fNCButton->SetText("No object selected.");
296 }
297}
298
299////////////////////////////////////////////////////////////////////////////////
300/// Create a new floating editor with current object.
301
303{
305}
306
307/** \class TEveGedNameTextButton
308\ingroup TEve
309Specialization of TGTextButton for EVE name frame.
310It opens a context-menu on right-click.
311*/
312
314
315////////////////////////////////////////////////////////////////////////////////
316/// Constructor.
317
319 TGTextButton(p, ""),
320 fFrame(p)
321{
322 gVirtualX->GrabButton(fId, kAnyButton, kAnyModifier,
324 kNone, kNone);
325}
326
327////////////////////////////////////////////////////////////////////////////////
328/// Destructor.
329
331{
332}
333
334////////////////////////////////////////////////////////////////////////////////
335/// Handle button.
336
338{
339 static const TEveException eh("TEveGedNameTextButton::HandleButton ");
340
341 if (fTip) fTip->Hide();
342 if (fState == kButtonDisabled) return kTRUE;
343
344 if (event->fCode == kButton3 && event->fType == kButtonPress)
345 {
347 TEveElement *el = eged->GetEveElement();
348 if (el)
350 el->GetObject(eh));
351 return 1;
352 }
353 else if (event->fCode == kButton1)
354 {
355 return TGTextButton::HandleButton(event);
356 }
357 else
358 {
359 return 0;
360 }
361}
@ kButton1Down
Definition Buttons.h:17
@ kButtonPress
Definition GuiTypes.h:60
const Mask_t kButtonPressMask
Definition GuiTypes.h:161
const Mask_t kAnyModifier
Definition GuiTypes.h:210
const Handle_t kNone
Definition GuiTypes.h:88
const Mask_t kButtonReleaseMask
Definition GuiTypes.h:162
@ kButton3
Definition GuiTypes.h:214
@ kButton1
Definition GuiTypes.h:214
@ kAnyButton
Definition GuiTypes.h:214
int Int_t
Definition RtypesCore.h:45
const Bool_t kFALSE
Definition RtypesCore.h:92
const Bool_t kTRUE
Definition RtypesCore.h:91
#define ClassImp(name)
Definition Rtypes.h:364
include TDocParser_001 C image html pict1_TDocParser_001 png width
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
Definition TError.cxx:220
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition TError.cxx:231
R__EXTERN TEveManager * gEve
@ kButtonDisabled
Definition TGButton.h:56
#define gClient
Definition TGClient.h:166
R__EXTERN TGDNDManager * gDNDManager
@ kLHintsNormal
Definition TGLayout.h:39
@ kLHintsTop
Definition TGLayout.h:34
@ kLHintsExpandX
Definition TGLayout.h:37
@ kMBOk
Definition TGMsgBox.h:40
@ kMBIconStop
Definition TGMsgBox.h:29
Int_t gDebug
Definition TROOT.cxx:590
char * Form(const char *fmt,...)
#define gVirtualX
Definition TVirtualX.h:338
The Canvas class.
Definition TCanvas.h:23
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:4955
Long_t GetDataMemberOffset(const char *membername) const
return offset for member name.
Definition TClass.cxx:3454
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:2957
virtual Bool_t IsEmpty() const
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
This class provides an interface to context sensitive popup menus.
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:36
virtual TObject * GetEditorObject(const TEveException &eh) const
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.
static Int_t fgMaxExtraEditors
TEveElement * GetEveElement() const
Return eve-element if it is the model object.
TObject * fObject
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
static TContextMenu * GetContextMenu()
Return context menu object shared among eve-ged-editors.
static TContextMenu * fgContextMenu
static TList * fgExtraEditors
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.
void SpawnEditorClone()
Create a new floating editor with current object.
virtual void SetModel(TObject *obj)
Set model object.
TGTextButton * fNCButton
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)
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:398
EButtonState fState
Definition TGButton.h:75
virtual void SetEnabled(Bool_t e=kTRUE)
Set enabled or disabled state of button.
Definition TGButton.cxx:412
TGToolTip * fTip
Definition TGButton.h:79
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event.
Definition TGButton.cxx:283
const TGWindow * GetRoot() const
Returns current root (i.e.
Definition TGClient.cxx:223
void SetRoot(TGWindow *root=nullptr)
Sets the current root (i.e.
Definition TGClient.cxx:243
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1102
virtual void RemoveAll()
Remove all frames from composite frame.
Definition TGFrame.cxx:1116
void SetMainFrame(TGFrame *main)
TGFrame * GetMainFrame() const
virtual void DeleteWindow()
Delete window.
Definition TGFrame.cxx:261
void SetWindowName(const char *name=0)
Set window name. This is typically done via the window manager.
Definition TGFrame.cxx:1749
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:597
virtual void SetTextColor(Pixel_t color, Bool_t global=kFALSE)
Changes text color.
Definition TGButton.cxx:871
void Hide()
Hide tool tip window.
TMap fFrameMap
Definition TGedEditor.h:47
TVirtualPad * fPad
Definition TGedEditor.h:59
virtual void SetModel(TVirtualPad *pad, TObject *obj, Int_t event, Bool_t force=kFALSE)
Activate object editors according to the selected object.
TGCompositeFrame * fTabContainer
Definition TGedEditor.h:56
TObject * fModel
Definition TGedEditor.h:58
static void SetFrameCreator(TGedEditor *e)
Set the TGedEditor that currently creates TGedFrames.
virtual TObject * GetModel() const
Definition TGedEditor.h:89
virtual void SetGedEditor(TGedEditor *ed)
Definition TGedFrame.h:87
TGedEditor * fGedEditor
Definition TGedFrame.h:55
void SetModelClass(TClass *mcl)
Definition TGedFrame.h:85
TGedEditor * GetGedEditor()
Definition TGedFrame.h:78
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:822
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:659
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:359
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition TObject.cxx:130
virtual const char * GetTitle() const
Returns title of object.
Definition TObject.cxx:403
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
Event structure.
Definition GuiTypes.h:174
EGEventType fType
of event (see EGEventType)
Definition GuiTypes.h:175
Int_t fXRoot
Definition GuiTypes.h:179
Int_t fYRoot
coordinates relative to root
Definition GuiTypes.h:179
UInt_t fCode
key or button code
Definition GuiTypes.h:180