CMS 3D CMS Logo

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() [1/2]

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

Definition at line 60 of file FWModelContextMenuHandler.cc.

64  : m_modelPopup(nullptr),
65  m_colorPopup(nullptr),
66  m_selectionManager(iSM),
67  m_detailViewManager(iDVM),
68  m_colorManager(iCM),
69  m_guiManager(iGM),
70  m_seperator(nullptr),
71  m_viewSeperator(nullptr),
72  m_afterViewSeperator(nullptr),
73  m_x(0),
74  m_y(0),
76  m_nViewEntries(0),
77  m_viewHander(nullptr) {}
FWSelectionManager * m_selectionManager
FWViewContextMenuHandlerBase * m_viewHander
FWDetailViewManager * m_detailViewManager

◆ ~FWModelContextMenuHandler()

FWModelContextMenuHandler::~FWModelContextMenuHandler ( )
virtual

Definition at line 84 of file FWModelContextMenuHandler.cc.

References m_modelPopup.

84 { delete m_modelPopup; }

◆ FWModelContextMenuHandler() [2/2]

FWModelContextMenuHandler::FWModelContextMenuHandler ( const FWModelContextMenuHandler )
private

Member Function Documentation

◆ addViewEntry()

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

Definition at line 198 of file FWModelContextMenuHandler.cc.

References cms::cuda::assert(), cms::soa::RestrictQualify::enabled, kViewOptionsMO, m_afterViewSeperator, m_modelPopup, m_nViewEntries, and m_viewSeperator.

198  {
199  if (!m_viewSeperator) {
200  m_modelPopup->AddSeparator(m_afterViewSeperator);
201  m_viewSeperator = dynamic_cast<TGMenuEntry*>(m_modelPopup->GetListOfEntries()->Before(m_afterViewSeperator));
202  assert(nullptr != m_viewSeperator);
203  }
204 
205  if (static_cast<int>(m_nViewEntries) > iEntryIndex) {
206  m_modelPopup->GetEntry(iEntryIndex + kViewOptionsMO)->GetLabel()->SetString(iEntryName);
207  if (enabled)
208  m_modelPopup->EnableEntry(iEntryIndex + kViewOptionsMO);
209  else
210  m_modelPopup->DisableEntry(iEntryIndex + kViewOptionsMO);
211 
212  } else {
213  assert(static_cast<int>(m_nViewEntries) == iEntryIndex);
214  m_modelPopup->AddEntry(iEntryName, kViewOptionsMO + iEntryIndex, nullptr, nullptr, m_viewSeperator);
215 
216  if (enabled)
217  m_modelPopup->EnableEntry(kViewOptionsMO + iEntryIndex);
218  else
219  m_modelPopup->DisableEntry(kViewOptionsMO + iEntryIndex);
220 
221  ++m_nViewEntries;
222  }
223 }
assert(be >=bs)
constexpr bool enabled
Definition: SoACommon.h:71

◆ chosenItem()

void FWModelContextMenuHandler::chosenItem ( Int_t  iChoice)

Definition at line 114 of file FWModelContextMenuHandler.cc.

References cms::cuda::assert(), FWColorManager::backgroundColorIndex(), pv::colors, createColorPopup(), FWDetailViewManager::detailViewsFor(), FWColorManager::fillLimitedColors(), B2GTnPMonitor_cfi::item, 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().

114  {
115  assert(!m_selectionManager->selected().empty());
116  switch (iChoice) {
117  case kSetVisibleMO: {
118  FWModelId id = *(m_selectionManager->selected().begin());
119  for_each(m_selectionManager->selected().begin(),
120  m_selectionManager->selected().end(),
121  change_visibility(!id.item()->modelInfo(id.index()).displayProperties().isVisible()));
122  break;
123  }
124  case kSetColorMO: {
125  FWModelId id = *(m_selectionManager->selected().begin());
127  m_colorPopup->SetName("Selected");
128  std::vector<Color_t> colors;
131  m_colorPopup->SetSelection(id.item()->modelInfo(id.index()).displayProperties().color());
132  m_colorPopup->PlacePopup(m_x, m_y, m_colorPopup->GetDefaultWidth(), m_colorPopup->GetDefaultHeight());
133  break;
134  } /*
135  case kPrint:
136  {
137  FWModelId id = *(m_selectionManager->selected().begin());
138  edm::TypeWithDict rtype(edm::TypeWithDict::byName(id.item()->modelType()->GetName()));
139  edm::ObjectWithDict o(rtype, const_cast<void *>(id.item()->modelData(id.index())));
140 
141  // void* xx = &std::cout;
142  //const std::vector<void*> j(1, xx);
143  //edm::TypeMemberQuery inh = edm::TypeMemberQuery::InheritedAlso;
144  //edm::FunctionWithDict m = rtype.functionMemberByName("print",edm::TypeWithDict(edm::TypeWithDict::byName("void (std::ostream&)"), edm::TypeModifiers::Const), edm::TypeModifiers::NoMod , inh))
145  //m.Invoke(o, 0, j);
146 
147  const char* cmd = Form("FWGUIManager::OStream() << *(%s*)%p ;", id.item()->modelType()->GetName(), (void*)id.item()->modelData(id.index()));
148  //const char* cmd = Form("*((std::ostream*)%p) << (%s*)%p ;", (void*)(&std::cout), id.item()->modelType()->GetName(), (void*)id.item()->modelData(id.index()));
149  std::cout << cmd << std::endl;
150  gROOT->ProcessLine(cmd);
151 
152 
153  break;
154  }*/
157  break;
158  }
161  break;
162  }
163  case kOpen3DRegion: {
165  break;
166  }
167  case kOpenDetailViewMO:
168  case kViewOptionsMO:
169  default: {
170  if (iChoice >= kViewOptionsMO) {
171  assert(nullptr != m_viewHander);
172  m_viewHander->select(iChoice - kViewOptionsMO, *(m_selectionManager->selected().begin()), m_x, m_y);
173  } else {
174  assert(iChoice < kOpenObjectControllerMO);
175  assert(m_selectionManager->selected().size() == 1);
176  std::vector<std::string> viewChoices =
178  assert(!viewChoices.empty());
180  viewChoices[iChoice - kOpenDetailViewMO]);
181  }
182  break;
183  } break;
184  }
185 }
void showModelPopup()
FWSelectionManager * m_selectionManager
void open3DRegion()
void SetName(const char *iName) override
std::vector< std::string > detailViewsFor(const FWModelId &) const
assert(be >=bs)
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
BackgroundColorIndex backgroundColorIndex() const
void PlacePopup(Int_t x, Int_t y, UInt_t w, UInt_t h)
void ResetColors(const std::vector< Color_t > &colors, bool backgroundIsBlack=true)
void SetSelection(Color_t)
FWViewContextMenuHandlerBase * m_viewHander
FWDetailViewManager * m_detailViewManager
void openDetailViewFor(const FWModelId &, const std::string &)
const Int_t colors[8]
Definition: colors.py:1
const std::set< FWModelId > & selected() const
void fillLimitedColors(std::vector< Color_t > &cv) const

◆ ClassDef()

FWModelContextMenuHandler::ClassDef ( FWModelContextMenuHandler  ,
 
)

◆ colorChangeRequested()

void FWModelContextMenuHandler::colorChangeRequested ( Color_t  color)

Definition at line 187 of file FWModelContextMenuHandler.cc.

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

187  {
188  for (std::set<FWModelId>::const_iterator it = m_selectionManager->selected().begin(),
189  itEnd = m_selectionManager->selected().end();
190  it != itEnd;
191  ++it) {
192  FWDisplayProperties changeProperties = it->item()->modelInfo(it->index()).displayProperties();
193  changeProperties.setColor(color);
194  it->item()->setDisplayProperties(it->index(), changeProperties);
195  }
196 }
void setColor(Color_t iColor)
FWSelectionManager * m_selectionManager
const std::set< FWModelId > & selected() const

◆ createColorPopup()

void FWModelContextMenuHandler::createColorPopup ( ) const
private

Definition at line 337 of file FWModelContextMenuHandler.cc.

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

Referenced by chosenItem().

337  {
338  if (nullptr == m_colorPopup) {
339  std::vector<Color_t> colors;
341 
342  m_colorPopup = new FWColorPopup(gClient->GetDefaultRoot(), colors.front());
344  m_colorPopup->Connect("ColorSelected(Color_t)",
345  "FWModelContextMenuHandler",
346  const_cast<FWModelContextMenuHandler*>(this),
347  "colorChangeRequested(Color_t)");
348  }
349 }
void InitContent(const char *name, const std::vector< Color_t > &colors, bool backgroundIsBlack=true)
const Int_t colors[8]
Definition: colors.py:1
void fillLimitedColors(std::vector< Color_t > &cv) const

◆ createModelContext()

void FWModelContextMenuHandler::createModelContext ( ) const
private

Definition at line 313 of file FWModelContextMenuHandler.cc.

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

Referenced by showSelectedModelContext().

313  {
314  if (nullptr == m_modelPopup) {
315  m_modelPopup = new FWPopupMenu();
316 
317  m_modelPopup->AddEntry("Set Visible", kSetVisibleMO);
318  m_modelPopup->AddEntry("Set Color ...", kSetColorMO);
319  // m_modelPopup->AddEntry("Print ...",kPrint);
322  m_seperator = dynamic_cast<TGMenuEntry*>(m_modelPopup->GetListOfEntries()->Last());
323  assert(nullptr != m_seperator);
324  m_modelPopup->AddEntry("Open 3D Region ...", kOpen3DRegion);
325  m_modelPopup->AddSeparator();
326  m_modelPopup->AddEntry("Open Object Controller ...", kOpenObjectControllerMO);
327  m_afterViewSeperator = dynamic_cast<TGMenuEntry*>(m_modelPopup->GetListOfEntries()->Last());
328  m_modelPopup->AddEntry("Open Collection Controller ...", kOpenCollectionControllerMO);
329 
330  m_modelPopup->Connect("Activated(Int_t)",
331  "FWModelContextMenuHandler",
332  const_cast<FWModelContextMenuHandler*>(this),
333  "chosenItem(Int_t)");
334  }
335 }
assert(be >=bs)
static const char *const kOpenDetailView

◆ operator=()

const FWModelContextMenuHandler& FWModelContextMenuHandler::operator= ( const FWModelContextMenuHandler )
private

◆ showSelectedModelContext()

void FWModelContextMenuHandler::showSelectedModelContext ( Int_t  iX,
Int_t  iY,
FWViewContextMenuHandlerBase iHandler 
) const

NOTE: iX and iY are in global coordinates.

Definition at line 227 of file FWModelContextMenuHandler.cc.

References FWViewContextMenuHandlerBase::addTo(), cms::cuda::assert(), createModelContext(), FWDetailViewManager::detailViewsFor(), mps_fire::i, B2GTnPMonitor_cfi::item, 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().

229  {
230  m_viewHander = iHandler;
231  assert(!m_selectionManager->selected().empty());
233 
234  //setup the menu based on this object
235  FWModelId id = *(m_selectionManager->selected().begin());
236  if (id.item()->modelInfo(id.index()).displayProperties().isVisible()) {
237  m_modelPopup->CheckEntry(kSetVisibleMO);
238  } else {
239  m_modelPopup->UnCheckEntry(kSetVisibleMO);
240  }
241 
242  if (m_selectionManager->selected().size() == 1) {
243  {
244  //edm::TypeWithDict rtype(edm::TypeWithDict::byName(id.item()->modelType()->GetName()));
245  //edm::ObjectWithDict o(rtype, const_cast<void *>(id.item()->modelData(id.index())));
246  //edm::TypeMemberQuery inh = edm::TypeMemberQuery::InheritedAlso;
247  //if ( rtype.functionMemberByName("print",edm::TypeWithDict(edm::TypeWithDict::byName("void (std::ostream&)"), Long_t(kIsConstant)), 0, inh))
248  //{
249  //m_modelPopup->EnableEntry(kPrint);
250  // std::cout << "Enable " <<std::endl;
251  //}
252  //else
253  //{
254  m_modelPopup->DisableEntry(kPrint);
255  // printf("Disable print \n");
256  //}
257  }
258  //add the detail view entries
259  std::vector<std::string> viewChoices =
261  if (!viewChoices.empty()) {
262  if (m_nDetailViewEntries < viewChoices.size()) {
263  for (unsigned int index = m_nDetailViewEntries; index != viewChoices.size(); ++index) {
264  m_modelPopup->AddEntry(kOpenDetailView, kOpenDetailViewMO + index, nullptr, nullptr, m_seperator);
265  }
266  m_nDetailViewEntries = viewChoices.size();
267  }
268  const std::string kStart("Open ");
269  const std::string kEnd(" Detail View ...");
270  for (unsigned int index = 0; index != viewChoices.size(); ++index) {
271  m_modelPopup->EnableEntry(index + kOpenDetailViewMO); // need to call this to make it visible
272  if (viewChoices[index][0] != '!') {
274  ->GetLabel()
275  ->SetString((kStart + viewChoices[index] + kEnd).c_str());
276  } else {
278  ->GetLabel()
279  ->SetString((kStart + &viewChoices[index][1] + kEnd).c_str());
280  m_modelPopup->DisableEntry(index + kOpenDetailViewMO);
281  }
282  }
283  for (unsigned int i = viewChoices.size(); i < m_nDetailViewEntries; ++i) {
284  m_modelPopup->HideEntry(kOpenDetailViewMO + i);
285  }
286 
287  } else {
288  for (unsigned int i = 0; i < m_nDetailViewEntries; ++i) {
289  m_modelPopup->HideEntry(kOpenDetailViewMO + i);
290  }
291  }
292  } else {
293  for (unsigned int i = 0; i < m_nDetailViewEntries; ++i) {
294  m_modelPopup->HideEntry(kOpenDetailViewMO + i);
295  }
296  }
297  //add necessary entries from the view
298  m_modelPopup->DeleteEntry(m_viewSeperator);
299  m_viewSeperator = nullptr;
300 
301  for (unsigned int i = 0; i < m_nViewEntries; ++i) {
302  m_modelPopup->HideEntry(kViewOptionsMO + i);
303  }
304  if (m_viewHander) {
305  m_viewHander->addTo(const_cast<FWModelContextMenuHandler&>(*this), *(m_selectionManager->selected().begin()));
306  }
307 
308  m_x = iX;
309  m_y = iY;
310  m_modelPopup->PlaceMenu(iX, iY, false, true);
311 }
FWSelectionManager * m_selectionManager
std::vector< std::string > detailViewsFor(const FWModelId &) const
assert(be >=bs)
static const char *const kOpenDetailView
FWViewContextMenuHandlerBase * m_viewHander
void addTo(FWModelContextMenuHandler &, const FWModelId &id)
FWDetailViewManager * m_detailViewManager
const std::set< FWModelId > & selected() const

Member Data Documentation

◆ m_afterViewSeperator

TGMenuEntry* FWModelContextMenuHandler::m_afterViewSeperator
mutableprivate

Definition at line 71 of file FWModelContextMenuHandler.h.

Referenced by addViewEntry(), and createModelContext().

◆ m_colorManager

FWColorManager* FWModelContextMenuHandler::m_colorManager
private

Definition at line 67 of file FWModelContextMenuHandler.h.

Referenced by chosenItem(), and createColorPopup().

◆ m_colorPopup

FWColorPopup* FWModelContextMenuHandler::m_colorPopup
mutableprivate

Definition at line 64 of file FWModelContextMenuHandler.h.

Referenced by chosenItem(), and createColorPopup().

◆ m_detailViewManager

FWDetailViewManager* FWModelContextMenuHandler::m_detailViewManager
private

Definition at line 66 of file FWModelContextMenuHandler.h.

Referenced by chosenItem(), and showSelectedModelContext().

◆ m_guiManager

FWGUIManager* FWModelContextMenuHandler::m_guiManager
private

Definition at line 68 of file FWModelContextMenuHandler.h.

Referenced by chosenItem().

◆ m_modelPopup

TGPopupMenu* FWModelContextMenuHandler::m_modelPopup
mutableprivate

◆ m_nDetailViewEntries

unsigned int FWModelContextMenuHandler::m_nDetailViewEntries
mutableprivate

Definition at line 74 of file FWModelContextMenuHandler.h.

Referenced by createModelContext(), and showSelectedModelContext().

◆ m_nViewEntries

unsigned int FWModelContextMenuHandler::m_nViewEntries
mutableprivate

Definition at line 75 of file FWModelContextMenuHandler.h.

Referenced by addViewEntry(), and showSelectedModelContext().

◆ m_selectionManager

FWSelectionManager* FWModelContextMenuHandler::m_selectionManager
private

◆ m_seperator

TGMenuEntry* FWModelContextMenuHandler::m_seperator
mutableprivate

Definition at line 69 of file FWModelContextMenuHandler.h.

Referenced by createModelContext(), and showSelectedModelContext().

◆ m_viewHander

FWViewContextMenuHandlerBase* FWModelContextMenuHandler::m_viewHander
mutableprivate

Definition at line 76 of file FWModelContextMenuHandler.h.

Referenced by chosenItem(), and showSelectedModelContext().

◆ m_viewSeperator

TGMenuEntry* FWModelContextMenuHandler::m_viewSeperator
mutableprivate

Definition at line 70 of file FWModelContextMenuHandler.h.

Referenced by addViewEntry(), and showSelectedModelContext().

◆ m_x

Int_t FWModelContextMenuHandler::m_x
mutableprivate

Definition at line 72 of file FWModelContextMenuHandler.h.

Referenced by chosenItem(), and showSelectedModelContext().

◆ m_y

Int_t FWModelContextMenuHandler::m_y
mutableprivate

Definition at line 73 of file FWModelContextMenuHandler.h.

Referenced by chosenItem(), and showSelectedModelContext().