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 38 of file FWModelContextMenuHandler.h.

Constructor & Destructor Documentation

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

Definition at line 58 of file FWModelContextMenuHandler.cc.

61  :
62 m_modelPopup(0),
63 m_colorPopup(0),
66 m_colorManager(iCM),
67 m_guiManager(iGM),
68 m_seperator(0),
71 m_x(0),
72 m_y(0),
75 m_viewHander(0)
76 {
77 }
FWSelectionManager * m_selectionManager
FWViewContextMenuHandlerBase * m_viewHander
FWDetailViewManager * m_detailViewManager
FWModelContextMenuHandler::~FWModelContextMenuHandler ( )
virtual

Definition at line 84 of file FWModelContextMenuHandler.cc.

References m_modelPopup.

85 {
86  delete m_modelPopup;
87 }
FWModelContextMenuHandler::FWModelContextMenuHandler ( const FWModelContextMenuHandler )
private

Member Function Documentation

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

Definition at line 208 of file FWModelContextMenuHandler.cc.

References kViewOptionsMO, m_afterViewSeperator, m_modelPopup, m_nViewEntries, and m_viewSeperator.

209 {
210  if(!m_viewSeperator) {
211  m_modelPopup->AddSeparator(m_afterViewSeperator);
212  m_viewSeperator=dynamic_cast<TGMenuEntry*>(m_modelPopup->GetListOfEntries()->Before(m_afterViewSeperator));
213  assert(0!=m_viewSeperator);
214  }
215 
216  if(static_cast<int>(m_nViewEntries) > iEntryIndex) {
217  m_modelPopup->GetEntry(iEntryIndex+kViewOptionsMO)->GetLabel()->SetString(iEntryName);
218  if(enabled)
219  m_modelPopup->EnableEntry(iEntryIndex+kViewOptionsMO);
220  else
221  m_modelPopup->DisableEntry(iEntryIndex+kViewOptionsMO);
222 
223  } else {
224  assert(static_cast<int>(m_nViewEntries) == iEntryIndex);
225  m_modelPopup->AddEntry(iEntryName,kViewOptionsMO+iEntryIndex,0,0,m_viewSeperator);
226 
227  if (enabled)
228  m_modelPopup->EnableEntry(kViewOptionsMO+iEntryIndex);
229  else
230  m_modelPopup->DisableEntry(kViewOptionsMO+iEntryIndex);
231 
232  ++m_nViewEntries;
233  }
234 
235 }
void FWModelContextMenuHandler::chosenItem ( Int_t  iChoice)

Definition at line 118 of file FWModelContextMenuHandler.cc.

References FWColorManager::backgroundColorIndex(), asciidump::cmd, colors, gather_cfg::cout, createColorPopup(), FWDetailViewManager::detailViewsFor(), FWColorManager::fillLimitedColors(), getHLTprescales::index, FWDisplayProperties::isVisible(), FWColorManager::kBlackIndex, kOpenCollectionControllerMO, kOpenDetailViewMO, kOpenObjectControllerMO, kPrint, kSetColorMO, kSetVisibleMO, kViewOptionsMO, m_colorManager, m_colorPopup, m_detailViewManager, m_guiManager, m_selectionManager, m_viewHander, m_x, m_y, connectstrParser::o, FWDetailViewManager::openDetailViewFor(), FWColorPopup::PlacePopup(), FWColorPopup::ResetColors(), FWViewContextMenuHandlerBase::select(), FWSelectionManager::selected(), FWColorPopup::SetName(), FWColorPopup::SetSelection(), FWGUIManager::showEDIFrame(), and FWGUIManager::showModelPopup().

119 {
120  assert(!m_selectionManager->selected().empty());
121  switch (iChoice) {
122  case kSetVisibleMO:
123  {
124  FWModelId id = *(m_selectionManager->selected().begin());
125  const FWDisplayProperties& props = id.item()->modelInfo(id.index()).displayProperties();
126  for_each(m_selectionManager->selected().begin(),
127  m_selectionManager->selected().end(),
128  change_visibility(!props.isVisible())
129  );
130  break;
131  }
132  case kSetColorMO:
133  {
134  FWModelId id = *(m_selectionManager->selected().begin());
136  m_colorPopup->SetName("Selected");
137  std::vector<Color_t> colors;
140  m_colorPopup->SetSelection(id.item()->modelInfo(id.index()).displayProperties().color());
141  m_colorPopup->PlacePopup(m_x, m_y, m_colorPopup->GetDefaultWidth(), m_colorPopup->GetDefaultHeight());
142  break;
143  }
144  case kPrint:
145  {
146  using namespace Reflex;
147  FWModelId id = *(m_selectionManager->selected().begin());
148  Type rtype(ROOT::Reflex::Type::ByName(id.item()->modelType()->GetName()));
149  Object o(rtype, const_cast<void *>(id.item()->modelData(id.index())));
150 
151  // void* xx = &std::cout;
152  //const std::vector<void*> j(1, xx);
153  //Member m = rtype.FunctionMemberByName("print",Type(Type::ByName("void (std::ostream&)"), CONST), 0 ,INHERITEDMEMBERS_ALSO );
154  //m.Invoke(o, 0, j);
155 
156  const char* cmd = Form("FWGUIManager::OStream() << *(%s*)%p ;", id.item()->modelType()->GetName(), (void*)id.item()->modelData(id.index()));
157  //const char* cmd = Form("*((std::ostream*)%p) << (%s*)%p ;", (void*)(&std::cout), id.item()->modelType()->GetName(), (void*)id.item()->modelData(id.index()));
158  std::cout << cmd << std::endl;
159  gROOT->ProcessLine(cmd);
160 
161 
162  break;
163  }
165  {
167  break;
168  }
170  {
172  break;
173  }
174  case kOpenDetailViewMO:
175  case kViewOptionsMO:
176  default:
177  {
178  if(iChoice>=kViewOptionsMO) {
179  assert(0!=m_viewHander);
181  }else {
182  assert(iChoice<kOpenObjectControllerMO);
183  assert(m_selectionManager->selected().size()==1);
184  std::vector<std::string> viewChoices = m_detailViewManager->detailViewsFor(*(m_selectionManager->selected().begin()));
185  assert(0!=viewChoices.size());
187  }
188  break;
189  }
190  break;
191  }
192 }
const std::set< FWModelId > & selected() const
void showModelPopup()
FWSelectionManager * m_selectionManager
void SetName(const char *iName)
std::vector< Color_t > colors
Definition: eve_filter.cc:26
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)
BackgroundColorIndex backgroundColorIndex() const
string cmd
Definition: asciidump.py:19
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 &)
tuple cout
Definition: gather_cfg.py:41
FWModelContextMenuHandler::ClassDef ( FWModelContextMenuHandler  ,
 
)
void FWModelContextMenuHandler::colorChangeRequested ( Color_t  color)

Definition at line 195 of file FWModelContextMenuHandler.cc.

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

196 {
197  for(std::set<FWModelId>::const_iterator it =m_selectionManager->selected().begin(),
198  itEnd = m_selectionManager->selected().end();
199  it != itEnd;
200  ++it) {
201  FWDisplayProperties changeProperties = it->item()->modelInfo(it->index()).displayProperties();
202  changeProperties.setColor(color);
203  it->item()->setDisplayProperties(it->index(), changeProperties);
204  }
205 }
const std::set< FWModelId > & selected() const
void setColor(Color_t iColor)
FWSelectionManager * m_selectionManager
void FWModelContextMenuHandler::createColorPopup ( ) const
private

Definition at line 346 of file FWModelContextMenuHandler.cc.

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

Referenced by chosenItem().

347 {
348  if(0==m_colorPopup) {
349  std::vector<Color_t> colors;
351 
352  m_colorPopup = new FWColorPopup(gClient->GetDefaultRoot(), colors.front());
353  m_colorPopup->InitContent("", colors);
354  m_colorPopup->Connect("ColorSelected(Color_t)","FWModelContextMenuHandler", const_cast<FWModelContextMenuHandler*>(this), "colorChangeRequested(Color_t)");
355  }
356 }
void InitContent(const char *name, const std::vector< Color_t > &colors, bool backgroundIsBlack=true)
std::vector< Color_t > colors
Definition: eve_filter.cc:26
void fillLimitedColors(std::vector< Color_t > &cv) const
void FWModelContextMenuHandler::createModelContext ( ) const
private

Definition at line 321 of file FWModelContextMenuHandler.cc.

References kOpenCollectionControllerMO, kOpenDetailView, kOpenDetailViewMO, kOpenObjectControllerMO, kPrint, kSetColorMO, kSetVisibleMO, m_afterViewSeperator, m_modelPopup, m_nDetailViewEntries, and m_seperator.

Referenced by showSelectedModelContext().

322 {
323  if(0==m_modelPopup) {
324  m_modelPopup = new FWPopupMenu();
325 
326  m_modelPopup->AddEntry("Set Visible",kSetVisibleMO);
327  m_modelPopup->AddEntry("Set Color ...",kSetColorMO);
328  m_modelPopup->AddEntry("Print ...",kPrint);
331  m_modelPopup->AddSeparator();
332  m_seperator = dynamic_cast<TGMenuEntry*>(m_modelPopup->GetListOfEntries()->Last());
333  assert(0!=m_seperator);
334  m_modelPopup->AddEntry("Open Object Controller ...",kOpenObjectControllerMO);
335  m_afterViewSeperator = dynamic_cast<TGMenuEntry*>(m_modelPopup->GetListOfEntries()->Last());
336  m_modelPopup->AddEntry("Open Collection Controller ...",kOpenCollectionControllerMO);
337 
338  m_modelPopup->Connect("Activated(Int_t)",
339  "FWModelContextMenuHandler",
340  const_cast<FWModelContextMenuHandler*>(this),
341  "chosenItem(Int_t)");
342  }
343 }
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 240 of file FWModelContextMenuHandler.cc.

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

Referenced by FWGUIManager::showSelectedModelContextMenu().

241 {
242  m_viewHander=iHandler;
243  assert(!m_selectionManager->selected().empty());
245 
246  //setup the menu based on this object
247  FWModelId id = *(m_selectionManager->selected().begin());
248  const FWDisplayProperties& props = id.item()->modelInfo(id.index()).displayProperties();
249  if(props.isVisible()) {
250  m_modelPopup->CheckEntry(kSetVisibleMO);
251  }else {
252  m_modelPopup->UnCheckEntry(kSetVisibleMO);
253  }
254 
255 
256  if( m_selectionManager->selected().size()==1 ) {
257  {
258  using namespace Reflex;
259  ROOT::Reflex::Type rtype(ROOT::Reflex::Type::ByName(id.item()->modelType()->GetName()));
260  ROOT::Reflex::Object o(rtype, const_cast<void *>(id.item()->modelData(id.index())));
261  EMEMBERQUERY inh = INHERITEDMEMBERS_ALSO;
262  if ( rtype.FunctionMemberByName("print",Type(Type::ByName("void (std::ostream&)"), CONST), 0 , inh))
263  {
264  m_modelPopup->EnableEntry(kPrint);
265  // std::cout << "Enable " <<std::endl;
266  }
267  else
268  {
269  m_modelPopup->DisableEntry(kPrint);
270  // printf("Disable print \n");
271  }
272  }
273  //add the detail view entries
274  std::vector<std::string> viewChoices = m_detailViewManager->detailViewsFor(*(m_selectionManager->selected().begin()));
275  if(viewChoices.size()>0) {
276  if(m_nDetailViewEntries < viewChoices.size()) {
277  for(unsigned int index = m_nDetailViewEntries;
278  index != viewChoices.size();
279  ++index) {
281  }
282  m_nDetailViewEntries=viewChoices.size();
283  }
284  const std::string kStart("Open ");
285  const std::string kEnd(" Detail View ...");
286  for(unsigned int index=0; index != viewChoices.size(); ++index) {
287  m_modelPopup->GetEntry(index+kOpenDetailViewMO)->GetLabel()->SetString((kStart+viewChoices[index]+kEnd).c_str());
288  m_modelPopup->EnableEntry(index+kOpenDetailViewMO);
289  }
290  for(unsigned int i =viewChoices.size(); i <m_nDetailViewEntries; ++i) {
291  m_modelPopup->HideEntry(kOpenDetailViewMO+i);
292  }
293 
294  } else {
295  for(unsigned int i =0; i <m_nDetailViewEntries; ++i) {
296  m_modelPopup->HideEntry(kOpenDetailViewMO+i);
297  }
298  }
299  } else {
300  for(unsigned int i =0; i <m_nDetailViewEntries; ++i) {
301  m_modelPopup->HideEntry(kOpenDetailViewMO+i);
302  }
303  }
304  //add necessary entries from the view
305  m_modelPopup->DeleteEntry(m_viewSeperator);
306  m_viewSeperator=0;
307 
308  for(unsigned int i=0; i<m_nViewEntries; ++i) {
309  m_modelPopup->HideEntry(kViewOptionsMO+i);
310  }
311  if(m_viewHander) {
312  m_viewHander->addTo(const_cast<FWModelContextMenuHandler&>(*this), *(m_selectionManager->selected().begin()));
313  }
314 
315  m_x=iX;
316  m_y=iY;
317  m_modelPopup->PlaceMenu(iX,iY,false,true);
318 }
const std::set< FWModelId > & selected() const
int i
Definition: DBlmapReader.cc:9
FWSelectionManager * m_selectionManager
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 76 of file FWModelContextMenuHandler.h.

Referenced by addViewEntry(), and createModelContext().

FWColorManager* FWModelContextMenuHandler::m_colorManager
private

Definition at line 72 of file FWModelContextMenuHandler.h.

Referenced by chosenItem(), and createColorPopup().

FWColorPopup* FWModelContextMenuHandler::m_colorPopup
mutableprivate

Definition at line 69 of file FWModelContextMenuHandler.h.

Referenced by chosenItem(), and createColorPopup().

FWDetailViewManager* FWModelContextMenuHandler::m_detailViewManager
private

Definition at line 71 of file FWModelContextMenuHandler.h.

Referenced by chosenItem(), and showSelectedModelContext().

FWGUIManager* FWModelContextMenuHandler::m_guiManager
private

Definition at line 73 of file FWModelContextMenuHandler.h.

Referenced by chosenItem().

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

Definition at line 79 of file FWModelContextMenuHandler.h.

Referenced by createModelContext(), and showSelectedModelContext().

unsigned int FWModelContextMenuHandler::m_nViewEntries
mutableprivate

Definition at line 80 of file FWModelContextMenuHandler.h.

Referenced by addViewEntry(), and showSelectedModelContext().

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

Definition at line 74 of file FWModelContextMenuHandler.h.

Referenced by createModelContext(), and showSelectedModelContext().

FWViewContextMenuHandlerBase* FWModelContextMenuHandler::m_viewHander
mutableprivate

Definition at line 81 of file FWModelContextMenuHandler.h.

Referenced by chosenItem(), and showSelectedModelContext().

TGMenuEntry* FWModelContextMenuHandler::m_viewSeperator
mutableprivate

Definition at line 75 of file FWModelContextMenuHandler.h.

Referenced by addViewEntry(), and showSelectedModelContext().

Int_t FWModelContextMenuHandler::m_x
mutableprivate

Definition at line 77 of file FWModelContextMenuHandler.h.

Referenced by chosenItem(), and showSelectedModelContext().

Int_t FWModelContextMenuHandler::m_y
mutableprivate

Definition at line 78 of file FWModelContextMenuHandler.h.

Referenced by chosenItem(), and showSelectedModelContext().