From: mpa Date: Fri, 20 Jun 2014 13:23:50 +0000 (+0400) Subject: clean programming code X-Git-Tag: V7_5_0a1~50^2~8 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=caeeba82b51dd5dc08ff22575ac8115eaa72814c;p=modules%2Fgeom.git clean programming code --- diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_ReduceStudyDlg.cxx b/src/GEOMToolsGUI/GEOMToolsGUI_ReduceStudyDlg.cxx index aa9099a79..f7cd041d9 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI_ReduceStudyDlg.cxx +++ b/src/GEOMToolsGUI/GEOMToolsGUI_ReduceStudyDlg.cxx @@ -55,8 +55,6 @@ GEOMToolsGUI_ReduceStudyDlg::GEOMToolsGUI_ReduceStudyDlg( QWidget* parent ) :QDialog( parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint ), myDisplayer(NULL) { - setAttribute(Qt::WA_DeleteOnClose); - SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); myVisible = QIcon( resMgr->loadPixmap( "SUIT", tr( "ICON_DATAOBJ_VISIBLE" ) ) ); myInvisible = QIcon( resMgr->loadPixmap( "SUIT", tr( "ICON_DATAOBJ_INVISIBLE" ) ) ); @@ -68,6 +66,7 @@ myDisplayer(NULL) myDisplayer = GEOM_Displayer( study ); setWindowTitle( tr( "GEOM_REDUCE_STUDY_TITLE" ) ); + setAttribute(Qt::WA_DeleteOnClose); QGridLayout* topLayout = new QGridLayout( this ); topLayout->setMargin( 11 ); topLayout->setSpacing( 6 ); @@ -135,11 +134,11 @@ myDisplayer(NULL) connect( myGroupSubObjects, SIGNAL( buttonClicked( int ) ), this, SLOT( update() ) ); connect( buttonOk, SIGNAL( clicked() ), this, SLOT( clickOnOk() ) ); - connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( clickOnCancel() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( clickOnHelp() ) ); - connect( myApp->selectionMgr(), - SIGNAL( currentSelectionChanged() ), this, SLOT( selectionChanged() ) ); + connect( myApp->selectionMgr(), SIGNAL( currentSelectionChanged() ), + this, SLOT( selectionChanged() ) ); init( getSelectedObjects() ); } @@ -160,59 +159,56 @@ void GEOMToolsGUI_ReduceStudyDlg::init( const std::set& theObjectEn myMainEntries = theObjectEntries; - std::cout << "\n\n\n myMainEntries = " << myMainEntries.size() << std::endl; - - GEOM::string_array_var selectedObjects = new GEOM::string_array(); + GEOM::string_array_var keptObjects = new GEOM::string_array(); int It = 0; - selectedObjects->length( theObjectEntries.size() ); + keptObjects->length( theObjectEntries.size() ); std::set::iterator iter; for( iter=theObjectEntries.begin(); iter!=theObjectEntries.end(); ++iter, It++ ) - selectedObjects[ It ] = (*iter).c_str(); + keptObjects[ It ] = (*iter).c_str(); GEOM::string_array_var parentsObjects = new GEOM::string_array(); GEOM::string_array_var subObjects = new GEOM::string_array(); - GEOM::string_array_var oters = new GEOM::string_array(); - - -////// PUT ALGORITHM HERE - GeometryGUI::GetGeomGen()->GetEntriesToCleanStudy( myStudy, selectedObjects, - parentsObjects, subObjects, oters ); + GEOM::string_array_var otherObjects = new GEOM::string_array(); - for ( int i = 0; i < selectedObjects->length(); i++ ) - myKeptObjects.insert( selectedObjects[i].in() ); + GeometryGUI::GetGeomGen()->GetEntriesToCleanStudy( myStudy, keptObjects, parentsObjects, + subObjects, otherObjects ); + for ( int i = 0; i < keptObjects->length(); i++ ) + myKeptObjects.insert( keptObjects[i].in() ); + for( int i = 0; i< otherObjects->length(); i++ ) + myRemovedObjects.insert( otherObjects[i].in() ); for( int i = 0; i< parentsObjects->length(); i++ ) myListParents.insert( parentsObjects[i].in() ); - for( int i = 0; i< subObjects->length(); i++ ) myListSubObjects.insert( subObjects[i].in() ); - for( int i = 0; i< oters->length(); i++ ) - myRemovedObjects.insert( oters[i].in() ); - -// myParents.insert( "0:1:21" ); -// myParents.insert( "0:1:17" ); -// myParents.insert( "0:1:20" ); -// myParents.insert( "0:1:13" ); -// myParents.insert( "0:1:12" ); -// -// myListSubObjects.insert( "0:1:24" ); -// myListSubObjects.insert( "0:1:28" ); -// myListSubObjects.insert( "0:1:29" ); -// myListSubObjects.insert( "0:1:34" ); -// -// myOthers.insert( "0:1:35" ); -// myOthers.insert( "0:1:36" ); -// myOthers.insert( "0:1:37" ); -// myOthers.insert( "0:1:38" ); -// myOthers.insert( "0:1:39" ); - update(); checkVisibleIcon( myTreeKeptObjects ); checkVisibleIcon( myTreeRemoveObjects ); } +std::set GEOMToolsGUI_ReduceStudyDlg::getSelectedObjects() const +{ + std::set objects; + + SALOME_ListIO selected; + myApp->selectionMgr()->selectedObjects( selected ); + + for( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) { + Handle( SALOME_InteractiveObject ) io = It.Value(); + if( !io->hasEntry() ) + continue; + GEOM::GEOM_Object_var geomObject = GEOM::GEOM_Object::_nil(); + geomObject = GEOMBase::ConvertIOinGEOMObject( io ); + if( geomObject->_is_nil() ) + continue; + QString entry = geomObject->GetEntry(); + objects.insert( entry.toStdString().c_str() ); + } + return objects; +} + void GEOMToolsGUI_ReduceStudyDlg::createTreeWidget( QTreeWidget* theTreeWidget ) { theTreeWidget->setColumnCount( 2 ); @@ -251,14 +247,177 @@ QGroupBox* GEOMToolsGUI_ReduceStudyDlg::createButtonGroup( QButtonGroup* theButt return groupObjects; } -void GEOMToolsGUI_ReduceStudyDlg::update() +void GEOMToolsGUI_ReduceStudyDlg::addObjectsToTree( QTreeWidget* theWidget, std::set& theObjects ) +{ + std::set::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_Object_var GeomObject = GEOM::GEOM_Object::_narrow( GeomBaseObject ); + QString studyEntry = GeomBaseObject->GetStudyEntry(); + if( GeomObject->_is_nil() || studyEntry.isEmpty() ) + continue; + addSubObject( theWidget, theObjects, GeomObject ); + } +} + +GEOMToolsGUI_TreeWidgetItem* GEOMToolsGUI_ReduceStudyDlg::addSubObject( QTreeWidget* theWidget, + std::set& theObjects, + GEOM::GEOM_Object_var theObject ) +{ + GEOMToolsGUI_TreeWidgetItem* item; + if( !theObject->IsMainShape() ) { + GEOMToolsGUI_TreeWidgetItem* parentItem = addSubObject( theWidget, theObjects, theObject->GetMainShape() ); + item = findObjectInTree( theWidget, theObject ); + if( !item ) + item = new GEOMToolsGUI_TreeWidgetItem( parentItem, QStringList() << theObject->GetName(), theObject->GetStudyEntry() ); + } + else { + item = findObjectInTree( theWidget, theObject ); + if( !item ) + item = new GEOMToolsGUI_TreeWidgetItem( theWidget, QStringList() << theObject->GetName(), theObject->GetStudyEntry() ); + } + + bool isDisplayed = false; + if( theObjects.find( theObject->GetEntry() ) != theObjects.end() ) { + isDisplayed = myDisplayer.IsDisplayed( theObject->GetStudyEntry() ); + if ( isDisplayed ) + item->setVisible( true, myVisible ); + else + item->setVisible( false, myInvisible ); + + if( myMainEntries.find( theObject->GetEntry() ) != myMainEntries.end() ) { + QFont Textfont = item->font(0); + Textfont.setBold( true ); + item->setFont( 0, Textfont ); + } + } + else { + item->setFlags( item->flags() & ~Qt::ItemIsSelectable ); + item->setTextColor( 0, QColor( 150, 150, 150 ) ); + } + return item; +} + +GEOMToolsGUI_TreeWidgetItem* GEOMToolsGUI_ReduceStudyDlg::findObjectInTree( QTreeWidget* theWidget, GEOM::GEOM_Object_var theObject ) +{ + QTreeWidgetItemIterator it( theWidget ); + while(*it) { + GEOMToolsGUI_TreeWidgetItem* item = dynamic_cast(*it); + if( QString( item->getStudyEntry() ) == QString( theObject->GetStudyEntry() ) ) + return item; + ++it; + } + return NULL; +} + +void GEOMToolsGUI_ReduceStudyDlg::checkVisibleIcon( QTreeWidget* theWidget ) +{ + bool isInvisible = false; + QTreeWidgetItemIterator it( theWidget ); + while(*it) { + GEOMToolsGUI_TreeWidgetItem* item = dynamic_cast(*it); + const char* entry = item->getStudyEntry(); + if( item->flags() & Qt::ItemIsSelectable ) + if( !item->isVisible() ) + isInvisible = true; + ++it; + } + + if( isInvisible ) { + theWidget->headerItem()->setIcon( 1, myInvisible ); + myMapTreeSelectAll[ theWidget ] = false; + } + else { + theWidget->headerItem()->setIcon( 1, myVisible ); + myMapTreeSelectAll[ theWidget ] = true; + } +} + +void GEOMToolsGUI_ReduceStudyDlg::unpublishObjects( std::set& theObjects ) +{ + +} + +void GEOMToolsGUI_ReduceStudyDlg::removeObjects( std::set& theObjects ) +{ + +} + +//================================================================================= +// function : onItemClicked() +// purpose : Called then treeItem clicked +//================================================================================= +void GEOMToolsGUI_ReduceStudyDlg::onItemClicked( QTreeWidgetItem* theItem, int theColumn ) +{ + if( theColumn != 1 || !( theItem->flags() & Qt::ItemIsSelectable ) ) + return; + + GEOMToolsGUI_TreeWidgetItem* item = dynamic_cast( theItem ); + + const char* entry = item->getStudyEntry(); + Handle(SALOME_InteractiveObject) io = new SALOME_InteractiveObject( entry, "GEOM", "TEMP_IO" ); + if( myDisplayer.IsDisplayed( entry ) ) { + item->setVisible( false, myInvisible ); + myDisplayer.Erase( io ); + } + else { + item->setVisible( true, myVisible ); + myDisplayer.Display( io ); + } + myDisplayer.UpdateViewer(); + checkVisibleIcon( item->treeWidget() ); +} + +void GEOMToolsGUI_ReduceStudyDlg::onHeaderClicked( int theColumn ) { + if( theColumn != 1 ) + return; + QTreeWidget* treeWidget = dynamic_cast(sender()->parent()); + if( myMapTreeSelectAll[ treeWidget ] ) { + myMapTreeSelectAll[ treeWidget ] = false; + treeWidget->headerItem()->setIcon( 1, myInvisible ); + QTreeWidgetItemIterator it( treeWidget ); + while(*it) { + GEOMToolsGUI_TreeWidgetItem* item = dynamic_cast(*it); + if( ( item->flags() & Qt::ItemIsSelectable ) && item->isVisible() ) { + const char* entry = item->getStudyEntry(); + item->setVisible( false, myInvisible ); + myDisplayer.Erase( new SALOME_InteractiveObject( entry, "GEOM", "TEMP_IO" ) ); + } + ++it; + } + } + else { + myMapTreeSelectAll[ treeWidget ] = true; + treeWidget->headerItem()->setIcon( 1, myVisible ); + QTreeWidgetItemIterator it( treeWidget ); + while(*it) { + GEOMToolsGUI_TreeWidgetItem* item = dynamic_cast(*it); + if( ( item->flags() & Qt::ItemIsSelectable ) && !item->isVisible() ) { + const char* entry = item->getStudyEntry(); + item->setVisible( true, myVisible ); + myDisplayer.Display( new SALOME_InteractiveObject( entry, "GEOM", "TEMP_IO" ) ); + } + ++it; + } + } + myDisplayer.UpdateViewer(); +} + +void GEOMToolsGUI_ReduceStudyDlg::selectionChanged() +{ + init( getSelectedObjects() ); +} + +void GEOMToolsGUI_ReduceStudyDlg::update() +{ myTreeKeptObjects->clear(); myTreeRemoveObjects->clear(); - std::set keptObjects(myKeptObjects); - std::set removeObjects(myRemovedObjects); + std::set keptObjects( myKeptObjects ); + std::set removeObjects( myRemovedObjects ); // Intermediate objects if( myGroupIntermediates->checkedId() == 2 ) { // remove @@ -284,66 +443,54 @@ void GEOMToolsGUI_ReduceStudyDlg::update() keptObjects.insert( *iter ); } - std::cout<<"\n\n\n Objects to be kept: "; - std::set::iterator it_kept; - for ( it_kept=keptObjects.begin(); it_kept!=keptObjects.end(); ++it_kept) - std::cout << ", " << *it_kept; - std::cout << std::endl; - - std::cout<<"\n\n\n Objects to be remove: "; - std::set::iterator it_remove; - for ( it_remove=removeObjects.begin(); it_remove!=removeObjects.end(); ++it_remove) - std::cout << ", " << *it_remove; - std::cout << std::endl; - - sortObjects( myTreeKeptObjects, keptObjects ); - sortObjects( myTreeRemoveObjects, removeObjects ); + addObjectsToTree( myTreeKeptObjects, keptObjects ); + addObjectsToTree( myTreeRemoveObjects, removeObjects ); myTreeKeptObjects->collapseAll(); myTreeRemoveObjects->collapseAll(); } -void GEOMToolsGUI_ReduceStudyDlg::selectionChanged() -{ - init( getSelectedObjects() ); -} - void GEOMToolsGUI_ReduceStudyDlg::clickOnOk() { + std::set objectsToBeRemoved = myRemovedObjects; + std::set objectsToBeUnpublished; - std::set ObjectsToBeRemove = myRemovedObjects; - std::set ObjectsToBeUnpublish; + std::set::iterator iter; + if( myGroupIntermediates->checkedId() == 1 ) { // unpublish + for( iter = myListParents.begin(); iter != myListParents.end(); ++iter ) + objectsToBeUnpublished.insert( *iter ); + } + if( myGroupIntermediates->checkedId() == 2 ) { // remove + for( iter = myListParents.begin(); iter != myListParents.end(); ++iter ) + objectsToBeRemoved.insert( *iter ); + } - if( myGroupIntermediates->checkedId() == 2 ) { - std::set::iterator iter; - for( iter=myListParents.begin(); iter!=myListParents.end(); ++iter) - ObjectsToBeRemove.insert( *iter ); + if( myGroupSubObjects->checkedId() == 1 ) { // unpublish + for( iter = myListSubObjects.begin(); iter != myListSubObjects.end(); ++iter ) + objectsToBeUnpublished.insert( *iter ); } - else if( myGroupIntermediates->checkedId() == 1 ) { - std::set::iterator iter; - for( iter=myListParents.begin(); iter!=myListParents.end(); ++iter) - ObjectsToBeUnpublish.insert( *iter ); + else if( myGroupSubObjects->checkedId() == 2 ) { // remove + for( iter = myListSubObjects.begin(); iter != myListSubObjects.end(); ++iter ) + objectsToBeRemoved.insert( *iter ); } - if( myGroupSubObjects->checkedId() == 2 ) { - std::set::iterator iter; - for( iter=myListSubObjects.begin(); iter!=myListSubObjects.end(); ++iter) - ObjectsToBeRemove.insert( *iter ); + if( myCBSoftRemoval->isChecked() ) { + for( iter = objectsToBeRemoved.begin(); iter != objectsToBeRemoved.end(); ++iter ) + objectsToBeUnpublished.insert( *iter ); + unpublishObjects( objectsToBeUnpublished ); } - else if( myGroupSubObjects->checkedId() == 1 ) { - std::set::iterator iter; - for( iter=myListSubObjects.begin(); iter!=myListSubObjects.end(); ++iter) - ObjectsToBeUnpublish.insert( *iter ); + else { + unpublishObjects( objectsToBeUnpublished ); + removeObjects( objectsToBeRemoved ); } - unpublishObjects( ObjectsToBeUnpublish ); - removeObjects( ObjectsToBeRemove ); + accept(); // std::cout<< "\n\n REMOVE:" << std::endl; // std::set::iterator it; -// for( it = ObjectsToBeRemove.begin(); it != ObjectsToBeRemove.end(); ++it ) +// for( it = objectsToBeRemoved.begin(); it != objectsToBeRemoved.end(); ++it ) // std::cout <<" " << (*it) << std::endl; // // SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); @@ -428,8 +575,6 @@ void GEOMToolsGUI_ReduceStudyDlg::clickOnOk() // aSelMgr->setSelectedObjects(aSelList); // GEOMToolsGUI::OnUnpublishObject(); - accept(); - // if( myCBRemoveEmptyFolder->isChecked() ) { @@ -497,213 +642,26 @@ void GEOMToolsGUI_ReduceStudyDlg::clickOnOk() // } //} - -void GEOMToolsGUI_ReduceStudyDlg::unpublishObjects( std::set& theObjects ) -{ - -} - -void GEOMToolsGUI_ReduceStudyDlg::removeObjects( std::set& theObjects ) -{ - -} - - -void GEOMToolsGUI_ReduceStudyDlg::clickOnCancel() -{ - close(); -} void GEOMToolsGUI_ReduceStudyDlg::clickOnHelp() { } -//================================================================================= -// function : onItemClicked() -// purpose : Called then treeItem clicked -//================================================================================= -void GEOMToolsGUI_ReduceStudyDlg::onItemClicked( QTreeWidgetItem* theItem, int theColumn ) -{ - if( theColumn != 1 || !( theItem->flags() & Qt::ItemIsSelectable ) ) - return; - - GEOMToolsGUI_TreeWidgetItem* item = dynamic_cast( theItem ); - - const char* entry = item->getStudyEntry(); - Handle(SALOME_InteractiveObject) io = new SALOME_InteractiveObject( entry, "GEOM", "TEMP_IO" ); - if( myDisplayer.IsDisplayed( entry ) ) { - item->setVisible( false, myInvisible ); - myDisplayer.Erase( io ); - } - else { - item->setVisible( true, myVisible ); - myDisplayer.Display( io ); - } - myDisplayer.UpdateViewer(); - checkVisibleIcon( item->treeWidget() ); -} - -void GEOMToolsGUI_ReduceStudyDlg::onHeaderClicked( int theColumn ) -{ - if( theColumn != 1 ) - return; - - QTreeWidget* treeData = dynamic_cast(sender()->parent()); - if( myMapTreeSelectAll[ treeData ] ) { - myMapTreeSelectAll[ treeData ] = false; - treeData->headerItem()->setIcon( 1, myInvisible ); - QTreeWidgetItemIterator it( treeData ); - while(*it) { - GEOMToolsGUI_TreeWidgetItem* item = dynamic_cast(*it); - if( ( item->flags() & Qt::ItemIsSelectable ) && item->isVisible() ) { - const char* entry = item->getStudyEntry(); - item->setVisible( false, myInvisible ); - myDisplayer.Erase( new SALOME_InteractiveObject( entry, "GEOM", "TEMP_IO" ) ); - } - ++it; - } - } - else { - myMapTreeSelectAll[ treeData ] = true; - treeData->headerItem()->setIcon( 1, myVisible ); - QTreeWidgetItemIterator it( treeData ); - while(*it) { - GEOMToolsGUI_TreeWidgetItem* item = dynamic_cast(*it); - if( ( item->flags() & Qt::ItemIsSelectable ) && !item->isVisible() ) { - const char* entry = item->getStudyEntry(); - item->setVisible( true, myVisible ); - myDisplayer.Display( new SALOME_InteractiveObject( entry, "GEOM", "TEMP_IO" ) ); - } - ++it; - } - } - myDisplayer.UpdateViewer(); -} - -void GEOMToolsGUI_ReduceStudyDlg::checkVisibleIcon( QTreeWidget* theWidget ) -{ - bool isInvisible = false; - QTreeWidgetItemIterator it( theWidget ); - while(*it) { - GEOMToolsGUI_TreeWidgetItem* item = dynamic_cast(*it); - const char* entry = item->getStudyEntry(); - if( item->flags() & Qt::ItemIsSelectable ) - if( !item->isVisible() ) - isInvisible = true; - ++it; - } - - if( isInvisible ) { - theWidget->headerItem()->setIcon( 1, myInvisible ); - myMapTreeSelectAll[ theWidget ] = false; - } - else { - theWidget->headerItem()->setIcon( 1, myVisible ); - myMapTreeSelectAll[ theWidget ] = true; - } -} - -void GEOMToolsGUI_ReduceStudyDlg::sortObjects( QTreeWidget* theWidget, std::set& theObjects ) -{ - std::set::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_Object_var GeomObject = GEOM::GEOM_Object::_narrow( GeomBaseObject ); - QString studyEntry = GeomBaseObject->GetStudyEntry(); - if( GeomObject->_is_nil() || studyEntry.isEmpty() ) - continue; - addSubObject( theWidget, theObjects, GeomObject ); - } -} - -GEOMToolsGUI_TreeWidgetItem* GEOMToolsGUI_ReduceStudyDlg::addSubObject( QTreeWidget* theWidget, std::set& theObjects, GEOM::GEOM_Object_var theObject ) -{ - GEOMToolsGUI_TreeWidgetItem* item; - if( !theObject->IsMainShape() ) { - GEOMToolsGUI_TreeWidgetItem* parentItem = addSubObject( theWidget, theObjects, theObject->GetMainShape() ); - item = findObjectInTree( theWidget, theObject ); - if( !item ) - item = new GEOMToolsGUI_TreeWidgetItem( parentItem, QStringList() << theObject->GetName(), theObject->GetStudyEntry(), false ); - } - else { - item = findObjectInTree( theWidget, theObject ); - if( !item ) - item = new GEOMToolsGUI_TreeWidgetItem( theWidget, QStringList() << theObject->GetName(), theObject->GetStudyEntry(), false ); - } - - bool isDisplayed = false; - if( theObjects.find( theObject->GetEntry() ) != theObjects.end() ) { - isDisplayed = myDisplayer.IsDisplayed( theObject->GetStudyEntry() ); - if ( isDisplayed ) { - item->setVisible( true, myVisible ); - } - else { - item->setVisible( false, myInvisible ); - } - if( myMainEntries.find( theObject->GetEntry() ) != myMainEntries.end() ) { - QFont Textfont = item->font(0); - Textfont.setBold( true ); - item->setFont( 0, Textfont ); - } - - } - else { - item->setFlags( item->flags() & ~Qt::ItemIsSelectable ); - item->setTextColor( 0, QColor( 150, 150, 150 ) ); - } - - return item; -} - -GEOMToolsGUI_TreeWidgetItem* GEOMToolsGUI_ReduceStudyDlg::findObjectInTree( QTreeWidget* theWidget, GEOM::GEOM_Object_var theObject ) -{ - QTreeWidgetItemIterator it( theWidget ); - while(*it) { - GEOMToolsGUI_TreeWidgetItem* item = dynamic_cast(*it); - if( QString( item->getStudyEntry() ) == QString( theObject->GetStudyEntry() ) ) - return item; - ++it; - } - return NULL; -} - -std::set GEOMToolsGUI_ReduceStudyDlg::getSelectedObjects() const -{ - std::set objects; - - SALOME_ListIO selected; - myApp->selectionMgr()->selectedObjects( selected ); - for( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) { - Handle( SALOME_InteractiveObject ) io = It.Value(); - if( !io->hasEntry() ) - continue; - GEOM::GEOM_Object_var geomObject = GEOM::GEOM_Object::_nil(); - geomObject = GEOMBase::ConvertIOinGEOMObject( io ); - if( geomObject->_is_nil() ) - continue; - QString entry = geomObject->GetEntry(); - objects.insert( entry.toStdString().c_str() ); - } - return objects; -} GEOMToolsGUI_TreeWidgetItem::GEOMToolsGUI_TreeWidgetItem( QTreeWidget* view, const QStringList &strings, - char* studyEntry, bool visible, int type ) + char* studyEntry, int type ) :QTreeWidgetItem( view, strings, type ), myStudyEntry( studyEntry ), - myVisible( visible ) + myVisible( false ) { - } GEOMToolsGUI_TreeWidgetItem::GEOMToolsGUI_TreeWidgetItem( QTreeWidgetItem* parent, const QStringList &strings, - char* studyEntry, bool visible, int type ) + char* studyEntry, int type ) :QTreeWidgetItem( parent, strings, type ), myStudyEntry( studyEntry ), - myVisible( visible ) + myVisible( false ) { - } GEOMToolsGUI_TreeWidgetItem::~GEOMToolsGUI_TreeWidgetItem() diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_ReduceStudyDlg.h b/src/GEOMToolsGUI/GEOMToolsGUI_ReduceStudyDlg.h index d5b14a764..e6396cb32 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI_ReduceStudyDlg.h +++ b/src/GEOMToolsGUI/GEOMToolsGUI_ReduceStudyDlg.h @@ -37,8 +37,8 @@ class GEOMToolsGUI_TreeWidgetItem : public QTreeWidgetItem { public: - GEOMToolsGUI_TreeWidgetItem( QTreeWidget*, const QStringList&, char*, bool, int = Type ); - GEOMToolsGUI_TreeWidgetItem( QTreeWidgetItem*, const QStringList&, char*, bool, int = Type ); + GEOMToolsGUI_TreeWidgetItem( QTreeWidget*, const QStringList&, char*, int = Type ); + GEOMToolsGUI_TreeWidgetItem( QTreeWidgetItem*, const QStringList&, char*, int = Type ); ~GEOMToolsGUI_TreeWidgetItem(); bool isVisible(); @@ -47,8 +47,9 @@ public: char* getStudyEntry() const; private: - char* myStudyEntry; bool myVisible; + char* myStudyEntry; + }; class GEOMTOOLSGUI_EXPORT GEOMToolsGUI_ReduceStudyDlg : public QDialog @@ -60,57 +61,56 @@ public: ~GEOMToolsGUI_ReduceStudyDlg(); private slots: + void onItemClicked(QTreeWidgetItem*, int ); + void onHeaderClicked( int ); - void clickOnOk(); - void clickOnCancel(); - void clickOnHelp(); + void selectionChanged(); - void onItemClicked(QTreeWidgetItem*, int ); - void onHeaderClicked( int ); + void update(); - void selectionChanged(); - - void update(); + void clickOnOk(); + void clickOnHelp(); private: + void init( const std::set& theObjectEntries ); + std::set getSelectedObjects() const; + + void createTreeWidget( QTreeWidget* ); + QGroupBox* createButtonGroup( QButtonGroup* ); - void init( const std::set& theObjectEntries ); - void createTreeWidget( QTreeWidget* ); - QGroupBox* createButtonGroup( QButtonGroup* ); - void checkVisibleIcon( QTreeWidget* ); - void sortObjects( QTreeWidget*, std::set& ); - GEOMToolsGUI_TreeWidgetItem* addSubObject( QTreeWidget*, std::set&, GEOM::GEOM_Object_var ); - GEOMToolsGUI_TreeWidgetItem* findObjectInTree( QTreeWidget*, GEOM::GEOM_Object_var ); + void addObjectsToTree( QTreeWidget*, std::set& ); + GEOMToolsGUI_TreeWidgetItem* addSubObject( QTreeWidget*, std::set&, GEOM::GEOM_Object_var ); + GEOMToolsGUI_TreeWidgetItem* findObjectInTree( QTreeWidget*, GEOM::GEOM_Object_var ); - void unpublishObjects( std::set& ); - void removeObjects( std::set& ); + void checkVisibleIcon( QTreeWidget* ); - std::set getSelectedObjects() const; + void unpublishObjects( std::set& ); + void removeObjects( std::set& ); - QTreeWidget* myTreeKeptObjects; - QTreeWidget* myTreeRemoveObjects; + QTreeWidget* myTreeKeptObjects; + QTreeWidget* myTreeRemoveObjects; + std::map myMapTreeSelectAll; - QButtonGroup* myGroupIntermediates; - QButtonGroup* myGroupSubObjects; + QButtonGroup* myGroupIntermediates; + QButtonGroup* myGroupSubObjects; - QCheckBox* myCBRemoveEmptyFolder; - QCheckBox* myCBSoftRemoval; + QCheckBox* myCBRemoveEmptyFolder; + QCheckBox* myCBSoftRemoval; - std::set myMainEntries; + std::set myMainEntries; - QIcon myVisible; - QIcon myInvisible; + std::set myKeptObjects; + std::set myRemovedObjects; + std::set myListParents; + std::set myListSubObjects; - GEOM_Displayer myDisplayer; - SalomeApp_Application* myApp; - SALOMEDS::Study_var myStudy; + QIcon myVisible; + QIcon myInvisible; - std::set myKeptObjects; - std::set myRemovedObjects; - std::set myListParents; - std::set myListSubObjects; + GEOM_Displayer myDisplayer; + SalomeApp_Application* myApp; + SALOMEDS::Study_var myStudy; - std::map myMapTreeSelectAll; }; #endif