CMS 3D CMS Logo

FWGUISubviewArea.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Core
4 // Class : FWGUISubviewArea
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Chris Jones
10 // Created: Fri Feb 15 14:13:33 EST 2008
11 //
12 
13 // system include files
14 #include <assert.h>
15 #include <stdexcept>
16 #include <iostream>
17 
18 #include "TSystem.h"
19 #include "TGButton.h"
20 #include "TEveWindow.h"
21 
26 
27 
28 //==============================================================================
29 // Workaround around bloody squeaking TGPictureButton.
30 // Want to get signal when pressed and released.
31 // This is needed for "info" button which "stays down".
32 //------------------------------------------------------------------------------
33 namespace
34 {
35  class XXXButton : public TGPictureButton
36  {
37  Int_t fXState;
38  public:
39  XXXButton(const TGWindow* p, const TGPicture* pic) :
40  TGPictureButton(p, pic), fXState(kButtonUp) {}
41 
42  virtual void SetState(EButtonState state, Bool_t emit=kFALSE) override
43  {
44  TGPictureButton::SetState(state, kFALSE);
45  if ((fXState == kButtonUp && fState == kButtonEngaged) ||
46  (fState == kButtonUp && fXState == kButtonEngaged))
47  {
48  fXState = fState;
49  Clicked();
50  }
51  }
52  };
53 }
54 //==============================================================================
55 
56 
57 //
58 // constructors and destructor
59 //
60 FWGUISubviewArea::FWGUISubviewArea(TEveCompositeFrame* ef, TGCompositeFrame* parent, Int_t height) :
61  TGHorizontalFrame(parent, 20, height),
62  m_frame (ef),
63  m_swapButton(0),
64  m_undockButton(0), m_dockButton(0),
65  m_closeButton(0),
66  m_infoButton(0)
67 {
68  UInt_t lh = kLHintsNormal | kLHintsExpandX | kLHintsExpandY;
69 
70  // info
71  m_infoButton = new XXXButton(this,infoIcon());
72  m_infoButton->ChangeOptions(kRaisedFrame);
73  m_infoButton->SetDisabledPicture(infoDisabledIcon());
74  AddFrame(m_infoButton, new TGLayoutHints(lh));
75  m_infoButton->AllowStayDown(kTRUE);
76  m_infoButton->Connect("Clicked()","FWGUISubviewArea",this,"selectButtonToggle()");
77  m_infoButton->SetToolTipText("Edit View");
78 
79  //swap
80  m_swapButton = new TGPictureButton(this, swapIcon());
81  m_swapButton->SetDisabledPicture(swapDisabledIcon());
82  m_swapButton->SetToolTipText("Swap with the first view or select window to swap with click on toolbar.");
83  m_swapButton->ChangeOptions(kRaisedFrame);
84  m_swapButton->SetHeight(height);
85  AddFrame(m_swapButton, new TGLayoutHints(lh));
86  m_swapButton->Connect("Clicked()","FWGUISubviewArea",this,"swap()");
87 
88  // dock
89  if (dynamic_cast<const TGMainFrame*>(ef->GetParent()))
90  {
91  m_dockButton = new TGPictureButton(this, dockIcon());
92  m_dockButton->ChangeOptions(kRaisedFrame);
93  m_dockButton->ChangeOptions(kRaisedFrame);
94  m_dockButton->SetToolTipText("Dock view");
95  m_dockButton->SetHeight(height);
96  AddFrame(m_dockButton, new TGLayoutHints(lh));
97  m_dockButton->Connect("Clicked()", "FWGUISubviewArea",this,"dock()");
98  }
99  else
100  {
101  // undock
102  m_undockButton = new TGPictureButton(this, undockIcon());
103  m_undockButton->ChangeOptions(kRaisedFrame);
104  m_undockButton->SetDisabledPicture(undockDisabledIcon());
105  m_undockButton->SetToolTipText("Undock view to own window");
106  m_undockButton->SetHeight(height);
107  AddFrame(m_undockButton, new TGLayoutHints(lh));
108  m_undockButton->Connect("Clicked()", "FWGUISubviewArea",this,"undock()");
109  }
110  // destroy
111  m_closeButton = new TGPictureButton(this,closeIcon());
112  m_closeButton->ChangeOptions(kRaisedFrame);
113  m_closeButton->SetToolTipText("Close view");
114  m_closeButton->SetHeight(height);
115  AddFrame(m_closeButton, new TGLayoutHints(lh));
116  m_closeButton->Connect("Clicked()", "FWGUISubviewArea",this,"destroy()");
117 
119 }
120 
122 {
123  //std::cout <<"IN dstr FWGUISubviewArea"<<std::endl;
124  m_closeButton->Disconnect("Clicked()", this,"destroy()");
125  m_infoButton->Disconnect("Clicked()",this,"selectButtonToggle()");
126 }
127 
128 //______________________________________________________________________________
129 //
130 // actions
131 //
132 
133 void
135 {
136  if (isSelected())
137  selected_(this);
138  else
139  unselected_(this);
140 }
141 
142 void
144 {
145  m_infoButton->SetState(kButtonUp);
146 }
147 
148 void
150 {
151  m_swapButton->SetEnabled(isOn);
152 }
153 
154 void
156 {
157  swap_(this);
158 }
159 
160 void
162 {
163  goingToBeDestroyed_(this);
164 }
165 
166 void
168 {
169  TEveWindow* ew = m_frame->GetEveWindow();
170  ew->UndockWindow();
171  TEveCompositeFrameInMainFrame* emf = dynamic_cast<TEveCompositeFrameInMainFrame*>(ew->GetEveFrame());
172  if (emf) {
173  const TGMainFrame* mf = dynamic_cast<const TGMainFrame*>(emf->GetParent());
174  if (mf)
176  }
177 }
178 
179 void
181 {
182  TGWindow* w = (TGWindow*)(m_frame->GetParent());
183  w->UnmapWindow();
184  TTimer::SingleShot(0, m_frame->ClassName(), m_frame, "MainFrameClosed()");
185 }
186 
187 //
188 // const member functions
189 //
190 bool
192 {
193  return m_infoButton->IsDown();
194 }
195 
196 
197 //______________________________________________________________________________
198 TEveWindow*
200 {
201  return m_frame->GetEveWindow();
202 }
203 
204 //______________________________________________________________________________
205 // static member functions
206 //
207 const TGPicture *
209 {
210  static const TGPicture* s_icon = 0;
211  if(0== s_icon) {
212  const char* cmspath = gSystem->Getenv("CMSSW_BASE");
213  if(0 == cmspath) {
214  throw std::runtime_error("CMSSW_BASE environment variable not set");
215  }
216  s_icon = gClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"moveup.png");
217  }
218  return s_icon;
219 }
220 
221 const TGPicture *
223 {
224  static const TGPicture* s_icon = 0;
225  if(0== s_icon) {
226  const char* cmspath = gSystem->Getenv("CMSSW_BASE");
227  if(0 == cmspath) {
228  throw std::runtime_error("CMSSW_BASE environment variable not set");
229  }
230  s_icon = gClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"moveup-disabled.png");
231  }
232  return s_icon;
233 }
234 
235 const TGPicture *
237 {
238  static const TGPicture* s_icon = 0;
239  if(0== s_icon) {
240  const char* cmspath = gSystem->Getenv("CMSSW_BASE");
241  if(0 == cmspath) {
242  throw std::runtime_error("CMSSW_BASE environment variable not set");
243  }
244  s_icon = gClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"delete.png");
245  }
246  return s_icon;
247 }
248 
249 const TGPicture *
251 {
252  static const TGPicture* s_icon = 0;
253  if(0== s_icon) {
254  const char* cmspath = gSystem->Getenv("CMSSW_BASE");
255  if(0 == cmspath) {
256  throw std::runtime_error("CMSSW_BASE environment variable not set");
257  }
258  s_icon = gClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"delete-disabled.png");
259  }
260  return s_icon;
261 }
262 
263 
264 const TGPicture *
266 {
267  static const TGPicture* s_icon = 0;
268  if(0== s_icon) {
269  const char* cmspath = gSystem->Getenv("CMSSW_BASE");
270  if(0 == cmspath) {
271  throw std::runtime_error("CMSSW_BASE environment variable not set");
272  }
273  s_icon = gClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"expand.png");
274  }
275  return s_icon;
276 }
277 
278 const TGPicture *
280 {
281  static const TGPicture* s_icon = 0;
282  if(0== s_icon) {
283  const char* cmspath = gSystem->Getenv("CMSSW_BASE");
284  if(0 == cmspath) {
285  throw std::runtime_error("CMSSW_BASE environment variable not set");
286  }
287  s_icon = gClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"dock.png");
288  }
289  return s_icon;
290 }
291 
292 const TGPicture *
294 {
295  static const TGPicture* s_icon = 0;
296  if(0== s_icon) {
297  const char* cmspath = gSystem->Getenv("CMSSW_BASE");
298  if(0 == cmspath) {
299  throw std::runtime_error("CMSSW_BASE environment variable not set");
300  }
301  s_icon = gClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"expand-disabled.png");
302  }
303  return s_icon;
304 }
305 
306 const TGPicture *
308 {
309  static const TGPicture* s_icon = 0;
310  if(0== s_icon) {
311  const char* cmspath = gSystem->Getenv("CMSSW_BASE");
312  if(0 == cmspath) {
313  throw std::runtime_error("CMSSW_BASE environment variable not set");
314  }
315  s_icon = gClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"info.png");
316  }
317  return s_icon;
318 }
319 
320 const TGPicture *
322 {
323  static const TGPicture* s_icon = 0;
324  if(0== s_icon) {
325  const char* cmspath = gSystem->Getenv("CMSSW_BASE");
326  if(0 == cmspath) {
327  throw std::runtime_error("CMSSW_BASE environment variable not set");
328  }
329  s_icon = gClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"info-disabled.png");
330  }
331  return s_icon;
332 }
333 
334 void
336 {
337  m_infoButton->SetState(downp ? kButtonEngaged : kButtonUp, false);
338 }
339 
342 {
343  // horizontal frame
344  TGFrameElement *el = (TGFrameElement*) w->GetEveFrame()->GetList()->First();
345  TGCompositeFrame* hf = (TGCompositeFrame*)el->fFrame;
346  // subview last in the horizontal frame
347  el = (TGFrameElement*)hf->GetList()->Last();
348  FWGUISubviewArea* ar = dynamic_cast<FWGUISubviewArea*>(el->fFrame);
349  return ar;
350 }
TGPictureButton * m_undockButton
static const TString & coreIcondir()
TEveWindow * getEveWindow()
void bindCSGActionKeys(const TGMainFrame *f) const
TGPictureButton * m_dockButton
static const TGPicture * swapIcon()
static const TGPicture * undockIcon()
sigc::signal< void, FWGUISubviewArea * > unselected_
const double w
Definition: UKUtility.cc:23
static const TGPicture * swapDisabledIcon()
bool int lh
Definition: SIMDVec.h:21
static const TGPicture * infoIcon()
void setInfoButton(bool downp)
static const TGPicture * closeDisabledIcon()
void connectSubviewAreaSignals(FWGUISubviewArea *)
static const TGPicture * undockDisabledIcon()
virtual ~FWGUISubviewArea()
emf
the use of emf in the JEC is not yet implemented
FWGUISubviewArea(TEveCompositeFrame *ef, TGCompositeFrame *parent, Int_t height)
sigc::signal< void, FWGUISubviewArea * > goingToBeDestroyed_
static FWGUISubviewArea * getToolBarFromWindow(TEveWindow *)
static const TGPicture * infoDisabledIcon()
TGPictureButton * m_swapButton
CmsShowMainFrame * getMainFrame() const
Definition: FWGUIManager.h:201
TGPictureButton * m_closeButton
TEveCompositeFrame * m_frame
static const TGPicture * dockIcon()
bool isSelected() const
static FWGUIManager * getGUIManager()
sigc::signal< void, FWGUISubviewArea * > swap_
static const TGPicture * closeIcon()
sigc::signal< void, FWGUISubviewArea * > selected_
TGPictureButton * m_infoButton