Bugs 16640, 19050: Improve selection mechanism in GEOM dialog boxes.

This commit is contained in:
jfa 2008-09-29 12:14:55 +00:00
parent 54666ebd00
commit 0dd54298d5
3 changed files with 496 additions and 462 deletions

View File

@ -1,22 +1,22 @@
// GEOM GEOMGUI : GUI for Geometry component // GEOM GEOMGUI : GUI for Geometry component
// //
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either // License as published by the Free Software Foundation; either
// version 2.1 of the License. // version 2.1 of the License.
// //
// This library is distributed in the hope that it will be useful, // This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details. // Lesser General Public License for more details.
// //
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
// //
// File : RepairGUI_CloseContourDlg.cxx // File : RepairGUI_CloseContourDlg.cxx
@ -29,17 +29,18 @@
#include <GeometryGUI.h> #include <GeometryGUI.h>
#include <GEOMBase.h> #include <GEOMBase.h>
#include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h>
#include <SUIT_Session.h> #include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h> #include <SUIT_ResourceMgr.h>
#include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h>
// OCCT Includes
#include <TopAbs.hxx>
#include <TColStd_MapOfInteger.hxx>
#include <TColStd_IndexedMapOfInteger.hxx>
#include <GEOMImpl_Types.hxx> #include <GEOMImpl_Types.hxx>
#include <TopAbs.hxx>
#include <TColStd_IndexedMapOfInteger.hxx>
#include <TColStd_MapOfInteger.hxx>
//================================================================================= //=================================================================================
// class : RepairGUI_CloseContourDlg() // class : RepairGUI_CloseContourDlg()
// purpose : Constructs a RepairGUI_CloseContourDlg which is a child of 'parent', with the // purpose : Constructs a RepairGUI_CloseContourDlg which is a child of 'parent', with the
@ -47,58 +48,56 @@
// The dialog will by default be modeless, unless you set 'modal' to // The dialog will by default be modeless, unless you set 'modal' to
// TRUE to construct a modal dialog. // TRUE to construct a modal dialog.
//================================================================================= //=================================================================================
RepairGUI_CloseContourDlg::RepairGUI_CloseContourDlg( GeometryGUI* theGeometryGUI, QWidget* parent, RepairGUI_CloseContourDlg::RepairGUI_CloseContourDlg (GeometryGUI* theGeometryGUI, QWidget* parent,
bool modal ) bool modal)
: GEOMBase_Skeleton( theGeometryGUI, parent, modal ) : GEOMBase_Skeleton(theGeometryGUI, parent, modal)
{ {
QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_CLOSECONTOUR" ) ) ); QPixmap image0 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_CLOSECONTOUR")));
QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) ); QPixmap image1 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT")));
setWindowTitle( tr( "GEOM_CLOSECONTOUR_TITLE" ) ); setWindowTitle(tr("GEOM_CLOSECONTOUR_TITLE"));
/***************************************************************/ /***************************************************************/
mainFrame()->GroupConstructors->setTitle( tr( "GEOM_CLOSECONTOUR_TITLE" ) ); mainFrame()->GroupConstructors->setTitle(tr("GEOM_CLOSECONTOUR_TITLE"));
mainFrame()->RadioButton1->setIcon( image0 ); mainFrame()->RadioButton1->setIcon(image0);
mainFrame()->RadioButton2->setAttribute( Qt::WA_DeleteOnClose ); mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose);
mainFrame()->RadioButton2->close(); mainFrame()->RadioButton2->close();
mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose ); mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
mainFrame()->RadioButton3->close(); mainFrame()->RadioButton3->close();
GroupPoints = new DlgRef_2SelExt( centralWidget() ); GroupPoints = new DlgRef_2SelExt(centralWidget());
GroupPoints->GroupBox1->setTitle( tr( "Contour to close" ) ); GroupPoints->GroupBox1->setTitle(tr("Contour to close"));
GroupPoints->TextLabel1->setText( tr( "GEOM_SELECTED_SHAPE" ) ); GroupPoints->TextLabel1->setText(tr("GEOM_SELECTED_SHAPE"));
GroupPoints->PushButton1->setIcon( image1 ); GroupPoints->PushButton1->setIcon(image1);
GroupPoints->LineEdit1->setReadOnly( true ); GroupPoints->LineEdit1->setReadOnly(true);
GroupPoints->TextLabel2->setText( tr( "Contour to close" ) ); GroupPoints->TextLabel2->setText(tr("Contour to close"));
GroupPoints->PushButton2->setIcon( image1 ); GroupPoints->PushButton2->setIcon(image1);
GroupPoints->LineEdit2->setReadOnly( true ); GroupPoints->LineEdit2->setReadOnly(true);
QRadioButton* rb1 = new QRadioButton( tr( "Close by common vertex" ), GroupPoints->Box ); QRadioButton* rb1 = new QRadioButton(tr("Close by common vertex"), GroupPoints->Box);
QRadioButton* rb2 = new QRadioButton( tr( "Close by new edge" ), GroupPoints->Box ); QRadioButton* rb2 = new QRadioButton(tr("Close by new edge"), GroupPoints->Box);
myIsVertexGr = new QButtonGroup( GroupPoints->Box ); myIsVertexGr = new QButtonGroup(GroupPoints->Box);
myIsVertexGr->addButton( rb1, 0 ); myIsVertexGr->addButton(rb1, 0);
myIsVertexGr->addButton( rb2, 1 ); myIsVertexGr->addButton(rb2, 1);
rb1->setChecked( true ); rb1->setChecked(true);
QVBoxLayout* l = new QVBoxLayout( GroupPoints->Box ); QVBoxLayout* l = new QVBoxLayout(GroupPoints->Box);
l->setMargin( 0 ); l->setSpacing( 6 ); l->setMargin(0); l->setSpacing(6);
l->addWidget( rb1 ); l->addWidget(rb1);
l->addWidget( rb2 ); l->addWidget(rb2);
QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
layout->setMargin( 0 ); layout->setSpacing( 6 );
layout->addWidget( GroupPoints );
QVBoxLayout* layout = new QVBoxLayout(centralWidget());
layout->setMargin(0); layout->setSpacing(6);
layout->addWidget(GroupPoints);
/***************************************************************/ /***************************************************************/
setHelpFileName( "close_contour_operation_page.html" ); setHelpFileName("close_contour_operation_page.html");
Init(); Init();
} }
//================================================================================= //=================================================================================
// function : ~RepairGUI_CloseContourDlg() // function : ~RepairGUI_CloseContourDlg()
// purpose : Destroys the object and frees any allocated resources // purpose : Destroys the object and frees any allocated resources
@ -107,116 +106,110 @@ RepairGUI_CloseContourDlg::~RepairGUI_CloseContourDlg()
{ {
} }
//================================================================================= //=================================================================================
// function : Init() // function : Init()
// purpose : // purpose :
//================================================================================= //=================================================================================
void RepairGUI_CloseContourDlg::Init() void RepairGUI_CloseContourDlg::Init()
{ {
/* init variables */ // init variables
myEditCurrentArgument = GroupPoints->LineEdit1; GroupPoints->LineEdit1->clear();
GroupPoints->LineEdit2->clear();
myObject = GEOM::GEOM_Object::_nil(); myObject = GEOM::GEOM_Object::_nil();
myWiresInd = new GEOM::short_array(); myWiresInd = new GEOM::short_array();
myWiresInd->length( 0 ); myWiresInd->length(0);
//myGeomGUI->SetState( 0 );
initSelection();
/* signals and slots connections */ // signals and slots connections
connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ); connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect( GroupPoints->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect( GroupPoints->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( GroupPoints->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( myGeomGUI->getApp()->selectionMgr(), connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
initName( tr( "CLOSE_CONTOUR_NEW_OBJ_NAME" ) ); initName(tr("CLOSE_CONTOUR_NEW_OBJ_NAME"));
GroupPoints->PushButton1->click();
SelectionIntoArgument();
} }
//================================================================================= //=================================================================================
// function : ClickOnOk() // function : ClickOnOk()
// purpose : Same than click on apply but close this dialog. // purpose : Same than click on apply but close this dialog.
//================================================================================= //=================================================================================
void RepairGUI_CloseContourDlg::ClickOnOk() void RepairGUI_CloseContourDlg::ClickOnOk()
{ {
if ( ClickOnApply() ) if (ClickOnApply())
ClickOnCancel(); ClickOnCancel();
} }
//================================================================================= //=================================================================================
// function : ClickOnApply() // function : ClickOnApply()
// purpose : // purpose :
//================================================================================= //=================================================================================
bool RepairGUI_CloseContourDlg::ClickOnApply() bool RepairGUI_CloseContourDlg::ClickOnApply()
{ {
if ( !onAccept() ) if (!onAccept())
return false; return false;
initName(); initName();
// activate first line edit
myEditCurrentArgument = GroupPoints->LineEdit1; GroupPoints->PushButton1->click();
myEditCurrentArgument->setText( "" );
myObject = GEOM::GEOM_Object::_nil();
myWiresInd->length( 0 );
initSelection();
return true; return true;
} }
//================================================================================= //=================================================================================
// function : SelectionIntoArgument() // function : SelectionIntoArgument()
// purpose : Called when selection as changed or other case // purpose : Called when selection is changed or on dialog initialization or activation
// : used only by SelectButtonC1A1 (LineEditC1A1)
//================================================================================= //=================================================================================
void RepairGUI_CloseContourDlg::SelectionIntoArgument() void RepairGUI_CloseContourDlg::SelectionIntoArgument()
{ {
erasePreview(); myEditCurrentArgument->setText("");
myEditCurrentArgument->setText( "" ); // the second argument depends on the first one
GroupPoints->LineEdit2->setText( "" ); GroupPoints->LineEdit2->setText("");
myWiresInd->length(0);
if ( myEditCurrentArgument == GroupPoints->LineEdit1 )
if (myEditCurrentArgument == GroupPoints->LineEdit1)
myObject = GEOM::GEOM_Object::_nil(); myObject = GEOM::GEOM_Object::_nil();
else if ( myEditCurrentArgument == GroupPoints->LineEdit2 )
myWiresInd->length( 0 );
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
SALOME_ListIO aSelList; SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList); aSelMgr->selectedObjects(aSelList);
if ( aSelList.Extent() == 1 ) { if (aSelList.Extent() == 1) {
Handle(SALOME_InteractiveObject) anIO = aSelList.First(); Handle(SALOME_InteractiveObject) anIO = aSelList.First();
if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) { // face selection if (myEditCurrentArgument == GroupPoints->LineEdit1) { // face selection
Standard_Boolean aRes; Standard_Boolean aRes;
myObject = GEOMBase::ConvertIOinGEOMObject( anIO, aRes ); myObject = GEOMBase::ConvertIOinGEOMObject(anIO, aRes);
if ( aRes && GEOMBase::IsShape( myObject ) ) { if (aRes && GEOMBase::IsShape(myObject)) {
myEditCurrentArgument->setText( GEOMBase::GetName( myObject ) ); myEditCurrentArgument->setText(GEOMBase::GetName(myObject));
TopoDS_Shape aShape; TopoDS_Shape aShape;
if ( GEOMBase::GetShape( myObject, aShape, TopAbs_WIRE ) ) if (GEOMBase::GetShape(myObject, aShape, TopAbs_WIRE))
GroupPoints->LineEdit2->setText( myEditCurrentArgument->text() ); GroupPoints->LineEdit2->setText(myEditCurrentArgument->text());
// clear selection
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
myGeomGUI->getApp()->selectionMgr()->clearSelected();
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
GroupPoints->PushButton2->click();
} }
else else
myObject = GEOM::GEOM_Object::_nil(); myObject = GEOM::GEOM_Object::_nil();
} }
else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) { else if (myEditCurrentArgument == GroupPoints->LineEdit2) {
TColStd_IndexedMapOfInteger aMap; TColStd_IndexedMapOfInteger aMap;
aSelMgr->GetIndexes( anIO, aMap ); aSelMgr->GetIndexes(anIO, aMap);
const int n = aMap.Extent(); const int n = aMap.Extent();
myWiresInd->length( n ); myWiresInd->length(n);
for ( int i = 1; i <= n; i++ ) for (int i = 1; i <= n; i++)
myWiresInd[ i-1 ] = aMap( i ); myWiresInd[i-1] = aMap(i);
if ( n ) if (n)
myEditCurrentArgument->setText( QString::number( n ) + "_" + tr( "GEOM_WIRE" ) + tr( "_S_" ) ); myEditCurrentArgument->setText(QString::number(n) + "_" + tr("GEOM_WIRE") + tr("_S_"));
} }
} }
} }
@ -227,19 +220,36 @@ void RepairGUI_CloseContourDlg::SelectionIntoArgument()
//================================================================================= //=================================================================================
void RepairGUI_CloseContourDlg::SetEditCurrentArgument() void RepairGUI_CloseContourDlg::SetEditCurrentArgument()
{ {
const QObject* send = sender(); QPushButton* send = (QPushButton*)sender();
if ( send == GroupPoints->PushButton1 )
myEditCurrentArgument = GroupPoints->LineEdit1; bool isEffective = false;
else if ( send == GroupPoints->PushButton2 && !myObject->_is_nil() )
if (send == GroupPoints->PushButton1) {
isEffective = true;
myEditCurrentArgument = GroupPoints->LineEdit1;
GroupPoints->PushButton2->setDown(false);
GroupPoints->LineEdit2->setEnabled(false);
}
else if (send == GroupPoints->PushButton2 && !myObject->_is_nil()) {
isEffective = true;
myEditCurrentArgument = GroupPoints->LineEdit2; myEditCurrentArgument = GroupPoints->LineEdit2;
if ( myEditCurrentArgument ) {
GroupPoints->PushButton1->setDown(false);
GroupPoints->LineEdit1->setEnabled(false);
}
if (isEffective) {
initSelection(); initSelection();
// enable line edit
myEditCurrentArgument->setEnabled(true);
myEditCurrentArgument->setFocus(); myEditCurrentArgument->setFocus();
SelectionIntoArgument(); // after setFocus(), because it will be setDown(false) when loses focus
send->setDown(true);
} }
} }
//================================================================================= //=================================================================================
// function : LineEditReturnPressed() // function : LineEditReturnPressed()
// purpose : // purpose :
@ -247,13 +257,12 @@ void RepairGUI_CloseContourDlg::SetEditCurrentArgument()
void RepairGUI_CloseContourDlg::LineEditReturnPressed() void RepairGUI_CloseContourDlg::LineEditReturnPressed()
{ {
const QObject* send = sender(); const QObject* send = sender();
if ( send == GroupPoints->LineEdit1 || send == GroupPoints->LineEdit2 ) { if (send == GroupPoints->LineEdit1 || send == GroupPoints->LineEdit2) {
myEditCurrentArgument = (QLineEdit*)send; myEditCurrentArgument = (QLineEdit*)send;
GEOMBase_Skeleton::LineEditReturnPressed(); GEOMBase_Skeleton::LineEditReturnPressed();
} }
} }
//================================================================================= //=================================================================================
// function : ActivateThisDialog() // function : ActivateThisDialog()
// purpose : // purpose :
@ -261,61 +270,54 @@ void RepairGUI_CloseContourDlg::LineEditReturnPressed()
void RepairGUI_CloseContourDlg::ActivateThisDialog() void RepairGUI_CloseContourDlg::ActivateThisDialog()
{ {
GEOMBase_Skeleton::ActivateThisDialog(); GEOMBase_Skeleton::ActivateThisDialog();
connect( myGeomGUI->getApp()->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
myEditCurrentArgument = GroupPoints->LineEdit1; // reinit, because some selected objects could be removed
myEditCurrentArgument->setText( "" ); Init();
GroupPoints->LineEdit2->setText( "" );
myObject = GEOM::GEOM_Object::_nil();
myWiresInd->length( 0 );
//myGeomGUI->SetState( 0 );
initSelection();
} }
//================================================================================= //=================================================================================
// function : enterEvent() // function : enterEvent()
// purpose : Mouse enter onto the dialog to activate it // purpose : Mouse enter onto the dialog to activate it
//================================================================================= //=================================================================================
void RepairGUI_CloseContourDlg::enterEvent( QEvent* ) void RepairGUI_CloseContourDlg::enterEvent (QEvent*)
{ {
if ( !mainFrame()->GroupConstructors->isEnabled() ) if (!mainFrame()->GroupConstructors->isEnabled())
ActivateThisDialog(); ActivateThisDialog();
} }
//================================================================================= //=================================================================================
// function : createOperation // function : createOperation
// purpose : // purpose :
//================================================================================= //=================================================================================
GEOM::GEOM_IOperations_ptr RepairGUI_CloseContourDlg::createOperation() GEOM::GEOM_IOperations_ptr RepairGUI_CloseContourDlg::createOperation()
{ {
return getGeomEngine()->GetIHealingOperations( getStudyId() ); return getGeomEngine()->GetIHealingOperations(getStudyId());
} }
//================================================================================= //=================================================================================
// function : isValid // function : isValid
// purpose : // purpose :
//================================================================================= //=================================================================================
bool RepairGUI_CloseContourDlg::isValid( QString& ) bool RepairGUI_CloseContourDlg::isValid (QString&)
{ {
TopoDS_Shape aTmpShape; TopoDS_Shape aTmpShape;
return !myObject->_is_nil() && ( myWiresInd->length() || GEOMBase::GetShape( myObject, aTmpShape, TopAbs_WIRE ) ); return !myObject->_is_nil() && (myWiresInd->length() ||
GEOMBase::GetShape(myObject, aTmpShape, TopAbs_WIRE));
} }
//================================================================================= //=================================================================================
// function : execute // function : execute
// purpose : // purpose :
//================================================================================= //=================================================================================
bool RepairGUI_CloseContourDlg::execute( ObjectList& objects ) bool RepairGUI_CloseContourDlg::execute (ObjectList& objects)
{ {
GEOM::GEOM_Object_var anObj = GEOM::GEOM_IHealingOperations::_narrow( getOperation() )->CloseContour( myObject, myWiresInd, getIsByVertex() ); GEOM::GEOM_Object_var anObj = GEOM::GEOM_IHealingOperations::_narrow(getOperation())->
CloseContour(myObject, myWiresInd, getIsByVertex());
bool aResult = !anObj->_is_nil(); bool aResult = !anObj->_is_nil();
if ( aResult ) if (aResult)
objects.push_back( anObj._retn() ); objects.push_back(anObj._retn());
return aResult; return aResult;
} }
@ -325,7 +327,7 @@ bool RepairGUI_CloseContourDlg::execute( ObjectList& objects )
//================================================================================= //=================================================================================
bool RepairGUI_CloseContourDlg::getIsByVertex() const bool RepairGUI_CloseContourDlg::getIsByVertex() const
{ {
return myIsVertexGr->button( 0 )->isChecked(); return myIsVertexGr->button(0)->isChecked();
} }
//================================================================================= //=================================================================================
@ -334,18 +336,23 @@ bool RepairGUI_CloseContourDlg::getIsByVertex() const
//================================================================================= //=================================================================================
void RepairGUI_CloseContourDlg::initSelection() void RepairGUI_CloseContourDlg::initSelection()
{ {
if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) { disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
if (myEditCurrentArgument == GroupPoints->LineEdit1) {
TColStd_MapOfInteger aTypes; TColStd_MapOfInteger aTypes;
aTypes.Add( GEOM_COMPOUND ); aTypes.Add(GEOM_COMPOUND);
aTypes.Add( GEOM_SOLID ); aTypes.Add(GEOM_SOLID);
aTypes.Add( GEOM_SHELL ); aTypes.Add(GEOM_SHELL);
aTypes.Add( GEOM_FACE ); aTypes.Add(GEOM_FACE);
aTypes.Add( GEOM_WIRE ); aTypes.Add(GEOM_WIRE);
globalSelection( aTypes ); globalSelection(aTypes);
} }
else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) { else if (myEditCurrentArgument == GroupPoints->LineEdit2) {
localSelection( myObject, TopAbs_EDGE ); localSelection(myObject, TopAbs_EDGE);
localSelection( myObject, TopAbs_WIRE ); localSelection(myObject, TopAbs_WIRE);
} }
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
} }

View File

@ -1,22 +1,22 @@
// GEOM GEOMGUI : GUI for Geometry component // GEOM GEOMGUI : GUI for Geometry component
// //
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either // License as published by the Free Software Foundation; either
// version 2.1 of the License. // version 2.1 of the License.
// //
// This library is distributed in the hope that it will be useful, // This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details. // Lesser General Public License for more details.
// //
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
// //
// File : RepairGUI_RemoveHolesDlg.cxx // File : RepairGUI_RemoveHolesDlg.cxx
@ -29,18 +29,19 @@
#include <GeometryGUI.h> #include <GeometryGUI.h>
#include <GEOMBase.h> #include <GEOMBase.h>
#include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h>
#include <SUIT_MessageBox.h>
#include <SUIT_Session.h> #include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h> #include <SUIT_ResourceMgr.h>
#include <SUIT_MessageBox.h>
#include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h>
#include <GEOMImpl_Types.hxx> // OCCT Includes
#include <TopAbs.hxx> #include <TopAbs.hxx>
#include <TColStd_MapOfInteger.hxx> #include <TColStd_MapOfInteger.hxx>
#include <TColStd_IndexedMapOfInteger.hxx> #include <TColStd_IndexedMapOfInteger.hxx>
#include <GEOMImpl_Types.hxx>
//================================================================================= //=================================================================================
// class : RepairGUI_RemoveHolesDlg() // class : RepairGUI_RemoveHolesDlg()
// purpose : Constructs a RepairGUI_RemoveHolesDlg which is a child of 'parent', with the // purpose : Constructs a RepairGUI_RemoveHolesDlg which is a child of 'parent', with the
@ -48,51 +49,49 @@
// The dialog will by default be modeless, unless you set 'modal' to // The dialog will by default be modeless, unless you set 'modal' to
// TRUE to construct a modal dialog. // TRUE to construct a modal dialog.
//================================================================================= //=================================================================================
RepairGUI_RemoveHolesDlg::RepairGUI_RemoveHolesDlg( GeometryGUI* theGeometryGUI, QWidget* parent, RepairGUI_RemoveHolesDlg::RepairGUI_RemoveHolesDlg (GeometryGUI* theGeometryGUI, QWidget* parent,
bool modal ) bool modal)
: GEOMBase_Skeleton( theGeometryGUI, parent, modal ) : GEOMBase_Skeleton(theGeometryGUI, parent, modal)
{ {
QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_SUPPRESS_HOLES" ) ) ); QPixmap image0 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_SUPPRESS_HOLES")));
QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) ); QPixmap image1 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT")));
setWindowTitle( tr( "GEOM_REMOVE_HOLES_TITLE" ) ); setWindowTitle(tr("GEOM_REMOVE_HOLES_TITLE"));
/***************************************************************/ /***************************************************************/
mainFrame()->GroupConstructors->setTitle( tr( "GEOM_REMOVE_HOLES_TITLE" ) ); mainFrame()->GroupConstructors->setTitle(tr("GEOM_REMOVE_HOLES_TITLE"));
mainFrame()->RadioButton1->setIcon( image0 ); mainFrame()->RadioButton1->setIcon(image0);
mainFrame()->RadioButton2->setAttribute( Qt::WA_DeleteOnClose ); mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose);
mainFrame()->RadioButton2->close(); mainFrame()->RadioButton2->close();
mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose ); mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
mainFrame()->RadioButton3->close(); mainFrame()->RadioButton3->close();
GroupPoints = new DlgRef_1Sel1Check1Sel( centralWidget() ); GroupPoints = new DlgRef_1Sel1Check1Sel(centralWidget());
GroupPoints->GroupBox1->setTitle( tr( "GEOM_HOLES" ) ); GroupPoints->GroupBox1->setTitle(tr("GEOM_HOLES"));
GroupPoints->TextLabel1->setText( tr( "GEOM_SELECTED_SHAPE" ) ); GroupPoints->TextLabel1->setText(tr("GEOM_SELECTED_SHAPE"));
GroupPoints->PushButton1->setIcon( image1 ); GroupPoints->PushButton1->setIcon(image1);
GroupPoints->LineEdit1->setReadOnly( true ); GroupPoints->LineEdit1->setReadOnly(true);
GroupPoints->CheckButton1->setText( tr( "GEOM_REMOVE_ALL_HOLES" ) ); GroupPoints->CheckButton1->setText(tr("GEOM_REMOVE_ALL_HOLES"));
GroupPoints->TextLabel2->setText( tr( "GEOM_WIRES_TO_REMOVE" ) ); GroupPoints->TextLabel2->setText(tr("GEOM_WIRES_TO_REMOVE"));
GroupPoints->PushButton2->setIcon( image1 ); GroupPoints->PushButton2->setIcon(image1);
GroupPoints->LineEdit2->setReadOnly( true ); GroupPoints->LineEdit2->setReadOnly(true);
myFreeBoundBtn = new QPushButton( tr( "GEOM_DETECT" ) + QString( " [%1]" ).arg( tr( "GEOM_FREE_BOUNDARIES" ) ),
GroupPoints->Box );
QVBoxLayout* l = new QVBoxLayout( GroupPoints->Box );
l->setMargin( 0 ); l->setSpacing( 0 );
l->addWidget( myFreeBoundBtn );
QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
layout->setMargin( 0 ); layout->setSpacing( 6 );
layout->addWidget( GroupPoints );
myFreeBoundBtn = new QPushButton(tr("GEOM_DETECT") + QString(" [%1]").arg(tr("GEOM_FREE_BOUNDARIES")),
GroupPoints->Box);
QVBoxLayout* l = new QVBoxLayout(GroupPoints->Box);
l->setMargin(0); l->setSpacing(0);
l->addWidget(myFreeBoundBtn);
QVBoxLayout* layout = new QVBoxLayout(centralWidget());
layout->setMargin(0); layout->setSpacing(6);
layout->addWidget(GroupPoints);
/***************************************************************/ /***************************************************************/
setHelpFileName( "suppress_holes_operation_page.html" ); setHelpFileName("suppress_holes_operation_page.html");
Init(); Init();
} }
//================================================================================= //=================================================================================
// function : ~RepairGUI_RemoveHolesDlg() // function : ~RepairGUI_RemoveHolesDlg()
// purpose : Destroys the object and frees any allocated resources // purpose : Destroys the object and frees any allocated resources
@ -101,52 +100,49 @@ RepairGUI_RemoveHolesDlg::~RepairGUI_RemoveHolesDlg()
{ {
} }
//================================================================================= //=================================================================================
// function : Init() // function : Init()
// purpose : // purpose :
//================================================================================= //=================================================================================
void RepairGUI_RemoveHolesDlg::Init() void RepairGUI_RemoveHolesDlg::Init()
{ {
/* init variables */ // init variables
myEditCurrentArgument = GroupPoints->LineEdit1; GroupPoints->LineEdit1->clear();
GroupPoints->LineEdit2->clear();
myObject = GEOM::GEOM_Object::_nil(); myObject = GEOM::GEOM_Object::_nil();
myWiresInd = new GEOM::short_array(); myWiresInd = new GEOM::short_array();
myWiresInd->length( 0 ); myWiresInd->length(0);
//myGeomGUI->SetState( 0 );
initSelection();
myClosed = -1; myClosed = -1;
myOpen = -1; myOpen = -1;
/* signals and slots connections */
connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); // signals and slots connections
connect( GroupPoints->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
connect( GroupPoints->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
connect( GroupPoints->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(), connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect( GroupPoints->CheckButton1, SIGNAL( clicked() ), this, SLOT( onRemoveAllClicked() ) ); connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect( myFreeBoundBtn, SIGNAL( clicked() ), this, SLOT( onDetect() ) ); connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
initName( tr( "REMOVE_HOLES_NEW_OBJ_NAME" ) ); connect(GroupPoints->CheckButton1, SIGNAL(clicked()), this, SLOT(onRemoveAllClicked()));
connect(myFreeBoundBtn, SIGNAL(clicked()), this, SLOT(onDetect()));
initName(tr("REMOVE_HOLES_NEW_OBJ_NAME"));
GroupPoints->PushButton1->click();
SelectionIntoArgument();
} }
//================================================================================= //=================================================================================
// function : ClickOnOk() // function : ClickOnOk()
// purpose : Same than click on apply but close this dialog. // purpose : Same than click on apply but close this dialog.
//================================================================================= //=================================================================================
void RepairGUI_RemoveHolesDlg::ClickOnOk() void RepairGUI_RemoveHolesDlg::ClickOnOk()
{ {
if ( ClickOnApply() ) if (ClickOnApply())
ClickOnCancel(); ClickOnCancel();
} }
@ -156,59 +152,65 @@ void RepairGUI_RemoveHolesDlg::ClickOnOk()
//================================================================================= //=================================================================================
bool RepairGUI_RemoveHolesDlg::ClickOnApply() bool RepairGUI_RemoveHolesDlg::ClickOnApply()
{ {
if ( !onAccept() ) if (!onAccept())
return false; return false;
initName(); initName();
// activate first line edit
myEditCurrentArgument = GroupPoints->LineEdit1; GroupPoints->PushButton1->click();
myEditCurrentArgument->setText( "" );
GroupPoints->LineEdit2->setText( "" );
myObject = GEOM::GEOM_Object::_nil();
myWiresInd->length( 0 );
initSelection();
return true; return true;
} }
//================================================================================= //=================================================================================
// function : SelectionIntoArgument() // function : SelectionIntoArgument()
// purpose : Called when selection // purpose : Called when selection is changed or on dialog initialization or activation
//================================================================================= //=================================================================================
void RepairGUI_RemoveHolesDlg::SelectionIntoArgument() void RepairGUI_RemoveHolesDlg::SelectionIntoArgument()
{ {
erasePreview(); erasePreview();
myEditCurrentArgument->setText( "" ); myEditCurrentArgument->setText("");
if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) myObject = GEOM::GEOM_Object::_nil(); // the second argument depends on the first one
else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) myWiresInd->length( 0 ); GroupPoints->LineEdit2->setText("");
myWiresInd->length(0);
if (myEditCurrentArgument == GroupPoints->LineEdit1)
myObject = GEOM::GEOM_Object::_nil();
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
SALOME_ListIO aSelList; SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList); aSelMgr->selectedObjects(aSelList);
if ( aSelList.Extent() == 1 ) { if (aSelList.Extent() == 1) {
Handle(SALOME_InteractiveObject) anIO = aSelList.First(); Handle(SALOME_InteractiveObject) anIO = aSelList.First();
if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) { // face selection if (myEditCurrentArgument == GroupPoints->LineEdit1) { // face selection
Standard_Boolean aRes; Standard_Boolean aRes;
myObject = GEOMBase::ConvertIOinGEOMObject( anIO, aRes ); myObject = GEOMBase::ConvertIOinGEOMObject(anIO, aRes);
if ( aRes && GEOMBase::IsShape( myObject ) ) if (aRes && GEOMBase::IsShape(myObject)) {
myEditCurrentArgument->setText( GEOMBase::GetName( myObject ) ); myEditCurrentArgument->setText(GEOMBase::GetName(myObject));
// clear selection
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
myGeomGUI->getApp()->selectionMgr()->clearSelected();
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
if (!GroupPoints->CheckButton1->isChecked())
GroupPoints->PushButton2->click();
}
else else
myObject = GEOM::GEOM_Object::_nil(); myObject = GEOM::GEOM_Object::_nil();
} }
else if ( myEditCurrentArgument == GroupPoints->LineEdit2 && else if (myEditCurrentArgument == GroupPoints->LineEdit2 &&
!GroupPoints->CheckButton1->isChecked() ) { !GroupPoints->CheckButton1->isChecked()) {
TColStd_IndexedMapOfInteger aMap; TColStd_IndexedMapOfInteger aMap;
aSelMgr->GetIndexes( anIO, aMap ); aSelMgr->GetIndexes(anIO, aMap);
const int n = aMap.Extent(); const int n = aMap.Extent();
myWiresInd->length( n ); myWiresInd->length(n);
for ( int i = 1; i <= n; i++ ) for (int i = 1; i <= n; i++)
myWiresInd[i-1] = aMap( i ); myWiresInd[i-1] = aMap(i);
if ( n ) if (n)
myEditCurrentArgument->setText( QString::number( n ) + "_" + tr( "GEOM_WIRE" ) + tr( "_S_" ) ); myEditCurrentArgument->setText(QString::number(n) + "_" + tr("GEOM_WIRE") + tr("_S_"));
} }
} }
} }
@ -219,19 +221,36 @@ void RepairGUI_RemoveHolesDlg::SelectionIntoArgument()
//================================================================================= //=================================================================================
void RepairGUI_RemoveHolesDlg::SetEditCurrentArgument() void RepairGUI_RemoveHolesDlg::SetEditCurrentArgument()
{ {
const QObject* send = sender(); QPushButton* send = (QPushButton*)sender();
if ( send == GroupPoints->PushButton1 )
myEditCurrentArgument = GroupPoints->LineEdit1; bool isEffective = false;
else if ( send == GroupPoints->PushButton2 && !myObject->_is_nil() )
if (send == GroupPoints->PushButton1) {
isEffective = true;
myEditCurrentArgument = GroupPoints->LineEdit1;
GroupPoints->PushButton2->setDown(false);
GroupPoints->LineEdit2->setEnabled(false);
}
else if (send == GroupPoints->PushButton2 && !myObject->_is_nil()) {
isEffective = true;
myEditCurrentArgument = GroupPoints->LineEdit2; myEditCurrentArgument = GroupPoints->LineEdit2;
if ( myEditCurrentArgument ) {
GroupPoints->PushButton1->setDown(false);
GroupPoints->LineEdit1->setEnabled(false);
}
if (isEffective) {
initSelection(); initSelection();
// enable line edit
myEditCurrentArgument->setEnabled(true);
myEditCurrentArgument->setFocus(); myEditCurrentArgument->setFocus();
SelectionIntoArgument(); // after setFocus(), because it will be setDown(false) when loses focus
send->setDown(true);
} }
} }
//================================================================================= //=================================================================================
// function : LineEditReturnPressed() // function : LineEditReturnPressed()
// purpose : // purpose :
@ -239,13 +258,12 @@ void RepairGUI_RemoveHolesDlg::SetEditCurrentArgument()
void RepairGUI_RemoveHolesDlg::LineEditReturnPressed() void RepairGUI_RemoveHolesDlg::LineEditReturnPressed()
{ {
const QObject* send = sender(); const QObject* send = sender();
if ( send == GroupPoints->LineEdit1 || send == GroupPoints->LineEdit2 ) { if (send == GroupPoints->LineEdit1 || send == GroupPoints->LineEdit2) {
myEditCurrentArgument = (QLineEdit*)send; myEditCurrentArgument = (QLineEdit*)send;
GEOMBase_Skeleton::LineEditReturnPressed(); GEOMBase_Skeleton::LineEditReturnPressed();
} }
} }
//================================================================================= //=================================================================================
// function : ActivateThisDialog() // function : ActivateThisDialog()
// purpose : // purpose :
@ -253,84 +271,76 @@ void RepairGUI_RemoveHolesDlg::LineEditReturnPressed()
void RepairGUI_RemoveHolesDlg::ActivateThisDialog() void RepairGUI_RemoveHolesDlg::ActivateThisDialog()
{ {
GEOMBase_Skeleton::ActivateThisDialog(); GEOMBase_Skeleton::ActivateThisDialog();
connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
myEditCurrentArgument = GroupPoints->LineEdit1; // reinit, because some selected objects could be removed
myEditCurrentArgument->setText( "" ); Init();
GroupPoints->LineEdit2->setText( "" );
myObject = GEOM::GEOM_Object::_nil();
myWiresInd->length( 0 );
myClosed = -1;
myOpen = -1;
//myGeomGUI->SetState( 0 );
initSelection();
} }
//================================================================================= //=================================================================================
// function : enterEvent() // function : enterEvent()
// purpose : Mouse enter onto the dialog to activate it // purpose : Mouse enter onto the dialog to activate it
//================================================================================= //=================================================================================
void RepairGUI_RemoveHolesDlg::enterEvent( QEvent* ) void RepairGUI_RemoveHolesDlg::enterEvent (QEvent*)
{ {
if ( !mainFrame()->GroupConstructors->isEnabled() ) if (!mainFrame()->GroupConstructors->isEnabled())
ActivateThisDialog(); ActivateThisDialog();
} }
//================================================================================= //=================================================================================
// function : createOperation // function : createOperation
// purpose : // purpose :
//================================================================================= //=================================================================================
GEOM::GEOM_IOperations_ptr RepairGUI_RemoveHolesDlg::createOperation() GEOM::GEOM_IOperations_ptr RepairGUI_RemoveHolesDlg::createOperation()
{ {
return getGeomEngine()->GetIHealingOperations( getStudyId() ); return getGeomEngine()->GetIHealingOperations(getStudyId());
} }
//================================================================================= //=================================================================================
// function : isValid // function : isValid
// purpose : // purpose :
//================================================================================= //=================================================================================
bool RepairGUI_RemoveHolesDlg::isValid( QString& ) bool RepairGUI_RemoveHolesDlg::isValid (QString&)
{ {
myClosed = -1; myClosed = -1;
return !myObject->_is_nil() && ( IsPreview() || GroupPoints->CheckButton1->isChecked() || myWiresInd->length() ); return !myObject->_is_nil() && (IsPreview() || GroupPoints->CheckButton1->isChecked() || myWiresInd->length());
} }
//================================================================================= //=================================================================================
// function : execute // function : execute
// purpose : // purpose :
//================================================================================= //=================================================================================
bool RepairGUI_RemoveHolesDlg::execute( ObjectList& objects ) bool RepairGUI_RemoveHolesDlg::execute (ObjectList& objects)
{ {
bool aResult = false; bool aResult = false;
if ( IsPreview() ) { // called from onDetect(): detect free boundary edges, highlight them (add to objects), display message dialog
if (IsPreview()) {
// called from onDetect(): detect free boundary edges,
// highlight them (add to objects), display message dialog
GEOM::ListOfGO_var aClosed, anOpen; GEOM::ListOfGO_var aClosed, anOpen;
aResult = GEOM::GEOM_IHealingOperations::_narrow( getOperation() )->GetFreeBoundary( myObject, aClosed, anOpen ); aResult = GEOM::GEOM_IHealingOperations::_narrow(getOperation())->
GetFreeBoundary(myObject, aClosed, anOpen);
if ( aResult ) { if (aResult) {
myClosed = aClosed->length(); myClosed = aClosed->length();
myOpen = anOpen->length(); myOpen = anOpen->length();
int i; int i;
for ( i = 0; i < myClosed; i++ ) for (i = 0; i < myClosed; i++)
objects.push_back( aClosed[i]._retn() ); objects.push_back(aClosed[i]._retn());
for ( i = 0; i < myOpen; i++ ) for (i = 0; i < myOpen; i++)
objects.push_back( anOpen[i]._retn() ); objects.push_back(anOpen[i]._retn());
} }
else else
myClosed = -1; myClosed = -1;
} }
else { else {
GEOM::GEOM_Object_var anObj = GEOM::GEOM_IHealingOperations::_narrow( getOperation() )->FillHoles( myObject, myWiresInd ); GEOM::GEOM_Object_var anObj = GEOM::GEOM_IHealingOperations::_narrow(getOperation())->
FillHoles(myObject, myWiresInd);
aResult = !anObj->_is_nil(); aResult = !anObj->_is_nil();
if ( aResult ) if (aResult)
objects.push_back( anObj._retn() ); objects.push_back(anObj._retn());
} }
return aResult; return aResult;
} }
@ -341,12 +351,12 @@ bool RepairGUI_RemoveHolesDlg::execute( ObjectList& objects )
void RepairGUI_RemoveHolesDlg::onRemoveAllClicked() void RepairGUI_RemoveHolesDlg::onRemoveAllClicked()
{ {
bool b = GroupPoints->CheckButton1->isChecked(); bool b = GroupPoints->CheckButton1->isChecked();
GroupPoints->TextLabel2->setEnabled( !b ); GroupPoints->TextLabel2->setEnabled(!b);
GroupPoints->PushButton2->setEnabled( !b ); GroupPoints->PushButton2->setEnabled(!b);
GroupPoints->LineEdit2->setEnabled( !b ); GroupPoints->LineEdit2->setEnabled(!b);
if ( b ) { if (b) {
GroupPoints->LineEdit2->setText( "" ); GroupPoints->LineEdit2->setText("");
myWiresInd->length( 0 ); myWiresInd->length(0);
} }
} }
@ -356,21 +366,25 @@ void RepairGUI_RemoveHolesDlg::onRemoveAllClicked()
//================================================================================= //=================================================================================
void RepairGUI_RemoveHolesDlg::initSelection() void RepairGUI_RemoveHolesDlg::initSelection()
{ {
if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) { disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
TColStd_MapOfInteger aTypes;
aTypes.Add( GEOM_COMPOUND );
aTypes.Add( GEOM_SOLID );
aTypes.Add( GEOM_SHELL );
aTypes.Add( GEOM_FACE );
globalSelection( aTypes );
}
else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) {
localSelection( myObject, TopAbs_EDGE );
localSelection( myObject, TopAbs_WIRE );
}
}
if (myEditCurrentArgument == GroupPoints->LineEdit1) {
TColStd_MapOfInteger aTypes;
aTypes.Add(GEOM_COMPOUND);
aTypes.Add(GEOM_SOLID);
aTypes.Add(GEOM_SHELL);
aTypes.Add(GEOM_FACE);
globalSelection(aTypes);
}
else if (myEditCurrentArgument == GroupPoints->LineEdit2) {
localSelection(myObject, TopAbs_EDGE);
localSelection(myObject, TopAbs_WIRE);
}
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
}
//================================================================================= //=================================================================================
// function : onDetect // function : onDetect
@ -378,14 +392,13 @@ void RepairGUI_RemoveHolesDlg::initSelection()
//================================================================================= //=================================================================================
void RepairGUI_RemoveHolesDlg::onDetect() void RepairGUI_RemoveHolesDlg::onDetect()
{ {
displayPreview( false, true, true, 3 ); displayPreview(false, true, true, 3);
// field myClosed,myOpen is initialized in execute() method, called by displayPreview(). // field myClosed,myOpen is initialized in execute() method, called by displayPreview().
QString msg; QString msg;
if ( myClosed != -1 ) if (myClosed != -1)
msg = tr( "GEOM_FREE_BOUNDS_MSG" ).arg( myClosed + myOpen ).arg( myClosed ).arg( myOpen ); msg = tr("GEOM_FREE_BOUNDS_MSG").arg(myClosed + myOpen).arg(myClosed).arg(myOpen);
else else
msg = tr( "GEOM_FREE_BOUNDS_ERROR" ); msg = tr("GEOM_FREE_BOUNDS_ERROR");
SUIT_MessageBox::information( this, tr( "GEOM_FREE_BOUNDS_TLT" ), msg ); SUIT_MessageBox::information(this, tr("GEOM_FREE_BOUNDS_TLT"), msg);
} }

View File

@ -1,22 +1,22 @@
// GEOM GEOMGUI : GUI for Geometry component // GEOM GEOMGUI : GUI for Geometry component
// //
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either // License as published by the Free Software Foundation; either
// version 2.1 of the License. // version 2.1 of the License.
// //
// This library is distributed in the hope that it will be useful, // This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details. // Lesser General Public License for more details.
// //
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
// //
// File : RepairGUI_RemoveIntWiresDlg.cxx // File : RepairGUI_RemoveIntWiresDlg.cxx
@ -29,17 +29,18 @@
#include <GeometryGUI.h> #include <GeometryGUI.h>
#include <GEOMBase.h> #include <GEOMBase.h>
#include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h>
#include <SUIT_Session.h> #include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h> #include <SUIT_ResourceMgr.h>
#include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h>
#include <GEOMImpl_Types.hxx> // OCCT Includes
#include <TopAbs.hxx> #include <TopAbs.hxx>
#include <TColStd_MapOfInteger.hxx> #include <TColStd_MapOfInteger.hxx>
#include <TColStd_IndexedMapOfInteger.hxx> #include <TColStd_IndexedMapOfInteger.hxx>
#include <GEOMImpl_Types.hxx>
//================================================================================= //=================================================================================
// class : RepairGUI_RemoveIntWiresDlg() // class : RepairGUI_RemoveIntWiresDlg()
// purpose : Constructs a RepairGUI_RemoveIntWiresDlg which is a child of 'parent', with the // purpose : Constructs a RepairGUI_RemoveIntWiresDlg which is a child of 'parent', with the
@ -47,45 +48,43 @@
// The dialog will by default be modeless, unless you set 'modal' to // The dialog will by default be modeless, unless you set 'modal' to
// TRUE to construct a modal dialog. // TRUE to construct a modal dialog.
//================================================================================= //=================================================================================
RepairGUI_RemoveIntWiresDlg::RepairGUI_RemoveIntWiresDlg( GeometryGUI* theGeometryGUI, QWidget* parent, RepairGUI_RemoveIntWiresDlg::RepairGUI_RemoveIntWiresDlg (GeometryGUI* theGeometryGUI, QWidget* parent,
bool modal ) bool modal)
: GEOMBase_Skeleton( theGeometryGUI, parent, modal ) : GEOMBase_Skeleton(theGeometryGUI, parent, modal)
{ {
QPixmap image0( myGeomGUI->getApp()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_SUPPRESS_INT_WIRES" ) ) ); QPixmap image0 (myGeomGUI->getApp()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_SUPPRESS_INT_WIRES")));
QPixmap image1( myGeomGUI->getApp()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) ); QPixmap image1 (myGeomGUI->getApp()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT")));
setWindowTitle( tr( "GEOM_REMOVE_INTERNAL_WIRES_TITLE" ) ); setWindowTitle(tr("GEOM_REMOVE_INTERNAL_WIRES_TITLE"));
/***************************************************************/ /***************************************************************/
mainFrame()->GroupConstructors->setTitle( tr( "GEOM_REMOVE_INTERNAL_WIRES_TITLE" ) ); mainFrame()->GroupConstructors->setTitle(tr("GEOM_REMOVE_INTERNAL_WIRES_TITLE"));
mainFrame()->RadioButton1->setIcon( image0 ); mainFrame()->RadioButton1->setIcon(image0);
mainFrame()->RadioButton2->setAttribute( Qt::WA_DeleteOnClose ); mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose);
mainFrame()->RadioButton2->close(); mainFrame()->RadioButton2->close();
mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose ); mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
mainFrame()->RadioButton3->close(); mainFrame()->RadioButton3->close();
GroupPoints = new DlgRef_1Sel1Check1Sel( centralWidget() ); GroupPoints = new DlgRef_1Sel1Check1Sel(centralWidget());
GroupPoints->GroupBox1->setTitle( tr( "GEOM_INTERNAL_WIRES" ) ); GroupPoints->GroupBox1->setTitle(tr("GEOM_INTERNAL_WIRES"));
GroupPoints->TextLabel1->setText( tr( "GEOM_SELECTED_FACE" ) ); GroupPoints->TextLabel1->setText(tr("GEOM_SELECTED_FACE"));
GroupPoints->PushButton1->setIcon( image1 ); GroupPoints->PushButton1->setIcon(image1);
GroupPoints->LineEdit1->setReadOnly( true ); GroupPoints->LineEdit1->setReadOnly(true);
GroupPoints->CheckButton1->setText( tr( "GEOM_REMOVE_ALL_INT_WIRES" ) ); GroupPoints->CheckButton1->setText(tr("GEOM_REMOVE_ALL_INT_WIRES"));
GroupPoints->TextLabel2->setText( tr( "GEOM_WIRES_TO_REMOVE" ) ); GroupPoints->TextLabel2->setText(tr("GEOM_WIRES_TO_REMOVE"));
GroupPoints->PushButton2->setIcon( image1 ); GroupPoints->PushButton2->setIcon(image1);
GroupPoints->LineEdit2->setReadOnly( true ); GroupPoints->LineEdit2->setReadOnly(true);
QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
layout->setMargin( 0 ); layout->setSpacing( 6 );
layout->addWidget( GroupPoints );
QVBoxLayout* layout = new QVBoxLayout(centralWidget());
layout->setMargin(0); layout->setSpacing(6);
layout->addWidget(GroupPoints);
/***************************************************************/ /***************************************************************/
setHelpFileName( "suppress_internal_wires_operation_page.html" ); setHelpFileName("suppress_internal_wires_operation_page.html");
Init(); Init();
} }
//================================================================================= //=================================================================================
// function : ~RepairGUI_RemoveIntWiresDlg() // function : ~RepairGUI_RemoveIntWiresDlg()
// purpose : Destroys the object and frees any allocated resources // purpose : Destroys the object and frees any allocated resources
@ -94,48 +93,44 @@ RepairGUI_RemoveIntWiresDlg::~RepairGUI_RemoveIntWiresDlg()
{ {
} }
//================================================================================= //=================================================================================
// function : Init() // function : Init()
// purpose : // purpose :
//================================================================================= //=================================================================================
void RepairGUI_RemoveIntWiresDlg::Init() void RepairGUI_RemoveIntWiresDlg::Init()
{ {
/* init variables */ // init variables
myEditCurrentArgument = GroupPoints->LineEdit1; GroupPoints->LineEdit1->clear();
GroupPoints->LineEdit2->clear();
myObject = GEOM::GEOM_Object::_nil(); myObject = GEOM::GEOM_Object::_nil();
myWiresInd = new GEOM::short_array(); myWiresInd = new GEOM::short_array();
myWiresInd->length( 0 ); myWiresInd->length(0);
//myGeomGUI->SetState( 0 ); // signals and slots connections
initSelection(); connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
/* signals and slots connections */ connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect( GroupPoints->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect( GroupPoints->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( GroupPoints->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(), connect(GroupPoints->CheckButton1, SIGNAL(clicked()), this, SLOT(onRemoveAllClicked()));
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
connect( GroupPoints->CheckButton1, SIGNAL( clicked() ), this, SLOT( onRemoveAllClicked() ) ); initName(tr("REMOVE_INT_WIRES_NEW_OBJ_NAME"));
initName( tr( "REMOVE_INT_WIRES_NEW_OBJ_NAME" ) ); GroupPoints->PushButton1->click();
SelectionIntoArgument();
} }
//================================================================================= //=================================================================================
// function : ClickOnOk() // function : ClickOnOk()
// purpose : Same than click on apply but close this dialog. // purpose : Same than click on apply but close this dialog.
//================================================================================= //=================================================================================
void RepairGUI_RemoveIntWiresDlg::ClickOnOk() void RepairGUI_RemoveIntWiresDlg::ClickOnOk()
{ {
if ( ClickOnApply() ) if (ClickOnApply())
ClickOnCancel(); ClickOnCancel();
} }
@ -145,58 +140,64 @@ void RepairGUI_RemoveIntWiresDlg::ClickOnOk()
//================================================================================= //=================================================================================
bool RepairGUI_RemoveIntWiresDlg::ClickOnApply() bool RepairGUI_RemoveIntWiresDlg::ClickOnApply()
{ {
if ( !onAccept() ) if (!onAccept())
return false; return false;
initName(); initName();
// activate first line edit
myEditCurrentArgument = GroupPoints->LineEdit1; GroupPoints->PushButton1->click();
myEditCurrentArgument->setText( "" );
GroupPoints->LineEdit2->setText( "" );
myObject = GEOM::GEOM_Object::_nil();
myWiresInd->length( 0 );
initSelection();
return true; return true;
} }
//================================================================================= //=================================================================================
// function : SelectionIntoArgument() // function : SelectionIntoArgument()
// purpose : Called when selection // purpose : Called when selection is changed or on dialog initialization or activation
//================================================================================= //=================================================================================
void RepairGUI_RemoveIntWiresDlg::SelectionIntoArgument() void RepairGUI_RemoveIntWiresDlg::SelectionIntoArgument()
{ {
myEditCurrentArgument->setText( "" ); myEditCurrentArgument->setText("");
if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) myObject = GEOM::GEOM_Object::_nil(); // the second argument depends on the first one
else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) myWiresInd->length( 0 ); GroupPoints->LineEdit2->setText("");
myWiresInd->length(0);
if (myEditCurrentArgument == GroupPoints->LineEdit1)
myObject = GEOM::GEOM_Object::_nil();
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
SALOME_ListIO aSelList; SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList); aSelMgr->selectedObjects(aSelList);
if ( aSelList.Extent() == 1 ) { if (aSelList.Extent() == 1) {
Handle(SALOME_InteractiveObject) anIO = aSelList.First(); Handle(SALOME_InteractiveObject) anIO = aSelList.First();
if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) { // face selection if (myEditCurrentArgument == GroupPoints->LineEdit1) { // face selection
Standard_Boolean aRes; Standard_Boolean aRes;
myObject = GEOMBase::ConvertIOinGEOMObject( anIO, aRes ); myObject = GEOMBase::ConvertIOinGEOMObject(anIO, aRes);
if ( aRes && GEOMBase::IsShape( myObject ) ) if (aRes && GEOMBase::IsShape(myObject)) {
myEditCurrentArgument->setText( GEOMBase::GetName( myObject ) ); myEditCurrentArgument->setText(GEOMBase::GetName(myObject));
// clear selection
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
myGeomGUI->getApp()->selectionMgr()->clearSelected();
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
if (!GroupPoints->CheckButton1->isChecked())
GroupPoints->PushButton2->click();
}
else else
myObject = GEOM::GEOM_Object::_nil(); myObject = GEOM::GEOM_Object::_nil();
} }
else if ( myEditCurrentArgument == GroupPoints->LineEdit2 && else if (myEditCurrentArgument == GroupPoints->LineEdit2 &&
!GroupPoints->CheckButton1->isChecked() ) { !GroupPoints->CheckButton1->isChecked()) {
TColStd_IndexedMapOfInteger aMap; TColStd_IndexedMapOfInteger aMap;
aSelMgr->GetIndexes( anIO, aMap ); aSelMgr->GetIndexes(anIO, aMap);
const int n = aMap.Extent(); const int n = aMap.Extent();
myWiresInd->length( n ); myWiresInd->length(n);
for ( int i = 1; i <= n; i++ ) for (int i = 1; i <= n; i++)
myWiresInd[i-1] = aMap( i ); myWiresInd[i-1] = aMap(i);
if ( n ) if (n)
myEditCurrentArgument->setText( QString::number( n ) + "_" + tr( "GEOM_WIRE" ) + tr( "_S_" ) ); myEditCurrentArgument->setText(QString::number(n) + "_" + tr("GEOM_WIRE") + tr("_S_"));
} }
} }
} }
@ -207,20 +208,36 @@ void RepairGUI_RemoveIntWiresDlg::SelectionIntoArgument()
//================================================================================= //=================================================================================
void RepairGUI_RemoveIntWiresDlg::SetEditCurrentArgument() void RepairGUI_RemoveIntWiresDlg::SetEditCurrentArgument()
{ {
const QObject* send = sender(); QPushButton* send = (QPushButton*)sender();
if ( send == GroupPoints->PushButton1 )
bool isEffective = false;
if (send == GroupPoints->PushButton1) {
isEffective = true;
myEditCurrentArgument = GroupPoints->LineEdit1; myEditCurrentArgument = GroupPoints->LineEdit1;
else if ( send == GroupPoints->PushButton2 && !myObject->_is_nil() )
GroupPoints->PushButton2->setDown(false);
GroupPoints->LineEdit2->setEnabled(false);
}
else if (send == GroupPoints->PushButton2 && !myObject->_is_nil()) {
isEffective = true;
myEditCurrentArgument = GroupPoints->LineEdit2; myEditCurrentArgument = GroupPoints->LineEdit2;
if ( myEditCurrentArgument ) { GroupPoints->PushButton1->setDown(false);
GroupPoints->LineEdit1->setEnabled(false);
}
if (isEffective) {
initSelection(); initSelection();
// enable line edit
myEditCurrentArgument->setEnabled(true);
myEditCurrentArgument->setFocus(); myEditCurrentArgument->setFocus();
SelectionIntoArgument(); // after setFocus(), because it will be setDown(false) when loses focus
send->setDown(true);
} }
} }
//================================================================================= //=================================================================================
// function : LineEditReturnPressed() // function : LineEditReturnPressed()
// purpose : // purpose :
@ -228,13 +245,12 @@ void RepairGUI_RemoveIntWiresDlg::SetEditCurrentArgument()
void RepairGUI_RemoveIntWiresDlg::LineEditReturnPressed() void RepairGUI_RemoveIntWiresDlg::LineEditReturnPressed()
{ {
const QObject* send = sender(); const QObject* send = sender();
if ( send == GroupPoints->LineEdit1 || send == GroupPoints->LineEdit2 ) { if (send == GroupPoints->LineEdit1 || send == GroupPoints->LineEdit2) {
myEditCurrentArgument = (QLineEdit*)send; myEditCurrentArgument = (QLineEdit*)send;
GEOMBase_Skeleton::LineEditReturnPressed(); GEOMBase_Skeleton::LineEditReturnPressed();
} }
} }
//================================================================================= //=================================================================================
// function : ActivateThisDialog() // function : ActivateThisDialog()
// purpose : // purpose :
@ -242,26 +258,18 @@ void RepairGUI_RemoveIntWiresDlg::LineEditReturnPressed()
void RepairGUI_RemoveIntWiresDlg::ActivateThisDialog() void RepairGUI_RemoveIntWiresDlg::ActivateThisDialog()
{ {
GEOMBase_Skeleton::ActivateThisDialog(); GEOMBase_Skeleton::ActivateThisDialog();
connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
myEditCurrentArgument = GroupPoints->LineEdit1; // reinit, because some selected objects could be removed
myEditCurrentArgument->setText( "" ); Init();
GroupPoints->LineEdit2->setText( "" );
myObject = GEOM::GEOM_Object::_nil();
myWiresInd->length( 0 );
//myGeomGUI->SetState( 0 );
initSelection();
} }
//================================================================================= //=================================================================================
// function : enterEvent() // function : enterEvent()
// purpose : Mouse enter onto the dialog to activate it // purpose : Mouse enter onto the dialog to activate it
//================================================================================= //=================================================================================
void RepairGUI_RemoveIntWiresDlg::enterEvent( QEvent* ) void RepairGUI_RemoveIntWiresDlg::enterEvent (QEvent*)
{ {
if ( !mainFrame()->GroupConstructors->isEnabled() ) if (!mainFrame()->GroupConstructors->isEnabled())
ActivateThisDialog(); ActivateThisDialog();
} }
@ -271,29 +279,30 @@ void RepairGUI_RemoveIntWiresDlg::enterEvent( QEvent* )
//================================================================================= //=================================================================================
GEOM::GEOM_IOperations_ptr RepairGUI_RemoveIntWiresDlg::createOperation() GEOM::GEOM_IOperations_ptr RepairGUI_RemoveIntWiresDlg::createOperation()
{ {
return getGeomEngine()->GetIHealingOperations( getStudyId() ); return getGeomEngine()->GetIHealingOperations(getStudyId());
} }
//================================================================================= //=================================================================================
// function : isValid // function : isValid
// purpose : // purpose :
//================================================================================= //=================================================================================
bool RepairGUI_RemoveIntWiresDlg::isValid( QString& ) bool RepairGUI_RemoveIntWiresDlg::isValid (QString&)
{ {
return !myObject->_is_nil() && ( GroupPoints->CheckButton1->isChecked() || myWiresInd->length() ); return !myObject->_is_nil() && (GroupPoints->CheckButton1->isChecked() || myWiresInd->length());
} }
//================================================================================= //=================================================================================
// function : execute // function : execute
// purpose : // purpose :
//================================================================================= //=================================================================================
bool RepairGUI_RemoveIntWiresDlg::execute( ObjectList& objects ) bool RepairGUI_RemoveIntWiresDlg::execute (ObjectList& objects)
{ {
GEOM::GEOM_Object_var anObj = GEOM::GEOM_IHealingOperations::_narrow( getOperation() )-> GEOM::GEOM_Object_var anObj = GEOM::GEOM_IHealingOperations::_narrow(getOperation())->
RemoveIntWires( myObject, myWiresInd ); RemoveIntWires(myObject, myWiresInd);
bool aResult = !anObj->_is_nil(); bool aResult = !anObj->_is_nil();
if ( aResult ) if (aResult)
objects.push_back( anObj._retn() ); objects.push_back(anObj._retn());
return aResult; return aResult;
} }
@ -305,12 +314,12 @@ bool RepairGUI_RemoveIntWiresDlg::execute( ObjectList& objects )
void RepairGUI_RemoveIntWiresDlg::onRemoveAllClicked() void RepairGUI_RemoveIntWiresDlg::onRemoveAllClicked()
{ {
bool b = GroupPoints->CheckButton1->isChecked(); bool b = GroupPoints->CheckButton1->isChecked();
GroupPoints->TextLabel2->setEnabled( !b ); GroupPoints->TextLabel2->setEnabled(!b);
GroupPoints->PushButton2->setEnabled( !b ); GroupPoints->PushButton2->setEnabled(!b);
GroupPoints->LineEdit2->setEnabled( !b ); GroupPoints->LineEdit2->setEnabled(!b);
if ( b ) { if (b) {
GroupPoints->LineEdit2->setText( "" ); GroupPoints->LineEdit2->setText("");
myWiresInd->length( 0 ); myWiresInd->length(0);
} }
} }
@ -320,17 +329,22 @@ void RepairGUI_RemoveIntWiresDlg::onRemoveAllClicked()
//================================================================================= //=================================================================================
void RepairGUI_RemoveIntWiresDlg::initSelection() void RepairGUI_RemoveIntWiresDlg::initSelection()
{ {
if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) { disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
if (myEditCurrentArgument == GroupPoints->LineEdit1) {
TColStd_MapOfInteger aTypes; TColStd_MapOfInteger aTypes;
aTypes.Add( GEOM_COMPOUND ); aTypes.Add(GEOM_COMPOUND);
aTypes.Add( GEOM_SOLID ); aTypes.Add(GEOM_SOLID);
aTypes.Add( GEOM_SHELL ); aTypes.Add(GEOM_SHELL);
aTypes.Add( GEOM_FACE ); aTypes.Add(GEOM_FACE);
globalSelection( aTypes ); globalSelection(aTypes);
} }
else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) { else if (myEditCurrentArgument == GroupPoints->LineEdit2) {
//localSelection( myObject, TopAbs_EDGE ); //localSelection(myObject, TopAbs_EDGE);
localSelection( myObject, TopAbs_WIRE ); localSelection(myObject, TopAbs_WIRE);
} }
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
} }