CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CmsShowViewPopup.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Core
4 // Class : CmsShowViewPopup
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author:
10 // Created: Wed Jun 25 15:15:04 EDT 2008
11 // $Id: CmsShowViewPopup.cc,v 1.31.2.3 2013/04/24 21:02:14 amraktad Exp $
12 //
13 
14 // system include files
15 #include <iostream>
16 #include <boost/bind.hpp>
17 #include <cassert>
18 #include "TGLabel.h"
19 #include "TGButton.h"
20 #include "TG3DLine.h"
21 #include "TGFrame.h"
22 #include "TGTab.h"
23 #include "TG3DLine.h"
24 #include "TEveWindow.h"
25 
26 // user include files
32 
33 
34 //
35 // constants, enums and typedefs
36 //
37 
38 //
39 // static data member definitions
40 //
41 
42 //
43 // constructors and destructor
44 //
45 CmsShowViewPopup::CmsShowViewPopup(const TGWindow* p, UInt_t w, UInt_t h, FWColorManager* iCMgr, FWViewBase* vb, TEveWindow* ew) :
46  TGTransientFrame(gClient->GetDefaultRoot(),p, w, h),
47  m_mapped(kFALSE),
48  m_viewLabel(0),
49  m_paramGUI(0),
50  m_saveImageButton(0),
51  m_changeBackground(0),
52  m_colorManager(iCMgr),
53  m_viewBase(0),
54  m_eveWindow(0)
55 {
57 
58  SetCleanup(kDeepCleanup);
59 
60  // label
61  TGHorizontalFrame* viewFrame = new TGHorizontalFrame(this);
62  m_viewLabel = new TGLabel(viewFrame, "No view selected");
63  try
64  {
65  TGFont* defaultFont = gClient->GetFontPool()->GetFont(m_viewLabel->GetDefaultFontStruct());
66  m_viewLabel->SetTextFont(gClient->GetFontPool()->GetFont(defaultFont->GetFontAttributes().fFamily, 14, defaultFont->GetFontAttributes().fWeight + 2, defaultFont->GetFontAttributes().fSlant));
67  }
68  catch(...)
69  {
70  // FIXME: looks like under certain conditions (e.g. in full framework)
71  // GetFontPool() throws when the default font is not found. This is a
72  // quick workaround, but we should probably investigate more.
73  }
74 
75  m_viewLabel->SetTextJustify(kTextLeft);
76  viewFrame->AddFrame(m_viewLabel, new TGLayoutHints(kLHintsExpandX));
77  AddFrame(viewFrame, new TGLayoutHints(kLHintsExpandX, 2, 2, 0, 0));
78  // background
79  m_changeBackground = new TGTextButton(this,"Change Background Color");
81  AddFrame(m_changeBackground, new TGLayoutHints(kLHintsExpandX, 2, 2, 5, 5));
82  m_changeBackground->Connect("Clicked()","CmsShowViewPopup",this,"changeBackground()");
83  // save image
84  m_saveImageButton= new TGTextButton(this,"Save Image ...");
85  AddFrame(m_saveImageButton, new TGLayoutHints(kLHintsExpandX, 2, 2, 5, 5));
86  m_saveImageButton->Connect("Clicked()","CmsShowViewPopup",this,"saveImage()");
87 
88  // content frame
89  AddFrame(new TGHorizontal3DLine(this), new TGLayoutHints(kLHintsExpandX, 0, 0, 5, 5));
90  m_paramGUI = new ViewerParameterGUI(this);
91  AddFrame(m_paramGUI,new TGLayoutHints(kLHintsExpandX|kLHintsExpandY));
92 
93  SetWindowName("View Controller");
94 }
95 
96 // CmsShowViewPopup::CmsShowViewPopup(const CmsShowViewPopup& rhs)
97 // {
98 // // do actual copying here;
99 // }
100 
102 {
103 }
104 
105 void
107 {
108  m_viewBase = vb;
109  m_eveWindow = ew;
110 
111  m_paramGUI->reset();
112 
113  // fill content
114  if (m_viewBase)
115  {
116  m_saveImageButton->SetEnabled(kTRUE);
117  m_viewLabel->SetText(m_viewBase->typeName().c_str());
120 
121  fMain = m_eveWindow->GetEveFrame();
122 
123  if (vb->typeId() >= FWViewType::kTable)
124  m_saveImageButton->SetText("Print Text To Terminal");
125  else
126  m_saveImageButton->SetText("Save Image ...");
127  }
128  else
129  {
130  fMain = 0;
131  m_viewLabel->SetText("No view selected");
132  m_saveImageButton->SetEnabled(kFALSE);
133  }
134 
135  MapSubwindows();
136  Resize(GetDefaultSize());
137  Layout();
138  if (fMain)
139  {
140  CenterOnParent(kTRUE, TGTransientFrame::kTopRight);
141  }
142 
143 
144 
145 }
146 
147 void
149 {
150  UnmapWindow();
151  closed_.emit();
152 }
153 
154 void
156 {
157  TGWindow::MapWindow();
158  m_mapped = true;
159 }
160 
161 void
163 {
164  TGWindow::UnmapWindow();
165  m_mapped = false;
166 }
167 
168 void
170 {
171  if (m_viewBase)
173 }
174 
175 void
177 {
181 }
182 
183 void
185 {
187  m_changeBackground->SetText("Change Background Color to White");
188  } else {
189  m_changeBackground->SetText("Change Background Color to Black");
190  }
191 }
192 
193 //==============================================================================
194 
196  TGCompositeFrame(p),
197  m_tab(0),
198  m_selectedTabName("Style")
199 {
200  SetCleanup(kDeepCleanup);
201 }
202 
203 void
205 {
206  // remember selected tab
207  if (m_tab)
208  m_selectedTabName = m_tab->GetCurrentTab()->GetString();
209  else
210  m_selectedTabName = "Style";
211 
212  // remove TGTab as the only child
213  m_setters.clear();
214  if (m_tab)
215  {
216  assert(GetList()->GetSize() == 1);
217  TGFrameElement *el = (TGFrameElement*) GetList()->First();
218  TGFrame* f = el->fFrame;
219 
220  assert (f == m_tab);
221  f->UnmapWindow();
222  RemoveFrame(f);
223  f->DeleteWindow();
224  m_tab = 0;
225  }
226 }
227 
230 {
231  if (!m_tab)
232  {
233  m_tab = new TGTab(this);
234  AddFrame(m_tab, new TGLayoutHints(kLHintsExpandX |kLHintsExpandY ));
235  }
236 
237  if (!m_tab->GetTabContainer(name))
238  m_tab->AddTab(name);
239 
240  m_tab->SetTab(name);
241 
242  return *this;
243 }
244 
245 /* Add parameter setter in the current tab.*/
248 {
249  boost::shared_ptr<FWParameterSetterBase> ptr( FWParameterSetterBase::makeSetterFor((FWParameterBase*)param) );
250  ptr->attach((FWParameterBase*)param, this);
251  TGCompositeFrame* parent = m_tab->GetCurrentContainer();
252 
253  TGFrame* pframe = ptr->build(parent);
254  parent->AddFrame(pframe, new TGLayoutHints(kLHintsExpandX));
255  m_setters.push_back(ptr);
256 
257  pframe->MapWindow();
258  pframe->MapSubwindows();
259  pframe->Layout();
260  parent->MapSubwindows();
261  parent->Layout();
262  m_tab->Layout();
263  parent->Resize(parent->GetDefaultSize());
264  return *this;
265 }
266 
267 
268 
269 /* Add separator in current tab. */
272 {
273  assert(m_tab);
274  TGHorizontal3DLine* s = new TGHorizontal3DLine(m_tab->GetCurrentContainer());
275  m_tab->GetCurrentContainer()->AddFrame(s, new TGLayoutHints(kLHintsExpandX,4 ,4, 2, 2));
276 
277  return *this;
278 }
279 
280 TGCompositeFrame*
282 {
283  assert (m_tab);
284  return m_tab->GetCurrentContainer();
285 }
286 
287 void
289 {
290  assert (m_tab);
291  TGCompositeFrame* parent = m_tab->GetCurrentContainer();
292  parent->AddFrame(x,new TGLayoutHints(kLHintsExpandX,4 ,4, 2, 2) );
293 
294  parent->MapSubwindows();
295  parent->Layout();
296  m_tab->Layout();
297  parent->Resize(parent->GetDefaultSize());
298 }
299 
300 void
302 {
303  // Set tab - same as it was before, if not exisiting select first time.
304  if (m_tab)
305  {
306  bool x = m_tab->SetTab(m_selectedTabName.c_str(), false);
307  if (!x) m_tab->SetTab("Style");
308  }
309 }
ViewerParameterGUI(const TGFrame *)
std::string m_selectedTabName
list parent
Definition: dbtoconf.py:74
std::vector< boost::shared_ptr< FWParameterSetterBase > > m_setters
virtual void MapWindow()
sigc::signal< void > closed_
ViewerParameterGUI & requestTab(const char *)
ViewerParameterGUI & separator()
const std::string & typeName() const
Definition: FWViewBase.cc:121
virtual void UnmapWindow()
static boost::shared_ptr< FWParameterSetterBase > makeSetterFor(FWParameterBase *)
void addFrameToContainer(TGCompositeFrame *)
void setBackgroundColorIndex(BackgroundColorIndex)
BackgroundColorIndex backgroundColorIndex() const
TGTextButton * m_changeBackground
TGTextButton * m_saveImageButton
void reset(FWViewBase *, TEveWindow *ew)
FWColorManager * m_colorManager
double f[11][100]
CmsShowViewPopup(const TGWindow *p=0, UInt_t w=200, UInt_t h=200, FWColorManager *cm=0, FWViewBase *wb=0, TEveWindow *ew=0)
virtual void CloseWindow()
virtual ~CmsShowViewPopup()
unsigned int UInt_t
Definition: FUTypes.h:12
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
FWViewBase * m_viewBase
ViewerParameterGUI & addParam(const FWParameterBase *)
TGCompositeFrame * getTabContainer()
void backgroundColorWasChanged()
virtual void populateController(ViewerParameterGUI &) const
Definition: FWViewBase.h:49
void promptForSaveImageTo(TGFrame *) const
Definition: FWViewBase.cc:74
sigc::signal< void > colorsHaveChanged_
x
Definition: VDTMath.h:216
ViewerParameterGUI * m_paramGUI
TEveWindow * m_eveWindow
T w() const
FWViewType::EType typeId() const
Definition: FWViewBase.h:42