//=====================================================================================
void DisplayGUI::DisplayAll()
{
- SalomeApp_Application* app = getGeometryGUI()->getApp();
- if ( !app ) return;
-
- SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
- if ( !appStudy ) return;
- _PTR(Study) aStudy = appStudy->studyDS();
+ _PTR(Study) aStudy = SalomeApp_Application::getStudy();
if ( !aStudy ) return;
_PTR(SComponent) SC ( aStudy->FindComponent( "GEOM" ) );
if ( !SC )
{
if ( obj ) {
// as soon as Use Case browser data tree was added
- return obj->GetStudy()->GetUseCaseBuilder()->HasChildren( obj );
+ return SalomeApp_Application::getStudy()->GetUseCaseBuilder()->HasChildren( obj );
}
}
_PTR(Study) study = appStudy->studyDS();
if ( study && !anEntry.isEmpty() ) {
_PTR(SObject) aSO( study->FindObjectID( anEntry.toStdString() ) );
- if ( aSO && aSO->GetStudy()->GetUseCaseBuilder()->IsUseCaseNode(aSO) ) {
- _PTR(UseCaseIterator) it = aSO->GetStudy()->GetUseCaseBuilder()->GetUseCaseIterator( aSO );
+ if ( aSO && study->GetUseCaseBuilder()->IsUseCaseNode(aSO) ) {
+ _PTR(UseCaseIterator) it = study->GetUseCaseBuilder()->GetUseCaseIterator( aSO );
for (it->Init(false); it->More(); it->Next()) nb++;
}
}
_PTR(SObject) aSO = dataObj->object();
if ( aSO ) {
_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") ) {
_PTR(AttributeLocalID) aLocalID( anAttr );
anObjectInFolder = aLocalID->Value() == 999;
_PTR(SObject) parentObj = dataObj->object();
// Find the current Study and StudyBuilder
- _PTR(Study) aStudy = parentObj->GetStudy();
+ _PTR(Study) aStudy = SalomeApp_Application::getStudy();
_PTR(UseCaseBuilder) aUseCaseBuilder = aStudy->GetUseCaseBuilder();
// collect all parents of the target node
QStringList parentIDs;
// purpose : check if the object(s) passed as the the second arguments are used
// 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() );
if ( !comp )
return false;
QMap<QString,QString>& geomObjList,
QMap<QString,QString>& folderList ) {
if ( !theSO ) return;
- _PTR(Study) aStudy = theSO->GetStudy();
+ _PTR(Study) aStudy = SalomeApp_Application::getStudy();
if ( !aStudy ) return;
_PTR(UseCaseBuilder) aUseCaseBuilder = aStudy->GetUseCaseBuilder();
return;
LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
- SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
- if ( !aSelMgr || !appStudy )
+ if ( !aSelMgr )
return;
// get selection
if ( selected.IsEmpty() )
return;
- _PTR(Study) aStudy = appStudy->studyDS();
+ _PTR(Study) aStudy = SalomeApp_Application::getStudy();
_PTR(UseCaseBuilder) aUseCaseBuilder = aStudy->GetUseCaseBuilder();
// check if study is locked
for ( it->InitEx( false ); it->More(); it->Next() ) {
_PTR(SObject) child( it->Value() );
// remove object from GEOM engine
- removeObjectWithChildren( child, aStudy, views, disp );
+ removeObjectWithChildren( child, views, disp );
// remove object from study
aStudyBuilder->RemoveObjectWithChildren( child );
// remove object from use case tree
}
else {
// 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(),
QObject::tr("WRN_WARNING"),
QObject::tr("DEP_OBJECT"),
for ( it = toBeDeleted.begin(); it != toBeDeleted.end(); ++it ) {
_PTR(SObject) obj ( aStudy->FindObjectID( it.key().toLatin1().data() ) );
// remove object from GEOM engine
- removeObjectWithChildren( obj, aStudy, views, disp );
+ removeObjectWithChildren( obj, views, disp );
// remove objects from study
aStudyBuilder->RemoveObjectWithChildren( obj );
// remove object from use case tree
for ( it = toBeDelFolders.begin(); it != toBeDelFolders.end(); ++it ) {
_PTR(SObject) obj ( aStudy->FindObjectID( it.key().toLatin1().data() ) );
// remove object from GEOM engine
- removeObjectWithChildren( obj, aStudy, views, disp );
+ removeObjectWithChildren( obj, views, disp );
// remove objects from study
aStudyBuilder->RemoveObjectWithChildren( obj );
// remove object from use case tree
// purpose : used by OnEditDelete() method
//=====================================================================================
void GEOMToolsGUI::removeObjectWithChildren(_PTR(SObject) obj,
- _PTR(Study) aStudy,
QList<SALOME_View*> views,
GEOM_Displayer* disp)
{
+ _PTR(Study) aStudy = SalomeApp_Application::getStudy();
// iterate through all children of obj
for (_PTR(ChildIterator) it (aStudy->NewChildIterator(obj)); it->More(); it->Next()) {
// for (_PTR(UseCaseIterator) it (aStudy->GetUseCaseBuilder()->GetUseCaseIterator(obj)); it->More(); it->Next()) {
_PTR(SObject) child (it->Value());
- removeObjectWithChildren(child, aStudy, views, disp);
+ removeObjectWithChildren(child, views, disp);
}
// erase object and remove it from engine
// Recursive deletion of object with children
void removeObjectWithChildren( _PTR(SObject),
- _PTR(Study),
QList<SALOME_View*>,
GEOM_Displayer* );
};
if(!myGeomRoot)
return;
- SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
- if(!appStudy )
- return;
-
- _PTR(Study) aStudy = appStudy->studyDS();
- if(!aStudy)
- return;
-
- buildTree(aStudy, myGeomRoot);
+ buildTree(myGeomRoot);
myTreeWidget->resizeColumnToContents(0);
myTreeWidget->resizeColumnToContents(1);
// function : findParentItem()
// 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;
SalomeApp_DataObject* aParrent = dynamic_cast<SalomeApp_DataObject*>(theObject->parent());
if( !(aResult = myEntryToItem.value(targetEntry)) ) {
if( aParrent != myGeomRoot ) {
QString aName;
- _PTR(SObject) aSO ( theStudy->FindObjectID(qPrintable(aParrent->entry())));
+ _PTR(SObject) aSO ( SalomeApp_Application::getStudy()->FindObjectID(qPrintable(aParrent->entry())));
_PTR(GenericAttribute) anAttr;
if ( aSO->FindAttribute(anAttr, "AttributeName") ) {
_PTR(AttributeName) anAttrName (anAttr);
aName = anAttrName->Value().c_str();
}
theList.push_front(qMakePair(targetEntry, aName));
- aResult = findParentItem(theStudy,aParrent,theList);
+ aResult = findParentItem(aParrent,theList);
} else {
//Publish List
for(int i = 0; i < theList.size(); i++ ) {
// function : buildTree()
// purpose :
//=================================================================================
-void GEOMToolsGUI_PublishDlg::buildTree(_PTR(Study) theStudy, SalomeApp_DataObject* theItem) {
+void GEOMToolsGUI_PublishDlg::buildTree(SalomeApp_DataObject* theItem) {
if(!theItem || theItem->isReference())
return;
//If object hasn't "AttributeDrawable" => it visible
bool isDrawable = true;
- _PTR(SObject) SO ( theStudy->FindObjectID(qPrintable(theItem->entry())));
+ _PTR(SObject) SO ( SalomeApp_Application::getStudy()->FindObjectID(qPrintable(theItem->entry())));
_PTR(GenericAttribute) anAttr;
if ( SO && SO->FindAttribute(anAttr, "AttributeDrawable") ) {
_PTR(AttributeDrawable) aDrw (anAttr);
aName = aAttrName->Value().c_str();
}
BufferedList aList;
- QTreeWidgetItem* parentItem = findParentItem(theStudy, theItem, aList);
+ QTreeWidgetItem* parentItem = findParentItem(theItem, aList);
createItem(parentItem,qMakePair(theItem->entry(),aName),true);
}
}
DataObjectList listObj = theItem->children( false );
DataObjectList::iterator itr = listObj.begin();
while( itr != listObj.end()) {
- buildTree(theStudy, dynamic_cast<SalomeApp_DataObject*>(*itr));
+ buildTree(dynamic_cast<SalomeApp_DataObject*>(*itr));
itr++;
}
}
protected:
void initData();
- void buildTree(_PTR(Study) theStudy, SalomeApp_DataObject* theItem);
- QTreeWidgetItem* findParentItem(_PTR(Study) theStudy, SalomeApp_DataObject* theItem, BufferedList& theList);
+ void buildTree(SalomeApp_DataObject* theItem);
+ QTreeWidgetItem* findParentItem(SalomeApp_DataObject* theItem, BufferedList& theList);
QTreeWidgetItem* createItem(QTreeWidgetItem* theItem, Pair theAttributes, bool isCheckable);
void getDrawableList(QTreeWidgetItem* theItem, QList<QTreeWidgetItem*>& theList);
void getTails(QTreeWidgetItem* theItem, QList<QTreeWidgetItem*>& theList);
myApp = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
if ( !myApp ) return;
- SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( myApp->activeStudy() );
- myStudy = study->studyDS();
+
myDisplayer = GEOM_Displayer();
setWindowTitle( tr( "GEOM_REDUCE_STUDY_TITLE" ) );
//=================================================================================
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
bool isDrawable = true;
- _PTR(SObject) SO ( myStudy->FindObjectID( theStudyEntry ) );
+ _PTR(SObject) SO ( aStudy->FindObjectID( theStudyEntry ) );
_PTR(GenericAttribute) anAttr;
if ( SO && SO->FindAttribute( anAttr, "AttributeDrawable" ) ) {
_PTR(AttributeDrawable) aDrw (anAttr);
//=================================================================================
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;
for( it = theObjects.begin(); it != theObjects.end(); ++it ) {
std::string objectEntry = *it;
std::string studyEntry = GeomBaseObject->GetStudyEntry();
if ( studyEntry == "" || !isObjectDrawable( studyEntry ) )
continue;
- _PTR(SObject) obj ( myStudy->FindObjectID( studyEntry.c_str() ) );
+ _PTR(SObject) obj ( aStudy->FindObjectID( studyEntry.c_str() ) );
_PTR(GenericAttribute) anAttr;
if ( obj ) {
_PTR(AttributeDrawable) aDrw = aStudyBuilder->FindOrCreateAttribute( obj, "AttributeDrawable" );
aDrw->SetDrawable( false );
myDisplayer.EraseWithChildren( new SALOME_InteractiveObject( studyEntry.c_str(), "GEOM", "TEMP_IO" ) );
// 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++ ) {
_PTR(SObject) refObj = vso[i];
aDrw = aStudyBuilder->FindOrCreateAttribute( refObj, "AttributeDrawable" );
void GEOMToolsGUI_ReduceStudyDlg::removeObject( std::string& theStudyEntry )
{
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( myApp->activeStudy() );
- _PTR(StudyBuilder) aStudyBuilder = myStudy->NewBuilder();
- _PTR(UseCaseBuilder) aUseCaseBuilder = myStudy->GetUseCaseBuilder();
+ _PTR(Study) aStudy = SalomeApp_Application::getStudy();
+ _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 ) {
// remove visual properties of the object
appStudy->removeObjectProperties(obj->GetID().c_str());
{
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 )
return;
- _PTR(ChildIterator) anIter ( myStudy->NewChildIterator( SC ) );
+ _PTR(ChildIterator) anIter ( aStudy->NewChildIterator( SC ) );
anIter->InitEx( true );
while( anIter->More() ) {
_PTR(SObject) valSO ( anIter->Value() );
//=================================================================================
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;
_PTR(GenericAttribute) anAttr;
GEOM_Displayer myDisplayer;
SalomeApp_Application* myApp;
- _PTR(Study) myStudy;
};
TCollection_AsciiString aNameWithExt("");
if (isMultiFile)
aNameWithExt = TCollection_AsciiString((char*)(SALOMEDS_Tool::GetNameFromPath
- (theComponent->GetStudy()->URL())).c_str());
+ (GetStudy()->URL())).c_str());
#if OCC_VERSION_MAJOR > 6
aNameWithExt += TCollection_AsciiString("_GEOM.cbf");
#else
// Prepare a file name to open
TCollection_AsciiString aNameWithExt("");
- SALOMEDS::Study_var study = theComponent->GetStudy();
+ SALOMEDS::Study_var study = GetStudy();
#if OCC_VERSION_MAJOR > 6
// Get the file name.
CORBA::Long theObjectID,
SALOMEDS::SObject_ptr theObject) {
// Find the current Study and StudyBuilder
- SALOMEDS::Study_var aStudy = theObject->GetStudy();
+ SALOMEDS::Study_var aStudy = GetStudy();
SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
SALOMEDS::UseCaseBuilder_var anUseCaseBuilder = aStudy->GetUseCaseBuilder();
SALOMEDS::SObject_var aNewSO;
//============================================================================
SALOMEDS::Study_var GEOM_Gen_i::GetStudy()
{
- CORBA::Object_var aStudyObject = name_service->Resolve( "/Study" );
- SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow( aStudyObject );
+ static SALOMEDS::Study_var aStudy;
+ if(CORBA::is_nil(aStudy)){
+ CORBA::Object_ptr anObject = name_service->Resolve("/Study");
+ aStudy = SALOMEDS::Study::_narrow(anObject);
+ }
return aStudy;
}
{
GEOM::GEOM_Object_var aGeomObject;
- CORBA::Object_var aStudyObject = name_service->Resolve( "/Study" );
- SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow( aStudyObject );
- SALOMEDS::SObject_var aSObj = aStudy->FindObjectID( entry );
+ SALOMEDS::SObject_var aSObj = GetStudy()->FindObjectID( entry );
SALOMEDS::SObject_var aResultSObj;
if (aSObj->ReferencedObject(aResultSObj))
aSObj = aResultSObj;
SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
CORBA::String_var aVal = anIOR->Value();
anIOR->UnRegister();
- CORBA::Object_var anObject = aStudy->ConvertIORToObject(aVal);
+ CORBA::Object_var anObject = GetStudy()->ConvertIORToObject(aVal);
aGeomObject = GEOM::GEOM_Object::_narrow(anObject);
}
if (!aSObj->_is_nil() )
aLocalID->UnRegister();
}
- SALOMEDS::Study_var aStudy = theFather->GetStudy();
+ SALOMEDS::Study_var aStudy = GetStudy();
SALOMEDS::StudyBuilder_var aStudyBuilder( aStudy->NewBuilder() );
aFolderSO = aStudyBuilder->NewObject( theFather );
SALOMEDS::SObject_ptr theFolder) {
GEOM::object_list_var objects = new GEOM::object_list();
objects->length( 1 );
- SALOMEDS::SObject_var aSO = theFolder->GetStudy()->FindObjectID( theObject->GetStudyEntry() );
+ SALOMEDS::SObject_var aSO = GetStudy()->FindObjectID( theObject->GetStudyEntry() );
objects[0] = aSO;
Move( objects, theFolder, -1 );
}
SALOMEDS::SObject_var aSO;
for (int i = 0; i < aLen; i++) {
aGO = GEOM::GEOM_Object::_duplicate( theListOfGO[i] );
- aSO = theFolder->GetStudy()->FindObjectID( aGO->GetStudyEntry() );
+ aSO = GetStudy()->FindObjectID( aGO->GetStudyEntry() );
objects[i] = aSO;
}
if ( objects->length() > 0 )
{
if ( CORBA::is_nil( where ) ) return;
- SALOMEDS::Study_var study = where->GetStudy();
+ SALOMEDS::Study_var study = GetStudy();
SALOMEDS::StudyBuilder_var studyBuilder = study->NewBuilder();
SALOMEDS::UseCaseBuilder_var useCaseBuilder = study->GetUseCaseBuilder();
SALOMEDS::SComponent_var father = where->GetFatherComponent();
"""
if theSObject is not None:
gg = salome.ImportComponentGUI("GEOM")
- aStudy = theSObject.GetStudy()
- useCaseBuilder = aStudy.GetUseCaseBuilder()
+ useCaseBuilder = salome.myStudy.GetUseCaseBuilder()
editor = getStudyEditor()
aIterator = useCaseBuilder.GetUseCaseIterator(theSObject)
aIterator.Init(False)