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

This commit is contained in:
jfa 2008-09-19 06:55:25 +00:00
parent b21305abc8
commit ab22b2dd47
5 changed files with 606 additions and 387 deletions

View File

@ -246,8 +246,7 @@ void BlocksGUI_BlockDlg::SelectionIntoArgument()
// nbSel == 1 // nbSel == 1
Standard_Boolean testResult = Standard_False; Standard_Boolean testResult = Standard_False;
GEOM::GEOM_Object_var aSelectedObject = GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult);
GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult);
if (!testResult || CORBA::is_nil(aSelectedObject)) if (!testResult || CORBA::is_nil(aSelectedObject))
return; return;

View File

@ -27,69 +27,74 @@
#include <DlgRef.h> #include <DlgRef.h>
#include <GeometryGUI.h> #include <GeometryGUI.h>
#include <GEOMBase.h> #include <GEOMBase.h>
#include <GEOMImpl_Types.hxx>
#include <SUIT_Session.h> #include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h> #include <SUIT_ResourceMgr.h>
#include <SalomeApp_Application.h> #include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h> #include <LightApp_SelectionMgr.h>
#include <GEOMImpl_Types.hxx>
#include <qlabel.h> #include <qlabel.h>
// OCCT Includes
#include <TColStd_IndexedMapOfInteger.hxx>
#include <TopAbs.hxx>
//================================================================================= //=================================================================================
// class : BlocksGUI_QuadFaceDlg() // class : BlocksGUI_QuadFaceDlg()
// purpose : Constructs a BlocksGUI_QuadFaceDlg which is a child of 'parent'. // purpose : Constructs a BlocksGUI_QuadFaceDlg which is a child of 'parent'.
//================================================================================= //=================================================================================
BlocksGUI_QuadFaceDlg::BlocksGUI_QuadFaceDlg( GeometryGUI* theGeometryGUI, QWidget* parent ) BlocksGUI_QuadFaceDlg::BlocksGUI_QuadFaceDlg (GeometryGUI* theGeometryGUI, QWidget* parent)
: GEOMBase_Skeleton( theGeometryGUI, parent ) : GEOMBase_Skeleton(theGeometryGUI, parent),
myInitial(true)
{ {
SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr(); SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr();
QPixmap image1( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_QUAD_FACE_4_VERT" ) ) ); QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_QUAD_FACE_4_VERT")));
QPixmap image2( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_QUAD_FACE_2_EDGE" ) ) ); QPixmap image2 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_QUAD_FACE_2_EDGE")));
QPixmap image3( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_QUAD_FACE_4_EDGE" ) ) ); QPixmap image3 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_QUAD_FACE_4_EDGE")));
QPixmap imageS( aResMgr->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) ); QPixmap imageS (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
setWindowTitle( tr( "GEOM_QUAD_FACE_TITLE" ) ); setWindowTitle(tr("GEOM_QUAD_FACE_TITLE"));
/***************************************************************/ /***************************************************************/
mainFrame()->GroupConstructors->setTitle( tr( "GEOM_QUAD_FACE" ) ); mainFrame()->GroupConstructors->setTitle(tr("GEOM_QUAD_FACE"));
mainFrame()->RadioButton1->setIcon( image1 ); mainFrame()->RadioButton1->setIcon(image1);
mainFrame()->RadioButton2->setIcon( image2 ); mainFrame()->RadioButton2->setIcon(image2);
mainFrame()->RadioButton3->setIcon( image3 ); mainFrame()->RadioButton3->setIcon(image3);
// Create first group // Create first group
myGrp1 = new QGroupBox( tr( "GEOM_ARGUMENTS" ), centralWidget() ); myGrp1 = new QGroupBox(tr("GEOM_ARGUMENTS"), centralWidget());
createSelWg( tr( "VERTEX_1" ), imageS, myGrp1, Vertex1 ); createSelWg(tr("VERTEX_1"), imageS, myGrp1, Vertex1);
createSelWg( tr( "VERTEX_2" ), imageS, myGrp1, Vertex2 ); createSelWg(tr("VERTEX_2"), imageS, myGrp1, Vertex2);
createSelWg( tr( "VERTEX_3" ), imageS, myGrp1, Vertex3 ); createSelWg(tr("VERTEX_3"), imageS, myGrp1, Vertex3);
createSelWg( tr( "VERTEX_4" ), imageS, myGrp1, Vertex4 ); createSelWg(tr("VERTEX_4"), imageS, myGrp1, Vertex4);
// Create second group // Create second group
myGrp2 = new QGroupBox( tr( "GEOM_ARGUMENTS" ), centralWidget() ); myGrp2 = new QGroupBox(tr("GEOM_ARGUMENTS"), centralWidget());
createSelWg( tr( "EDGE_1" ), imageS, myGrp2, Edge12 ); createSelWg(tr("EDGE_1"), imageS, myGrp2, Edge12);
createSelWg( tr( "EDGE_2" ), imageS, myGrp2, Edge22 ); createSelWg(tr("EDGE_2"), imageS, myGrp2, Edge22);
// Create fird group // Create fird group
myGrp3 = new QGroupBox( tr( "GEOM_ARGUMENTS" ), centralWidget() ); myGrp3 = new QGroupBox(tr("GEOM_ARGUMENTS"), centralWidget());
createSelWg( tr( "EDGE_1" ), imageS, myGrp3, Edge14 ); createSelWg(tr("EDGE_1"), imageS, myGrp3, Edge14);
createSelWg( tr( "EDGE_2" ), imageS, myGrp3, Edge24 ); createSelWg(tr("EDGE_2"), imageS, myGrp3, Edge24);
createSelWg( tr( "EDGE_3" ), imageS, myGrp3, Edge34 ); createSelWg(tr("EDGE_3"), imageS, myGrp3, Edge34);
createSelWg( tr( "EDGE_4" ), imageS, myGrp3, Edge44 ); createSelWg(tr("EDGE_4"), imageS, myGrp3, Edge44);
// Add groups to layout // Add groups to layout
QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); QVBoxLayout* layout = new QVBoxLayout(centralWidget());
layout->setMargin( 0 ); layout->setSpacing( 6 ); layout->setMargin(0); layout->setSpacing(6);
layout->addWidget( myGrp1 ); layout->addWidget(myGrp1);
layout->addWidget( myGrp2 ); layout->addWidget(myGrp2);
layout->addWidget( myGrp3 ); layout->addWidget(myGrp3);
/***************************************************************/ /***************************************************************/
setHelpFileName( "build_by_blocks_page.html#quad_face_anchor" ); setHelpFileName("build_by_blocks_page.html#quad_face_anchor");
Init(); Init();
} }
@ -110,74 +115,71 @@ BlocksGUI_QuadFaceDlg::~BlocksGUI_QuadFaceDlg()
void BlocksGUI_QuadFaceDlg::Init() void BlocksGUI_QuadFaceDlg::Init()
{ {
// 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( this, SIGNAL( constructorsClicked( int ) ), connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
this, SLOT( ConstructorsClicked( int ) ) );
QMap<int, QPushButton*>::iterator anIterBtn; QMap<int, QPushButton*>::iterator anIterBtn;
for ( anIterBtn = mySelBtn.begin(); anIterBtn != mySelBtn.end(); ++anIterBtn ) for (anIterBtn = mySelBtn.begin(); anIterBtn != mySelBtn.end(); ++anIterBtn)
connect( anIterBtn.value(), SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect(anIterBtn.value(), SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
// init controls and fields // init controls and fields
initName( tr( "GEOM_QUAD_FACE" ) ); initName(tr("GEOM_QUAD_FACE"));
myConstructorId = -1; myConstructorId = -1;
ConstructorsClicked( 0 ); ConstructorsClicked(0);
} }
//================================================================================= //=================================================================================
// function : ConstructorsClicked() // function : ConstructorsClicked()
// purpose : Radio button management // purpose : Radio button management
//================================================================================= //=================================================================================
void BlocksGUI_QuadFaceDlg::ConstructorsClicked( int constructorId ) void BlocksGUI_QuadFaceDlg::ConstructorsClicked (int constructorId)
{ {
if ( myConstructorId == constructorId ) if (myConstructorId == constructorId)
return; return;
myConstructorId = constructorId; myConstructorId = constructorId;
switch ( constructorId ) {
case 0:
myGrp2->hide();
myGrp3->hide();
myGrp1->show();
myEditCurrentArgument = mySelName[Vertex1];
break;
case 1:
myGrp1->hide();
myGrp3->hide();
myGrp2->show();
myEditCurrentArgument = mySelName[Edge12];
break;
case 2:
myGrp1->hide();
myGrp2->hide();
myGrp3->show();
myEditCurrentArgument = mySelName[Edge14];
break;
default:
break;
}
// clear line edits
QMap<int, QLineEdit*>::iterator anIterLE;
for ( anIterLE = mySelName.begin(); anIterLE != mySelName.end(); ++anIterLE )
anIterLE.value()->setText( "" );
// init fields // init fields
myShape1 = myShape2 = GEOM::GEOM_Object::_nil(); myShape1 = myShape2 = GEOM::GEOM_Object::_nil();
myShape3 = myShape4 = myShape1; myShape3 = myShape4 = myShape1;
// clear line edits
QMap<int, QLineEdit*>::iterator anIterLE;
for (anIterLE = mySelName.begin(); anIterLE != mySelName.end(); ++anIterLE)
anIterLE.value()->setText("");
switch (constructorId) {
case 0:
myGrp2->hide();
myGrp3->hide();
myGrp1->show();
mySelBtn[Vertex1]->click();
break;
case 1:
myGrp1->hide();
myGrp3->hide();
myGrp2->show();
mySelBtn[Edge12]->click();
break;
case 2:
myGrp1->hide();
myGrp2->hide();
myGrp3->show();
mySelBtn[Edge14]->click();
break;
default:
break;
}
qApp->processEvents(); qApp->processEvents();
updateGeometry(); updateGeometry();
resize( minimumSize() ); resize(minimumSize());
activateSelection(); // on dialog initialization we init the first field with a selected object (if any)
SelectionIntoArgument();
} }
//================================================================================= //=================================================================================
@ -186,7 +188,7 @@ void BlocksGUI_QuadFaceDlg::ConstructorsClicked( int constructorId )
//================================================================================= //=================================================================================
void BlocksGUI_QuadFaceDlg::ClickOnOk() void BlocksGUI_QuadFaceDlg::ClickOnOk()
{ {
if ( ClickOnApply() ) if (ClickOnApply())
ClickOnCancel(); ClickOnCancel();
} }
@ -196,7 +198,7 @@ void BlocksGUI_QuadFaceDlg::ClickOnOk()
//================================================================================= //=================================================================================
bool BlocksGUI_QuadFaceDlg::ClickOnApply() bool BlocksGUI_QuadFaceDlg::ClickOnApply()
{ {
if ( !onAccept() ) if (!onAccept())
return false; return false;
initName(); initName();
@ -205,18 +207,17 @@ bool BlocksGUI_QuadFaceDlg::ClickOnApply()
//================================================================================= //=================================================================================
// function : SelectionIntoArgument() // function : SelectionIntoArgument()
// purpose : Called when selection has changed // purpose : Called when selection is changed or on dialog initialization or activation
//================================================================================= //=================================================================================
void BlocksGUI_QuadFaceDlg::SelectionIntoArgument() void BlocksGUI_QuadFaceDlg::SelectionIntoArgument()
{ {
erasePreview(); erasePreview();
myEditCurrentArgument->setText( "" );
// Get index of current selection focus // Get index of current selection focus
int aCurrFocus = -1; int aCurrFocus = -1;
QMap<int, QLineEdit*>::iterator anIter; QMap<int, QLineEdit*>::iterator anIter;
for ( anIter = mySelName.begin(); anIter != mySelName.end(); ++anIter ) { for (anIter = mySelName.begin(); anIter != mySelName.end(); ++anIter) {
if ( myEditCurrentArgument == anIter.value() ) { if (myEditCurrentArgument == anIter.value()) {
aCurrFocus = anIter.key(); aCurrFocus = anIter.key();
break; break;
} }
@ -226,41 +227,118 @@ void BlocksGUI_QuadFaceDlg::SelectionIntoArgument()
SALOME_ListIO aSelList; SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList); aSelMgr->selectedObjects(aSelList);
GEOM::GEOM_Object_var anObj; TopAbs_ShapeEnum aType = TopAbs_EDGE;
if (aCurrFocus == Vertex1 || aCurrFocus == Vertex2 ||
aCurrFocus == Vertex3 || aCurrFocus == Vertex4)
aType = TopAbs_VERTEX;
QString aName;
GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object::_nil();
if (aSelList.Extent() == 1) { if (aSelList.Extent() == 1) {
Standard_Boolean aResult = Standard_False; Standard_Boolean aResult = Standard_False;
anObj = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aResult); anObj = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aResult);
if ( aResult ) { if (aResult && !anObj->_is_nil()) {
if (anObj->_is_nil()) { aName = GEOMBase::GetName(anObj);
aResult = Standard_False;
} // Get Selected object if selected subshape
else { TopoDS_Shape aShape;
mySelName[aCurrFocus]->setText( GEOMBase::GetName( anObj ) ); if (GEOMBase::GetShape(anObj, aShape, TopAbs_SHAPE) && !aShape.IsNull())
{
TColStd_IndexedMapOfInteger aMap;
aSelMgr->GetIndexes(aSelList.First(), aMap);
if (aMap.Extent() == 1) // Local Selection
{
int anIndex = aMap(1);
if (aType == TopAbs_VERTEX)
aName += QString(":vertex_%1").arg(anIndex);
else
aName += QString(":edge_%1").arg(anIndex);
//Find SubShape Object in Father
GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(anObj, aName);
if (aFindedObject == GEOM::GEOM_Object::_nil()) { // Object not found in study
GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId());
anObj = aShapesOp->GetSubShape(anObj, anIndex);
}
else
anObj = aFindedObject; // get Object from study
}
else // Global Selection
{
if (aShape.ShapeType() != aType) {
anObj = GEOM::GEOM_Object::_nil();
aName = "";
}
}
} }
}
else {
anObj = GEOM::GEOM_Object::_nil();
} }
} }
switch ( aCurrFocus ) { myEditCurrentArgument->setText(aName);
switch (aCurrFocus) {
// four vertices
case Vertex1: case Vertex1:
case Edge12: myShape1 = anObj;
case Edge14: if (!myShape1->_is_nil() && myShape2->_is_nil())
myShape1 = anObj; break; mySelBtn[Vertex2]->click();
break;
case Vertex2: case Vertex2:
case Edge22: myShape2 = anObj;
case Edge24: if (!myShape2->_is_nil() && myShape3->_is_nil())
myShape2 = anObj; break; mySelBtn[Vertex3]->click();
break;
case Vertex3: case Vertex3:
case Edge34: myShape3 = anObj;
myShape3 = anObj; break; if (!myShape3->_is_nil() && myShape4->_is_nil())
mySelBtn[Vertex4]->click();
break;
case Vertex4: case Vertex4:
myShape4 = anObj;
if (!myShape4->_is_nil() && myShape1->_is_nil())
mySelBtn[Vertex1]->click();
break;
// two edges
case Edge12:
myShape1 = anObj;
if (!myShape1->_is_nil() && myShape2->_is_nil())
mySelBtn[Edge22]->click();
break;
case Edge22:
myShape2 = anObj;
if (!myShape2->_is_nil() && myShape1->_is_nil())
mySelBtn[Edge12]->click();
break;
// four edges
case Edge14:
myShape1 = anObj;
if (!myShape1->_is_nil() && myShape2->_is_nil())
mySelBtn[Edge24]->click();
break;
case Edge24:
myShape2 = anObj;
if (!myShape2->_is_nil() && myShape3->_is_nil())
mySelBtn[Edge34]->click();
break;
case Edge34:
myShape3 = anObj;
if (!myShape3->_is_nil() && myShape4->_is_nil())
mySelBtn[Edge44]->click();
break;
case Edge44: case Edge44:
myShape4 = anObj; break; myShape4 = anObj;
if (!myShape4->_is_nil() && myShape1->_is_nil())
mySelBtn[Edge14]->click();
break;
default: default:
return; break;
} }
displayPreview(); displayPreview();
} }
@ -272,14 +350,64 @@ void BlocksGUI_QuadFaceDlg::SetEditCurrentArgument()
{ {
QPushButton* aSender = (QPushButton*)sender(); QPushButton* aSender = (QPushButton*)sender();
// clear selection
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
if (myInitial)
myInitial = false;
else
myGeomGUI->getApp()->selectionMgr()->clearSelected();
// disable all
switch (myConstructorId) {
case 0:
mySelBtn[Vertex1]->setDown(false);
mySelBtn[Vertex2]->setDown(false);
mySelBtn[Vertex3]->setDown(false);
mySelBtn[Vertex4]->setDown(false);
mySelName[Vertex1]->setEnabled(false);
mySelName[Vertex2]->setEnabled(false);
mySelName[Vertex3]->setEnabled(false);
mySelName[Vertex4]->setEnabled(false);
break;
case 1:
mySelBtn[Edge12]->setDown(false);
mySelBtn[Edge22]->setDown(false);
mySelName[Edge12]->setEnabled(false);
mySelName[Edge22]->setEnabled(false);
break;
case 2:
mySelBtn[Edge14]->setDown(false);
mySelBtn[Edge24]->setDown(false);
mySelBtn[Edge34]->setDown(false);
mySelBtn[Edge44]->setDown(false);
mySelName[Edge14]->setEnabled(false);
mySelName[Edge24]->setEnabled(false);
mySelName[Edge34]->setEnabled(false);
mySelName[Edge44]->setEnabled(false);
break;
default:
break;
}
// enable push button
aSender->setDown(true);
// set line edit as current argument
QMap<int, QPushButton*>::iterator anIter; QMap<int, QPushButton*>::iterator anIter;
for ( anIter = mySelBtn.begin(); anIter != mySelBtn.end(); ++anIter ) { for (anIter = mySelBtn.begin(); anIter != mySelBtn.end(); ++anIter) {
if ( anIter.value() == aSender ) { if (anIter.value() == aSender) {
mySelName[anIter.key()]->setFocus();
myEditCurrentArgument = mySelName[anIter.key()]; myEditCurrentArgument = mySelName[anIter.key()];
break;
} }
} }
// enable line edit
myEditCurrentArgument->setEnabled(true);
myEditCurrentArgument->setFocus();
activateSelection(); activateSelection();
} }
@ -290,10 +418,9 @@ void BlocksGUI_QuadFaceDlg::SetEditCurrentArgument()
void BlocksGUI_QuadFaceDlg::ActivateThisDialog() void BlocksGUI_QuadFaceDlg::ActivateThisDialog()
{ {
GEOMBase_Skeleton::ActivateThisDialog(); GEOMBase_Skeleton::ActivateThisDialog();
connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
activateSelection(); activateSelection();
// ??
displayPreview(); displayPreview();
} }
@ -301,49 +428,39 @@ void BlocksGUI_QuadFaceDlg::ActivateThisDialog()
// function : enterEvent() // function : enterEvent()
// purpose : // purpose :
//================================================================================= //=================================================================================
void BlocksGUI_QuadFaceDlg::enterEvent( QEvent* ) void BlocksGUI_QuadFaceDlg::enterEvent (QEvent*)
{ {
if ( !mainFrame()->GroupConstructors->isEnabled() ) if (!mainFrame()->GroupConstructors->isEnabled())
this->ActivateThisDialog(); ActivateThisDialog();
} }
//=================================================================================
// function : DeactivateActiveDialog()
// purpose :
//=================================================================================
//void BlocksGUI_QuadFaceDlg::DeactivateActiveDialog()
//{
// // disconnect selection
// GEOMBase_Skeleton::DeactivateActiveDialog();
//}
//================================================================================= //=================================================================================
// function : createSelWg() // function : createSelWg()
// purpose : // purpose :
//================================================================================= //=================================================================================
void BlocksGUI_QuadFaceDlg::createSelWg( const QString& theLbl, void BlocksGUI_QuadFaceDlg::createSelWg (const QString& theLbl,
QPixmap& thePix, QPixmap& thePix,
QWidget* theParent, QWidget* theParent,
const int theId ) const int theId)
{ {
QLabel* lab = new QLabel( theLbl, theParent ); QLabel* lab = new QLabel(theLbl, theParent);
mySelBtn[theId] = new QPushButton( theParent ); mySelBtn[theId] = new QPushButton(theParent);
mySelBtn[theId]->setIcon( thePix ); mySelBtn[theId]->setIcon(thePix);
mySelBtn[theId]->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); mySelBtn[theId]->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
mySelName[theId] = new QLineEdit( theParent ); mySelName[theId] = new QLineEdit(theParent);
mySelName[theId]->setReadOnly( true ); mySelName[theId]->setReadOnly(true);
QGridLayout* l = 0; QGridLayout* l = 0;
if ( !theParent->layout() ) { if (!theParent->layout()) {
l = new QGridLayout( theParent ); l = new QGridLayout(theParent);
l->setMargin( 9 ); l->setSpacing( 6 ); l->setMargin(9); l->setSpacing(6);
} }
else { else {
l = qobject_cast<QGridLayout*>( theParent->layout() ); l = qobject_cast<QGridLayout*>(theParent->layout());
} }
int row = l->rowCount(); int row = l->rowCount();
l->addWidget( lab, row, 0 ); l->addWidget(lab, row, 0);
l->addWidget( mySelBtn[theId], row, 1 ); l->addWidget(mySelBtn[theId], row, 1);
l->addWidget( mySelName[theId], row, 2 ); l->addWidget(mySelName[theId], row, 2);
} }
//================================================================================= //=================================================================================
@ -352,17 +469,20 @@ void BlocksGUI_QuadFaceDlg::createSelWg( const QString& theLbl,
//================================================================================= //=================================================================================
void BlocksGUI_QuadFaceDlg::activateSelection() void BlocksGUI_QuadFaceDlg::activateSelection()
{ {
if ( myEditCurrentArgument == mySelName[Vertex1] || globalSelection(); // close local contexts, if any
myEditCurrentArgument == mySelName[Vertex2] || if (myEditCurrentArgument == mySelName[Vertex1] ||
myEditCurrentArgument == mySelName[Vertex3] || myEditCurrentArgument == mySelName[Vertex2] ||
myEditCurrentArgument == mySelName[Vertex4] ) { myEditCurrentArgument == mySelName[Vertex3] ||
globalSelection( GEOM_POINT ); myEditCurrentArgument == mySelName[Vertex4])
} {
else { localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); //Select Vertices on All Shapes
globalSelection( GEOM_EDGE );
} }
else
SelectionIntoArgument(); {
localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE); //Select Edges on All Shapes
}
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
} }
//================================================================================= //=================================================================================
@ -371,27 +491,27 @@ void BlocksGUI_QuadFaceDlg::activateSelection()
//================================================================================= //=================================================================================
GEOM::GEOM_IOperations_ptr BlocksGUI_QuadFaceDlg::createOperation() GEOM::GEOM_IOperations_ptr BlocksGUI_QuadFaceDlg::createOperation()
{ {
return getGeomEngine()->GetIBlocksOperations( getStudyId() ); return getGeomEngine()->GetIBlocksOperations(getStudyId());
} }
//================================================================================= //=================================================================================
// function : isValid // function : isValid
// purpose : Verify validity of input data // purpose : Verify validity of input data
//================================================================================= //=================================================================================
bool BlocksGUI_QuadFaceDlg::isValid( QString& ) bool BlocksGUI_QuadFaceDlg::isValid (QString&)
{ {
bool ok = false; bool ok = false;
switch ( getConstructorId() ) { switch (getConstructorId()) {
case 0: case 0:
ok = ( !myShape1->_is_nil() && !myShape2->_is_nil() && ok = (!myShape1->_is_nil() && !myShape2->_is_nil() &&
!myShape3->_is_nil() && !myShape4->_is_nil() ); !myShape3->_is_nil() && !myShape4->_is_nil());
break; break;
case 1: case 1:
ok = ( !myShape1->_is_nil() && !myShape2->_is_nil() ); ok = (!myShape1->_is_nil() && !myShape2->_is_nil());
break; break;
case 2: case 2:
ok = ( !myShape1->_is_nil() && !myShape2->_is_nil() && ok = (!myShape1->_is_nil() && !myShape2->_is_nil() &&
!myShape3->_is_nil() && !myShape4->_is_nil() ); !myShape3->_is_nil() && !myShape4->_is_nil());
break; break;
default: default:
break; break;
@ -403,34 +523,63 @@ bool BlocksGUI_QuadFaceDlg::isValid( QString& )
// function : execute // function : execute
// purpose : // purpose :
//================================================================================= //=================================================================================
bool BlocksGUI_QuadFaceDlg::execute( ObjectList& objects ) bool BlocksGUI_QuadFaceDlg::execute (ObjectList& objects)
{ {
bool res = false; bool res = false;
GEOM::GEOM_Object_var anObj; GEOM::GEOM_Object_var anObj;
switch ( getConstructorId() ) { switch (getConstructorId()) {
case 0: case 0:
anObj = GEOM::GEOM_IBlocksOperations::_narrow( getOperation() )->MakeQuad4Vertices anObj = GEOM::GEOM_IBlocksOperations::_narrow(getOperation())->
( myShape1, myShape2, myShape3, myShape4 ); MakeQuad4Vertices(myShape1, myShape2, myShape3, myShape4);
res = true; res = true;
break; break;
case 1: case 1:
anObj = GEOM::GEOM_IBlocksOperations::_narrow( getOperation() )->MakeQuad2Edges anObj = GEOM::GEOM_IBlocksOperations::_narrow(getOperation())->
( myShape1, myShape2 ); MakeQuad2Edges(myShape1, myShape2);
res = true; res = true;
break; break;
case 2: case 2:
anObj = GEOM::GEOM_IBlocksOperations::_narrow( getOperation() )->MakeQuad anObj = GEOM::GEOM_IBlocksOperations::_narrow(getOperation())->
( myShape1, myShape2, myShape3, myShape4 ); MakeQuad(myShape1, myShape2, myShape3, myShape4);
res = true; res = true;
break; break;
default: default:
break; break;
} }
if ( !anObj->_is_nil() ) if (!anObj->_is_nil())
objects.push_back( anObj._retn() ); objects.push_back(anObj._retn());
return res; return res;
} }
//=================================================================================
// function : addSubshapeToStudy
// purpose : virtual method to add new SubObjects if local selection
//=================================================================================
void BlocksGUI_QuadFaceDlg::addSubshapesToStudy()
{
QMap<QString, GEOM::GEOM_Object_var> objMap;
switch (getConstructorId()) {
case 0:
objMap[mySelName[Vertex1]->text()] = myShape1;
objMap[mySelName[Vertex2]->text()] = myShape2;
objMap[mySelName[Vertex3]->text()] = myShape3;
objMap[mySelName[Vertex4]->text()] = myShape4;
break;
case 1:
objMap[mySelName[Edge12]->text()] = myShape1;
objMap[mySelName[Edge22]->text()] = myShape2;
break;
case 2:
objMap[mySelName[Edge14]->text()] = myShape1;
objMap[mySelName[Edge24]->text()] = myShape2;
objMap[mySelName[Edge34]->text()] = myShape3;
objMap[mySelName[Edge44]->text()] = myShape4;
break;
}
addSubshapesToFather(objMap);
}

View File

@ -42,25 +42,26 @@ class BlocksGUI_QuadFaceDlg : public GEOMBase_Skeleton
Q_OBJECT Q_OBJECT
enum { Vertex1, Vertex2, Vertex3, Vertex4, enum { Vertex1, Vertex2, Vertex3, Vertex4,
Edge12, Edge22, Edge12, Edge22,
Edge14, Edge24, Edge34, Edge44 }; Edge14, Edge24, Edge34, Edge44 };
public: public:
BlocksGUI_QuadFaceDlg( GeometryGUI*, QWidget* ); BlocksGUI_QuadFaceDlg (GeometryGUI*, QWidget*);
~BlocksGUI_QuadFaceDlg(); ~BlocksGUI_QuadFaceDlg();
protected: protected:
// redefined from GEOMBase_Helper // redefined from GEOMBase_Helper
virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual GEOM::GEOM_IOperations_ptr createOperation();
virtual bool isValid( QString& ); virtual bool isValid (QString&);
virtual bool execute( ObjectList& ); virtual bool execute (ObjectList&);
virtual void addSubshapesToStudy();
private: private:
void Init(); void Init();
void enterEvent( QEvent* ); void enterEvent (QEvent*);
void createSelWg( const QString&, QPixmap&, void createSelWg (const QString&, QPixmap&,
QWidget*, const int ); QWidget*, const int);
void activateSelection(); void activateSelection();
private: private:
@ -71,6 +72,9 @@ private:
GEOM::GEOM_Object_var myShape3; GEOM::GEOM_Object_var myShape3;
GEOM::GEOM_Object_var myShape4; GEOM::GEOM_Object_var myShape4;
// to initialize the first selection field with a selected object on the dialog creation
bool myInitial;
QGroupBox* myGrp1; QGroupBox* myGrp1;
QGroupBox* myGrp2; QGroupBox* myGrp2;
QGroupBox* myGrp3; QGroupBox* myGrp3;
@ -82,7 +86,7 @@ private slots:
void ClickOnOk(); void ClickOnOk();
bool ClickOnApply(); bool ClickOnApply();
void ActivateThisDialog(); void ActivateThisDialog();
void ConstructorsClicked( int ); void ConstructorsClicked (int);
void SelectionIntoArgument(); void SelectionIntoArgument();
void SetEditCurrentArgument(); void SetEditCurrentArgument();

View File

@ -37,57 +37,59 @@
#include <LightApp_SelectionMgr.h> #include <LightApp_SelectionMgr.h>
#include <OCCViewer_ViewModel.h> #include <OCCViewer_ViewModel.h>
// OCCT Includes
#include <TColStd_IndexedMapOfInteger.hxx> #include <TColStd_IndexedMapOfInteger.hxx>
//================================================================================= //=================================================================================
// class : BlocksGUI_TrsfDlg() // class : BlocksGUI_TrsfDlg()
// purpose : Constructs a BlocksGUI_TrsfDlg which is a child of 'parent'. // purpose : Constructs a BlocksGUI_TrsfDlg which is a child of 'parent'.
//================================================================================= //=================================================================================
BlocksGUI_TrsfDlg::BlocksGUI_TrsfDlg( GeometryGUI* theGeometryGUI, QWidget* parent ) BlocksGUI_TrsfDlg::BlocksGUI_TrsfDlg (GeometryGUI* theGeometryGUI, QWidget* parent)
: GEOMBase_Skeleton( theGeometryGUI, parent ) : GEOMBase_Skeleton(theGeometryGUI, parent),
myInitial(true)
{ {
SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr(); SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr();
QPixmap image1( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_BLOCK_MULTITRSF_SIMPLE" ) ) ); QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_BLOCK_MULTITRSF_SIMPLE")));
QPixmap image2( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_BLOCK_MULTITRSF_DOUBLE" ) ) ); QPixmap image2 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_BLOCK_MULTITRSF_DOUBLE")));
QPixmap imageS( aResMgr->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) ); QPixmap imageS (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
setWindowTitle( tr( "GEOM_BLOCK_MULTITRSF_TITLE" ) ); setWindowTitle(tr("GEOM_BLOCK_MULTITRSF_TITLE"));
/***************************************************************/ /***************************************************************/
mainFrame()->GroupConstructors->setTitle( tr( "GEOM_BLOCK_MULTITRSF" ) ); mainFrame()->GroupConstructors->setTitle(tr("GEOM_BLOCK_MULTITRSF"));
mainFrame()->RadioButton1->setIcon( image1 ); mainFrame()->RadioButton1->setIcon(image1);
mainFrame()->RadioButton2->setIcon( image2 ); mainFrame()->RadioButton2->setIcon(image2);
mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose ); mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
mainFrame()->RadioButton3->close(); mainFrame()->RadioButton3->close();
// Create first group // Create first group
myGrp1 = new QGroupBox( tr( "GEOM_BLOCK_MULTITRSF_SIMPLE" ), centralWidget() ); myGrp1 = new QGroupBox(tr("GEOM_BLOCK_MULTITRSF_SIMPLE"), centralWidget());
createSelWg( tr( "GEOM_MAIN_OBJECT" ), imageS, myGrp1, MainObj1 ); createSelWg(tr("GEOM_MAIN_OBJECT"), imageS, myGrp1, MainObj1);
createSelWg( tr( "FACE_1" ), imageS, myGrp1, Face1 ); createSelWg(tr("FACE_1"), imageS, myGrp1, Face1);
createSelWg( tr( "FACE_2" ), imageS, myGrp1, Face2 ); createSelWg(tr("FACE_2"), imageS, myGrp1, Face2);
createSpinWg( tr( "GEOM_NB_TIMES" ), myGrp1, SpinBox1 ); createSpinWg(tr("GEOM_NB_TIMES"), myGrp1, SpinBox1);
// Create second group // Create second group
myGrp2 = new QGroupBox( tr( "GEOM_BLOCK_MULTITRSF_DOUBLE" ), centralWidget() ); myGrp2 = new QGroupBox(tr("GEOM_BLOCK_MULTITRSF_DOUBLE"), centralWidget());
createSelWg( tr( "GEOM_MAIN_OBJECT"), imageS, myGrp2, MainObj2 ); createSelWg(tr("GEOM_MAIN_OBJECT"), imageS, myGrp2, MainObj2);
createSelWg( tr( "FACE_1U"), imageS, myGrp2, Face1U ); createSelWg(tr("FACE_1U"), imageS, myGrp2, Face1U);
createSelWg( tr( "FACE_2U"), imageS, myGrp2, Face2U ); createSelWg(tr("FACE_2U"), imageS, myGrp2, Face2U);
createSpinWg( tr( "GEOM_NB_TIMES_U" ), myGrp2, SpinBox2U ); createSpinWg(tr("GEOM_NB_TIMES_U"), myGrp2, SpinBox2U);
createSelWg( tr( "FACE_1V" ), imageS, myGrp2, Face1V ); createSelWg(tr("FACE_1V"), imageS, myGrp2, Face1V);
createSelWg( tr( "FACE_2V" ), imageS, myGrp2, Face2V ); createSelWg(tr("FACE_2V"), imageS, myGrp2, Face2V);
createSpinWg( tr( "GEOM_NB_TIMES_V" ), myGrp2, SpinBox2V ); createSpinWg(tr("GEOM_NB_TIMES_V"), myGrp2, SpinBox2V);
// Add groups to layout // Add groups to layout
QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); QVBoxLayout* layout = new QVBoxLayout(centralWidget());
layout->setMargin( 0 ); layout->setSpacing( 6 ); layout->setMargin(0); layout->setSpacing(6);
layout->addWidget( myGrp1 ); layout->addWidget(myGrp1);
layout->addWidget( myGrp2 ); layout->addWidget(myGrp2);
/***************************************************************/ /***************************************************************/
setHelpFileName( "multi_transformation_operation_page.html" ); setHelpFileName("multi_transformation_operation_page.html");
Init(); Init();
} }
@ -110,86 +112,78 @@ void BlocksGUI_TrsfDlg::Init()
// Set range of spinboxes // Set range of spinboxes
double SpecificStep = 1.0; double SpecificStep = 1.0;
QMap<int, QDoubleSpinBox*>::iterator anIter; QMap<int, QDoubleSpinBox*>::iterator anIter;
for ( anIter = mySpinBox.begin(); anIter != mySpinBox.end(); ++anIter ) { for (anIter = mySpinBox.begin(); anIter != mySpinBox.end(); ++anIter) {
//anIter.data()->RangeStepAndValidator(1.0, 999.999, SpecificStep, 3); //anIter.data()->RangeStepAndValidator(1.0, 999.999, SpecificStep, 3);
initSpinBox( anIter.value(), 1.0, MAX_NUMBER, SpecificStep, 3 ); initSpinBox(anIter.value(), 1.0, MAX_NUMBER, SpecificStep, 3);
} }
// 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( this, SIGNAL( constructorsClicked( int ) ), connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
this, SLOT( ConstructorsClicked( int ) ) );
QMap<int, QPushButton*>::iterator anIterBtn; QMap<int, QPushButton*>::iterator anIterBtn;
for ( anIterBtn = mySelBtn.begin(); anIterBtn != mySelBtn.end(); ++anIterBtn ) for (anIterBtn = mySelBtn.begin(); anIterBtn != mySelBtn.end(); ++anIterBtn)
connect( anIterBtn.value(), SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect(anIterBtn.value(), SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
QMap<int, QDoubleSpinBox*>::iterator anIterSpin; QMap<int, QDoubleSpinBox*>::iterator anIterSpin;
for ( anIterSpin = mySpinBox.begin(); anIterSpin != mySpinBox.end(); ++anIterSpin ) for (anIterSpin = mySpinBox.begin(); anIterSpin != mySpinBox.end(); ++anIterSpin)
connect( anIterSpin.value(), SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); connect(anIterSpin.value(), SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ) ;
// init controls and fields // init controls and fields
initName( tr( "GEOM_BLOCK_MULTITRSF" ) ); initName(tr("GEOM_BLOCK_MULTITRSF"));
myConstructorId = -1; myConstructorId = -1;
ConstructorsClicked( 0 ); ConstructorsClicked(0);
} }
//================================================================================= //=================================================================================
// function : ConstructorsClicked() // function : ConstructorsClicked()
// purpose : Radio button management // purpose : Radio button management
//================================================================================= //=================================================================================
void BlocksGUI_TrsfDlg::ConstructorsClicked( int constructorId ) void BlocksGUI_TrsfDlg::ConstructorsClicked (int constructorId)
{ {
if ( myConstructorId == constructorId ) if (myConstructorId == constructorId)
return; return;
myConstructorId = constructorId; myConstructorId = constructorId;
switch ( constructorId ) { // init fields
myShape = GEOM::GEOM_Object::_nil();
myFaces[Face1] = myFaces[Face2] = -1;
myFaces[Face1U] = myFaces[Face2U] = -1;
myFaces[Face1V] = myFaces[Face2V] = -1;
// clear line edits
QMap<int, QLineEdit*>::iterator anIterLE;
for (anIterLE = mySelName.begin(); anIterLE != mySelName.end(); ++anIterLE)
anIterLE.value()->setText("");
switch (constructorId) {
case 0: case 0:
myGrp2->hide(); myGrp2->hide();
myGrp1->show(); myGrp1->show();
mySpinBox[SpinBox1]->setValue( 2.0 ); mySpinBox[SpinBox1]->setValue(2.0);
myEditCurrentArgument = mySelName[MainObj1]; mySelBtn[MainObj1]->click();
myFaces[Face1] = -1;
myFaces[Face2] = -1;
break; break;
case 1: case 1:
myGrp1->hide(); myGrp1->hide();
myGrp2->show(); myGrp2->show();
mySpinBox[SpinBox2U]->setValue( 2.0 ); mySpinBox[SpinBox2U]->setValue(2.0);
mySpinBox[SpinBox2V]->setValue( 2.0 ); mySpinBox[SpinBox2V]->setValue(2.0);
myEditCurrentArgument = mySelName[MainObj2]; mySelBtn[MainObj2]->click();
myFaces[Face1U] = -1;
myFaces[Face2U] = -1;
myFaces[Face1V] = -1;
myFaces[Face2V] = -1;
break; break;
default: default:
break; break;
} }
// clear line edits
QMap<int, QLineEdit*>::iterator anIterLE;
for ( anIterLE = mySelName.begin(); anIterLE != mySelName.end(); ++anIterLE )
anIterLE.value()->setText( "" );
// init fields
myShape = GEOM::GEOM_Object::_nil();
qApp->processEvents(); qApp->processEvents();
updateGeometry(); updateGeometry();
resize( minimumSize() ); resize(minimumSize());
activateSelection(); // on dialog initialization we init the first field with a selected object (if any)
// enableWidgets(); SelectionIntoArgument();
// displayPreview();
} }
//================================================================================= //=================================================================================
@ -198,7 +192,7 @@ void BlocksGUI_TrsfDlg::ConstructorsClicked( int constructorId )
//================================================================================= //=================================================================================
void BlocksGUI_TrsfDlg::ClickOnOk() void BlocksGUI_TrsfDlg::ClickOnOk()
{ {
if ( ClickOnApply() ) if (ClickOnApply())
ClickOnCancel(); ClickOnCancel();
} }
@ -208,7 +202,7 @@ void BlocksGUI_TrsfDlg::ClickOnOk()
//================================================================================= //=================================================================================
bool BlocksGUI_TrsfDlg::ClickOnApply() bool BlocksGUI_TrsfDlg::ClickOnApply()
{ {
if ( !onAccept() ) if (!onAccept())
return false; return false;
initName(); initName();
@ -217,18 +211,18 @@ bool BlocksGUI_TrsfDlg::ClickOnApply()
//================================================================================= //=================================================================================
// function : SelectionIntoArgument() // function : SelectionIntoArgument()
// purpose : Called when selection has changed // purpose : Called when selection is changed or on dialog initialization or activation
//================================================================================= //=================================================================================
void BlocksGUI_TrsfDlg::SelectionIntoArgument() void BlocksGUI_TrsfDlg::SelectionIntoArgument()
{ {
erasePreview(); erasePreview();
myEditCurrentArgument->setText( "" ); myEditCurrentArgument->setText("");
// Get index of current selection focus // Get index of current selection focus
int aCurrFocus = -1; int aCurrFocus = -1;
QMap<int, QLineEdit*>::iterator anIter; QMap<int, QLineEdit*>::iterator anIter;
for ( anIter = mySelName.begin(); anIter != mySelName.end(); ++anIter ) { for (anIter = mySelName.begin(); anIter != mySelName.end(); ++anIter) {
if ( myEditCurrentArgument == anIter.value() ) { if (myEditCurrentArgument == anIter.value()) {
aCurrFocus = anIter.key(); aCurrFocus = anIter.key();
break; break;
} }
@ -238,49 +232,87 @@ void BlocksGUI_TrsfDlg::SelectionIntoArgument()
SALOME_ListIO aSelList; SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList); aSelMgr->selectedObjects(aSelList);
// If selection of main object is activated QString aName;
if ( aCurrFocus == MainObj1 || aCurrFocus == MainObj2 ) { GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object::_nil();
if (aCurrFocus == MainObj1 || aCurrFocus == MainObj2)
{
// If selection of main object is activated
if (aSelList.Extent() == 1) { if (aSelList.Extent() == 1) {
Standard_Boolean aResult = Standard_False; Standard_Boolean aResult = Standard_False;
GEOM::GEOM_Object_var anObj = anObj = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aResult);
GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aResult);
if ( aResult && !anObj->_is_nil() && GEOMBase::IsShape( anObj ) ) { if (aResult && !anObj->_is_nil() && GEOMBase::IsShape(anObj)) {
myShape = anObj; aName = GEOMBase::GetName(anObj);
mySelName[aCurrFocus]->setText( GEOMBase::GetName( anObj ) );
enableWidgets();
return;
} }
} }
myEditCurrentArgument->setText(aName);
myShape = GEOM::GEOM_Object::_nil(); myShape = anObj;
enableWidgets(); enableWidgets();
} }
// If face selection is activated else if (aCurrFocus == Face1 || aCurrFocus == Face2 ||
else if ( aCurrFocus == Face1 || aCurrFocus == Face2 || aCurrFocus == Face1U || aCurrFocus == Face2U ||
aCurrFocus == Face1U || aCurrFocus == Face2U || aCurrFocus == Face1V || aCurrFocus == Face2V) {
aCurrFocus == Face1V || aCurrFocus == Face2V ) { // If face selection is activated
int anIndex = -1;
if (aSelList.Extent() == 1) { if (aSelList.Extent() == 1) {
Standard_Boolean aResult = Standard_False; Standard_Boolean aResult = Standard_False;
GEOM::GEOM_Object_var anObj = anObj = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aResult);
GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aResult); if (aResult && !anObj->_is_nil() && GEOMBase::IsShape(anObj)) {
aName = GEOMBase::GetName(anObj);
if ( aResult && !anObj->_is_nil() && GEOMBase::IsShape( anObj ) ) {
TColStd_IndexedMapOfInteger anIndexes; TColStd_IndexedMapOfInteger anIndexes;
myGeomGUI->getApp()->selectionMgr()->GetIndexes(aSelList.First(), anIndexes); aSelMgr->GetIndexes(aSelList.First(), anIndexes);
if ( anIndexes.Extent() == 1 ) { if (anIndexes.Extent() == 1) {
int anIndex = anIndexes( 1 ); anIndex = anIndexes(1);
QString aFaceName = QString( GEOMBase::GetName( anObj ) ) + ":%1"; aName += QString(":face_%1").arg(anIndex);
myEditCurrentArgument->setText( aFaceName.arg( anIndex ) );
myFaces[aCurrFocus] = anIndex;
displayPreview();
return;
} }
} }
} }
myEditCurrentArgument->setText(aName);
myFaces[aCurrFocus] = anIndex;
displayPreview();
}
myFaces[aCurrFocus] = -1; switch (aCurrFocus) {
// 1D
case MainObj1:
if (!myShape->_is_nil() && myFaces[Face1] == -1)
mySelBtn[Face1]->click();
break;
case Face1:
if (myFaces[Face1] != -1 && myFaces[Face2] == -1)
mySelBtn[Face2]->click();
break;
case Face2:
if (myFaces[Face2] != -1 && myShape->_is_nil())
mySelBtn[MainObj1]->click();
break;
// 2D
case MainObj2:
if (!myShape->_is_nil() && myFaces[Face1U] == -1)
mySelBtn[Face1U]->click();
break;
case Face1U:
if (myFaces[Face1U] != -1 && myFaces[Face2U] == -1)
mySelBtn[Face2U]->click();
break;
case Face2U:
if (myFaces[Face2U] != -1 && myFaces[Face1V] == -1)
mySelBtn[Face1V]->click();
break;
case Face1V:
if (myFaces[Face1V] != -1 && myFaces[Face2V] == -1)
mySelBtn[Face2V]->click();
break;
case Face2V:
if (myFaces[Face2V] != -1 && myShape->_is_nil())
mySelBtn[MainObj1]->click();
break;
default:
break;
} }
} }
@ -292,15 +324,57 @@ void BlocksGUI_TrsfDlg::SetEditCurrentArgument()
{ {
QPushButton* aSender = (QPushButton*)sender(); QPushButton* aSender = (QPushButton*)sender();
// clear selection
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
if (myInitial)
myInitial = false;
else
myGeomGUI->getApp()->selectionMgr()->clearSelected();
// disable all
switch (myConstructorId) {
case 0:
mySelBtn[MainObj1]->setDown(false);
mySelBtn[Face1]->setDown(false);
mySelBtn[Face2]->setDown(false);
mySelName[MainObj1]->setEnabled(false);
mySelName[Face1]->setEnabled(false);
mySelName[Face2]->setEnabled(false);
break;
case 1:
mySelBtn[MainObj2]->setDown(false);
mySelBtn[Face1U]->setDown(false);
mySelBtn[Face2U]->setDown(false);
mySelBtn[Face1V]->setDown(false);
mySelBtn[Face2V]->setDown(false);
mySelName[MainObj2]->setEnabled(false);
mySelName[Face1U]->setEnabled(false);
mySelName[Face2U]->setEnabled(false);
mySelName[Face1V]->setEnabled(false);
mySelName[Face2V]->setEnabled(false);
break;
default:
break;
}
// enable push button
aSender->setDown(true);
// set line edit as current argument
QMap<int, QPushButton*>::iterator anIter; QMap<int, QPushButton*>::iterator anIter;
for ( anIter = mySelBtn.begin(); anIter != mySelBtn.end(); ++anIter ) { for (anIter = mySelBtn.begin(); anIter != mySelBtn.end(); ++anIter) {
if ( anIter.value() == aSender ) { if (anIter.value() == aSender) {
mySelName[anIter.key()]->setFocus();
myEditCurrentArgument = mySelName[anIter.key()]; myEditCurrentArgument = mySelName[anIter.key()];
break; break;
} }
} }
// enable line edit
myEditCurrentArgument->setEnabled(true);
myEditCurrentArgument->setFocus();
activateSelection(); activateSelection();
} }
@ -311,10 +385,9 @@ void BlocksGUI_TrsfDlg::SetEditCurrentArgument()
void BlocksGUI_TrsfDlg::ActivateThisDialog() void BlocksGUI_TrsfDlg::ActivateThisDialog()
{ {
GEOMBase_Skeleton::ActivateThisDialog(); GEOMBase_Skeleton::ActivateThisDialog();
connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
activateSelection(); activateSelection();
// ??
displayPreview(); displayPreview();
} }
@ -322,17 +395,17 @@ void BlocksGUI_TrsfDlg::ActivateThisDialog()
// function : enterEvent() // function : enterEvent()
// purpose : // purpose :
//================================================================================= //=================================================================================
void BlocksGUI_TrsfDlg::enterEvent( QEvent* ) void BlocksGUI_TrsfDlg::enterEvent (QEvent*)
{ {
if ( !mainFrame()->GroupConstructors->isEnabled() ) if (!mainFrame()->GroupConstructors->isEnabled())
this->ActivateThisDialog(); ActivateThisDialog();
} }
//================================================================================= //=================================================================================
// function : ValueChangedInSpinBox() // function : ValueChangedInSpinBox()
// purpose : // purpose :
//================================================================================= //=================================================================================
void BlocksGUI_TrsfDlg::ValueChangedInSpinBox( double ) void BlocksGUI_TrsfDlg::ValueChangedInSpinBox(double)
{ {
displayPreview(); displayPreview();
} }
@ -341,52 +414,52 @@ void BlocksGUI_TrsfDlg::ValueChangedInSpinBox( double )
// function : createSelWg() // function : createSelWg()
// purpose : // purpose :
//================================================================================= //=================================================================================
void BlocksGUI_TrsfDlg::createSelWg( const QString& theLbl, void BlocksGUI_TrsfDlg::createSelWg (const QString& theLbl,
QPixmap& thePix, QPixmap& thePix,
QWidget* theParent, QWidget* theParent,
const int theId ) const int theId)
{ {
QLabel* lab = new QLabel( theLbl, theParent ); QLabel* lab = new QLabel(theLbl, theParent);
mySelBtn[theId] = new QPushButton( theParent ); mySelBtn[theId] = new QPushButton(theParent);
mySelBtn[theId]->setIcon( thePix ); mySelBtn[theId]->setIcon(thePix);
mySelBtn[theId]->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); mySelBtn[theId]->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
mySelName[theId] = new QLineEdit( theParent ); mySelName[theId] = new QLineEdit(theParent);
mySelName[theId]->setReadOnly( true ); mySelName[theId]->setReadOnly(true);
QGridLayout* l = 0; QGridLayout* l = 0;
if ( !theParent->layout() ) { if (!theParent->layout()) {
l = new QGridLayout( theParent ); l = new QGridLayout(theParent);
l->setMargin( 9 ); l->setSpacing( 6 ); l->setMargin(9); l->setSpacing(6);
} }
else { else {
l = qobject_cast<QGridLayout*>( theParent->layout() ); l = qobject_cast<QGridLayout*>(theParent->layout());
} }
int row = l->rowCount(); int row = l->rowCount();
l->addWidget( lab, row, 0 ); l->addWidget(lab, row, 0);
l->addWidget( mySelBtn[theId], row, 1 ); l->addWidget(mySelBtn[theId], row, 1);
l->addWidget( mySelName[theId], row, 2 ); l->addWidget(mySelName[theId], row, 2);
} }
//================================================================================= //=================================================================================
// function : createSpinWg() // function : createSpinWg()
// purpose : // purpose :
//================================================================================= //=================================================================================
void BlocksGUI_TrsfDlg::createSpinWg( const QString& theLbl, void BlocksGUI_TrsfDlg::createSpinWg (const QString& theLbl,
QWidget* theParent, QWidget* theParent,
const int theId ) const int theId)
{ {
QLabel* lab = new QLabel( theLbl, theParent ); QLabel* lab = new QLabel(theLbl, theParent);
mySpinBox[theId] = new QDoubleSpinBox( theParent ); mySpinBox[theId] = new QDoubleSpinBox(theParent);
QGridLayout* l = 0; QGridLayout* l = 0;
if ( !theParent->layout() ) { if (!theParent->layout()) {
l = new QGridLayout( theParent ); l = new QGridLayout(theParent);
l->setMargin( 9 ); l->setSpacing( 6 ); l->setMargin(9); l->setSpacing(6);
} }
else { else {
l = qobject_cast<QGridLayout*>( theParent->layout() ); l = qobject_cast<QGridLayout*>(theParent->layout());
} }
int row = l->rowCount(); int row = l->rowCount();
l->addWidget( lab, row, 0 ); l->addWidget(lab, row, 0);
l->addWidget( mySpinBox[theId], row, 2 ); l->addWidget(mySpinBox[theId], row, 2);
} }
//================================================================================= //=================================================================================
@ -395,28 +468,22 @@ void BlocksGUI_TrsfDlg::createSpinWg( const QString& theLbl,
//================================================================================= //=================================================================================
void BlocksGUI_TrsfDlg::activateSelection() void BlocksGUI_TrsfDlg::activateSelection()
{ {
if ( !myShape->_is_nil() && globalSelection(GEOM_ALLSHAPES);
( myEditCurrentArgument == mySelName[ Face1 ] || if (!myShape->_is_nil() &&
myEditCurrentArgument == mySelName[ Face2 ] || (myEditCurrentArgument == mySelName[Face1 ] ||
myEditCurrentArgument == mySelName[ Face1U ] || myEditCurrentArgument == mySelName[Face2 ] ||
myEditCurrentArgument == mySelName[ Face2U ] || myEditCurrentArgument == mySelName[Face1U] ||
myEditCurrentArgument == mySelName[ Face1V ] || myEditCurrentArgument == mySelName[Face2U] ||
myEditCurrentArgument == mySelName[ Face2V ] ) ) { myEditCurrentArgument == mySelName[Face1V] ||
myEditCurrentArgument == mySelName[Face2V]))
{
// Local selection is available only in the OCC Viewer // Local selection is available only in the OCC Viewer
if ( SUIT_Session::session()->activeApplication()->desktop()->activeWindow()->getViewManager()->getType() if (getDesktop()->activeWindow()->getViewManager()->getType() == OCCViewer_Viewer::Type()) {
== OCCViewer_Viewer::Type() ) { localSelection(myShape, TopAbs_FACE);
localSelection( myShape, TopAbs_FACE );
}
else {
return;
} }
}
else {
globalSelection( GEOM_ALLSHAPES );
} }
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
SelectionIntoArgument(); this, SLOT(SelectionIntoArgument()));
} }
//================================================================================= //=================================================================================
@ -429,34 +496,34 @@ void BlocksGUI_TrsfDlg::enableWidgets()
bool toEnable = !myShape->_is_nil(); bool toEnable = !myShape->_is_nil();
if ( anId == 0 ) { if (anId == 0) {
mySelName[Face1]->setEnabled( toEnable ); //mySelName[Face1]->setEnabled(toEnable);
mySelName[Face2]->setEnabled( toEnable ); //mySelName[Face2]->setEnabled(toEnable);
mySelBtn[Face1]->setEnabled( toEnable ); //mySelBtn[Face1]->setEnabled(toEnable);
mySelBtn[Face2]->setEnabled( toEnable ); //mySelBtn[Face2]->setEnabled(toEnable);
if ( !toEnable) { if (!toEnable) {
mySelName[Face1]->setText( "" ); mySelName[Face1]->setText("");
mySelName[Face2]->setText( "" ); mySelName[Face2]->setText("");
myFaces[Face1] = -1; myFaces[Face1] = -1;
myFaces[Face2] = -1; myFaces[Face2] = -1;
} }
} }
else if ( anId == 1 ) { else if (anId == 1) {
mySelName[Face1U]->setEnabled( toEnable ); //mySelName[Face1U]->setEnabled(toEnable);
mySelName[Face2U]->setEnabled( toEnable ); //mySelName[Face2U]->setEnabled(toEnable);
mySelName[Face1V]->setEnabled( toEnable ); //mySelName[Face1V]->setEnabled(toEnable);
mySelName[Face2V]->setEnabled( toEnable ); //mySelName[Face2V]->setEnabled(toEnable);
mySelBtn[Face1U]->setEnabled( toEnable ); //mySelBtn[Face1U]->setEnabled(toEnable);
mySelBtn[Face2U]->setEnabled( toEnable ); //mySelBtn[Face2U]->setEnabled(toEnable);
mySelBtn[Face1V]->setEnabled( toEnable ); //mySelBtn[Face1V]->setEnabled(toEnable);
mySelBtn[Face2V]->setEnabled( toEnable ); //mySelBtn[Face2V]->setEnabled(toEnable);
if ( !toEnable ) { if (!toEnable) {
mySelName[Face1U]->setText( "" ); mySelName[Face1U]->setText("");
mySelName[Face2U]->setText( "" ); mySelName[Face2U]->setText("");
mySelName[Face1V]->setText( "" ); mySelName[Face1V]->setText("");
mySelName[Face2V]->setText( "" ); mySelName[Face2V]->setText("");
myFaces[Face1U] = -1; myFaces[Face1U] = -1;
myFaces[Face2U] = -1; myFaces[Face2U] = -1;
myFaces[Face1V] = -1; myFaces[Face1V] = -1;
@ -471,17 +538,17 @@ void BlocksGUI_TrsfDlg::enableWidgets()
//================================================================================= //=================================================================================
GEOM::GEOM_IOperations_ptr BlocksGUI_TrsfDlg::createOperation() GEOM::GEOM_IOperations_ptr BlocksGUI_TrsfDlg::createOperation()
{ {
return getGeomEngine()->GetIBlocksOperations( getStudyId() ); return getGeomEngine()->GetIBlocksOperations(getStudyId());
} }
//================================================================================= //=================================================================================
// function : ClickOnApply() // function : isValid
// purpose : Verify validity of input data // purpose : Verify validity of input data
//================================================================================= //=================================================================================
bool BlocksGUI_TrsfDlg::isValid( QString& ) bool BlocksGUI_TrsfDlg::isValid (QString&)
{ {
bool ok = false; bool ok = false;
switch ( getConstructorId() ) { switch (getConstructorId()) {
case 0: case 0:
ok = !myShape->_is_nil() && myFaces[Face1] > 0; ok = !myShape->_is_nil() && myFaces[Face1] > 0;
break; break;
@ -498,36 +565,35 @@ bool BlocksGUI_TrsfDlg::isValid( QString& )
// function : execute // function : execute
// purpose : // purpose :
//================================================================================= //=================================================================================
bool BlocksGUI_TrsfDlg::execute( ObjectList& objects ) bool BlocksGUI_TrsfDlg::execute (ObjectList& objects)
{ {
bool res = false; bool res = false;
GEOM::GEOM_Object_var anObj; GEOM::GEOM_Object_var anObj;
switch ( getConstructorId() ) { switch (getConstructorId()) {
case 0: case 0:
anObj = GEOM::GEOM_IBlocksOperations::_narrow( getOperation() )->MakeMultiTransformation1D anObj = GEOM::GEOM_IBlocksOperations::_narrow(getOperation())->
( myShape, MakeMultiTransformation1D(myShape,
myFaces[Face1], myFaces[Face1], myFaces[Face2],
myFaces[Face2], (int)mySpinBox[SpinBox1]->value());
(int)mySpinBox[SpinBox1]->value() );
res = true; res = true;
break; break;
case 1: case 1:
anObj = GEOM::GEOM_IBlocksOperations::_narrow( getOperation() )->MakeMultiTransformation2D anObj = GEOM::GEOM_IBlocksOperations::_narrow(getOperation())->
( myShape, MakeMultiTransformation2D (myShape,
myFaces[Face1U], myFaces[Face1U], myFaces[Face2U],
myFaces[Face2U], (int)mySpinBox[SpinBox2U]->value(),
(int)mySpinBox[SpinBox2U]->value(), myFaces[Face1V], myFaces[Face2V],
myFaces[Face1V], (int)mySpinBox[SpinBox2V]->value());
myFaces[Face2V],
(int)mySpinBox[SpinBox2V]->value() );
res = true; res = true;
break; break;
default:
break;
} }
if ( !anObj->_is_nil() ) if (!anObj->_is_nil())
objects.push_back( anObj._retn() ); objects.push_back(anObj._retn());
return res; return res;
} }

View File

@ -46,23 +46,21 @@ class BlocksGUI_TrsfDlg : public GEOMBase_Skeleton
enum { SpinBox1, SpinBox2U, SpinBox2V }; enum { SpinBox1, SpinBox2U, SpinBox2V };
public: public:
BlocksGUI_TrsfDlg( GeometryGUI*, QWidget* ); BlocksGUI_TrsfDlg (GeometryGUI*, QWidget*);
~BlocksGUI_TrsfDlg(); ~BlocksGUI_TrsfDlg();
protected: protected:
// redefined from GEOMBase_Helper // redefined from GEOMBase_Helper
virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual GEOM::GEOM_IOperations_ptr createOperation();
virtual bool isValid( QString& ); virtual bool isValid (QString&);
virtual bool execute( ObjectList& ); virtual bool execute (ObjectList&);
private: private:
void Init(); void Init();
void enterEvent( QEvent* ); void enterEvent(QEvent*);
void createSelWg( const QString&, QPixmap&, void createSelWg (const QString&, QPixmap&, QWidget*, const int);
QWidget*, const int ); void createSpinWg (const QString&, QWidget*, const int);
void createSpinWg( const QString&, QWidget*,
const int );
void activateSelection(); void activateSelection();
void enableWidgets(); void enableWidgets();
@ -72,6 +70,9 @@ private:
GEOM::GEOM_Object_var myShape; GEOM::GEOM_Object_var myShape;
QMap<int, int> myFaces; QMap<int, int> myFaces;
// to initialize the first selection field with a selected object on the dialog creation
bool myInitial;
QGroupBox* myGrp1; QGroupBox* myGrp1;
QGroupBox* myGrp2; QGroupBox* myGrp2;
@ -83,12 +84,12 @@ private slots:
void ClickOnOk(); void ClickOnOk();
bool ClickOnApply(); bool ClickOnApply();
void ActivateThisDialog(); void ActivateThisDialog();
void ConstructorsClicked( int ); void ConstructorsClicked (int);
void SelectionIntoArgument(); void SelectionIntoArgument();
void SetEditCurrentArgument(); void SetEditCurrentArgument();
void ValueChangedInSpinBox( double ); void ValueChangedInSpinBox (double);
}; };
#endif // BLOCKSGUI_TRSFDLG_H #endif // BLOCKSGUI_TRSFDLG_H