CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CmsShowEDI.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Core
4 // Class : CmsShowEDI
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Joshua Berger
10 // Created: Mon Jun 23 15:48:11 EDT 2008
11 // $Id: CmsShowEDI.cc,v 1.42 2010/12/06 16:11:38 amraktad Exp $
12 //
13 
14 // system include files
15 #include <iostream>
16 #include <sstream>
17 #include <sigc++/sigc++.h>
18 #include <boost/bind.hpp>
19 #include "TClass.h"
20 #include "TGFrame.h"
21 #include "TGTab.h"
22 #include "TGButton.h"
23 #include "TGLabel.h"
24 #include "TGString.h"
25 #include "TColor.h"
26 #include "TG3DLine.h"
27 #include "TGNumberEntry.h"
28 #include "TGTextEntry.h"
29 #include "TGTextView.h"
30 #include "TGLayout.h"
31 #include "TGFont.h"
32 #include "TEveManager.h"
33 #include "TGSlider.h"
34 #include "TGMsgBox.h"
35 #include "TGComboBox.h"
36 
37 // user include files
51 
52 //
53 // constants, enums and typedefs
55 
56 //
57 // static data member definitions
58 //
59 
60 //
61 // constructors and destructor
62 //
63 CmsShowEDI::CmsShowEDI(const TGWindow* p, UInt_t w, UInt_t h, FWSelectionManager* selMgr, FWColorManager* colorMgr) :
64  TGTransientFrame(gClient->GetDefaultRoot(),p, w, h),
65  m_item(0),
66  m_validator( new FWExpressionValidator),
67  m_colorManager(colorMgr)
68 {
69  m_selectionManager = selMgr;
70  SetCleanup(kDeepCleanup);
71 
73 
74  TGVerticalFrame* vf = new TGVerticalFrame(this);
75  AddFrame(vf, new TGLayoutHints(kLHintsExpandX|kLHintsExpandY, 0, 0, 0, 0));
76  FWDialogBuilder builder(vf);
77 
78  builder.indent(0)
79  .addLabel(" ", 14, 2, &m_objectLabel)
80  .vSpacer()
81  .tabs(&m_tabs)
82  .beginTab("Graphics")
83  .indent(3)
84  .addLabel("Color", 8)
85  .addColorPicker(colorMgr, &m_colorSelectWidget).expand(false)
86  .addHSeparator()
87  .addLabel("Opacity", 8)
89  .addHSeparator()
90  .addCheckbox("Visible", &m_isVisibleButton)
91  .addHSeparator()
92  .addLabel("Drawing order", 8)
93  .addTextButton("To back", &m_backButton).floatLeft().expand(false)
94  .addNumberEntry(0.0, 4, TGNumberFormat::kNESInteger,
97  &m_layerEntry).expand(false).floatLeft()
98  .addTextButton("To front", &m_frontButton).expand(false)
99  .vSpacer()
100  .endTab()
101  .beginTab("Filter")
102  .indent(3)
103  .addLabel("Expression", 8)
105  .addTextButton("Filter", &m_filterButton).expand(false)
107  .vSpacer()
108  .endTab()
109  .beginTab("Select")
110  .indent(3)
111  .addLabel("Expression", 8)
113  .addTextButton("Select", &m_selectButton).floatLeft().expand(false)
114  .addTextButton("Select all", &m_selectAllButton).expand(false)
116  .vSpacer()
117  .endTab()
118  .beginTab("Data")
119  .indent(3)
120  .addLabel("Name:", 8)
121  .addTextEntry("None", &m_nameEntry)
122  .addLabel("Labels:", 8)
123  .addLabel("Type:", 8)
124  .addTextEntry("None", &m_typeEntry)
125  .addLabel("Module:", 8)
126  .addTextEntry("None", &m_moduleEntry)
127  .addLabel("Instance:", 8)
128  .addTextEntry("None", &m_instanceEntry)
129  .addLabel("Process:", 8)
130  .addTextEntry("None", &m_processEntry)
131  .addHSeparator()
132  .addTextButton("Remove collection", &m_removeButton).expand(false)
133  .vSpacer()
134  .endTab()
135  .untabs();
136 
137  m_filterError->SetForegroundColor(gVirtualX->GetPixel(kRed));
138  m_filterError->SetBackgroundColor(TGFrame::GetDefaultFrameBackground());
139  m_filterError->ChangeOptions(0);
140 
141  m_selectError->SetForegroundColor(gVirtualX->GetPixel(kRed));
142  m_selectError->SetBackgroundColor(TGFrame::GetDefaultFrameBackground());
143  m_selectError->ChangeOptions(0);
144 
147 
148  m_colorSelectWidget->Connect("ColorChosen(Color_t)", "CmsShowEDI", this, "changeItemColor(Color_t)");
149  m_opacitySlider->Connect("PositionChanged(Int_t)", "CmsShowEDI", this, "changeItemOpacity(Int_t)");
150  m_isVisibleButton->Connect("Toggled(Bool_t)", "CmsShowEDI", this, "toggleItemVisible(Bool_t)");
151  m_filterExpressionEntry->Connect("ReturnPressed()", "CmsShowEDI", this, "runFilter()");
152  m_filterButton->Connect("Clicked()", "CmsShowEDI", this, "runFilter()");
153  m_selectExpressionEntry->Connect("ReturnPressed()", "CmsShowEDI", this, "runSelection()");
154  m_selectButton->Connect("Clicked()", "CmsShowEDI", this, "runSelection()");
155  m_removeButton->Connect("Clicked()", "CmsShowEDI", this, "removeItem()");
156  m_selectAllButton->Connect("Clicked()", "CmsShowEDI", this, "selectAll()");
157  m_frontButton->Connect("Clicked()","CmsShowEDI",this,"moveToFront()");
158  m_backButton->Connect("Clicked()","CmsShowEDI",this,"moveToBack()");
159  m_layerEntry->Connect("ValueSet(Long_t)","CmsShowEDI",this,"moveToLayer(Long_t)");
160 
161  SetWindowName("Collection Controller");
162  MapSubwindows();
163  Resize(GetDefaultSize());
164  Layout();
165 
166  fillEDIFrame();
167 }
168 
169 // CmsShowEDI::CmsShowEDI(const CmsShowEDI& rhs)
170 // {
171 // // do actual copying here;
172 // }
173 
175 {
176  disconnectAll();
177  m_colorSelectWidget->Disconnect("ColorSelected(Pixel_t)", this, "changeItemColor(Pixel_t)");
178  m_opacitySlider->Disconnect("PositionChanged(Int_t)", this, "changeItemColor");
179  m_isVisibleButton->Disconnect("Toggled(Bool_t)", this, "toggleItemVisible(Bool_t)");
180  m_filterExpressionEntry->Disconnect("ReturnPressed()", this, "runFilter()");
181  m_selectExpressionEntry->Disconnect("ReturnPressed()", this, "runSelection()");
182  m_filterButton->Disconnect("Clicked()", this, "runFilter()");
183  m_selectButton->Disconnect("Clicked()", this, "runSelection()");
184  m_selectAllButton->Disconnect("Clicked()", this, "selectAll()");
185  m_removeButton->Disconnect("Clicked()", this, "removeItem()");
186  m_frontButton->Disconnect("Clicked()",this,"moveToFront()");
187  m_backButton->Disconnect("Clicked()",this,"moveToBack()");
188  m_layerEntry->Disconnect("ValueSet(Long_t)",this,"moveToLayer(Long_t)");
189  // delete m_objectLabel;
190  // delete m_colorSelectWidget;
191  // delete m_isVisibleButton;
192  delete m_validator;
193 }
194 
195 //
196 // assignment operators
197 //
198 // const CmsShowEDI& CmsShowEDI::operator=(const CmsShowEDI& rhs)
199 // {
200 // //An exception safe implementation is
201 // CmsShowEDI temp(rhs);
202 // swap(rhs);
203 //
204 // return *this;
205 // }
206 
207 //
208 // member functions
209 //
210 void
212  FWEventItem* iItem =0;
213  bool multipleCollections = false;
214  if(!m_selectionManager->selectedItems().empty()) {
215  if(m_selectionManager->selectedItems().size()==1) {
216  iItem=*(m_selectionManager->selectedItems().begin());
217  } else {
218  multipleCollections=true;
219  }
220  }
221  //m_item can be zero because we had 0 or many collections selected
222  if (0 == m_item || iItem != m_item) {
223  disconnectAll();
224  m_item = iItem;
225  if(0 != m_item) {
227  m_objectLabel->SetText(iItem->name().c_str());
229  m_opacitySlider->SetPosition(100 - p.transparency());
230  m_isVisibleButton->SetDisabledAndSelected(p.isVisible());
231  m_validator->setType(ROOT::Reflex::Type::ByTypeInfo(*(iItem->modelType()->GetTypeInfo())));
232  m_filterExpressionEntry->SetText(iItem->filterExpression().c_str());
233  m_filterError->Clear();
234  m_selectError->Clear();
235  m_nameEntry->SetText(iItem->name().c_str());
236  m_typeEntry->SetText(iItem->type()->GetName());
237  m_moduleEntry->SetText(iItem->moduleLabel().c_str());
238  m_instanceEntry->SetText(iItem->productInstanceLabel().c_str());
239  m_processEntry->SetText(iItem->processName().c_str());
240  // else m_isVisibleButton->SetState(kButtonDown, kFALSE);
241  m_colorSelectWidget->SetEnabled(kTRUE);
242  m_opacitySlider->SetEnabled(kTRUE);
243  m_isVisibleButton->SetEnabled(kTRUE);
244  m_filterExpressionEntry->SetEnabled(kTRUE);
245  m_selectExpressionEntry->SetEnabled(kTRUE);
246  m_filterButton->SetEnabled(kTRUE);
247  m_selectButton->SetEnabled(kTRUE);
248  m_selectAllButton->SetEnabled(kTRUE);
249  m_removeButton->SetEnabled(kTRUE);
251  m_layerEntry->SetState(kTRUE);
253  m_modelChangedConn = m_item->changed_.connect(boost::bind(&CmsShowEDI::updateFilter, this));
254  // m_selectionChangedConn = m_selectionManager->selectionChanged_.connect(boost::bind(&CmsShowEDI::updateSelection, this));
256  } else if(multipleCollections) {
257  std::ostringstream s;
258  s<<m_selectionManager->selectedItems().size()<<" Collections Selected";
259  m_objectLabel->SetText(s.str().c_str());
260  }
261 
262  Resize(GetDefaultSize());
263  Layout();
264  }
265 }
266 
267 void
269  Int_t chosen=0;
270  std::string message("This action will remove the ");
271  message += m_item->name();
272  message +=" collection from the display."
273  "\nIf you wish to return the collection you would have to use the 'Add Collection' window.";
274  new TGMsgBox(gClient->GetDefaultRoot(),
275  this,
276  "Remove Collection Confirmation",
277  message.c_str(),
278  kMBIconExclamation,
279  kMBCancel | kMBApply,
280  &chosen);
281  if(kMBApply == chosen) {
282  m_item->destroy();
283  m_item = 0;
284  //make sure the ROOT global editor does not try to use this
285  gEve->EditElement(0);
286  gEve->Redraw3D();
287  }
288 }
289 
290 void
292  //std::cout<<"Updating display"<<std::endl;
294  m_colorSelectWidget->SetColorByIndex(props.color(),kFALSE);
295  m_opacitySlider->SetPosition(100 - props.transparency());
296  m_isVisibleButton->SetState(props.isVisible() ? kButtonDown : kButtonUp, kFALSE);
297 }
298 
299 void
301 {
302  m_backButton->SetEnabled(!m_item->isInBack());
303  m_frontButton->SetEnabled(!m_item->isInFront());
304  m_layerEntry->SetIntNumber(m_item->layer());
305 }
306 void
308 {
309  m_item->moveToBack();
311 }
312 void
314 {
315  m_item->moveToFront();
317 }
318 void
320 {
321  m_item->moveToLayer(static_cast<Int_t>(m_layerEntry->GetIntNumber()));
323 }
324 
325 void
327  m_filterExpressionEntry->SetText(m_item->filterExpression().c_str());
328 }
329 
330 void
332  m_objectLabel->SetText("No Collection Selected");
333  if(0 != m_item) {
334  m_displayChangedConn.disconnect();
335  m_modelChangedConn.disconnect();
336  m_destroyedConn.disconnect();
337  m_item = 0;
339  m_opacitySlider->SetPosition(100);
340  m_isVisibleButton->SetDisabledAndSelected(kTRUE);
341  m_filterExpressionEntry->SetText(0);
342  m_selectExpressionEntry->SetText(0);
343  m_nameEntry->SetText(0);
344  m_typeEntry->SetText(0);
345  m_moduleEntry->SetText(0);
346  m_instanceEntry->SetText(0);
347  m_processEntry->SetText(0);
348  // else m_isVisibleButton->SetState(kButtonDown, kFALSE);
349  m_colorSelectWidget->SetEnabled(kFALSE);
350  m_opacitySlider->SetEnabled(kFALSE);
351 
352  m_isVisibleButton->SetEnabled(kFALSE);
353  m_filterExpressionEntry->SetEnabled(kFALSE);
354  m_filterButton->SetEnabled(kFALSE);
355  m_selectExpressionEntry->SetEnabled(kFALSE);
356  m_selectButton->SetEnabled(kFALSE);
357  m_selectAllButton->SetEnabled(kFALSE);
358  m_removeButton->SetEnabled(kFALSE);
359  m_backButton->SetEnabled(kFALSE);
360  m_frontButton->SetEnabled(kFALSE);
361  m_layerEntry->SetIntNumber(0);
362  m_layerEntry->SetState(kFALSE);
363  m_layerEntry->GetNumberEntry()->SetEnabled(kFALSE);
364  m_layerEntry->GetButtonUp()->SetEnabled(kFALSE);
365  m_layerEntry->GetButtonDown()->SetEnabled(kFALSE);
366  }
367 }
368 
375 void
378  changeProperties.setColor(color);
379  m_item->setDefaultDisplayProperties(changeProperties);
380 }
381 
383 void
386  changeProperties.setIsVisible(on);
387  m_item->setDefaultDisplayProperties(changeProperties);
388 }
389 
397 void
400  changeProperties.setTransparency(100 - opacity);
401  m_item->setDefaultDisplayProperties(changeProperties);
402 }
403 
404 void
406  const std::string filter(m_filterExpressionEntry->GetText());
407  if (m_item != 0) {
408  try {
409  m_filterError->Clear();
411  } catch( const FWExpressionException& e) {
412  m_filterError->AddLine(e.what().c_str());
413  m_filterError->Update();
414  if(e.column() > -1) {
415  m_filterExpressionEntry->SetCursorPosition(e.column());
416  }
417  }
418  }
419 }
420 
421 
422 
423 void
425  FWModelExpressionSelector selector;
426  const std::string selection(m_selectExpressionEntry->GetText());
427  if (m_item != 0){
428  try {
429  m_selectError->Clear();
430  //NOTE call clearModelSelectionLeaveItem so that the item does not get deselected
431  // just for safety use a copy of the pointer to m_item
432  FWEventItem* item = m_item;
433  item->selectionManager()-> clearModelSelectionLeaveItem();
434 
435  selector.select(item, selection);
436  } catch( const FWExpressionException& e) {
437  m_selectError->AddLine(e.what().c_str());
438  m_selectError->Update();
439  if(e.column() > -1) {
440  m_selectExpressionEntry->SetCursorPosition(e.column());
441  }
442  }
443  }
444 }
445 
446 void
448  FWChangeSentry sentry(*(m_item->changeManager()));
449  for (int i = 0; i < static_cast<int>(m_item->size()); i++) {
450  m_item->select(i);
451  }
452 }
453 void
455 {
456  m_tabs->SetTab(iToView);
457 }
458 
459 /* Called by FWGUIManager when change background/colorset. */
460 void
462 {
463  if (m_item)
464  {
467  }
468 }
int i
Definition: DBlmapReader.cc:9
const FWDisplayProperties & defaultDisplayProperties() const
Definition: FWEventItem.cc:451
FWDialogBuilder & addHSlider(size_t size, TGHSlider **out=0)
void fillEDIFrame()
Definition: CmsShowEDI.cc:211
void setColor(Color_t iColor)
FWModelChangeManager * changeManager() const
Definition: FWEventItem.h:130
sigc::connection m_displayChangedConn
Definition: CmsShowEDI.h:119
const std::string & what() const
TGHSlider * m_opacitySlider
Definition: CmsShowEDI.h:105
void destroy() const
Definition: FWEventItem.cc:614
void colorSetChanged()
Definition: CmsShowEDI.cc:461
void moveToBack()
Definition: FWEventItem.cc:343
void moveToFront()
Definition: FWEventItem.cc:320
TGCheckButton * m_isVisibleButton
Definition: CmsShowEDI.h:106
FWGUIValidatingTextEntry * m_filterExpressionEntry
Definition: CmsShowEDI.h:107
void moveToLayer(int layer)
Definition: FWEventItem.cc:366
void SetColorByIndex(Color_t iColor)
FWDialogBuilder & endTab(void)
const std::string & name() const
Definition: FWEventItem.cc:500
FWDialogBuilder & addLabel(const char *text, size_t fontSize=12, size_t weight=0, TGLabel **out=0)
const std::string & filterExpression() const
Definition: FWEventItem.cc:608
FWItemChangeSignal defaultDisplayPropertiesChanged_
Definition: FWEventItem.h:204
TGLabel * m_objectLabel
Definition: CmsShowEDI.h:99
TGTab * m_tabs
Definition: CmsShowEDI.h:98
FWItemChangeSignal goingToBeDestroyed_
Definition: FWEventItem.h:211
void disconnectAll()
Definition: CmsShowEDI.cc:331
const std::string & processName() const
Definition: FWEventItem.cc:529
const std::set< FWEventItem * > & selectedItems() const
TGTextButton * m_selectAllButton
Definition: CmsShowEDI.h:111
void moveToLayer(Long_t)
Definition: CmsShowEDI.cc:319
void updateFilter()
Definition: CmsShowEDI.cc:326
static int maxLayerValue()
Definition: FWEventItem.cc:55
FWDialogBuilder & vSpacer(size_t size=0)
void moveToFront()
Definition: CmsShowEDI.cc:313
Color_t color() const
int layer() const
Definition: FWEventItem.cc:457
FWDialogBuilder & untabs(void)
TGTextEntry * m_instanceEntry
Definition: CmsShowEDI.h:115
void removeItem()
Definition: CmsShowEDI.cc:268
Char_t transparency() const
void setDefaultDisplayProperties(const FWDisplayProperties &)
Definition: FWEventItem.cc:165
const std::string & productInstanceLabel() const
Definition: FWEventItem.cc:523
void updateDisplay()
Definition: CmsShowEDI.cc:291
void changeItemColor(Color_t color)
Definition: CmsShowEDI.cc:376
TGNumberEntry * m_layerEntry
Definition: CmsShowEDI.h:103
FWDialogBuilder & addTextButton(const char *text, TGTextButton **out=0)
void moveToBack()
Definition: CmsShowEDI.cc:307
const TClass * type() const
Definition: FWEventItem.cc:506
bool select(FWEventItem *iItem, const std::string &iExpression) const
FWDialogBuilder & addTextView(const char *defaultText=0, TGTextView **out=0)
void setValidator(FWValidatorBase *)
TGTextButton * m_backButton
Definition: CmsShowEDI.h:102
TGTextEntry * m_moduleEntry
Definition: CmsShowEDI.h:114
sigc::connection m_destroyedConn
Definition: CmsShowEDI.h:121
FWDialogBuilder & addHSeparator(size_t horizontalPadding=4, size_t verticalPadding=3)
static int minLayerValue()
Definition: FWEventItem.cc:50
FWDialogBuilder & tabs(TGTab **out)
void changeItemOpacity(Int_t opacity)
Definition: CmsShowEDI.cc:398
FWSelectionManager * selectionManager() const
Definition: FWEventItem.h:133
unsigned int UInt_t
Definition: FUTypes.h:12
FWDialogBuilder & addValidatingTextEntry(const char *defaultText, FWGUIValidatingTextEntry **out)
TGTextView * m_selectError
Definition: CmsShowEDI.h:124
FWDialogBuilder & addTextEntry(const char *defaultText, TGTextEntry **out)
TGTextButton * m_removeButton
Definition: CmsShowEDI.h:100
virtual ~CmsShowEDI()
Definition: CmsShowEDI.cc:174
bool isInBack() const
returns true if item is behind all other items
Definition: FWEventItem.cc:478
tuple filter
USE THIS FOR SKIMMED TRACKS process.p = cms.Path(process.hltLevel1GTSeed*process.skimming*process.offlineBeamSpot*process.TrackRefitter2) OTHERWISE USE THIS.
Definition: align_tpl.py:86
size_t size() const
Definition: FWEventItem.cc:548
FWDialogBuilder & floatLeft(size_t spacing=3)
FWExpressionValidator * m_validator
Definition: CmsShowEDI.h:125
bool isInFront() const
returns true if item is in front of all other items
Definition: FWEventItem.cc:463
void setFilterExpression(const std::string &)
Definition: FWEventItem.cc:209
TGTextView * m_filterError
Definition: CmsShowEDI.h:123
TGTextEntry * m_processEntry
Definition: CmsShowEDI.h:116
string message
Definition: argparse.py:126
FWDialogBuilder & expand(size_t expandX=true, size_t expandY=false)
void setTransparency(Char_t transparency)
sigc::signal< void, const FWSelectionManager & > itemSelectionChanged_
FWColorSelect * m_colorSelectWidget
Definition: CmsShowEDI.h:104
void runFilter()
Definition: CmsShowEDI.cc:405
CmsShowEDI(const TGWindow *p=0, UInt_t w=1, UInt_t h=1, FWSelectionManager *selMgr=0, FWColorManager *colorMgr=0)
Definition: CmsShowEDI.cc:63
FWModelChangeSignal changed_
Definition: FWEventItem.h:192
TGTextButton * m_filterButton
Definition: CmsShowEDI.h:109
const TClass * modelType() const
Definition: FWEventItem.cc:561
FWSelectionManager * m_selectionManager
Definition: CmsShowEDI.h:97
TGTextEntry * m_typeEntry
Definition: CmsShowEDI.h:113
void toggleItemVisible(Bool_t on=kTRUE)
Definition: CmsShowEDI.cc:384
void select(int iIndex) const
Definition: FWEventItem.cc:260
FWDialogBuilder & beginTab(const char *label)
void runSelection()
Definition: CmsShowEDI.cc:424
string s
Definition: asciidump.py:422
FWEventItem * m_item
Definition: CmsShowEDI.h:117
void setIsVisible(bool iSet)
sigc::connection m_modelChangedConn
Definition: CmsShowEDI.h:120
void updateLayerControls()
Definition: CmsShowEDI.cc:300
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
FWGUIValidatingTextEntry * m_selectExpressionEntry
Definition: CmsShowEDI.h:108
TGTextEntry * m_nameEntry
Definition: CmsShowEDI.h:112
FWDialogBuilder & addCheckbox(const char *text, TGCheckButton **out=0)
FWDialogBuilder & indent(int left=2, int right=-1)
FWDialogBuilder & addNumberEntry(float defaultValue, size_t digits, TGNumberFormat::EStyle style, int min, int max, TGNumberEntry **out)
TGTextButton * m_frontButton
Definition: CmsShowEDI.h:101
void setType(const ROOT::Reflex::Type &)
const std::string & moduleLabel() const
Definition: FWEventItem.cc:518
void show(FWDataCategories)
Definition: CmsShowEDI.cc:454
TGTextButton * m_selectButton
Definition: CmsShowEDI.h:110
FWDialogBuilder & addColorPicker(const FWColorManager *manager, FWColorSelect **out=0)
void selectAll()
Definition: CmsShowEDI.cc:447