Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:27:19

0001 // -*- C++ -*-
0002 //
0003 // Package:     Core
0004 // Class  :     FWSummaryManager
0005 //
0006 // Implementation:
0007 //     <Notes on implementation>
0008 //
0009 // Original Author:  Chris Jones
0010 //         Created:  Tue Mar  4 09:35:32 EST 2008
0011 //
0012 
0013 // system include files
0014 #include <functional>
0015 
0016 #include "TGFrame.h"
0017 
0018 // user include files
0019 #include "Fireworks/Core/interface/FWSummaryManager.h"
0020 #include "Fireworks/Core/interface/FWSelectionManager.h"
0021 #include "Fireworks/Core/interface/FWEventItemsManager.h"
0022 #include "Fireworks/Core/interface/FWModelChangeManager.h"
0023 #include "Fireworks/Core/interface/FWColorManager.h"
0024 #include "Fireworks/Core/interface/FWGUIManager.h"
0025 #include "Fireworks/Core/interface/FWEventItem.h"
0026 
0027 #include "Fireworks/Core/src/FWCollectionSummaryWidget.h"
0028 #include "Fireworks/Core/interface/FWDataCategories.h"
0029 
0030 #include "Fireworks/Core/src/FWCompactVerticalLayout.h"
0031 
0032 //
0033 // constants, enums and typedefs
0034 //
0035 
0036 //
0037 // static data member definitions
0038 //
0039 
0040 //
0041 // constructors and destructor
0042 //
0043 FWSummaryManager::FWSummaryManager(TGFrame* iParent,
0044                                    FWSelectionManager* sm,
0045                                    FWEventItemsManager* eim,
0046                                    FWGUIManager* gm,
0047                                    FWModelChangeManager* cm,
0048                                    FWColorManager* colorm)
0049     : m_guiManager(gm), m_colorManager(colorm), m_itemChanged(false) {
0050   colorm->colorsHaveChanged_.connect(std::bind(&FWSummaryManager::colorsChanged, this));
0051   sm->selectionChanged_.connect(std::bind(&FWSummaryManager::selectionChanged, this, std::placeholders::_1));
0052   eim->newItem_.connect(std::bind(&FWSummaryManager::newItem, this, std::placeholders::_1));
0053   eim->goingToClearItems_.connect(std::bind(&FWSummaryManager::removeAllItems, this));
0054   eim->goingToClearItems_.connect(std::bind(&FWModelChangeManager::itemsGoingToBeClearedSlot, cm));
0055 
0056   m_pack = new TGVerticalFrame(iParent);
0057   m_pack->SetLayoutManager(new FWCompactVerticalLayout(m_pack));
0058   const unsigned int backgroundColor = 0x2f2f2f;
0059   m_pack->SetBackgroundColor(backgroundColor);
0060   cm->changeSignalsAreDone_.connect(std::bind(&FWSummaryManager::changesDone, this));
0061 }
0062 
0063 // FWSummaryManager::FWSummaryManager(const FWSummaryManager& rhs)
0064 // {
0065 //    // do actual copying here;
0066 // }
0067 
0068 FWSummaryManager::~FWSummaryManager() {}
0069 
0070 //
0071 // assignment operators
0072 //
0073 // const FWSummaryManager& FWSummaryManager::operator=(const FWSummaryManager& rhs)
0074 // {
0075 //   //An exception safe implementation is
0076 //   FWSummaryManager temp(rhs);
0077 //   swap(rhs);
0078 //
0079 //   return *this;
0080 // }
0081 
0082 //
0083 // member functions
0084 //
0085 void FWSummaryManager::newItem(FWEventItem* iItem) {
0086   TGLayoutHints* hints = new TGLayoutHints(kLHintsExpandX);
0087   FWCollectionSummaryWidget* lst = new FWCollectionSummaryWidget(m_pack, *iItem, hints);
0088   m_pack->AddFrame(lst, hints);
0089   m_collectionWidgets.push_back(lst);
0090   bool backgroundIsWhite = m_colorManager->backgroundColorIndex() == FWColorManager::kWhiteIndex;
0091   lst->setBackgroundToWhite(backgroundIsWhite);
0092   iItem->goingToBeDestroyed_.connect(std::bind(&FWSummaryManager::itemDestroyed, this, std::placeholders::_1));
0093   iItem->itemChanged_.connect(std::bind(&FWSummaryManager::itemChanged, this, std::placeholders::_1));
0094   lst->Connect("requestForInfo(FWEventItem*)", "FWSummaryManager", this, "requestForInfo(FWEventItem*)");
0095   lst->Connect("requestForFilter(FWEventItem*)", "FWSummaryManager", this, "requestForFilter(FWEventItem*)");
0096   lst->Connect("requestForErrorInfo(FWEventItem*)", "FWSummaryManager", this, "requestForError(FWEventItem*)");
0097   lst->Connect("requestForController(FWEventItem*)", "FWSummaryManager", this, "requestForController(FWEventItem*)");
0098   lst->Connect("requestForModelContextMenu(Int_t,Int_t)",
0099                "FWSummaryManager",
0100                this,
0101                "requestForSelectedModelContextMenu(Int_t,Int_t)");
0102 }
0103 
0104 void FWSummaryManager::itemDestroyed(const FWEventItem* iItem) {
0105   m_pack->HideFrame(m_collectionWidgets[iItem->id()]);
0106   m_pack->RemoveFrame(m_collectionWidgets[iItem->id()]);
0107   delete m_collectionWidgets[iItem->id()];
0108   m_collectionWidgets[iItem->id()] = nullptr;
0109   m_pack->Layout();
0110   gClient->NeedRedraw(m_pack);
0111 }
0112 
0113 void FWSummaryManager::itemChanged(const FWEventItem*) { m_itemChanged = true; }
0114 
0115 void FWSummaryManager::removeAllItems() {
0116   for (std::vector<FWCollectionSummaryWidget*>::iterator it = m_collectionWidgets.begin(),
0117                                                          itEnd = m_collectionWidgets.end();
0118        it != itEnd;
0119        ++it) {
0120     if (nullptr != *it) {
0121       m_pack->HideFrame(*it);
0122       m_pack->RemoveFrame(*it);
0123       delete *it;
0124       *it = nullptr;
0125     }
0126   }
0127   m_collectionWidgets.clear();
0128   m_pack->Layout();
0129   gClient->NeedRedraw(m_pack);
0130 }
0131 
0132 void FWSummaryManager::selectionChanged(const FWSelectionManager& iSM) {}
0133 
0134 void FWSummaryManager::changesDone() {
0135   if (m_itemChanged) {
0136     m_pack->Layout();
0137     m_itemChanged = false;
0138   }
0139 }
0140 
0141 void FWSummaryManager::colorsChanged() {
0142   bool backgroundIsWhite = m_colorManager->backgroundColorIndex() == FWColorManager::kWhiteIndex;
0143 
0144   if (m_colorManager->isColorSetLight()) {
0145     m_pack->SetBackgroundColor(TGFrame::GetDefaultFrameBackground());
0146   } else {
0147     const unsigned int backgroundColor = 0x2f2f2f;
0148     m_pack->SetBackgroundColor(backgroundColor);
0149   }
0150   gClient->NeedRedraw(m_pack);
0151   for (std::vector<FWCollectionSummaryWidget*>::iterator it = m_collectionWidgets.begin(),
0152                                                          itEnd = m_collectionWidgets.end();
0153        it != itEnd;
0154        ++it) {
0155     if (nullptr != *it) {
0156       (*it)->setBackgroundToWhite(backgroundIsWhite);
0157     }
0158   }
0159 }
0160 
0161 void FWSummaryManager::requestForInfo(FWEventItem* iItem) { m_guiManager->showEDIFrame(kData); }
0162 void FWSummaryManager::requestForFilter(FWEventItem* iItem) { m_guiManager->showEDIFrame(kFilter); }
0163 void FWSummaryManager::requestForError(FWEventItem* iItem) { m_guiManager->showEDIFrame(); }
0164 
0165 void FWSummaryManager::requestForController(FWEventItem* iItem) { m_guiManager->showEDIFrame(); }
0166 
0167 void FWSummaryManager::requestForSelectedModelContextMenu(Int_t iGlobalX, Int_t iGlobalY) {
0168   m_guiManager->showSelectedModelContextMenu(iGlobalX, iGlobalY, nullptr);
0169 }
0170 
0171 //
0172 // const member functions
0173 //
0174 TGCompositeFrame* FWSummaryManager::widget() const { return m_pack; }
0175 
0176 //
0177 // static member functions
0178 //