mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2024-12-26 09:20:35 +05:00
clean programming code
This commit is contained in:
parent
f586974bcb
commit
caeeba82b5
@ -55,8 +55,6 @@ GEOMToolsGUI_ReduceStudyDlg::GEOMToolsGUI_ReduceStudyDlg( QWidget* parent )
|
|||||||
:QDialog( parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint ),
|
:QDialog( parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint ),
|
||||||
myDisplayer(NULL)
|
myDisplayer(NULL)
|
||||||
{
|
{
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
|
||||||
|
|
||||||
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
|
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
|
||||||
myVisible = QIcon( resMgr->loadPixmap( "SUIT", tr( "ICON_DATAOBJ_VISIBLE" ) ) );
|
myVisible = QIcon( resMgr->loadPixmap( "SUIT", tr( "ICON_DATAOBJ_VISIBLE" ) ) );
|
||||||
myInvisible = QIcon( resMgr->loadPixmap( "SUIT", tr( "ICON_DATAOBJ_INVISIBLE" ) ) );
|
myInvisible = QIcon( resMgr->loadPixmap( "SUIT", tr( "ICON_DATAOBJ_INVISIBLE" ) ) );
|
||||||
@ -68,6 +66,7 @@ myDisplayer(NULL)
|
|||||||
myDisplayer = GEOM_Displayer( study );
|
myDisplayer = GEOM_Displayer( study );
|
||||||
|
|
||||||
setWindowTitle( tr( "GEOM_REDUCE_STUDY_TITLE" ) );
|
setWindowTitle( tr( "GEOM_REDUCE_STUDY_TITLE" ) );
|
||||||
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
|
||||||
QGridLayout* topLayout = new QGridLayout( this );
|
QGridLayout* topLayout = new QGridLayout( this );
|
||||||
topLayout->setMargin( 11 ); topLayout->setSpacing( 6 );
|
topLayout->setMargin( 11 ); topLayout->setSpacing( 6 );
|
||||||
@ -135,11 +134,11 @@ myDisplayer(NULL)
|
|||||||
connect( myGroupSubObjects, SIGNAL( buttonClicked( int ) ), this, SLOT( update() ) );
|
connect( myGroupSubObjects, SIGNAL( buttonClicked( int ) ), this, SLOT( update() ) );
|
||||||
|
|
||||||
connect( buttonOk, SIGNAL( clicked() ), this, SLOT( clickOnOk() ) );
|
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( buttonHelp, SIGNAL( clicked() ), this, SLOT( clickOnHelp() ) );
|
||||||
|
|
||||||
connect( myApp->selectionMgr(),
|
connect( myApp->selectionMgr(), SIGNAL( currentSelectionChanged() ),
|
||||||
SIGNAL( currentSelectionChanged() ), this, SLOT( selectionChanged() ) );
|
this, SLOT( selectionChanged() ) );
|
||||||
|
|
||||||
init( getSelectedObjects() );
|
init( getSelectedObjects() );
|
||||||
}
|
}
|
||||||
@ -160,59 +159,56 @@ void GEOMToolsGUI_ReduceStudyDlg::init( const std::set<std::string>& theObjectEn
|
|||||||
|
|
||||||
myMainEntries = theObjectEntries;
|
myMainEntries = theObjectEntries;
|
||||||
|
|
||||||
std::cout << "\n\n\n myMainEntries = " << myMainEntries.size() << std::endl;
|
GEOM::string_array_var keptObjects = new GEOM::string_array();
|
||||||
|
|
||||||
GEOM::string_array_var selectedObjects = new GEOM::string_array();
|
|
||||||
int It = 0;
|
int It = 0;
|
||||||
selectedObjects->length( theObjectEntries.size() );
|
keptObjects->length( theObjectEntries.size() );
|
||||||
std::set<std::string>::iterator iter;
|
std::set<std::string>::iterator iter;
|
||||||
for( iter=theObjectEntries.begin(); iter!=theObjectEntries.end(); ++iter, It++ )
|
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 parentsObjects = new GEOM::string_array();
|
||||||
GEOM::string_array_var subObjects = new GEOM::string_array();
|
GEOM::string_array_var subObjects = new GEOM::string_array();
|
||||||
GEOM::string_array_var oters = new GEOM::string_array();
|
GEOM::string_array_var otherObjects = new GEOM::string_array();
|
||||||
|
|
||||||
|
GeometryGUI::GetGeomGen()->GetEntriesToCleanStudy( myStudy, keptObjects, parentsObjects,
|
||||||
|
subObjects, otherObjects );
|
||||||
|
|
||||||
////// PUT ALGORITHM HERE
|
for ( int i = 0; i < keptObjects->length(); i++ )
|
||||||
GeometryGUI::GetGeomGen()->GetEntriesToCleanStudy( myStudy, selectedObjects,
|
myKeptObjects.insert( keptObjects[i].in() );
|
||||||
parentsObjects, subObjects, oters );
|
for( int i = 0; i< otherObjects->length(); i++ )
|
||||||
|
myRemovedObjects.insert( otherObjects[i].in() );
|
||||||
for ( int i = 0; i < selectedObjects->length(); i++ )
|
|
||||||
myKeptObjects.insert( selectedObjects[i].in() );
|
|
||||||
|
|
||||||
for( int i = 0; i< parentsObjects->length(); i++ )
|
for( int i = 0; i< parentsObjects->length(); i++ )
|
||||||
myListParents.insert( parentsObjects[i].in() );
|
myListParents.insert( parentsObjects[i].in() );
|
||||||
|
|
||||||
for( int i = 0; i< subObjects->length(); i++ )
|
for( int i = 0; i< subObjects->length(); i++ )
|
||||||
myListSubObjects.insert( subObjects[i].in() );
|
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();
|
update();
|
||||||
|
|
||||||
checkVisibleIcon( myTreeKeptObjects );
|
checkVisibleIcon( myTreeKeptObjects );
|
||||||
checkVisibleIcon( myTreeRemoveObjects );
|
checkVisibleIcon( myTreeRemoveObjects );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::set<std::string> GEOMToolsGUI_ReduceStudyDlg::getSelectedObjects() const
|
||||||
|
{
|
||||||
|
std::set<std::string> 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 )
|
void GEOMToolsGUI_ReduceStudyDlg::createTreeWidget( QTreeWidget* theTreeWidget )
|
||||||
{
|
{
|
||||||
theTreeWidget->setColumnCount( 2 );
|
theTreeWidget->setColumnCount( 2 );
|
||||||
@ -251,14 +247,177 @@ QGroupBox* GEOMToolsGUI_ReduceStudyDlg::createButtonGroup( QButtonGroup* theButt
|
|||||||
return groupObjects;
|
return groupObjects;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GEOMToolsGUI_ReduceStudyDlg::update()
|
void GEOMToolsGUI_ReduceStudyDlg::addObjectsToTree( QTreeWidget* theWidget, 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( 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<std::string>& 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<GEOMToolsGUI_TreeWidgetItem*>(*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<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::unpublishObjects( std::set<std::string>& theObjects )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void GEOMToolsGUI_ReduceStudyDlg::removeObjects( std::set<std::string>& 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<GEOMToolsGUI_TreeWidgetItem*>( 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<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 ) && 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<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();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GEOMToolsGUI_ReduceStudyDlg::selectionChanged()
|
||||||
|
{
|
||||||
|
init( getSelectedObjects() );
|
||||||
|
}
|
||||||
|
|
||||||
|
void GEOMToolsGUI_ReduceStudyDlg::update()
|
||||||
|
{
|
||||||
myTreeKeptObjects->clear();
|
myTreeKeptObjects->clear();
|
||||||
myTreeRemoveObjects->clear();
|
myTreeRemoveObjects->clear();
|
||||||
|
|
||||||
std::set<std::string> keptObjects(myKeptObjects);
|
std::set<std::string> keptObjects( myKeptObjects );
|
||||||
std::set<std::string> removeObjects(myRemovedObjects);
|
std::set<std::string> removeObjects( myRemovedObjects );
|
||||||
|
|
||||||
// Intermediate objects
|
// Intermediate objects
|
||||||
if( myGroupIntermediates->checkedId() == 2 ) { // remove
|
if( myGroupIntermediates->checkedId() == 2 ) { // remove
|
||||||
@ -284,66 +443,54 @@ void GEOMToolsGUI_ReduceStudyDlg::update()
|
|||||||
keptObjects.insert( *iter );
|
keptObjects.insert( *iter );
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout<<"\n\n\n Objects to be kept: ";
|
addObjectsToTree( myTreeKeptObjects, keptObjects );
|
||||||
std::set<std::string>::iterator it_kept;
|
addObjectsToTree( myTreeRemoveObjects, removeObjects );
|
||||||
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<std::string>::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 );
|
|
||||||
|
|
||||||
myTreeKeptObjects->collapseAll();
|
myTreeKeptObjects->collapseAll();
|
||||||
myTreeRemoveObjects->collapseAll();
|
myTreeRemoveObjects->collapseAll();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GEOMToolsGUI_ReduceStudyDlg::selectionChanged()
|
|
||||||
{
|
|
||||||
init( getSelectedObjects() );
|
|
||||||
}
|
|
||||||
|
|
||||||
void GEOMToolsGUI_ReduceStudyDlg::clickOnOk()
|
void GEOMToolsGUI_ReduceStudyDlg::clickOnOk()
|
||||||
{
|
{
|
||||||
|
std::set<std::string> objectsToBeRemoved = myRemovedObjects;
|
||||||
|
std::set<std::string> objectsToBeUnpublished;
|
||||||
|
|
||||||
std::set<std::string> ObjectsToBeRemove = myRemovedObjects;
|
std::set<std::string>::iterator iter;
|
||||||
std::set<std::string> ObjectsToBeUnpublish;
|
if( myGroupIntermediates->checkedId() == 1 ) { // unpublish
|
||||||
|
for( iter = myListParents.begin(); iter != myListParents.end(); ++iter )
|
||||||
if( myGroupIntermediates->checkedId() == 2 ) {
|
objectsToBeUnpublished.insert( *iter );
|
||||||
std::set<std::string>::iterator iter;
|
|
||||||
for( iter=myListParents.begin(); iter!=myListParents.end(); ++iter)
|
|
||||||
ObjectsToBeRemove.insert( *iter );
|
|
||||||
}
|
}
|
||||||
else if( myGroupIntermediates->checkedId() == 1 ) {
|
if( myGroupIntermediates->checkedId() == 2 ) { // remove
|
||||||
std::set<std::string>::iterator iter;
|
for( iter = myListParents.begin(); iter != myListParents.end(); ++iter )
|
||||||
for( iter=myListParents.begin(); iter!=myListParents.end(); ++iter)
|
objectsToBeRemoved.insert( *iter );
|
||||||
ObjectsToBeUnpublish.insert( *iter );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( myGroupSubObjects->checkedId() == 2 ) {
|
if( myGroupSubObjects->checkedId() == 1 ) { // unpublish
|
||||||
std::set<std::string>::iterator iter;
|
for( iter = myListSubObjects.begin(); iter != myListSubObjects.end(); ++iter )
|
||||||
for( iter=myListSubObjects.begin(); iter!=myListSubObjects.end(); ++iter)
|
objectsToBeUnpublished.insert( *iter );
|
||||||
ObjectsToBeRemove.insert( *iter );
|
|
||||||
}
|
}
|
||||||
else if( myGroupSubObjects->checkedId() == 1 ) {
|
else if( myGroupSubObjects->checkedId() == 2 ) { // remove
|
||||||
std::set<std::string>::iterator iter;
|
for( iter = myListSubObjects.begin(); iter != myListSubObjects.end(); ++iter )
|
||||||
for( iter=myListSubObjects.begin(); iter!=myListSubObjects.end(); ++iter)
|
objectsToBeRemoved.insert( *iter );
|
||||||
ObjectsToBeUnpublish.insert( *iter );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unpublishObjects( ObjectsToBeUnpublish );
|
if( myCBSoftRemoval->isChecked() ) {
|
||||||
removeObjects( ObjectsToBeRemove );
|
for( iter = objectsToBeRemoved.begin(); iter != objectsToBeRemoved.end(); ++iter )
|
||||||
|
objectsToBeUnpublished.insert( *iter );
|
||||||
|
unpublishObjects( objectsToBeUnpublished );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
unpublishObjects( objectsToBeUnpublished );
|
||||||
|
removeObjects( objectsToBeRemoved );
|
||||||
|
}
|
||||||
|
|
||||||
|
accept();
|
||||||
|
|
||||||
|
|
||||||
// std::cout<< "\n\n REMOVE:" << std::endl;
|
// std::cout<< "\n\n REMOVE:" << std::endl;
|
||||||
// std::set<std::string>::iterator it;
|
// std::set<std::string>::iterator it;
|
||||||
// for( it = ObjectsToBeRemove.begin(); it != ObjectsToBeRemove.end(); ++it )
|
// for( it = objectsToBeRemoved.begin(); it != objectsToBeRemoved.end(); ++it )
|
||||||
// std::cout <<" " << (*it) << std::endl;
|
// std::cout <<" " << (*it) << std::endl;
|
||||||
//
|
//
|
||||||
// SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
|
// SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
|
||||||
@ -428,8 +575,6 @@ void GEOMToolsGUI_ReduceStudyDlg::clickOnOk()
|
|||||||
// aSelMgr->setSelectedObjects(aSelList);
|
// aSelMgr->setSelectedObjects(aSelList);
|
||||||
// GEOMToolsGUI::OnUnpublishObject();
|
// GEOMToolsGUI::OnUnpublishObject();
|
||||||
|
|
||||||
accept();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// if( myCBRemoveEmptyFolder->isChecked() ) {
|
// if( myCBRemoveEmptyFolder->isChecked() ) {
|
||||||
@ -497,213 +642,26 @@ void GEOMToolsGUI_ReduceStudyDlg::clickOnOk()
|
|||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
|
||||||
void GEOMToolsGUI_ReduceStudyDlg::unpublishObjects( std::set<std::string>& theObjects )
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void GEOMToolsGUI_ReduceStudyDlg::removeObjects( std::set<std::string>& theObjects )
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void GEOMToolsGUI_ReduceStudyDlg::clickOnCancel()
|
|
||||||
{
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
void GEOMToolsGUI_ReduceStudyDlg::clickOnHelp()
|
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<GEOMToolsGUI_TreeWidgetItem*>( 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<QTreeWidget*>(sender()->parent());
|
|
||||||
if( myMapTreeSelectAll[ treeData ] ) {
|
|
||||||
myMapTreeSelectAll[ treeData ] = false;
|
|
||||||
treeData->headerItem()->setIcon( 1, myInvisible );
|
|
||||||
QTreeWidgetItemIterator it( treeData );
|
|
||||||
while(*it) {
|
|
||||||
GEOMToolsGUI_TreeWidgetItem* item = dynamic_cast<GEOMToolsGUI_TreeWidgetItem*>(*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<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();
|
|
||||||
}
|
|
||||||
|
|
||||||
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::sortObjects( QTreeWidget* theWidget, 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( 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<std::string>& 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<GEOMToolsGUI_TreeWidgetItem*>(*it);
|
|
||||||
if( QString( item->getStudyEntry() ) == QString( theObject->GetStudyEntry() ) )
|
|
||||||
return item;
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::set<std::string> GEOMToolsGUI_ReduceStudyDlg::getSelectedObjects() const
|
|
||||||
{
|
|
||||||
std::set<std::string> 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,
|
GEOMToolsGUI_TreeWidgetItem::GEOMToolsGUI_TreeWidgetItem( QTreeWidget* view, const QStringList &strings,
|
||||||
char* studyEntry, bool visible, int type )
|
char* studyEntry, int type )
|
||||||
:QTreeWidgetItem( view, strings, type ),
|
:QTreeWidgetItem( view, strings, type ),
|
||||||
myStudyEntry( studyEntry ),
|
myStudyEntry( studyEntry ),
|
||||||
myVisible( visible )
|
myVisible( false )
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GEOMToolsGUI_TreeWidgetItem::GEOMToolsGUI_TreeWidgetItem( QTreeWidgetItem* parent, const QStringList &strings,
|
GEOMToolsGUI_TreeWidgetItem::GEOMToolsGUI_TreeWidgetItem( QTreeWidgetItem* parent, const QStringList &strings,
|
||||||
char* studyEntry, bool visible, int type )
|
char* studyEntry, int type )
|
||||||
:QTreeWidgetItem( parent, strings, type ),
|
:QTreeWidgetItem( parent, strings, type ),
|
||||||
myStudyEntry( studyEntry ),
|
myStudyEntry( studyEntry ),
|
||||||
myVisible( visible )
|
myVisible( false )
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GEOMToolsGUI_TreeWidgetItem::~GEOMToolsGUI_TreeWidgetItem()
|
GEOMToolsGUI_TreeWidgetItem::~GEOMToolsGUI_TreeWidgetItem()
|
||||||
|
@ -37,8 +37,8 @@ class GEOMToolsGUI_TreeWidgetItem : public QTreeWidgetItem
|
|||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GEOMToolsGUI_TreeWidgetItem( QTreeWidget*, const QStringList&, char*, bool, int = Type );
|
GEOMToolsGUI_TreeWidgetItem( QTreeWidget*, const QStringList&, char*, int = Type );
|
||||||
GEOMToolsGUI_TreeWidgetItem( QTreeWidgetItem*, const QStringList&, char*, bool, int = Type );
|
GEOMToolsGUI_TreeWidgetItem( QTreeWidgetItem*, const QStringList&, char*, int = Type );
|
||||||
~GEOMToolsGUI_TreeWidgetItem();
|
~GEOMToolsGUI_TreeWidgetItem();
|
||||||
|
|
||||||
bool isVisible();
|
bool isVisible();
|
||||||
@ -47,8 +47,9 @@ public:
|
|||||||
char* getStudyEntry() const;
|
char* getStudyEntry() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
char* myStudyEntry;
|
|
||||||
bool myVisible;
|
bool myVisible;
|
||||||
|
char* myStudyEntry;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class GEOMTOOLSGUI_EXPORT GEOMToolsGUI_ReduceStudyDlg : public QDialog
|
class GEOMTOOLSGUI_EXPORT GEOMToolsGUI_ReduceStudyDlg : public QDialog
|
||||||
@ -60,57 +61,56 @@ public:
|
|||||||
~GEOMToolsGUI_ReduceStudyDlg();
|
~GEOMToolsGUI_ReduceStudyDlg();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void onItemClicked(QTreeWidgetItem*, int );
|
||||||
|
void onHeaderClicked( int );
|
||||||
|
|
||||||
void clickOnOk();
|
void selectionChanged();
|
||||||
void clickOnCancel();
|
|
||||||
void clickOnHelp();
|
|
||||||
|
|
||||||
void onItemClicked(QTreeWidgetItem*, int );
|
void update();
|
||||||
void onHeaderClicked( int );
|
|
||||||
|
|
||||||
void selectionChanged();
|
void clickOnOk();
|
||||||
|
void clickOnHelp();
|
||||||
void update();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void init( const std::set<std::string>& theObjectEntries );
|
||||||
|
std::set<std::string> getSelectedObjects() const;
|
||||||
|
|
||||||
void init( const std::set<std::string>& theObjectEntries );
|
void createTreeWidget( QTreeWidget* );
|
||||||
void createTreeWidget( QTreeWidget* );
|
QGroupBox* createButtonGroup( QButtonGroup* );
|
||||||
QGroupBox* createButtonGroup( QButtonGroup* );
|
|
||||||
void checkVisibleIcon( QTreeWidget* );
|
|
||||||
void sortObjects( QTreeWidget*, std::set<std::string>& );
|
|
||||||
GEOMToolsGUI_TreeWidgetItem* addSubObject( QTreeWidget*, std::set<std::string>&, GEOM::GEOM_Object_var );
|
|
||||||
GEOMToolsGUI_TreeWidgetItem* findObjectInTree( QTreeWidget*, GEOM::GEOM_Object_var );
|
|
||||||
|
|
||||||
void unpublishObjects( std::set<std::string>& );
|
void addObjectsToTree( QTreeWidget*, std::set<std::string>& );
|
||||||
void removeObjects( std::set<std::string>& );
|
GEOMToolsGUI_TreeWidgetItem* addSubObject( QTreeWidget*, std::set<std::string>&, GEOM::GEOM_Object_var );
|
||||||
|
GEOMToolsGUI_TreeWidgetItem* findObjectInTree( QTreeWidget*, GEOM::GEOM_Object_var );
|
||||||
|
|
||||||
std::set<std::string> getSelectedObjects() const;
|
void checkVisibleIcon( QTreeWidget* );
|
||||||
|
|
||||||
QTreeWidget* myTreeKeptObjects;
|
void unpublishObjects( std::set<std::string>& );
|
||||||
QTreeWidget* myTreeRemoveObjects;
|
void removeObjects( std::set<std::string>& );
|
||||||
|
|
||||||
QButtonGroup* myGroupIntermediates;
|
QTreeWidget* myTreeKeptObjects;
|
||||||
QButtonGroup* myGroupSubObjects;
|
QTreeWidget* myTreeRemoveObjects;
|
||||||
|
std::map<QTreeWidget*,bool> myMapTreeSelectAll;
|
||||||
|
|
||||||
QCheckBox* myCBRemoveEmptyFolder;
|
QButtonGroup* myGroupIntermediates;
|
||||||
QCheckBox* myCBSoftRemoval;
|
QButtonGroup* myGroupSubObjects;
|
||||||
|
|
||||||
std::set<std::string> myMainEntries;
|
QCheckBox* myCBRemoveEmptyFolder;
|
||||||
|
QCheckBox* myCBSoftRemoval;
|
||||||
|
|
||||||
QIcon myVisible;
|
std::set<std::string> myMainEntries;
|
||||||
QIcon myInvisible;
|
|
||||||
|
|
||||||
GEOM_Displayer myDisplayer;
|
std::set<std::string> myKeptObjects;
|
||||||
SalomeApp_Application* myApp;
|
std::set<std::string> myRemovedObjects;
|
||||||
SALOMEDS::Study_var myStudy;
|
std::set<std::string> myListParents;
|
||||||
|
std::set<std::string> myListSubObjects;
|
||||||
|
|
||||||
std::set<std::string> myKeptObjects;
|
QIcon myVisible;
|
||||||
std::set<std::string> myRemovedObjects;
|
QIcon myInvisible;
|
||||||
std::set<std::string> myListParents;
|
|
||||||
std::set<std::string> myListSubObjects;
|
GEOM_Displayer myDisplayer;
|
||||||
|
SalomeApp_Application* myApp;
|
||||||
|
SALOMEDS::Study_var myStudy;
|
||||||
|
|
||||||
std::map<QTreeWidget*,bool> myMapTreeSelectAll;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user