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

This commit is contained in:
jfa 2008-09-24 11:38:20 +00:00
parent 183e4a7cd2
commit 3e545a24c5
16 changed files with 1284 additions and 1150 deletions

View File

@ -271,9 +271,10 @@ void BlocksGUI_BlockDlg::SelectionIntoArgument()
GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId()); GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId());
aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
} }
else else {
aSelectedObject = aFindedObject; // get Object from study aSelectedObject = aFindedObject; // get Object from study
} }
}
else // Global Selection else // Global Selection
{ {
if (aShape.ShapeType() != TopAbs_FACE) { if (aShape.ShapeType() != TopAbs_FACE) {
@ -372,9 +373,6 @@ void BlocksGUI_BlockDlg::SetEditCurrentArgument()
break; break;
} }
// enable push button
aSender->setDown(true);
// set line edit as current argument // set line edit as current argument
if (aSender == Group2F->PushButton1) { if (aSender == Group2F->PushButton1) {
myEditCurrentArgument = Group2F->LineEdit1; myEditCurrentArgument = Group2F->LineEdit1;
@ -401,9 +399,11 @@ void BlocksGUI_BlockDlg::SetEditCurrentArgument()
myEditCurrentArgument = Group6F->LineEdit6; myEditCurrentArgument = Group6F->LineEdit6;
} }
// enable line edit // enable push button and line edit
myEditCurrentArgument->setEnabled(true); myEditCurrentArgument->setEnabled(true);
myEditCurrentArgument->setFocus(); myEditCurrentArgument->setFocus();
// after setFocus(), because it will be setDown(false) then loses focus
aSender->setDown(true);
globalSelection(); // close local contexts, if any globalSelection(); // close local contexts, if any
localSelection(GEOM::GEOM_Object::_nil(), TopAbs_FACE); //Select Faces on All Shapes localSelection(GEOM::GEOM_Object::_nil(), TopAbs_FACE); //Select Faces on All Shapes
@ -422,6 +422,7 @@ void BlocksGUI_BlockDlg::ActivateThisDialog()
localSelection(GEOM::GEOM_Object::_nil(), TopAbs_FACE); //Select Faces on All Shapes localSelection(GEOM::GEOM_Object::_nil(), TopAbs_FACE); //Select Faces on All Shapes
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument())); this, SLOT(SelectionIntoArgument()));
displayPreview();
} }
//================================================================================= //=================================================================================
@ -501,7 +502,7 @@ bool BlocksGUI_BlockDlg::execute (ObjectList& objects)
} }
//================================================================================= //=================================================================================
// function : addSubshapeToStudy // function : addSubshapesToStudy
// purpose : virtual method to add new SubObjects if local selection // purpose : virtual method to add new SubObjects if local selection
//================================================================================= //=================================================================================
void BlocksGUI_BlockDlg::addSubshapesToStudy() void BlocksGUI_BlockDlg::addSubshapesToStudy()

View File

@ -33,13 +33,14 @@
#include <SalomeApp_Application.h> #include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h> #include <LightApp_SelectionMgr.h>
#include <GEOMImpl_Types.hxx> // QT Includes
#include <qlabel.h> #include <qlabel.h>
// OCCT Includes // OCCT Includes
#include <TColStd_IndexedMapOfInteger.hxx>
#include <TopAbs.hxx> #include <TopAbs.hxx>
#include <TColStd_IndexedMapOfInteger.hxx>
#include <GEOMImpl_Types.hxx>
//================================================================================= //=================================================================================
// class : BlocksGUI_QuadFaceDlg() // class : BlocksGUI_QuadFaceDlg()
@ -392,9 +393,6 @@ void BlocksGUI_QuadFaceDlg::SetEditCurrentArgument()
break; break;
} }
// enable push button
aSender->setDown(true);
// set line edit as current argument // 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) {
@ -408,6 +406,10 @@ void BlocksGUI_QuadFaceDlg::SetEditCurrentArgument()
myEditCurrentArgument->setEnabled(true); myEditCurrentArgument->setEnabled(true);
myEditCurrentArgument->setFocus(); myEditCurrentArgument->setFocus();
// enable push button
// after setFocus(), because it will be setDown(false) then loses focus
aSender->setDown(true);
activateSelection(); activateSelection();
} }

View File

@ -359,9 +359,6 @@ void BlocksGUI_TrsfDlg::SetEditCurrentArgument()
break; break;
} }
// enable push button
aSender->setDown(true);
// set line edit as current argument // 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) {
@ -375,6 +372,10 @@ void BlocksGUI_TrsfDlg::SetEditCurrentArgument()
myEditCurrentArgument->setEnabled(true); myEditCurrentArgument->setEnabled(true);
myEditCurrentArgument->setFocus(); myEditCurrentArgument->setFocus();
// enable push button
// after setFocus(), because it will be setDown(false) then loses focus
aSender->setDown(true);
activateSelection(); activateSelection();
} }

View File

@ -191,6 +191,7 @@ void GEOMBase_Skeleton::DeactivateActiveDialog()
myGeomGUI->SetActiveDialogBox( 0 ); myGeomGUI->SetActiveDialogBox( 0 );
disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 ); disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 );
} }
erasePreview();
} }
//================================================================================= //=================================================================================

View File

@ -29,11 +29,12 @@
#include <GeometryGUI.h> #include <GeometryGUI.h>
#include <GEOMBase.h> #include <GEOMBase.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h> #include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h>
#include <SalomeApp_Application.h> #include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h> #include <LightApp_SelectionMgr.h>
// OCCT Includes
#include <TopoDS_Shape.hxx> #include <TopoDS_Shape.hxx>
#include <TopoDS.hxx> #include <TopoDS.hxx>
#include <TopExp.hxx> #include <TopExp.hxx>
@ -41,7 +42,7 @@
#include <TopTools_IndexedMapOfShape.hxx> #include <TopTools_IndexedMapOfShape.hxx>
#include <GEOMImpl_Types.hxx> #include <GEOMImpl_Types.hxx>
#include <ostream> //#include <ostream>
//================================================================================= //=================================================================================
// class : PrimitiveGUI_BoxDlg() // class : PrimitiveGUI_BoxDlg()
@ -52,7 +53,8 @@
//================================================================================= //=================================================================================
PrimitiveGUI_BoxDlg::PrimitiveGUI_BoxDlg (GeometryGUI* theGeometryGUI, QWidget* parent, PrimitiveGUI_BoxDlg::PrimitiveGUI_BoxDlg (GeometryGUI* theGeometryGUI, QWidget* parent,
bool modal, Qt::WindowFlags fl) bool modal, Qt::WindowFlags fl)
: GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl ) : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl),
myInitial(true)
{ {
QPixmap image0 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_BOX_2P"))); QPixmap image0 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_BOX_2P")));
QPixmap image1 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_BOX_DXYZ"))); QPixmap image1 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_BOX_DXYZ")));
@ -91,7 +93,6 @@ PrimitiveGUI_BoxDlg::PrimitiveGUI_BoxDlg( GeometryGUI* theGeometryGUI, QWidget*
Init(); Init();
} }
//================================================================================= //=================================================================================
// function : ~DialogBox_Box() // function : ~DialogBox_Box()
// purpose : Destroys the object and frees any allocated resources // purpose : Destroys the object and frees any allocated resources
@ -101,35 +102,35 @@ PrimitiveGUI_BoxDlg::~PrimitiveGUI_BoxDlg()
// no need to delete child widgets, Qt does it all for us // no need to delete child widgets, Qt does it all for us
} }
//================================================================================= //=================================================================================
// function : Init() // function : Init()
// purpose : // purpose :
//================================================================================= //=================================================================================
void PrimitiveGUI_BoxDlg::Init() void PrimitiveGUI_BoxDlg::Init()
{ {
/* init variables */ // Get setting of step value from file configuration
myEditCurrentArgument = GroupPoints->LineEdit1;
GroupPoints->LineEdit1->setReadOnly( true );
GroupPoints->LineEdit2->setReadOnly( true );
myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil();
/* Get setting of step value from file configuration */
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100); double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100);
/* min, max, step and decimals for spin boxes */ // min, max, step and decimals for spin boxes
initSpinBox(GroupDimensions->SpinBox_DX, COORD_MIN, COORD_MAX, step, 3); // VSR: TODO: DBL_DIGITS_DISPLAY initSpinBox(GroupDimensions->SpinBox_DX, COORD_MIN, COORD_MAX, step, 3); // VSR: TODO: DBL_DIGITS_DISPLAY
initSpinBox(GroupDimensions->SpinBox_DY, COORD_MIN, COORD_MAX, step, 3); // VSR: TODO: DBL_DIGITS_DISPLAY initSpinBox(GroupDimensions->SpinBox_DY, COORD_MIN, COORD_MAX, step, 3); // VSR: TODO: DBL_DIGITS_DISPLAY
initSpinBox(GroupDimensions->SpinBox_DZ, COORD_MIN, COORD_MAX, step, 3); // VSR: TODO: DBL_DIGITS_DISPLAY initSpinBox(GroupDimensions->SpinBox_DZ, COORD_MIN, COORD_MAX, step, 3); // VSR: TODO: DBL_DIGITS_DISPLAY
// init variables
GroupPoints->LineEdit1->setReadOnly(true);
GroupPoints->LineEdit2->setReadOnly(true);
GroupPoints->LineEdit1->setText("");
GroupPoints->LineEdit2->setText("");
myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil();
double initValue = 200.0; double initValue = 200.0;
GroupDimensions->SpinBox_DX->setValue(initValue); GroupDimensions->SpinBox_DX->setValue(initValue);
GroupDimensions->SpinBox_DY->setValue(initValue); GroupDimensions->SpinBox_DY->setValue(initValue);
GroupDimensions->SpinBox_DZ->setValue(initValue); GroupDimensions->SpinBox_DZ->setValue(initValue);
/* 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()));
@ -147,9 +148,6 @@ void PrimitiveGUI_BoxDlg::Init()
connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double))); connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double)));
connect( myGeomGUI->getApp()->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
initName(tr("GEOM_BOX")); initName(tr("GEOM_BOX"));
setConstructorId(1); // simplest constructor setConstructorId(1); // simplest constructor
@ -167,39 +165,29 @@ void PrimitiveGUI_BoxDlg::SetDoubleSpinBoxStep( double step )
GroupDimensions->SpinBox_DZ->setSingleStep(step); GroupDimensions->SpinBox_DZ->setSingleStep(step);
} }
//================================================================================= //=================================================================================
// function : ConstructorsClicked() // function : ConstructorsClicked()
// purpose : Radio button management // purpose : Radio button management
//================================================================================= //=================================================================================
void PrimitiveGUI_BoxDlg::ConstructorsClicked (int constructorId) void PrimitiveGUI_BoxDlg::ConstructorsClicked (int constructorId)
{ {
disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 );
switch (constructorId) { switch (constructorId) {
case 0: case 0:
{ {
//globalSelection( GEOM_POINT );
globalSelection(); // close local contexts, if any
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
GroupDimensions->hide(); GroupDimensions->hide();
GroupPoints->show(); GroupPoints->show();
myEditCurrentArgument = GroupPoints->LineEdit1; GroupPoints->PushButton1->click();
GroupPoints->LineEdit1->setText( "" );
GroupPoints->LineEdit2->setText( "" );
myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil();
connect( myGeomGUI->getApp()->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
break; break;
} }
case 1: case 1:
{ {
GroupPoints->hide(); GroupPoints->hide();
GroupDimensions->show(); GroupDimensions->show();
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
globalSelection(); // close local contexts, if any globalSelection(); // close local contexts, if any
displayPreview();
break; break;
} }
} }
@ -208,9 +196,15 @@ void PrimitiveGUI_BoxDlg::ConstructorsClicked( int constructorId )
updateGeometry(); updateGeometry();
resize(minimumSize()); resize(minimumSize());
if (myInitial) {
// on dialog initialization we init the first field with a selected object (if any)
SelectionIntoArgument();
myInitial = false;
}
else {
displayPreview(); displayPreview();
} }
}
//================================================================================= //=================================================================================
// function : ClickOnOk() // function : ClickOnOk()
@ -222,7 +216,6 @@ void PrimitiveGUI_BoxDlg::ClickOnOk()
ClickOnCancel(); ClickOnCancel();
} }
//================================================================================= //=================================================================================
// function : ClickOnApply() // function : ClickOnApply()
// purpose : // purpose :
@ -233,20 +226,21 @@ bool PrimitiveGUI_BoxDlg::ClickOnApply()
return false; return false;
initName(); initName();
// activate selection and connect selection manager
ConstructorsClicked(getConstructorId()); ConstructorsClicked(getConstructorId());
return true; return true;
} }
//================================================================================= //=================================================================================
// function : SelectionIntoArgument() // function : SelectionIntoArgument()
// purpose : Called when selection as changed // purpose : Called when selection is changed or on dialog initialization or activation
//================================================================================= //=================================================================================
void PrimitiveGUI_BoxDlg::SelectionIntoArgument() void PrimitiveGUI_BoxDlg::SelectionIntoArgument()
{ {
if (getConstructorId() != 0) if (getConstructorId() != 0)
return; return;
erasePreview();
myEditCurrentArgument->setText(""); myEditCurrentArgument->setText("");
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
@ -254,10 +248,8 @@ void PrimitiveGUI_BoxDlg::SelectionIntoArgument()
aSelMgr->selectedObjects(aSelList); aSelMgr->selectedObjects(aSelList);
if (aSelList.Extent() != 1) { if (aSelList.Extent() != 1) {
if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint1 = GEOM::GEOM_Object::_nil();
myPoint1 = GEOM::GEOM_Object::_nil(); else if (myEditCurrentArgument == GroupPoints->LineEdit2) myPoint2 = GEOM::GEOM_Object::_nil();
else if ( myEditCurrentArgument == GroupPoints->LineEdit2 )
myPoint2 = GEOM::GEOM_Object::_nil();
return; return;
} }
@ -268,12 +260,16 @@ void PrimitiveGUI_BoxDlg::SelectionIntoArgument()
if (!testResult || CORBA::is_nil(aSelectedObject)) if (!testResult || CORBA::is_nil(aSelectedObject))
return; return;
TopoDS_Shape aShape;
QString aName = GEOMBase::GetName(aSelectedObject); QString aName = GEOMBase::GetName(aSelectedObject);
if (GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) {
// Get Selected object if selected subshape
TopoDS_Shape aShape;
if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull())
{
TColStd_IndexedMapOfInteger aMap; TColStd_IndexedMapOfInteger aMap;
aSelMgr->GetIndexes(aSelList.First(), aMap); aSelMgr->GetIndexes(aSelList.First(), aMap);
if ( aMap.Extent() == 1) { // Local Selection if (aMap.Extent() == 1) // Local Selection
{
int anIndex = aMap(1); int anIndex = aMap(1);
aName.append(":vertex_" + QString::number(anIndex)); aName.append(":vertex_" + QString::number(anIndex));
@ -289,7 +285,8 @@ void PrimitiveGUI_BoxDlg::SelectionIntoArgument()
aSelectedObject = aFindedObject; // get Object from study aSelectedObject = aFindedObject; // get Object from study
} }
} }
else { // Global Selection else // Global Selection
{
if (aShape.ShapeType() != TopAbs_VERTEX) { if (aShape.ShapeType() != TopAbs_VERTEX) {
aSelectedObject = GEOM::GEOM_Object::_nil(); aSelectedObject = GEOM::GEOM_Object::_nil();
aName = ""; aName = "";
@ -299,15 +296,26 @@ void PrimitiveGUI_BoxDlg::SelectionIntoArgument()
myEditCurrentArgument->setText(aName); myEditCurrentArgument->setText(aName);
if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) // clear selection
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
myGeomGUI->getApp()->selectionMgr()->clearSelected();
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
if (myEditCurrentArgument == GroupPoints->LineEdit1) {
myPoint1 = aSelectedObject; myPoint1 = aSelectedObject;
else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) if (!myPoint1->_is_nil() && myPoint2->_is_nil())
GroupPoints->PushButton2->click();
}
else if (myEditCurrentArgument == GroupPoints->LineEdit2) {
myPoint2 = aSelectedObject; myPoint2 = aSelectedObject;
if (!myPoint2->_is_nil() && myPoint1->_is_nil())
GroupPoints->PushButton1->click();
}
displayPreview(); displayPreview();
} }
//================================================================================= //=================================================================================
// function : SetEditCurrentArgument() // function : SetEditCurrentArgument()
// purpose : // purpose :
@ -316,19 +324,40 @@ void PrimitiveGUI_BoxDlg::SetEditCurrentArgument()
{ {
QPushButton* send = (QPushButton*)sender(); QPushButton* send = (QPushButton*)sender();
if ( send == GroupPoints->PushButton1 ) // ?? Commented, because we need this flag in ConstructorsClicked, because
// SelectionIntoArgument must be called only on dialog creation, and must not be called on
// simple switch between constructors (as we need to keep old values in fields in this case)
// clear selection
//disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
//if (myInitial)
// myInitial = false;
//else
// myGeomGUI->getApp()->selectionMgr()->clearSelected();
if (send == GroupPoints->PushButton1) {
myEditCurrentArgument = GroupPoints->LineEdit1; myEditCurrentArgument = GroupPoints->LineEdit1;
else if ( send == GroupPoints->PushButton2 ) GroupPoints->PushButton2->setDown(false);
GroupPoints->LineEdit2->setEnabled(false);
}
else if (send == GroupPoints->PushButton2) {
myEditCurrentArgument = GroupPoints->LineEdit2; myEditCurrentArgument = GroupPoints->LineEdit2;
GroupPoints->PushButton1->setDown(false);
// globalSelection( GEOM_POINT ); GroupPoints->LineEdit1->setEnabled(false);
globalSelection(); // close local contexts, if any
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
myEditCurrentArgument->setFocus();
SelectionIntoArgument();
} }
// enable line edit
myEditCurrentArgument->setEnabled(true);
myEditCurrentArgument->setFocus();
// after setFocus(), because it will be setDown(false) then loses focus
send->setDown(true);
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
globalSelection(); // close local contexts, if any
localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
}
//================================================================================= //=================================================================================
// function : LineEditReturnPressed() // function : LineEditReturnPressed()
@ -343,7 +372,6 @@ void PrimitiveGUI_BoxDlg::LineEditReturnPressed()
} }
} }
//================================================================================= //=================================================================================
// function : ActivateThisDialog() // function : ActivateThisDialog()
// purpose : // purpose :
@ -351,13 +379,17 @@ void PrimitiveGUI_BoxDlg::LineEditReturnPressed()
void PrimitiveGUI_BoxDlg::ActivateThisDialog() void PrimitiveGUI_BoxDlg::ActivateThisDialog()
{ {
GEOMBase_Skeleton::ActivateThisDialog(); GEOMBase_Skeleton::ActivateThisDialog();
connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), //if (getConstructorId() == 0) {
this, SLOT( SelectionIntoArgument() ) ); // localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
// connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
// this, SLOT(SelectionIntoArgument()));
//}
//displayPreview();
ConstructorsClicked( getConstructorId() ); // reinit, because some selected objects could be removed
Init();
} }
//================================================================================= //=================================================================================
// function : enterEvent [REDEFINED] // function : enterEvent [REDEFINED]
// purpose : // purpose :
@ -368,7 +400,6 @@ void PrimitiveGUI_BoxDlg::enterEvent( QEvent* )
ActivateThisDialog(); ActivateThisDialog();
} }
//================================================================================= //=================================================================================
// function : ValueChangedInSpinBox() // function : ValueChangedInSpinBox()
// purpose : // purpose :
@ -378,7 +409,6 @@ void PrimitiveGUI_BoxDlg::ValueChangedInSpinBox()
displayPreview(); displayPreview();
} }
//================================================================================= //=================================================================================
// function : createOperation // function : createOperation
// purpose : // purpose :
@ -388,17 +418,15 @@ GEOM::GEOM_IOperations_ptr PrimitiveGUI_BoxDlg::createOperation()
return getGeomEngine()->GetI3DPrimOperations(getStudyId()); return getGeomEngine()->GetI3DPrimOperations(getStudyId());
} }
//================================================================================= //=================================================================================
// function : isValid // function : isValid
// purpose : // purpose :
//================================================================================= //=================================================================================
bool PrimitiveGUI_BoxDlg::isValid( QString& msg ) bool PrimitiveGUI_BoxDlg::isValid (QString&)
{ {
return getConstructorId() == 0 ? !(myPoint1->_is_nil() || myPoint2->_is_nil()) : true; return getConstructorId() == 0 ? !(myPoint1->_is_nil() || myPoint2->_is_nil()) : true;
} }
//================================================================================= //=================================================================================
// function : execute // function : execute
// purpose : // purpose :
@ -416,9 +444,8 @@ bool PrimitiveGUI_BoxDlg::execute( ObjectList& objects )
anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())->MakeBoxTwoPnt(myPoint1, myPoint2); anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())->MakeBoxTwoPnt(myPoint1, myPoint2);
res = true; res = true;
} }
break;
} }
break;
case 1: case 1:
{ {
double x = GroupDimensions->SpinBox_DX->value(); double x = GroupDimensions->SpinBox_DX->value();
@ -427,8 +454,8 @@ bool PrimitiveGUI_BoxDlg::execute( ObjectList& objects )
anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())->MakeBoxDXDYDZ(x, y, z); anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())->MakeBoxDXDYDZ(x, y, z);
res = true; res = true;
break;
} }
break;
} }
if (!anObj->_is_nil()) if (!anObj->_is_nil())
@ -438,13 +465,13 @@ bool PrimitiveGUI_BoxDlg::execute( ObjectList& objects )
} }
//================================================================================= //=================================================================================
// function : addSubshapeToStudy // function : addSubshapesToStudy
// purpose : virtual method to add new SubObjects if local selection // purpose : virtual method to add new SubObjects if local selection
//================================================================================= //=================================================================================
void PrimitiveGUI_BoxDlg::addSubshapesToStudy() void PrimitiveGUI_BoxDlg::addSubshapesToStudy()
{ {
QMap<QString, GEOM::GEOM_Object_var> objMap;
if (getConstructorId() == 0) { if (getConstructorId() == 0) {
QMap<QString, GEOM::GEOM_Object_var> objMap;
objMap[GroupPoints->LineEdit1->text()] = myPoint1; objMap[GroupPoints->LineEdit1->text()] = myPoint1;
objMap[GroupPoints->LineEdit2->text()] = myPoint2; objMap[GroupPoints->LineEdit2->text()] = myPoint2;
addSubshapesToFather(objMap); addSubshapesToFather(objMap);

View File

@ -57,6 +57,9 @@ private:
private: private:
GEOM::GEOM_Object_var myPoint1, myPoint2; /* Points containing the vector */ GEOM::GEOM_Object_var myPoint1, myPoint2; /* Points containing the vector */
// to initialize the first selection field with a selected object on the dialog creation
bool myInitial;
DlgRef_2Sel* GroupPoints; DlgRef_2Sel* GroupPoints;
DlgRef_3Spin* GroupDimensions; DlgRef_3Spin* GroupDimensions;

View File

@ -29,11 +29,12 @@
#include <GeometryGUI.h> #include <GeometryGUI.h>
#include <GEOMBase.h> #include <GEOMBase.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h> #include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h>
#include <SalomeApp_Application.h> #include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h> #include <LightApp_SelectionMgr.h>
// OCCT Includes
#include <TopoDS_Shape.hxx> #include <TopoDS_Shape.hxx>
#include <TopoDS_Edge.hxx> #include <TopoDS_Edge.hxx>
#include <TopoDS.hxx> #include <TopoDS.hxx>
@ -52,7 +53,8 @@
//================================================================================= //=================================================================================
PrimitiveGUI_ConeDlg::PrimitiveGUI_ConeDlg (GeometryGUI* theGeometryGUI, QWidget* parent, PrimitiveGUI_ConeDlg::PrimitiveGUI_ConeDlg (GeometryGUI* theGeometryGUI, QWidget* parent,
bool modal, Qt::WindowFlags fl) bool modal, Qt::WindowFlags fl)
: GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl ) : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl),
myInitial(true)
{ {
QPixmap image0 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_CONE_PV"))); QPixmap image0 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_CONE_PV")));
QPixmap image1 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_CONE_DXYZ"))); QPixmap image1 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_CONE_DXYZ")));
@ -94,7 +96,6 @@ PrimitiveGUI_ConeDlg::PrimitiveGUI_ConeDlg( GeometryGUI* theGeometryGUI, QWidget
Init(); Init();
} }
//================================================================================= //=================================================================================
// function : ~PrimitiveGUI_ConeDlg() // function : ~PrimitiveGUI_ConeDlg()
// purpose : Destroys the object and frees any allocated resources // purpose : Destroys the object and frees any allocated resources
@ -104,25 +105,17 @@ PrimitiveGUI_ConeDlg::~PrimitiveGUI_ConeDlg()
// no need to delete child widgets, Qt does it all for us // no need to delete child widgets, Qt does it all for us
} }
//================================================================================= //=================================================================================
// function : Init() // function : Init()
// purpose : // purpose :
//================================================================================= //=================================================================================
void PrimitiveGUI_ConeDlg::Init() void PrimitiveGUI_ConeDlg::Init()
{ {
/* init variables */ // Get setting of step value from file configuration
myEditCurrentArgument = GroupPoints->LineEdit1;
GroupPoints->LineEdit1->setReadOnly( true );
GroupPoints->LineEdit2->setReadOnly( true );
myPoint = myDir = GEOM::GEOM_Object::_nil();
/* Get setting of step value from file configuration */
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100); double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100);
/* min, max, step and decimals for spin boxes & initial values */ // min, max, step and decimals for spin boxes & initial values
initSpinBox(GroupPoints->SpinBox_DX, 0.000, COORD_MAX, step, 3); // VSR: TODO: DBL_DIGITS_DISPLAY initSpinBox(GroupPoints->SpinBox_DX, 0.000, COORD_MAX, step, 3); // VSR: TODO: DBL_DIGITS_DISPLAY
initSpinBox(GroupPoints->SpinBox_DY, 0.000, COORD_MAX, step, 3); // VSR: TODO: DBL_DIGITS_DISPLAY initSpinBox(GroupPoints->SpinBox_DY, 0.000, COORD_MAX, step, 3); // VSR: TODO: DBL_DIGITS_DISPLAY
initSpinBox(GroupPoints->SpinBox_DZ, COORD_MIN, COORD_MAX, step, 3); // VSR: TODO: DBL_DIGITS_DISPLAY initSpinBox(GroupPoints->SpinBox_DZ, COORD_MIN, COORD_MAX, step, 3); // VSR: TODO: DBL_DIGITS_DISPLAY
@ -130,6 +123,14 @@ void PrimitiveGUI_ConeDlg::Init()
initSpinBox(GroupDimensions->SpinBox_DY, 0.000, COORD_MAX, step, 3); // VSR: TODO: DBL_DIGITS_DISPLAY initSpinBox(GroupDimensions->SpinBox_DY, 0.000, COORD_MAX, step, 3); // VSR: TODO: DBL_DIGITS_DISPLAY
initSpinBox(GroupDimensions->SpinBox_DZ, COORD_MIN, COORD_MAX, step, 3); // VSR: TODO: DBL_DIGITS_DISPLAY initSpinBox(GroupDimensions->SpinBox_DZ, COORD_MIN, COORD_MAX, step, 3); // VSR: TODO: DBL_DIGITS_DISPLAY
// init variables
GroupPoints->LineEdit1->setReadOnly(true);
GroupPoints->LineEdit2->setReadOnly(true);
GroupPoints->LineEdit1->setText("");
GroupPoints->LineEdit2->setText("");
myPoint = myDir = GEOM::GEOM_Object::_nil();
double aRadius1(100.0), aRadius2(0.0), aHeight(300.0); double aRadius1(100.0), aRadius2(0.0), aHeight(300.0);
GroupPoints->SpinBox_DX->setValue(aRadius1); GroupPoints->SpinBox_DX->setValue(aRadius1);
GroupPoints->SpinBox_DY->setValue(aRadius2); GroupPoints->SpinBox_DY->setValue(aRadius2);
@ -138,7 +139,7 @@ void PrimitiveGUI_ConeDlg::Init()
GroupDimensions->SpinBox_DY->setValue(aRadius2); GroupDimensions->SpinBox_DY->setValue(aRadius2);
GroupDimensions->SpinBox_DZ->setValue(aHeight); GroupDimensions->SpinBox_DZ->setValue(aHeight);
/* 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()));
@ -159,16 +160,12 @@ void PrimitiveGUI_ConeDlg::Init()
connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double))); connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double)));
connect( myGeomGUI->getApp()->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
initName(tr("GEOM_CONE")); initName(tr("GEOM_CONE"));
setConstructorId(1); // simplest constructor setConstructorId(1); // simplest constructor
ConstructorsClicked(1); ConstructorsClicked(1);
} }
//================================================================================= //=================================================================================
// function : SetDoubleSpinBoxStep() // function : SetDoubleSpinBoxStep()
// purpose : Double spin box management // purpose : Double spin box management
@ -189,34 +186,23 @@ void PrimitiveGUI_ConeDlg::SetDoubleSpinBoxStep( double step )
//================================================================================= //=================================================================================
void PrimitiveGUI_ConeDlg::ConstructorsClicked (int constructorId) void PrimitiveGUI_ConeDlg::ConstructorsClicked (int constructorId)
{ {
disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 );
switch (constructorId) { switch (constructorId) {
case 0: case 0:
{ {
//globalSelection( GEOM_POINT );
globalSelection(); // to break prvious local selection
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
GroupDimensions->hide(); GroupDimensions->hide();
GroupPoints->show(); GroupPoints->show();
myEditCurrentArgument = GroupPoints->LineEdit1; GroupPoints->PushButton1->click();
GroupPoints->LineEdit1->setText( "" );
GroupPoints->LineEdit2->setText( "" );
myPoint = myDir = GEOM::GEOM_Object::_nil();
connect( myGeomGUI->getApp()->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
break; break;
} }
case 1: case 1:
{ {
globalSelection(); // close local contexts, if any
GroupPoints->hide(); GroupPoints->hide();
GroupDimensions->show(); GroupDimensions->show();
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
globalSelection(); // close local contexts, if any
displayPreview();
break; break;
} }
} }
@ -225,9 +211,15 @@ void PrimitiveGUI_ConeDlg::ConstructorsClicked( int constructorId )
updateGeometry(); updateGeometry();
resize(minimumSize()); resize(minimumSize());
if (myInitial) {
// on dialog initialization we init the first field with a selected object (if any)
SelectionIntoArgument();
myInitial = false;
}
else {
displayPreview(); displayPreview();
} }
}
//================================================================================= //=================================================================================
// function : ClickOnOk() // function : ClickOnOk()
@ -239,7 +231,6 @@ void PrimitiveGUI_ConeDlg::ClickOnOk()
ClickOnCancel(); ClickOnCancel();
} }
//================================================================================= //=================================================================================
// function : ClickOnApply() // function : ClickOnApply()
// purpose : // purpose :
@ -250,49 +241,54 @@ bool PrimitiveGUI_ConeDlg::ClickOnApply()
return false; return false;
initName(); initName();
// activate selection and connect selection manager
ConstructorsClicked(getConstructorId()); ConstructorsClicked(getConstructorId());
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
//================================================================================= //=================================================================================
void PrimitiveGUI_ConeDlg::SelectionIntoArgument() void PrimitiveGUI_ConeDlg::SelectionIntoArgument()
{ {
if (getConstructorId() != 0) if (getConstructorId() != 0)
return; return;
erasePreview();
myEditCurrentArgument->setText("");
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) {
if (myEditCurrentArgument == GroupPoints->LineEdit1) if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint = GEOM::GEOM_Object::_nil();
myPoint = GEOM::GEOM_Object::_nil(); else if (myEditCurrentArgument == GroupPoints->LineEdit2) myDir = GEOM::GEOM_Object::_nil();
else if (myEditCurrentArgument == GroupPoints->LineEdit2)
myDir = GEOM::GEOM_Object::_nil();
return; return;
} }
/* nbSel == 1 */ // nbSel == 1
Standard_Boolean testResult = Standard_False; Standard_Boolean testResult = Standard_False;
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult); GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult);
if (!testResult || CORBA::is_nil(aSelectedObject)) if (!testResult || CORBA::is_nil(aSelectedObject))
return; return;
TopoDS_Shape aShape;
QString aName = GEOMBase::GetName(aSelectedObject); QString aName = GEOMBase::GetName(aSelectedObject);
if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) { // Get Selected object if selected subshape
TopoDS_Shape aShape;
if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull())
{
TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX; TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
if (myEditCurrentArgument == GroupPoints->LineEdit2) if (myEditCurrentArgument == GroupPoints->LineEdit2)
aNeedType = TopAbs_EDGE; aNeedType = TopAbs_EDGE;
TColStd_IndexedMapOfInteger aMap; TColStd_IndexedMapOfInteger aMap;
aSelMgr->GetIndexes(aSelList.First(), aMap); aSelMgr->GetIndexes(aSelList.First(), aMap);
if ( aMap.Extent() == 1 ) { if (aMap.Extent() == 1) // Local Selection
{
int anIndex = aMap(1); int anIndex = aMap(1);
if (aNeedType == TopAbs_EDGE) if (aNeedType == TopAbs_EDGE)
aName.append(":edge_" + QString::number(anIndex)); aName.append(":edge_" + QString::number(anIndex));
@ -311,7 +307,8 @@ void PrimitiveGUI_ConeDlg::SelectionIntoArgument()
aSelectedObject = aFindedObject; // get Object from study aSelectedObject = aFindedObject; // get Object from study
} }
} }
else { else // Global Selection
{
if (aShape.ShapeType() != aNeedType) { if (aShape.ShapeType() != aNeedType) {
aSelectedObject = GEOM::GEOM_Object::_nil(); aSelectedObject = GEOM::GEOM_Object::_nil();
aName = ""; aName = "";
@ -321,10 +318,22 @@ void PrimitiveGUI_ConeDlg::SelectionIntoArgument()
myEditCurrentArgument->setText(aName); myEditCurrentArgument->setText(aName);
if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) // clear selection
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
myGeomGUI->getApp()->selectionMgr()->clearSelected();
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
if (myEditCurrentArgument == GroupPoints->LineEdit1) {
myPoint = aSelectedObject; myPoint = aSelectedObject;
else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) if (!myPoint->_is_nil() && myDir->_is_nil())
GroupPoints->PushButton2->click();
}
else if (myEditCurrentArgument == GroupPoints->LineEdit2) {
myDir = aSelectedObject; myDir = aSelectedObject;
if (!myDir->_is_nil() && myPoint->_is_nil())
GroupPoints->PushButton1->click();
}
displayPreview(); displayPreview();
} }
@ -337,22 +346,35 @@ void PrimitiveGUI_ConeDlg::SetEditCurrentArgument()
{ {
QPushButton* send = (QPushButton*)sender(); QPushButton* send = (QPushButton*)sender();
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
if (send == GroupPoints->PushButton1) { if (send == GroupPoints->PushButton1) {
myEditCurrentArgument = GroupPoints->LineEdit1; myEditCurrentArgument = GroupPoints->LineEdit1;
globalSelection( GEOM_POINT ); // to break prvious local selection
GroupPoints->PushButton2->setDown(false);
GroupPoints->LineEdit2->setEnabled(false);
globalSelection(GEOM_POINT); // to break previous local selection
localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
} }
else if (send == GroupPoints->PushButton2) { else if (send == GroupPoints->PushButton2) {
myEditCurrentArgument = GroupPoints->LineEdit2; myEditCurrentArgument = GroupPoints->LineEdit2;
globalSelection( GEOM_LINE );// to break prvious local selection
GroupPoints->PushButton1->setDown(false);
GroupPoints->LineEdit1->setEnabled(false);
globalSelection(GEOM_LINE);// to break previous local selection
localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE); localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE);
} }
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
// enable line edit
myEditCurrentArgument->setEnabled(true);
myEditCurrentArgument->setFocus(); myEditCurrentArgument->setFocus();
SelectionIntoArgument(); // after setFocus(), because it will be setDown(false) then loses focus
send->setDown(true);
} }
//================================================================================= //=================================================================================
// function : LineEditReturnPressed() // function : LineEditReturnPressed()
// purpose : // purpose :
@ -367,7 +389,6 @@ void PrimitiveGUI_ConeDlg::LineEditReturnPressed()
} }
} }
//================================================================================= //=================================================================================
// function : ActivateThisDialog() // function : ActivateThisDialog()
// purpose : // purpose :
@ -375,23 +396,11 @@ void PrimitiveGUI_ConeDlg::LineEditReturnPressed()
void PrimitiveGUI_ConeDlg::ActivateThisDialog() void PrimitiveGUI_ConeDlg::ActivateThisDialog()
{ {
GEOMBase_Skeleton::ActivateThisDialog(); GEOMBase_Skeleton::ActivateThisDialog();
connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
this, SLOT( SelectionIntoArgument() ) );
ConstructorsClicked( getConstructorId() ); // reinit, because some selected objects could be removed
Init();
} }
//=================================================================================
// function : DeactivateActiveDialog()
// purpose : public slot to deactivate if active
//=================================================================================
void PrimitiveGUI_ConeDlg::DeactivateActiveDialog()
{
GEOMBase_Skeleton::DeactivateActiveDialog();
}
//================================================================================= //=================================================================================
// function : enterEvent() // function : enterEvent()
// purpose : // purpose :
@ -402,7 +411,6 @@ void PrimitiveGUI_ConeDlg::enterEvent( QEvent* )
ActivateThisDialog(); ActivateThisDialog();
} }
//================================================================================= //=================================================================================
// function : ValueChangedInSpinBox() // function : ValueChangedInSpinBox()
// purpose : // purpose :
@ -412,7 +420,6 @@ void PrimitiveGUI_ConeDlg::ValueChangedInSpinBox()
displayPreview(); displayPreview();
} }
//================================================================================= //=================================================================================
// function : createOperation // function : createOperation
// purpose : // purpose :
@ -426,7 +433,7 @@ GEOM::GEOM_IOperations_ptr PrimitiveGUI_ConeDlg::createOperation()
// function : isValid // function : isValid
// purpose : // purpose :
//================================================================================= //=================================================================================
bool PrimitiveGUI_ConeDlg::isValid( QString& msg ) bool PrimitiveGUI_ConeDlg::isValid (QString&)
{ {
return getConstructorId() == 0 ? !(myPoint->_is_nil() || myDir->_is_nil()) : true; return getConstructorId() == 0 ? !(myPoint->_is_nil() || myDir->_is_nil()) : true;
} }
@ -444,18 +451,14 @@ bool PrimitiveGUI_ConeDlg::execute( ObjectList& objects )
switch (getConstructorId()) { switch (getConstructorId()) {
case 0: case 0:
if (!CORBA::is_nil(myPoint) && !CORBA::is_nil(myDir)) { if (!CORBA::is_nil(myPoint) && !CORBA::is_nil(myDir)) {
anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeConePntVecR1R2H( myPoint, anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())->
myDir, MakeConePntVecR1R2H(myPoint, myDir, getRadius1(), getRadius2(), getHeight());
getRadius1(),
getRadius2(),
getHeight() );
res = true; res = true;
} }
break; break;
case 1: case 1:
anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeConeR1R2H( getRadius1(), anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())->
getRadius2(), MakeConeR1R2H(getRadius1(), getRadius2(), getHeight());
getHeight() );
res = true; res = true;
break; break;
} }
@ -466,7 +469,6 @@ bool PrimitiveGUI_ConeDlg::execute( ObjectList& objects )
return res; return res;
} }
//================================================================================= //=================================================================================
// function : getRadius1() // function : getRadius1()
// purpose : // purpose :
@ -481,7 +483,6 @@ double PrimitiveGUI_ConeDlg::getRadius1() const
return 0; return 0;
} }
//================================================================================= //=================================================================================
// function : getRadius2() // function : getRadius2()
// purpose : // purpose :
@ -496,9 +497,8 @@ double PrimitiveGUI_ConeDlg::getRadius2() const
return 0; return 0;
} }
//================================================================================= //=================================================================================
// function : getRadius2() // function : getHeight()
// purpose : // purpose :
//================================================================================= //=================================================================================
double PrimitiveGUI_ConeDlg::getHeight() const double PrimitiveGUI_ConeDlg::getHeight() const

View File

@ -60,6 +60,9 @@ private:
private: private:
GEOM::GEOM_Object_var myPoint, myDir; GEOM::GEOM_Object_var myPoint, myDir;
// to initialize the first selection field with a selected object on the dialog creation
bool myInitial;
DlgRef_2Sel3Spin* GroupPoints; DlgRef_2Sel3Spin* GroupPoints;
DlgRef_3Spin* GroupDimensions; DlgRef_3Spin* GroupDimensions;
@ -67,7 +70,6 @@ private slots:
void ClickOnOk(); void ClickOnOk();
bool ClickOnApply(); bool ClickOnApply();
void ActivateThisDialog(); void ActivateThisDialog();
void DeactivateActiveDialog();
void LineEditReturnPressed(); void LineEditReturnPressed();
void SelectionIntoArgument(); void SelectionIntoArgument();
void SetEditCurrentArgument(); void SetEditCurrentArgument();

View File

@ -26,15 +26,15 @@
#include "PrimitiveGUI_CylinderDlg.h" #include "PrimitiveGUI_CylinderDlg.h"
#include <DlgRef.h> #include <DlgRef.h>
#include <GeometryGUI.h> #include <GeometryGUI.h>
#include <GEOMBase.h> #include <GEOMBase.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h> #include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h>
#include <SalomeApp_Application.h> #include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h> #include <LightApp_SelectionMgr.h>
// OCCT Includes
#include <TopoDS_Shape.hxx> #include <TopoDS_Shape.hxx>
#include <TopoDS_Edge.hxx> #include <TopoDS_Edge.hxx>
#include <TopoDS.hxx> #include <TopoDS.hxx>
@ -53,7 +53,8 @@
//================================================================================= //=================================================================================
PrimitiveGUI_CylinderDlg::PrimitiveGUI_CylinderDlg (GeometryGUI* theGeometryGUI, QWidget* parent, PrimitiveGUI_CylinderDlg::PrimitiveGUI_CylinderDlg (GeometryGUI* theGeometryGUI, QWidget* parent,
bool modal, Qt::WindowFlags fl) bool modal, Qt::WindowFlags fl)
: GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl ) : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl),
myInitial(true)
{ {
QPixmap image0 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_CYLINDER_PV"))); QPixmap image0 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_CYLINDER_PV")));
QPixmap image1 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_CYLINDER_DXYZ"))); QPixmap image1 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_CYLINDER_DXYZ")));
@ -93,7 +94,6 @@ PrimitiveGUI_CylinderDlg::PrimitiveGUI_CylinderDlg( GeometryGUI* theGeometryGUI,
Init(); Init();
} }
//================================================================================= //=================================================================================
// function : ~PrimitiveGUI_CylinderDlg() // function : ~PrimitiveGUI_CylinderDlg()
// purpose : Destroys the object and frees any allocated resources // purpose : Destroys the object and frees any allocated resources
@ -103,40 +103,38 @@ PrimitiveGUI_CylinderDlg::~PrimitiveGUI_CylinderDlg()
// no need to delete child widgets, Qt does it all for us // no need to delete child widgets, Qt does it all for us
} }
//================================================================================= //=================================================================================
// function : Init() // function : Init()
// purpose : // purpose :
//================================================================================= //=================================================================================
void PrimitiveGUI_CylinderDlg::Init() void PrimitiveGUI_CylinderDlg::Init()
{ {
/* init variables */ // Get setting of step value from file configuration
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100);
// min, max, step and decimals for spin boxes & initial values
initSpinBox(GroupPoints->SpinBox_DX, 0.001, COORD_MAX, step, 3); // VSR: TODO: DBL_DIGITS_DISPLAY
initSpinBox(GroupPoints->SpinBox_DY, COORD_MIN, COORD_MAX, step, 3); // VSR: TODO: DBL_DIGITS_DISPLAY
initSpinBox(GroupDimensions->SpinBox_DX, 0.001, COORD_MAX, step, 3); // VSR: TODO: DBL_DIGITS_DISPLAY
initSpinBox(GroupDimensions->SpinBox_DY, COORD_MIN, COORD_MAX, step, 3); // VSR: TODO: DBL_DIGITS_DISPLAY
// init variables
myEditCurrentArgument = GroupPoints->LineEdit1; myEditCurrentArgument = GroupPoints->LineEdit1;
GroupPoints->LineEdit1->setReadOnly(true); GroupPoints->LineEdit1->setReadOnly(true);
GroupPoints->LineEdit2->setReadOnly(true); GroupPoints->LineEdit2->setReadOnly(true);
GroupPoints->LineEdit1->setText("");
GroupPoints->LineEdit2->setText("");
myPoint = myDir = GEOM::GEOM_Object::_nil(); myPoint = myDir = GEOM::GEOM_Object::_nil();
/* Get setting of step value from file configuration */ double aRadius(100.0), aHeight(300.0);
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); GroupPoints->SpinBox_DX->setValue(aRadius);
double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100 ); GroupPoints->SpinBox_DY->setValue(aHeight);
GroupDimensions->SpinBox_DX->setValue(aRadius);
GroupDimensions->SpinBox_DY->setValue(aHeight);
/* min, max, step and decimals for spin boxes & initial values */ // signals and slots connections
/* First constructor : radius */
initSpinBox( GroupPoints->SpinBox_DX, 0.001, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
/* First constructor : algebric height */
initSpinBox( GroupPoints->SpinBox_DY, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
/* Second constructor : radius */
initSpinBox( GroupDimensions->SpinBox_DX, 0.001, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
/* Second constructor : algebric height */
initSpinBox( GroupDimensions->SpinBox_DY, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
GroupPoints->SpinBox_DX->setValue( 100.0 );
GroupPoints->SpinBox_DY->setValue( 300.0 );
GroupDimensions->SpinBox_DX->setValue( 100.0 );
GroupDimensions->SpinBox_DY->setValue( 300.0 );
/* 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()));
@ -155,16 +153,12 @@ void PrimitiveGUI_CylinderDlg::Init()
connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double))); connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double)));
connect( myGeomGUI->getApp()->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
initName(tr("GEOM_CYLINDER")); initName(tr("GEOM_CYLINDER"));
setConstructorId(1); // simplest constructor setConstructorId(1); // simplest constructor
ConstructorsClicked(1); ConstructorsClicked(1);
} }
//================================================================================= //=================================================================================
// function : SetDoubleSpinBoxStep() // function : SetDoubleSpinBoxStep()
// purpose : Double spin box management // purpose : Double spin box management
@ -177,7 +171,6 @@ void PrimitiveGUI_CylinderDlg::SetDoubleSpinBoxStep( double step )
GroupDimensions->SpinBox_DY->setSingleStep(step); GroupDimensions->SpinBox_DY->setSingleStep(step);
} }
//================================================================================= //=================================================================================
// function : ConstructorsClicked() // function : ConstructorsClicked()
// purpose : Radio button management // purpose : Radio button management
@ -189,27 +182,18 @@ void PrimitiveGUI_CylinderDlg::ConstructorsClicked( int constructorId )
switch (constructorId) { switch (constructorId) {
case 0: case 0:
{ {
globalSelection( GEOM_POINT ); // to break previous local selection
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
GroupDimensions->hide(); GroupDimensions->hide();
GroupPoints->show(); GroupPoints->show();
myEditCurrentArgument = GroupPoints->LineEdit1; GroupPoints->PushButton1->click();
GroupPoints->LineEdit1->setText( "" );
GroupPoints->LineEdit2->setText( "" );
myPoint = myDir = GEOM::GEOM_Object::_nil();
connect( myGeomGUI->getApp()->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
break; break;
} }
case 1: case 1:
{ {
globalSelection(); // close local contexts, if any
GroupPoints->hide(); GroupPoints->hide();
GroupDimensions->show(); GroupDimensions->show();
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
globalSelection(); // close local contexts, if any
break; break;
} }
} }
@ -218,9 +202,20 @@ void PrimitiveGUI_CylinderDlg::ConstructorsClicked( int constructorId )
updateGeometry(); updateGeometry();
resize(minimumSize()); resize(minimumSize());
if (myInitial) {
myInitial = false;
if (constructorId == 0) {
// on dialog initialization we init the first field with a selected object (if any)
SelectionIntoArgument();
}
else {
displayPreview(); displayPreview();
} }
}
else {
displayPreview();
}
}
//================================================================================= //=================================================================================
// function : ClickOnOk() // function : ClickOnOk()
@ -232,7 +227,6 @@ void PrimitiveGUI_CylinderDlg::ClickOnOk()
ClickOnCancel(); ClickOnCancel();
} }
//================================================================================= //=================================================================================
// function : ClickOnApply() // function : ClickOnApply()
// purpose : // purpose :
@ -243,20 +237,21 @@ bool PrimitiveGUI_CylinderDlg::ClickOnApply()
return false; return false;
initName(); initName();
// activate selection and connect selection manager
ConstructorsClicked(getConstructorId()); ConstructorsClicked(getConstructorId());
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
//================================================================================= //=================================================================================
void PrimitiveGUI_CylinderDlg::SelectionIntoArgument() void PrimitiveGUI_CylinderDlg::SelectionIntoArgument()
{ {
if (getConstructorId() != 0) if (getConstructorId() != 0)
return; return;
erasePreview();
myEditCurrentArgument->setText(""); myEditCurrentArgument->setText("");
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
@ -271,7 +266,7 @@ void PrimitiveGUI_CylinderDlg::SelectionIntoArgument()
return; return;
} }
/* nbSel == 1 */ // nbSel == 1
Standard_Boolean testResult = Standard_False; Standard_Boolean testResult = Standard_False;
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult); GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult);
@ -279,8 +274,11 @@ void PrimitiveGUI_CylinderDlg::SelectionIntoArgument()
return; return;
QString aName = GEOMBase::GetName(aSelectedObject); QString aName = GEOMBase::GetName(aSelectedObject);
// Get Selected object if selected subshape
TopoDS_Shape aShape; TopoDS_Shape aShape;
if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) { if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull())
{
TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX; TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
if (myEditCurrentArgument == GroupPoints->LineEdit2) if (myEditCurrentArgument == GroupPoints->LineEdit2)
aNeedType = TopAbs_EDGE; aNeedType = TopAbs_EDGE;
@ -316,15 +314,26 @@ void PrimitiveGUI_CylinderDlg::SelectionIntoArgument()
myEditCurrentArgument->setText(aName); myEditCurrentArgument->setText(aName);
if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) // clear selection
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
myGeomGUI->getApp()->selectionMgr()->clearSelected();
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
if (myEditCurrentArgument == GroupPoints->LineEdit1) {
myPoint = aSelectedObject; myPoint = aSelectedObject;
else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) if (!myPoint->_is_nil() && myDir->_is_nil())
GroupPoints->PushButton2->click();
}
else if (myEditCurrentArgument == GroupPoints->LineEdit2) {
myDir = aSelectedObject; myDir = aSelectedObject;
if (!myDir->_is_nil() && myPoint->_is_nil())
GroupPoints->PushButton1->click();
}
displayPreview(); displayPreview();
} }
//================================================================================= //=================================================================================
// function : SetEditCurrentArgument() // function : SetEditCurrentArgument()
// purpose : // purpose :
@ -333,22 +342,35 @@ void PrimitiveGUI_CylinderDlg::SetEditCurrentArgument()
{ {
QPushButton* send = (QPushButton*)sender(); QPushButton* send = (QPushButton*)sender();
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
if (send == GroupPoints->PushButton1) { if (send == GroupPoints->PushButton1) {
myEditCurrentArgument = GroupPoints->LineEdit1; myEditCurrentArgument = GroupPoints->LineEdit1;
GroupPoints->PushButton2->setDown(false);
GroupPoints->LineEdit2->setEnabled(false);
globalSelection(GEOM_POINT); // to break previous local selection globalSelection(GEOM_POINT); // to break previous local selection
localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
} }
else if (send == GroupPoints->PushButton2) { else if (send == GroupPoints->PushButton2) {
myEditCurrentArgument = GroupPoints->LineEdit2; myEditCurrentArgument = GroupPoints->LineEdit2;
GroupPoints->PushButton1->setDown(false);
GroupPoints->LineEdit1->setEnabled(false);
globalSelection(GEOM_LINE); // to break previous local selection globalSelection(GEOM_LINE); // to break previous local selection
localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE); localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE);
} }
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
// enable line edit
myEditCurrentArgument->setEnabled(true);
myEditCurrentArgument->setFocus(); myEditCurrentArgument->setFocus();
SelectionIntoArgument(); // after setFocus(), because it will be setDown(false) then loses focus
send->setDown(true);
} }
//================================================================================= //=================================================================================
// function : LineEditReturnPressed() // function : LineEditReturnPressed()
// purpose : // purpose :
@ -363,7 +385,6 @@ void PrimitiveGUI_CylinderDlg::LineEditReturnPressed()
} }
} }
//================================================================================= //=================================================================================
// function : ActivateThisDialog() // function : ActivateThisDialog()
// purpose : // purpose :
@ -371,13 +392,11 @@ void PrimitiveGUI_CylinderDlg::LineEditReturnPressed()
void PrimitiveGUI_CylinderDlg::ActivateThisDialog() void PrimitiveGUI_CylinderDlg::ActivateThisDialog()
{ {
GEOMBase_Skeleton::ActivateThisDialog(); GEOMBase_Skeleton::ActivateThisDialog();
connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
this, SLOT( SelectionIntoArgument() ) );
ConstructorsClicked( getConstructorId() ); // reinit, because some selected objects could be removed
Init();
} }
//================================================================================= //=================================================================================
// function : enterEvent() // function : enterEvent()
// purpose : // purpose :
@ -388,19 +407,8 @@ void PrimitiveGUI_CylinderDlg::enterEvent( QEvent* )
ActivateThisDialog(); ActivateThisDialog();
} }
//================================================================================= //=================================================================================
// function : DeactivateActiveDialog() // function : ValueChangedInSpinBox()
// purpose : public slot to deactivate if active
//=================================================================================
void PrimitiveGUI_CylinderDlg::DeactivateActiveDialog()
{
GEOMBase_Skeleton::DeactivateActiveDialog();
}
//=================================================================================
// function : ValueChangedInSpinBox
// purpose : // purpose :
//================================================================================= //=================================================================================
void PrimitiveGUI_CylinderDlg::ValueChangedInSpinBox() void PrimitiveGUI_CylinderDlg::ValueChangedInSpinBox()
@ -408,7 +416,6 @@ void PrimitiveGUI_CylinderDlg::ValueChangedInSpinBox( )
displayPreview(); displayPreview();
} }
//================================================================================= //=================================================================================
// function : createOperation // function : createOperation
// purpose : // purpose :
@ -418,12 +425,11 @@ GEOM::GEOM_IOperations_ptr PrimitiveGUI_CylinderDlg::createOperation()
return getGeomEngine()->GetI3DPrimOperations(getStudyId()); return getGeomEngine()->GetI3DPrimOperations(getStudyId());
} }
//================================================================================= //=================================================================================
// function : isValid // function : isValid
// purpose : // purpose :
//================================================================================= //=================================================================================
bool PrimitiveGUI_CylinderDlg::isValid( QString& msg ) bool PrimitiveGUI_CylinderDlg::isValid (QString&)
{ {
return getConstructorId() == 0 ? !(myPoint->_is_nil() || myDir->_is_nil()) : true; return getConstructorId() == 0 ? !(myPoint->_is_nil() || myDir->_is_nil()) : true;
} }
@ -441,14 +447,15 @@ bool PrimitiveGUI_CylinderDlg::execute( ObjectList& objects )
switch (getConstructorId()) { switch (getConstructorId()) {
case 0: case 0:
if (!CORBA::is_nil(myPoint) && !CORBA::is_nil(myDir)) { if (!CORBA::is_nil(myPoint) && !CORBA::is_nil(myDir)) {
anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeCylinderPntVecRH( myPoint, myDir, getRadius(), getHeight() ); anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())->
MakeCylinderPntVecRH(myPoint, myDir, getRadius(), getHeight());
res = true; res = true;
} }
break; break;
case 1: case 1:
anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeCylinderRH( getRadius(), getHeight() ); anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())->
MakeCylinderRH(getRadius(), getHeight());
res = true; res = true;
break; break;
} }
@ -458,7 +465,6 @@ bool PrimitiveGUI_CylinderDlg::execute( ObjectList& objects )
return res; return res;
} }
//================================================================================= //=================================================================================
// function : getRadius() // function : getRadius()
// purpose : // purpose :
@ -473,7 +479,6 @@ double PrimitiveGUI_CylinderDlg::getRadius() const
return 0; return 0;
} }
//================================================================================= //=================================================================================
// function : getHeight() // function : getHeight()
// purpose : // purpose :

View File

@ -59,6 +59,9 @@ private:
private: private:
GEOM::GEOM_Object_var myPoint, myDir; GEOM::GEOM_Object_var myPoint, myDir;
// to initialize the first selection field with a selected object on the dialog creation
bool myInitial;
DlgRef_2Sel2Spin* GroupPoints; DlgRef_2Sel2Spin* GroupPoints;
DlgRef_2Spin* GroupDimensions; DlgRef_2Spin* GroupDimensions;
@ -66,7 +69,6 @@ private slots:
void ClickOnOk(); void ClickOnOk();
bool ClickOnApply(); bool ClickOnApply();
void ActivateThisDialog(); void ActivateThisDialog();
void DeactivateActiveDialog();
void LineEditReturnPressed(); void LineEditReturnPressed();
void SelectionIntoArgument(); void SelectionIntoArgument();
void SetEditCurrentArgument(); void SetEditCurrentArgument();

View File

@ -26,21 +26,21 @@
#include "PrimitiveGUI_DiskDlg.h" #include "PrimitiveGUI_DiskDlg.h"
#include <DlgRef.h> #include <DlgRef.h>
#include <GeometryGUI.h> #include <GeometryGUI.h>
#include <GEOMBase.h> #include <GEOMBase.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h> #include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h>
#include <SalomeApp_Application.h> #include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h> #include <LightApp_SelectionMgr.h>
#include <TColStd_IndexedMapOfInteger.hxx> // OCCT Includes
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopoDS_Shape.hxx> #include <TopoDS_Shape.hxx>
#include <TopoDS_Edge.hxx> #include <TopoDS_Edge.hxx>
#include <TopoDS.hxx> #include <TopoDS.hxx>
#include <TopExp.hxx> #include <TopExp.hxx>
#include <TColStd_IndexedMapOfInteger.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
//================================================================================= //=================================================================================
// class : PrimitiveGUI_DiskDlg() // class : PrimitiveGUI_DiskDlg()
@ -51,12 +51,14 @@
//================================================================================= //=================================================================================
PrimitiveGUI_DiskDlg::PrimitiveGUI_DiskDlg (GeometryGUI* theGeometryGUI, QWidget* parent, PrimitiveGUI_DiskDlg::PrimitiveGUI_DiskDlg (GeometryGUI* theGeometryGUI, QWidget* parent,
bool modal, Qt::WindowFlags fl) bool modal, Qt::WindowFlags fl)
: GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl ) : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl),
myInitial(true)
{ {
QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_DISK_PNT_VEC_R" ) ) ); SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) ); QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_DISK_PNT_VEC_R")));
QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_DISK_THREE_POINTS" ) ) ); QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
QPixmap image3( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_DISK_R" ) ) ); QPixmap image2 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_DISK_THREE_POINTS")));
QPixmap image3 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_DISK_R")));
setWindowTitle(tr("GEOM_DISK_TITLE")); setWindowTitle(tr("GEOM_DISK_TITLE"));
@ -111,7 +113,6 @@ PrimitiveGUI_DiskDlg::PrimitiveGUI_DiskDlg( GeometryGUI* theGeometryGUI, QWidget
Init(); Init();
} }
//================================================================================= //=================================================================================
// function : ~PrimitiveGUI_DiskDlg() // function : ~PrimitiveGUI_DiskDlg()
// purpose : Destroys the object and frees any allocated resources // purpose : Destroys the object and frees any allocated resources
@ -120,33 +121,36 @@ PrimitiveGUI_DiskDlg::~PrimitiveGUI_DiskDlg()
{ {
} }
//================================================================================= //=================================================================================
// function : Init() // function : Init()
// purpose : // purpose :
//================================================================================= //=================================================================================
void PrimitiveGUI_DiskDlg::Init() void PrimitiveGUI_DiskDlg::Init()
{ {
/* init variables */ // Get setting of step value from file configuration
myEditCurrentArgument = GroupPntVecR->LineEdit1;
myOrientationType = 1;
myPoint = myDir = myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil();
/* Get setting of step value from file configuration */
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
double aStep = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100); double aStep = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100);
/* min, max, step and decimals for spin boxes & initial values */ // min, max, step and decimals for spin boxes & initial values
initSpinBox(GroupPntVecR->SpinBox_DX, 0.001, COORD_MAX, aStep, 3); // VSR:TODO : DBL_DIGITS_DISPLAY initSpinBox(GroupPntVecR->SpinBox_DX, 0.001, COORD_MAX, aStep, 3); // VSR:TODO : DBL_DIGITS_DISPLAY
GroupPntVecR->SpinBox_DX->setValue( 100 );
initSpinBox(GroupDimensions->SpinBox_DX, 0.001, COORD_MAX, aStep, 3); // VSR:TODO : DBL_DIGITS_DISPLAY initSpinBox(GroupDimensions->SpinBox_DX, 0.001, COORD_MAX, aStep, 3); // VSR:TODO : DBL_DIGITS_DISPLAY
// init variables
myEditCurrentArgument = GroupPntVecR->LineEdit1;
myOrientationType = 1;
GroupOrientation->RadioButton1->setChecked(true);
GroupPntVecR->LineEdit1->setText("");
GroupPntVecR->LineEdit2->setText("");
Group3Pnts->LineEdit1->setText("");
Group3Pnts->LineEdit2->setText("");
Group3Pnts->LineEdit3->setText("");
myPoint = myDir = myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil();
GroupPntVecR->SpinBox_DX->setValue(100);
GroupDimensions->SpinBox_DX->setValue(100); GroupDimensions->SpinBox_DX->setValue(100);
/* signals and slots connections */ // signals and slots connections
connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) );
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()));
@ -154,26 +158,27 @@ void PrimitiveGUI_DiskDlg::Init()
connect(GroupPntVecR->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupPntVecR->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(GroupPntVecR->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupPntVecR->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(GroupPntVecR->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); connect(GroupPntVecR->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(GroupPntVecR->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); connect(GroupPntVecR->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(Group3Pnts->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(Group3Pnts->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(Group3Pnts->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(Group3Pnts->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(Group3Pnts->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(Group3Pnts->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(Group3Pnts->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); connect(Group3Pnts->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(Group3Pnts->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); connect(Group3Pnts->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(Group3Pnts->LineEdit3, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); connect(Group3Pnts->LineEdit3, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(GroupPntVecR->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(GroupPntVecR->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
connect(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
connect(GroupOrientation->RadioButton1, SIGNAL(clicked()), this, SLOT(RadioButtonClicked())); connect(GroupOrientation->RadioButton1, SIGNAL(clicked()), this, SLOT(RadioButtonClicked()));
connect(GroupOrientation->RadioButton2, SIGNAL(clicked()), this, SLOT(RadioButtonClicked())); connect(GroupOrientation->RadioButton2, SIGNAL(clicked()), this, SLOT(RadioButtonClicked()));
connect(GroupOrientation->RadioButton3, SIGNAL(clicked()), this, SLOT(RadioButtonClicked())); connect(GroupOrientation->RadioButton3, SIGNAL(clicked()), this, SLOT(RadioButtonClicked()));
connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double)));
this, SLOT( SelectionIntoArgument() ) ); connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
initName(tr("GEOM_DISK")); initName(tr("GEOM_DISK"));
@ -186,6 +191,7 @@ void PrimitiveGUI_DiskDlg::Init()
//================================================================================= //=================================================================================
void PrimitiveGUI_DiskDlg::SetDoubleSpinBoxStep (double step) void PrimitiveGUI_DiskDlg::SetDoubleSpinBoxStep (double step)
{ {
GroupDimensions->SpinBox_DX->setSingleStep(step);
GroupPntVecR->SpinBox_DX->setSingleStep(step); GroupPntVecR->SpinBox_DX->setSingleStep(step);
} }
@ -212,8 +218,6 @@ void PrimitiveGUI_DiskDlg::ConstructorsClicked( int constructorId )
{ {
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
myPoint = myDir = myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil();
switch (constructorId) { switch (constructorId) {
case 0: case 0:
{ {
@ -221,31 +225,29 @@ void PrimitiveGUI_DiskDlg::ConstructorsClicked( int constructorId )
Group3Pnts->hide(); Group3Pnts->hide();
GroupDimensions->show(); GroupDimensions->show();
GroupOrientation->show(); GroupOrientation->show();
GroupOrientation->RadioButton1->setChecked( true );
myOrientationType = 1; disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
globalSelection(); // close local contexts, if any
break; break;
} }
case 1: case 1:
{ {
Group3Pnts->hide();
GroupPntVecR->show();
GroupDimensions->hide(); GroupDimensions->hide();
GroupOrientation->hide(); GroupOrientation->hide();
myEditCurrentArgument = GroupPntVecR->LineEdit1; GroupPntVecR->show();
GroupPntVecR->LineEdit1->setText( "" ); Group3Pnts->hide();
GroupPntVecR->LineEdit2->setText( "" );
GroupPntVecR->PushButton1->click();
break; break;
} }
case 2: case 2:
{ {
GroupPntVecR->hide();
Group3Pnts->show();
GroupDimensions->hide(); GroupDimensions->hide();
GroupOrientation->hide(); GroupOrientation->hide();
myEditCurrentArgument = Group3Pnts->LineEdit1; GroupPntVecR->hide();
Group3Pnts->LineEdit1->setText( "" ); Group3Pnts->show();
Group3Pnts->LineEdit2->setText( "" );
Group3Pnts->LineEdit3->setText( "" ); Group3Pnts->PushButton1->click();
break; break;
} }
} }
@ -254,14 +256,20 @@ void PrimitiveGUI_DiskDlg::ConstructorsClicked( int constructorId )
updateGeometry(); updateGeometry();
resize(minimumSize()); resize(minimumSize());
myEditCurrentArgument->setFocus(); if (myInitial) {
globalSelection(); // close local contexts, if any myInitial = false;
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); if (constructorId == 1 || constructorId == 2) {
// on dialog initialization we init the first field with a selected object (if any)
connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged() ), SelectionIntoArgument();
this, SLOT( SelectionIntoArgument() ) ); }
else {
displayPreview(); displayPreview();
} }
}
else {
displayPreview();
}
}
//================================================================================= //=================================================================================
// function : ClickOnOk() // function : ClickOnOk()
@ -283,28 +291,28 @@ bool PrimitiveGUI_DiskDlg::ClickOnApply()
return false; return false;
initName(); initName();
// activate selection and connect selection manager
ConstructorsClicked(getConstructorId()); ConstructorsClicked(getConstructorId());
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
//================================================================================= //=================================================================================
void PrimitiveGUI_DiskDlg::SelectionIntoArgument() void PrimitiveGUI_DiskDlg::SelectionIntoArgument()
{ {
if (getConstructorId() == 0) { if (getConstructorId() == 0)
displayPreview();
return; return;
}
erasePreview();
myEditCurrentArgument->setText(""); myEditCurrentArgument->setText("");
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
SALOME_ListIO aList; SALOME_ListIO aSelList;
aSelMgr->selectedObjects( aList ); aSelMgr->selectedObjects(aSelList);
if ( aList.Extent() != 1 ) { if (aSelList.Extent() != 1) {
if (myEditCurrentArgument == GroupPntVecR->LineEdit1) myPoint = GEOM::GEOM_Object::_nil(); if (myEditCurrentArgument == GroupPntVecR->LineEdit1) myPoint = GEOM::GEOM_Object::_nil();
else if (myEditCurrentArgument == GroupPntVecR->LineEdit2) myDir = GEOM::GEOM_Object::_nil(); else if (myEditCurrentArgument == GroupPntVecR->LineEdit2) myDir = GEOM::GEOM_Object::_nil();
else if (myEditCurrentArgument == Group3Pnts->LineEdit1) myPoint1 = GEOM::GEOM_Object::_nil(); else if (myEditCurrentArgument == Group3Pnts->LineEdit1) myPoint1 = GEOM::GEOM_Object::_nil();
@ -314,16 +322,19 @@ void PrimitiveGUI_DiskDlg::SelectionIntoArgument()
} }
// nbSel == 1 // nbSel == 1
Handle(SALOME_InteractiveObject) anIO = aList.First(); Handle(SALOME_InteractiveObject) anIO = aSelList.First();
Standard_Boolean testResult = Standard_False;
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(anIO, testResult);
if (!testResult || CORBA::is_nil(aSelectedObject))
return;
Standard_Boolean aRes = Standard_False;
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(anIO, aRes);
if ( !CORBA::is_nil( aSelectedObject ) && aRes ) {
QString aName = GEOMBase::GetName(aSelectedObject); QString aName = GEOMBase::GetName(aSelectedObject);
// If selected Vertex or Edge on the some Shape Get selection Subshape // If selected Vertex or Edge on the some Shape Get selection Subshape
TopoDS_Shape aShape; TopoDS_Shape aShape;
if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) { if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull())
{
TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX; TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
if (myEditCurrentArgument == GroupPntVecR->LineEdit2) if (myEditCurrentArgument == GroupPntVecR->LineEdit2)
aNeedType = TopAbs_EDGE; aNeedType = TopAbs_EDGE;
@ -358,17 +369,41 @@ void PrimitiveGUI_DiskDlg::SelectionIntoArgument()
myEditCurrentArgument->setText(aName); myEditCurrentArgument->setText(aName);
if ( myEditCurrentArgument == GroupPntVecR->LineEdit1 ) myPoint = aSelectedObject; // clear selection
else if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) myDir = aSelectedObject; disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) myPoint1 = aSelectedObject; myGeomGUI->getApp()->selectionMgr()->clearSelected();
else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) myPoint2 = aSelectedObject; connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) myPoint3 = aSelectedObject; this, SLOT(SelectionIntoArgument()));
if (myEditCurrentArgument == GroupPntVecR->LineEdit1) {
myPoint = aSelectedObject;
if (!myPoint->_is_nil() && myDir->_is_nil())
GroupPntVecR->PushButton2->click();
}
else if (myEditCurrentArgument == GroupPntVecR->LineEdit2) {
myDir = aSelectedObject;
if (!myDir->_is_nil() && myPoint->_is_nil())
GroupPntVecR->PushButton1->click();
}
else if (myEditCurrentArgument == Group3Pnts->LineEdit1) {
myPoint1 = aSelectedObject;
if (!myPoint1->_is_nil() && myPoint2->_is_nil())
Group3Pnts->PushButton2->click();
}
else if (myEditCurrentArgument == Group3Pnts->LineEdit2) {
myPoint2 = aSelectedObject;
if (!myPoint2->_is_nil() && myPoint3->_is_nil())
Group3Pnts->PushButton3->click();
}
else if (myEditCurrentArgument == Group3Pnts->LineEdit3) {
myPoint3 = aSelectedObject;
if (!myPoint3->_is_nil() && myPoint1->_is_nil())
Group3Pnts->PushButton1->click();
} }
displayPreview(); displayPreview();
} }
//================================================================================= //=================================================================================
// function : SetEditCurrentArgument() // function : SetEditCurrentArgument()
// purpose : // purpose :
@ -377,14 +412,44 @@ void PrimitiveGUI_DiskDlg::SetEditCurrentArgument()
{ {
QPushButton* send = (QPushButton*)sender(); QPushButton* send = (QPushButton*)sender();
if ( send == GroupPntVecR->PushButton1 ) myEditCurrentArgument = GroupPntVecR->LineEdit1; if (send == GroupPntVecR->PushButton1) {
else if ( send == GroupPntVecR->PushButton2 ) myEditCurrentArgument = GroupPntVecR->LineEdit2; myEditCurrentArgument = GroupPntVecR->LineEdit1;
else if ( send == Group3Pnts->PushButton1 ) myEditCurrentArgument = Group3Pnts->LineEdit1;
else if ( send == Group3Pnts->PushButton2 ) myEditCurrentArgument = Group3Pnts->LineEdit2;
else if ( send == Group3Pnts->PushButton3 ) myEditCurrentArgument = Group3Pnts->LineEdit3;
myEditCurrentArgument->setFocus(); GroupPntVecR->PushButton2->setDown(false);
GroupPntVecR->LineEdit2->setEnabled(false);
}
else if (send == GroupPntVecR->PushButton2) {
myEditCurrentArgument = GroupPntVecR->LineEdit2;
GroupPntVecR->PushButton1->setDown(false);
GroupPntVecR->LineEdit1->setEnabled(false);
}
else if (send == Group3Pnts->PushButton1) {
myEditCurrentArgument = Group3Pnts->LineEdit1;
Group3Pnts->PushButton2->setDown(false);
Group3Pnts->PushButton3->setDown(false);
Group3Pnts->LineEdit2->setEnabled(false);
Group3Pnts->LineEdit3->setEnabled(false);
}
else if (send == Group3Pnts->PushButton2) {
myEditCurrentArgument = Group3Pnts->LineEdit2;
Group3Pnts->PushButton1->setDown(false);
Group3Pnts->PushButton3->setDown(false);
Group3Pnts->LineEdit1->setEnabled(false);
Group3Pnts->LineEdit3->setEnabled(false);
}
else if (send == Group3Pnts->PushButton3) {
myEditCurrentArgument = Group3Pnts->LineEdit3;
Group3Pnts->PushButton1->setDown(false);
Group3Pnts->PushButton2->setDown(false);
Group3Pnts->LineEdit1->setEnabled(false);
Group3Pnts->LineEdit2->setEnabled(false);
}
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
if (myEditCurrentArgument == GroupPntVecR->LineEdit2) { if (myEditCurrentArgument == GroupPntVecR->LineEdit2) {
globalSelection(); // close local contexts, if any globalSelection(); // close local contexts, if any
localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE); localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE);
@ -393,8 +458,17 @@ void PrimitiveGUI_DiskDlg::SetEditCurrentArgument()
globalSelection(); // close local contexts, if any globalSelection(); // close local contexts, if any
localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
} }
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
SelectionIntoArgument(); // enable line edit
myEditCurrentArgument->setEnabled(true);
myEditCurrentArgument->setFocus();
// after setFocus(), because it will be setDown(false) then loses focus
send->setDown(true);
// seems we need it only to avoid preview disappearing, caused by selection mode change
displayPreview();
} }
//================================================================================= //=================================================================================
@ -414,7 +488,6 @@ void PrimitiveGUI_DiskDlg::LineEditReturnPressed()
} }
} }
//================================================================================= //=================================================================================
// function : ActivateThisDialog() // function : ActivateThisDialog()
// purpose : // purpose :
@ -423,13 +496,10 @@ void PrimitiveGUI_DiskDlg::ActivateThisDialog()
{ {
GEOMBase_Skeleton::ActivateThisDialog(); GEOMBase_Skeleton::ActivateThisDialog();
connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), // reinit, because some selected objects could be removed
this, SLOT( SelectionIntoArgument() ) ); Init();
ConstructorsClicked( getConstructorId() );
} }
//================================================================================= //=================================================================================
// function : enterEvent() // function : enterEvent()
// purpose : // purpose :
@ -440,16 +510,6 @@ void PrimitiveGUI_DiskDlg::enterEvent( QEvent* )
ActivateThisDialog(); ActivateThisDialog();
} }
//=================================================================================
// function : DeactivateActiveDialog()
// purpose : public slot to deactivate if active
//=================================================================================
void PrimitiveGUI_DiskDlg::DeactivateActiveDialog()
{
// myGeomGUI->SetState( -1 );
GEOMBase_Skeleton::DeactivateActiveDialog();
}
//================================================================================= //=================================================================================
// function : ValueChangedInSpinBox() // function : ValueChangedInSpinBox()
// purpose : // purpose :
@ -459,29 +519,13 @@ void PrimitiveGUI_DiskDlg::ValueChangedInSpinBox()
displayPreview(); displayPreview();
} }
//=================================================================================
// function : getRadius()
// purpose :
//=================================================================================
double PrimitiveGUI_DiskDlg::getRadius() const
{
double r = 0.;
switch ( getConstructorId() ) {
case 0:
r = GroupDimensions->SpinBox_DX->value(); break;
case 1:
r = GroupPntVecR->SpinBox_DX->value(); break;
}
return r;
}
//================================================================================= //=================================================================================
// function : createOperation // function : createOperation
// purpose : // purpose :
//================================================================================= //=================================================================================
GEOM::GEOM_IOperations_ptr PrimitiveGUI_DiskDlg::createOperation() GEOM::GEOM_IOperations_ptr PrimitiveGUI_DiskDlg::createOperation()
{ {
return myGeomGUI->GetGeomGen()->GetI3DPrimOperations( getStudyId() ); return getGeomEngine()->GetI3DPrimOperations(getStudyId());
} }
//================================================================================= //=================================================================================
@ -497,7 +541,7 @@ static bool isEqual( const GEOM::GEOM_Object_var& thePnt1, const GEOM::GEOM_Obje
// function : isValid // function : isValid
// purpose : // purpose :
//================================================================================= //=================================================================================
bool PrimitiveGUI_DiskDlg::isValid( QString& msg ) bool PrimitiveGUI_DiskDlg::isValid (QString&)
{ {
const int id = getConstructorId(); const int id = getConstructorId();
if (id == 0) if (id == 0)
@ -522,28 +566,44 @@ bool PrimitiveGUI_DiskDlg::execute( ObjectList& objects )
switch (getConstructorId()) { switch (getConstructorId()) {
case 0: case 0:
anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeDiskR( getRadius(), myOrientationType ); anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())->
MakeDiskR(getRadius(), myOrientationType);
res = true; res = true;
break; break;
case 1: case 1:
anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeDiskPntVecR( myPoint, myDir, getRadius() ); anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())->
MakeDiskPntVecR(myPoint, myDir, getRadius());
res = true; res = true;
break; break;
case 2: case 2:
anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeDiskThreePnt( myPoint1, myPoint2, myPoint3 ); anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())->
MakeDiskThreePnt(myPoint1, myPoint2, myPoint3);
res = true; res = true;
break; break;
} }
if (!anObj->_is_nil()) if (!anObj->_is_nil())
objects.push_back(anObj._retn()); objects.push_back(anObj._retn());
else {
MESSAGE( "Execute Object is NULL!" );
}
return res; return res;
} }
//=================================================================================
// function : getRadius()
// purpose :
//=================================================================================
double PrimitiveGUI_DiskDlg::getRadius() const
{
double r = 0.;
switch (getConstructorId()) {
case 0:
r = GroupDimensions->SpinBox_DX->value(); break;
case 1:
r = GroupPntVecR->SpinBox_DX->value(); break;
}
return r;
}
//================================================================================= //=================================================================================
// function : addSubshapeToStudy // function : addSubshapeToStudy
// purpose : virtual method to add new SubObjects if local selection // purpose : virtual method to add new SubObjects if local selection

View File

@ -62,6 +62,9 @@ private:
private: private:
GEOM::GEOM_Object_var myPoint, myDir, myPoint1, myPoint2, myPoint3; GEOM::GEOM_Object_var myPoint, myDir, myPoint1, myPoint2, myPoint3;
// to initialize the first selection field with a selected object on the dialog creation
bool myInitial;
DlgRef_2Sel1Spin* GroupPntVecR; DlgRef_2Sel1Spin* GroupPntVecR;
DlgRef_3Sel* Group3Pnts; DlgRef_3Sel* Group3Pnts;
DlgRef_1Spin* GroupDimensions; DlgRef_1Spin* GroupDimensions;
@ -72,7 +75,6 @@ private slots:
bool ClickOnApply(); bool ClickOnApply();
void ActivateThisDialog(); void ActivateThisDialog();
void DeactivateActiveDialog();
void SelectionIntoArgument(); void SelectionIntoArgument();

View File

@ -268,6 +268,7 @@ bool PrimitiveGUI_FaceDlg::ClickOnApply()
//================================================================================= //=================================================================================
void PrimitiveGUI_FaceDlg::ConstructorsClicked( int constructorId ) void PrimitiveGUI_FaceDlg::ConstructorsClicked( int constructorId )
{ {
erasePreview();
switch ( constructorId ) { switch ( constructorId ) {
case 0: case 0:
{ {
@ -302,7 +303,7 @@ void PrimitiveGUI_FaceDlg::ConstructorsClicked( int constructorId )
updateGeometry(); updateGeometry();
resize( minimumSize() ); resize( minimumSize() );
SelectionIntoArgument(); SelectionIntoArgument();
displayPreview(); //displayPreview();
} }
//================================================================================= //=================================================================================
@ -480,14 +481,18 @@ bool PrimitiveGUI_FaceDlg::execute( ObjectList& objects )
GEOM::GEOM_Object_var anObj; GEOM::GEOM_Object_var anObj;
switch (getConstructorId()) { switch (getConstructorId()) {
case 0: case 0:
anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeFaceHW( GroupDimensions->SpinBox_DX->value(), GroupDimensions->SpinBox_DY->value(), myOrientationType ); anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())->
MakeFaceHW(GroupDimensions->SpinBox_DX->value(),
GroupDimensions->SpinBox_DY->value(), myOrientationType);
res = true; res = true;
break; break;
case 1: case 1:
if (GroupType->RadioButton1->isChecked()) if (GroupType->RadioButton1->isChecked())
anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeFaceObjHW( myEdge, GroupPlane->SpinBox_DX->value(), GroupPlane->SpinBox_DY->value() ); anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())->
MakeFaceObjHW(myEdge, GroupPlane->SpinBox_DX->value(), GroupPlane->SpinBox_DY->value());
else if (GroupType->RadioButton2->isChecked()) else if (GroupType->RadioButton2->isChecked())
anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeFaceObjHW( myFace, GroupPlane->SpinBox_DX->value(), GroupPlane->SpinBox_DY->value() ); anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())->
MakeFaceObjHW(myFace, GroupPlane->SpinBox_DX->value(), GroupPlane->SpinBox_DY->value());
res = true; res = true;
break; break;
} }

View File

@ -56,9 +56,6 @@ private:
void enterEvent( QEvent* ); void enterEvent( QEvent* );
private: private:
GEOM::GEOM_Object_var myPoint1;
GEOM::GEOM_Object_var myPoint2;
GEOM::GEOM_Object_var myVector;
GEOM::GEOM_Object_var myEdge; GEOM::GEOM_Object_var myEdge;
GEOM::GEOM_Object_var myFace; GEOM::GEOM_Object_var myFace;

View File

@ -29,11 +29,12 @@
#include <GeometryGUI.h> #include <GeometryGUI.h>
#include <GEOMBase.h> #include <GEOMBase.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h> #include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h>
#include <SalomeApp_Application.h> #include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h> #include <LightApp_SelectionMgr.h>
// OCCT Includes
#include <TopoDS_Shape.hxx> #include <TopoDS_Shape.hxx>
#include <TopoDS_Edge.hxx> #include <TopoDS_Edge.hxx>
#include <TopoDS.hxx> #include <TopoDS.hxx>
@ -52,7 +53,8 @@
//================================================================================= //=================================================================================
PrimitiveGUI_TorusDlg::PrimitiveGUI_TorusDlg (GeometryGUI* theGeometryGUI, QWidget* parent, PrimitiveGUI_TorusDlg::PrimitiveGUI_TorusDlg (GeometryGUI* theGeometryGUI, QWidget* parent,
bool modal, Qt::WindowFlags fl) bool modal, Qt::WindowFlags fl)
: GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl ) : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl),
myInitial(true)
{ {
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_TORUS_PV"))); QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_TORUS_PV")));
@ -93,7 +95,6 @@ PrimitiveGUI_TorusDlg::PrimitiveGUI_TorusDlg( GeometryGUI* theGeometryGUI, QWidg
Init(); Init();
} }
//================================================================================= //=================================================================================
// function : ~PrimitiveGUI_TorusDlg() // function : ~PrimitiveGUI_TorusDlg()
// purpose : Destroys the object and frees any allocated resources // purpose : Destroys the object and frees any allocated resources
@ -103,36 +104,37 @@ PrimitiveGUI_TorusDlg::~PrimitiveGUI_TorusDlg()
// no need to delete child widgets, Qt does it all for us // no need to delete child widgets, Qt does it all for us
} }
//================================================================================= //=================================================================================
// function : Init() // function : Init()
// purpose : // purpose :
//================================================================================= //=================================================================================
void PrimitiveGUI_TorusDlg::Init() void PrimitiveGUI_TorusDlg::Init()
{ {
/* init variables */ // Get setting of step value from file configuration
myEditCurrentArgument = GroupPoints->LineEdit1;
GroupPoints->LineEdit1->setReadOnly( true );
GroupPoints->LineEdit2->setReadOnly( true );
myPoint = myDir = GEOM::GEOM_Object::_nil();
/* Get setting of step value from file configuration */
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100); double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100);
/* min, max, step and decimals for spin boxes & initial values */ // min, max, step and decimals for spin boxes & initial values
initSpinBox(GroupPoints->SpinBox_DX, 0.001, COORD_MAX, step, 3); // VSR: TODO: DBL_DIGITS_DISPLAY initSpinBox(GroupPoints->SpinBox_DX, 0.001, COORD_MAX, step, 3); // VSR: TODO: DBL_DIGITS_DISPLAY
initSpinBox(GroupPoints->SpinBox_DY, 0.001, COORD_MAX, step, 3); // VSR: TODO: DBL_DIGITS_DISPLAY initSpinBox(GroupPoints->SpinBox_DY, 0.001, COORD_MAX, step, 3); // VSR: TODO: DBL_DIGITS_DISPLAY
initSpinBox(GroupDimensions->SpinBox_DX, 0.001, COORD_MAX, step, 3); // VSR: TODO: DBL_DIGITS_DISPLAY initSpinBox(GroupDimensions->SpinBox_DX, 0.001, COORD_MAX, step, 3); // VSR: TODO: DBL_DIGITS_DISPLAY
initSpinBox(GroupDimensions->SpinBox_DY, 0.001, COORD_MAX, step, 3); // VSR: TODO: DBL_DIGITS_DISPLAY initSpinBox(GroupDimensions->SpinBox_DY, 0.001, COORD_MAX, step, 3); // VSR: TODO: DBL_DIGITS_DISPLAY
// init variables
myEditCurrentArgument = GroupPoints->LineEdit1;
GroupPoints->LineEdit1->setReadOnly(true);
GroupPoints->LineEdit2->setReadOnly(true);
GroupPoints->LineEdit1->setText("");
GroupPoints->LineEdit2->setText("");
myPoint = myDir = GEOM::GEOM_Object::_nil();
GroupPoints->SpinBox_DX->setValue(300.0); GroupPoints->SpinBox_DX->setValue(300.0);
GroupPoints->SpinBox_DY->setValue(100.0); GroupPoints->SpinBox_DY->setValue(100.0);
GroupDimensions->SpinBox_DX->setValue(300.0); GroupDimensions->SpinBox_DX->setValue(300.0);
GroupDimensions->SpinBox_DY->setValue(100.0); GroupDimensions->SpinBox_DY->setValue(100.0);
/* 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()));
@ -151,9 +153,6 @@ void PrimitiveGUI_TorusDlg::Init()
connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double))); connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double)));
connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
this, SLOT( SelectionIntoArgument() ) );
initName(tr("GEOM_TORUS")); initName(tr("GEOM_TORUS"));
setConstructorId(1); // simplest constructor setConstructorId(1); // simplest constructor
@ -172,7 +171,6 @@ void PrimitiveGUI_TorusDlg::SetDoubleSpinBoxStep( double step )
GroupDimensions->SpinBox_DY->setSingleStep(step); GroupDimensions->SpinBox_DY->setSingleStep(step);
} }
//================================================================================= //=================================================================================
// function : ConstructorsClicked() // function : ConstructorsClicked()
// purpose : Radio button management // purpose : Radio button management
@ -184,28 +182,18 @@ void PrimitiveGUI_TorusDlg::ConstructorsClicked( int constructorId )
switch (constructorId) { switch (constructorId) {
case 0: case 0:
{ {
globalSelection(); // close local contexts, if any
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
GroupDimensions->hide(); GroupDimensions->hide();
GroupPoints->show(); GroupPoints->show();
myEditCurrentArgument = GroupPoints->LineEdit1; GroupPoints->PushButton1->click();
GroupPoints->LineEdit1->setText( "" );
GroupPoints->LineEdit2->setText( "" );
myPoint = myDir = GEOM::GEOM_Object::_nil();
connect( myGeomGUI->getApp()->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
SelectionIntoArgument();
break; break;
} }
case 1: case 1:
{ {
GroupPoints->hide(); GroupPoints->hide();
GroupDimensions->show(); GroupDimensions->show();
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
globalSelection(); // close local contexts, if any globalSelection(); // close local contexts, if any
break; break;
} }
} }
@ -214,9 +202,20 @@ void PrimitiveGUI_TorusDlg::ConstructorsClicked( int constructorId )
updateGeometry(); updateGeometry();
resize(minimumSize()); resize(minimumSize());
if (myInitial) {
myInitial = false;
if (constructorId == 0) {
// on dialog initialization we init the first field with a selected object (if any)
SelectionIntoArgument();
}
else {
displayPreview(); displayPreview();
} }
}
else {
displayPreview();
}
}
//================================================================================= //=================================================================================
// function : ClickOnOk() // function : ClickOnOk()
@ -228,7 +227,6 @@ void PrimitiveGUI_TorusDlg::ClickOnOk()
ClickOnCancel(); ClickOnCancel();
} }
//================================================================================= //=================================================================================
// function : ClickOnApply() // function : ClickOnApply()
// purpose : // purpose :
@ -239,20 +237,21 @@ bool PrimitiveGUI_TorusDlg::ClickOnApply()
return false; return false;
initName(); initName();
// activate selection and connect selection manager
ConstructorsClicked(getConstructorId());
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
//================================================================================= //=================================================================================
void PrimitiveGUI_TorusDlg::SelectionIntoArgument() void PrimitiveGUI_TorusDlg::SelectionIntoArgument()
{ {
if (getConstructorId() != 0) if (getConstructorId() != 0)
return; return;
erasePreview();
myEditCurrentArgument->setText(""); myEditCurrentArgument->setText("");
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
@ -267,17 +266,19 @@ void PrimitiveGUI_TorusDlg::SelectionIntoArgument()
return; return;
} }
/* nbSel == 1 */ // nbSel == 1
Standard_Boolean testResult = Standard_False; Standard_Boolean testResult = Standard_False;
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult); GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult);
if (!testResult || CORBA::is_nil(aSelectedObject)) if (!testResult || CORBA::is_nil(aSelectedObject))
return; return;
QString aName = GEOMBase::GetName(aSelectedObject); QString aName = GEOMBase::GetName(aSelectedObject);
// Get Selected object if selected subshape
TopoDS_Shape aShape; TopoDS_Shape aShape;
if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) { if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull())
{
TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX; TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
if (myEditCurrentArgument == GroupPoints->LineEdit2) if (myEditCurrentArgument == GroupPoints->LineEdit2)
aNeedType = TopAbs_EDGE; aNeedType = TopAbs_EDGE;
@ -299,9 +300,10 @@ void PrimitiveGUI_TorusDlg::SelectionIntoArgument()
getGeomEngine()->GetIShapesOperations(getStudyId()); getGeomEngine()->GetIShapesOperations(getStudyId());
aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
} }
else else {
aSelectedObject = aFindedObject; // get Object from study aSelectedObject = aFindedObject; // get Object from study
} }
}
else { // Global Selection else { // Global Selection
if (aShape.ShapeType() != aNeedType) { if (aShape.ShapeType() != aNeedType) {
aSelectedObject = GEOM::GEOM_Object::_nil(); aSelectedObject = GEOM::GEOM_Object::_nil();
@ -312,15 +314,26 @@ void PrimitiveGUI_TorusDlg::SelectionIntoArgument()
myEditCurrentArgument->setText(aName); myEditCurrentArgument->setText(aName);
if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) // clear selection
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
myGeomGUI->getApp()->selectionMgr()->clearSelected();
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
if (myEditCurrentArgument == GroupPoints->LineEdit1) {
myPoint = aSelectedObject; myPoint = aSelectedObject;
else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) if (!myPoint->_is_nil() && myDir->_is_nil())
GroupPoints->PushButton2->click();
}
else if (myEditCurrentArgument == GroupPoints->LineEdit2) {
myDir = aSelectedObject; myDir = aSelectedObject;
if (!myDir->_is_nil() && myPoint->_is_nil())
GroupPoints->PushButton1->click();
}
displayPreview(); displayPreview();
} }
//================================================================================= //=================================================================================
// function : SetEditCurrentArgument() // function : SetEditCurrentArgument()
// purpose : // purpose :
@ -328,22 +341,38 @@ void PrimitiveGUI_TorusDlg::SelectionIntoArgument()
void PrimitiveGUI_TorusDlg::SetEditCurrentArgument() void PrimitiveGUI_TorusDlg::SetEditCurrentArgument()
{ {
QPushButton* send = (QPushButton*)sender(); QPushButton* send = (QPushButton*)sender();
globalSelection( GEOM_POINT ); // to break previous local selection
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
if (send == GroupPoints->PushButton1) { if (send == GroupPoints->PushButton1) {
myEditCurrentArgument = GroupPoints->LineEdit1; myEditCurrentArgument = GroupPoints->LineEdit1;
GroupPoints->PushButton2->setDown(false);
GroupPoints->LineEdit2->setEnabled(false);
globalSelection(GEOM_POINT); // to break previous local selection
localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
} }
else if (send == GroupPoints->PushButton2) { else if (send == GroupPoints->PushButton2) {
myEditCurrentArgument = GroupPoints->LineEdit2; myEditCurrentArgument = GroupPoints->LineEdit2;
GEOM::GEOM_Object_var anObj;
localSelection( anObj, TopAbs_EDGE );
}
GroupPoints->PushButton1->setDown(false);
GroupPoints->LineEdit1->setEnabled(false);
globalSelection(GEOM_LINE); // to break previous local selection
localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE);
}
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
// enable line edit
myEditCurrentArgument->setEnabled(true);
myEditCurrentArgument->setFocus(); myEditCurrentArgument->setFocus();
SelectionIntoArgument(); // after setFocus(), because it will be setDown(false) then loses focus
} send->setDown(true);
// seems we need it only to avoid preview disappearing, caused by selection mode change
displayPreview();
}
//================================================================================= //=================================================================================
// function : LineEditReturnPressed() // function : LineEditReturnPressed()
@ -359,7 +388,6 @@ void PrimitiveGUI_TorusDlg::LineEditReturnPressed()
} }
} }
//================================================================================= //=================================================================================
// function : ActivateThisDialog() // function : ActivateThisDialog()
// purpose : // purpose :
@ -367,13 +395,11 @@ void PrimitiveGUI_TorusDlg::LineEditReturnPressed()
void PrimitiveGUI_TorusDlg::ActivateThisDialog() void PrimitiveGUI_TorusDlg::ActivateThisDialog()
{ {
GEOMBase_Skeleton::ActivateThisDialog(); GEOMBase_Skeleton::ActivateThisDialog();
connect( myGeomGUI->getApp()->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
ConstructorsClicked( getConstructorId() ); // reinit, because some selected objects could be removed
Init();
} }
//================================================================================= //=================================================================================
// function : enterEvent() // function : enterEvent()
// purpose : // purpose :
@ -384,9 +410,8 @@ void PrimitiveGUI_TorusDlg::enterEvent( QEvent* )
ActivateThisDialog(); ActivateThisDialog();
} }
//================================================================================= //=================================================================================
// function : ValueChangedInSpinBox // function : ValueChangedInSpinBox()
// purpose : // purpose :
//================================================================================= //=================================================================================
void PrimitiveGUI_TorusDlg::ValueChangedInSpinBox() void PrimitiveGUI_TorusDlg::ValueChangedInSpinBox()
@ -394,7 +419,6 @@ void PrimitiveGUI_TorusDlg::ValueChangedInSpinBox()
displayPreview(); displayPreview();
} }
//================================================================================= //=================================================================================
// function : createOperation // function : createOperation
// purpose : // purpose :
@ -404,17 +428,15 @@ GEOM::GEOM_IOperations_ptr PrimitiveGUI_TorusDlg::createOperation()
return getGeomEngine()->GetI3DPrimOperations(getStudyId()); return getGeomEngine()->GetI3DPrimOperations(getStudyId());
} }
//================================================================================= //=================================================================================
// function : isValid // function : isValid
// purpose : // purpose :
//================================================================================= //=================================================================================
bool PrimitiveGUI_TorusDlg::isValid( QString& msg ) bool PrimitiveGUI_TorusDlg::isValid (QString&)
{ {
return getConstructorId() == 0 ? !(myPoint->_is_nil() || myDir->_is_nil()) : true; return getConstructorId() == 0 ? !(myPoint->_is_nil() || myDir->_is_nil()) : true;
} }
//================================================================================= //=================================================================================
// function : execute // function : execute
// purpose : // purpose :
@ -428,12 +450,14 @@ bool PrimitiveGUI_TorusDlg::execute( ObjectList& objects )
switch (getConstructorId()) { switch (getConstructorId()) {
case 0: case 0:
if (!CORBA::is_nil(myPoint) && !CORBA::is_nil(myDir)) { if (!CORBA::is_nil(myPoint) && !CORBA::is_nil(myDir)) {
anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeTorusPntVecRR( myPoint, myDir, getRadius1(), getRadius2() ); anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())->
MakeTorusPntVecRR(myPoint, myDir, getRadius1(), getRadius2());
res = true; res = true;
} }
break; break;
case 1: case 1:
anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeTorusRR( getRadius1(), getRadius2() ); anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())->
MakeTorusRR(getRadius1(), getRadius2());
res = true; res = true;
break; break;
} }
@ -444,7 +468,6 @@ bool PrimitiveGUI_TorusDlg::execute( ObjectList& objects )
return res; return res;
} }
//================================================================================= //=================================================================================
// function : getRadius1() // function : getRadius1()
// purpose : // purpose :
@ -459,7 +482,6 @@ double PrimitiveGUI_TorusDlg::getRadius1() const
return 0; return 0;
} }
//================================================================================= //=================================================================================
// function : getRadius2() // function : getRadius2()
// purpose : // purpose :

View File

@ -56,8 +56,12 @@ private:
double getRadius1() const; double getRadius1() const;
double getRadius2() const; double getRadius2() const;
private:
GEOM::GEOM_Object_var myPoint, myDir; GEOM::GEOM_Object_var myPoint, myDir;
// to initialize the first selection field with a selected object on the dialog creation
bool myInitial;
DlgRef_2Sel2Spin* GroupPoints; DlgRef_2Sel2Spin* GroupPoints;
DlgRef_2Spin* GroupDimensions; DlgRef_2Spin* GroupDimensions;