From 1aaad1cdf96d8246ae6570844d4908ca1de4669b Mon Sep 17 00:00:00 2001 From: Matevz Tadel Date: Mon, 27 Oct 2014 16:23:49 -0700 Subject: [PATCH] GeometryView -- add context menu entry for applying color to children. --- Fireworks/Core/interface/FWGeoTopNode.h | 2 ++ .../interface/FWGeometryTableManagerBase.h | 4 +++ Fireworks/Core/src/FWGeoTopNode.cc | 8 +++-- .../Core/src/FWGeometryTableManagerBase.cc | 30 ++++++++++++++++++- Fireworks/Core/src/FWGeometryTableViewBase.cc | 14 +++++++-- 5 files changed, 52 insertions(+), 6 deletions(-) diff --git a/Fireworks/Core/interface/FWGeoTopNode.h b/Fireworks/Core/interface/FWGeoTopNode.h index a93ad99483eb3..45712ee2490a4 100644 --- a/Fireworks/Core/interface/FWGeoTopNode.h +++ b/Fireworks/Core/interface/FWGeoTopNode.h @@ -50,6 +50,8 @@ class FWGeoTopNode : public TEveElementList, kVisSelfOff, kVisChldOn, kVisChldOff, + kApplyChldCol, + kApplyChldColRec, kCamera, kPrintMaterial, kPrintPath, diff --git a/Fireworks/Core/interface/FWGeometryTableManagerBase.h b/Fireworks/Core/interface/FWGeometryTableManagerBase.h index 4d17f0cad5b32..b951f3ee7eb5f 100644 --- a/Fireworks/Core/interface/FWGeometryTableManagerBase.h +++ b/Fireworks/Core/interface/FWGeometryTableManagerBase.h @@ -78,6 +78,8 @@ class FWGeometryTableManagerBase : public FWTableManagerBase bool testBitAny(UChar_t f) const { return (m_flags & f) != 0; } void switchBit(UChar_t f) { testBit(f) ? resetBit(f) : setBit(f); } + + void copyColorTransparency(const NodeInfo& x) { m_color = x.m_color; m_transparency = x.m_transparency; } }; @@ -161,6 +163,8 @@ class FWGeometryTableManagerBase : public FWTableManagerBase virtual bool getVisibilityChld(const NodeInfo& nodeInfo) const; virtual bool getVisibility (const NodeInfo& nodeInfo) const; + virtual void applyColorTranspToDaughters(int selectedIdx, bool recurse); + bool isNodeRendered(int idx, int top_node_idx) const; static void getNNodesTotal(TGeoNode* geoNode, int& off); diff --git a/Fireworks/Core/src/FWGeoTopNode.cc b/Fireworks/Core/src/FWGeoTopNode.cc index 08fd7951375b6..d262326f4fe0e 100644 --- a/Fireworks/Core/src/FWGeoTopNode.cc +++ b/Fireworks/Core/src/FWGeoTopNode.cc @@ -378,13 +378,15 @@ FWPopupMenu* FWGeoTopNode::setPopupMenu(int iX, int iY, TGLViewer* v, bool overl FWPopupMenu* nodePopup = new FWPopupMenu(); nodePopup->AddEntry("Set As Top Node", kSetTopNode); - nodePopup->AddEntry("Set As Top Node And Reset Camera", kSetTopNodeCam); + nodePopup->AddEntry("Set As Top Node and Reset Camera", kSetTopNodeCam); nodePopup->AddSeparator(); if (v) { nodePopup->AddEntry("Rnr Off", kVisSelfOff); } - nodePopup->AddEntry("Rnr Off For All Children", kVisChldOff); - nodePopup->AddEntry("Rnr On For All Children", kVisChldOn); + nodePopup->AddEntry("Turn Render On For Children", kVisChldOn); + nodePopup->AddEntry("Turn Render Off For Children", kVisChldOff); + nodePopup->AddEntry("Apply Color To Children", kApplyChldCol); + nodePopup->AddEntry("Apply Color Recursively", kApplyChldColRec); nodePopup->AddSeparator(); if (overlap) diff --git a/Fireworks/Core/src/FWGeometryTableManagerBase.cc b/Fireworks/Core/src/FWGeometryTableManagerBase.cc index d9aedc9cbe42c..8825f68dd1700 100644 --- a/Fireworks/Core/src/FWGeometryTableManagerBase.cc +++ b/Fireworks/Core/src/FWGeometryTableManagerBase.cc @@ -323,7 +323,8 @@ void FWGeometryTableManagerBase::setVisibilityChld(NodeInfo& data, bool x) { data.setBitVal(kVisNodeChld, x); } -//______________________________________________________________________________ + +//------------------------------------------------------------------------------ void FWGeometryTableManagerBase::setDaughtersSelfVisibility(int selectedIdx, bool v) { @@ -349,11 +350,38 @@ bool FWGeometryTableManagerBase::getVisibility(const NodeInfo& data) const return data.testBit(kVisNodeSelf); } +//------------------------------------------------------------------------------ + bool FWGeometryTableManagerBase::getVisibilityChld(const NodeInfo& data) const { return data.testBit(kVisNodeChld); } +//------------------------------------------------------------------------------ + +void FWGeometryTableManagerBase::applyColorTranspToDaughters(int selectedIdx, bool recurse) +{ + NodeInfo &nInfo = m_entries[selectedIdx]; + TGeoNode *parentNode = nInfo.m_node; + int nD = parentNode->GetNdaughters(); + int dOff = 0; + for (int n = 0; n != nD; ++n) + { + int idx = selectedIdx + 1 + n + dOff; + NodeInfo& data = m_entries[idx]; + + data.copyColorTransparency(nInfo); + + if (recurse) + { + applyColorTranspToDaughters(idx, recurse); + } + + getNNodesTotal(parentNode->GetDaughter(n), dOff); + } +} + +//------------------------------------------------------------------------------ bool FWGeometryTableManagerBase::isNodeRendered(int idx, int topNodeIdx) const { diff --git a/Fireworks/Core/src/FWGeometryTableViewBase.cc b/Fireworks/Core/src/FWGeometryTableViewBase.cc index 219ad58057fa0..b6cdacf735c12 100644 --- a/Fireworks/Core/src/FWGeometryTableViewBase.cc +++ b/Fireworks/Core/src/FWGeometryTableViewBase.cc @@ -522,10 +522,20 @@ void FWGeometryTableViewBase::chosenItem(int menuIdx) break; case FWGeoTopNode::kVisChldOn: - getTableManager()->setDaughtersSelfVisibility(selectedIdx, true); + getTableManager()->setDaughtersSelfVisibility(selectedIdx, true); refreshTable3D(); break; - + + case FWGeoTopNode::kApplyChldCol: + getTableManager()->applyColorTranspToDaughters(selectedIdx, false); + refreshTable3D(); + break; + + case FWGeoTopNode::kApplyChldColRec: + getTableManager()->applyColorTranspToDaughters(selectedIdx, true); + refreshTable3D(); + break; + case FWGeoTopNode::kPrintMaterial: gv->InspectMaterial(); break;