CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

FWGUIEventDataAdder Class Reference

#include <Fireworks/Core/interface/FWGUIEventDataAdder.h>

List of all members.

Public Member Functions

void addNewItem ()
void addNewItemAndClose ()
 FWGUIEventDataAdder (UInt_t w, UInt_t, FWEventItemsManager *, TGFrame *, FWJobMetadataManager *)
void metadataUpdatedSlot (void)
void resetNameEntry ()
void rowClicked (Int_t iRow, Int_t iButton, Int_t iKeyMod, Int_t, Int_t)
void show ()
void updateFilterString (const char *str)
void windowIsClosing ()
virtual ~FWGUIEventDataAdder ()

Private Member Functions

void createWindow ()
 FWGUIEventDataAdder (const FWGUIEventDataAdder &)
void newIndexSelected (int)
const FWGUIEventDataAdderoperator= (const FWGUIEventDataAdder &)

Private Attributes

TGTextButton * m_apply
TGTextButton * m_applyAndClose
TGCheckButton * m_doNotUseProcessName
std::string m_expr
TGTransientFrame * m_frame
FWEventItemsManagerm_manager
FWJobMetadataManagerm_metadataManager
std::string m_moduleLabel
TGTextEntry * m_name
TGFrame * m_parentFrame
std::string m_processName
std::string m_productInstanceLabel
std::string m_purpose
TGTextEntry * m_search
DataAdderTableManagerm_tableManager
FWTableWidgetm_tableWidget
std::string m_type

Detailed Description

Description: <one line="" class="" summary>="">

Usage: <usage>

Definition at line 41 of file FWGUIEventDataAdder.h.


Constructor & Destructor Documentation

FWGUIEventDataAdder::FWGUIEventDataAdder ( UInt_t  w,
UInt_t  iHeight,
FWEventItemsManager iManager,
TGFrame *  iParent,
FWJobMetadataManager iMetadataManager 
)
FWGUIEventDataAdder::~FWGUIEventDataAdder ( ) [virtual]

Definition at line 371 of file FWGUIEventDataAdder.cc.

{
   /*
    // m_frame->Cleanup();
    // delete m_frame;
    m_frame=0;
    // delete m_tableWidget;
    m_tableWidget=0;
    delete m_tableManager;
    m_tableManager=0;
    */
}
FWGUIEventDataAdder::FWGUIEventDataAdder ( const FWGUIEventDataAdder ) [private]

Member Function Documentation

void FWGUIEventDataAdder::addNewItem ( )

Definition at line 400 of file FWGUIEventDataAdder.cc.

References FWEventItemsManager::add(), FWEventItemsManager::begin(), FWDisplayProperties::defaultProperties, FWEventItemsManager::end(), FWEventItemsManager::find(), fwLog, fwlog::kWarning, m_doNotUseProcessName, m_frame, m_manager, m_moduleLabel, m_name, m_processName, m_productInstanceLabel, m_purpose, m_type, moduleLabel(), runTheMatrix::msg, and AlCaRecoCosmics_cfg::name.

Referenced by addNewItemAndClose().

{
   TClass* theClass = TClass::GetClass(m_type.c_str());
   if(0==theClass) {
      return;
   }
   const std::string moduleLabel = m_moduleLabel;
   if(moduleLabel.empty()) {
      return;
   }

   const std::string name = m_name->GetText();
   if(name.empty()) {
      return;
   }

   if ( m_manager->find( name ) ) {
      TString msg("Event item '");
      msg += name;
      msg += "' is already registered. Please use another name.";
      fwLog(fwlog::kWarning) << msg.Data() << std::endl;
      new TGMsgBox(gClient->GetDefaultRoot(), m_frame,
                   "Error - Name conflict", msg, kMBIconExclamation, kMBOk);
      return;
   }

   int largest = -1;
   if(m_manager->begin() != m_manager->end()) {
      if ( *(m_manager->begin()) )
         largest = (*(m_manager->begin()))->layer();
   }
   for(FWEventItemsManager::const_iterator it = m_manager->begin(),
                                           itEnd = m_manager->end();
       it!=itEnd;
       ++it) {
      if((*it) && largest < (*it)->layer()) {
         largest = (*it)->layer();
      }
   }
   ++largest;
   std::string processName = m_processName;
   if(m_doNotUseProcessName->IsOn() && m_doNotUseProcessName->IsEnabled()) {
      processName="";
   }
   FWPhysicsObjectDesc desc(name, theClass, m_purpose,
                            FWDisplayProperties::defaultProperties,
                            moduleLabel,
                            m_productInstanceLabel,
                            processName,
                            "",
                            largest);
   m_manager->add(desc);
}
void FWGUIEventDataAdder::addNewItemAndClose ( )

Definition at line 455 of file FWGUIEventDataAdder.cc.

References addNewItem(), and windowIsClosing().

void FWGUIEventDataAdder::createWindow ( ) [private]

Definition at line 496 of file FWGUIEventDataAdder.cc.

References FWDialogBuilder::addCheckbox(), FWDialogBuilder::addLabel(), FWDialogBuilder::addTable(), FWDialogBuilder::addTextButton(), FWDialogBuilder::addTextEntry(), FWTableWidget::disableGrowInWidth(), FWDialogBuilder::expand(), FWDialogBuilder::floatLeft(), FWDialogBuilder::frameSpaceDown(), FWDialogBuilder::frameSpaceUpDown(), FWDialogBuilder::hSpacer(), FWDialogBuilder::indent(), DataAdderTableManager::indexSelected_, m_apply, m_applyAndClose, m_doNotUseProcessName, m_frame, m_metadataManager, m_name, m_parentFrame, m_search, m_tableManager, m_tableWidget, newIndexSelected(), FWTableWidget::SetBackgroundColor(), FWTableWidget::SetHeaderBackgroundColor(), FWTableWidget::SetLineSeparatorColor(), FWDialogBuilder::spaceDown(), FWDialogBuilder::spaceRight(), and FWDialogBuilder::spaceUp().

Referenced by FWGUIEventDataAdder(), and show().

{
   m_tableManager = new DataAdderTableManager(m_metadataManager);
   m_tableManager->indexSelected_.connect(boost::bind(&FWGUIEventDataAdder::newIndexSelected,this,_1));

   m_frame = new TGTransientFrame(gClient->GetDefaultRoot(),m_parentFrame,600,400);
   m_frame->Connect("CloseWindow()","FWGUIEventDataAdder",this,"windowIsClosing()");

   FWDialogBuilder builder(m_frame);
   TGTextButton *cancelButton, *resetButton;
   
   builder.indent(10)
          .spaceDown(15)
          .addLabel("Search:", 0).expand(false).spaceUp(4).floatLeft(4)
          .addTextEntry("", &m_search).spaceUp(0)
          .frameSpaceDown(10)
          .addLabel("Viewable Collections", 8)
          .frameSpaceDown(5)
          .addTable(m_tableManager, &m_tableWidget).expand(true, true)
          .addLabel("Name:", 0).expand(false).spaceUp(4).floatLeft(4)
          .addTextEntry("", &m_name).spaceUp(0).floatLeft(4)
          .addTextButton(" Reset  ", &resetButton).expand(false, false)
          .frameSpaceUpDown(5)
          .addCheckbox("Do not use Process Name and "
                       "instead only get this data "
                       "from the most recent Process",
                       &m_doNotUseProcessName)
          .frameSpaceDown(15)
          .hSpacer().floatLeft(0)
          .addTextButton(" Close  ", &cancelButton).expand(false).floatLeft(4)
          .addTextButton(" Add Data  ", &m_apply).expand(false).floatLeft(4)
          .addTextButton(" Add Data && Close  ", &m_applyAndClose).expand(false)
                                .spaceRight(25).spaceDown(15);

   m_search->Connect("TextChanged(const char *)", "FWGUIEventDataAdder", 
                     this, "updateFilterString(const char *)");
   m_search->SetEnabled(true);
   m_tableWidget->SetBackgroundColor(0xffffff);
   m_tableWidget->SetLineSeparatorColor(0x000000);
   m_tableWidget->SetHeaderBackgroundColor(0xececec);
   m_tableWidget->Connect("rowClicked(Int_t,Int_t,Int_t,Int_t,Int_t)",
                          "FWGUIEventDataAdder",this,
                          "rowClicked(Int_t,Int_t,Int_t,Int_t,Int_t)");

   m_tableWidget->disableGrowInWidth();
   m_name->SetState(true);
   resetButton->SetEnabled(true);
   resetButton->Connect("Clicked()", "FWGUIEventDataAdder", this, "resetNameEntry()");
   m_doNotUseProcessName->SetState(kButtonDown);
   cancelButton->Connect("Clicked()","FWGUIEventDataAdder", this, "windowIsClosing()");
   cancelButton->SetEnabled(true);
   m_apply->Connect("Clicked()", "FWGUIEventDataAdder", this, "addNewItem()");
   m_applyAndClose->Connect("Clicked()", "FWGUIEventDataAdder", this, "addNewItemAndClose()");
   
   m_frame->SetWindowName("Add Collection");
   m_frame->MapSubwindows();
   m_frame->Layout();
}
void FWGUIEventDataAdder::metadataUpdatedSlot ( void  )

Slot for the metadataChanged signal of the FWJobMetadataManager. Whenever metadata changes, for whatever reason (e.g. a new file), we need to update the table.

Definition at line 560 of file FWGUIEventDataAdder.cc.

References m_tableManager, DataAdderTableManager::reset(), and FWTableManagerBase::sort().

Referenced by FWGUIEventDataAdder().

void FWGUIEventDataAdder::newIndexSelected ( int  iSelectedIndex) [private]

Definition at line 573 of file FWGUIEventDataAdder.cc.

References getHLTprescales::index, m_apply, m_applyAndClose, m_doNotUseProcessName, m_metadataManager, m_moduleLabel, m_name, m_processName, m_productInstanceLabel, m_purpose, m_type, FWJobMetadataManager::processNamesInJob(), and FWJobMetadataManager::usableData().

Referenced by createWindow().

{
   if(-1 != iSelectedIndex) {
      std::vector<FWJobMetadataManager::Data> &metadata = m_metadataManager->usableData();
      m_purpose = metadata[iSelectedIndex].purpose_;
      m_type = metadata[iSelectedIndex].type_;
      std::string oldModuleLabel = m_moduleLabel;
      m_moduleLabel = metadata[iSelectedIndex].moduleLabel_;
      m_productInstanceLabel = metadata[iSelectedIndex].productInstanceLabel_;
      m_processName = metadata[iSelectedIndex].processName_;
      
      if(strlen(m_name->GetText())==0 || oldModuleLabel == m_name->GetText()) {
         m_name->SetText(m_moduleLabel.c_str());
      }
      m_apply->SetEnabled(true);
      m_applyAndClose->SetEnabled(true);

      //Check to see if this is the last process, if it is then we can let the user decide
      // to not use the process name when doing the lookup.  This makes a saved configuration
      // more robust.  However, if they choose a collection not from the last process then we need the
      // process name in order to correctly get the data they want
      bool isMostRecentProcess =true;
      int index = 0;
      for(std::vector<FWJobMetadataManager::Data>::iterator it = metadata.begin(), itEnd = metadata.end();
          it != itEnd && isMostRecentProcess;
          ++it,++index) {
         if(index == iSelectedIndex) {continue;}
         if(it->moduleLabel_ == m_moduleLabel &&
            it->purpose_ == m_purpose &&
            it->type_ == m_type &&
            it->productInstanceLabel_ == m_productInstanceLabel) {
            //see if this process is newer than the data requested
            
            for(size_t pni = 0, pne = m_metadataManager->processNamesInJob().size();
                pni != pne; ++pni) 
            {
               const std::string &processName = m_metadataManager->processNamesInJob()[pni];
               if (m_processName == processName)
                  break;

               if(it->processName_ == processName) 
               {
                  isMostRecentProcess = false;
                  break;
               }
            }
         }
      }
      if(isMostRecentProcess) {
         if(!m_doNotUseProcessName->IsEnabled()) {
            m_doNotUseProcessName->SetEnabled(true);
         }
      } else {
         //NOTE: must remember state before we get here because 'enable' and 'on' are mutually
         // exlcusive :(
         m_doNotUseProcessName->SetEnabled(false);
      }
   }
}
const FWGUIEventDataAdder& FWGUIEventDataAdder::operator= ( const FWGUIEventDataAdder ) [private]
void FWGUIEventDataAdder::resetNameEntry ( )

Definition at line 567 of file FWGUIEventDataAdder.cc.

References m_apply, m_moduleLabel, and m_name.

{
   m_name->SetText(m_apply->IsEnabled() ? m_moduleLabel.c_str() : "", kFALSE);
}
void FWGUIEventDataAdder::rowClicked ( Int_t  iRow,
Int_t  iButton,
Int_t  iKeyMod,
Int_t  ,
Int_t   
)

Definition at line 634 of file FWGUIEventDataAdder.cc.

References m_tableManager, and DataAdderTableManager::setSelection().

{
   if(iButton==kButton1) {
      m_tableManager->setSelection(iRow,iKeyMod);
   }
}
void FWGUIEventDataAdder::show ( void  )

Definition at line 462 of file FWGUIEventDataAdder.cc.

References createWindow(), and m_frame.

Referenced by FWGUIManager::addData().

{
   // Map main frame
   if(0==m_frame) {
      createWindow();
   }
   m_frame->MapWindow();
}
void FWGUIEventDataAdder::updateFilterString ( const char *  str)
void FWGUIEventDataAdder::windowIsClosing ( )

Definition at line 472 of file FWGUIEventDataAdder.cc.

References m_apply, m_applyAndClose, m_frame, m_moduleLabel, m_name, m_processName, m_productInstanceLabel, m_purpose, m_search, and m_type.

Referenced by addNewItemAndClose().

{
   m_name->SetText("");
   m_search->SetText("");
   m_purpose.clear();
   m_type.clear();
   m_moduleLabel.clear();
   m_processName.clear();
   m_productInstanceLabel.clear();
   m_apply->SetEnabled(false);
   m_applyAndClose->SetEnabled(false);
   
   m_frame->UnmapWindow();
   m_frame->DontCallClose();
}

Member Data Documentation

TGTextButton* FWGUIEventDataAdder::m_apply [private]
TGTextButton* FWGUIEventDataAdder::m_applyAndClose [private]

Definition at line 84 of file FWGUIEventDataAdder.h.

Referenced by createWindow(), newIndexSelected(), and windowIsClosing().

Definition at line 82 of file FWGUIEventDataAdder.h.

Referenced by addNewItem(), createWindow(), and newIndexSelected().

std::string FWGUIEventDataAdder::m_expr [private]

Definition at line 94 of file FWGUIEventDataAdder.h.

TGTransientFrame* FWGUIEventDataAdder::m_frame [private]

Definition at line 80 of file FWGUIEventDataAdder.h.

Referenced by addNewItem(), createWindow(), show(), and windowIsClosing().

Definition at line 76 of file FWGUIEventDataAdder.h.

Referenced by addNewItem().

Definition at line 77 of file FWGUIEventDataAdder.h.

Referenced by createWindow(), FWGUIEventDataAdder(), and newIndexSelected().

std::string FWGUIEventDataAdder::m_moduleLabel [private]
TGTextEntry* FWGUIEventDataAdder::m_name [private]

Definition at line 79 of file FWGUIEventDataAdder.h.

Referenced by createWindow().

std::string FWGUIEventDataAdder::m_processName [private]

Definition at line 92 of file FWGUIEventDataAdder.h.

Referenced by addNewItem(), newIndexSelected(), and windowIsClosing().

Definition at line 91 of file FWGUIEventDataAdder.h.

Referenced by addNewItem(), newIndexSelected(), and windowIsClosing().

std::string FWGUIEventDataAdder::m_purpose [private]

Definition at line 87 of file FWGUIEventDataAdder.h.

Referenced by addNewItem(), newIndexSelected(), and windowIsClosing().

TGTextEntry* FWGUIEventDataAdder::m_search [private]

Definition at line 85 of file FWGUIEventDataAdder.h.

Referenced by createWindow(), and windowIsClosing().

Definition at line 97 of file FWGUIEventDataAdder.h.

Referenced by createWindow().

std::string FWGUIEventDataAdder::m_type [private]

Definition at line 89 of file FWGUIEventDataAdder.h.

Referenced by addNewItem(), newIndexSelected(), and windowIsClosing().