CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/Fireworks/Core/src/FWSummaryManager.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     Core
00004 // Class  :     FWSummaryManager
00005 //
00006 // Implementation:
00007 //     <Notes on implementation>
00008 //
00009 // Original Author:  Chris Jones
00010 //         Created:  Tue Mar  4 09:35:32 EST 2008
00011 // $Id: FWSummaryManager.cc,v 1.22 2010/06/18 10:17:16 yana Exp $
00012 //
00013 
00014 // system include files
00015 #include <boost/bind.hpp>
00016 
00017 #include "TGFrame.h"
00018 
00019 // user include files
00020 #include "Fireworks/Core/interface/FWSummaryManager.h"
00021 #include "Fireworks/Core/interface/FWSelectionManager.h"
00022 #include "Fireworks/Core/interface/FWEventItemsManager.h"
00023 #include "Fireworks/Core/interface/FWModelChangeManager.h"
00024 #include "Fireworks/Core/interface/FWColorManager.h"
00025 #include "Fireworks/Core/interface/FWGUIManager.h"
00026 #include "Fireworks/Core/interface/FWEventItem.h"
00027 
00028 #include "Fireworks/Core/src/FWCollectionSummaryWidget.h"
00029 #include "Fireworks/Core/interface/FWDataCategories.h"
00030 
00031 #include "Fireworks/Core/src/FWCompactVerticalLayout.h"
00032 
00033 //
00034 // constants, enums and typedefs
00035 //
00036 
00037 //
00038 // static data member definitions
00039 //
00040 
00041 //
00042 // constructors and destructor
00043 //
00044 FWSummaryManager::FWSummaryManager(TGFrame* iParent,
00045                                    FWSelectionManager* sm,
00046                                    FWEventItemsManager* eim,
00047                                    FWGUIManager* gm,
00048                                    FWModelChangeManager* cm,
00049                                    FWColorManager* colorm
00050 ) :
00051    m_guiManager(gm),
00052    m_colorManager(colorm),
00053 m_itemChanged(false)
00054 {
00055    colorm->colorsHaveChanged_.connect(boost::bind(&FWSummaryManager::colorsChanged,this));
00056    sm->selectionChanged_.connect(boost::bind(&FWSummaryManager::selectionChanged,this,_1));
00057    eim->newItem_.connect(boost::bind(&FWSummaryManager::newItem,
00058                                      this, _1) );
00059    eim->goingToClearItems_.connect(boost::bind(&FWSummaryManager::removeAllItems, this));
00060    eim->goingToClearItems_.connect(boost::bind(&FWModelChangeManager::itemsGoingToBeClearedSlot, cm));
00061 
00062    m_pack = new TGVerticalFrame(iParent);
00063    m_pack->SetLayoutManager( new FWCompactVerticalLayout(m_pack));
00064    const unsigned int backgroundColor=0x2f2f2f;
00065    m_pack->SetBackgroundColor(backgroundColor);
00066    cm->changeSignalsAreDone_.connect(boost::bind(&FWSummaryManager::changesDone,this));
00067 }
00068 
00069 // FWSummaryManager::FWSummaryManager(const FWSummaryManager& rhs)
00070 // {
00071 //    // do actual copying here;
00072 // }
00073 
00074 FWSummaryManager::~FWSummaryManager()
00075 {
00076 }
00077 
00078 //
00079 // assignment operators
00080 //
00081 // const FWSummaryManager& FWSummaryManager::operator=(const FWSummaryManager& rhs)
00082 // {
00083 //   //An exception safe implementation is
00084 //   FWSummaryManager temp(rhs);
00085 //   swap(rhs);
00086 //
00087 //   return *this;
00088 // }
00089 
00090 //
00091 // member functions
00092 //
00093 void
00094 FWSummaryManager::newItem(FWEventItem* iItem)
00095 {
00096    TGLayoutHints* hints = new TGLayoutHints(kLHintsExpandX);
00097    FWCollectionSummaryWidget* lst = new FWCollectionSummaryWidget(m_pack,*iItem,hints);
00098    m_pack->AddFrame(lst, hints);
00099    m_collectionWidgets.push_back(lst);
00100    bool backgroundIsWhite = m_colorManager->backgroundColorIndex()==FWColorManager::kWhiteIndex;
00101    lst->setBackgroundToWhite(backgroundIsWhite);
00102    iItem->goingToBeDestroyed_.connect(boost::bind(&FWSummaryManager::itemDestroyed,this,_1));
00103    iItem->itemChanged_.connect(boost::bind(&FWSummaryManager::itemChanged,this,_1));
00104    lst->Connect("requestForInfo(FWEventItem*)","FWSummaryManager",this,"requestForInfo(FWEventItem*)");
00105    lst->Connect("requestForFilter(FWEventItem*)","FWSummaryManager",this,"requestForFilter(FWEventItem*)");
00106    lst->Connect("requestForErrorInfo(FWEventItem*)","FWSummaryManager",this,"requestForError(FWEventItem*)");
00107    lst->Connect("requestForController(FWEventItem*)","FWSummaryManager",this,"requestForController(FWEventItem*)");
00108    lst->Connect("requestForModelContextMenu(Int_t,Int_t)","FWSummaryManager",this,"requestForSelectedModelContextMenu(Int_t,Int_t)");
00109 }
00110 
00111 void 
00112 FWSummaryManager::itemDestroyed(const FWEventItem* iItem)
00113 {
00114    m_pack->HideFrame(m_collectionWidgets[iItem->id()]);
00115    m_pack->RemoveFrame(m_collectionWidgets[iItem->id()]);
00116    delete m_collectionWidgets[iItem->id()];
00117    m_collectionWidgets[iItem->id()]=0;
00118    m_pack->Layout();
00119    gClient->NeedRedraw(m_pack);
00120 }
00121 
00122 void
00123 FWSummaryManager::itemChanged(const FWEventItem*)
00124 {
00125    m_itemChanged = true;
00126 }
00127 
00128 void
00129 FWSummaryManager::removeAllItems()
00130 {
00131    for(std::vector<FWCollectionSummaryWidget*>::iterator it = m_collectionWidgets.begin(), 
00132        itEnd = m_collectionWidgets.end();
00133        it != itEnd;
00134        ++it) {
00135       if(0!=*it) {
00136          m_pack->HideFrame(*it);
00137          m_pack->RemoveFrame(*it);
00138          delete *it;
00139          *it=0;
00140       }
00141    }
00142    m_collectionWidgets.clear();
00143    m_pack->Layout();
00144    gClient->NeedRedraw(m_pack);
00145 }
00146 
00147 void
00148 FWSummaryManager::selectionChanged(const FWSelectionManager& iSM)
00149 {
00150 }
00151 
00152 void
00153 FWSummaryManager::changesDone()
00154 {
00155    if(m_itemChanged) {
00156       m_pack->Layout();
00157       m_itemChanged=false;
00158    }
00159 }
00160 
00161 void
00162 FWSummaryManager::colorsChanged()
00163 {
00164    bool backgroundIsWhite = m_colorManager->backgroundColorIndex()==FWColorManager::kWhiteIndex;
00165    
00166    if(m_colorManager->isColorSetLight()) {
00167       m_pack->SetBackgroundColor(TGFrame::GetDefaultFrameBackground());
00168    } else {
00169       const unsigned int backgroundColor=0x2f2f2f;
00170       m_pack->SetBackgroundColor(backgroundColor);
00171    }
00172    gClient->NeedRedraw(m_pack);
00173    for(std::vector<FWCollectionSummaryWidget*>::iterator it = m_collectionWidgets.begin(), 
00174           itEnd = m_collectionWidgets.end();
00175        it != itEnd;
00176        ++it) {
00177       if(0!=*it) {
00178          (*it)->setBackgroundToWhite(backgroundIsWhite);
00179       }
00180    }
00181 }
00182 
00183 void 
00184 FWSummaryManager::requestForInfo(FWEventItem* iItem)
00185 {
00186    m_guiManager->showEDIFrame(kData);
00187 }
00188 void 
00189 FWSummaryManager::requestForFilter(FWEventItem* iItem)
00190 {
00191    m_guiManager->showEDIFrame(kFilter);
00192 }
00193 void 
00194 FWSummaryManager::requestForError(FWEventItem* iItem)
00195 {
00196    m_guiManager->showEDIFrame();
00197 }
00198 
00199 void 
00200 FWSummaryManager::requestForController(FWEventItem* iItem)
00201 {
00202    m_guiManager->showEDIFrame();
00203 }
00204 
00205 void 
00206 FWSummaryManager::requestForSelectedModelContextMenu(Int_t iGlobalX, Int_t iGlobalY)
00207 {
00208    m_guiManager->showSelectedModelContextMenu(iGlobalX,iGlobalY,0);
00209 }
00210 
00211 //
00212 // const member functions
00213 //
00214 TGCompositeFrame*
00215 FWSummaryManager::widget() const
00216 {
00217    return m_pack;
00218 }
00219 
00220 //
00221 // static member functions
00222 //