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)
 
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 144 of file FWModelContextMenuHandler.cc.

147  :
148 m_modelPopup(0),
149 m_colorPopup(0),
150 m_selectionManager(iSM),
151 m_detailViewManager(iDVM),
152 m_colorManager(iCM),
153 m_guiManager(iGM),
154 m_seperator(0),
155 m_viewSeperator(0),
157 m_x(0),
158 m_y(0),
160 m_nViewEntries(0),
161 m_viewHander(0)
162 {
163 }
FWSelectionManager * m_selectionManager
FWViewContextMenuHandlerBase * m_viewHander
FWDetailViewManager * m_detailViewManager
FWModelContextMenuHandler::~FWModelContextMenuHandler ( )
virtual

Definition at line 170 of file FWModelContextMenuHandler.cc.

References m_modelPopup.

171 {
172  delete m_modelPopup;
173 }
FWModelContextMenuHandler::FWModelContextMenuHandler ( const FWModelContextMenuHandler )
private

Member Function Documentation

void FWModelContextMenuHandler::addViewEntry ( const char *  iEntryName,
int  iEntryIndex 
)

Definition at line 273 of file FWModelContextMenuHandler.cc.

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

274 {
275  if(!m_viewSeperator) {
276  m_modelPopup->AddSeparator(m_afterViewSeperator);
277  m_viewSeperator=dynamic_cast<TGMenuEntry*>(m_modelPopup->GetListOfEntries()->Before(m_afterViewSeperator));
278  assert(0!=m_viewSeperator);
279  }
280  if(static_cast<int>(m_nViewEntries) > iEntryIndex) {
281  m_modelPopup->GetEntry(iEntryIndex+kViewOptionsMO)->GetLabel()->SetString(iEntryName);
282  m_modelPopup->EnableEntry(iEntryIndex+kViewOptionsMO);
283  } else {
284  assert(static_cast<int>(m_nViewEntries) == iEntryIndex);
285  m_modelPopup->AddEntry(iEntryName,kViewOptionsMO+iEntryIndex,0,0,m_viewSeperator);
286  ++m_nViewEntries;
287  }
288 }
void FWModelContextMenuHandler::chosenItem ( Int_t  iChoice)

Definition at line 203 of file FWModelContextMenuHandler.cc.

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

204 {
205  assert(!m_selectionManager->selected().empty());
206  switch (iChoice) {
207  case kSetVisibleMO:
208  {
209  FWModelId id = *(m_selectionManager->selected().begin());
210  const FWDisplayProperties& props = id.item()->modelInfo(id.index()).displayProperties();
211  for_each(m_selectionManager->selected().begin(),
212  m_selectionManager->selected().end(),
213  change_visibility(!props.isVisible())
214  );
215  break;
216  }
217  case kSetColorMO:
218  {
219  FWModelId id = *(m_selectionManager->selected().begin());
221  m_colorPopup->SetName("Selected");
222  std::vector<Color_t> colors;
225  m_colorPopup->SetSelection(id.item()->modelInfo(id.index()).displayProperties().color());
226  m_colorPopup->PlacePopup(m_x, m_y, m_colorPopup->GetDefaultWidth(), m_colorPopup->GetDefaultHeight());
227  break;
228  }
230  {
232  break;
233  }
235  {
237  break;
238  }
239  case kOpenDetailViewMO:
240  case kViewOptionsMO:
241  default:
242  {
243  if(iChoice>=kViewOptionsMO) {
244  assert(0!=m_viewHander);
246  }else {
247  assert(iChoice<kOpenObjectControllerMO);
248  assert(m_selectionManager->selected().size()==1);
249  std::vector<std::string> viewChoices = m_detailViewManager->detailViewsFor(*(m_selectionManager->selected().begin()));
250  assert(0!=viewChoices.size());
252  }
253  break;
254  }
255  break;
256  }
257 }
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
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 260 of file FWModelContextMenuHandler.cc.

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

261 {
262  for(std::set<FWModelId>::const_iterator it =m_selectionManager->selected().begin(),
263  itEnd = m_selectionManager->selected().end();
264  it != itEnd;
265  ++it) {
266  FWDisplayProperties changeProperties = it->item()->modelInfo(it->index()).displayProperties();
267  changeProperties.setColor(color);
268  it->item()->setDisplayProperties(it->index(), changeProperties);
269  }
270 }
const std::set< FWModelId > & selected() const
void setColor(Color_t iColor)
FWSelectionManager * m_selectionManager
void FWModelContextMenuHandler::createColorPopup ( ) const
private

Definition at line 382 of file FWModelContextMenuHandler.cc.

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

Referenced by chosenItem().

383 {
384  if(0==m_colorPopup) {
385  std::vector<Color_t> colors;
387 
388  m_colorPopup = new FWColorPopup(gClient->GetDefaultRoot(), colors.front());
389  m_colorPopup->InitContent("", colors);
390  m_colorPopup->Connect("ColorSelected(Color_t)","FWModelContextMenuHandler", const_cast<FWModelContextMenuHandler*>(this), "colorChangeRequested(Color_t)");
391  }
392 }
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 358 of file FWModelContextMenuHandler.cc.

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

Referenced by showSelectedModelContext().

359 {
360  if(0==m_modelPopup) {
361  m_modelPopup = new FWPopupMenu();
362 
363  m_modelPopup->AddEntry("Set Visible",kSetVisibleMO);
364  m_modelPopup->AddEntry("Set Color ...",kSetColorMO);
367  m_modelPopup->AddSeparator();
368  m_seperator = dynamic_cast<TGMenuEntry*>(m_modelPopup->GetListOfEntries()->Last());
369  assert(0!=m_seperator);
370  m_modelPopup->AddEntry("Open Object Controller ...",kOpenObjectControllerMO);
371  m_afterViewSeperator = dynamic_cast<TGMenuEntry*>(m_modelPopup->GetListOfEntries()->Last());
372  m_modelPopup->AddEntry("Open Collection Controller ...",kOpenCollectionControllerMO);
373 
374  m_modelPopup->Connect("Activated(Int_t)",
375  "FWModelContextMenuHandler",
376  const_cast<FWModelContextMenuHandler*>(this),
377  "chosenItem(Int_t)");
378  }
379 }
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 294 of file FWModelContextMenuHandler.cc.

References FWViewContextMenuHandlerBase::addTo(), createModelContext(), FWDetailViewManager::detailViewsFor(), i, getHLTprescales::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, and FWSelectionManager::selected().

Referenced by FWGUIManager::showSelectedModelContextMenu().

295 {
296  m_viewHander=iHandler;
297  assert(!m_selectionManager->selected().empty());
299 
300  //setup the menu based on this object
301  FWModelId id = *(m_selectionManager->selected().begin());
302  const FWDisplayProperties& props = id.item()->modelInfo(id.index()).displayProperties();
303  if(props.isVisible()) {
304  m_modelPopup->CheckEntry(kSetVisibleMO);
305  }else {
306  m_modelPopup->UnCheckEntry(kSetVisibleMO);
307  }
308 
309  if(m_selectionManager->selected().size()==1) {
310  //add the detail view entries
311  std::vector<std::string> viewChoices = m_detailViewManager->detailViewsFor(*(m_selectionManager->selected().begin()));
312  if(viewChoices.size()>0) {
313  if(m_nDetailViewEntries < viewChoices.size()) {
314  for(unsigned int index = m_nDetailViewEntries;
315  index != viewChoices.size();
316  ++index) {
318  }
319  m_nDetailViewEntries=viewChoices.size();
320  }
321  const std::string kStart("Open ");
322  const std::string kEnd(" Detail View ...");
323  for(unsigned int index=0; index != viewChoices.size(); ++index) {
324  m_modelPopup->GetEntry(index+kOpenDetailViewMO)->GetLabel()->SetString((kStart+viewChoices[index]+kEnd).c_str());
325  m_modelPopup->EnableEntry(index+kOpenDetailViewMO);
326  }
327  for(unsigned int i =viewChoices.size(); i <m_nDetailViewEntries; ++i) {
328  m_modelPopup->HideEntry(kOpenDetailViewMO+i);
329  }
330 
331  } else {
332  for(unsigned int i =0; i <m_nDetailViewEntries; ++i) {
333  m_modelPopup->HideEntry(kOpenDetailViewMO+i);
334  }
335  }
336  } else {
337  for(unsigned int i =0; i <m_nDetailViewEntries; ++i) {
338  m_modelPopup->HideEntry(kOpenDetailViewMO+i);
339  }
340  }
341  //add necessary entries from the view
342  m_modelPopup->DeleteEntry(m_viewSeperator);
343  m_viewSeperator=0;
344 
345  for(unsigned int i=0; i<m_nViewEntries; ++i) {
346  m_modelPopup->HideEntry(kViewOptionsMO+i);
347  }
348  if(m_viewHander) {
349  m_viewHander->addTo(const_cast<FWModelContextMenuHandler&>(*this));
350  }
351 
352  m_x=iX;
353  m_y=iY;
354  m_modelPopup->PlaceMenu(iX,iY,false,true);
355 }
const std::set< FWModelId > & selected() const
int i
Definition: DBlmapReader.cc:9
FWSelectionManager * m_selectionManager
void addTo(FWModelContextMenuHandler &)
static const char *const kOpenDetailView
FWViewContextMenuHandlerBase * m_viewHander
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().