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.28 2010/09/24 18:51:18 amraktad Exp $
12 //
13 
14 // system include files
15 #include <iostream>
16 #include <boost/bind.hpp>
17 #include "TGLabel.h"
18 #include "TGButton.h"
19 #include "TG3DLine.h"
20 #include "TGFrame.h"
21 #include "TGTab.h"
22 #include "TG3DLine.h"
23 #include "TEveWindow.h"
24 
25 // user include files
31 
32 
33 //
34 // constants, enums and typedefs
35 //
36 
37 //
38 // static data member definitions
39 //
40 
41 //
42 // constructors and destructor
43 //
44 CmsShowViewPopup::CmsShowViewPopup(const TGWindow* p, UInt_t w, UInt_t h, FWColorManager* iCMgr, FWViewBase* vb, TEveWindow* ew) :
45  TGTransientFrame(gClient->GetDefaultRoot(),p, w, h),
46  m_mapped(kFALSE),
47  m_viewLabel(0),
48  m_paramGUI(0),
49  m_saveImageButton(0),
50  m_changeBackground(0),
51  m_colorManager(iCMgr),
52  m_viewBase(0),
53  m_eveWindow(0)
54 {
56 
57  SetCleanup(kDeepCleanup);
58 
59  // label
60  TGHorizontalFrame* viewFrame = new TGHorizontalFrame(this);
61  m_viewLabel = new TGLabel(viewFrame, "No view selected");
62  try
63  {
64  TGFont* defaultFont = gClient->GetFontPool()->GetFont(m_viewLabel->GetDefaultFontStruct());
65  m_viewLabel->SetTextFont(gClient->GetFontPool()->GetFont(defaultFont->GetFontAttributes().fFamily, 14, defaultFont->GetFontAttributes().fWeight + 2, defaultFont->GetFontAttributes().fSlant));
66  }
67  catch(...)
68  {
69  // FIXME: looks like under certain conditions (e.g. in full framework)
70  // GetFontPool() throws when the default font is not found. This is a
71  // quick workaround, but we should probably investigate more.
72  }
73 
74  m_viewLabel->SetTextJustify(kTextLeft);
75  viewFrame->AddFrame(m_viewLabel, new TGLayoutHints(kLHintsExpandX));
76  AddFrame(viewFrame, new TGLayoutHints(kLHintsExpandX, 2, 2, 0, 0));
77  // background
78  m_changeBackground = new TGTextButton(this,"Change Background Color");
80  AddFrame(m_changeBackground, new TGLayoutHints(kLHintsNormal, 0, 0, 5, 5));
81  m_changeBackground->Connect("Clicked()","CmsShowViewPopup",this,"changeBackground()");
82  // save image
83  m_saveImageButton= new TGTextButton(this,"Save Image ...");
84  AddFrame(m_saveImageButton);
85  m_saveImageButton->Connect("Clicked()","CmsShowViewPopup",this,"saveImage()");
86 
87  // content frame
88  AddFrame(new TGHorizontal3DLine(this), new TGLayoutHints(kLHintsExpandX, 0, 0, 5, 5));
89  m_paramGUI = new ViewerParameterGUI(this);
90  AddFrame(m_paramGUI,new TGLayoutHints(kLHintsExpandX|kLHintsExpandY));
91 
92  SetWindowName("View Controller");
93 }
94 
95 // CmsShowViewPopup::CmsShowViewPopup(const CmsShowViewPopup& rhs)
96 // {
97 // // do actual copying here;
98 // }
99 
101 {
102 }
103 
104 void
106 {
107  m_viewBase = vb;
108  m_eveWindow = ew;
109 
110  m_paramGUI->reset();
111 
112  // fill content
113  if(m_viewBase) {
114  m_saveImageButton->SetEnabled(kTRUE);
115  m_viewLabel->SetText(m_viewBase->typeName().c_str());
118 
119  fMain = m_eveWindow->GetEveFrame();
120  }
121  else {
122  fMain = 0;
123  m_viewLabel->SetText("No view selected");
124  m_saveImageButton->SetEnabled(kFALSE);
125  }
126 
127  MapSubwindows();
128  Resize(GetDefaultSize());
129  Layout();
130  if (fMain)
131  {
132  CenterOnParent(kTRUE, TGTransientFrame::kTopRight);
133  }
134 }
135 
136 void
138 {
139  UnmapWindow();
140  closed_.emit();
141 }
142 
143 void
145 {
146  TGWindow::MapWindow();
147  m_mapped = true;
148 }
149 
150 void
152 {
153  TGWindow::UnmapWindow();
154  m_mapped = false;
155 }
156 
157 void
159 {
160  if(m_viewBase)
162 }
163 
164 void
166 {
170 }
171 
172 void
174 {
176  m_changeBackground->SetText("Change Background Color to White");
177  } else {
178  m_changeBackground->SetText("Change Background Color to Black");
179  }
180 }
181 
182 //==============================================================================
183 
185  TGCompositeFrame(p),
186  m_tab(0),
187  m_selectedTabName("Style")
188 {
189  SetCleanup(kDeepCleanup);
190 }
191 
192 void
194 {
195  // remember selected tab
196  if (m_tab)
197  m_selectedTabName = m_tab->GetCurrentTab()->GetString();
198  else
199  m_selectedTabName = "Style";
200 
201  m_setters.clear();
202  if (m_tab) RemoveFrame(m_tab);
203  m_tab = 0;
204 }
205 
206 
209 {
210  if (!m_tab)
211  {
212  m_tab = new TGTab(this);
213  AddFrame(m_tab, new TGLayoutHints(kLHintsExpandX));
214  }
215 
216  if (!m_tab->GetTabContainer(name))
217  m_tab->AddTab(name);
218 
219  m_tab->SetTab(name);
220 
221  return *this;
222 }
223 
224 /* Add parameter setter in the current tab.*/
227 {
228  boost::shared_ptr<FWParameterSetterBase> ptr( FWParameterSetterBase::makeSetterFor((FWParameterBase*)param) );
229  ptr->attach((FWParameterBase*)param, this);
230  TGCompositeFrame* parent = m_tab->GetCurrentContainer();
231 
232  TGFrame* pframe = ptr->build(parent);
233  parent->AddFrame(pframe, new TGLayoutHints(kLHintsExpandX));
234  m_setters.push_back(ptr);
235 
236  pframe->MapWindow();
237  pframe->MapSubwindows();
238  pframe->Layout();
239  parent->MapSubwindows();
240  parent->Layout();
241  m_tab->Layout();
242  parent->Resize(parent->GetDefaultSize());
243  return *this;
244 }
245 
246 
247 
248 /* Add separator in current tab. */
251 {
252  assert(m_tab);
253  TGHorizontal3DLine* s = new TGHorizontal3DLine(m_tab->GetCurrentContainer());
254  m_tab->GetCurrentContainer()->AddFrame(s, new TGLayoutHints(kLHintsExpandX,4 ,4, 2, 2));
255 
256  return *this;
257 }
258 
259 TGCompositeFrame*
261 {
262  assert (m_tab);
263  return m_tab->GetCurrentContainer();
264 }
265 
266 void
268 {
269  assert (m_tab);
270  TGCompositeFrame* parent = m_tab->GetCurrentContainer();
271  parent->AddFrame(x,new TGLayoutHints(kLHintsExpandX,4 ,4, 2, 2) );
272 
273  parent->MapSubwindows();
274  parent->Layout();
275  m_tab->Layout();
276  parent->Resize(parent->GetDefaultSize());
277 }
278 
279 /* Setup after finish gui build. */
280 void
282 {
283  if (m_tab)
284  {
285  bool x = m_tab->SetTab(m_selectedTabName.c_str(), false);
286  if (!x) m_tab->SetTab("Style");
287  }
288 }
289 
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:114
virtual void UnmapWindow()
static boost::shared_ptr< FWParameterSetterBase > makeSetterFor(FWParameterBase *)
void addFrameToContainer(TGCompositeFrame *)
void setBackgroundColorIndex(BackgroundColorIndex)
BackgroundColorIndex backgroundColorIndex() const
TGTextButton * m_changeBackground
void reset(FWViewBase *, TEveWindow *ew)
FWColorManager * m_colorManager
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
FWViewBase * m_viewBase
ViewerParameterGUI & addParam(const FWParameterBase *)
TGCompositeFrame * getTabContainer()
void backgroundColorWasChanged()
virtual void populateController(ViewerParameterGUI &) const
Definition: FWViewBase.h:49
string s
Definition: asciidump.py:422
TGButton * m_saveImageButton
void promptForSaveImageTo(TGFrame *) const
Definition: FWViewBase.cc:74
sigc::signal< void > colorsHaveChanged_
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
ViewerParameterGUI * m_paramGUI
TEveWindow * m_eveWindow