00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include <iostream>
00018 #include <boost/bind.hpp>
00019 #include <stack>
00020 #ifdef PERFTOOL_GEO_TABLE
00021 #include <google/profiler.h>
00022 #endif
00023 #include "Fireworks/Core/interface/FWGeometryTableManager.h"
00024 #include "Fireworks/Core/interface/FWGeometryTableView.h"
00025 #include "Fireworks/Core/interface/FWGeometryTableViewManager.h"
00026 #include "Fireworks/Core/src/FWColorBoxIcon.h"
00027 #include "Fireworks/TableWidget/interface/GlobalContexts.h"
00028 #include "Fireworks/TableWidget/src/FWTabularWidget.h"
00029 #include "Fireworks/Core/interface/fwLog.h"
00030
00031 #include "TMath.h"
00032 #include "TGeoVolume.h"
00033 #include "TGeoMatrix.h"
00034 #include "TGeoShape.h"
00035 #include "TGeoBBox.h"
00036 #include "TGeoMatrix.h"
00037 #include "TEveUtil.h"
00038
00039 #include "TGFrame.h"
00040
00041 static const char* redTxt = "\033[01;31m";
00042
00043
00044
00045
00046 const char* FWGeometryTableManager::NodeInfo::name() const
00047 {
00048 return m_node->GetName();
00049 }
00050
00051 const char* FWGeometryTableManager::NodeInfo::nameIndent() const
00052 {
00053 std::string x(m_level*3 , ' ');
00054 x += m_node->GetName();
00055 return x.c_str();
00056 }
00057
00058 FWGeometryTableManager::ColorBoxRenderer::ColorBoxRenderer():
00059 FWTableCellRendererBase(),
00060 m_width(1),
00061 m_height(1),
00062 m_color(0xffffff),
00063 m_isSelected(false)
00064 {
00065 GCValues_t gval;
00066 gval.fMask = kGCForeground | kGCBackground | kGCStipple | kGCFillStyle | kGCGraphicsExposures;
00067 gval.fStipple = gClient->GetResourcePool()->GetCheckeredBitmap();
00068 gval.fGraphicsExposures = kFALSE;
00069 gval.fBackground = gVirtualX->GetPixel(kGray);
00070 m_colorContext = gClient->GetResourcePool()->GetGCPool()->GetGC(&gval,kTRUE);
00071
00072 }
00073
00074 FWGeometryTableManager::ColorBoxRenderer::~ColorBoxRenderer()
00075 {
00076 gClient->GetResourcePool()->GetGCPool()->FreeGC(m_colorContext->GetGC());
00077 }
00078
00079 void FWGeometryTableManager::ColorBoxRenderer::setData(Color_t c, bool s)
00080 {
00081 m_color = gVirtualX->GetPixel(c);
00082 m_isSelected = s;
00083 }
00084
00085
00086 void FWGeometryTableManager::ColorBoxRenderer::draw(Drawable_t iID, int iX, int iY, unsigned int iWidth, unsigned int iHeight)
00087 {
00088 iX -= FWTabularWidget::kTextBuffer;
00089 iY -= FWTabularWidget::kTextBuffer;
00090 iWidth += 2*FWTabularWidget::kTextBuffer;
00091 iHeight += 2*FWTabularWidget::kTextBuffer;
00092
00093 m_colorContext->SetFillStyle(kFillSolid);
00094 Pixel_t baq = m_colorContext->GetForeground();
00095 m_colorContext->SetForeground(m_color);
00096 gVirtualX->FillRectangle(iID, m_colorContext->GetGC(), iX, iY, iWidth, iHeight);
00097
00098 if (m_isSelected)
00099 {
00100 m_colorContext->SetFillStyle(kFillOpaqueStippled);
00101 gVirtualX->FillRectangle(iID, m_colorContext->GetGC(), iX, iY, iWidth, iHeight);
00102 }
00103 m_colorContext->SetForeground(baq);
00104 }
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114 FWGeometryTableManager::FWGeometryTableManager(FWGeometryTableView* browser)
00115 : m_selectedRow(-1),
00116 m_selectedIdx(0),
00117 m_selectedColumn(-1),
00118 m_browser(browser),
00119 m_filterOff(true),
00120 m_numVolumesMatched(-1),
00121 m_levelOffset(0)
00122 {
00123 m_colorBoxRenderer.m_width = 50;
00124 m_colorBoxRenderer.m_height = m_renderer.height();
00125 }
00126
00127 FWGeometryTableManager::~FWGeometryTableManager()
00128 {
00129 }
00130
00131
00132 int FWGeometryTableManager::unsortedRowNumber(int unsorted) const
00133 {
00134 return unsorted;
00135 }
00136
00137 int FWGeometryTableManager::numberOfRows() const
00138 {
00139 return m_row_to_index.size();
00140 }
00141
00142 int FWGeometryTableManager::numberOfColumns() const
00143 {
00144 return kNumCol;
00145 }
00146
00147
00148 std::vector<std::string> FWGeometryTableManager::getTitles() const
00149 {
00150 std::vector<std::string> returnValue;
00151 returnValue.reserve(numberOfColumns());
00152
00153 if (m_browser->getVolumeMode() )
00154 returnValue.push_back("Volume Name");
00155 else
00156 returnValue.push_back("Node Name");
00157
00158 returnValue.push_back("Color");
00159 returnValue.push_back("RnrSelf");
00160 returnValue.push_back("RnrChildren");
00161 returnValue.push_back("Material");
00162 returnValue.push_back("X");
00163 returnValue.push_back("Y");
00164 returnValue.push_back("Z");
00165
00166
00167 return returnValue;
00168 }
00169
00170 void FWGeometryTableManager::setSelection (int row, int column, int mask)
00171 {
00172 changeSelection(row, column);
00173 }
00174
00175 const std::string FWGeometryTableManager::title() const
00176 {
00177 return "Geometry";
00178 }
00179
00180 int FWGeometryTableManager::selectedRow() const
00181 {
00182 return m_selectedRow;
00183 }
00184
00185 int FWGeometryTableManager::selectedColumn() const
00186 {
00187 return m_selectedColumn;
00188 }
00189
00190 bool FWGeometryTableManager::rowIsSelected(int row) const
00191 {
00192 return m_selectedRow == row;
00193 }
00194
00195 void FWGeometryTableManager::changeSelection(int iRow, int iColumn)
00196 {
00197 if (iRow < 0) return;
00198
00199 m_selectedRow = iRow;
00200 m_selectedColumn = iColumn;
00201 if (m_row_to_index.size() > 0) m_selectedIdx = m_row_to_index[iRow];
00202
00203
00204 visualPropertiesChanged();
00205 }
00206
00207 void FWGeometryTableManager::setBackgroundToWhite(bool iToWhite )
00208 {
00209 if(iToWhite) {
00210 m_renderer.setGraphicsContext(&TGFrame::GetBlackGC());
00211 m_renderer.setHighlightContext(&(FWTextTableCellRenderer::getDefaultHighlightGC()));
00212 } else {
00213 static const TGGC* s_blackHighLight = 0;
00214 if (!s_blackHighLight) {
00215 GCValues_t gval;
00216 gval.fMask = kGCForeground | kGCBackground | kGCStipple | kGCFillStyle | kGCGraphicsExposures;
00217 gval.fForeground = 0xbbbbbb;
00218 gval.fBackground = 0x000000;
00219 gval.fFillStyle = kFillOpaqueStippled;
00220 gval.fStipple = gClient->GetResourcePool()->GetCheckeredBitmap();
00221 gval.fGraphicsExposures = kFALSE;
00222 s_blackHighLight = gClient->GetGC(&gval, kTRUE);
00223 }
00224 m_renderer.setHighlightContext(s_blackHighLight);
00225 m_renderer.setGraphicsContext(&TGFrame::GetWhiteGC());
00226 }
00227 m_renderer.setBlackIcon(iToWhite);
00228 }
00229
00230
00231
00232 FWTableCellRendererBase* FWGeometryTableManager::cellRenderer(int iSortedRowNumber, int iCol) const
00233 {
00234 struct Cache
00235 {
00236 TGeoHMatrix mtx;
00237 double pos[3];
00238 int row;
00239
00240 };
00241
00242 static Cache mxCache;
00243 if (static_cast<int>(m_row_to_index.size()) <= iSortedRowNumber)
00244 {
00245 m_renderer.setData(std::string("FWGeometryTableManager::cellRenderer() Error!"), false);
00246 return &m_renderer;
00247 }
00248
00249 static char sval[12];
00250 static std::string zero = "0.000";
00251
00252 FWTextTreeCellRenderer* renderer = &m_renderer;
00253
00254 int unsortedRow = m_row_to_index[iSortedRowNumber];
00255 const NodeInfo& data = m_entries[unsortedRow];
00256 TGeoNode& gn = *data.m_node;
00257
00258 bool isSelected = (iCol == kMaterial ) && (!m_filterOff && m_volumes[gn.GetVolume()].m_matches);
00259
00260 if (iCol == kName)
00261 {
00262
00263 int nD = data.m_node->GetNdaughters();
00264 if (m_browser->getVolumeMode())
00265 renderer->setData(Form("%s [%d]", gn.GetVolume()->GetName(), nD), isSelected);
00266 else
00267 renderer->setData(Form("%s [%d]", gn.GetName(), nD), isSelected);
00268
00269 renderer->setIsParent((gn.GetNdaughters() > 0) && (m_filterOff || data.testBit(kChildMatches) ));
00270
00271 renderer->setIsOpen( data.testBit(FWGeometryTableManager::kExpanded));
00272
00273 int level = data.m_level - m_levelOffset;
00274
00275 if (data.m_node->GetNdaughters())
00276 renderer->setIndentation(20*level);
00277 else
00278 renderer->setIndentation(20*level + FWTextTreeCellRenderer::iconWidth());
00279
00280 return renderer;
00281 }
00282 else
00283 {
00284
00285 renderer->setIsParent(false);
00286 renderer->setIndentation(0);
00287 if (iCol == kColor)
00288 {
00289
00290 m_colorBoxRenderer.setData(data.m_color, isSelected);
00291 return &m_colorBoxRenderer;
00292 }
00293 else if (iCol == kVisSelf )
00294 {
00295 renderer->setData(getVisibility(data) ? "On" : "-", isSelected );
00296 return renderer;
00297 }
00298 else if (iCol == kVisChild )
00299 {
00300 renderer->setData( getVisibilityChld(data) ? "On" : "-", isSelected);
00301 return renderer;
00302 }
00303 else if (iCol == kMaterial )
00304 {
00305 renderer->setData( gn.GetVolume()->GetMaterial()->GetName(), isSelected);
00306 return renderer;
00307 }
00308
00309 else if (iCol == kPosX || iCol == kPosY || iCol == kPosZ)
00310 {
00311 if (mxCache.row != iSortedRowNumber) {
00312 mxCache.row = iSortedRowNumber;
00313 mxCache.pos[0] = 0; mxCache.pos[1] = 0; mxCache.pos[2] = 0;
00314 mxCache.mtx.Clear();
00315 getNodeMatrix(data, mxCache.mtx);
00316 TGeoBBox* bb = static_cast<TGeoBBox*>(data.m_node->GetVolume()->GetShape());
00317 const double* origin = bb->GetOrigin();
00318 mxCache.mtx.LocalToMaster(origin, mxCache.pos);
00319 }
00320 float val = mxCache.pos[iCol - kPosX];
00321 if (val < 0.001) {
00322 renderer->setData(zero, isSelected);
00323 }
00324 else {
00325 snprintf(sval, sizeof(sval), "%.3f", val);
00326 renderer->setData(sval, isSelected);
00327
00328 }
00329
00330 return renderer;
00331 }
00332 else
00333 {
00334 TGeoBBox* gs = static_cast<TGeoBBox*>( gn.GetVolume()->GetShape());
00335 float val = TMath::Sqrt(gs->GetDX()*gs->GetDX() + gs->GetDY()*gs->GetDY() +gs->GetDZ()*gs->GetDZ() );
00336
00337 if (val < 0.001) {
00338 renderer->setData(zero, isSelected);
00339 }
00340 else {
00341 snprintf(sval, sizeof(sval), "%.3f", val);
00342 renderer->setData(sval, isSelected);
00343 }
00344 return renderer;
00345 }
00346
00347 }
00348 }
00349
00350
00351 void FWGeometryTableManager::firstColumnClicked(int row)
00352 {
00353 if (row == -1)
00354 return;
00355
00356 int idx = rowToIndex()[row];
00357
00358
00359 m_entries[idx].switchBit(kExpanded);
00360
00361 recalculateVisibility();
00362 dataChanged();
00363 visualPropertiesChanged();
00364 }
00365
00366
00367 void FWGeometryTableManager::assertNodeFilterCache(NodeInfo& data)
00368 {
00369 if (!data.testBit(kFilterCached))
00370 {
00371 bool matches = m_volumes[data.m_node->GetVolume()].m_matches;
00372 data.setBitVal(kMatches, matches);
00373 setVisibility(data, matches);
00374
00375 bool childMatches = m_volumes[data.m_node->GetVolume()].m_childMatches;
00376 data.setBitVal(kChildMatches, childMatches);
00377 data.setBitVal(kExpanded, childMatches);
00378 setVisibilityChld(data, childMatches);
00379
00380
00381 data.setBit(kFilterCached);
00382
00383 }
00384 }
00385
00386
00387
00388 void FWGeometryTableManager::recalculateVisibility()
00389 {
00390 m_row_to_index.clear();
00391 int i = TMath::Max(0, m_browser->getTopNodeIdx());
00392 m_row_to_index.push_back(i);
00393
00394 NodeInfo& data = m_entries[i];
00395 if (!m_filterOff)
00396 assertNodeFilterCache(data);
00397
00398 if ((m_filterOff && data.testBit(kExpanded) == false) ||
00399 (m_filterOff == false && data.testBit(kChildMatches) == false) )
00400 return;
00401
00402
00403 if (m_browser->getVolumeMode())
00404 recalculateVisibilityVolumeRec(i);
00405 else
00406 recalculateVisibilityNodeRec(i);
00407
00408
00409 }
00410
00411
00412 void FWGeometryTableManager::recalculateVisibilityNodeRec( int pIdx)
00413 {
00414 TGeoNode* parentNode = m_entries[pIdx].m_node;
00415 int nD = parentNode->GetNdaughters();
00416 int dOff=0;
00417 for (int n = 0; n != nD; ++n)
00418 {
00419 int idx = pIdx + 1 + n + dOff;
00420 NodeInfo& data = m_entries[idx];
00421
00422 if (m_filterOff)
00423 {
00424 m_row_to_index.push_back(idx);
00425 if (data.testBit(kExpanded)) recalculateVisibilityNodeRec(idx);
00426 }
00427 else
00428 {
00429 assertNodeFilterCache(data);
00430 if (data.testBitAny(kMatches | kChildMatches)) m_row_to_index.push_back(idx);
00431 if (data.testBit(kChildMatches) && data.testBit(kExpanded) ) recalculateVisibilityNodeRec(idx);
00432 }
00433
00434 FWGeometryTableManager::getNNodesTotal(parentNode->GetDaughter(n), dOff);
00435 }
00436 }
00437
00438
00439
00440 void FWGeometryTableManager::recalculateVisibilityVolumeRec(int pIdx)
00441 {
00442 TGeoNode* parentNode = m_entries[pIdx].m_node;
00443 int nD = parentNode->GetNdaughters();
00444 int dOff=0;
00445
00446
00447
00448 std::vector<int> vi;
00449 vi.reserve(nD);
00450
00451
00452 for (int n = 0; n != nD; ++n)
00453 {
00454 int idx = pIdx + 1 + n + dOff;
00455 NodeInfo& data = m_entries[idx];
00456
00457 bool toAdd = true;
00458 for (std::vector<int>::iterator u = vi.begin(); u != vi.end(); ++u )
00459 {
00460 TGeoVolume* neighbourVolume = parentNode->GetDaughter(*u)->GetVolume();
00461 if (neighbourVolume == data.m_node->GetVolume())
00462 {
00463 toAdd = false;
00464
00465 break;
00466 }
00467 }
00468
00469 if (toAdd)
00470 {
00471 vi.push_back(n);
00472 if (m_filterOff)
00473 {
00474
00475 m_row_to_index.push_back(idx);
00476 if (data.testBit(kExpanded)) recalculateVisibilityVolumeRec(idx);
00477 }
00478 else
00479 {
00480 assertNodeFilterCache(data);
00481 if (data.testBitAny(kMatches | kChildMatches)) m_row_to_index.push_back(idx);
00482 if (data.testBit(kChildMatches) && data.testBit(kExpanded)) recalculateVisibilityVolumeRec(idx);
00483 }
00484 }
00485 FWGeometryTableManager::getNNodesTotal(parentNode->GetDaughter(n), dOff);
00486 }
00487 }
00488
00489
00490
00491
00492 void FWGeometryTableManager::redrawTable()
00493 {
00494 if (m_entries.empty()) return;
00495
00496 changeSelection(0, 0);
00497
00498 recalculateVisibility();
00499
00500
00501
00502
00503
00504
00505 dataChanged();
00506 visualPropertiesChanged();
00507 }
00508
00509
00510
00511 void FWGeometryTableManager::loadGeometry( TGeoNode* iGeoTopNode, TObjArray* iVolumes)
00512 {
00513 #ifdef PERFTOOL_GEO_TABLE
00514 ProfilerStart("loadGeo");
00515 #endif
00516
00517
00518
00519
00520 m_entries.clear();
00521 m_row_to_index.clear();
00522 m_volumes.clear();
00523 m_levelOffset = 0;
00524
00525
00526 boost::unordered_map<TGeoVolume*, Match> pipi(iVolumes->GetSize());
00527 m_volumes.swap(pipi);
00528 TIter next( iVolumes);
00529 TGeoVolume* v;
00530 while ((v = (TGeoVolume*) next()) != 0)
00531 m_volumes.insert(std::make_pair(v, Match()));
00532
00533 if (!m_filterOff)
00534 updateFilter();
00535
00536
00537
00538 int nTotal = 0;
00539 NodeInfo topNodeInfo;
00540 topNodeInfo.m_node = iGeoTopNode;
00541 topNodeInfo.m_level = 0;
00542 topNodeInfo.m_parent = -1;
00543 if (m_browser->getAutoExpand())
00544 topNodeInfo.setBit(kExpanded);
00545
00546 getNNodesTotal(topNodeInfo.m_node , nTotal);
00547 m_entries.resize(nTotal+1);
00548 m_entries[0] = topNodeInfo;
00549
00550 importChildren(0);
00551
00552
00553
00554 #ifdef PERFTOOL_GEO_TABLE
00555 ProfilerStop();
00556 #endif
00557 }
00558
00559
00560
00561
00562
00563
00564 void FWGeometryTableManager::importChildren(int parent_idx)
00565 {
00566 NodeInfo& parent = m_entries[parent_idx];
00567 TGeoNode* parentGeoNode = parent.m_node;
00568 int parentLevel = parent.m_level;
00569
00570 int nV = parentGeoNode->GetNdaughters();
00571 int dOff = 0;
00572 for (int n = 0; n != nV; ++n)
00573 {
00574 NodeInfo& data = m_entries[parent_idx + n + 1 + dOff];
00575 data.m_node = parentGeoNode->GetDaughter(n);
00576 data.m_level = parentLevel + 1;
00577 data.m_parent = parent_idx;
00578 data.m_color = data.m_node->GetVolume()->GetLineColor();
00579 if (data.m_level <= m_browser->getAutoExpand()) data.setBit(kExpanded);
00580
00581
00582 importChildren(parent_idx + n + 1 + dOff);
00583 getNNodesTotal(parentGeoNode->GetDaughter(n), dOff);
00584 }
00585 }
00586
00587
00588
00589 void FWGeometryTableManager::checkHierarchy()
00590 {
00591
00592
00593
00594 for ( size_t i = 0, e = m_entries.size(); i != e; ++i )
00595 {
00596 if ( m_entries[i].m_level > 0)
00597 {
00598 TGeoNode* pn = m_entries[m_entries[i].m_parent].m_node;
00599 bool ok = false;
00600 for (int d = 0; d < pn->GetNdaughters(); ++d )
00601 {
00602 if (m_entries[i].m_node == pn->GetDaughter(d))
00603 {
00604 ok = true;
00605 break;
00606 }
00607 }
00608 if (!ok) printf("%s!!!!!! node %s has false parent %s \n", redTxt, m_entries[i].name(), pn->GetName());
00609 }
00610 }
00611 }
00612
00613 void FWGeometryTableManager::checkChildMatches(TGeoVolume* vol, std::vector<TGeoVolume*>& pstack)
00614 {
00615 if (m_volumes[vol].m_matches)
00616 {
00617 for (std::vector<TGeoVolume*>::iterator i = pstack.begin(); i!= pstack.end(); ++i)
00618 {
00619 Match& pm = m_volumes[*i];
00620 pm.m_childMatches = true;
00621 }
00622 }
00623
00624 pstack.push_back(vol);
00625
00626 int nD = vol->GetNdaughters();
00627 for (int i = 0; i!=nD; ++i)
00628 checkChildMatches(vol->GetNode(i)->GetVolume(), pstack);
00629
00630 pstack.pop_back();
00631 }
00632
00633
00634
00635 void FWGeometryTableManager::updateFilter()
00636 {
00637 std::string filterExp = m_browser->getFilter();
00638 m_filterOff = filterExp.empty();
00639
00640
00641 if (m_filterOff || m_entries.empty()) return;
00642
00643
00644 m_numVolumesMatched = 0;
00645 for (Volumes_i i = m_volumes.begin(); i!= m_volumes.end(); ++i)
00646 {
00647 if (strcasestr(i->first->GetMaterial()->GetName(), filterExp.c_str()) > 0) {
00648 i->second.m_matches = true;
00649 m_numVolumesMatched++;
00650 }
00651 else {
00652 i->second.m_matches = false;
00653 }
00654 i->second.m_childMatches = false;
00655 }
00656
00657 std::vector<TGeoVolume*> pstack;
00658 checkChildMatches(m_entries[TMath::Max(0,m_browser->getTopNodeIdx())].m_node->GetVolume(), pstack);
00659
00660
00661 for (Entries_i ni = m_entries.begin(); ni != m_entries.end(); ++ni)
00662 ni->resetBit(kFilterCached);
00663
00664 }
00665
00666
00667 FWGeometryTableManager::Entries_i FWGeometryTableManager::refSelected()
00668 {
00669 Entries_i i = m_entries.begin();
00670 std::advance(i,m_selectedIdx );
00671 return i;
00672 }
00673
00674 void FWGeometryTableManager::getNodePath(int idx, std::string& path) const
00675 {
00676 std::vector<std::string> relPath;
00677 while(idx >= 0)
00678 {
00679 relPath.push_back( m_entries[idx].name());
00680
00681 idx = m_entries[idx].m_parent;
00682 }
00683
00684 size_t ns = relPath.size();
00685 for (size_t i = 1; i < ns; ++i )
00686 {
00687 path +="/";
00688 path += relPath[ns-i -1];
00689
00690 }
00691 }
00692
00693
00694
00695 void FWGeometryTableManager::checkExpandLevel()
00696 {
00697
00698 int ae = m_browser->getAutoExpand() + m_levelOffset;
00699 for (Entries_i i = m_entries.begin(); i != m_entries.end(); ++i)
00700 {
00701 if (i->m_level < ae)
00702 i->setBit(kExpanded);
00703 else
00704 i->resetBit(kExpanded);
00705 }
00706 }
00707
00708
00709
00710
00711 void FWGeometryTableManager::topGeoNodeChanged(int idx)
00712 {
00713
00714 if (idx >= 0)
00715 m_levelOffset = m_entries[idx].m_level;
00716 else
00717 m_levelOffset = 0;
00718
00719 }
00720
00721 void FWGeometryTableManager::printChildren(int idx) const
00722 {
00723
00724 std::string path;
00725 getNodePath(idx, path);
00726 printf("My %s parent %s path %d \n",m_entries[idx].name(),path.c_str(), m_entries[idx].m_parent );
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741 }
00742
00743 void FWGeometryTableManager::setDaughtersSelfVisibility(bool v)
00744 {
00745 int dOff = 0;
00746 TGeoNode* parentNode = m_entries[m_selectedIdx].m_node;
00747 int nD = parentNode->GetNdaughters();
00748 for (int n = 0; n != nD; ++n)
00749 {
00750 int idx = m_selectedIdx + 1 + n + dOff;
00751 NodeInfo& data = m_entries[idx];
00752
00753 setVisibility(data, v);
00754 setVisibilityChld(data, v);
00755
00756 FWGeometryTableManager::getNNodesTotal(parentNode->GetDaughter(n), dOff);
00757 }
00758 }
00759
00760
00761 void FWGeometryTableManager::getNodeMatrix(const NodeInfo& data, TGeoHMatrix& mtx) const
00762 {
00763
00764
00765 int pIdx = data.m_parent;
00766 int endl = data.m_level -1;
00767 for (int l = 0 ; l < endl ; ++l)
00768 {
00769 pIdx = m_entries.at(pIdx).m_parent;
00770 mtx.MultiplyLeft(m_entries.at(pIdx).m_node->GetMatrix());
00771 }
00772
00773 mtx.Multiply(data.m_node->GetMatrix());
00774 }
00775
00776
00777 void FWGeometryTableManager::setVisibility(NodeInfo& data, bool x)
00778 {
00779 if (m_browser->getVolumeMode())
00780 {
00781 if (data.m_node->GetVolume()->IsVisible() != x)
00782 {
00783 TEveGeoManagerHolder gmgr( FWGeometryTableViewManager::getGeoMangeur());
00784 data.m_node->GetVolume()->SetVisibility(x);
00785 }
00786 }
00787 else
00788 {
00789 data.setBitVal(kVisNode, x);
00790 }
00791 }
00792
00793 void FWGeometryTableManager::setVisibilityChld(NodeInfo& data, bool x)
00794 {
00795 if (m_browser->getVolumeMode())
00796 {
00797 if (data.m_node->GetVolume()->IsVisibleDaughters() != x)
00798 {
00799 TEveGeoManagerHolder gmgr( FWGeometryTableViewManager::getGeoMangeur());
00800 data.m_node->GetVolume()->VisibleDaughters(x);
00801 }
00802 }
00803 else
00804 {
00805 data.setBitVal(kVisNodeChld, x);
00806 }
00807 }
00808
00809
00810
00811 bool FWGeometryTableManager::getVisibility(const NodeInfo& data) const
00812 {
00813 if (m_browser->getVolumeMode())
00814 return data.m_node->GetVolume()->IsVisible();
00815 else
00816 return data.testBit(kVisNode);
00817
00818 }
00819
00820 bool FWGeometryTableManager::getVisibilityChld(const NodeInfo& data) const
00821 {
00822 if (m_browser->getVolumeMode())
00823 return data.m_node->GetVolume()->IsVisibleDaughters();
00824 else
00825 return data.testBit(kVisNodeChld);
00826
00827 }
00828
00829
00830
00831
00832 void FWGeometryTableManager::printMaterials()
00833 {
00834 std::map<TGeoMaterial*, std::string> mlist;
00835 Entries_i it = m_entries.begin();
00836 std::advance(it, m_selectedIdx );
00837 int nLevel = it->m_level;
00838 it++;
00839 while (it->m_level > nLevel)
00840 {
00841 TGeoMaterial* m = it->m_node->GetVolume()->GetMaterial();
00842 if (mlist.find(m) == mlist.end())
00843 {
00844 mlist[m] = m->GetName();
00845 }
00846 it++;
00847 }
00848
00849 printf("size %d \n", (int)mlist.size());
00850 for(std::map<TGeoMaterial*, std::string>::iterator i = mlist.begin(); i != mlist.end(); ++i)
00851 {
00852 printf("material %s \n", i->second.c_str());
00853 }
00854
00855 }
00856