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 <cassert>
15 #include <stdexcept>
16 #include <iostream>
17 
18 #include "TSystem.h"
19 #include "TGButton.h"
20 #include "TEveWindow.h"
21 
26 
27 //==============================================================================
28 // Workaround around bloody squeaking TGPictureButton.
29 // Want to get signal when pressed and released.
30 // This is needed for "info" button which "stays down".
31 //------------------------------------------------------------------------------
32 namespace {
33  class XXXButton : public TGPictureButton {
34  Int_t fXState;
35 
36  public:
37  XXXButton(const TGWindow* p, const TGPicture* pic) : TGPictureButton(p, pic), fXState(kButtonUp) {}
38 
39  void SetState(EButtonState state, Bool_t emit = kFALSE) override {
40  TGPictureButton::SetState(state, kFALSE);
41  if ((fXState == kButtonUp && fState == kButtonEngaged) || (fState == kButtonUp && fXState == kButtonEngaged)) {
42  fXState = fState;
43  Clicked();
44  }
45  }
46  };
47 } // namespace
48 //==============================================================================
49 
50 //
51 // constructors and destructor
52 //
53 FWGUISubviewArea::FWGUISubviewArea(TEveCompositeFrame* ef, TGCompositeFrame* parent, Int_t height)
54  : TGHorizontalFrame(parent, 20, height),
55  m_frame(ef),
56  m_swapButton(nullptr),
57  m_undockButton(nullptr),
58  m_dockButton(nullptr),
59  m_closeButton(nullptr),
60  m_infoButton(nullptr) {
61  UInt_t lh = kLHintsNormal | kLHintsExpandX | kLHintsExpandY;
62 
63  // info
64  m_infoButton = new XXXButton(this, infoIcon());
65  m_infoButton->ChangeOptions(kRaisedFrame);
66  m_infoButton->SetDisabledPicture(infoDisabledIcon());
67  AddFrame(m_infoButton, new TGLayoutHints(lh));
68  m_infoButton->AllowStayDown(kTRUE);
69  m_infoButton->Connect("Clicked()", "FWGUISubviewArea", this, "selectButtonToggle()");
70  m_infoButton->SetToolTipText("Edit View");
71 
72  //swap
73  m_swapButton = new TGPictureButton(this, swapIcon());
74  m_swapButton->SetDisabledPicture(swapDisabledIcon());
75  m_swapButton->SetToolTipText("Swap with the first view or select window to swap with click on toolbar.");
76  m_swapButton->ChangeOptions(kRaisedFrame);
77  m_swapButton->SetHeight(height);
78  AddFrame(m_swapButton, new TGLayoutHints(lh));
79  m_swapButton->Connect("Clicked()", "FWGUISubviewArea", this, "swap()");
80 
81  // dock
82  if (dynamic_cast<const TGMainFrame*>(ef->GetParent())) {
83  m_dockButton = new TGPictureButton(this, dockIcon());
84  m_dockButton->ChangeOptions(kRaisedFrame);
85  m_dockButton->ChangeOptions(kRaisedFrame);
86  m_dockButton->SetToolTipText("Dock view");
87  m_dockButton->SetHeight(height);
88  AddFrame(m_dockButton, new TGLayoutHints(lh));
89  m_dockButton->Connect("Clicked()", "FWGUISubviewArea", this, "dock()");
90  } else {
91  // undock
92  m_undockButton = new TGPictureButton(this, undockIcon());
93  m_undockButton->ChangeOptions(kRaisedFrame);
94  m_undockButton->SetDisabledPicture(undockDisabledIcon());
95  m_undockButton->SetToolTipText("Undock view to own window");
96  m_undockButton->SetHeight(height);
97  AddFrame(m_undockButton, new TGLayoutHints(lh));
98  m_undockButton->Connect("Clicked()", "FWGUISubviewArea", this, "undock()");
99  }
100  // destroy
101  m_closeButton = new TGPictureButton(this, closeIcon());
102  m_closeButton->ChangeOptions(kRaisedFrame);
103  m_closeButton->SetToolTipText("Close view");
104  m_closeButton->SetHeight(height);
105  AddFrame(m_closeButton, new TGLayoutHints(lh));
106  m_closeButton->Connect("Clicked()", "FWGUISubviewArea", this, "destroy()");
107 
109 }
110 
112  //std::cout <<"IN dstr FWGUISubviewArea"<<std::endl;
113  m_closeButton->Disconnect("Clicked()", this, "destroy()");
114  m_infoButton->Disconnect("Clicked()", this, "selectButtonToggle()");
115 }
116 
117 //______________________________________________________________________________
118 //
119 // actions
120 //
121 
123  if (isSelected())
124  selected_(this);
125  else
126  unselected_(this);
127 }
128 
129 void FWGUISubviewArea::unselect() { m_infoButton->SetState(kButtonUp); }
130 
131 void FWGUISubviewArea::setSwapIcon(bool isOn) { m_swapButton->SetEnabled(isOn); }
132 
133 void FWGUISubviewArea::swap() { swap_(this); }
134 
136 
138  TEveWindow* ew = m_frame->GetEveWindow();
139  ew->UndockWindow();
140  TEveCompositeFrameInMainFrame* emf = dynamic_cast<TEveCompositeFrameInMainFrame*>(ew->GetEveFrame());
141  if (emf) {
142  const TGMainFrame* mf = dynamic_cast<const TGMainFrame*>(emf->GetParent());
143  if (mf)
145  }
146 }
147 
149  TGWindow* w = (TGWindow*)(m_frame->GetParent());
150  w->UnmapWindow();
151  TTimer::SingleShot(0, m_frame->ClassName(), m_frame, "MainFrameClosed()");
152 }
153 
154 //
155 // const member functions
156 //
157 bool FWGUISubviewArea::isSelected() const { return m_infoButton->IsDown(); }
158 
159 //______________________________________________________________________________
160 TEveWindow* FWGUISubviewArea::getEveWindow() { return m_frame->GetEveWindow(); }
161 
162 //______________________________________________________________________________
163 // static member functions
164 //
165 const TGPicture* FWGUISubviewArea::swapIcon() {
166  static const TGPicture* s_icon = nullptr;
167  if (nullptr == s_icon) {
168  const char* cmspath = gSystem->Getenv("CMSSW_BASE");
169  if (nullptr == cmspath) {
170  throw std::runtime_error("CMSSW_BASE environment variable not set");
171  }
172  s_icon = gClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "moveup.png");
173  }
174  return s_icon;
175 }
176 
178  static const TGPicture* s_icon = nullptr;
179  if (nullptr == s_icon) {
180  const char* cmspath = gSystem->Getenv("CMSSW_BASE");
181  if (nullptr == cmspath) {
182  throw std::runtime_error("CMSSW_BASE environment variable not set");
183  }
184  s_icon = gClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "moveup-disabled.png");
185  }
186  return s_icon;
187 }
188 
189 const TGPicture* FWGUISubviewArea::closeIcon() {
190  static const TGPicture* s_icon = nullptr;
191  if (nullptr == s_icon) {
192  const char* cmspath = gSystem->Getenv("CMSSW_BASE");
193  if (nullptr == cmspath) {
194  throw std::runtime_error("CMSSW_BASE environment variable not set");
195  }
196  s_icon = gClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "delete.png");
197  }
198  return s_icon;
199 }
200 
202  static const TGPicture* s_icon = nullptr;
203  if (nullptr == s_icon) {
204  const char* cmspath = gSystem->Getenv("CMSSW_BASE");
205  if (nullptr == cmspath) {
206  throw std::runtime_error("CMSSW_BASE environment variable not set");
207  }
208  s_icon = gClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "delete-disabled.png");
209  }
210  return s_icon;
211 }
212 
213 const TGPicture* FWGUISubviewArea::undockIcon() {
214  static const TGPicture* s_icon = nullptr;
215  if (nullptr == s_icon) {
216  const char* cmspath = gSystem->Getenv("CMSSW_BASE");
217  if (nullptr == cmspath) {
218  throw std::runtime_error("CMSSW_BASE environment variable not set");
219  }
220  s_icon = gClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "expand.png");
221  }
222  return s_icon;
223 }
224 
225 const TGPicture* FWGUISubviewArea::dockIcon() {
226  static const TGPicture* s_icon = nullptr;
227  if (nullptr == s_icon) {
228  const char* cmspath = gSystem->Getenv("CMSSW_BASE");
229  if (nullptr == cmspath) {
230  throw std::runtime_error("CMSSW_BASE environment variable not set");
231  }
232  s_icon = gClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "dock.png");
233  }
234  return s_icon;
235 }
236 
238  static const TGPicture* s_icon = nullptr;
239  if (nullptr == s_icon) {
240  const char* cmspath = gSystem->Getenv("CMSSW_BASE");
241  if (nullptr == cmspath) {
242  throw std::runtime_error("CMSSW_BASE environment variable not set");
243  }
244  s_icon = gClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "expand-disabled.png");
245  }
246  return s_icon;
247 }
248 
249 const TGPicture* FWGUISubviewArea::infoIcon() {
250  static const TGPicture* s_icon = nullptr;
251  if (nullptr == s_icon) {
252  const char* cmspath = gSystem->Getenv("CMSSW_BASE");
253  if (nullptr == cmspath) {
254  throw std::runtime_error("CMSSW_BASE environment variable not set");
255  }
256  s_icon = gClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "info.png");
257  }
258  return s_icon;
259 }
260 
262  static const TGPicture* s_icon = nullptr;
263  if (nullptr == s_icon) {
264  const char* cmspath = gSystem->Getenv("CMSSW_BASE");
265  if (nullptr == cmspath) {
266  throw std::runtime_error("CMSSW_BASE environment variable not set");
267  }
268  s_icon = gClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "info-disabled.png");
269  }
270  return s_icon;
271 }
272 
273 void FWGUISubviewArea::setInfoButton(bool downp) { m_infoButton->SetState(downp ? kButtonEngaged : kButtonUp, false); }
274 
276  // horizontal frame
277  TGFrameElement* el = (TGFrameElement*)w->GetEveFrame()->GetList()->First();
278  TGCompositeFrame* hf = (TGCompositeFrame*)el->fFrame;
279  // subview last in the horizontal frame
280  el = (TGFrameElement*)hf->GetList()->Last();
281  FWGUISubviewArea* ar = dynamic_cast<FWGUISubviewArea*>(el->fFrame);
282  return ar;
283 }
FWGUISubviewArea::dockIcon
static const TGPicture * dockIcon()
Definition: FWGUISubviewArea.cc:225
FWGUISubviewArea::m_frame
TEveCompositeFrame * m_frame
Definition: FWGUISubviewArea.h:82
CmsShowMainFrame::bindCSGActionKeys
void bindCSGActionKeys(const TGMainFrame *f) const
Definition: CmsShowMainFrame.cc:780
FWGUISubviewArea::goingToBeDestroyed_
sigc::signal< void, FWGUISubviewArea * > goingToBeDestroyed_
Definition: FWGUISubviewArea.h:65
FWGUISubviewArea::getToolBarFromWindow
static FWGUISubviewArea * getToolBarFromWindow(TEveWindow *)
Definition: FWGUISubviewArea.cc:275
FWCheckBoxIcon::coreIcondir
static const TString & coreIcondir()
Definition: FWCheckBoxIcon.cc:76
FWGUISubviewArea::FWGUISubviewArea
FWGUISubviewArea(TEveCompositeFrame *ef, TGCompositeFrame *parent, Int_t height)
Definition: FWGUISubviewArea.cc:53
FWGUISubviewArea::m_closeButton
TGPictureButton * m_closeButton
Definition: FWGUISubviewArea.h:87
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
FWGUISubviewArea::infoDisabledIcon
static const TGPicture * infoDisabledIcon()
Definition: FWGUISubviewArea.cc:261
FWGUISubviewArea::destroy
void destroy()
Definition: FWGUISubviewArea.cc:135
FWCheckBoxIcon.h
FWGUISubviewArea::swap_
sigc::signal< void, FWGUISubviewArea * > swap_
Definition: FWGUISubviewArea.h:64
mathSSE::lh
bool int lh
Definition: SIMDVec.h:20
FWGUISubviewArea::dock
void dock()
Definition: FWGUISubviewArea.cc:148
FWGUIManager::getMainFrame
CmsShowMainFrame * getMainFrame() const
Definition: FWGUIManager.h:197
FWGUISubviewArea::m_undockButton
TGPictureButton * m_undockButton
Definition: FWGUISubviewArea.h:85
photonIsolationHIProducer_cfi.hf
hf
Definition: photonIsolationHIProducer_cfi.py:9
FWGUISubviewArea.h
w
const double w
Definition: UKUtility.cc:23
FWGUISubviewArea::closeIcon
static const TGPicture * closeIcon()
Definition: FWGUISubviewArea.cc:189
FWGUISubviewArea::swapIcon
static const TGPicture * swapIcon()
Definition: FWGUISubviewArea.cc:165
FWGUISubviewArea
Definition: FWGUISubviewArea.h:33
custom_jme_cff.emf
emf
Definition: custom_jme_cff.py:205
FWGUISubviewArea::getEveWindow
TEveWindow * getEveWindow()
Definition: FWGUISubviewArea.cc:160
FWGUISubviewArea::unselect
void unselect()
Definition: FWGUISubviewArea.cc:129
FWGUISubviewArea::undock
void undock()
Definition: FWGUISubviewArea.cc:137
FWGUISubviewArea::unselected_
sigc::signal< void, FWGUISubviewArea * > unselected_
Definition: FWGUISubviewArea.h:67
FWGUISubviewArea::selected_
sigc::signal< void, FWGUISubviewArea * > selected_
Definition: FWGUISubviewArea.h:66
FWGUISubviewArea::m_infoButton
TGPictureButton * m_infoButton
Definition: FWGUISubviewArea.h:88
FWGUISubviewArea::swap
void swap()
Definition: FWGUISubviewArea.cc:133
FWGUISubviewArea::m_dockButton
TGPictureButton * m_dockButton
Definition: FWGUISubviewArea.h:86
FWGUISubviewArea::undockIcon
static const TGPicture * undockIcon()
Definition: FWGUISubviewArea.cc:213
FWGUIManager::connectSubviewAreaSignals
void connectSubviewAreaSignals(FWGUISubviewArea *)
Definition: FWGUIManager.cc:221
FWGUISubviewArea::closeDisabledIcon
static const TGPicture * closeDisabledIcon()
Definition: FWGUISubviewArea.cc:201
FWGUISubviewArea::setInfoButton
void setInfoButton(bool downp)
Definition: FWGUISubviewArea.cc:273
FWGUIManager::getGUIManager
static FWGUIManager * getGUIManager()
Definition: FWGUIManager.cc:685
RunInfoPI::state
state
Definition: RunInfoPayloadInspectoHelper.h:16
FWGUISubviewArea::isSelected
bool isSelected() const
Definition: FWGUISubviewArea.cc:157
CmsShowMainFrame.h
FWGUISubviewArea::~FWGUISubviewArea
~FWGUISubviewArea() override
Definition: FWGUISubviewArea.cc:111
FWGUISubviewArea::setSwapIcon
void setSwapIcon(bool)
Definition: FWGUISubviewArea.cc:131
FWGUISubviewArea::swapDisabledIcon
static const TGPicture * swapDisabledIcon()
Definition: FWGUISubviewArea.cc:177
hcaldqm::quantity::fState
Definition: ValueQuantity.h:47
FWGUISubviewArea::undockDisabledIcon
static const TGPicture * undockDisabledIcon()
Definition: FWGUISubviewArea.cc:237
FWGUISubviewArea::m_swapButton
TGPictureButton * m_swapButton
Definition: FWGUISubviewArea.h:84
class-composition.parent
parent
Definition: class-composition.py:88
FWGUIManager.h
FWGUISubviewArea::infoIcon
static const TGPicture * infoIcon()
Definition: FWGUISubviewArea.cc:249
FWGUISubviewArea::selectButtonToggle
void selectButtonToggle()
Definition: FWGUISubviewArea.cc:122