From 794a0d255bbc979e79d2413bbe90364a50459802 Mon Sep 17 00:00:00 2001 From: Matevz Tadel <matevz.tadel@cern.ch> Date: Tue, 17 Nov 2009 13:53:33 +0000 Subject: [PATCH] * TEveUtil When checking and executing a macro strip off also the directory. * TEveManager InsertVizDBEntry() - rewrite logic for un-registration of clients from the old model. Also propagate changes to projected replicas if update is requested. LoadVizDB() - call Redraw3D() at the end. SaveVizDB() - expand pathname before opening the file. * TEveElement SetVizModel() - decrease fParentIgnoreCnt *before* removing itself from the old model and increase it *after* adding itself to the new model. * TEveStraightLineSet In CopyVizParams() write out "kTRUE"/"kFALSE" for boll values. git-svn-id: http://root.cern.ch/svn/root/trunk@31233 27541ba8-7e3a-0410-8455-c3a389f83636 --- graf3d/eve/src/TEveElement.cxx | 4 ++-- graf3d/eve/src/TEveManager.cxx | 23 ++++++++++++++++------- graf3d/eve/src/TEveStraightLineSet.cxx | 5 +++-- graf3d/eve/src/TEveUtil.cxx | 18 ++++++++---------- 4 files changed, 29 insertions(+), 21 deletions(-) diff --git a/graf3d/eve/src/TEveElement.cxx b/graf3d/eve/src/TEveElement.cxx index 99b5c91fee2..0df1abe10b8 100644 --- a/graf3d/eve/src/TEveElement.cxx +++ b/graf3d/eve/src/TEveElement.cxx @@ -341,13 +341,13 @@ void TEveElement::SetVizModel(TEveElement* model) // viz-model. if (fVizModel) { - fVizModel->RemoveElement(this); --fParentIgnoreCnt; + fVizModel->RemoveElement(this); } fVizModel = model; if (fVizModel) { - ++fParentIgnoreCnt; fVizModel->AddElement(this); + ++fParentIgnoreCnt; } } diff --git a/graf3d/eve/src/TEveManager.cxx b/graf3d/eve/src/TEveManager.cxx index ed55815412d..979a9647b1b 100644 --- a/graf3d/eve/src/TEveManager.cxx +++ b/graf3d/eve/src/TEveManager.cxx @@ -617,17 +617,22 @@ Bool_t TEveManager::InsertVizDBEntry(const TString& tag, TEveElement* model, { if (replace) { + model->IncDenyDestroy(); + model->SetRnrChildren(kFALSE); + TEveElement* old_model = dynamic_cast<TEveElement*>(pair->Value()); - for (TEveElement::List_i i = old_model->BeginChildren(); i != old_model->EndChildren(); ++i) + while (old_model->HasChildren()) { - (*i)->SetVizModel(model); + TEveElement *el = old_model->FirstChild(); + el->SetVizModel(model); if (update) - (*i)->CopyVizParams(model); + { + el->CopyVizParams(model); + el->PropagateVizParamsToProjecteds(); + } } old_model->DecDenyDestroy(); - old_model->Destroy(); - model->IncDenyDestroy(); - model->SetRnrChildren(kFALSE); + pair->SetValue(dynamic_cast<TObject*>(model)); return kTRUE; } @@ -692,6 +697,7 @@ void TEveManager::LoadVizDB(const TString& filename) // how the registered entries are handled. TEveUtil::Macro(filename); + Redraw3D(); } //______________________________________________________________________________ @@ -705,7 +711,10 @@ void TEveManager::SaveVizDB(const TString& filename) return; } - ofstream out(filename, ios::out | ios::trunc); + TString exp_filename(filename); + gSystem->ExpandPathName(exp_filename); + + ofstream out(exp_filename, ios::out | ios::trunc); out << "void " << re[1] << "()\n"; out << "{\n"; out << " TEveManager::Create();\n"; diff --git a/graf3d/eve/src/TEveStraightLineSet.cxx b/graf3d/eve/src/TEveStraightLineSet.cxx index 8572fe18ba4..d3f09a13b2c 100644 --- a/graf3d/eve/src/TEveStraightLineSet.cxx +++ b/graf3d/eve/src/TEveStraightLineSet.cxx @@ -77,6 +77,7 @@ void TEveStraightLineSet::AddMarker(Int_t line, Float_t pos) /******************************************************************************/ +//______________________________________________________________________________ void TEveStraightLineSet::CopyVizParams(const TEveElement* el) { // Copy visualization parameters from element el. @@ -103,8 +104,8 @@ void TEveStraightLineSet::WriteVizParams(ostream& out, const TString& var) TString t = " " + var + "->"; TAttMarker::SaveMarkerAttributes(out, var); TAttLine ::SaveLineAttributes (out, var); - out << t << "SetRnrMarkers(" << fRnrMarkers << ");\n"; - out << t << "SetRnrLines(" << fRnrLines << ");\n"; + out << t << "SetRnrMarkers(" << (fRnrMarkers ? "kTRUE" : "kFALSE") << ");\n"; + out << t << "SetRnrLines(" << (fRnrLines ? "kTRUE" : "kFALSE") << ");\n"; } /******************************************************************************/ diff --git a/graf3d/eve/src/TEveUtil.cxx b/graf3d/eve/src/TEveUtil.cxx index 43ec7315b1e..7faf239a4fe 100644 --- a/graf3d/eve/src/TEveUtil.cxx +++ b/graf3d/eve/src/TEveUtil.cxx @@ -120,14 +120,19 @@ void TEveUtil::SetupGUI() namespace { //______________________________________________________________________________ -void ChompTail(TString& s, char c='.') +void ChompTailAndDir(TString& s, char c='.') { // Remove last part of string 's', starting from the last // occurrence of character 'c'. + // Remove directory part -- everything until the last '/'. Ssiz_t p = s.Last(c); if (p != kNPOS) s.Remove(p); + + Ssiz_t ls = s.Last('/'); + if (ls != kNPOS) + s.Remove(0, ls + 1); } } @@ -142,14 +147,7 @@ Bool_t TEveUtil::CheckMacro(const char* mac) // Previous version expected function with same name and used ROOT's // list of global functions. - TString foo(mac); ChompTail(foo); - /* - if(recreate) { - TCollection* logf = gROOT->GetListOfGlobalFunctions(kFALSE); - logf->SetOwner(); - logf->Clear(); - } - */ + TString foo(mac); ChompTailAndDir(foo); if (gROOT->GetGlobalFunction(foo.Data(), 0, kFALSE) != 0) return kTRUE; else @@ -174,7 +172,7 @@ void TEveUtil::Macro(const char* mac) if (CheckMacro(mac) == kFALSE) { gROOT->LoadMacro(mac); } - TString foo(mac); ChompTail(foo); foo += "()"; + TString foo(mac); ChompTailAndDir(foo); foo += "()"; gROOT->ProcessLine(foo.Data()); } -- GitLab