Skip to content
Snippets Groups Projects
Commit e3dcb9db authored by Matevz Tadel's avatar Matevz Tadel
Browse files

TEveManager::GetGeometry() - if TGeoManager is locked, unlock it on

load time and re-lock it back afterwards.

TEveGeoShape - added method SetShape() so that full object can be
constructed also in program (required loading from file before).


git-svn-id: http://root.cern.ch/svn/root/trunk@23731 27541ba8-7e3a-0410-8455-c3a389f83636
parent 4328348b
No related branches found
No related tags found
No related merge requests found
...@@ -137,14 +137,15 @@ public: ...@@ -137,14 +137,15 @@ public:
TEveGeoShape(const Text_t* name="TEveGeoShape", const Text_t* title=0); TEveGeoShape(const Text_t* name="TEveGeoShape", const Text_t* title=0);
virtual ~TEveGeoShape(); virtual ~TEveGeoShape();
virtual Bool_t CanEditMainColor() const { return kTRUE; } virtual Bool_t CanEditMainColor() const { return kTRUE; }
virtual Bool_t CanEditMainTransparency() const { return kTRUE; } virtual Bool_t CanEditMainTransparency() const { return kTRUE; }
virtual UChar_t GetMainTransparency() const { return fTransparency; } virtual UChar_t GetMainTransparency() const { return fTransparency; }
virtual void SetMainTransparency(UChar_t t) { fTransparency = t; } virtual void SetMainTransparency(UChar_t t) { fTransparency = t; }
Color_t GetColor() const { return fColor; } Color_t GetColor() const { return fColor; }
TGeoShape* GetShape() { return fShape; } TGeoShape* GetShape() { return fShape; }
void SetShape(TGeoShape* s);
virtual void Paint(Option_t* option=""); virtual void Paint(Option_t* option="");
......
...@@ -476,11 +476,23 @@ TEveGeoShape::~TEveGeoShape() ...@@ -476,11 +476,23 @@ TEveGeoShape::~TEveGeoShape()
{ {
// Destructor. // Destructor.
SetShape(0);
}
//______________________________________________________________________________
void TEveGeoShape::SetShape(TGeoShape* s)
{
// Set TGeoShape shown by this object.
if (fShape) { if (fShape) {
fShape->SetUniqueID(fShape->GetUniqueID() - 1); fShape->SetUniqueID(fShape->GetUniqueID() - 1);
if (fShape->GetUniqueID() == 0) if (fShape->GetUniqueID() == 0)
delete fShape; delete fShape;
} }
fShape = s;
if (fShape) {
fShape->SetUniqueID(fShape->GetUniqueID() + 1);
}
} }
/******************************************************************************/ /******************************************************************************/
...@@ -598,9 +610,7 @@ TEveGeoShape* TEveGeoShape::SubImportShapeExtract(TEveGeoShapeExtract* gse, ...@@ -598,9 +610,7 @@ TEveGeoShape* TEveGeoShape::SubImportShapeExtract(TEveGeoShapeExtract* gse,
gsre->fTransparency = (UChar_t) (100.0f*(1.0f - rgba[3])); gsre->fTransparency = (UChar_t) (100.0f*(1.0f - rgba[3]));
gsre->SetRnrSelf(gse->GetRnrSelf()); gsre->SetRnrSelf(gse->GetRnrSelf());
gsre->SetRnrChildren(gse->GetRnrElements()); gsre->SetRnrChildren(gse->GetRnrElements());
gsre->fShape = gse->GetShape(); gsre->SetShape(gse->GetShape());
if (gsre->fShape)
gsre->fShape->SetUniqueID(gsre->fShape->GetUniqueID() + 1);
if (parent) if (parent)
parent->AddElement(gsre); parent->AddElement(gsre);
......
...@@ -481,6 +481,7 @@ TGeoManager* TEveManager::GetGeometry(const TString& filename) ...@@ -481,6 +481,7 @@ TGeoManager* TEveManager::GetGeometry(const TString& filename)
// Get geometry with given filename. // Get geometry with given filename.
// This is cached internally so the second time this function is // This is cached internally so the second time this function is
// called with the same argument the same geo-manager is returned. // called with the same argument the same geo-manager is returned.
// gGeoManager is set to the return value.
static const TEveException eh("TEveManager::GetGeometry "); static const TEveException eh("TEveManager::GetGeometry ");
...@@ -491,11 +492,20 @@ TGeoManager* TEveManager::GetGeometry(const TString& filename) ...@@ -491,11 +492,20 @@ TGeoManager* TEveManager::GetGeometry(const TString& filename)
std::map<TString, TGeoManager*>::iterator geom = fGeometries.find(filename); std::map<TString, TGeoManager*>::iterator geom = fGeometries.find(filename);
if (geom != fGeometries.end()) { if (geom != fGeometries.end()) {
return geom->second; gGeoManager = geom->second;
} else { } else {
gGeoManager = 0; gGeoManager = 0;
if (TGeoManager::Import(filename) == 0) Bool_t locked = TGeoManager::IsLocked();
throw(eh + "GeoManager::Import() failed for '" + exp_filename + "'."); if (locked) {
Warning(eh, "TGeoManager is locked ... unlocking it.");
TGeoManager::UnlockGeometry();
}
if (TGeoManager::Import(filename) == 0) {
throw(eh + "TGeoManager::Import() failed for '" + exp_filename + "'.");
}
if (locked) {
TGeoManager::LockGeometry();
}
gGeoManager->GetTopVolume()->VisibleDaughters(1); gGeoManager->GetTopVolume()->VisibleDaughters(1);
...@@ -520,8 +530,8 @@ TGeoManager* TEveManager::GetGeometry(const TString& filename) ...@@ -520,8 +530,8 @@ TGeoManager* TEveManager::GetGeometry(const TString& filename)
} }
fGeometries[filename] = gGeoManager; fGeometries[filename] = gGeoManager;
return gGeoManager;
} }
return gGeoManager;
} }
//______________________________________________________________________________ //______________________________________________________________________________
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment