CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
FWModelContextMenuHandler Class Reference

#include <Fireworks/Core/interface/FWModelContextMenuHandler.h>

Public Member Functions

void addViewEntry (const char *, int, bool enabled=true)
 
void chosenItem (Int_t)
 
 ClassDef (FWModelContextMenuHandler, 0)
 
void colorChangeRequested (Color_t)
 
 FWModelContextMenuHandler (FWSelectionManager *, FWDetailViewManager *, FWColorManager *, FWGUIManager *)
 
void showSelectedModelContext (Int_t iX, Int_t iY, FWViewContextMenuHandlerBase *) const
 NOTE: iX and iY are in global coordinates. More...
 
virtual ~FWModelContextMenuHandler ()
 

Private Member Functions

void createColorPopup () const
 
void createModelContext () const
 
 FWModelContextMenuHandler (const FWModelContextMenuHandler &)
 
const FWModelContextMenuHandleroperator= (const FWModelContextMenuHandler &)
 

Private Attributes

TGMenuEntry * m_afterViewSeperator
 
FWColorManagerm_colorManager
 
FWColorPopupm_colorPopup
 
FWDetailViewManagerm_detailViewManager
 
FWGUIManagerm_guiManager
 
TGPopupMenu * m_modelPopup
 
unsigned int m_nDetailViewEntries
 
unsigned int m_nViewEntries
 
FWSelectionManagerm_selectionManager
 
TGMenuEntry * m_seperator
 
FWViewContextMenuHandlerBasem_viewHander
 
TGMenuEntry * m_viewSeperator
 
Int_t m_x
 
Int_t m_y
 

Detailed Description

Description: Controls the context menus

Usage: This file is used internally by the system

Definition at line 37 of file FWModelContextMenuHandler.h.

Constructor & Destructor Documentation

FWModelContextMenuHandler::FWModelContextMenuHandler ( FWSelectionManager iSM,
FWDetailViewManager iDVM,
FWColorManager iCM,
FWGUIManager iGM 
)

Definition at line 61 of file FWModelContextMenuHandler.cc.

64  :
65 m_modelPopup(0),
66 m_colorPopup(0),
69 m_colorManager(iCM),
70 m_guiManager(iGM),
71 m_seperator(0),
74 m_x(0),
75 m_y(0),
78 m_viewHander(0)
79 {
80 }
FWSelectionManager * m_selectionManager
FWViewContextMenuHandlerBase * m_viewHander
FWDetailViewManager * m_detailViewManager
FWModelContextMenuHandler::~FWModelContextMenuHandler ( )
virtual

Definition at line 87 of file FWModelContextMenuHandler.cc.

References m_modelPopup.

88 {
89  delete m_modelPopup;
90 }
FWModelContextMenuHandler::FWModelContextMenuHandler ( const FWModelContextMenuHandler )
private

Member Function Documentation

void FWModelContextMenuHandler::addViewEntry ( const char *  iEntryName,
int  iEntryIndex,
bool  enabled = true 
)

Definition at line 216 of file FWModelContextMenuHandler.cc.

References assert(), kViewOptionsMO, m_afterViewSeperator, m_modelPopup, m_nViewEntries, and m_viewSeperator.

217 {
218  if(!m_viewSeperator) {
219  m_modelPopup->AddSeparator(m_afterViewSeperator);
220  m_viewSeperator=dynamic_cast<TGMenuEntry*>(m_modelPopup->GetListOfEntries()->Before(m_afterViewSeperator));
221  assert(0!=m_viewSeperator);
222  }
223 
224  if(static_cast<int>(m_nViewEntries) > iEntryIndex) {
225  m_modelPopup->GetEntry(iEntryIndex+kViewOptionsMO)->GetLabel()->SetString(iEntryName);
226  if(enabled)
227  m_modelPopup->EnableEntry(iEntryIndex+kViewOptionsMO);
228  else
229  m_modelPopup->DisableEntry(iEntryIndex+kViewOptionsMO);
230 
231  } else {
232  assert(static_cast<int>(m_nViewEntries) == iEntryIndex);
233  m_modelPopup->AddEntry(iEntryName,kViewOptionsMO+iEntryIndex,0,0,m_viewSeperator);
234 
235  if (enabled)
236  m_modelPopup->EnableEntry(kViewOptionsMO+iEntryIndex);
237  else
238  m_modelPopup->DisableEntry(kViewOptionsMO+iEntryIndex);
239 
240  ++m_nViewEntries;
241  }
242 
243 }
assert(m_qm.get())
void FWModelContextMenuHandler::chosenItem ( Int_t  iChoice)

Definition at line 121 of file FWModelContextMenuHandler.cc.

References assert(), FWColorManager::backgroundColorIndex(), create_public_lumi_plots::color, colors, createColorPopup(), FWDetailViewManager::detailViewsFor(), FWColorManager::fillLimitedColors(), cmsHarvester::index, FWDisplayProperties::isVisible(), FWColorManager::kBlackIndex, kOpen3DRegion, kOpenCollectionControllerMO, kOpenDetailViewMO, kOpenObjectControllerMO, kSetColorMO, kSetVisibleMO, kViewOptionsMO, m_colorManager, m_colorPopup, m_detailViewManager, m_guiManager, m_selectionManager, m_viewHander, m_x, m_y, FWGUIManager::open3DRegion(), FWDetailViewManager::openDetailViewFor(), FWColorPopup::PlacePopup(), FWColorPopup::ResetColors(), FWViewContextMenuHandlerBase::select(), FWSelectionManager::selected(), FWColorPopup::SetName(), FWColorPopup::SetSelection(), FWGUIManager::showEDIFrame(), and FWGUIManager::showModelPopup().

122 {
123  assert(!m_selectionManager->selected().empty());
124  switch (iChoice) {
125  case kSetVisibleMO:
126  {
127  FWModelId id = *(m_selectionManager->selected().begin());
128  const FWDisplayProperties& props = id.item()->modelInfo(id.index()).displayProperties();
129  for_each(m_selectionManager->selected().begin(),
130  m_selectionManager->selected().end(),
131  change_visibility(!props.isVisible())
132  );
133  break;
134  }
135  case kSetColorMO:
136  {
137  FWModelId id = *(m_selectionManager->selected().begin());
139  m_colorPopup->SetName("Selected");
140  std::vector<Color_t> colors;
143  m_colorPopup->SetSelection(id.item()->modelInfo(id.index()).displayProperties().color());
144  m_colorPopup->PlacePopup(m_x, m_y, m_colorPopup->GetDefaultWidth(), m_colorPopup->GetDefaultHeight());
145  break;
146  }/*
147  case kPrint:
148  {
149  FWModelId id = *(m_selectionManager->selected().begin());
150  edm::TypeWithDict rtype(edm::TypeWithDict::byName(id.item()->modelType()->GetName()));
151  edm::ObjectWithDict o(rtype, const_cast<void *>(id.item()->modelData(id.index())));
152 
153  // void* xx = &std::cout;
154  //const std::vector<void*> j(1, xx);
155  //edm::TypeMemberQuery inh = edm::TypeMemberQuery::InheritedAlso;
156  //edm::FunctionWithDict m = rtype.functionMemberByName("print",edm::TypeWithDict(edm::TypeWithDict::byName("void (std::ostream&)"), edm::TypeModifiers::Const), edm::TypeModifiers::NoMod , inh))
157  //m.Invoke(o, 0, j);
158 
159  const char* cmd = Form("FWGUIManager::OStream() << *(%s*)%p ;", id.item()->modelType()->GetName(), (void*)id.item()->modelData(id.index()));
160  //const char* cmd = Form("*((std::ostream*)%p) << (%s*)%p ;", (void*)(&std::cout), id.item()->modelType()->GetName(), (void*)id.item()->modelData(id.index()));
161  std::cout << cmd << std::endl;
162  gROOT->ProcessLine(cmd);
163 
164 
165  break;
166  }*/
168  {
170  break;
171  }
173  {
175  break;
176  }
177  case kOpen3DRegion:
178  {
180  break;
181  }
182  case kOpenDetailViewMO:
183  case kViewOptionsMO:
184  default:
185  {
186  if(iChoice>=kViewOptionsMO) {
187  assert(0!=m_viewHander);
189  }else {
191  assert(m_selectionManager->selected().size()==1);
192  std::vector<std::string> viewChoices = m_detailViewManager->detailViewsFor(*(m_selectionManager->selected().begin()));
193  assert(0!=viewChoices.size());
195  }
196  break;
197  }
198  break;
199  }
200 }
const std::set< FWModelId > & selected() const
void showModelPopup()
FWSelectionManager * m_selectionManager
void SetName(const char *iName)
void open3DRegion()
assert(m_qm.get())
void fillLimitedColors(std::vector< Color_t > &cv) const
void showEDIFrame(int iInfoToShow=-1)
Allowed values are -1 or ones from FWDataCategories enum.
virtual void select(int iEntryIndex, const FWModelId &id, int iX, int iY)=0
void PlacePopup(Int_t x, Int_t y, UInt_t w, UInt_t h)
vector< Color_t > colors
BackgroundColorIndex backgroundColorIndex() const
void ResetColors(const std::vector< Color_t > &colors, bool backgroundIsBlack=true)
void SetSelection(Color_t)
FWViewContextMenuHandlerBase * m_viewHander
std::vector< std::string > detailViewsFor(const FWModelId &) const
FWDetailViewManager * m_detailViewManager
void openDetailViewFor(const FWModelId &, const std::string &)
FWModelContextMenuHandler::ClassDef ( FWModelContextMenuHandler  ,
 
)
void FWModelContextMenuHandler::colorChangeRequested ( Color_t  color)

Definition at line 203 of file FWModelContextMenuHandler.cc.

References m_selectionManager, FWSelectionManager::selected(), and FWDisplayProperties::setColor().

204 {
205  for(std::set<FWModelId>::const_iterator it =m_selectionManager->selected().begin(),
206  itEnd = m_selectionManager->selected().end();
207  it != itEnd;
208  ++it) {
209  FWDisplayProperties changeProperties = it->item()->modelInfo(it->index()).displayProperties();
210  changeProperties.setColor(color);
211  it->item()->setDisplayProperties(it->index(), changeProperties);
212  }
213 }
const std::set< FWModelId > & selected() const
void setColor(Color_t iColor)
FWSelectionManager * m_selectionManager
void FWModelContextMenuHandler::createColorPopup ( ) const
private

Definition at line 361 of file FWModelContextMenuHandler.cc.

References colors, FWColorManager::fillLimitedColors(), FWColorPopup::InitContent(), m_colorManager, and m_colorPopup.

Referenced by chosenItem().

362 {
363  if(0==m_colorPopup) {
364  std::vector<Color_t> colors;
366 
367  m_colorPopup = new FWColorPopup(gClient->GetDefaultRoot(), colors.front());
368  m_colorPopup->InitContent("", colors);
369  m_colorPopup->Connect("ColorSelected(Color_t)","FWModelContextMenuHandler", const_cast<FWModelContextMenuHandler*>(this), "colorChangeRequested(Color_t)");
370  }
371 }
void InitContent(const char *name, const std::vector< Color_t > &colors, bool backgroundIsBlack=true)
void fillLimitedColors(std::vector< Color_t > &cv) const
vector< Color_t > colors
void FWModelContextMenuHandler::createModelContext ( ) const
private

Definition at line 335 of file FWModelContextMenuHandler.cc.

References assert(), kOpen3DRegion, kOpenCollectionControllerMO, kOpenDetailView, kOpenDetailViewMO, kOpenObjectControllerMO, kSetColorMO, kSetVisibleMO, m_afterViewSeperator, m_modelPopup, m_nDetailViewEntries, and m_seperator.

Referenced by showSelectedModelContext().

336 {
337  if(0==m_modelPopup) {
338  m_modelPopup = new FWPopupMenu();
339 
340  m_modelPopup->AddEntry("Set Visible",kSetVisibleMO);
341  m_modelPopup->AddEntry("Set Color ...",kSetColorMO);
342  // m_modelPopup->AddEntry("Print ...",kPrint);
345  m_seperator = dynamic_cast<TGMenuEntry*>(m_modelPopup->GetListOfEntries()->Last());
346  assert(0!=m_seperator);
347  m_modelPopup->AddEntry("Open 3D Region ...",kOpen3DRegion);
348  m_modelPopup->AddSeparator();
349  m_modelPopup->AddEntry("Open Object Controller ...",kOpenObjectControllerMO);
350  m_afterViewSeperator = dynamic_cast<TGMenuEntry*>(m_modelPopup->GetListOfEntries()->Last());
351  m_modelPopup->AddEntry("Open Collection Controller ...",kOpenCollectionControllerMO);
352 
353  m_modelPopup->Connect("Activated(Int_t)",
354  "FWModelContextMenuHandler",
355  const_cast<FWModelContextMenuHandler*>(this),
356  "chosenItem(Int_t)");
357  }
358 }
assert(m_qm.get())
static const char *const kOpenDetailView
const FWModelContextMenuHandler& FWModelContextMenuHandler::operator= ( const FWModelContextMenuHandler )
private
void FWModelContextMenuHandler::showSelectedModelContext ( Int_t  iX,
Int_t  iY,
FWViewContextMenuHandlerBase iHandler 
) const

NOTE: iX and iY are in global coordinates.

Definition at line 248 of file FWModelContextMenuHandler.cc.

References FWViewContextMenuHandlerBase::addTo(), assert(), createModelContext(), FWDetailViewManager::detailViewsFor(), i, cmsHarvester::index, FWDisplayProperties::isVisible(), kOpenDetailView, kOpenDetailViewMO, kSetVisibleMO, kViewOptionsMO, m_detailViewManager, m_modelPopup, m_nDetailViewEntries, m_nViewEntries, m_selectionManager, m_seperator, m_viewHander, m_viewSeperator, m_x, m_y, FWSelectionManager::selected(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by FWGUIManager::showSelectedModelContextMenu().

249 {
250  m_viewHander=iHandler;
251  assert(!m_selectionManager->selected().empty());
253 
254  //setup the menu based on this object
255  FWModelId id = *(m_selectionManager->selected().begin());
256  const FWDisplayProperties& props = id.item()->modelInfo(id.index()).displayProperties();
257  if(props.isVisible()) {
258  m_modelPopup->CheckEntry(kSetVisibleMO);
259  }else {
260  m_modelPopup->UnCheckEntry(kSetVisibleMO);
261  }
262 
263 
264  if( m_selectionManager->selected().size()==1 ) {
265  {
266  //edm::TypeWithDict rtype(edm::TypeWithDict::byName(id.item()->modelType()->GetName()));
267  //edm::ObjectWithDict o(rtype, const_cast<void *>(id.item()->modelData(id.index())));
268  //edm::TypeMemberQuery inh = edm::TypeMemberQuery::InheritedAlso;
269  //if ( rtype.functionMemberByName("print",edm::TypeWithDict(edm::TypeWithDict::byName("void (std::ostream&)"), Long_t(kIsConstant)), 0, inh))
270  //{
271  //m_modelPopup->EnableEntry(kPrint);
272  // std::cout << "Enable " <<std::endl;
273  //}
274  //else
275  //{
276  m_modelPopup->DisableEntry(kPrint);
277  // printf("Disable print \n");
278  //}
279  }
280  //add the detail view entries
281  std::vector<std::string> viewChoices = m_detailViewManager->detailViewsFor(*(m_selectionManager->selected().begin()));
282  if(viewChoices.size()>0) {
283  if(m_nDetailViewEntries < viewChoices.size()) {
284  for(unsigned int index = m_nDetailViewEntries;
285  index != viewChoices.size();
286  ++index) {
288  }
289  m_nDetailViewEntries=viewChoices.size();
290  }
291  const std::string kStart("Open ");
292  const std::string kEnd(" Detail View ...");
293  for(unsigned int index=0; index != viewChoices.size(); ++index) {
294  m_modelPopup->EnableEntry(index+kOpenDetailViewMO); // need to call this to make it visible
295  if ( viewChoices[index][0] != '!') {
296  m_modelPopup->GetEntry(index+kOpenDetailViewMO)->GetLabel()->SetString((kStart+viewChoices[index]+kEnd).c_str());
297  }
298  else
299  {
300  m_modelPopup->GetEntry(index+kOpenDetailViewMO)->GetLabel()->SetString((kStart+&viewChoices[index][1]+kEnd).c_str());
301  m_modelPopup->DisableEntry(index+kOpenDetailViewMO);
302  }
303  }
304  for(unsigned int i =viewChoices.size(); i <m_nDetailViewEntries; ++i) {
305  m_modelPopup->HideEntry(kOpenDetailViewMO+i);
306  }
307 
308  } else {
309  for(unsigned int i =0; i <m_nDetailViewEntries; ++i) {
310  m_modelPopup->HideEntry(kOpenDetailViewMO+i);
311  }
312  }
313  } else {
314  for(unsigned int i =0; i <m_nDetailViewEntries; ++i) {
315  m_modelPopup->HideEntry(kOpenDetailViewMO+i);
316  }
317  }
318  //add necessary entries from the view
319  m_modelPopup->DeleteEntry(m_viewSeperator);
320  m_viewSeperator=0;
321 
322  for(unsigned int i=0; i<m_nViewEntries; ++i) {
323  m_modelPopup->HideEntry(kViewOptionsMO+i);
324  }
325  if(m_viewHander) {
326  m_viewHander->addTo(const_cast<FWModelContextMenuHandler&>(*this), *(m_selectionManager->selected().begin()));
327  }
328 
329  m_x=iX;
330  m_y=iY;
331  m_modelPopup->PlaceMenu(iX,iY,false,true);
332 }
const std::set< FWModelId > & selected() const
int i
Definition: DBlmapReader.cc:9
FWSelectionManager * m_selectionManager
assert(m_qm.get())
static const char *const kOpenDetailView
FWViewContextMenuHandlerBase * m_viewHander
void addTo(FWModelContextMenuHandler &, const FWModelId &id)
std::vector< std::string > detailViewsFor(const FWModelId &) const
FWDetailViewManager * m_detailViewManager

Member Data Documentation

TGMenuEntry* FWModelContextMenuHandler::m_afterViewSeperator
mutableprivate

Definition at line 75 of file FWModelContextMenuHandler.h.

Referenced by addViewEntry(), and createModelContext().

FWColorManager* FWModelContextMenuHandler::m_colorManager
private

Definition at line 71 of file FWModelContextMenuHandler.h.

Referenced by chosenItem(), and createColorPopup().

FWColorPopup* FWModelContextMenuHandler::m_colorPopup
mutableprivate

Definition at line 68 of file FWModelContextMenuHandler.h.

Referenced by chosenItem(), and createColorPopup().

FWDetailViewManager* FWModelContextMenuHandler::m_detailViewManager
private

Definition at line 70 of file FWModelContextMenuHandler.h.

Referenced by chosenItem(), and showSelectedModelContext().

FWGUIManager* FWModelContextMenuHandler::m_guiManager
private

Definition at line 72 of file FWModelContextMenuHandler.h.

Referenced by chosenItem().

TGPopupMenu* FWModelContextMenuHandler::m_modelPopup
mutableprivate
unsigned int FWModelContextMenuHandler::m_nDetailViewEntries
mutableprivate

Definition at line 78 of file FWModelContextMenuHandler.h.

Referenced by createModelContext(), and showSelectedModelContext().

unsigned int FWModelContextMenuHandler::m_nViewEntries
mutableprivate

Definition at line 79 of file FWModelContextMenuHandler.h.

Referenced by addViewEntry(), and showSelectedModelContext().

FWSelectionManager* FWModelContextMenuHandler::m_selectionManager
private
TGMenuEntry* FWModelContextMenuHandler::m_seperator
mutableprivate

Definition at line 73 of file FWModelContextMenuHandler.h.

Referenced by createModelContext(), and showSelectedModelContext().

FWViewContextMenuHandlerBase* FWModelContextMenuHandler::m_viewHander
mutableprivate

Definition at line 80 of file FWModelContextMenuHandler.h.

Referenced by chosenItem(), and showSelectedModelContext().

TGMenuEntry* FWModelContextMenuHandler::m_viewSeperator
mutableprivate

Definition at line 74 of file FWModelContextMenuHandler.h.

Referenced by addViewEntry(), and showSelectedModelContext().

Int_t FWModelContextMenuHandler::m_x
mutableprivate

Definition at line 76 of file FWModelContextMenuHandler.h.

Referenced by chosenItem(), and showSelectedModelContext().

Int_t FWModelContextMenuHandler::m_y
mutableprivate

Definition at line 77 of file FWModelContextMenuHandler.h.

Referenced by chosenItem(), and showSelectedModelContext().