-// Copyright (C) 2014 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2014-2022 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
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+// internal includes
#include "GEOMToolsGUI_ReduceStudyDlg.h"
-#include <QVBoxLayout>
-#include <QHBoxLayout>
-#include <QGroupBox>
-#include <QGridLayout>
-#include <QHeaderView>
-#include <QPushButton>
+// GEOM includes
+#include <GEOMBase.h>
// GUI includes
#include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h>
-#include <SalomeApp_Application.h>
-#include <SalomeApp_Study.h>
-#include <OCCViewer_ViewManager.h>
-
-// GEOM includes
-#include <SALOMEconfig.h>
-#include CORBA_CLIENT_HEADER(GEOM_Gen)
-#include <GEOMBase_Helper.h>
-
-#include <iostream>
-
-GEOMToolsGUI_TreeWidgetItem::GEOMToolsGUI_TreeWidgetItem( QTreeWidget* view, const QStringList &strings,
- char* studyEntry, bool visible, int type )
-:QTreeWidgetItem( view, strings, type ),
- myStudyEntry( studyEntry ),
- myVisible( visible )
-{
-
-}
-
-GEOMToolsGUI_TreeWidgetItem::GEOMToolsGUI_TreeWidgetItem( QTreeWidgetItem* parent, const QStringList &strings,
- char* studyEntry, bool visible, int type )
-:QTreeWidgetItem( parent, strings, type ),
- myStudyEntry( studyEntry ),
- myVisible( visible )
-{
-
-}
+#include <SUIT_MessageBox.h>
-GEOMToolsGUI_TreeWidgetItem::~GEOMToolsGUI_TreeWidgetItem()
-{
-}
+#include <LightApp_SelectionMgr.h>
-bool GEOMToolsGUI_TreeWidgetItem::isVisible()
-{
- return myVisible;
-}
-
-void GEOMToolsGUI_TreeWidgetItem::setVisible( bool theIsVisible, QIcon& theIcon )
-{
- myVisible = theIsVisible;
- setIcon( 1, theIcon );
-}
+#include <SalomeApp_Application.h>
+#include <SalomeApp_Study.h>
+#include <SALOME_ListIO.hxx>
-char* GEOMToolsGUI_TreeWidgetItem::getStudyEntry() const
-{
- return myStudyEntry;
-}
+// Qt includes
+#include <QGridLayout>
+#include <QPushButton>
+#include <QRadioButton>
+#include <QHeaderView>
+#include <QMessageBox>
-GEOMToolsGUI_ReduceStudyDlg::GEOMToolsGUI_ReduceStudyDlg( const GEOM::string_array& theObjectEntries, QWidget* parent )
-:QDialog( parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint ),
-mySelectAll( false ),
-myDisplayer(NULL)
+GEOMToolsGUI_ReduceStudyDlg::GEOMToolsGUI_ReduceStudyDlg( QWidget* parent )
+:QDialog( parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint )
{
- for( int i = 0; i < theObjectEntries.length(); i++ )
- myMainEntries.insert( theObjectEntries[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" );
-
- mySubObjects.insert( "0:1:24" );
- mySubObjects.insert( "0:1:28" );
- mySubObjects.insert( "0:1:29" );
- mySubObjects.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" );
-
- std::set<std::string>::iterator it;
- for ( it=myParents.begin(); it!=myParents.end(); ++it)
- std::cout << ' ' << *it;
-
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" ) ) );
- SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
- if ( !app ) return;
- SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
- int studyId = GeometryGUI::ClientStudyToStudy( study->studyDS())->StudyId();
+ myApp = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
+ if ( !myApp ) return;
- myDisplayer = GEOM_Displayer( study );
+ myDisplayer = GEOM_Displayer();
- // setModal( true );
setWindowTitle( tr( "GEOM_REDUCE_STUDY_TITLE" ) );
- setSizeGripEnabled( TRUE );
+ setAttribute(Qt::WA_DeleteOnClose);
QGridLayout* topLayout = new QGridLayout( this );
topLayout->setMargin( 11 ); topLayout->setSpacing( 6 );
+ /********************** Objects to be kept **********************/
QGroupBox* groupKeptObjects = new QGroupBox( tr( "GEOM_REDUCE_STUDY_KEPT_OBJECTS" ) );
-
- if(true) {
- myTreeKeptObjects = new QTreeWidget();
- myTreeKeptObjects->setColumnCount( 2 );
- myTreeKeptObjects->setAllColumnsShowFocus(true);
- QStringList columnNames;
- columnNames.append(tr( "GEOM_REDUCE_STUDY_NAME" ));
- columnNames.append("");
- myTreeKeptObjects->setHeaderLabels( columnNames );
- QTreeWidgetItem * headerItem = new QTreeWidgetItem( columnNames );
- myTreeKeptObjects->setHeaderItem ( headerItem );
- myTreeKeptObjects->header()->moveSection( 1, 0 );
- myTreeKeptObjects->header()->setClickable( true );
- myTreeKeptObjects->header()->setMovable( false );
- myTreeKeptObjects->header()->setResizeMode( 1, QHeaderView::ResizeToContents );
- myTreeKeptObjects->setSelectionMode( QAbstractItemView::ExtendedSelection );
-
- }
-
-// myTreeWidget->header()->setSortIndicatorShown( true );
-// myTreeWidget->header()->moveSection( 2, 0 );
-// myTreeWidget->setSortingEnabled( true );
-// myTreeWidget->setColumnWidth( 2, VISIBILITY_COLUMN_WIDTH );
-
- QLayout* layoutKeptObjects = new QGridLayout( groupKeptObjects );
+ QGridLayout* layoutKeptObjects = new QGridLayout( groupKeptObjects );
+ createTreeWidget( myTreeKeptObjects = new QTreeWidget() );
layoutKeptObjects->addWidget( myTreeKeptObjects );
+ /********************** Objects to be removed **********************/
QGroupBox* groupRemoveObjects = new QGroupBox( tr( "GEOM_REDUCE_STUDY_REMOVE_OBJECTS" ) );
-
- if(true) {
- myTreeRemoveObjects = new QTreeWidget();
- myTreeRemoveObjects->setColumnCount( 2 );
- myTreeRemoveObjects->setAllColumnsShowFocus(true);
- QStringList columnNames;
- columnNames.append(tr( "GEOM_REDUCE_STUDY_NAME" ));
- columnNames.append("");
- myTreeRemoveObjects->setHeaderLabels( columnNames );
- QTreeWidgetItem* headerItem = new QTreeWidgetItem( columnNames );
- myTreeRemoveObjects->setHeaderItem ( headerItem );
- myTreeRemoveObjects->header()->moveSection( 1, 0 );
- myTreeRemoveObjects->header()->setClickable( true );
- myTreeRemoveObjects->header()->setMovable( false );
- myTreeRemoveObjects->header()->setResizeMode( 1, QHeaderView::ResizeToContents );
- myTreeRemoveObjects->setSelectionMode( QAbstractItemView::ExtendedSelection );
- }
-
QGridLayout* layoutRemoveObjects = new QGridLayout( groupRemoveObjects );
+ createTreeWidget( myTreeRemoveObjects = new QTreeWidget() );
layoutRemoveObjects->addWidget( myTreeRemoveObjects );
+ /********************** Options **********************/
QGroupBox* groupOptions = new QGroupBox( tr( "GEOM_REDUCE_STUDY_OPTIONS" ) );
+ QVBoxLayout* layoutOptions = new QVBoxLayout( groupOptions );
+
+ // Intermediate objects
+ QGroupBox* groupIntermediates = createButtonGroup( myGroupIntermediates = new QButtonGroup() );
+ groupIntermediates->setTitle( tr( "GEOM_REDUCE_STUDY_INTERMEDIATES" ) );
- QGridLayout* layoutOptions = new QGridLayout( groupOptions );
+ // Sub-objects
+ QGroupBox* groupSubObjects = createButtonGroup( myGroupSubObjects = new QButtonGroup() );
+ groupSubObjects->setTitle( tr( "GEOM_REDUCE_STUDY_SUB_OBJECTS" ) );
- myCBUnpublishIntermediate = new QCheckBox( tr( "GEOM_REDUCE_STUDY_UNPUB_INTERMEDIATE" ) );
- myCBRemoveIntermediate = new QCheckBox( tr( "GEOM_REDUCE_STUDY_REMOVE_INTERMEDIATE" ) );
- myCBKeepSubObjects = new QCheckBox( tr( "GEOM_REDUCE_STUDY_KEEP_SUB_OBJECTS" ) );
+ // Others
myCBRemoveEmptyFolder = new QCheckBox( tr( "GEOM_REDUCE_STUDY_REMOVE_EMPTY_FOLDER" ) );
myCBRemoveEmptyFolder->setChecked( true );
myCBSoftRemoval = new QCheckBox( tr( "GEOM_REDUCE_STUDY_SOFT_REMOVAL" ) );
- layoutOptions->addWidget( myCBUnpublishIntermediate, 0, 0 );
- layoutOptions->addWidget( myCBRemoveIntermediate, 0, 1 );
- layoutOptions->addWidget( myCBKeepSubObjects, 1, 0, 1, 2 );
- layoutOptions->addWidget( myCBRemoveEmptyFolder, 2, 0, 1, 2 );
- layoutOptions->addWidget( myCBSoftRemoval, 3, 0, 1, 2 );
+ layoutOptions->addWidget( groupIntermediates );
+ layoutOptions->addWidget( groupSubObjects );
+ layoutOptions->addWidget( myCBRemoveEmptyFolder );
+ layoutOptions->addWidget( myCBSoftRemoval );
+ /********************** Buttons **********************/
QGroupBox* groupButtons = new QGroupBox();
-
QHBoxLayout* layoutButtons = new QHBoxLayout( groupButtons );
QPushButton* buttonOk = new QPushButton( tr( "GEOM_BUT_OK" ) );
topLayout->addWidget( groupOptions, 1, 0, 1, 2 );
topLayout->addWidget( groupButtons, 2, 0, 1, 2 );
-// connect( myCBUnpublishIntermediate, SIGNAL( toggled( bool ) ), this, SLOT( onUnpublishIntermediate( bool ) ) );
-// connect( myCBRemoveIntermediate, SIGNAL( toggled ( bool ) ), this, SLOT( onRemoveIntermediate( bool ) ) );
-// connect( myCBKeepSubObjects, SIGNAL( toggled ( bool ) ), this, SLOT( onKeepSubObjects( bool ) ) );
-// connect( myCBRemoveEmptyFolder, SIGNAL( toggled ( bool ) ), this, SLOT( onRemoveEmptyFolder( bool ) ) );
-// connect( myCBSoftRemoval, SIGNAL( toggled ( bool ) ), this, SLOT( onSoftRemoval( bool ) ) );
-
- connect( buttonOk, SIGNAL( clicked() ), this, SLOT( clickOnOk() ) );
- connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( clickOnCancel() ) );
- connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( clickOnHelp() ) );
-
- connect( myTreeKeptObjects, SIGNAL(itemClicked(QTreeWidgetItem*, int)), this, SLOT(onItemClicked(QTreeWidgetItem*, int)) );
- connect( myTreeRemoveObjects, SIGNAL(itemClicked(QTreeWidgetItem*, int)), this, SLOT(onItemClicked(QTreeWidgetItem*, int)) );
+ // Signals and slots connections
+ connect( myTreeKeptObjects, SIGNAL( itemClicked( QTreeWidgetItem*, int) ), this, SLOT( onItemClicked( QTreeWidgetItem*, int ) ) );
+ connect( myTreeRemoveObjects, SIGNAL( itemClicked( QTreeWidgetItem*, int) ), this, SLOT( onItemClicked( QTreeWidgetItem*, int ) ) );
connect( myTreeKeptObjects->header(), SIGNAL( sectionClicked ( int ) ), this, SLOT( onHeaderClicked( int ) ) );
connect( myTreeRemoveObjects->header(), SIGNAL( sectionClicked ( int ) ), this, SLOT( onHeaderClicked( int ) ) );
- connect( myCBKeepSubObjects, SIGNAL( toggled(bool)), this, SLOT( update() ) );
- connect( myCBRemoveIntermediate, SIGNAL( toggled(bool)), this, SLOT( update() ) );
- connect( myCBUnpublishIntermediate, SIGNAL( toggled(bool) ), this, SLOT( update() ) );
-
- update();
+ connect( myGroupIntermediates, SIGNAL( buttonClicked( int ) ), this, SLOT( update() ) );
+ connect( myGroupSubObjects, SIGNAL( buttonClicked( int ) ), this, SLOT( update() ) );
- checkVisibleIcon( myTreeKeptObjects );
- checkVisibleIcon( myTreeRemoveObjects );
+ connect( buttonOk, SIGNAL( clicked() ), this, SLOT( clickOnOk() ) );
+ connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
+ connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( clickOnHelp() ) );
+ connect( myApp->selectionMgr(), SIGNAL( currentSelectionChanged() ),
+ this, SLOT( selectionChanged() ) );
+ init( getSelectedObjects() );
}
GEOMToolsGUI_ReduceStudyDlg::~GEOMToolsGUI_ReduceStudyDlg()
// no need to delete child widgets, Qt does it all for us
}
-void GEOMToolsGUI_ReduceStudyDlg::update()
+//=================================================================================
+// function : init()
+// purpose : initialize dialog data
+//=================================================================================
+void GEOMToolsGUI_ReduceStudyDlg::init( const std::set<std::string>& theObjectEntries )
{
- myTreeKeptObjects->clear();
- myTreeRemoveObjects->clear();
-
- std::set<std::string> keptObjects(myMainEntries);
- std::set<std::string> removeObjects(myOthers);
+ myMainEntries.clear();
+
+ myKeptObjects.clear();
+ myListParents.clear();
+ myListSubObjects.clear();
+ myRemovedObjects.clear();
+
+ myMainEntries = theObjectEntries;
+
+ GEOM::string_array_var keptObjects = new GEOM::string_array();
+ int It = 0;
+ keptObjects->length( theObjectEntries.size() );
+ std::set<std::string>::iterator iter;
+ for( iter=theObjectEntries.begin(); iter!=theObjectEntries.end(); ++iter, It++ )
+ 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 otherObjects = new GEOM::string_array();
+
+ GeometryGUI::GetGeomGen()->GetEntriesToReduceStudy( keptObjects, parentsObjects,
+ subObjects, otherObjects );
+
+ for ( unsigned long i = 0; i < keptObjects->length(); i++ )
+ myKeptObjects.insert( keptObjects[i].in() );
+ for( unsigned long i = 0; i< otherObjects->length(); i++ )
+ myRemovedObjects.insert( otherObjects[i].in() );
+ for( unsigned long i = 0; i< parentsObjects->length(); i++ )
+ myListParents.insert( parentsObjects[i].in() );
+ for( unsigned long i = 0; i< subObjects->length(); i++ )
+ myListSubObjects.insert( subObjects[i].in() );
- if( myCBUnpublishIntermediate->isChecked() || myCBRemoveIntermediate->isChecked() ) {
- std::set<std::string>::iterator iter;
- for( iter=myParents.begin(); iter!=myParents.end(); ++iter)
- removeObjects.insert( *iter );
- }
- else {
- std::set<std::string>::iterator iter;
- for( iter=myParents.begin(); iter!=myParents.end(); ++iter)
- keptObjects.insert( *iter );
- }
+ update();
- if( myCBKeepSubObjects->isChecked() ) {
- std::set<std::string>::iterator iter;
- for( iter=mySubObjects.begin(); iter!=mySubObjects.end(); ++iter)
- keptObjects.insert( *iter );
- }
- else {
- std::set<std::string>::iterator iter;
- for( iter=mySubObjects.begin(); iter!=mySubObjects.end(); ++iter)
- removeObjects.insert( *iter );
- }
+ checkVisibleIcon( myTreeKeptObjects );
+ checkVisibleIcon( myTreeRemoveObjects );
+}
- std::cout<<"\n\n\n Objects to be kept: ";
- std::set<std::string>::iterator it_kept;
- for ( it_kept=keptObjects.begin(); it_kept!=keptObjects.end(); ++it_kept)
- std::cout << ", " << *it_kept;
- std::cout << std::endl;
+//=================================================================================
+// function : getSelectedObjects()
+// purpose : get selected objects in object browser
+//=================================================================================
+std::set<std::string> GEOMToolsGUI_ReduceStudyDlg::getSelectedObjects() const
+{
+ std::set<std::string> objects;
- std::cout<<"\n\n\n Objects to be remove: ";
- std::set<std::string>::iterator it_remove;
- for ( it_remove=removeObjects.begin(); it_remove!=removeObjects.end(); ++it_remove)
- std::cout << ", " << *it_remove;
- std::cout << std::endl;
+ SALOME_ListIO selected;
+ myApp->selectionMgr()->selectedObjects( selected );
- sortObjects( myTreeKeptObjects, keptObjects );
- sortObjects( myTreeRemoveObjects, removeObjects );
+ 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;
+}
- myTreeKeptObjects->update();
- myTreeKeptObjects->collapseAll();
- myTreeRemoveObjects->update();
- myTreeRemoveObjects->collapseAll();
+//=================================================================================
+// function : createTreeWidget()
+// purpose : create tree widget for unpublished or removed objects
+//=================================================================================
+void GEOMToolsGUI_ReduceStudyDlg::createTreeWidget( QTreeWidget* theTreeWidget )
+{
+ theTreeWidget->setColumnCount( 2 );
+ QStringList columnNames;
+ columnNames.append(tr( "GEOM_REDUCE_STUDY_NAME" ));
+ columnNames.append("");
+ theTreeWidget->setHeaderLabels( columnNames );
+ QTreeWidgetItem * headerItem = new QTreeWidgetItem( columnNames );
+ theTreeWidget->setHeaderItem ( headerItem );
+ theTreeWidget->header()->moveSection( 1, 0 );
+ theTreeWidget->header()->setSectionsClickable( true );
+ theTreeWidget->header()->setSectionsMovable( false );
+ theTreeWidget->header()->setSectionResizeMode( 1, QHeaderView::ResizeToContents );
+ theTreeWidget->setSelectionMode( QAbstractItemView::ExtendedSelection );
}
-void GEOMToolsGUI_ReduceStudyDlg::onUnpublishIntermediate( bool )
+//=================================================================================
+// function : createButtonGroup()
+// purpose : create button group for intermediate objects or sub-objects
+//=================================================================================
+QGroupBox* GEOMToolsGUI_ReduceStudyDlg::createButtonGroup( QButtonGroup* theButtonGroup )
{
+ QGroupBox* groupObjects = new QGroupBox();
+ QHBoxLayout* layoutObjects = new QHBoxLayout( groupObjects );
+
+ QRadioButton* buttonKeep = new QRadioButton( tr( "GEOM_REDUCE_STUDY_KEEP") );
+ theButtonGroup->addButton( buttonKeep, 0 );
+ QRadioButton* buttonUnpublish = new QRadioButton( tr( "GEOM_REDUCE_STUDY_UNPUBLISH") );
+ theButtonGroup->addButton( buttonUnpublish, 1 );
+ QRadioButton* buttonRemove = new QRadioButton( tr( "GEOM_REDUCE_STUDY_REMOVE") );
+ theButtonGroup->addButton( buttonRemove, 2 );
+
+ theButtonGroup->button( 0 )->setChecked( true );
+ theButtonGroup->setExclusive( true );
+
+ layoutObjects->addWidget( buttonKeep );
+ layoutObjects->addWidget( buttonUnpublish );
+ layoutObjects->addWidget( buttonRemove );
+ return groupObjects;
}
-void GEOMToolsGUI_ReduceStudyDlg::onRemoveIntermediate( bool theIsRemove )
+
+//=================================================================================
+// function : addObjectsToTree()
+// purpose : add the list of objects to tree
+//=================================================================================
+void GEOMToolsGUI_ReduceStudyDlg::addObjectsToTree( QTreeWidget* theWidget, std::set<std::string>& theObjects )
{
- myCBUnpublishIntermediate->setEnabled( !theIsRemove );
+ 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( 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() ) )
+ continue;
+ addSubObject( theWidget, theObjects, GeomObject );
+ }
}
-void GEOMToolsGUI_ReduceStudyDlg::onKeepSubObjects( bool )
+
+//=================================================================================
+// function : addSubObject()
+// purpose : add sub-object to parent object in the tree
+//=================================================================================
+GEOMToolsGUI_TreeWidgetItem* GEOMToolsGUI_ReduceStudyDlg::addSubObject( QTreeWidget* theWidget,
+ std::set<std::string>& theObjects,
+ GEOM::GEOM_Object_var theObject )
{
+ GEOMToolsGUI_TreeWidgetItem* item;
+ if( !theObject->IsMainShape() ) {
+ 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() );
+ }
+ 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;
}
-void GEOMToolsGUI_ReduceStudyDlg::onRemoveEmptyFolder( bool )
-{
+//=================================================================================
+// function : findObjectInTree()
+// purpose : find object in the tree
+//=================================================================================
+GEOMToolsGUI_TreeWidgetItem* GEOMToolsGUI_ReduceStudyDlg::findObjectInTree( QTreeWidget* theWidget, GEOM::GEOM_Object_var theObject )
+{
+ QTreeWidgetItemIterator it( theWidget );
+ while(*it) {
+ GEOMToolsGUI_TreeWidgetItem* item = dynamic_cast<GEOMToolsGUI_TreeWidgetItem*>(*it);
+ if( QString( item->getStudyEntry() ) == QString( theObject->GetStudyEntry() ) )
+ return item;
+ ++it;
+ }
+ return NULL;
}
-void GEOMToolsGUI_ReduceStudyDlg::onSoftRemoval( bool )
+
+//=================================================================================
+// function : checkVisibleIcon()
+// purpose : set visible or invisible icon in the header of tree
+//=================================================================================
+void GEOMToolsGUI_ReduceStudyDlg::checkVisibleIcon( QTreeWidget* theWidget )
{
+ bool isInvisible = false;
+ QTreeWidgetItemIterator it( theWidget );
+ while(*it) {
+ GEOMToolsGUI_TreeWidgetItem* item = dynamic_cast<GEOMToolsGUI_TreeWidgetItem*>(*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::clickOnOk()
+//=================================================================================
+// function : isObjectDrawable()
+// purpose : return true if object is drawable, and false if object is hidden in the study
+//=================================================================================
+bool GEOMToolsGUI_ReduceStudyDlg::isObjectDrawable( std::string theStudyEntry )
{
-// if( myCBRemoveEmptyFolder->isChecked() ) {
-//
-// SALOME_ListIO selected;
-// SalomeApp_Application* app =
-// dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
-// if ( !app )
-// return;
-//
-// LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
-// SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
-// if ( !aSelMgr || !appStudy )
-// return;
-//
-// // get selection
-// aSelMgr->selectedObjects( selected, "ObjectBrowser", false );
-// if ( selected.IsEmpty() )
-// return;
-//
-// _PTR(Study) aStudy = appStudy->studyDS();
-// _PTR(UseCaseBuilder) aUseCaseBuilder = aStudy->GetUseCaseBuilder();
-//
-// // ... and then delete all folders
-// 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 );
-// // remove objects from study
-// aStudyBuilder->RemoveObjectWithChildren( obj );
-// // remove object from use case tree
-// aUseCaseBuilder->Remove( obj );
-// }
-// }
+ _PTR(Study) aStudy = SalomeApp_Application::getStudy();
+ _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
+ //If object hasn't "AttributeDrawable" => it visible
+ bool isDrawable = true;
+ _PTR(SObject) SO ( aStudy->FindObjectID( theStudyEntry ) );
+ _PTR(GenericAttribute) anAttr;
+ if ( SO && SO->FindAttribute( anAttr, "AttributeDrawable" ) ) {
+ _PTR(AttributeDrawable) aDrw (anAttr);
+ isDrawable = aDrw->IsDrawable();
+ }
+ return isDrawable;
}
-////=======================================================================
-//// function : getGeomChildrenAndFolders
-//// purpose : Get direct (1-level) GEOM objects under each folder, sub-folder, etc. and these folders itself
-////=======================================================================
-//static void getGeomChildrenAndFolders( _PTR(SObject) theSO,
-// QMap<QString,QString>& geomObjList,
-// QMap<QString,QString>& folderList ) {
-// if ( !theSO ) return;
-// _PTR(Study) aStudy = theSO->GetStudy();
-// if ( !aStudy ) return;
-// _PTR(UseCaseBuilder) aUseCaseBuilder = aStudy->GetUseCaseBuilder();
-//
-// bool isFolder = false;
-// _PTR(GenericAttribute) anAttr;
-// if ( theSO->FindAttribute(anAttr, "AttributeLocalID") ) {
-// _PTR(AttributeLocalID) aLocalID( anAttr );
-// isFolder = aLocalID->Value() == 999;
-// }
-// QString anEntry = theSO->GetID().c_str();
-// QString aName = theSO->GetName().c_str();
-// if ( isFolder ) {
-// folderList.insert( anEntry, aName );
-// _PTR(UseCaseIterator) ucit ( aUseCaseBuilder->GetUseCaseIterator( theSO ) );
-// for ( ucit->Init( false ); ucit->More(); ucit->Next() ) {
-// getGeomChildrenAndFolders( ucit->Value(), geomObjList, folderList );
-// }
-// } else {
-// geomObjList.insert( anEntry, aName );
-// }
-//}
-
-void GEOMToolsGUI_ReduceStudyDlg::clickOnCancel()
+//=================================================================================
+// function : unpublishObjects()
+// purpose : unpublish(hide) objects in the study
+//=================================================================================
+void GEOMToolsGUI_ReduceStudyDlg::unpublishObjects( std::set<std::string>& theObjects )
{
- accept();
+ _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( objectEntry.c_str() );
+ std::string studyEntry = GeomBaseObject->GetStudyEntry();
+ if ( studyEntry == "" || !isObjectDrawable( studyEntry ) )
+ continue;
+ _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 = 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 );
+ }
+ }
+ }
+ myApp->updateObjectBrowser( false );
+ myApp->updateActions();
}
-void GEOMToolsGUI_ReduceStudyDlg::clickOnHelp()
-{
+//=================================================================================
+// function : removeObjects()
+// purpose : remove objects from the study
+//=================================================================================
+void GEOMToolsGUI_ReduceStudyDlg::removeObjects( std::set<std::string>& theObjects )
+{
+ 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( objectEntry.c_str() );
+ std::string studyEntry = GeomBaseObject->GetStudyEntry();
+ if ( studyEntry == "" )
+ GeometryGUI::GetGeomGen()->RemoveObject( GeomBaseObject );
+ else {
+ if( !isObjectDrawable( studyEntry ) )
+ continue;
+ removeObject( studyEntry );
+ }
+ }
+ myApp->updateObjectBrowser( false );
+ myApp->updateActions();
}
-void GEOMToolsGUI_ReduceStudyDlg::onSelectionChanged()
+//=================================================================================
+// function : removeObject()
+// purpose : remove object with given study entry
+//=================================================================================
+void GEOMToolsGUI_ReduceStudyDlg::removeObject( std::string& theStudyEntry )
{
- onShowOnlySelected();
+ SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( myApp->activeStudy() );
+ _PTR(Study) aStudy = SalomeApp_Application::getStudy();
+ _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
+ _PTR(UseCaseBuilder) aUseCaseBuilder = aStudy->GetUseCaseBuilder();
+
+ _PTR(SObject) obj ( aStudy->FindObjectID( theStudyEntry.c_str() ) );
+ if ( obj ) {
+ // remove visual properties of the object
+ appStudy->removeObjectProperties(obj->GetID().c_str());
+ // remove references to this object
+ appStudy->deleteReferencesTo( obj );
+ // remove objects from study
+ aStudyBuilder->RemoveObjectWithChildren( obj );
+ // remove object from use case tree
+ aUseCaseBuilder->Remove( obj );
+ myDisplayer.EraseWithChildren( new SALOME_InteractiveObject( theStudyEntry.c_str(), "GEOM", "TEMP_IO" ) );
+ }
}
-void GEOMToolsGUI_ReduceStudyDlg::onShowOnlySelected()
+//=================================================================================
+// function : removeEmptyFolders()
+// purpose : remove empty folders from the study
+//=================================================================================
+void GEOMToolsGUI_ReduceStudyDlg::removeEmptyFolders()
{
-// SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
-// if ( !app ) return;
-//
-// SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
-// GEOM_Displayer* disp = new GEOM_Displayer( appStudy );
-//
-// OCCViewer_ViewManager* anOCCVM = (OCCViewer_ViewManager*) app->getViewManager( OCCViewer_Viewer::Type(), /*create=*/ true );
-//
-// std::cout << "\n\n\n onShowOnlySelected = " << std::endl;
-// if ( SUIT_ViewModel* viewModel = anOCCVM->getViewModel() )
-// if ( SALOME_View* viewFrame = dynamic_cast<SALOME_View*>( viewModel ) ) {
-// disp->EraseAll( true, false, viewFrame );
-//
-// std::cout << "\n\n\n EraseAll = " << std::endl;
-//
-// QList<QTreeWidgetItem*> selected = myTreeKeptObjects->selectedItems();
-// for( int i = 0; i< selected.size(); i++ ) {
-// const char* entry = myMap[selected[i]].first.c_str();
-// std::cout << "\n\n\n entry = " << QString( entry ).toStdString() << std::endl;
-// const char* name = "TEMP_IO";
-//
-// Handle(SALOME_InteractiveObject) tmpIO =
-// new SALOME_InteractiveObject( entry, "GEOM", name );
-//
-// disp->Display( tmpIO, false, viewFrame );
-// }
-// viewFrame->Repaint();
-// }
+ std::set<std::string> emptyFolders;
+
+ _PTR(Study) aStudy = SalomeApp_Application::getStudy();
+ _PTR(SComponent) SC ( aStudy->FindComponent( "GEOM" ) );
+ if ( !SC )
+ return;
+ _PTR(ChildIterator) anIter ( aStudy->NewChildIterator( SC ) );
+ anIter->InitEx( true );
+ while( anIter->More() ) {
+ _PTR(SObject) valSO ( anIter->Value() );
+ _PTR(SObject) refSO;
+ if ( !valSO->ReferencedObject( refSO ) )
+ getEmptyFolders( valSO, emptyFolders );
+ anIter->Next();
+ }
+
+ std::set<std::string>::iterator iter;
+ for( iter = emptyFolders.begin(); iter != emptyFolders.end(); ++iter ) {
+ std::string studyEntry = *iter;
+ removeObject( studyEntry );
+ }
+ myApp->updateObjectBrowser( false );
+ myApp->updateActions();
}
+//=================================================================================
+// function : removeEmptyFolders()
+// purpose : remove empty folders from the study
+//=================================================================================
+void GEOMToolsGUI_ReduceStudyDlg::getEmptyFolders( _PTR(SObject) theSO, std::set<std::string>& theFolders )
+{
+ _PTR(UseCaseBuilder) aUseCaseBuilder = SalomeApp_Application::getStudy()->GetUseCaseBuilder();
+
+ bool isFolder = false;
+ _PTR(GenericAttribute) anAttr;
+ if ( theSO->FindAttribute(anAttr, "AttributeLocalID") ) {
+ _PTR(AttributeLocalID) aLocalID( anAttr );
+ isFolder = aLocalID->Value() == 999;
+ }
+ QString studyEntry = theSO->GetID().c_str();
+ if ( isFolder ) {
+ if( !aUseCaseBuilder->HasChildren( theSO ) )
+ theFolders.insert( studyEntry.toStdString() );
+ else {
+ _PTR(UseCaseIterator) ucit ( aUseCaseBuilder->GetUseCaseIterator( theSO ) );
+ for ( ucit->Init( false ); ucit->More(); ucit->Next() )
+ getEmptyFolders( ucit->Value(), theFolders );
+ }
+ }
+}
//=================================================================================
// function : onItemClicked()
-// purpose : Called then treeItem clicked
+// purpose : called when tree item was clicked
//=================================================================================
void GEOMToolsGUI_ReduceStudyDlg::onItemClicked( QTreeWidgetItem* theItem, int theColumn )
{
checkVisibleIcon( item->treeWidget() );
}
+//=================================================================================
+// function : onHeaderClicked()
+// purpose : called when header item of tree was clicked
+//=================================================================================
void GEOMToolsGUI_ReduceStudyDlg::onHeaderClicked( int theColumn )
{
if( theColumn != 1 )
return;
- QTreeWidget* treeData = dynamic_cast<QTreeWidget*>(sender()->parent());
- if( myMapTreeSelectAll[ treeData ] ) {
- myMapTreeSelectAll[ treeData ] = false;
- treeData->headerItem()->setIcon( 1, myInvisible );
- QTreeWidgetItemIterator it( treeData );
+
+ QTreeWidget* treeWidget = dynamic_cast<QTreeWidget*>(sender()->parent());
+ if( myMapTreeSelectAll[ treeWidget ] ) {
+ myMapTreeSelectAll[ treeWidget ] = false;
+ treeWidget->headerItem()->setIcon( 1, myInvisible );
+ QTreeWidgetItemIterator it( treeWidget );
while(*it) {
GEOMToolsGUI_TreeWidgetItem* item = dynamic_cast<GEOMToolsGUI_TreeWidgetItem*>(*it);
- if( item->flags() & Qt::ItemIsSelectable ) {
- const char* entry = item->getStudyEntry();
- if( item->isVisible() ) {
+ 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);
+ myMapTreeSelectAll[ treeWidget ] = true;
+ treeWidget->headerItem()->setIcon( 1, myVisible );
+ QTreeWidgetItemIterator it( treeWidget );
while(*it) {
- GEOMToolsGUI_TreeWidgetItem* item = dynamic_cast<GEOMToolsGUI_TreeWidgetItem*>(*it);
- if( item->flags() & Qt::ItemIsSelectable ) {
- const char* entry = item->getStudyEntry();
- if( !item->isVisible() ) {
- item->setVisible( true, myVisible );
+ GEOMToolsGUI_TreeWidgetItem* item = dynamic_cast<GEOMToolsGUI_TreeWidgetItem*>(*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();
}
+//=================================================================================
+// function : selectionChanged()
+// purpose : called when selection of object browser was changed
+//=================================================================================
+void GEOMToolsGUI_ReduceStudyDlg::selectionChanged()
+{
+ init( getSelectedObjects() );
+}
-void GEOMToolsGUI_ReduceStudyDlg::checkVisibleIcon( QTreeWidget* theWidget )
+//=================================================================================
+// function : update()
+// purpose : update tree data
+//=================================================================================
+void GEOMToolsGUI_ReduceStudyDlg::update()
{
- bool isInvisible = false;
- QTreeWidgetItemIterator it( theWidget );
- while(*it) {
- GEOMToolsGUI_TreeWidgetItem* item = dynamic_cast<GEOMToolsGUI_TreeWidgetItem*>(*it);
- const char* entry = item->getStudyEntry();
- if( item->flags() & Qt::ItemIsSelectable )
- if( !item->isVisible() )
- isInvisible = true;
- ++it;
+ myTreeKeptObjects->clear();
+ myTreeRemoveObjects->clear();
+
+ std::set<std::string> keptObjects( myKeptObjects );
+ std::set<std::string> removeObjects( myRemovedObjects );
+
+ // Intermediate objects
+ if( myGroupIntermediates->checkedId() == 2 ) { // remove
+ std::set<std::string>::iterator iter;
+ for( iter=myListParents.begin(); iter!=myListParents.end(); ++iter)
+ removeObjects.insert( *iter );
+ }
+ else { // keep or unpublish
+ std::set<std::string>::iterator iter;
+ for( iter=myListParents.begin(); iter!=myListParents.end(); ++iter)
+ keptObjects.insert( *iter );
}
- if( isInvisible ) {
- theWidget->headerItem()->setIcon( 1, myInvisible );
- myMapTreeSelectAll[ theWidget ] = false;
+ // Sub-objects
+ if( myGroupSubObjects->checkedId() == 2 ) {
+ std::set<std::string>::iterator iter;
+ for( iter=myListSubObjects.begin(); iter!=myListSubObjects.end(); ++iter)
+ removeObjects.insert( *iter );
}
else {
- theWidget->headerItem()->setIcon( 1, myVisible );
- myMapTreeSelectAll[ theWidget ] = true;
+ std::set<std::string>::iterator iter;
+ for( iter=myListSubObjects.begin(); iter!=myListSubObjects.end(); ++iter)
+ keptObjects.insert( *iter );
}
-}
-void GEOMToolsGUI_ReduceStudyDlg::sortObjects( QTreeWidget* theWidget, std::set<std::string>& theObjects )
-{
- SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
- if ( !app ) return;
- SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
- int studyId = GeometryGUI::ClientStudyToStudy( study->studyDS())->StudyId();
+ addObjectsToTree( myTreeKeptObjects, keptObjects );
+ addObjectsToTree( myTreeRemoveObjects, removeObjects );
+
+ myTreeKeptObjects->collapseAll();
+ myTreeRemoveObjects->collapseAll();
- 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( studyId, objectEntry.c_str() );
- GEOM::GEOM_Object_var GeomObject = GEOM::GEOM_Object::_narrow( GeomBaseObject );
- if( GeomObject->_is_nil() )
- continue;
- addSubObject( theWidget, theObjects, GeomObject );
- }
}
-GEOMToolsGUI_TreeWidgetItem* GEOMToolsGUI_ReduceStudyDlg::addSubObject( QTreeWidget* theWidget, std::set<std::string>& theObjects, GEOM::GEOM_Object_var theObject )
+//=================================================================================
+// function : clickOnOk()
+// purpose : called when OK button was clicked
+//=================================================================================
+void GEOMToolsGUI_ReduceStudyDlg::clickOnOk()
{
- std::cout<<"\n\n ----------------- addSubObject ---------------------" << std::endl;
- std::cout <<"\nObject = " << theObject->GetName() << std::endl;
- GEOMToolsGUI_TreeWidgetItem* item;
- if( !theObject->IsMainShape() ) {
- GEOMToolsGUI_TreeWidgetItem* parentItem = addSubObject( theWidget, theObjects, theObject->GetMainShape() );
- std::cout <<"\nParentItem = " << parentItem->text(0).toStdString() << std::endl;
- item = findObjectInTree( theWidget, theObject );
- if( !item )
- item = new GEOMToolsGUI_TreeWidgetItem( parentItem, QStringList() << theObject->GetName(), theObject->GetStudyEntry(), false );
+ std::set<std::string> objectsToBeRemoved = myRemovedObjects;
+ std::set<std::string> objectsToBeUnpublished;
+
+ // Create lists of intermediate objects to be removed or to be unpublished
+ std::set<std::string>::iterator iter;
+ if( myGroupIntermediates->checkedId() == 1 ) { // unpublish
+ for( iter = myListParents.begin(); iter != myListParents.end(); ++iter )
+ objectsToBeUnpublished.insert( *iter );
}
- else {
- std::cout <<"\nParentItem = ROOT" << std::endl;
- item = findObjectInTree( theWidget, theObject );
- if( !item )
- item = new GEOMToolsGUI_TreeWidgetItem( theWidget, QStringList() << theObject->GetName(), theObject->GetStudyEntry(), false );
+ 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 ) {
+ return;
+ }
+ for( iter = myListParents.begin(); iter != myListParents.end(); ++iter )
+ objectsToBeRemoved.insert( *iter );
}
- bool isDisplayed = false;
- if( theObjects.find( theObject->GetEntry() ) != theObjects.end() ) {
- std::cout << "\n FOUND " << std::endl;
- 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 );
- }
+ // Create lists of sub-objects to be removed or to be unpublished
+ if( myGroupSubObjects->checkedId() == 1 ) { // unpublish
+ for( iter = myListSubObjects.begin(); iter != myListSubObjects.end(); ++iter )
+ objectsToBeUnpublished.insert( *iter );
+ }
+ else if( myGroupSubObjects->checkedId() == 2 ) { // remove
+ for( iter = myListSubObjects.begin(); iter != myListSubObjects.end(); ++iter )
+ objectsToBeRemoved.insert( *iter );
+ }
+ // if user chosen the soft removal
+ if( myCBSoftRemoval->isChecked() ) {
+ for( iter = objectsToBeRemoved.begin(); iter != objectsToBeRemoved.end(); ++iter )
+ objectsToBeUnpublished.insert( *iter );
+ unpublishObjects( objectsToBeUnpublished );
}
else {
- std::cout << "\n NOT FOUND " << std::endl;
- item->setFlags( item->flags() & ~Qt::ItemIsSelectable );
- item->setTextColor( 0, QColor( 150, 150, 150 ) );
+ unpublishObjects( objectsToBeUnpublished );
+ removeObjects( objectsToBeRemoved );
}
- std::cout<<"\n\n ----------------- FINISH addSubObject ---------------------" << std::endl;
- return item;
+ // if user want to delete the empty folders
+ if( myCBRemoveEmptyFolder->isChecked() )
+ removeEmptyFolders();
+
+ accept();
}
-GEOMToolsGUI_TreeWidgetItem* GEOMToolsGUI_ReduceStudyDlg::findObjectInTree( QTreeWidget* theWidget, GEOM::GEOM_Object_var theObject )
+//=================================================================================
+// function : clickOnHelp()
+// purpose : called when Help button was clicked to open a help page
+//=================================================================================
+void GEOMToolsGUI_ReduceStudyDlg::clickOnHelp()
{
- QTreeWidgetItemIterator it( theWidget );
- std::cout <<"\n\n\n theObject->GetStudyEntry() = " << theObject->GetStudyEntry() << std::endl;
- while(*it) {
- GEOMToolsGUI_TreeWidgetItem* item = dynamic_cast<GEOMToolsGUI_TreeWidgetItem*>(*it);
- std::cout <<"\n\n\n item->getStudyEntry() = " << item->getStudyEntry() << std::endl;
- if( QString( item->getStudyEntry() ) == QString( theObject->GetStudyEntry() ) )
- return item;
- ++it;
- }
- std::cout <<"\n\n\n RETURN NULL " << std::endl;
- return NULL;
+ myApp->onHelpContextModule( "GEOM", "reduce_study_page.html" );
+}
+
+GEOMToolsGUI_TreeWidgetItem::GEOMToolsGUI_TreeWidgetItem( QTreeWidget* view, const QStringList &strings,
+ char* studyEntry, int type )
+:QTreeWidgetItem( view, strings, type ),
+ myVisible( false ),
+ myStudyEntry( studyEntry )
+{
+}
+
+GEOMToolsGUI_TreeWidgetItem::GEOMToolsGUI_TreeWidgetItem( QTreeWidgetItem* parent, const QStringList &strings,
+ char* studyEntry, int type )
+:QTreeWidgetItem( parent, strings, type ),
+ myVisible( false ),
+ myStudyEntry( studyEntry )
+{
+}
+
+GEOMToolsGUI_TreeWidgetItem::~GEOMToolsGUI_TreeWidgetItem()
+{
+}
+
+bool GEOMToolsGUI_TreeWidgetItem::isVisible()
+{
+ return myVisible;
+}
+
+void GEOMToolsGUI_TreeWidgetItem::setVisible( bool theIsVisible, QIcon& theIcon )
+{
+ myVisible = theIsVisible;
+ setIcon( 1, theIcon );
+}
+
+char* GEOMToolsGUI_TreeWidgetItem::getStudyEntry() const
+{
+ return myStudyEntry;
}