CMS 3D CMS Logo

Public Types | Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Friends

FWGeometryBrowser Class Reference

#include <FWGeometryBrowser.h>

Inheritance diagram for FWGeometryBrowser:
FWConfigurableParameterizable FWParameterSetterEditorBase FWParameterizable FWConfigurable

List of all members.

Public Types

enum  EMode { kNode, kVolume }

Public Member Functions

virtual void addTo (FWConfiguration &) const
void browse ()
void cellClicked (Int_t iRow, Int_t iColumn, Int_t iButton, Int_t iKeyMod, Int_t iGlobalX, Int_t iGlobalY)
 FWGeometryBrowser (FWGUIManager *)
Bool_t HandleKey (Event_t *event)
void newIndexSelected (int, int)
void readFile ()
virtual void setFrom (const FWConfiguration &)
void updateStatusBar (const char *status)
void windowIsClosing ()
virtual ~FWGeometryBrowser ()

Protected Attributes

FWLongParameter m_autoExpand
FWStringParameter m_filter
FWLongParameter m_maxDaughters
FWEnumParameter m_mode

Private Member Functions

 ClassDef (FWGeometryBrowser, 0)
 FWGeometryBrowser (const FWGeometryBrowser &)
void makeSetter (TGCompositeFrame *frame, FWParameterBase *param)
const FWGeometryBrowseroperator= (const FWGeometryBrowser &)
void resetSetters ()

Private Attributes

TGTextButton * m_fileOpen
TFile * m_geometryFile
FWGUIManagerm_guiManager
std::vector< boost::shared_ptr
< FWParameterSetterBase > > 
m_setters
TGCompositeFrame * m_settersFrame
TGStatusBar * m_statBar
FWGeometryTableManagerm_tableManager
FWTableWidgetm_tableWidget

Friends

class FWGeometryTableManager

Detailed Description

Definition at line 34 of file FWGeometryBrowser.h.


Member Enumeration Documentation

Enumerator:
kNode 
kVolume 

Definition at line 42 of file FWGeometryBrowser.h.

{ kNode, kVolume };

Constructor & Destructor Documentation

FWGeometryBrowser::FWGeometryBrowser ( FWGUIManager guiManager)

Definition at line 20 of file FWGeometryBrowser.cc.

References FWEnumParameter::addEntry(), FWTableWidget::disableGrowInWidth(), FWGeometryTableManager, m_fileOpen, m_mode, m_settersFrame, m_statBar, m_tableManager, m_tableWidget, resetSetters(), FWTableWidget::SetBackgroundColor(), FWTableWidget::SetHeaderBackgroundColor(), and FWTableWidget::SetLineSeparatorColor().

   : TGMainFrame(gClient->GetRoot(), 600, 500),
     m_mode(this, "Mode:", 1l, 0l, 1l),
     m_filter(this,"Materials:",std::string()),
     m_autoExpand(this,"AutoExpand:", 5l, 0l, 1000l),
     m_maxDaughters(this,"MaxChildren:", 999l, 0l, 1000l), // debug
     m_guiManager(guiManager),
     m_tableManager(0),
     m_geometryFile(0),
     m_fileOpen(0),
     m_settersFrame(0)
{
   m_mode.addEntry(0, "Node");
   m_mode.addEntry(1, "Volume");
   
   m_tableManager = new FWGeometryTableManager(this);
 
   TGTextButton* m_fileOpen = new TGTextButton (this, "Open Geometry File");
   this->AddFrame(m_fileOpen,  new TGLayoutHints( kLHintsExpandX , 4, 2, 2, 2));
   m_fileOpen->Connect("Clicked()","FWGeometryBrowser",this,"browse()");


   m_settersFrame = new TGHorizontalFrame(this);
   this->AddFrame( m_settersFrame,new TGLayoutHints(kLHintsExpandX, 2, 2, 2, 2));
   m_settersFrame->SetCleanup(kDeepCleanup);

   m_tableWidget = new FWTableWidget(m_tableManager, this); 
   AddFrame(m_tableWidget,new TGLayoutHints(kLHintsExpandX|kLHintsExpandY,2,2,2,2));
   m_tableWidget->SetBackgroundColor(0xffffff);
   m_tableWidget->SetLineSeparatorColor(0x000000);
   m_tableWidget->SetHeaderBackgroundColor(0xececec);
   m_tableWidget->Connect("cellClicked(Int_t,Int_t,Int_t,Int_t,Int_t,Int_t)",
                          "FWGeometryBrowser",this,
                          "cellClicked(Int_t,Int_t,Int_t,Int_t,Int_t,Int_t)");
   m_tableWidget->disableGrowInWidth();
   resetSetters();

   m_statBar = new TGStatusBar(this, this->GetWidth(), 12);
   m_statBar->SetText("No simulation geomtery loaded.");
   AddFrame(m_statBar, new TGLayoutHints(kLHintsExpandX));

   SetWindowName("Geometry Browser");
   this->Connect("CloseWindow()","FWGeometryBrowser",this,"windowIsClosing()");
   Layout();
   MapSubwindows();

   gVirtualX->SelectInput(GetId(), kKeyPressMask | kKeyReleaseMask | kExposureMask |
                          kPointerMotionMask | kStructureNotifyMask | kFocusChangeMask |
                          kEnterWindowMask | kLeaveWindowMask);
}
FWGeometryBrowser::~FWGeometryBrowser ( ) [virtual]

Definition at line 71 of file FWGeometryBrowser.cc.

{}
FWGeometryBrowser::FWGeometryBrowser ( const FWGeometryBrowser ) [private]

Member Function Documentation

void FWGeometryBrowser::addTo ( FWConfiguration iTo) const [virtual]

Reimplemented from FWConfigurableParameterizable.

Definition at line 109 of file FWGeometryBrowser.cc.

Referenced by FWGUIManager::addTo().

void FWGeometryBrowser::browse ( )

Definition at line 204 of file FWGeometryBrowser.cc.

References FWGUIManager::clearStatus(), gather_cfg::cout, geodebug, FWGUIManager::getMainFrame(), m_geometryFile, m_guiManager, readFile(), and FWGUIManager::updateStatus().

Referenced by FWGUIManager::showGeometryBrowser().

{
   std::cout<<"FWGeometryBrowser::openFile()"<<std::endl;

   if (!geodebug)
   {  
      const char* kRootType[] = {"ROOT files","*.root", 0, 0};
      TGFileInfo fi;
      fi.fFileTypes = kRootType;
 
      m_guiManager->updateStatus("opening geometry file...");

      new TGFileDialog(gClient->GetDefaultRoot(), 
                       (TGWindow*) m_guiManager->getMainFrame(), kFDOpen, &fi);

      m_guiManager->updateStatus("loading geometry file...");
      m_geometryFile = new TFile(fi.fFilename, "READ");
   }
   else
   {
      // AMT developing environment
      m_geometryFile = new TFile("cmsSimGeom-14.root", "READ");
   }
   m_guiManager->clearStatus();

   readFile();
}
void FWGeometryBrowser::cellClicked ( Int_t  iRow,
Int_t  iColumn,
Int_t  iButton,
Int_t  iKeyMod,
Int_t  iGlobalX,
Int_t  iGlobalY 
)

Definition at line 132 of file FWGeometryBrowser.cc.

References FWGeometryTableManager::firstColumnClicked(), and m_tableManager.

{
   if (iButton != kButton1)
   {
      // m_tableManager->setSelection(iRow, iColumn, iKeyMod);
      return;   
   }
 
   if (iButton == kButton1 && iColumn == 0)
   {
      m_tableManager->firstColumnClicked(iRow);
   }
}
FWGeometryBrowser::ClassDef ( FWGeometryBrowser  ,
 
) [private]
bool FWGeometryBrowser::HandleKey ( Event_t *  event)

Definition at line 146 of file FWGeometryBrowser.cc.

References if(), and m.

{
      if (!fBindList) return kFALSE;

      TIter next(fBindList);
      TGMapKey *m;
      TGFrame  *w = 0;

      while ((m = (TGMapKey *) next())) {
         if (m->fKeyCode == event->fCode) {
            w = (TGFrame *) m->fWindow;
            if (w->HandleKey(event)) return kTRUE;
         }
      }
      return kFALSE;
}
void FWGeometryBrowser::makeSetter ( TGCompositeFrame *  frame,
FWParameterBase param 
) [private]

Definition at line 95 of file FWGeometryBrowser.cc.

References m_setters, and FWParameterSetterBase::makeSetterFor().

Referenced by resetSetters().

{
   boost::shared_ptr<FWParameterSetterBase> ptr( FWParameterSetterBase::makeSetterFor(param) );
   ptr->attach(param, this);
 
   TGFrame* pframe = ptr->build(frame, false);
   frame->AddFrame(pframe, new TGLayoutHints(kLHintsExpandX));

   m_setters.push_back(ptr);
}
void FWGeometryBrowser::newIndexSelected ( int  iSelectedRow,
int  iSelectedColumn 
)

Definition at line 170 of file FWGeometryBrowser.cc.

References FWTableManagerBase::dataChanged(), and m_tableManager.

{
  if (iSelectedRow == -1)
    return;

  m_tableManager->dataChanged();
}
const FWGeometryBrowser& FWGeometryBrowser::operator= ( const FWGeometryBrowser ) [private]
void FWGeometryBrowser::readFile ( )

Definition at line 179 of file FWGeometryBrowser.cc.

References ExpressReco_HICollisions_FallBack::e, fwLog, fwlog::kError, FWGeometryTableManager::loadGeometry(), m_geometryFile, m_tableManager, and updateStatusBar().

Referenced by browse().

{
   try {

      if ( ! m_geometryFile )
         throw std::runtime_error("No root file.");
  
      m_geometryFile->ls();
      
      if ( !m_geometryFile->Get("cmsGeo;1"))
         throw std::runtime_error("Can't find TGeoManager object in selected file.");

      TGeoManager* m_geoManager = (TGeoManager*) m_geometryFile->Get("cmsGeo;1");
      m_tableManager->loadGeometry(m_geoManager);
      MapRaised();

   }
   catch (std::runtime_error &e)
   {
      fwLog(fwlog::kError) << "Failed to load simulation geomtery.\n";
      updateStatusBar("Failed to load simulation geomtery from file");
   }
}
void FWGeometryBrowser::resetSetters ( ) [private]

Definition at line 75 of file FWGeometryBrowser.cc.

References geodebug, m_autoExpand, m_filter, m_maxDaughters, m_mode, m_setters, m_settersFrame, and makeSetter().

Referenced by FWGeometryBrowser(), and setFrom().

{
   if (!m_settersFrame->GetList()->IsEmpty())
   {
      m_setters.clear();
      TGFrameElement *el = (TGFrameElement*) m_settersFrame->GetList()->First();
      m_settersFrame->RemoveFrame(el->fFrame);
   }
   
   TGHorizontalFrame* frame = new TGHorizontalFrame(m_settersFrame);
   m_settersFrame->AddFrame(frame);
   makeSetter(frame, &m_mode);
   makeSetter(frame, &m_filter);
   makeSetter(frame, &m_autoExpand);
   if (geodebug) makeSetter(frame, &m_maxDaughters);
   m_settersFrame->MapSubwindows();
   Layout();
}
void FWGeometryBrowser::setFrom ( const FWConfiguration iFrom) [virtual]

Reimplemented from FWConfigurableParameterizable.

Definition at line 115 of file FWGeometryBrowser.cc.

References FWParameterizable::begin(), FWParameterizable::end(), geodebug, m_maxDaughters, and resetSetters().

Referenced by FWGUIManager::setFrom().

{ 
   for(const_iterator it =begin(), itEnd = end();
       it != itEnd;
       ++it) {
      
      if (!geodebug && (&m_maxDaughters == (*it)))
          continue;
          
      (*it)->setFrom(iFrom);

   }  
   resetSetters();
}
void FWGeometryBrowser::updateStatusBar ( const char *  status)
void FWGeometryBrowser::windowIsClosing ( )

Definition at line 164 of file FWGeometryBrowser.cc.

{
  UnmapWindow();
}

Friends And Related Function Documentation

friend class FWGeometryTableManager [friend]

Definition at line 39 of file FWGeometryBrowser.h.

Referenced by FWGeometryBrowser().


Member Data Documentation

TGTextButton* FWGeometryBrowser::m_fileOpen [private]

Definition at line 82 of file FWGeometryBrowser.h.

Referenced by FWGeometryBrowser().

Definition at line 81 of file FWGeometryBrowser.h.

Referenced by browse(), and readFile().

Definition at line 76 of file FWGeometryBrowser.h.

Referenced by browse().

std::vector<boost::shared_ptr<FWParameterSetterBase> > FWGeometryBrowser::m_setters [private]

Definition at line 87 of file FWGeometryBrowser.h.

Referenced by makeSetter(), and resetSetters().

TGCompositeFrame* FWGeometryBrowser::m_settersFrame [private]

Definition at line 84 of file FWGeometryBrowser.h.

Referenced by FWGeometryBrowser(), and resetSetters().

TGStatusBar* FWGeometryBrowser::m_statBar [private]

Definition at line 83 of file FWGeometryBrowser.h.

Referenced by FWGeometryBrowser(), and updateStatusBar().

Definition at line 79 of file FWGeometryBrowser.h.

Referenced by cellClicked(), FWGeometryBrowser(), newIndexSelected(), and readFile().

Definition at line 78 of file FWGeometryBrowser.h.

Referenced by FWGeometryBrowser().