CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/Fireworks/Core/src/FWGeometryTableView.cc

Go to the documentation of this file.
00001 #include <iostream>
00002 #include <boost/bind.hpp>
00003 #include <boost/regex.hpp>
00004 
00005 #include "Fireworks/Core/interface/FWGeometryTableView.h"
00006 #include "Fireworks/Core/interface/FWGeoTopNode.h"
00007 #include "Fireworks/Core/interface/FWGeometryTableManager.h"
00008 #include "Fireworks/TableWidget/interface/FWTableWidget.h"
00009 #include "Fireworks/Core/interface/FWGUIManager.h"
00010 #include "Fireworks/Core/interface/FWColorManager.h"
00011 #include "Fireworks/Core/interface/FWParameterSetterBase.h"
00012 #include "Fireworks/Core/interface/FWColorManager.h"
00013 #include "Fireworks/Core/src/FWPopupMenu.cc"
00014 #include "Fireworks/Core/src/FWColorSelect.h"
00015 #include "Fireworks/Core/src/FWGUIValidatingTextEntry.h"
00016 #include "Fireworks/Core/src/FWValidatorBase.h"
00017 
00018 #include "Fireworks/Core/interface/fwLog.h"
00019 
00020 #include "TGFileDialog.h"
00021 #include "TGeoNode.h"
00022 #include "TGeoMatrix.h"
00023 #include "TGStatusBar.h"
00024 #include "TGButton.h"
00025 #include "TGLabel.h"
00026 #include "TGMenu.h"
00027 #include "TGComboBox.h"
00028 #include "KeySymbols.h"
00029 
00030 // #define PERFTOOL_BROWSER
00031 #include "TGeoShape.h"
00032 #include "TGeoBBox.h"
00033 #include "TEveManager.h"
00034 #include "TEveGeoNode.h"
00035 #include "TEveScene.h"
00036 #include "TEveSceneInfo.h"
00037 #include "TEveViewer.h"
00038 #include "TGLViewer.h"
00039 #include "TGLCamera.h"
00040 #ifdef PERFTOOL_BROWSER 
00041 #include <google/profiler.h>
00042 #endif
00043 
00044 bool geodebug = 0;
00045 
00046 enum GeoMenuOptions {
00047    kSetTopNode,
00048    kSetTopNodeCam,
00049    kVisOn,
00050    kVisOff,
00051    kInspectMaterial,
00052    kInspectShape,
00053    kCamera,
00054    kTableDebug
00055 };
00056 
00057 
00058 class FWGeoMaterialValidator : public FWValidatorBase {
00059 public:
00060    struct Material
00061    {
00062       TGeoMaterial* g;
00063       std::string n;
00064       bool operator< (const Material& x) const { return n < x.n ;}
00065       Material( TGeoMaterial* x) {  g= x; n = x ? x->GetName() : "<show-all>";}
00066    };
00067 
00068    FWGeometryTableManager* m_table;
00069    mutable std::vector<Material> m_list;
00070 
00071    FWGeoMaterialValidator( FWGeometryTableManager* t) { m_table = t;}
00072    virtual ~FWGeoMaterialValidator() {}
00073 
00074 
00075    virtual void fillOptions(const char* iBegin, const char* iEnd, std::vector<std::pair<boost::shared_ptr<std::string>, std::string> >& oOptions) const 
00076    {
00077       oOptions.clear();
00078       std::string part(iBegin,iEnd);
00079       unsigned int part_size = part.size();
00080 
00081       m_list.clear();
00082       m_list.push_back(0);
00083 
00084       FWGeometryTableManager::Entries_i it = m_table->refSelected();
00085       int nLevel = it->m_level;
00086       it++;
00087       while (it->m_level > nLevel)
00088       {
00089          TGeoMaterial* g = it->m_node->GetVolume()->GetMaterial();
00090          bool duplicate = false;
00091          for (std::vector<Material>::iterator j = m_list.begin(); j!=m_list.end(); ++j) {
00092             if (j->g == g) {
00093                duplicate = true;
00094                break;
00095             }
00096          }
00097          if (!duplicate)
00098             m_list.push_back(g);
00099 
00100          ++it;
00101       }
00102       std::vector<Material>::iterator startIt = m_list.begin();
00103       startIt++;
00104       std::sort(startIt, m_list.end());
00105 
00106       std::string h = "";
00107       oOptions.push_back(std::make_pair(boost::shared_ptr<std::string>(new std::string(m_list.begin()->n)), h));
00108       for (std::vector<Material>::iterator i = startIt; i!=m_list.end(); ++i) {
00109          if(part == (*i).n.substr(0,part_size) )
00110          {
00111             //  std::cout << i->n <<std::endl;
00112             oOptions.push_back(std::make_pair(boost::shared_ptr<std::string>(new std::string((*i).n)), (*i).n.substr(part_size, (*i).n.size()-part_size)));
00113          }
00114       }
00115 
00116    }
00117 
00118    bool isStringValid(std::string& exp) 
00119    {
00120       if (exp.empty()) return true;
00121 
00122       for (std::vector<Material>::iterator i = m_list.begin(); i!=m_list.end(); ++i) {
00123          if (exp == (*i).n) 
00124             return true;
00125     
00126       }
00127       return false;
00128    }
00129 };
00130 
00131 //______________________________________________________________________________
00132 
00133 class FWViewCombo : public TGTextButton
00134 {
00135 private:
00136    FWGeometryTableView* m_tableView;
00137    TEveElement* m_el;
00138 
00139 public:
00140    FWViewCombo(const TGWindow *p, FWGeometryTableView* t): 
00141       TGTextButton(p, "Select Views", -1, TGButton::GetDefaultGC()(), TGTextButton::GetDefaultFontStruct(), kRaisedFrame | kDoubleBorder  ), m_tableView(t), m_el(0) {}
00142    virtual ~FWViewCombo() {}
00143    void setElement(TEveElement* x) {m_el = x;}
00144 
00145    virtual Bool_t  HandleButton(Event_t* event) 
00146    {
00147       if (event->fType == kButtonPress)
00148       {
00149          bool map = false;
00150 
00151          FWPopupMenu* m_viewPopup = new FWPopupMenu(0);
00152 
00153          TEveElementList* views = gEve->GetViewers();
00154          int idx = 0;
00155 
00156          for (TEveElement::List_i it = views->BeginChildren(); it != views->EndChildren(); ++it)
00157          { 
00158             TEveViewer* v = ((TEveViewer*)(*it));
00159             if (strstr( v->GetElementName(), "3D") )
00160             {     
00161                bool added = false;          
00162                m_viewPopup->AddEntry(v->GetElementName(), idx);
00163                TEveSceneInfo* si = ( TEveSceneInfo*)v->FindChild(Form("SI - EventScene %s",v->GetElementName() ));
00164                if (m_el) {
00165                   for (TEveElement::List_i it = m_el->BeginParents(); it != m_el->EndParents(); ++it ){
00166                      if (*it == si->GetScene()) {
00167                         added = true;
00168                         break;
00169                      }
00170                   }
00171                }
00172                map = true;
00173                if (added)
00174                   m_viewPopup->CheckEntry(idx);
00175             }
00176             ++idx;
00177          }
00178 
00179          if (map) {
00180 
00181             Window_t wdummy;
00182             Int_t ax,ay;
00183             gVirtualX->TranslateCoordinates(GetId(),
00184                                             gClient->GetDefaultRoot()->GetId(),
00185                                             event->fX, event->fY, //0,0 in local coordinates
00186                                             ax,ay, //coordinates of screen
00187                                             wdummy);
00188 
00189 
00190             m_viewPopup->PlaceMenu(ax, ay, true,true);
00191             m_viewPopup->Connect("Activated(Int_t)",
00192                                  "FWGeometryTableView",
00193                                  const_cast<FWGeometryTableView*>(m_tableView),
00194                                  "selectView(Int_t)");
00195          }
00196          else
00197          {
00198             fwLog(fwlog::kError) << "No 3D View added. \n";
00199          }
00200       }
00201       return true;
00202    }
00203 
00204 };
00205 
00206 //==============================================================================
00207 //==============================================================================
00208 //==============================================================================
00209 //==============================================================================
00210 
00211 FWGeometryTableView::FWGeometryTableView(TEveWindowSlot* iParent,FWColorManager* colMng, TGeoNode* tn, TObjArray* volumes )
00212    : FWViewBase(FWViewType::kGeometryTable),
00213      m_mode(this, "Mode:", 0l, 0l, 1l),
00214      m_filter(this,"Materials:",std::string()),
00215      m_autoExpand(this,"ExpandList:", 1l, 0l, 100l),
00216      m_visLevel(this,"VisLevel:", 3l, 1l, 100l),
00217      m_visLevelFilter(this,"IgnoreVisLevelOnFilter", true),
00218      m_topNodeIdx(this, "TopNodeIndex", -1l, 0, 1e7),
00219      m_colorManager(colMng),
00220      m_tableManager(0),
00221      m_eveTopNode(0),
00222      m_colorPopup(0),
00223      m_eveWindow(0),
00224      m_frame(0),
00225      m_viewBox(0),
00226      m_filterEntry(0),
00227      m_filterValidator(0),
00228      m_viewersConfig(0)
00229 {
00230    m_eveWindow = iParent->MakeFrame(0);
00231    TGCompositeFrame* xf = m_eveWindow->GetGUICompositeFrame();
00232 
00233    m_frame = new TGVerticalFrame(xf);
00234    xf->AddFrame(m_frame, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
00235 
00236    m_mode.addEntry(0, "Node");
00237    m_mode.addEntry(1, "Volume");
00238    
00239    m_tableManager = new FWGeometryTableManager(this);
00240    m_mode.changed_.connect(boost::bind(&FWGeometryTableView::modeChanged,this));
00241    m_autoExpand.changed_.connect(boost::bind(&FWGeometryTableView::autoExpandChanged, this));
00242    m_visLevel.changed_.connect(boost::bind(&FWGeometryTableView::refreshTable3D,this));
00243    m_visLevelFilter.changed_.connect(boost::bind(&FWGeometryTableView::refreshTable3D,this));
00244 
00245 
00246    // top row
00247    {
00248       TGHorizontalFrame* hp =  new TGHorizontalFrame(m_frame);
00249  
00250       if (0) { TGTextButton* fileOpen = new TGTextButton (hp, "Open Geometry File");
00251          hp->AddFrame(fileOpen);
00252          fileOpen->Connect("Clicked()","FWGeometryTableView",this,"browse()");
00253       }
00254       {
00255          TGTextButton* rb = new TGTextButton (hp, "CdTop");
00256          hp->AddFrame(rb, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0) );
00257          rb->Connect("Clicked()","FWGeometryTableView",this,"cdTop()");
00258       } {
00259          TGTextButton* rb = new TGTextButton (hp, "CdUp");
00260          hp->AddFrame(rb, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0));
00261          rb->Connect("Clicked()","FWGeometryTableView",this,"cdUp()");
00262       }
00263 
00264       {
00265          m_viewBox = new FWViewCombo(hp, this);
00266          hp->AddFrame( m_viewBox,new TGLayoutHints(kLHintsExpandY, 2, 2, 0, 0));
00267       }
00268       {
00269          hp->AddFrame(new TGLabel(hp, "Filter:"), new TGLayoutHints(kLHintsBottom, 10, 0, 0, 2));
00270          m_filterEntry = new FWGUIValidatingTextEntry(hp);
00271          m_filterEntry->SetHeight(20);
00272          m_filterValidator = new FWGeoMaterialValidator(m_tableManager);
00273          m_filterEntry->setValidator(m_filterValidator);
00274          hp->AddFrame(m_filterEntry, new TGLayoutHints(kLHintsExpandX,  1, 2, 1, 0));
00275          m_filterEntry->setMaxListBoxHeight(150);
00276          m_filterEntry->getListBox()->Connect("Selected(int)", "FWGeometryTableView",  this, "filterListCallback()");
00277          m_filterEntry->Connect("ReturnPressed()", "FWGeometryTableView",  this, "filterTextEntryCallback()");
00278 
00279          gVirtualX->GrabKey( m_filterEntry->GetId(),gVirtualX->KeysymToKeycode((int)kKey_A),  kKeyControlMask, true);
00280       }
00281       m_frame->AddFrame(hp,new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 4, 2, 2, 0));
00282    }
00283 
00284    m_settersFrame = new TGHorizontalFrame(m_frame);
00285    m_frame->AddFrame( m_settersFrame, new TGLayoutHints(kLHintsExpandX,4,2,2,2));
00286    m_settersFrame->SetCleanup(kDeepCleanup);
00287 
00288    m_tableWidget = new FWTableWidget(m_tableManager, m_frame); 
00289    m_frame->AddFrame(m_tableWidget,new TGLayoutHints(kLHintsExpandX|kLHintsExpandY,2,2,0,0));
00290    m_tableWidget->SetBackgroundColor(0xffffff);
00291    m_tableWidget->SetLineSeparatorColor(0x000000);
00292    m_tableWidget->SetHeaderBackgroundColor(0xececec);
00293    m_tableWidget->Connect("cellClicked(Int_t,Int_t,Int_t,Int_t,Int_t,Int_t)",
00294                           "FWGeometryTableView",this,
00295                           "cellClicked(Int_t,Int_t,Int_t,Int_t,Int_t,Int_t)");
00296    m_tableWidget->disableGrowInWidth();
00297    resetSetters();
00298 
00299    if (tn)
00300    {
00301       m_tableManager->loadGeometry(tn, volumes);
00302       cdTop();
00303    }
00304 
00305    m_frame->MapSubwindows();
00306    m_frame->Layout();
00307    xf->Layout();
00308    m_frame->MapWindow();
00309 }
00310 
00311 FWGeometryTableView::~FWGeometryTableView()
00312 {
00313    if (m_eveTopNode)
00314    {
00315       while ( m_eveTopNode->HasParents()) {
00316          TEveElement* x =  *m_eveTopNode->BeginParents();
00317         x->RemoveElement(m_eveTopNode);
00318       }
00319       m_eveTopNode->DecDenyDestroy();
00320    }
00321 
00322    // take out composite frame and delete it directly (zwithout the timeout)
00323    TGCompositeFrame *frame = m_eveWindow->GetGUICompositeFrame();
00324    frame->RemoveFrame( m_frame );
00325    delete m_frame;
00326 
00327    m_eveWindow->DestroyWindowAndSlot();
00328    delete m_tableManager;
00329 }
00330 
00331 //==============================================================================
00332 
00333 void
00334 FWGeometryTableView::addTo(FWConfiguration& iTo) const
00335 {
00336    FWConfigurableParameterizable::addTo(iTo);
00337 
00338    FWConfiguration viewers(1);
00339    if (m_eveTopNode)
00340    { 
00341       for (TEveElement::List_i it = m_eveTopNode->BeginParents(); it != m_eveTopNode->EndParents(); ++it )
00342       {
00343          FWConfiguration tempArea;
00344          TEveScene* scene = dynamic_cast<TEveScene*>(*it);
00345          std::string n = scene->GetElementName();
00346          viewers.addKeyValue(n, tempArea);
00347       }
00348    }
00349    iTo.addKeyValue("Viewers", viewers, true);
00350 }
00351   
00352 void
00353 FWGeometryTableView::setFrom(const FWConfiguration& iFrom)
00354 { 
00355    for(const_iterator it =begin(), itEnd = end();
00356        it != itEnd;
00357        ++it) {
00358       (*it)->setFrom(iFrom);
00359 
00360    }  
00361    m_filterEntry->SetText(m_filter.value().c_str(), false);
00362    resetSetters();
00363    cdNode(m_topNodeIdx.value());
00364    m_viewersConfig = iFrom.valueForKey("Viewers");
00365 }
00366 
00367 void
00368 FWGeometryTableView::populate3DViewsFromConfig()
00369 {
00370    // post-config 
00371    if (m_viewersConfig) {
00372       TEveElementList* scenes = gEve->GetScenes();
00373       const FWConfiguration::KeyValues* keyVals = m_viewersConfig->keyValues();
00374       if(0!=keyVals) 
00375       {
00376          for(FWConfiguration::KeyValuesIt it = keyVals->begin(); it!= keyVals->end(); ++it) {
00377     
00378             TString sname = it->first;
00379             TEveElement* s = scenes->FindChild(sname);
00380             if (s)
00381             {
00382                // std::cout << sname.Data() << std::endl;   
00383                if (!m_eveTopNode) {
00384                   m_eveTopNode = new FWGeoTopNode(this);
00385                   m_eveTopNode->IncDenyDestroy();
00386                   m_viewBox->setElement(m_eveTopNode);
00387                }
00388                s->AddElement(m_eveTopNode);
00389             }
00390          }   
00391       }
00392    }
00393 }
00394 
00395 void
00396 FWGeometryTableView::resetSetters()
00397 {
00398 
00399    if (!m_settersFrame->GetList()->IsEmpty())
00400    {
00401       m_setters.clear();
00402 
00403       TGFrameElement *el = (TGFrameElement*) m_settersFrame->GetList()->First();
00404       TGHorizontalFrame* f = (TGHorizontalFrame*) el->fFrame;
00405       m_settersFrame->RemoveFrame(f);
00406    }
00407 
00408    TGHorizontalFrame* frame =  new TGHorizontalFrame(m_settersFrame);
00409    m_settersFrame->AddFrame(frame, new TGLayoutHints(kLHintsExpandX,4,2,2,2) );
00410    m_settersFrame->SetCleanup(kDeepCleanup);
00411    makeSetter(frame, &m_mode);
00412    makeSetter(frame, &m_autoExpand);
00413    makeSetter(frame, &m_visLevel);
00414    makeSetter(frame, &m_visLevelFilter);
00415    m_settersFrame->MapSubwindows();
00416    m_frame->Layout();
00417 }
00418 
00419 void
00420 FWGeometryTableView::makeSetter(TGCompositeFrame* frame, FWParameterBase* param) 
00421 {
00422    boost::shared_ptr<FWParameterSetterBase> ptr( FWParameterSetterBase::makeSetterFor(param) );
00423    ptr->attach(param, this);
00424  
00425    TGFrame* m_frame = ptr->build(frame, false);
00426    frame->AddFrame(m_frame, new TGLayoutHints(kLHintsExpandX));
00427 
00428    m_setters.push_back(ptr);
00429 }
00430 
00431 
00432 //==============================================================================
00433 
00434 void 
00435 FWGeometryTableView::selectView(int idx)
00436 {
00437    TEveElement::List_i it = gEve->GetViewers()->BeginChildren();
00438    std::advance(it, idx);
00439    TEveViewer* v = (TEveViewer*)(*it);
00440    TEveSceneInfo* si = (TEveSceneInfo*)v->FindChild(Form("SI - EventScene %s",v->GetElementName()));
00441 
00442    bool added = false;
00443    if (!m_eveTopNode) {
00444       m_eveTopNode = new FWGeoTopNode(this);
00445       m_eveTopNode->IncDenyDestroy();
00446       m_viewBox->setElement(m_eveTopNode);
00447    }
00448    else
00449    {
00450       for (TEveElement::List_i it = m_eveTopNode->BeginParents(); it != m_eveTopNode->EndParents(); ++it ){
00451          if (*it == si->GetScene()) {
00452             added = true;
00453             break;
00454          }
00455       }
00456    }
00457    printf("add node %s \n", si->GetElementName());
00458 
00459    if (added)
00460       si->GetScene()->RemoveElement(m_eveTopNode);
00461    else
00462       si->GetScene()->AddElement(m_eveTopNode);
00463 
00464    m_eveTopNode->ElementChanged();
00465    gEve->Redraw3D();
00466 }
00467 
00468 
00469 
00470 //==============================================================================
00471 void 
00472 FWGeometryTableView::cellClicked(Int_t iRow, Int_t iColumn, Int_t iButton, Int_t iKeyMod, Int_t x, Int_t y)
00473 {
00474    m_tableManager->setSelection(iRow, iColumn, iButton);
00475    FWGeometryTableManager::NodeInfo& ni = *m_tableManager->refSelected();
00476 
00477    if (iButton == kButton1) 
00478    {
00479       if (iColumn == FWGeometryTableManager::kName)
00480       {
00481          m_tableManager->firstColumnClicked(iRow);
00482          return;
00483       }
00484       else if (iColumn == FWGeometryTableManager::kColor)
00485       { 
00486          std::vector<Color_t> colors;
00487          m_colorManager->fillLimitedColors(colors);
00488       
00489          if (!m_colorPopup) {
00490             m_colorPopup = new FWColorPopup(gClient->GetDefaultRoot(), colors.front());
00491             m_colorPopup->InitContent("", colors);
00492             m_colorPopup->Connect("ColorSelected(Color_t)","FWGeometryTableView", const_cast<FWGeometryTableView*>(this), "nodeColorChangeRequested(Color_t)");
00493          }
00494          m_colorPopup->SetName("Selected");
00495          m_colorPopup->ResetColors(colors, m_colorManager->backgroundColorIndex()==FWColorManager::kBlackIndex);
00496          m_colorPopup->PlacePopup(x, y, m_colorPopup->GetDefaultWidth(), m_colorPopup->GetDefaultHeight());
00497          return;
00498       }
00499       else
00500       {
00501          bool elementChanged = false;
00502          if (iColumn ==  FWGeometryTableManager::kVisSelf)
00503          {
00504             m_tableManager->setVisibility(ni, !m_tableManager->getVisibility(ni));
00505             elementChanged = true;
00506          }
00507          if (iColumn ==  FWGeometryTableManager::kVisChild)
00508          { 
00509             m_tableManager->setVisibilityChld(ni, !m_tableManager->getVisibilityChld(ni));; 
00510             elementChanged = true;
00511          }
00512 
00513 
00514          if (m_eveTopNode && elementChanged)
00515          {
00516             m_eveTopNode->ElementChanged();
00517             gEve->RegisterRedraw3D();
00518          }
00519       }
00520         
00521 
00522       m_tableManager->dataChanged();
00523 
00524    }
00525    else if (iColumn == FWGeometryTableManager::kName)
00526    {
00527       FWPopupMenu* m_nodePopup = new FWPopupMenu();
00528       m_nodePopup->AddEntry("Set As Top Node", kSetTopNode);
00529       m_nodePopup->AddEntry("Set As Top Node And Camera Center", kSetTopNodeCam);
00530       m_nodePopup->AddSeparator();
00531       m_nodePopup->AddEntry("Rnr Off For All Children", kVisOff);
00532       m_nodePopup->AddEntry("Rnr On For All Children", kVisOn);
00533       m_nodePopup->AddSeparator();
00534       m_nodePopup->AddEntry("Set Camera Center", kCamera);
00535       m_nodePopup->AddSeparator();
00536       m_nodePopup->AddEntry("InspectMaterial", kInspectMaterial);
00537       m_nodePopup->AddEntry("InspectShape", kInspectShape);
00538      m_nodePopup->AddEntry("Table Debug", kTableDebug);
00539 
00540       m_nodePopup->PlaceMenu(x,y,true,true);
00541       m_nodePopup->Connect("Activated(Int_t)",
00542                            "FWGeometryTableView",
00543                            const_cast<FWGeometryTableView*>(this),
00544                            "chosenItem(Int_t)");
00545    }
00546 }
00547 
00548 void FWGeometryTableView::chosenItem(int x)
00549 {
00550    FWGeometryTableManager::NodeInfo& ni = *m_tableManager->refSelected();
00551    TGeoVolume* gv = ni.m_node->GetVolume();
00552    bool visible = true;
00553    bool resetHome = false;
00554    if (gv)
00555    {
00556       switch (x) {
00557         case kVisOff:
00558             visible = false;
00559         case kVisOn:
00560            m_tableManager->setDaughtersSelfVisibility(visible);
00561             refreshTable3D();
00562             break;
00563 
00564          case kInspectMaterial:
00565             gv->InspectMaterial();
00566             break;
00567          case kInspectShape:
00568             gv->InspectShape();
00569             break;
00570          case kTableDebug:
00571             // std::cout << "node name " << ni.name() << "parent " <<m_tableManager->refEntries()[ni.m_parent].name() <<  std::endl;
00572             // printf("node expanded [%d] imported[%d] children[%d]\n", ni.m_expanded,m_tableManager->nodeImported(m_tableManager->m_selectedIdx) ,  ni.m_node->GetNdaughters());
00573             //            m_tableManager->printChildren(
00574             // m_tableManager->m_selectedIdx);
00575             m_tableManager->printMaterials();
00576             break;
00577 
00578          case kSetTopNode:
00579             cdNode(m_tableManager->m_selectedIdx);
00580             break;
00581 
00582          case kSetTopNodeCam:
00583             cdNode(m_tableManager->m_selectedIdx);
00584             resetHome = true;
00585          case kCamera:
00586          {
00587             TGeoHMatrix mtx;
00588             m_tableManager->getNodeMatrix( ni, mtx);
00589 
00590             static double pnt[3];
00591             TGeoBBox* bb = static_cast<TGeoBBox*>( ni.m_node->GetVolume()->GetShape());
00592             const double* origin = bb->GetOrigin();
00593             mtx.LocalToMaster(origin, pnt);
00594 
00595             TEveElementList* vl = gEve->GetViewers();
00596             for (TEveElement::List_i it = vl->BeginChildren(); it != vl->EndChildren(); ++it)
00597             {
00598                TEveViewer* v = ((TEveViewer*)(*it));
00599                TString name = v->GetElementName();
00600                if (name.Contains("3D"))
00601                {
00602                   v->GetGLViewer()->SetDrawCameraCenter(true);
00603                   TGLCamera& cam = v->GetGLViewer()->CurrentCamera();
00604                   cam.SetExternalCenter(true);
00605                   cam.SetCenterVec(pnt[0], pnt[1], pnt[2]);
00606                }
00607             }
00608             if (resetHome) gEve->FullRedraw3D(true, true);
00609             break;
00610          }
00611       }
00612    }
00613 }
00614 
00615 void FWGeometryTableView::setBackgroundColor()
00616 {
00617    bool backgroundIsWhite = m_colorManager->backgroundColorIndex()==FWColorManager::kWhiteIndex;
00618    if(backgroundIsWhite) {
00619       m_tableWidget->SetBackgroundColor(0xffffff);
00620       m_tableWidget->SetLineSeparatorColor(0x000000);
00621    } else {
00622       m_tableWidget->SetBackgroundColor(0x000000);
00623       m_tableWidget->SetLineSeparatorColor(0xffffff);
00624    }
00625    m_tableManager->setBackgroundToWhite(backgroundIsWhite);
00626    gClient->NeedRedraw(m_tableWidget);
00627 }
00628 
00629 void FWGeometryTableView::nodeColorChangeRequested(Color_t col)
00630 {
00631    FWGeometryTableManager::NodeInfo& ni = *m_tableManager->refSelected();
00632    ni.m_color = col;
00633    ni.m_node->GetVolume()->SetLineColor(col);
00634    refreshTable3D();
00635 }
00636 
00637 void
00638 FWGeometryTableView::printTable()
00639 {
00640    // print all entries
00641    m_tableManager->printChildren(-1);
00642 }
00643 
00644 //______________________________________________________________________________
00645 
00646 
00647 void FWGeometryTableView::cdNode(int idx)
00648 {
00649    std::string p;
00650    m_tableManager->getNodePath(idx, p);
00651    setPath(idx, p);
00652 }
00653 
00654 void FWGeometryTableView::cdTop()
00655 {
00656    std::string path = "/" ;
00657    path += m_tableManager->refEntries().at(0).name();
00658    setPath(-1, path ); 
00659 }
00660 
00661 void FWGeometryTableView::cdUp()
00662 {   
00663    if ( getTopNodeIdx() != -1)
00664    {
00665       int pIdx   = m_tableManager->refEntries()[getTopNodeIdx()].m_parent;
00666       std::string p;
00667       m_tableManager->getNodePath(pIdx, p);
00668       setPath(pIdx, p);
00669    }
00670 }
00671 
00672 void FWGeometryTableView::setPath(int parentIdx, std::string& path)
00673 {
00674    m_topNodeIdx.set(parentIdx);
00675 #ifdef PERFTOOL_BROWSER  
00676    ProfilerStart(Form("cdPath%d.prof", parentIdx));
00677 #endif
00678 
00679    m_tableManager->topGeoNodeChanged(parentIdx);
00680    m_tableManager->updateFilter();
00681    m_tableManager->checkExpandLevel();
00682 
00683    refreshTable3D();
00684    // printf("END Set Path to [%s], curren node %s \n", m_path.value().c_str(), topNode->GetName()); 
00685 
00686    m_tableManager->redrawTable();
00687    if ( m_eveTopNode) {
00688       m_eveTopNode->ElementChanged();
00689       gEve->FullRedraw3D(false, true);
00690    } 
00691 
00692 #ifdef PERFTOOL_BROWSER  
00693    ProfilerStop();
00694 #endif 
00695 }
00696 //______________________________________________________________________________
00697 void FWGeometryTableView::filterTextEntryCallback()
00698 {
00699    // std::cout << "text entry click ed \n" ;
00700    std::string exp = m_filterEntry->GetText();
00701    if ( m_filterValidator->isStringValid(exp)) 
00702    {
00703       updateFilter(exp);
00704    }
00705    else
00706    {
00707       fwLog(fwlog::kError) << "filter expression not valid." << std::endl;
00708       return;
00709    }
00710 }
00711 
00712 void FWGeometryTableView::filterListCallback()
00713 { 
00714    //   std::cout << "list click ed \n" ;
00715    TGListBox* list =   m_filterEntry->getListBox();
00716    TList selected;
00717    list->GetSelectedEntries(&selected);
00718    if (selected.GetEntries() == 1)
00719    {
00720       const TGLBEntry* entry = dynamic_cast<TGLBEntry*> (selected.First());
00721       updateFilter( m_filterValidator->m_list[ entry->EntryId()].n);
00722    } 
00723 }
00724 
00725 
00726 
00727 void FWGeometryTableView::updateFilter(std::string& exp)
00728 {
00729    // std::cout << "=FWGeometryTableView::updateFilter()" << m_filterEntry->GetText() <<std::endl;
00730   
00731    if (exp == m_filterValidator->m_list.begin()->n) 
00732       exp.clear();
00733 
00734    if (exp == m_filter.value()) return;
00735 
00736    if (exp.empty())
00737    {
00738       // std::cout << "FITLER OFF \n";
00739       for (FWGeometryTableManager::Entries_i i = m_tableManager->refEntries().begin(); i !=  m_tableManager->refEntries().end(); ++i)
00740       {
00741          m_tableManager->setVisibility(*i, true);
00742          m_tableManager->setVisibilityChld(*i, true);
00743       }
00744 
00745       // NOTE: entry should be cleared automatically
00746       m_filterEntry->Clear();
00747 
00748       m_tableManager->checkExpandLevel();
00749    }
00750   
00751    m_filter.set(exp);
00752    m_tableManager->updateFilter();
00753    refreshTable3D();
00754 
00755 }
00756 
00757 //______________________________________________________________________________
00758 void FWGeometryTableView::modeChanged()
00759 {
00760    // reset filter when change mode
00761    //   std::cout << "chage mode \n";
00762    m_tableManager->updateFilter();
00763    refreshTable3D();
00764 }
00765 
00766 //______________________________________________________________________________
00767 
00768 void FWGeometryTableView::autoExpandChanged()
00769 {
00770    m_tableManager->checkExpandLevel();
00771    m_tableManager->redrawTable();
00772 }
00773 //______________________________________________________________________________
00774 
00775 void FWGeometryTableView::refreshTable3D()
00776 {
00777    m_tableManager->redrawTable();
00778 
00779    if ( m_eveTopNode) {
00780       m_eveTopNode->ElementChanged();
00781       gEve->FullRedraw3D(false, true);
00782    } 
00783 }
00784