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
29
32
34
35////////////////////////////////////////////////////////////////////////////////
36/// Constructor.
37
39 TGedEditor(canvas, width, height),
40 fElement (nullptr),
41 fObject (nullptr)
42{
43 // Remove old name-frame -- it is created in TGedEditor constructor
44 // so virtuals are not active yet.
47 nf->SetGedEditor(this);
48 nf->SetModelClass(nullptr);
50
51 // Fix priority for TAttMarkerEditor.
52 TClass* amClass = TClass::GetClass("TAttMarker");
53 TClass* edClass = TClass::GetClass("TAttMarkerEditor");
56 SetFrameCreator(this);
57 TGedFrame *frame = reinterpret_cast<TGedFrame*>(edClass->New());
58 frame->SetModelClass(amClass);
59 {
60 Int_t off = edClass->GetDataMemberOffset("fPriority");
61 if (off == 0)
62 Warning("TEveGedEditor::TEveGedEditor", "Can't fix priority for TAttMarkerEditor.\n");
63 else
64 * (Int_t*) (((char*)frame) + off) = 1;
65 }
66 SetFrameCreator(nullptr);
68 fFrameMap.Add(amClass, frame);
69}
70
71////////////////////////////////////////////////////////////////////////////////
72/// Destructor.
73
75{
76 if (gDebug > 0)
77 Info("TEveGedEditor::~TEveGedEditor", "%p going down.", this);
78}
79
80////////////////////////////////////////////////////////////////////////////////
81/// Called from window-manger close button.
82/// Unregister from global list and delete the window.
83
85{
86 if (gDebug > 0)
87 Info("TEveGedEditor::CloseWindow", "%p closing.", this);
88
89 fgExtraEditors->Remove(this);
90
91 DisplayElement(nullptr);
92
93 if (gDNDManager) {
94 if (gDNDManager->GetMainFrame() == this)
95 gDNDManager->SetMainFrame(nullptr);
96 }
98}
99
100////////////////////////////////////////////////////////////////////////////////
101/// Create name-frame for a tab.
102
103TGedFrame* TEveGedEditor::CreateNameFrame(const TGWindow* parent, const char* /*tab_name*/)
104{
105 return new TEveGedNameFrame(parent);
106}
107
108////////////////////////////////////////////////////////////////////////////////
109/// Return eve-element if it is the model object.
110
112{
113 return (fModel == fObject) ? fElement : nullptr;
114}
115
116////////////////////////////////////////////////////////////////////////////////
117/// Show a TEveElement in editor.
118
120{
121 static const TEveException eh("TEveGedEditor::DisplayElement ");
122
123 fElement = re;
126}
127
128////////////////////////////////////////////////////////////////////////////////
129/// Show a TObject in editor.
130
132{
133 fElement = dynamic_cast<TEveElement*>(obj);
134 fObject = obj;
136}
137
138////////////////////////////////////////////////////////////////////////////////
139/// Set model object.
140
142{
143 fElement = dynamic_cast<TEveElement*>(obj);
144 fObject = obj;
145 TGedEditor::SetModel(pad, obj, event, force);
146}
147
148////////////////////////////////////////////////////////////////////////////////
149/// Virtual method from TGedEditor, called on every change.
150/// Propagates changes to TEveElement and TEveManager.
151
153{
154 if (fElement)
155 {
158 }
159
160 gEve->Redraw3D();
161}
162
163////////////////////////////////////////////////////////////////////////////////
164/// Static function to create a new extra editor.
165
167{
168 if (fgExtraEditors->GetSize() >= fgMaxExtraEditors)
169 {
170 new TGMsgBox(gClient->GetDefaultRoot(), gEve->GetMainWindow(),
171 "Clutter warning",
172 "Maximum number of extra editors reached.",
174 }
175
176 if (obj)
177 {
179 ed->DisplayObject(obj);
180 ed->SetWindowName(Form("GED %s", obj->GetName()));
181
182 fgExtraEditors->Add(ed);
183 }
184}
185
186////////////////////////////////////////////////////////////////////////////////
187/// Element was changed. Update editors showing it.
188
190{
191 TObject *eobj = el->GetEditorObject("TEveGedEditor::ElementChanged ");
192 TObjLink *lnk = fgExtraEditors->FirstLink();
193 while (lnk)
194 {
195 TEveGedEditor *ed = (TEveGedEditor*) lnk->GetObject();
196 if (ed->GetModel() == eobj)
197 ed->DisplayElement(el);
198 lnk = lnk->Next();
199 }
200}
201
202////////////////////////////////////////////////////////////////////////////////
203/// Element is being deleted. Close editors showing it.
204
206{
207 TObject *eobj = el->GetEditorObject("TEveGedEditor::ElementChanged ");
208 TObjLink *lnk = fgExtraEditors->FirstLink();
209 while (lnk)
210 {
211 TEveGedEditor *ed = (TEveGedEditor*) lnk->GetObject();
212 if (ed->GetModel() == eobj)
213 {
214 TObjLink *next = lnk->Next();
215 ed->DeleteWindow();
216 fgExtraEditors->Remove(lnk);
217 lnk = next;
218 }
219 else
220 {
221 lnk = lnk->Next();
222 }
223 }
224}
225
226////////////////////////////////////////////////////////////////////////////////
227/// Destroys all editors. Called from EVE termination.
228
230{
231 while ( ! fgExtraEditors->IsEmpty())
232 {
234 ed->DeleteWindow();
235 fgExtraEditors->RemoveFirst();
236 }
237}
238
239////////////////////////////////////////////////////////////////////////////////
240/// Return context menu object shared among eve-ged-editors.
241
243{
244 if (fgContextMenu == nullptr)
245 fgContextMenu = new TContextMenu("", "");
246 return fgContextMenu;
247}
248
249/** \class TEveGedNameFrame
250\ingroup TEve
251Specialization of TGedNameFrame used in EVE.
252It provides the ability to undock given editor for easier use.
253Support for that is also provided from the TEveManager.
254*/
255
256
257////////////////////////////////////////////////////////////////////////////////
258/// Constructor.
259
261 UInt_t options) :
262 TGedFrame(p, width, height, options),
263 fNCButton(nullptr)
264{
266 fNCButton->SetTextColor(0x0020a0);
268 fNCButton->Connect("Clicked()", "TEveGedNameFrame", this, "SpawnEditorClone()");
269}
270
271////////////////////////////////////////////////////////////////////////////////
272/// Destructor.
273
277
278////////////////////////////////////////////////////////////////////////////////
279/// Set model object.
280
282{
283 if (obj)
284 {
285 fNCButton->SetText(Form("%s [%s]", obj->GetName(), obj->ClassName()));
288 }
289 else
290 {
291 fNCButton->SetText("No object selected.");
292 fNCButton->SetToolTipText(nullptr);
294 }
295}
296
297////////////////////////////////////////////////////////////////////////////////
298/// Create a new floating editor with current object.
299
304
305/** \class TEveGedNameTextButton
306\ingroup TEve
307Specialization of TGTextButton for EVE name frame.
308It opens a context-menu on right-click.
309*/
310
311
312////////////////////////////////////////////////////////////////////////////////
313/// Constructor.
314
323
324////////////////////////////////////////////////////////////////////////////////
325/// Destructor.
326
330
331////////////////////////////////////////////////////////////////////////////////
332/// Handle button.
333
335{
336 static const TEveException eh("TEveGedNameTextButton::HandleButton ");
337
338 if (fTip) fTip->Hide();
339 if (fState == kButtonDisabled) return kTRUE;
340
341 if (event->fCode == kButton3 && event->fType == kButtonPress)
342 {
344 TEveElement *el = eged->GetEveElement();
345 if (el)
346 TEveGedEditor::GetContextMenu()->Popup(event->fXRoot, event->fYRoot,
347 el->GetObject(eh));
348 return true;
349 }
350 else if (event->fCode == kButton1)
351 {
352 return TGTextButton::HandleButton(event);
353 }
354 else
355 {
356 return false;
357 }
358}
@ 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
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
Definition TError.cxx:241
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition TError.cxx:252
R__EXTERN TEveManager * gEve
@ kButtonDisabled
Definition TGButton.h:56
#define gClient
Definition TGClient.h:157
R__EXTERN TGDNDManager * gDNDManager
@ kLHintsNormal
Definition TGLayout.h:32
@ kLHintsTop
Definition TGLayout.h:27
@ kLHintsExpandX
Definition TGLayout.h:30
@ kMBOk
Definition TGMsgBox.h:33
@ kMBIconStop
Definition TGMsgBox.h:22
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t width
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
Int_t gDebug
Global variable setting the debug level. Set to 0 to disable, increase it in steps of 1 to increase t...
Definition TROOT.cxx:627
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2495
#define gVirtualX
Definition TVirtualX.h:337
The Canvas class.
Definition TCanvas.h:23
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:84
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:2973
This class provides an interface to context sensitive popup menus.
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.
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
TGedFrame * CreateNameFrame(const TGWindow *parent, const char *tab_name) override
Create name-frame for a tab.
TEveElement * GetEveElement() const
Return eve-element if it is the model object.
TObject * fObject
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
void CloseWindow() override
Called from window-manger close button.
void Update(TGedFrame *gframe=nullptr) override
Virtual method from TGedEditor, called on every change.
void SetModel(TVirtualPad *pad, TObject *obj, Int_t event, Bool_t force=kFALSE) override
Set model object.
static void DestroyEditors()
Destroys all editors. Called from EVE termination.
TEveGedEditor(const TEveGedEditor &)
void DisplayObject(TObject *obj)
Show a TObject in editor.
static void ElementChanged(TEveElement *el)
Element was changed. Update editors showing it.
~TEveGedEditor() override
Destructor.
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.
void SetModel(TObject *obj) override
Set model object.
TGTextButton * fNCButton
~TEveGedNameFrame() override
Destructor.
TEveGedNameFrame(const TEveGedNameFrame &)
Specialization of TGTextButton for EVE name frame.
Bool_t HandleButton(Event_t *event) override
Handle button.
~TEveGedNameTextButton() override
Destructor.
TEveGedNameFrame * fFrame
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:439
Bool_t HandleButton(Event_t *event) override
Handle mouse button event.
Definition TGButton.cxx:324
EButtonState fState
button state
Definition TGButton.h:75
virtual void SetEnabled(Bool_t e=kTRUE)
Set enabled or disabled state of button.
Definition TGButton.cxx:453
TGToolTip * fTip
tool tip associated with button
Definition TGButton.h:79
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=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1109
virtual void RemoveAll()
Remove all frames from composite frame.
Definition TGFrame.cxx:1123
void SetMainFrame(TGFrame *main)
TGFrame * GetMainFrame() const
virtual void DeleteWindow()
Delete window.
Definition TGFrame.cxx:268
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
TGClient * fClient
Connection to display server.
Definition TGObject.h:25
Handle_t fId
X11/Win32 Window identifier.
Definition TGObject.h:24
Yield an action as soon as it is clicked.
Definition TGButton.h:142
virtual void SetText(TGHotString *new_label)
Set new button text.
Definition TGButton.cxx:638
virtual void SetTextColor(Pixel_t color, Bool_t global=kFALSE)
Changes text color.
Definition TGButton.cxx:912
void Hide()
Hide tool tip window.
ROOT GUI Window base class.
Definition TGWindow.h:23
TMap fFrameMap
global map of available frames
Definition TGedEditor.h:37
TVirtualPad * fPad
selected pad
Definition TGedEditor.h:49
virtual void SetModel(TVirtualPad *pad, TObject *obj, Int_t event, Bool_t force=kFALSE)
Activate object editors according to the selected object.
TGCompositeFrame * fTabContainer
main tab container
Definition TGedEditor.h:46
TObject * fModel
selected object
Definition TGedEditor.h:48
static void SetFrameCreator(TGedEditor *e)
Set the TGedEditor that currently creates TGedFrames.
virtual TObject * GetModel() const
Definition TGedEditor.h:79
Base frame for implementing GUI - a service class.
Definition TGedFrame.h:27
TGedEditor * fGedEditor
manager of this frame
Definition TGedFrame.h:48
void SetModelClass(TClass *mcl)
Definition TGedFrame.h:78
TGedEditor * GetGedEditor()
Definition TGedFrame.h:71
A doubly linked list.
Definition TList.h:38
void Add(TObject *obj) override
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:41
virtual const char * GetName() const
Returns name of object.
Definition TObject.cxx:457
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition TObject.cxx:226
virtual const char * GetTitle() const
Returns title of object.
Definition TObject.cxx:501
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:865
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