Deleted Study as an input parameter and as a class field.

This commit is contained in:
mpa 2017-01-31 12:27:37 +03:00
parent 8bea06f4fa
commit b409504254
11 changed files with 58 additions and 70 deletions

View File

@ -180,12 +180,7 @@ bool DisplayGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent)
//===================================================================================== //=====================================================================================
void DisplayGUI::DisplayAll() void DisplayGUI::DisplayAll()
{ {
SalomeApp_Application* app = getGeometryGUI()->getApp(); _PTR(Study) aStudy = SalomeApp_Application::getStudy();
if ( !app ) return;
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
if ( !appStudy ) return;
_PTR(Study) aStudy = appStudy->studyDS();
if ( !aStudy ) return; if ( !aStudy ) return;
_PTR(SComponent) SC ( aStudy->FindComponent( "GEOM" ) ); _PTR(SComponent) SC ( aStudy->FindComponent( "GEOM" ) );
if ( !SC ) if ( !SC )

View File

@ -529,7 +529,7 @@ bool GEOMGUI_Selection::hasChildren( const _PTR(SObject)& obj )
{ {
if ( obj ) { if ( obj ) {
// as soon as Use Case browser data tree was added // as soon as Use Case browser data tree was added
return obj->GetStudy()->GetUseCaseBuilder()->HasChildren( obj ); return SalomeApp_Application::getStudy()->GetUseCaseBuilder()->HasChildren( obj );
} }
} }
@ -592,8 +592,8 @@ int GEOMGUI_Selection::nbChildren( const int index ) const
_PTR(Study) study = appStudy->studyDS(); _PTR(Study) study = appStudy->studyDS();
if ( study && !anEntry.isEmpty() ) { if ( study && !anEntry.isEmpty() ) {
_PTR(SObject) aSO( study->FindObjectID( anEntry.toStdString() ) ); _PTR(SObject) aSO( study->FindObjectID( anEntry.toStdString() ) );
if ( aSO && aSO->GetStudy()->GetUseCaseBuilder()->IsUseCaseNode(aSO) ) { if ( aSO && study->GetUseCaseBuilder()->IsUseCaseNode(aSO) ) {
_PTR(UseCaseIterator) it = aSO->GetStudy()->GetUseCaseBuilder()->GetUseCaseIterator( aSO ); _PTR(UseCaseIterator) it = study->GetUseCaseBuilder()->GetUseCaseIterator( aSO );
for (it->Init(false); it->More(); it->Next()) nb++; for (it->Init(false); it->More(); it->Next()) nb++;
} }
} }

View File

@ -3399,7 +3399,7 @@ bool GeometryGUI::isDraggable( const SUIT_DataObject* what ) const
_PTR(SObject) aSO = dataObj->object(); _PTR(SObject) aSO = dataObj->object();
if ( aSO ) { if ( aSO ) {
_PTR(GenericAttribute) anAttr; _PTR(GenericAttribute) anAttr;
_PTR(SObject) aFatherSO = aSO->GetStudy()->GetUseCaseBuilder()->GetFather( aSO ); _PTR(SObject) aFatherSO = SalomeApp_Application::getStudy()->GetUseCaseBuilder()->GetFather( aSO );
if ( aFatherSO && aFatherSO->FindAttribute(anAttr, "AttributeLocalID") ) { if ( aFatherSO && aFatherSO->FindAttribute(anAttr, "AttributeLocalID") ) {
_PTR(AttributeLocalID) aLocalID( anAttr ); _PTR(AttributeLocalID) aLocalID( anAttr );
anObjectInFolder = aLocalID->Value() == 999; anObjectInFolder = aLocalID->Value() == 999;
@ -3476,7 +3476,7 @@ void GeometryGUI::dropObjects( const DataObjectList& what, SUIT_DataObject* wher
_PTR(SObject) parentObj = dataObj->object(); _PTR(SObject) parentObj = dataObj->object();
// Find the current Study and StudyBuilder // Find the current Study and StudyBuilder
_PTR(Study) aStudy = parentObj->GetStudy(); _PTR(Study) aStudy = SalomeApp_Application::getStudy();
_PTR(UseCaseBuilder) aUseCaseBuilder = aStudy->GetUseCaseBuilder(); _PTR(UseCaseBuilder) aUseCaseBuilder = aStudy->GetUseCaseBuilder();
// collect all parents of the target node // collect all parents of the target node
QStringList parentIDs; QStringList parentIDs;

View File

@ -80,8 +80,9 @@ static QString getParentComponent( _PTR( SObject ) obj )
// purpose : check if the object(s) passed as the the second arguments are used // purpose : check if the object(s) passed as the the second arguments are used
// by the other objects in the study // by the other objects in the study
//===================================================================================== //=====================================================================================
static bool inUse( _PTR(Study) study, const QString& component, const QMap<QString,QString>& objects ) static bool inUse( const QString& component, const QMap<QString,QString>& objects )
{ {
_PTR(Study) study = SalomeApp_Application::getStudy();
_PTR(SObject) comp = study->FindObjectID( component.toLatin1().data() ); _PTR(SObject) comp = study->FindObjectID( component.toLatin1().data() );
if ( !comp ) if ( !comp )
return false; return false;
@ -154,7 +155,7 @@ static void getGeomChildrenAndFolders( _PTR(SObject) theSO,
QMap<QString,QString>& geomObjList, QMap<QString,QString>& geomObjList,
QMap<QString,QString>& folderList ) { QMap<QString,QString>& folderList ) {
if ( !theSO ) return; if ( !theSO ) return;
_PTR(Study) aStudy = theSO->GetStudy(); _PTR(Study) aStudy = SalomeApp_Application::getStudy();
if ( !aStudy ) return; if ( !aStudy ) return;
_PTR(UseCaseBuilder) aUseCaseBuilder = aStudy->GetUseCaseBuilder(); _PTR(UseCaseBuilder) aUseCaseBuilder = aStudy->GetUseCaseBuilder();
@ -355,8 +356,7 @@ void GEOMToolsGUI::OnEditDelete()
return; return;
LightApp_SelectionMgr* aSelMgr = app->selectionMgr(); LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ); if ( !aSelMgr )
if ( !aSelMgr || !appStudy )
return; return;
// get selection // get selection
@ -364,7 +364,7 @@ void GEOMToolsGUI::OnEditDelete()
if ( selected.IsEmpty() ) if ( selected.IsEmpty() )
return; return;
_PTR(Study) aStudy = appStudy->studyDS(); _PTR(Study) aStudy = SalomeApp_Application::getStudy();
_PTR(UseCaseBuilder) aUseCaseBuilder = aStudy->GetUseCaseBuilder(); _PTR(UseCaseBuilder) aUseCaseBuilder = aStudy->GetUseCaseBuilder();
// check if study is locked // check if study is locked
@ -469,7 +469,7 @@ void GEOMToolsGUI::OnEditDelete()
for ( it->InitEx( false ); it->More(); it->Next() ) { for ( it->InitEx( false ); it->More(); it->Next() ) {
_PTR(SObject) child( it->Value() ); _PTR(SObject) child( it->Value() );
// remove object from GEOM engine // remove object from GEOM engine
removeObjectWithChildren( child, aStudy, views, disp ); removeObjectWithChildren( child, views, disp );
// remove object from study // remove object from study
aStudyBuilder->RemoveObjectWithChildren( child ); aStudyBuilder->RemoveObjectWithChildren( child );
// remove object from use case tree // remove object from use case tree
@ -478,7 +478,7 @@ void GEOMToolsGUI::OnEditDelete()
} }
else { else {
// GEOM component is not selected: check if selected objects are in use // GEOM component is not selected: check if selected objects are in use
if ( inUse( aStudy, geomComp, allDeleted ) && if ( inUse( geomComp, allDeleted ) &&
SUIT_MessageBox::question( app->desktop(), SUIT_MessageBox::question( app->desktop(),
QObject::tr("WRN_WARNING"), QObject::tr("WRN_WARNING"),
QObject::tr("DEP_OBJECT"), QObject::tr("DEP_OBJECT"),
@ -491,7 +491,7 @@ void GEOMToolsGUI::OnEditDelete()
for ( it = toBeDeleted.begin(); it != toBeDeleted.end(); ++it ) { for ( it = toBeDeleted.begin(); it != toBeDeleted.end(); ++it ) {
_PTR(SObject) obj ( aStudy->FindObjectID( it.key().toLatin1().data() ) ); _PTR(SObject) obj ( aStudy->FindObjectID( it.key().toLatin1().data() ) );
// remove object from GEOM engine // remove object from GEOM engine
removeObjectWithChildren( obj, aStudy, views, disp ); removeObjectWithChildren( obj, views, disp );
// remove objects from study // remove objects from study
aStudyBuilder->RemoveObjectWithChildren( obj ); aStudyBuilder->RemoveObjectWithChildren( obj );
// remove object from use case tree // remove object from use case tree
@ -501,7 +501,7 @@ void GEOMToolsGUI::OnEditDelete()
for ( it = toBeDelFolders.begin(); it != toBeDelFolders.end(); ++it ) { for ( it = toBeDelFolders.begin(); it != toBeDelFolders.end(); ++it ) {
_PTR(SObject) obj ( aStudy->FindObjectID( it.key().toLatin1().data() ) ); _PTR(SObject) obj ( aStudy->FindObjectID( it.key().toLatin1().data() ) );
// remove object from GEOM engine // remove object from GEOM engine
removeObjectWithChildren( obj, aStudy, views, disp ); removeObjectWithChildren( obj, views, disp );
// remove objects from study // remove objects from study
aStudyBuilder->RemoveObjectWithChildren( obj ); aStudyBuilder->RemoveObjectWithChildren( obj );
// remove object from use case tree // remove object from use case tree
@ -520,15 +520,15 @@ void GEOMToolsGUI::OnEditDelete()
// purpose : used by OnEditDelete() method // purpose : used by OnEditDelete() method
//===================================================================================== //=====================================================================================
void GEOMToolsGUI::removeObjectWithChildren(_PTR(SObject) obj, void GEOMToolsGUI::removeObjectWithChildren(_PTR(SObject) obj,
_PTR(Study) aStudy,
QList<SALOME_View*> views, QList<SALOME_View*> views,
GEOM_Displayer* disp) GEOM_Displayer* disp)
{ {
_PTR(Study) aStudy = SalomeApp_Application::getStudy();
// iterate through all children of obj // iterate through all children of obj
for (_PTR(ChildIterator) it (aStudy->NewChildIterator(obj)); it->More(); it->Next()) { for (_PTR(ChildIterator) it (aStudy->NewChildIterator(obj)); it->More(); it->Next()) {
// for (_PTR(UseCaseIterator) it (aStudy->GetUseCaseBuilder()->GetUseCaseIterator(obj)); it->More(); it->Next()) { // for (_PTR(UseCaseIterator) it (aStudy->GetUseCaseBuilder()->GetUseCaseIterator(obj)); it->More(); it->Next()) {
_PTR(SObject) child (it->Value()); _PTR(SObject) child (it->Value());
removeObjectWithChildren(child, aStudy, views, disp); removeObjectWithChildren(child, views, disp);
} }
// erase object and remove it from engine // erase object and remove it from engine

View File

@ -97,7 +97,6 @@ private:
// Recursive deletion of object with children // Recursive deletion of object with children
void removeObjectWithChildren( _PTR(SObject), void removeObjectWithChildren( _PTR(SObject),
_PTR(Study),
QList<SALOME_View*>, QList<SALOME_View*>,
GEOM_Displayer* ); GEOM_Displayer* );
}; };

View File

@ -185,15 +185,7 @@ void GEOMToolsGUI_PublishDlg::initData() {
if(!myGeomRoot) if(!myGeomRoot)
return; return;
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ); buildTree(myGeomRoot);
if(!appStudy )
return;
_PTR(Study) aStudy = appStudy->studyDS();
if(!aStudy)
return;
buildTree(aStudy, myGeomRoot);
myTreeWidget->resizeColumnToContents(0); myTreeWidget->resizeColumnToContents(0);
myTreeWidget->resizeColumnToContents(1); myTreeWidget->resizeColumnToContents(1);
@ -231,7 +223,7 @@ QTreeWidgetItem* GEOMToolsGUI_PublishDlg::createItem(QTreeWidgetItem* theParent,
// function : findParentItem() // function : findParentItem()
// purpose : // purpose :
//================================================================================= //=================================================================================
QTreeWidgetItem* GEOMToolsGUI_PublishDlg::findParentItem(_PTR(Study) theStudy, SalomeApp_DataObject* theObject, BufferedList& theList ) { QTreeWidgetItem* GEOMToolsGUI_PublishDlg::findParentItem(SalomeApp_DataObject* theObject, BufferedList& theList ) {
QTreeWidgetItem* aResult = NULL; QTreeWidgetItem* aResult = NULL;
SalomeApp_DataObject* aParrent = dynamic_cast<SalomeApp_DataObject*>(theObject->parent()); SalomeApp_DataObject* aParrent = dynamic_cast<SalomeApp_DataObject*>(theObject->parent());
@ -240,14 +232,14 @@ QTreeWidgetItem* GEOMToolsGUI_PublishDlg::findParentItem(_PTR(Study) theStudy, S
if( !(aResult = myEntryToItem.value(targetEntry)) ) { if( !(aResult = myEntryToItem.value(targetEntry)) ) {
if( aParrent != myGeomRoot ) { if( aParrent != myGeomRoot ) {
QString aName; QString aName;
_PTR(SObject) aSO ( theStudy->FindObjectID(qPrintable(aParrent->entry()))); _PTR(SObject) aSO ( SalomeApp_Application::getStudy()->FindObjectID(qPrintable(aParrent->entry())));
_PTR(GenericAttribute) anAttr; _PTR(GenericAttribute) anAttr;
if ( aSO->FindAttribute(anAttr, "AttributeName") ) { if ( aSO->FindAttribute(anAttr, "AttributeName") ) {
_PTR(AttributeName) anAttrName (anAttr); _PTR(AttributeName) anAttrName (anAttr);
aName = anAttrName->Value().c_str(); aName = anAttrName->Value().c_str();
} }
theList.push_front(qMakePair(targetEntry, aName)); theList.push_front(qMakePair(targetEntry, aName));
aResult = findParentItem(theStudy,aParrent,theList); aResult = findParentItem(aParrent,theList);
} else { } else {
//Publish List //Publish List
for(int i = 0; i < theList.size(); i++ ) { for(int i = 0; i < theList.size(); i++ ) {
@ -270,7 +262,7 @@ QTreeWidgetItem* GEOMToolsGUI_PublishDlg::findParentItem(_PTR(Study) theStudy, S
// function : buildTree() // function : buildTree()
// purpose : // purpose :
//================================================================================= //=================================================================================
void GEOMToolsGUI_PublishDlg::buildTree(_PTR(Study) theStudy, SalomeApp_DataObject* theItem) { void GEOMToolsGUI_PublishDlg::buildTree(SalomeApp_DataObject* theItem) {
if(!theItem || theItem->isReference()) if(!theItem || theItem->isReference())
return; return;
@ -278,7 +270,7 @@ void GEOMToolsGUI_PublishDlg::buildTree(_PTR(Study) theStudy, SalomeApp_DataObje
//If object hasn't "AttributeDrawable" => it visible //If object hasn't "AttributeDrawable" => it visible
bool isDrawable = true; bool isDrawable = true;
_PTR(SObject) SO ( theStudy->FindObjectID(qPrintable(theItem->entry()))); _PTR(SObject) SO ( SalomeApp_Application::getStudy()->FindObjectID(qPrintable(theItem->entry())));
_PTR(GenericAttribute) anAttr; _PTR(GenericAttribute) anAttr;
if ( SO && SO->FindAttribute(anAttr, "AttributeDrawable") ) { if ( SO && SO->FindAttribute(anAttr, "AttributeDrawable") ) {
_PTR(AttributeDrawable) aDrw (anAttr); _PTR(AttributeDrawable) aDrw (anAttr);
@ -292,7 +284,7 @@ void GEOMToolsGUI_PublishDlg::buildTree(_PTR(Study) theStudy, SalomeApp_DataObje
aName = aAttrName->Value().c_str(); aName = aAttrName->Value().c_str();
} }
BufferedList aList; BufferedList aList;
QTreeWidgetItem* parentItem = findParentItem(theStudy, theItem, aList); QTreeWidgetItem* parentItem = findParentItem(theItem, aList);
createItem(parentItem,qMakePair(theItem->entry(),aName),true); createItem(parentItem,qMakePair(theItem->entry(),aName),true);
} }
} }
@ -300,7 +292,7 @@ void GEOMToolsGUI_PublishDlg::buildTree(_PTR(Study) theStudy, SalomeApp_DataObje
DataObjectList listObj = theItem->children( false ); DataObjectList listObj = theItem->children( false );
DataObjectList::iterator itr = listObj.begin(); DataObjectList::iterator itr = listObj.begin();
while( itr != listObj.end()) { while( itr != listObj.end()) {
buildTree(theStudy, dynamic_cast<SalomeApp_DataObject*>(*itr)); buildTree(dynamic_cast<SalomeApp_DataObject*>(*itr));
itr++; itr++;
} }
} }

View File

@ -59,8 +59,8 @@ public:
protected: protected:
void initData(); void initData();
void buildTree(_PTR(Study) theStudy, SalomeApp_DataObject* theItem); void buildTree(SalomeApp_DataObject* theItem);
QTreeWidgetItem* findParentItem(_PTR(Study) theStudy, SalomeApp_DataObject* theItem, BufferedList& theList); QTreeWidgetItem* findParentItem(SalomeApp_DataObject* theItem, BufferedList& theList);
QTreeWidgetItem* createItem(QTreeWidgetItem* theItem, Pair theAttributes, bool isCheckable); QTreeWidgetItem* createItem(QTreeWidgetItem* theItem, Pair theAttributes, bool isCheckable);
void getDrawableList(QTreeWidgetItem* theItem, QList<QTreeWidgetItem*>& theList); void getDrawableList(QTreeWidgetItem* theItem, QList<QTreeWidgetItem*>& theList);
void getTails(QTreeWidgetItem* theItem, QList<QTreeWidgetItem*>& theList); void getTails(QTreeWidgetItem* theItem, QList<QTreeWidgetItem*>& theList);

View File

@ -50,8 +50,7 @@ GEOMToolsGUI_ReduceStudyDlg::GEOMToolsGUI_ReduceStudyDlg( QWidget* parent )
myApp = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); myApp = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
if ( !myApp ) return; if ( !myApp ) return;
SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( myApp->activeStudy() );
myStudy = study->studyDS();
myDisplayer = GEOM_Displayer(); myDisplayer = GEOM_Displayer();
setWindowTitle( tr( "GEOM_REDUCE_STUDY_TITLE" ) ); setWindowTitle( tr( "GEOM_REDUCE_STUDY_TITLE" ) );
@ -370,10 +369,11 @@ void GEOMToolsGUI_ReduceStudyDlg::checkVisibleIcon( QTreeWidget* theWidget )
//================================================================================= //=================================================================================
bool GEOMToolsGUI_ReduceStudyDlg::isObjectDrawable( std::string theStudyEntry ) bool GEOMToolsGUI_ReduceStudyDlg::isObjectDrawable( std::string theStudyEntry )
{ {
_PTR(StudyBuilder) aStudyBuilder = myStudy->NewBuilder(); _PTR(Study) aStudy = SalomeApp_Application::getStudy();
_PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
//If object hasn't "AttributeDrawable" => it visible //If object hasn't "AttributeDrawable" => it visible
bool isDrawable = true; bool isDrawable = true;
_PTR(SObject) SO ( myStudy->FindObjectID( theStudyEntry ) ); _PTR(SObject) SO ( aStudy->FindObjectID( theStudyEntry ) );
_PTR(GenericAttribute) anAttr; _PTR(GenericAttribute) anAttr;
if ( SO && SO->FindAttribute( anAttr, "AttributeDrawable" ) ) { if ( SO && SO->FindAttribute( anAttr, "AttributeDrawable" ) ) {
_PTR(AttributeDrawable) aDrw (anAttr); _PTR(AttributeDrawable) aDrw (anAttr);
@ -388,7 +388,8 @@ bool GEOMToolsGUI_ReduceStudyDlg::isObjectDrawable( std::string theStudyEntry )
//================================================================================= //=================================================================================
void GEOMToolsGUI_ReduceStudyDlg::unpublishObjects( std::set<std::string>& theObjects ) void GEOMToolsGUI_ReduceStudyDlg::unpublishObjects( std::set<std::string>& theObjects )
{ {
_PTR(StudyBuilder) aStudyBuilder = myStudy->NewBuilder(); _PTR(Study) aStudy = SalomeApp_Application::getStudy();
_PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
std::set<std::string>::iterator it; std::set<std::string>::iterator it;
for( it = theObjects.begin(); it != theObjects.end(); ++it ) { for( it = theObjects.begin(); it != theObjects.end(); ++it ) {
std::string objectEntry = *it; std::string objectEntry = *it;
@ -396,14 +397,14 @@ void GEOMToolsGUI_ReduceStudyDlg::unpublishObjects( std::set<std::string>& theOb
std::string studyEntry = GeomBaseObject->GetStudyEntry(); std::string studyEntry = GeomBaseObject->GetStudyEntry();
if ( studyEntry == "" || !isObjectDrawable( studyEntry ) ) if ( studyEntry == "" || !isObjectDrawable( studyEntry ) )
continue; continue;
_PTR(SObject) obj ( myStudy->FindObjectID( studyEntry.c_str() ) ); _PTR(SObject) obj ( aStudy->FindObjectID( studyEntry.c_str() ) );
_PTR(GenericAttribute) anAttr; _PTR(GenericAttribute) anAttr;
if ( obj ) { if ( obj ) {
_PTR(AttributeDrawable) aDrw = aStudyBuilder->FindOrCreateAttribute( obj, "AttributeDrawable" ); _PTR(AttributeDrawable) aDrw = aStudyBuilder->FindOrCreateAttribute( obj, "AttributeDrawable" );
aDrw->SetDrawable( false ); aDrw->SetDrawable( false );
myDisplayer.EraseWithChildren( new SALOME_InteractiveObject( studyEntry.c_str(), "GEOM", "TEMP_IO" ) ); myDisplayer.EraseWithChildren( new SALOME_InteractiveObject( studyEntry.c_str(), "GEOM", "TEMP_IO" ) );
// hide references if any // hide references if any
std::vector< _PTR(SObject) > vso = myStudy->FindDependances(obj); std::vector< _PTR(SObject) > vso = aStudy->FindDependances(obj);
for ( int i = 0; i < vso.size(); i++ ) { for ( int i = 0; i < vso.size(); i++ ) {
_PTR(SObject) refObj = vso[i]; _PTR(SObject) refObj = vso[i];
aDrw = aStudyBuilder->FindOrCreateAttribute( refObj, "AttributeDrawable" ); aDrw = aStudyBuilder->FindOrCreateAttribute( refObj, "AttributeDrawable" );
@ -445,10 +446,11 @@ void GEOMToolsGUI_ReduceStudyDlg::removeObjects( std::set<std::string>& theObjec
void GEOMToolsGUI_ReduceStudyDlg::removeObject( std::string& theStudyEntry ) void GEOMToolsGUI_ReduceStudyDlg::removeObject( std::string& theStudyEntry )
{ {
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( myApp->activeStudy() ); SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( myApp->activeStudy() );
_PTR(StudyBuilder) aStudyBuilder = myStudy->NewBuilder(); _PTR(Study) aStudy = SalomeApp_Application::getStudy();
_PTR(UseCaseBuilder) aUseCaseBuilder = myStudy->GetUseCaseBuilder(); _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
_PTR(UseCaseBuilder) aUseCaseBuilder = aStudy->GetUseCaseBuilder();
_PTR(SObject) obj ( myStudy->FindObjectID( theStudyEntry.c_str() ) ); _PTR(SObject) obj ( aStudy->FindObjectID( theStudyEntry.c_str() ) );
if ( obj ) { if ( obj ) {
// remove visual properties of the object // remove visual properties of the object
appStudy->removeObjectProperties(obj->GetID().c_str()); appStudy->removeObjectProperties(obj->GetID().c_str());
@ -470,10 +472,11 @@ void GEOMToolsGUI_ReduceStudyDlg::removeEmptyFolders()
{ {
std::set<std::string> emptyFolders; std::set<std::string> emptyFolders;
_PTR(SComponent) SC ( myStudy->FindComponent( "GEOM" ) ); _PTR(Study) aStudy = SalomeApp_Application::getStudy();
_PTR(SComponent) SC ( aStudy->FindComponent( "GEOM" ) );
if ( !SC ) if ( !SC )
return; return;
_PTR(ChildIterator) anIter ( myStudy->NewChildIterator( SC ) ); _PTR(ChildIterator) anIter ( aStudy->NewChildIterator( SC ) );
anIter->InitEx( true ); anIter->InitEx( true );
while( anIter->More() ) { while( anIter->More() ) {
_PTR(SObject) valSO ( anIter->Value() ); _PTR(SObject) valSO ( anIter->Value() );
@ -498,7 +501,7 @@ void GEOMToolsGUI_ReduceStudyDlg::removeEmptyFolders()
//================================================================================= //=================================================================================
void GEOMToolsGUI_ReduceStudyDlg::getEmptyFolders( _PTR(SObject) theSO, std::set<std::string>& theFolders ) void GEOMToolsGUI_ReduceStudyDlg::getEmptyFolders( _PTR(SObject) theSO, std::set<std::string>& theFolders )
{ {
_PTR(UseCaseBuilder) aUseCaseBuilder = myStudy->GetUseCaseBuilder(); _PTR(UseCaseBuilder) aUseCaseBuilder = SalomeApp_Application::getStudy()->GetUseCaseBuilder();
bool isFolder = false; bool isFolder = false;
_PTR(GenericAttribute) anAttr; _PTR(GenericAttribute) anAttr;

View File

@ -120,7 +120,6 @@ private:
GEOM_Displayer myDisplayer; GEOM_Displayer myDisplayer;
SalomeApp_Application* myApp; SalomeApp_Application* myApp;
_PTR(Study) myStudy;
}; };

View File

@ -595,7 +595,7 @@ SALOMEDS::TMPFile* GEOM_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent,
TCollection_AsciiString aNameWithExt(""); TCollection_AsciiString aNameWithExt("");
if (isMultiFile) if (isMultiFile)
aNameWithExt = TCollection_AsciiString((char*)(SALOMEDS_Tool::GetNameFromPath aNameWithExt = TCollection_AsciiString((char*)(SALOMEDS_Tool::GetNameFromPath
(theComponent->GetStudy()->URL())).c_str()); (GetStudy()->URL())).c_str());
#if OCC_VERSION_MAJOR > 6 #if OCC_VERSION_MAJOR > 6
aNameWithExt += TCollection_AsciiString("_GEOM.cbf"); aNameWithExt += TCollection_AsciiString("_GEOM.cbf");
#else #else
@ -661,7 +661,7 @@ CORBA::Boolean GEOM_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent,
// Prepare a file name to open // Prepare a file name to open
TCollection_AsciiString aNameWithExt(""); TCollection_AsciiString aNameWithExt("");
SALOMEDS::Study_var study = theComponent->GetStudy(); SALOMEDS::Study_var study = GetStudy();
#if OCC_VERSION_MAJOR > 6 #if OCC_VERSION_MAJOR > 6
// Get the file name. // Get the file name.
@ -800,7 +800,7 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::PasteInto(const SALOMEDS::TMPFile& theStream,
CORBA::Long theObjectID, CORBA::Long theObjectID,
SALOMEDS::SObject_ptr theObject) { SALOMEDS::SObject_ptr theObject) {
// Find the current Study and StudyBuilder // Find the current Study and StudyBuilder
SALOMEDS::Study_var aStudy = theObject->GetStudy(); SALOMEDS::Study_var aStudy = GetStudy();
SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
SALOMEDS::UseCaseBuilder_var anUseCaseBuilder = aStudy->GetUseCaseBuilder(); SALOMEDS::UseCaseBuilder_var anUseCaseBuilder = aStudy->GetUseCaseBuilder();
SALOMEDS::SObject_var aNewSO; SALOMEDS::SObject_var aNewSO;
@ -2175,8 +2175,11 @@ void GEOM_Gen_i::register_name(char * name)
//============================================================================ //============================================================================
SALOMEDS::Study_var GEOM_Gen_i::GetStudy() SALOMEDS::Study_var GEOM_Gen_i::GetStudy()
{ {
CORBA::Object_var aStudyObject = name_service->Resolve( "/Study" ); static SALOMEDS::Study_var aStudy;
SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow( aStudyObject ); if(CORBA::is_nil(aStudy)){
CORBA::Object_ptr anObject = name_service->Resolve("/Study");
aStudy = SALOMEDS::Study::_narrow(anObject);
}
return aStudy; return aStudy;
} }
@ -2681,9 +2684,7 @@ char* GEOM_Gen_i::getObjectInfo(const char* entry)
{ {
GEOM::GEOM_Object_var aGeomObject; GEOM::GEOM_Object_var aGeomObject;
CORBA::Object_var aStudyObject = name_service->Resolve( "/Study" ); SALOMEDS::SObject_var aSObj = GetStudy()->FindObjectID( entry );
SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow( aStudyObject );
SALOMEDS::SObject_var aSObj = aStudy->FindObjectID( entry );
SALOMEDS::SObject_var aResultSObj; SALOMEDS::SObject_var aResultSObj;
if (aSObj->ReferencedObject(aResultSObj)) if (aSObj->ReferencedObject(aResultSObj))
aSObj = aResultSObj; aSObj = aResultSObj;
@ -2693,7 +2694,7 @@ char* GEOM_Gen_i::getObjectInfo(const char* entry)
SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
CORBA::String_var aVal = anIOR->Value(); CORBA::String_var aVal = anIOR->Value();
anIOR->UnRegister(); anIOR->UnRegister();
CORBA::Object_var anObject = aStudy->ConvertIORToObject(aVal); CORBA::Object_var anObject = GetStudy()->ConvertIORToObject(aVal);
aGeomObject = GEOM::GEOM_Object::_narrow(anObject); aGeomObject = GEOM::GEOM_Object::_narrow(anObject);
} }
if (!aSObj->_is_nil() ) if (!aSObj->_is_nil() )
@ -2857,7 +2858,7 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::CreateFolder(const char* theName,
aLocalID->UnRegister(); aLocalID->UnRegister();
} }
SALOMEDS::Study_var aStudy = theFather->GetStudy(); SALOMEDS::Study_var aStudy = GetStudy();
SALOMEDS::StudyBuilder_var aStudyBuilder( aStudy->NewBuilder() ); SALOMEDS::StudyBuilder_var aStudyBuilder( aStudy->NewBuilder() );
aFolderSO = aStudyBuilder->NewObject( theFather ); aFolderSO = aStudyBuilder->NewObject( theFather );
@ -2892,7 +2893,7 @@ void GEOM_Gen_i::MoveToFolder(GEOM::GEOM_Object_ptr theObject,
SALOMEDS::SObject_ptr theFolder) { SALOMEDS::SObject_ptr theFolder) {
GEOM::object_list_var objects = new GEOM::object_list(); GEOM::object_list_var objects = new GEOM::object_list();
objects->length( 1 ); objects->length( 1 );
SALOMEDS::SObject_var aSO = theFolder->GetStudy()->FindObjectID( theObject->GetStudyEntry() ); SALOMEDS::SObject_var aSO = GetStudy()->FindObjectID( theObject->GetStudyEntry() );
objects[0] = aSO; objects[0] = aSO;
Move( objects, theFolder, -1 ); Move( objects, theFolder, -1 );
} }
@ -2910,7 +2911,7 @@ void GEOM_Gen_i::MoveListToFolder (const GEOM::ListOfGO& theListOfGO,
SALOMEDS::SObject_var aSO; SALOMEDS::SObject_var aSO;
for (int i = 0; i < aLen; i++) { for (int i = 0; i < aLen; i++) {
aGO = GEOM::GEOM_Object::_duplicate( theListOfGO[i] ); aGO = GEOM::GEOM_Object::_duplicate( theListOfGO[i] );
aSO = theFolder->GetStudy()->FindObjectID( aGO->GetStudyEntry() ); aSO = GetStudy()->FindObjectID( aGO->GetStudyEntry() );
objects[i] = aSO; objects[i] = aSO;
} }
if ( objects->length() > 0 ) if ( objects->length() > 0 )
@ -2928,7 +2929,7 @@ void GEOM_Gen_i::Move( const GEOM::object_list& what,
{ {
if ( CORBA::is_nil( where ) ) return; if ( CORBA::is_nil( where ) ) return;
SALOMEDS::Study_var study = where->GetStudy(); SALOMEDS::Study_var study = GetStudy();
SALOMEDS::StudyBuilder_var studyBuilder = study->NewBuilder(); SALOMEDS::StudyBuilder_var studyBuilder = study->NewBuilder();
SALOMEDS::UseCaseBuilder_var useCaseBuilder = study->GetUseCaseBuilder(); SALOMEDS::UseCaseBuilder_var useCaseBuilder = study->GetUseCaseBuilder();
SALOMEDS::SComponent_var father = where->GetFatherComponent(); SALOMEDS::SComponent_var father = where->GetFatherComponent();

View File

@ -476,8 +476,7 @@ class StructuralElement:
""" """
if theSObject is not None: if theSObject is not None:
gg = salome.ImportComponentGUI("GEOM") gg = salome.ImportComponentGUI("GEOM")
aStudy = theSObject.GetStudy() useCaseBuilder = salome.myStudy.GetUseCaseBuilder()
useCaseBuilder = aStudy.GetUseCaseBuilder()
editor = getStudyEditor() editor = getStudyEditor()
aIterator = useCaseBuilder.GetUseCaseIterator(theSObject) aIterator = useCaseBuilder.GetUseCaseIterator(theSObject)
aIterator.Init(False) aIterator.Init(False)