Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TVirtualPadEditor.cxx
Go to the documentation of this file.
1 // @(#)root/base:$Id: TVirtualPadEditor.cxx,v 1.0 2003/11/25
2 // Author: Ilka Antcheva 25/11/03
3 /*************************************************************************
4  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
5  * All rights reserved. *
6  * *
7  * For the licensing terms see $ROOTSYS/LICENSE. *
8  * For the list of contributors see $ROOTSYS/README/CREDITS. *
9  *************************************************************************/
10 
11 /** \class TVirtualPadEditor
12 \ingroup Base
13 
14 Abstract base class used by ROOT graphics editor
15 */
16 
17 #include "TROOT.h"
18 #include "TVirtualPadEditor.h"
19 #include "TPluginManager.h"
20 #include "TEnv.h"
21 #include "TVirtualPad.h"
22 
23 TVirtualPadEditor *TVirtualPadEditor::fgPadEditor = 0;
24 TString TVirtualPadEditor::fgEditorName = "";
25 
26 ClassImp(TVirtualPadEditor);
27 
28 ////////////////////////////////////////////////////////////////////////////////
29 /// Virtual editor ctor.
30 
31 TVirtualPadEditor::TVirtualPadEditor()
32 {
33 }
34 
35 ////////////////////////////////////////////////////////////////////////////////
36 /// Virtual editor dtor.
37 
38 TVirtualPadEditor::~TVirtualPadEditor()
39 {
40 }
41 
42 ////////////////////////////////////////////////////////////////////////////////
43 /// Static function returning a pointer to a new pad editor.
44 /// This pointer can be adopted by a TCanvas (i.e. TRootCanvas)
45 /// when it embeds the editor.
46 
47 TVirtualPadEditor *TVirtualPadEditor::LoadEditor()
48 {
49  TPluginHandler *h;
50  if (fgEditorName.Length() == 0)
51  fgEditorName = gEnv->GetValue("Root.PadEditor","Ged");
52  h = gROOT->GetPluginManager()->FindHandler("TVirtualPadEditor",
53  fgEditorName);
54  if (h) {
55  if (h->LoadPlugin() == -1)
56  return 0;
57  return (TVirtualPadEditor*) h->ExecPlugin(1, gPad ? gPad->GetCanvas() : 0);
58  }
59 
60  return 0;
61 }
62 
63 ////////////////////////////////////////////////////////////////////////////////
64 /// Returns the type of the default pad editor. Static method.
65 
66 const char *TVirtualPadEditor::GetEditorName()
67 {
68  return fgEditorName;
69 }
70 
71 ////////////////////////////////////////////////////////////////////////////////
72 /// Returns the pad editor dialog. Static method.
73 
74 TVirtualPadEditor *TVirtualPadEditor::GetPadEditor(Bool_t load)
75 {
76  if (!fgPadEditor && load)
77  fgPadEditor = LoadEditor();
78 
79  return fgPadEditor;
80 }
81 
82 ////////////////////////////////////////////////////////////////////////////////
83 /// Set type of default pad editor. Static method.
84 
85 void TVirtualPadEditor::SetPadEditorName(const char *name)
86 {
87  if (fgEditorName == name) return;
88  delete fgPadEditor;
89  fgPadEditor = 0;
90  fgEditorName = name;
91 }
92 
93 ////////////////////////////////////////////////////////////////////////////////
94 /// Show the global pad editor. Static method.
95 
96 void TVirtualPadEditor::ShowEditor()
97 {
98  if (!fgPadEditor) {
99  GetPadEditor();
100  if (!fgPadEditor) return;
101  fgPadEditor->SetGlobal(kTRUE);
102  }
103  fgPadEditor->Show();
104 }
105 
106 ////////////////////////////////////////////////////////////////////////////////
107 /// Hide the pad editor. Static method.
108 
109 void TVirtualPadEditor::HideEditor()
110 {
111  if (fgPadEditor)
112  fgPadEditor->Hide();
113 }
114 
115 ////////////////////////////////////////////////////////////////////////////////
116 /// Close the global pad editor. Static method.
117 
118 void TVirtualPadEditor::Terminate()
119 {
120  if (!fgPadEditor) return;
121 
122  delete fgPadEditor;
123  fgPadEditor = 0;
124 }
125 
126 ////////////////////////////////////////////////////////////////////////////////
127 /// Update fill attributes via the pad editor
128 
129 void TVirtualPadEditor::UpdateFillAttributes(Int_t color, Int_t style)
130 {
131  ShowEditor();
132 
133  if (fgPadEditor)
134  fgPadEditor->FillAttributes(color, style);
135 }
136 
137 ////////////////////////////////////////////////////////////////////////////////
138 /// Update text attributes via the pad editor
139 
140 void TVirtualPadEditor::UpdateTextAttributes(Int_t align, Float_t angle,
141  Int_t col, Int_t font, Float_t tsize)
142 {
143  ShowEditor();
144 
145  if (fgPadEditor)
146  fgPadEditor->TextAttributes(align, angle, col, font, tsize);
147 }
148 
149 ////////////////////////////////////////////////////////////////////////////////
150 /// Update line attributes via the pad editor
151 
152 void TVirtualPadEditor::UpdateLineAttributes(Int_t color, Int_t style,
153  Int_t width)
154 {
155  ShowEditor();
156 
157  if (fgPadEditor)
158  fgPadEditor->LineAttributes(color, style, width);
159 }
160 
161 ////////////////////////////////////////////////////////////////////////////////
162 /// Update marker attributes via the pad editor
163 
164 void TVirtualPadEditor::UpdateMarkerAttributes(Int_t color, Int_t style,
165  Float_t msize)
166 {
167  ShowEditor();
168 
169  if (fgPadEditor)
170  fgPadEditor->MarkerAttributes(color, style, msize);
171 }