CMS 3D CMS Logo

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