#include <Fireworks/Core/interface/FWModelContextMenuHandler.h>
Description: Controls the context menus
Usage: This file is used internally by the system
Definition at line 38 of file FWModelContextMenuHandler.h.
FWModelContextMenuHandler::FWModelContextMenuHandler | ( | FWSelectionManager * | iSM, |
FWDetailViewManager * | iDVM, | ||
FWColorManager * | iCM, | ||
FWGUIManager * | iGM | ||
) |
Definition at line 144 of file FWModelContextMenuHandler.cc.
: m_modelPopup(0), m_colorPopup(0), m_selectionManager(iSM), m_detailViewManager(iDVM), m_colorManager(iCM), m_guiManager(iGM), m_seperator(0), m_viewSeperator(0), m_afterViewSeperator(0), m_x(0), m_y(0), m_nDetailViewEntries(0), m_nViewEntries(0), m_viewHander(0) { }
FWModelContextMenuHandler::~FWModelContextMenuHandler | ( | ) | [virtual] |
Definition at line 170 of file FWModelContextMenuHandler.cc.
References m_modelPopup.
{ delete m_modelPopup; }
FWModelContextMenuHandler::FWModelContextMenuHandler | ( | const FWModelContextMenuHandler & | ) | [private] |
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.
{ if(!m_viewSeperator) { m_modelPopup->AddSeparator(m_afterViewSeperator); m_viewSeperator=dynamic_cast<TGMenuEntry*>(m_modelPopup->GetListOfEntries()->Before(m_afterViewSeperator)); assert(0!=m_viewSeperator); } if(static_cast<int>(m_nViewEntries) > iEntryIndex) { m_modelPopup->GetEntry(iEntryIndex+kViewOptionsMO)->GetLabel()->SetString(iEntryName); m_modelPopup->EnableEntry(iEntryIndex+kViewOptionsMO); } else { assert(static_cast<int>(m_nViewEntries) == iEntryIndex); m_modelPopup->AddEntry(iEntryName,kViewOptionsMO+iEntryIndex,0,0,m_viewSeperator); ++m_nViewEntries; } }
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().
{ assert(!m_selectionManager->selected().empty()); switch (iChoice) { case kSetVisibleMO: { FWModelId id = *(m_selectionManager->selected().begin()); const FWDisplayProperties& props = id.item()->modelInfo(id.index()).displayProperties(); for_each(m_selectionManager->selected().begin(), m_selectionManager->selected().end(), change_visibility(!props.isVisible()) ); break; } case kSetColorMO: { FWModelId id = *(m_selectionManager->selected().begin()); createColorPopup(); m_colorPopup->SetName("Selected"); std::vector<Color_t> colors; m_colorManager->fillLimitedColors(colors); m_colorPopup->ResetColors(colors, m_colorManager->backgroundColorIndex()==FWColorManager::kBlackIndex); m_colorPopup->SetSelection(id.item()->modelInfo(id.index()).displayProperties().color()); m_colorPopup->PlacePopup(m_x, m_y, m_colorPopup->GetDefaultWidth(), m_colorPopup->GetDefaultHeight()); break; } case kOpenObjectControllerMO: { m_guiManager->showModelPopup(); break; } case kOpenCollectionControllerMO: { m_guiManager->showEDIFrame(); break; } case kOpenDetailViewMO: case kViewOptionsMO: default: { if(iChoice>=kViewOptionsMO) { assert(0!=m_viewHander); m_viewHander->select(iChoice-kViewOptionsMO, *(m_selectionManager->selected().begin()), m_x, m_y); }else { assert(iChoice<kOpenObjectControllerMO); assert(m_selectionManager->selected().size()==1); std::vector<std::string> viewChoices = m_detailViewManager->detailViewsFor(*(m_selectionManager->selected().begin())); assert(0!=viewChoices.size()); m_detailViewManager->openDetailViewFor(*(m_selectionManager->selected().begin()),viewChoices[iChoice-kOpenDetailViewMO]) ; } break; } break; } }
FWModelContextMenuHandler::ClassDef | ( | FWModelContextMenuHandler | , |
0 | |||
) |
void FWModelContextMenuHandler::colorChangeRequested | ( | Color_t | color | ) |
Definition at line 260 of file FWModelContextMenuHandler.cc.
References m_selectionManager, FWSelectionManager::selected(), and FWDisplayProperties::setColor().
{ for(std::set<FWModelId>::const_iterator it =m_selectionManager->selected().begin(), itEnd = m_selectionManager->selected().end(); it != itEnd; ++it) { FWDisplayProperties changeProperties = it->item()->modelInfo(it->index()).displayProperties(); changeProperties.setColor(color); it->item()->setDisplayProperties(it->index(), changeProperties); } }
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().
{ if(0==m_colorPopup) { std::vector<Color_t> colors; m_colorManager->fillLimitedColors(colors); m_colorPopup = new FWColorPopup(gClient->GetDefaultRoot(), colors.front()); m_colorPopup->InitContent("", colors); m_colorPopup->Connect("ColorSelected(Color_t)","FWModelContextMenuHandler", const_cast<FWModelContextMenuHandler*>(this), "colorChangeRequested(Color_t)"); } }
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().
{ if(0==m_modelPopup) { m_modelPopup = new FWPopupMenu(); m_modelPopup->AddEntry("Set Visible",kSetVisibleMO); m_modelPopup->AddEntry("Set Color ...",kSetColorMO); m_modelPopup->AddEntry(kOpenDetailView,kOpenDetailViewMO); m_nDetailViewEntries=1; m_modelPopup->AddSeparator(); m_seperator = dynamic_cast<TGMenuEntry*>(m_modelPopup->GetListOfEntries()->Last()); assert(0!=m_seperator); m_modelPopup->AddEntry("Open Object Controller ...",kOpenObjectControllerMO); m_afterViewSeperator = dynamic_cast<TGMenuEntry*>(m_modelPopup->GetListOfEntries()->Last()); m_modelPopup->AddEntry("Open Collection Controller ...",kOpenCollectionControllerMO); m_modelPopup->Connect("Activated(Int_t)", "FWModelContextMenuHandler", const_cast<FWModelContextMenuHandler*>(this), "chosenItem(Int_t)"); } }
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().
{ m_viewHander=iHandler; assert(!m_selectionManager->selected().empty()); createModelContext(); //setup the menu based on this object FWModelId id = *(m_selectionManager->selected().begin()); const FWDisplayProperties& props = id.item()->modelInfo(id.index()).displayProperties(); if(props.isVisible()) { m_modelPopup->CheckEntry(kSetVisibleMO); }else { m_modelPopup->UnCheckEntry(kSetVisibleMO); } if(m_selectionManager->selected().size()==1) { //add the detail view entries std::vector<std::string> viewChoices = m_detailViewManager->detailViewsFor(*(m_selectionManager->selected().begin())); if(viewChoices.size()>0) { if(m_nDetailViewEntries < viewChoices.size()) { for(unsigned int index = m_nDetailViewEntries; index != viewChoices.size(); ++index) { m_modelPopup->AddEntry(kOpenDetailView,kOpenDetailViewMO+index,0,0,m_seperator); } m_nDetailViewEntries=viewChoices.size(); } const std::string kStart("Open "); const std::string kEnd(" Detail View ..."); for(unsigned int index=0; index != viewChoices.size(); ++index) { m_modelPopup->GetEntry(index+kOpenDetailViewMO)->GetLabel()->SetString((kStart+viewChoices[index]+kEnd).c_str()); m_modelPopup->EnableEntry(index+kOpenDetailViewMO); } for(unsigned int i =viewChoices.size(); i <m_nDetailViewEntries; ++i) { m_modelPopup->HideEntry(kOpenDetailViewMO+i); } } else { for(unsigned int i =0; i <m_nDetailViewEntries; ++i) { m_modelPopup->HideEntry(kOpenDetailViewMO+i); } } } else { for(unsigned int i =0; i <m_nDetailViewEntries; ++i) { m_modelPopup->HideEntry(kOpenDetailViewMO+i); } } //add necessary entries from the view m_modelPopup->DeleteEntry(m_viewSeperator); m_viewSeperator=0; for(unsigned int i=0; i<m_nViewEntries; ++i) { m_modelPopup->HideEntry(kViewOptionsMO+i); } if(m_viewHander) { m_viewHander->addTo(const_cast<FWModelContextMenuHandler&>(*this)); } m_x=iX; m_y=iY; m_modelPopup->PlaceMenu(iX,iY,false,true); }
TGMenuEntry* FWModelContextMenuHandler::m_afterViewSeperator [mutable, private] |
Definition at line 76 of file FWModelContextMenuHandler.h.
Referenced by addViewEntry(), and createModelContext().
Definition at line 72 of file FWModelContextMenuHandler.h.
Referenced by chosenItem(), and createColorPopup().
FWColorPopup* FWModelContextMenuHandler::m_colorPopup [mutable, private] |
Definition at line 69 of file FWModelContextMenuHandler.h.
Referenced by chosenItem(), and createColorPopup().
Definition at line 71 of file FWModelContextMenuHandler.h.
Referenced by chosenItem(), and showSelectedModelContext().
Definition at line 73 of file FWModelContextMenuHandler.h.
Referenced by chosenItem().
TGPopupMenu* FWModelContextMenuHandler::m_modelPopup [mutable, private] |
Definition at line 68 of file FWModelContextMenuHandler.h.
Referenced by addViewEntry(), createModelContext(), showSelectedModelContext(), and ~FWModelContextMenuHandler().
unsigned int FWModelContextMenuHandler::m_nDetailViewEntries [mutable, private] |
Definition at line 79 of file FWModelContextMenuHandler.h.
Referenced by createModelContext(), and showSelectedModelContext().
unsigned int FWModelContextMenuHandler::m_nViewEntries [mutable, private] |
Definition at line 80 of file FWModelContextMenuHandler.h.
Referenced by addViewEntry(), and showSelectedModelContext().
Definition at line 70 of file FWModelContextMenuHandler.h.
Referenced by chosenItem(), colorChangeRequested(), and showSelectedModelContext().
TGMenuEntry* FWModelContextMenuHandler::m_seperator [mutable, private] |
Definition at line 74 of file FWModelContextMenuHandler.h.
Referenced by createModelContext(), and showSelectedModelContext().
FWViewContextMenuHandlerBase* FWModelContextMenuHandler::m_viewHander [mutable, private] |
Definition at line 81 of file FWModelContextMenuHandler.h.
Referenced by chosenItem(), and showSelectedModelContext().
TGMenuEntry* FWModelContextMenuHandler::m_viewSeperator [mutable, private] |
Definition at line 75 of file FWModelContextMenuHandler.h.
Referenced by addViewEntry(), and showSelectedModelContext().
Int_t FWModelContextMenuHandler::m_x [mutable, private] |
Definition at line 77 of file FWModelContextMenuHandler.h.
Referenced by chosenItem(), and showSelectedModelContext().
Int_t FWModelContextMenuHandler::m_y [mutable, private] |
Definition at line 78 of file FWModelContextMenuHandler.h.
Referenced by chosenItem(), and showSelectedModelContext().