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

@ -29,17 +29,18 @@
#include <GeometryGUI.h>
#include <GEOMBase.h>
#include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h>
#include <SUIT_Session.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 <TopAbs.hxx>
#include <TColStd_IndexedMapOfInteger.hxx>
#include <TColStd_MapOfInteger.hxx>
//=================================================================================
// class : RepairGUI_CloseContourDlg()
// purpose : Constructs a RepairGUI_CloseContourDlg which is a child of 'parent', with the
@ -90,7 +91,6 @@ RepairGUI_CloseContourDlg::RepairGUI_CloseContourDlg( GeometryGUI* theGeometryGU
QVBoxLayout* layout = new QVBoxLayout(centralWidget());
layout->setMargin(0); layout->setSpacing(6);
layout->addWidget(GroupPoints);
/***************************************************************/
setHelpFileName("close_contour_operation_page.html");
@ -98,7 +98,6 @@ RepairGUI_CloseContourDlg::RepairGUI_CloseContourDlg( GeometryGUI* theGeometryGU
Init();
}
//=================================================================================
// function : ~RepairGUI_CloseContourDlg()
// purpose : Destroys the object and frees any allocated resources
@ -107,38 +106,34 @@ RepairGUI_CloseContourDlg::~RepairGUI_CloseContourDlg()
{
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void RepairGUI_CloseContourDlg::Init()
{
/* init variables */
myEditCurrentArgument = GroupPoints->LineEdit1;
// init variables
GroupPoints->LineEdit1->clear();
GroupPoints->LineEdit2->clear();
myObject = GEOM::GEOM_Object::_nil();
myWiresInd = new GEOM::short_array();
myWiresInd->length(0);
//myGeomGUI->SetState( 0 );
initSelection();
/* signals and slots connections */
// 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()));
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(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
initName(tr("CLOSE_CONTOUR_NEW_OBJ_NAME"));
}
GroupPoints->PushButton1->click();
SelectionIntoArgument();
}
//=================================================================================
// function : ClickOnOk()
@ -150,8 +145,6 @@ void RepairGUI_CloseContourDlg::ClickOnOk()
ClickOnCancel();
}
//=================================================================================
// function : ClickOnApply()
// purpose :
@ -162,32 +155,24 @@ bool RepairGUI_CloseContourDlg::ClickOnApply()
return false;
initName();
myEditCurrentArgument = GroupPoints->LineEdit1;
myEditCurrentArgument->setText( "" );
myObject = GEOM::GEOM_Object::_nil();
myWiresInd->length( 0 );
initSelection();
// activate first line edit
GroupPoints->PushButton1->click();
return true;
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection as changed or other case
// : used only by SelectButtonC1A1 (LineEditC1A1)
// purpose : Called when selection is changed or on dialog initialization or activation
//=================================================================================
void RepairGUI_CloseContourDlg::SelectionIntoArgument()
{
erasePreview();
myEditCurrentArgument->setText("");
// the second argument depends on the first one
GroupPoints->LineEdit2->setText("");
myWiresInd->length(0);
if (myEditCurrentArgument == GroupPoints->LineEdit1)
myObject = GEOM::GEOM_Object::_nil();
else if ( myEditCurrentArgument == GroupPoints->LineEdit2 )
myWiresInd->length( 0 );
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
SALOME_ListIO aSelList;
@ -204,6 +189,14 @@ void RepairGUI_CloseContourDlg::SelectionIntoArgument()
TopoDS_Shape aShape;
if (GEOMBase::GetShape(myObject, aShape, TopAbs_WIRE))
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
myObject = GEOM::GEOM_Object::_nil();
@ -227,18 +220,35 @@ void RepairGUI_CloseContourDlg::SelectionIntoArgument()
//=================================================================================
void RepairGUI_CloseContourDlg::SetEditCurrentArgument()
{
const QObject* send = sender();
if ( send == GroupPoints->PushButton1 )
QPushButton* send = (QPushButton*)sender();
bool isEffective = false;
if (send == GroupPoints->PushButton1) {
isEffective = true;
myEditCurrentArgument = GroupPoints->LineEdit1;
else if ( send == GroupPoints->PushButton2 && !myObject->_is_nil() )
myEditCurrentArgument = GroupPoints->LineEdit2;
if ( myEditCurrentArgument ) {
initSelection();
myEditCurrentArgument->setFocus();
SelectionIntoArgument();
GroupPoints->PushButton2->setDown(false);
GroupPoints->LineEdit2->setEnabled(false);
}
else if (send == GroupPoints->PushButton2 && !myObject->_is_nil()) {
isEffective = true;
myEditCurrentArgument = GroupPoints->LineEdit2;
GroupPoints->PushButton1->setDown(false);
GroupPoints->LineEdit1->setEnabled(false);
}
if (isEffective) {
initSelection();
// enable line edit
myEditCurrentArgument->setEnabled(true);
myEditCurrentArgument->setFocus();
// after setFocus(), because it will be setDown(false) when loses focus
send->setDown(true);
}
}
//=================================================================================
// function : LineEditReturnPressed()
@ -253,7 +263,6 @@ void RepairGUI_CloseContourDlg::LineEditReturnPressed()
}
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
@ -261,20 +270,11 @@ void RepairGUI_CloseContourDlg::LineEditReturnPressed()
void RepairGUI_CloseContourDlg::ActivateThisDialog()
{
GEOMBase_Skeleton::ActivateThisDialog();
connect( myGeomGUI->getApp()->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
myEditCurrentArgument = GroupPoints->LineEdit1;
myEditCurrentArgument->setText( "" );
GroupPoints->LineEdit2->setText( "" );
myObject = GEOM::GEOM_Object::_nil();
myWiresInd->length( 0 );
//myGeomGUI->SetState( 0 );
initSelection();
// reinit, because some selected objects could be removed
Init();
}
//=================================================================================
// function : enterEvent()
// purpose : Mouse enter onto the dialog to activate it
@ -285,7 +285,6 @@ void RepairGUI_CloseContourDlg::enterEvent( QEvent* )
ActivateThisDialog();
}
//=================================================================================
// function : createOperation
// purpose :
@ -302,7 +301,8 @@ GEOM::GEOM_IOperations_ptr RepairGUI_CloseContourDlg::createOperation()
bool RepairGUI_CloseContourDlg::isValid (QString&)
{
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));
}
//=================================================================================
@ -311,7 +311,9 @@ bool RepairGUI_CloseContourDlg::isValid( QString& )
//=================================================================================
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();
if (aResult)
objects.push_back(anObj._retn());
@ -334,6 +336,8 @@ bool RepairGUI_CloseContourDlg::getIsByVertex() const
//=================================================================================
void RepairGUI_CloseContourDlg::initSelection()
{
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
if (myEditCurrentArgument == GroupPoints->LineEdit1) {
TColStd_MapOfInteger aTypes;
aTypes.Add(GEOM_COMPOUND);
@ -348,4 +352,7 @@ void RepairGUI_CloseContourDlg::initSelection()
localSelection(myObject, TopAbs_EDGE);
localSelection(myObject, TopAbs_WIRE);
}
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
}

View File

@ -29,18 +29,19 @@
#include <GeometryGUI.h>
#include <GEOMBase.h>
#include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h>
#include <SUIT_MessageBox.h>
#include <SUIT_Session.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 <TColStd_MapOfInteger.hxx>
#include <TColStd_IndexedMapOfInteger.hxx>
#include <GEOMImpl_Types.hxx>
//=================================================================================
// class : RepairGUI_RemoveHolesDlg()
// purpose : Constructs a RepairGUI_RemoveHolesDlg which is a child of 'parent', with the
@ -84,7 +85,6 @@ RepairGUI_RemoveHolesDlg::RepairGUI_RemoveHolesDlg( GeometryGUI* theGeometryGUI,
QVBoxLayout* layout = new QVBoxLayout(centralWidget());
layout->setMargin(0); layout->setSpacing(6);
layout->addWidget(GroupPoints);
/***************************************************************/
setHelpFileName("suppress_holes_operation_page.html");
@ -92,7 +92,6 @@ RepairGUI_RemoveHolesDlg::RepairGUI_RemoveHolesDlg( GeometryGUI* theGeometryGUI,
Init();
}
//=================================================================================
// function : ~RepairGUI_RemoveHolesDlg()
// purpose : Destroys the object and frees any allocated resources
@ -101,44 +100,41 @@ RepairGUI_RemoveHolesDlg::~RepairGUI_RemoveHolesDlg()
{
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void RepairGUI_RemoveHolesDlg::Init()
{
/* init variables */
myEditCurrentArgument = GroupPoints->LineEdit1;
// init variables
GroupPoints->LineEdit1->clear();
GroupPoints->LineEdit2->clear();
myObject = GEOM::GEOM_Object::_nil();
myWiresInd = new GEOM::short_array();
myWiresInd->length(0);
//myGeomGUI->SetState( 0 );
initSelection();
myClosed = -1;
myOpen = -1;
/* signals and slots connections */
// 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()));
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( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
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()
@ -160,29 +156,25 @@ bool RepairGUI_RemoveHolesDlg::ClickOnApply()
return false;
initName();
myEditCurrentArgument = GroupPoints->LineEdit1;
myEditCurrentArgument->setText( "" );
GroupPoints->LineEdit2->setText( "" );
myObject = GEOM::GEOM_Object::_nil();
myWiresInd->length( 0 );
initSelection();
// activate first line edit
GroupPoints->PushButton1->click();
return true;
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection
// purpose : Called when selection is changed or on dialog initialization or activation
//=================================================================================
void RepairGUI_RemoveHolesDlg::SelectionIntoArgument()
{
erasePreview();
myEditCurrentArgument->setText("");
if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) myObject = GEOM::GEOM_Object::_nil();
else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) myWiresInd->length( 0 );
// the second argument depends on the first one
GroupPoints->LineEdit2->setText("");
myWiresInd->length(0);
if (myEditCurrentArgument == GroupPoints->LineEdit1)
myObject = GEOM::GEOM_Object::_nil();
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
SALOME_ListIO aSelList;
@ -194,8 +186,18 @@ void RepairGUI_RemoveHolesDlg::SelectionIntoArgument()
if (myEditCurrentArgument == GroupPoints->LineEdit1) { // face selection
Standard_Boolean aRes;
myObject = GEOMBase::ConvertIOinGEOMObject(anIO, aRes);
if ( aRes && GEOMBase::IsShape( myObject ) )
if (aRes && GEOMBase::IsShape(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
myObject = GEOM::GEOM_Object::_nil();
}
@ -219,18 +221,35 @@ void RepairGUI_RemoveHolesDlg::SelectionIntoArgument()
//=================================================================================
void RepairGUI_RemoveHolesDlg::SetEditCurrentArgument()
{
const QObject* send = sender();
if ( send == GroupPoints->PushButton1 )
QPushButton* send = (QPushButton*)sender();
bool isEffective = false;
if (send == GroupPoints->PushButton1) {
isEffective = true;
myEditCurrentArgument = GroupPoints->LineEdit1;
else if ( send == GroupPoints->PushButton2 && !myObject->_is_nil() )
myEditCurrentArgument = GroupPoints->LineEdit2;
if ( myEditCurrentArgument ) {
initSelection();
myEditCurrentArgument->setFocus();
SelectionIntoArgument();
GroupPoints->PushButton2->setDown(false);
GroupPoints->LineEdit2->setEnabled(false);
}
else if (send == GroupPoints->PushButton2 && !myObject->_is_nil()) {
isEffective = true;
myEditCurrentArgument = GroupPoints->LineEdit2;
GroupPoints->PushButton1->setDown(false);
GroupPoints->LineEdit1->setEnabled(false);
}
if (isEffective) {
initSelection();
// enable line edit
myEditCurrentArgument->setEnabled(true);
myEditCurrentArgument->setFocus();
// after setFocus(), because it will be setDown(false) when loses focus
send->setDown(true);
}
}
//=================================================================================
// function : LineEditReturnPressed()
@ -245,7 +264,6 @@ void RepairGUI_RemoveHolesDlg::LineEditReturnPressed()
}
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
@ -253,23 +271,11 @@ void RepairGUI_RemoveHolesDlg::LineEditReturnPressed()
void RepairGUI_RemoveHolesDlg::ActivateThisDialog()
{
GEOMBase_Skeleton::ActivateThisDialog();
connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
myEditCurrentArgument = GroupPoints->LineEdit1;
myEditCurrentArgument->setText( "" );
GroupPoints->LineEdit2->setText( "" );
myObject = GEOM::GEOM_Object::_nil();
myWiresInd->length( 0 );
myClosed = -1;
myOpen = -1;
//myGeomGUI->SetState( 0 );
initSelection();
// reinit, because some selected objects could be removed
Init();
}
//=================================================================================
// function : enterEvent()
// purpose : Mouse enter onto the dialog to activate it
@ -280,7 +286,6 @@ void RepairGUI_RemoveHolesDlg::enterEvent( QEvent* )
ActivateThisDialog();
}
//=================================================================================
// function : createOperation
// purpose :
@ -307,10 +312,14 @@ bool RepairGUI_RemoveHolesDlg::isValid( QString& )
bool RepairGUI_RemoveHolesDlg::execute (ObjectList& objects)
{
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;
aResult = GEOM::GEOM_IHealingOperations::_narrow( getOperation() )->GetFreeBoundary( myObject, aClosed, anOpen );
aResult = GEOM::GEOM_IHealingOperations::_narrow(getOperation())->
GetFreeBoundary(myObject, aClosed, anOpen);
if (aResult) {
myClosed = aClosed->length();
@ -325,7 +334,8 @@ bool RepairGUI_RemoveHolesDlg::execute( ObjectList& objects )
myClosed = -1;
}
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();
if (aResult)
objects.push_back(anObj._retn());
@ -356,6 +366,8 @@ void RepairGUI_RemoveHolesDlg::onRemoveAllClicked()
//=================================================================================
void RepairGUI_RemoveHolesDlg::initSelection()
{
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
if (myEditCurrentArgument == GroupPoints->LineEdit1) {
TColStd_MapOfInteger aTypes;
aTypes.Add(GEOM_COMPOUND);
@ -369,8 +381,10 @@ void RepairGUI_RemoveHolesDlg::initSelection()
localSelection(myObject, TopAbs_EDGE);
localSelection(myObject, TopAbs_WIRE);
}
}
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
}
//=================================================================================
// function : onDetect
@ -388,4 +402,3 @@ void RepairGUI_RemoveHolesDlg::onDetect()
msg = tr("GEOM_FREE_BOUNDS_ERROR");
SUIT_MessageBox::information(this, tr("GEOM_FREE_BOUNDS_TLT"), msg);
}

View File

@ -29,17 +29,18 @@
#include <GeometryGUI.h>
#include <GEOMBase.h>
#include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h>
#include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h>
#include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h>
#include <GEOMImpl_Types.hxx>
// OCCT Includes
#include <TopAbs.hxx>
#include <TColStd_MapOfInteger.hxx>
#include <TColStd_IndexedMapOfInteger.hxx>
#include <GEOMImpl_Types.hxx>
//=================================================================================
// class : RepairGUI_RemoveIntWiresDlg()
// purpose : Constructs a RepairGUI_RemoveIntWiresDlg which is a child of 'parent', with the
@ -77,7 +78,6 @@ RepairGUI_RemoveIntWiresDlg::RepairGUI_RemoveIntWiresDlg( GeometryGUI* theGeomet
QVBoxLayout* layout = new QVBoxLayout(centralWidget());
layout->setMargin(0); layout->setSpacing(6);
layout->addWidget(GroupPoints);
/***************************************************************/
setHelpFileName("suppress_internal_wires_operation_page.html");
@ -85,7 +85,6 @@ RepairGUI_RemoveIntWiresDlg::RepairGUI_RemoveIntWiresDlg( GeometryGUI* theGeomet
Init();
}
//=================================================================================
// function : ~RepairGUI_RemoveIntWiresDlg()
// purpose : Destroys the object and frees any allocated resources
@ -94,40 +93,36 @@ RepairGUI_RemoveIntWiresDlg::~RepairGUI_RemoveIntWiresDlg()
{
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void RepairGUI_RemoveIntWiresDlg::Init()
{
/* init variables */
myEditCurrentArgument = GroupPoints->LineEdit1;
// init variables
GroupPoints->LineEdit1->clear();
GroupPoints->LineEdit2->clear();
myObject = GEOM::GEOM_Object::_nil();
myWiresInd = new GEOM::short_array();
myWiresInd->length(0);
//myGeomGUI->SetState( 0 );
initSelection();
/* signals and slots connections */
// 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()));
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( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
connect(GroupPoints->CheckButton1, SIGNAL(clicked()), this, SLOT(onRemoveAllClicked()));
initName(tr("REMOVE_INT_WIRES_NEW_OBJ_NAME"));
}
GroupPoints->PushButton1->click();
SelectionIntoArgument();
}
//=================================================================================
// function : ClickOnOk()
@ -149,28 +144,24 @@ bool RepairGUI_RemoveIntWiresDlg::ClickOnApply()
return false;
initName();
myEditCurrentArgument = GroupPoints->LineEdit1;
myEditCurrentArgument->setText( "" );
GroupPoints->LineEdit2->setText( "" );
myObject = GEOM::GEOM_Object::_nil();
myWiresInd->length( 0 );
initSelection();
// activate first line edit
GroupPoints->PushButton1->click();
return true;
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection
// purpose : Called when selection is changed or on dialog initialization or activation
//=================================================================================
void RepairGUI_RemoveIntWiresDlg::SelectionIntoArgument()
{
myEditCurrentArgument->setText("");
if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) myObject = GEOM::GEOM_Object::_nil();
else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) myWiresInd->length( 0 );
// the second argument depends on the first one
GroupPoints->LineEdit2->setText("");
myWiresInd->length(0);
if (myEditCurrentArgument == GroupPoints->LineEdit1)
myObject = GEOM::GEOM_Object::_nil();
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
SALOME_ListIO aSelList;
@ -182,8 +173,18 @@ void RepairGUI_RemoveIntWiresDlg::SelectionIntoArgument()
if (myEditCurrentArgument == GroupPoints->LineEdit1) { // face selection
Standard_Boolean aRes;
myObject = GEOMBase::ConvertIOinGEOMObject(anIO, aRes);
if ( aRes && GEOMBase::IsShape( myObject ) )
if (aRes && GEOMBase::IsShape(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
myObject = GEOM::GEOM_Object::_nil();
}
@ -207,19 +208,35 @@ void RepairGUI_RemoveIntWiresDlg::SelectionIntoArgument()
//=================================================================================
void RepairGUI_RemoveIntWiresDlg::SetEditCurrentArgument()
{
const QObject* send = sender();
if ( send == GroupPoints->PushButton1 )
QPushButton* send = (QPushButton*)sender();
bool isEffective = false;
if (send == GroupPoints->PushButton1) {
isEffective = true;
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;
if ( myEditCurrentArgument ) {
initSelection();
myEditCurrentArgument->setFocus();
SelectionIntoArgument();
}
GroupPoints->PushButton1->setDown(false);
GroupPoints->LineEdit1->setEnabled(false);
}
if (isEffective) {
initSelection();
// enable line edit
myEditCurrentArgument->setEnabled(true);
myEditCurrentArgument->setFocus();
// after setFocus(), because it will be setDown(false) when loses focus
send->setDown(true);
}
}
//=================================================================================
// function : LineEditReturnPressed()
@ -234,7 +251,6 @@ void RepairGUI_RemoveIntWiresDlg::LineEditReturnPressed()
}
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
@ -242,17 +258,9 @@ void RepairGUI_RemoveIntWiresDlg::LineEditReturnPressed()
void RepairGUI_RemoveIntWiresDlg::ActivateThisDialog()
{
GEOMBase_Skeleton::ActivateThisDialog();
connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
myEditCurrentArgument = GroupPoints->LineEdit1;
myEditCurrentArgument->setText( "" );
GroupPoints->LineEdit2->setText( "" );
myObject = GEOM::GEOM_Object::_nil();
myWiresInd->length( 0 );
//myGeomGUI->SetState( 0 );
initSelection();
// reinit, because some selected objects could be removed
Init();
}
//=================================================================================
@ -291,6 +299,7 @@ bool RepairGUI_RemoveIntWiresDlg::execute( ObjectList& objects )
{
GEOM::GEOM_Object_var anObj = GEOM::GEOM_IHealingOperations::_narrow(getOperation())->
RemoveIntWires(myObject, myWiresInd);
bool aResult = !anObj->_is_nil();
if (aResult)
objects.push_back(anObj._retn());
@ -320,6 +329,8 @@ void RepairGUI_RemoveIntWiresDlg::onRemoveAllClicked()
//=================================================================================
void RepairGUI_RemoveIntWiresDlg::initSelection()
{
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
if (myEditCurrentArgument == GroupPoints->LineEdit1) {
TColStd_MapOfInteger aTypes;
aTypes.Add(GEOM_COMPOUND);
@ -333,4 +344,7 @@ void RepairGUI_RemoveIntWiresDlg::initSelection()
//localSelection(myObject, TopAbs_EDGE);
localSelection(myObject, TopAbs_WIRE);
}
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
}