-// Copyright (C) 2014 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2014-2021 CEA/DEN, EDF R&D, OPEN CASCADE
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
#include <SalomeApp_Application.h>
#include <SalomeApp_Study.h>
-#include <SALOME_ListIteratorOfListIO.hxx>
+#include <SALOME_ListIO.hxx>
// Qt includes
#include <QGridLayout>
#include <QMessageBox>
GEOMToolsGUI_ReduceStudyDlg::GEOMToolsGUI_ReduceStudyDlg( QWidget* parent )
-:QDialog( parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint ),
-myDisplayer(NULL)
+:QDialog( parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint )
{
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
myVisible = QIcon( resMgr->loadPixmap( "SUIT", tr( "ICON_DATAOBJ_VISIBLE" ) ) );
myApp = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
if ( !myApp ) return;
- SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( myApp->activeStudy() );
- myStudy = dynamic_cast<SalomeApp_Study*>( myApp->activeStudy() )->studyDS();
- myDisplayer = GEOM_Displayer( study );
+
+ myDisplayer = GEOM_Displayer();
setWindowTitle( tr( "GEOM_REDUCE_STUDY_TITLE" ) );
setAttribute(Qt::WA_DeleteOnClose);
GEOM::string_array_var subObjects = new GEOM::string_array();
GEOM::string_array_var otherObjects = new GEOM::string_array();
- GeometryGUI::GetGeomGen()->GetEntriesToReduceStudy( GeometryGUI::ClientStudyToStudy( myStudy ),
- keptObjects, parentsObjects,
- subObjects, otherObjects );
+ GeometryGUI::GetGeomGen()->GetEntriesToReduceStudy( keptObjects, parentsObjects,
+ subObjects, otherObjects );
- for ( int i = 0; i < keptObjects->length(); i++ )
+ for ( unsigned long i = 0; i < keptObjects->length(); i++ )
myKeptObjects.insert( keptObjects[i].in() );
- for( int i = 0; i< otherObjects->length(); i++ )
+ for( unsigned long i = 0; i< otherObjects->length(); i++ )
myRemovedObjects.insert( otherObjects[i].in() );
- for( int i = 0; i< parentsObjects->length(); i++ )
+ for( unsigned long i = 0; i< parentsObjects->length(); i++ )
myListParents.insert( parentsObjects[i].in() );
- for( int i = 0; i< subObjects->length(); i++ )
+ for( unsigned long i = 0; i< subObjects->length(); i++ )
myListSubObjects.insert( subObjects[i].in() );
update();
QTreeWidgetItem * headerItem = new QTreeWidgetItem( columnNames );
theTreeWidget->setHeaderItem ( headerItem );
theTreeWidget->header()->moveSection( 1, 0 );
- theTreeWidget->header()->setClickable( true );
- theTreeWidget->header()->setMovable( false );
- theTreeWidget->header()->setResizeMode( 1, QHeaderView::ResizeToContents );
+ theTreeWidget->header()->setSectionsClickable( true );
+ theTreeWidget->header()->setSectionsMovable( false );
+ theTreeWidget->header()->setSectionResizeMode( 1, QHeaderView::ResizeToContents );
+
theTreeWidget->setSelectionMode( QAbstractItemView::ExtendedSelection );
}
std::set<std::string>::iterator it;
for( it = theObjects.begin(); it != theObjects.end(); ++it ) {
std::string objectEntry = *it;
- GEOM::GEOM_BaseObject_var GeomBaseObject = GeometryGUI::GetGeomGen()->GetObject( myStudy->StudyId(), objectEntry.c_str() );
+ GEOM::GEOM_BaseObject_var GeomBaseObject = GeometryGUI::GetGeomGen()->GetObject( objectEntry.c_str() );
GEOM::GEOM_Object_var GeomObject = GEOM::GEOM_Object::_narrow( GeomBaseObject );
QString studyEntry = GeomBaseObject->GetStudyEntry();
if( GeomObject->_is_nil() || studyEntry.isEmpty() || !isObjectDrawable( studyEntry.toStdString() ) )
{
GEOMToolsGUI_TreeWidgetItem* item;
if( !theObject->IsMainShape() ) {
- GEOMToolsGUI_TreeWidgetItem* parentItem = addSubObject( theWidget, theObjects, theObject->GetMainShape() );
+ GEOM::GEOM_Object_var aMainShape = theObject->GetMainShape();
+ if ( CORBA::is_nil( aMainShape ) )
+ return NULL;
+ GEOMToolsGUI_TreeWidgetItem* parentItem = addSubObject( theWidget, theObjects, aMainShape );
item = findObjectInTree( theWidget, theObject );
if( !item )
item = new GEOMToolsGUI_TreeWidgetItem( parentItem, QStringList() << theObject->GetName(), theObject->GetStudyEntry() );
QTreeWidgetItemIterator it( theWidget );
while(*it) {
GEOMToolsGUI_TreeWidgetItem* item = dynamic_cast<GEOMToolsGUI_TreeWidgetItem*>(*it);
- const char* entry = item->getStudyEntry();
+ //const char* entry = item->getStudyEntry();
if( item->flags() & Qt::ItemIsSelectable )
if( !item->isVisible() )
isInvisible = true;
//=================================================================================
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;
- GEOM::GEOM_BaseObject_var GeomBaseObject = GeometryGUI::GetGeomGen()->GetObject( myStudy->StudyId(),
- objectEntry.c_str() );
+ GEOM::GEOM_BaseObject_var GeomBaseObject = GeometryGUI::GetGeomGen()->GetObject( objectEntry.c_str() );
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);
- for ( int i = 0; i < vso.size(); i++ ) {
+ std::vector< _PTR(SObject) > vso = aStudy->FindDependances(obj);
+ for ( int i = 0; i < (int)vso.size(); i++ ) {
_PTR(SObject) refObj = vso[i];
aDrw = aStudyBuilder->FindOrCreateAttribute( refObj, "AttributeDrawable" );
aDrw->SetDrawable( false );
std::set<std::string>::iterator it;
for( it = theObjects.begin(); it != theObjects.end(); ++it ) {
std::string objectEntry = *it;
- GEOM::GEOM_BaseObject_var GeomBaseObject = GeometryGUI::GetGeomGen()->GetObject( myStudy->StudyId(),
- objectEntry.c_str() );
+ GEOM::GEOM_BaseObject_var GeomBaseObject = GeometryGUI::GetGeomGen()->GetObject( objectEntry.c_str() );
std::string studyEntry = GeomBaseObject->GetStudyEntry();
if ( studyEntry == "" )
GeometryGUI::GetGeomGen()->RemoveObject( GeomBaseObject );
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->removeObjectFromAll(obj->GetID().c_str());
+ appStudy->removeObjectProperties(obj->GetID().c_str());
// remove references to this object
appStudy->deleteReferencesTo( obj );
// remove objects from study
{
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;
}
if( myGroupIntermediates->checkedId() == 2 ) { // remove
if( !myCBSoftRemoval->isChecked() &&
- SUIT_MessageBox::question( this,
- tr( "GEOM_WRN_WARNING" ),
- tr( "GEOM_REDUCE_STUDY_WARNING_DELETE" ),
- QMessageBox::Yes | QMessageBox::No,
- QMessageBox::Yes ) == QMessageBox::No ) {
+ SUIT_MessageBox::question( this,
+ tr( "GEOM_WRN_WARNING" ),
+ tr( "GEOM_REDUCE_STUDY_WARNING_DELETE" ),
+ QMessageBox::Yes | QMessageBox::No,
+ QMessageBox::Yes ) == QMessageBox::No ) {
return;
}
for( iter = myListParents.begin(); iter != myListParents.end(); ++iter )
GEOMToolsGUI_TreeWidgetItem::GEOMToolsGUI_TreeWidgetItem( QTreeWidget* view, const QStringList &strings,
char* studyEntry, int type )
:QTreeWidgetItem( view, strings, type ),
- myStudyEntry( studyEntry ),
- myVisible( false )
+ myVisible( false ),
+ myStudyEntry( studyEntry )
{
}
GEOMToolsGUI_TreeWidgetItem::GEOMToolsGUI_TreeWidgetItem( QTreeWidgetItem* parent, const QStringList &strings,
char* studyEntry, int type )
:QTreeWidgetItem( parent, strings, type ),
- myStudyEntry( studyEntry ),
- myVisible( false )
+ myVisible( false ),
+ myStudyEntry( studyEntry )
{
}