From: vsr Date: Thu, 5 Jun 2008 04:29:20 +0000 (+0000) Subject: Issue 0019855 (Cannot delete objects with dependencies) : improve 'Delete objects... X-Git-Tag: V4_1_3~10 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7eb7482caa7ca748b62c0ed49026a5d92d1ff535;p=modules%2Fgeom.git Issue 0019855 (Cannot delete objects with dependencies) : improve 'Delete objects' operation --- diff --git a/src/GEOMToolsGUI/GEOMToolsGUI.cxx b/src/GEOMToolsGUI/GEOMToolsGUI.cxx index 7d4dd1f24..c0f6227b7 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI.cxx +++ b/src/GEOMToolsGUI/GEOMToolsGUI.cxx @@ -27,11 +27,11 @@ // $Header$ #include "GEOMToolsGUI.h" +#include "GEOMToolsGUI_DeleteDlg.h" #include "GeometryGUI.h" #include "GEOM_Actor.h" #include "GEOMBase.h" -#include "GEOMBase_aWarningDlg.h" #include "GEOM_Operation.h" #include "GEOM_Displayer.h" @@ -119,6 +119,74 @@ static QString getFileName( QWidget* parent, return filename; } +//======================================================================= +// function : getParentComponent +// purpose : Get object's parent component entry +//======================================================================= +static QString getParentComponent( _PTR( SObject ) obj ) +{ + if ( obj ) { + _PTR(SComponent) comp = obj->GetFatherComponent(); + if ( comp ) + return QString( comp->GetID().c_str() ); + } + return QString(); +} + +//===================================================================================== +// function : inUse +// purpose : check if the object(s) passed as the the second arguments are used +// by the other objects in the study +//===================================================================================== +static bool inUse( _PTR(Study) study, const QString& component, const QMap& objects ) +{ + _PTR(SObject) comp = study->FindObjectID( component.latin1() ); + if ( !comp ) + return false; + + // collect all GEOM objects being deleted + QMap gobjects; + QMap::ConstIterator oit; + for ( oit = objects.begin(); oit != objects.end(); ++oit ) { + _PTR(SObject) so = study->FindObjectID( oit.key().latin1() ); + if ( !so ) + continue; + CORBA::Object_var corbaObj_rem = GeometryGUI::ClientSObjectToObject( so ); + GEOM::GEOM_Object_var geomObj_rem = GEOM::GEOM_Object::_narrow( corbaObj_rem ); + if( CORBA::is_nil( geomObj_rem ) ) + continue; + gobjects.insert( oit.key(), geomObj_rem ); + } + + // browse through all GEOM data tree + _PTR(ChildIterator) it ( study->NewChildIterator( comp ) ); + for ( it->InitEx( true ); it->More(); it->Next() ) { + _PTR(SObject) child( it->Value() ); + CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject( child ); + GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( corbaObj ); + if( CORBA::is_nil( geomObj ) ) + continue; + + GEOM::ListOfGO_var list = geomObj->GetDependency(); + if( list->length() <= 1 ) + continue; // ??? why 1? + + for( int i = 0; i < list->length(); i++ ) { + bool depends = false; + bool deleted = false; + QMap::Iterator git; + for ( git = gobjects.begin(); git != gobjects.end() && ( !depends || !deleted ); ++git ) { + depends = depends || list[i]->_is_equivalent( *git ); + deleted = deleted || git.key() == child->GetID().c_str() ;//geomObj->_is_equivalent( *git ); + } + if ( depends && !deleted ) + return true; + } + } + return false; +} + + //======================================================================= // function : GEOMToolsGUI() // purpose : Constructor @@ -222,16 +290,6 @@ bool GEOMToolsGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent) OnSettingsColor(); break; } - case 413: // SETTINGS - ISOS - { - OnSettingsIsos(); - break; - } - case 414: // SETTINGS : STEP VALUE FOR SPIN BOXES - { - OnSettingsStep(); - break; - } case 804: // ADD IN STUDY - POPUP VIEWER { // SAN -- TO BE REMOVED !!!! @@ -287,7 +345,6 @@ bool GEOMToolsGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent) } - //=============================================================================== // function : OnEditDelete() // purpose : @@ -297,164 +354,148 @@ void GEOMToolsGUI::OnEditDelete() SALOME_ListIO selected; SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); - if ( app ) { - LightApp_SelectionMgr* aSelMgr = app->selectionMgr(); - SalomeApp_Study* appStudy = dynamic_cast( app->activeStudy() ); - if ( aSelMgr && appStudy ) { - aSelMgr->selectedObjects( selected, QString::null, false ); - if ( !selected.IsEmpty() ) { - _PTR(Study) aStudy = appStudy->studyDS(); - - bool aLocked = (_PTR(AttributeStudyProperties)(aStudy->GetProperties()))->IsLocked(); - if ( aLocked ) { - SUIT_MessageBox::warn1 ( app->desktop(), - QObject::tr("WRN_WARNING"), - QObject::tr("WRN_STUDY_LOCKED"), - QObject::tr("BUT_OK") ); - return; - } - - // VSR 17/11/04: check if all objects selected belong to GEOM component --> start - // modifications of ASV 01.06.05 - QString parentComp = getParentComponent( aStudy, selected ); - CORBA::String_var geomIOR = app->orb()->object_to_string( GeometryGUI::GetGeomGen() ); - QString geomComp = getParentComponent( aStudy->FindObjectIOR( geomIOR.in() ) ); - - if ( parentComp != geomComp ) { - SUIT_MessageBox::warn1 ( app->desktop(), - QObject::tr("ERR_ERROR"), - QObject::tr("NON_GEOM_OBJECTS_SELECTED").arg( getGeometryGUI()->moduleName() ), - QObject::tr("BUT_OK") ); - return; - } - // VSR 17/11/04: check if all objects selected belong to GEOM component <-- finish - QString aNameList; - int nbSel = 0; - //Get Main Objects Names - Handle(SALOME_InteractiveObject) anIObject; - for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) - { - QString aName = It.Value()->getName(); - if ( aName != "" && aName.ref(0) != '*') { - aNameList.append(" - " + aName + "\n"); - nbSel++; - } - anIObject = It.Value(); - } - // Append Child Names of Last Selected Object - _PTR(SObject) obj ( aStudy->FindObjectID( anIObject->getEntry() ) ); - for (_PTR(ChildIterator) iit (aStudy->NewChildIterator(obj)); iit->More(); iit->Next()) { - _PTR(SObject) child (iit->Value()); - QString aName = child->GetName(); - if (aName != "" && aName.ref(0) != '*') { - aNameList.append(" - " + aName + "\n"); - nbSel++; - //append childs child - for (_PTR(ChildIterator) iitt(aStudy->NewChildIterator(child)); iitt->More(); iitt->Next()) { - _PTR(SObject) childchild(iitt->Value()); - QString aName = childchild->GetName(); - if (aName != "" && aName.ref(0) != '*') { - aNameList.append(" - " + aName + "\n"); - nbSel++; - for (_PTR(ChildIterator) itt(aStudy->NewChildIterator(childchild)); itt->More(); itt->Next()) - { - _PTR(SObject) childs(itt->Value()); - QString aName = childs->GetName(); - if (aName != "" && aName.ref(0) != '*') { - aNameList.append(" - " + aName + "\n"); - nbSel++; - } - } - } - } - } - } //end of child append - - GEOMBase_aWarningDlg* Dialog = new GEOMBase_aWarningDlg( app->desktop(), QObject::tr( "GEOM_WRN_WARNING" ), aNameList, nbSel); - int r = Dialog->exec(); - - if (!r) - return; - - // QAD_Operation* op = new SALOMEGUI_ImportOperation(.....); - // op->start(); - - // prepare list of SALOME_Views - QPtrList views; - SALOME_View* view; - // fill the list - ViewManagerList vmans = app->viewManagers(); - SUIT_ViewManager* vman; - for ( vman = vmans.first(); vman; vman = vmans.next() ) { - SUIT_ViewModel* vmod = vman->getViewModel(); - view = dynamic_cast ( vmod ); // must work for OCC and VTK views - if ( view ) - views.append( view ); - } + if ( !app ) + return; - _PTR(StudyBuilder) aStudyBuilder (aStudy->NewBuilder()); - _PTR(GenericAttribute) anAttr; - GEOM_Displayer* disp = new GEOM_Displayer( appStudy ); + LightApp_SelectionMgr* aSelMgr = app->selectionMgr(); + SalomeApp_Study* appStudy = dynamic_cast( app->activeStudy() ); + if ( !aSelMgr || !appStudy ) + return; - _PTR(SComponent) aGeom ( aStudy->FindComponent("GEOM") ); - if ( !aGeom ) - return; - - // MAIN LOOP OF SELECTED OBJECTS - for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) { - - Handle(SALOME_InteractiveObject) io = It.Value(); - if ( !io->hasEntry() ) - continue; - - _PTR(SObject) obj ( aStudy->FindObjectID( io->getEntry() ) ); - - // disable removal of "Geometry" component object - if ( !strcmp( obj->GetIOR().c_str(), geomIOR ) ) - continue; - - //If the object has been used to create another one,then it can't be deleted - // _PTR(ChildIterator) it (aStudy->NewChildIterator(aGeom)); - // for ( it->InitEx( true ); it->More(); it->Next() ) { - - for (_PTR(ChildIterator) it (aStudy->NewChildIterator(aGeom)); it->More(); it->Next()) { - _PTR(SObject) chobj (it->Value()); - if(CheckSubObjectInUse(chobj, obj, aStudy)) return; - //check subobjects - for (_PTR(ChildIterator) it (aStudy->NewChildIterator(obj)); it->More(); it->Next()) { - _PTR(SObject) child (it->Value()); - if(CheckSubObjectInUse( chobj, child, aStudy)) return; - //check subchildobject - for (_PTR(ChildIterator) it (aStudy->NewChildIterator(child)); it->More(); it->Next()) { - _PTR(SObject) subchildobj (it->Value()); - if(CheckSubObjectInUse( chobj, subchildobj, aStudy)) return; - } - } - } - - RemoveObjectWithChildren(obj, aStudy, views, disp); - - // Remove objects from Study - aStudyBuilder->RemoveObjectWithChildren( obj ); - - //deleted = true; - } // MAIN LOOP of selected - - selected.Clear(); - aSelMgr->setSelectedObjects( selected ); - getGeometryGUI()->updateObjBrowser(); - } // if ( selected not empty ) - } // if ( selMgr && appStudy ) - - app->updateActions(); //SRN: To update a Save button in the toolbar - - } // if ( app ) + // get selection + aSelMgr->selectedObjects( selected, "ObjectBrowser", false ); + if ( selected.IsEmpty() ) + return; + _PTR(Study) aStudy = appStudy->studyDS(); + + // check if study is locked + if ( _PTR(AttributeStudyProperties)( aStudy->GetProperties() )->IsLocked() ) { + SUIT_MessageBox::warn1( app->desktop(), + tr("WRN_WARNING"), + tr("WRN_STUDY_LOCKED"), + tr("BUT_OK") ); + return; // study is locked + } + + // get GEOM component + CORBA::String_var geomIOR = app->orb()->object_to_string( GeometryGUI::GetGeomGen() ); + QString geomComp = getParentComponent( aStudy->FindObjectIOR( geomIOR.in() ) ); + + // check each selected object: if belongs to GEOM, if not reference... + QMap toBeDeleted; + QMap allDeleted; + bool isComponentSelected = false; + for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) { + Handle(SALOME_InteractiveObject) anIObject = It.Value(); + if ( !anIObject->hasEntry() ) + continue; // invalid object + // ... + QString entry = anIObject->getEntry(); + _PTR(SObject) obj = aStudy->FindObjectID( entry.latin1() ); + // check parent component + QString parentComp = getParentComponent( obj ); + if ( parentComp != geomComp ) { + SUIT_MessageBox::warn1( app->desktop(), + QObject::tr("ERR_ERROR"), + QObject::tr("NON_GEOM_OBJECTS_SELECTED").arg( getGeometryGUI()->moduleName() ), + QObject::tr("BUT_OK") ); + return; // not GEOM object selected + } - // if ( deleted ) - // op->finish(); - // else - // op->abort(); + /////////////////////////////////////////////////////// + // if GEOM component is selected, so skip other checks + if ( isComponentSelected ) continue; + /////////////////////////////////////////////////////// + + // check if object is reference + _PTR(SObject) refobj; + if ( obj && obj->ReferencedObject( refobj ) ) + continue; // skip references + // ... + QString aName = obj->GetName().c_str(); + if ( entry == geomComp ) { + // GEOM component is selected, skip other checks + isComponentSelected = true; + continue; + } + toBeDeleted.insert( entry, aName ); + allDeleted.insert( entry, aName ); // skip GEOM component + // browse through all children recursively + _PTR(ChildIterator) it ( aStudy->NewChildIterator( obj ) ); + for ( it->InitEx( true ); it->More(); it->Next() ) { + _PTR(SObject) child( it->Value() ); + if ( child && child->ReferencedObject( refobj ) ) + continue; // skip references + aName = child->GetName().c_str(); + if ( !aName.isEmpty() ) + allDeleted.insert( child->GetID().c_str(), aName ); + } + } + + // is there is anything to delete? + if ( !isComponentSelected && allDeleted.count() <= 0 ) + return; // nothing to delete + + // show confirmation dialog box + GEOMToolsGUI_DeleteDlg dlg( app->desktop(), allDeleted, isComponentSelected ); + if ( !dlg.exec() ) + return; // operation is cancelled by user + + // get currently opened views + QPtrList views; + SALOME_View* view; + ViewManagerList vmans = app->viewManagers(); + SUIT_ViewManager* vman; + for ( vman = vmans.first(); vman; vman = vmans.next() ) { + SUIT_ViewModel* vmod = vman->getViewModel(); + view = dynamic_cast ( vmod ); // must work for OCC and VTK views + if ( view ) + views.append( view ); + } + + _PTR(StudyBuilder) aStudyBuilder (aStudy->NewBuilder()); + GEOM_Displayer* disp = new GEOM_Displayer( appStudy ); + + if ( isComponentSelected ) { + // GEOM component is selected: delete all objects recursively + _PTR(SObject) comp = aStudy->FindObjectID( geomComp.latin1() ); + if ( !comp ) + return; + _PTR(ChildIterator) it ( aStudy->NewChildIterator( comp ) ); + // remove top-level objects only + for ( it->InitEx( false ); it->More(); it->Next() ) { + _PTR(SObject) child( it->Value() ); + // remove object from GEOM engine + removeObjectWithChildren( child, aStudy, views, disp ); + // remove object from study + aStudyBuilder->RemoveObjectWithChildren( child ); + } + } + else { + // GEOM component is not selected: check if selected objects are in use + if ( inUse( aStudy, geomComp, allDeleted ) ) { + SUIT_MessageBox::warn1( app->desktop(), + QObject::tr("WRN_WARNING"), + QObject::tr("DEP_OBJECT"), + QObject::tr("BUT_OK") ); + return; // object(s) in use + } + // ... and then delete all objects + QMap::Iterator it; + for ( it = toBeDeleted.begin(); it != toBeDeleted.end(); ++it ) { + _PTR(SObject) obj ( aStudy->FindObjectID( it.key().latin1() ) ); + // remove object from GEOM engine + removeObjectWithChildren( obj, aStudy, views, disp ); + // remove objects from study + aStudyBuilder->RemoveObjectWithChildren( obj ); + } + } + + selected.Clear(); + aSelMgr->setSelectedObjects( selected ); + getGeometryGUI()->updateObjBrowser(); + app->updateActions(); //SRN: To update a Save button in the toolbar } @@ -712,50 +753,11 @@ bool GEOMToolsGUI::Export() return true; } - -QString GEOMToolsGUI::getParentComponent( _PTR( Study ) study, const SALOME_ListIO& iobjs ) -{ - QString parentComp; - - for ( SALOME_ListIteratorOfListIO it( iobjs ); it.More(); it.Next() ) { - - Handle(SALOME_InteractiveObject) io = it.Value(); - if ( !io->hasEntry() ) - continue; - - QString compName = getParentComponent( study->FindObjectID( io->getEntry() ) ); - - if ( parentComp.isNull() ) - parentComp = compName; - else if ( parentComp.compare( compName) != 0 ) { // objects belonging to different components are selected - parentComp = QString::null; - break; - } - } - - return parentComp; -} - -QString GEOMToolsGUI::getParentComponent( _PTR( SObject ) obj ) -{ - if ( obj ) { - _PTR(SComponent) comp = obj->GetFatherComponent(); - if ( comp ) { - _PTR(GenericAttribute) anAttr; - if ( comp->FindAttribute( anAttr, "AttributeName") ) { - _PTR(AttributeName) aName( anAttr ); - return QString( aName->Value().c_str() ); - } - } - } - return QString(); -} - //===================================================================================== // function : RemoveObjectWithChildren // purpose : to be used by OnEditDelete() method //===================================================================================== -void GEOMToolsGUI::RemoveObjectWithChildren(_PTR(SObject) obj, +void GEOMToolsGUI::removeObjectWithChildren(_PTR(SObject) obj, _PTR(Study) aStudy, QPtrList views, GEOM_Displayer* disp) @@ -763,7 +765,7 @@ void GEOMToolsGUI::RemoveObjectWithChildren(_PTR(SObject) obj, // iterate through all children of obj for (_PTR(ChildIterator) it (aStudy->NewChildIterator(obj)); it->More(); it->Next()) { _PTR(SObject) child (it->Value()); - RemoveObjectWithChildren(child, aStudy, views, disp); + removeObjectWithChildren(child, aStudy, views, disp); } // erase object and remove it from engine @@ -790,41 +792,6 @@ void GEOMToolsGUI::RemoveObjectWithChildren(_PTR(SObject) obj, } } -//===================================================================================== -// function : CheckSubObjectInUse -// purpose : to be used by OnEditDelete() method -//===================================================================================== -bool GEOMToolsGUI::CheckSubObjectInUse(_PTR(SObject) checkobj, - _PTR(SObject) remobj, - _PTR(Study) aStudy) -{ - CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject(checkobj); - GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( corbaObj ); - - CORBA::Object_var corbaObj_rem = GeometryGUI::ClientSObjectToObject(remobj); - GEOM::GEOM_Object_var geomObj_rem = GEOM::GEOM_Object::_narrow( corbaObj_rem ); - - if( CORBA::is_nil(geomObj) || CORBA::is_nil(geomObj_rem)) - return false; - - GEOM::ListOfGO_var list = geomObj->GetDependency(); - if( list->length() > 0 ) - for(int i = 0; i < list->length(); i++ ){ - if( list[i]->_is_equivalent( geomObj_rem ) ){ - SalomeApp_Application* app = - dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); - - SUIT_MessageBox::warn1 ( app->desktop(), - QObject::tr("WRN_WARNING"), - QObject::tr("DEP_OBJECT"), - QObject::tr("BUT_OK") ); - return true; - } - } - - return false; -} - //================================================================================= // function : deactivate() // purpose : Called when GEOM component is deactivated diff --git a/src/GEOMToolsGUI/GEOMToolsGUI.h b/src/GEOMToolsGUI/GEOMToolsGUI.h index 69ad114d1..36fb6a8d0 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI.h +++ b/src/GEOMToolsGUI/GEOMToolsGUI.h @@ -65,8 +65,6 @@ private: void OnEditDelete(); void OnSettingsColor(); - void OnSettingsIsos(); - void OnSettingsStep(); void OnRename(); void OnCheckGeometry(); @@ -79,21 +77,11 @@ private: void OnOpen(); void OnSelectOnly(int mode); - // returns name of Module (Component) of given objects (usually selected objects) - // if objects belong to different Components, a NULL string is returned. - QString getParentComponent( _PTR( Study ), const SALOME_ListIO& ); - QString getParentComponent( _PTR(SObject) ); - // Recursive deletion of object with children - void RemoveObjectWithChildren(_PTR(SObject) obj, + void removeObjectWithChildren(_PTR(SObject) obj, _PTR(Study) aStudy, QPtrList views, GEOM_Displayer* disp); - - //checks if the object passed as the first argument depends on the second arguments - bool CheckSubObjectInUse(_PTR(SObject) checkobj, - _PTR(SObject) remobj, - _PTR(Study) aStudy); }; #endif diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_DeleteDlg.cxx b/src/GEOMToolsGUI/GEOMToolsGUI_DeleteDlg.cxx new file mode 100644 index 000000000..e0f7f93f9 --- /dev/null +++ b/src/GEOMToolsGUI/GEOMToolsGUI_DeleteDlg.cxx @@ -0,0 +1,131 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : GEOMToolsGUI_DeleteDlg.cxx +// Author : Dmitry Matveitchev, Open CASCADE S.A.S. +// + +#include "GEOMToolsGUI_DeleteDlg.h" + +#include +#include +#include +#include +#include +#include +#include + +static bool isEntryLess( const QString& e1, const QString& e2 ) +{ + QStringList el1 = QStringList::split(":", e1); + QStringList el2 = QStringList::split(":", e2); + int e1c = el1.count(), e2c = el2.count(); + for ( int i = 0; i < e1c && i < e2c; i++ ) { + int id1 = el1[i].toInt(); + int id2 = el2[i].toInt(); + if ( id1 < id2 ) return true; + else if ( id2 < id1 ) return false; + } + return el1.count() < el2.count(); +} + +static QStringList objectsToNames( const QMap& objects ) +{ + QStringList entries; + for ( QMap::ConstIterator it = objects.begin(); it != objects.end(); ++it ) { + QString entry = it.key(); + QStringList::Iterator it; + bool added = false; + for ( it = entries.begin(); it != entries.end() && !added; ++it ) { + if ( isEntryLess( entry, *it ) ) { + entries.insert( it, entry ); + added = true; + } + } + if ( !added ) + entries.append( entry ); + } + QStringList names; + for ( int i = 0; i < entries.count(); i++ ) { + int level = entries[i].contains(":")-3; + QString prefix; prefix.fill( ' ', level*2 ); + names.append( prefix + objects[ entries[i] ] ); + } + return names; +} + +/*! + \brief Constructor. + \param parent parent widget +*/ +GEOMToolsGUI_DeleteDlg::GEOMToolsGUI_DeleteDlg( QWidget* parent, + const QMap& objects, + bool deleteAll ) +: QDialog( parent, "GEOMToolsGUI_DeleteDlg", true ) +{ + setCaption( tr( "GEOM_DELETE_OBJECTS" ) ); + setSizeGripEnabled( true ); + + QGridLayout* topLayout = new QGridLayout( this ); + + topLayout->setSpacing( 6 ); + topLayout->setMargin( 11 ); + + QLabel* pix = new QLabel( this ); + pix->setPixmap( QMessageBox::standardIcon( QMessageBox::Question ) ); + pix->setScaledContents( false ); + pix->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); + topLayout->addWidget( pix, 0, 0 ); + + QLabel* lab = new QLabel( this ); + lab->setAlignment( Qt::AlignCenter ); + topLayout->addWidget( lab, 0, 1 ); + + if ( !deleteAll ) { + lab->setText( tr( "GEOM_REALLY_DELETE" ).arg( objects.count() ) ); + QTextBrowser* viewer = new QTextBrowser( this ); + viewer->setText( QString( " - %1" ).arg( objectsToNames( objects ).join( "\n - " ) ) ); + topLayout->addMultiCellWidget( viewer, 1, 1, 0, 1 ); + } + else { + lab->setText( tr( "GEOM_REALLY_DELETE_ALL" ) ); + } + + QPushButton* buttonYes = new QPushButton( tr( "GEOM_BUT_YES" ), this ); + QPushButton* buttonNo = new QPushButton( tr( "GEOM_BUT_NO" ), this ); + QHBoxLayout* btnLayout = new QHBoxLayout; + btnLayout->setMargin( 0 ); + btnLayout->setSpacing( 6 ); + btnLayout->addWidget( buttonYes ); + btnLayout->addSpacing( 10 ); + btnLayout->addStretch(); + btnLayout->addWidget( buttonNo ); + int rc = topLayout->numRows(); + topLayout->addMultiCellLayout( btnLayout, rc, rc, 0, 1 ); + + /* signals and slots connections */ + connect( buttonYes, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( buttonNo, SIGNAL( clicked() ), this, SLOT( reject() ) ); +} + +GEOMToolsGUI_DeleteDlg::~GEOMToolsGUI_DeleteDlg() +{ +} diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_DeleteDlg.h b/src/GEOMToolsGUI/GEOMToolsGUI_DeleteDlg.h new file mode 100644 index 000000000..d178dac3b --- /dev/null +++ b/src/GEOMToolsGUI/GEOMToolsGUI_DeleteDlg.h @@ -0,0 +1,41 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : GEOMToolsGUI_DeleteDlg.h +// Author : Dmitry Matveitchev, Open CASCADE S.A.S. +// + +#ifndef GEOMTOOLSGUI_DELETEDLG_H +#define GEOMTOOLSGUI_DELETEDLG_H + +#include +#include + +class GEOMToolsGUI_DeleteDlg : public QDialog +{ + Q_OBJECT + +public: + GEOMToolsGUI_DeleteDlg( QWidget*, const QMap&, bool = false ); + ~GEOMToolsGUI_DeleteDlg(); +}; + +#endif // GEOMTOOLSGUI_DELETEDLG_H diff --git a/src/GEOMToolsGUI/Makefile.am b/src/GEOMToolsGUI/Makefile.am index 45092979a..da6bcb0d3 100644 --- a/src/GEOMToolsGUI/Makefile.am +++ b/src/GEOMToolsGUI/Makefile.am @@ -36,14 +36,22 @@ lib_LTLIBRARIES = libGEOMToolsGUI.la salomeinclude_HEADERS = dist_libGEOMToolsGUI_la_SOURCES = \ - GEOMToolsGUI.cxx \ - GEOMToolsGUI_1.cxx \ - GEOMToolsGUI_TransparencyDlg.cxx \ - GEOMToolsGUI_NbIsosDlg.cxx + GEOM_ToolsGUI.hxx \ + GEOMToolsGUI.h \ + GEOMToolsGUI_NbIsosDlg.h \ + GEOMToolsGUI_TransparencyDlg.h \ + GEOMToolsGUI_DeleteDlg.h \ + \ + GEOMToolsGUI.cxx \ + GEOMToolsGUI_1.cxx \ + GEOMToolsGUI_TransparencyDlg.cxx \ + GEOMToolsGUI_NbIsosDlg.cxx \ + GEOMToolsGUI_DeleteDlg.cxx MOC_FILES = \ - GEOMToolsGUI_TransparencyDlg_moc.cxx \ - GEOMToolsGUI_NbIsosDlg_moc.cxx + GEOMToolsGUI_TransparencyDlg_moc.cxx \ + GEOMToolsGUI_NbIsosDlg_moc.cxx \ + GEOMToolsGUI_DeleteDlg_moc.cxx nodist_libGEOMToolsGUI_la_SOURCES= \ $(MOC_FILES)