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());
aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
}
else
else {
aSelectedObject = aFindedObject; // get Object from study
}
}
else // Global Selection
{
if (aShape.ShapeType() != TopAbs_FACE) {
@ -372,9 +373,6 @@ void BlocksGUI_BlockDlg::SetEditCurrentArgument()
break;
}
// enable push button
aSender->setDown(true);
// set line edit as current argument
if (aSender == Group2F->PushButton1) {
myEditCurrentArgument = Group2F->LineEdit1;
@ -401,9 +399,11 @@ void BlocksGUI_BlockDlg::SetEditCurrentArgument()
myEditCurrentArgument = Group6F->LineEdit6;
}
// enable line edit
// enable push button and line edit
myEditCurrentArgument->setEnabled(true);
myEditCurrentArgument->setFocus();
// after setFocus(), because it will be setDown(false) then loses focus
aSender->setDown(true);
globalSelection(); // close local contexts, if any
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
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
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
//=================================================================================
void BlocksGUI_BlockDlg::addSubshapesToStudy()

View File

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

View File

@ -359,9 +359,6 @@ void BlocksGUI_TrsfDlg::SetEditCurrentArgument()
break;
}
// enable push button
aSender->setDown(true);
// set line edit as current argument
QMap<int, QPushButton*>::iterator anIter;
for (anIter = mySelBtn.begin(); anIter != mySelBtn.end(); ++anIter) {
@ -375,6 +372,10 @@ void BlocksGUI_TrsfDlg::SetEditCurrentArgument()
myEditCurrentArgument->setEnabled(true);
myEditCurrentArgument->setFocus();
// enable push button
// after setFocus(), because it will be setDown(false) then loses focus
aSender->setDown(true);
activateSelection();
}

View File

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

View File

@ -29,11 +29,12 @@
#include <GeometryGUI.h>
#include <GEOMBase.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h>
#include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h>
// OCCT Includes
#include <TopoDS_Shape.hxx>
#include <TopoDS.hxx>
#include <TopExp.hxx>
@ -41,7 +42,7 @@
#include <TopTools_IndexedMapOfShape.hxx>
#include <GEOMImpl_Types.hxx>
#include <ostream>
//#include <ostream>
//=================================================================================
// class : PrimitiveGUI_BoxDlg()
@ -52,7 +53,8 @@
//=================================================================================
PrimitiveGUI_BoxDlg::PrimitiveGUI_BoxDlg (GeometryGUI* theGeometryGUI, QWidget* parent,
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 image1 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_BOX_DXYZ")));
@ -91,7 +93,6 @@ PrimitiveGUI_BoxDlg::PrimitiveGUI_BoxDlg( GeometryGUI* theGeometryGUI, QWidget*
Init();
}
//=================================================================================
// function : ~DialogBox_Box()
// 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
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void PrimitiveGUI_BoxDlg::Init()
{
/* init variables */
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 */
// 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 */
// 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_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
// 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;
GroupDimensions->SpinBox_DX->setValue(initValue);
GroupDimensions->SpinBox_DY->setValue(initValue);
GroupDimensions->SpinBox_DZ->setValue(initValue);
/* signals and slots connections */
// signals and slots connections
connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
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->getApp()->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
initName(tr("GEOM_BOX"));
setConstructorId(1); // simplest constructor
@ -167,39 +165,29 @@ void PrimitiveGUI_BoxDlg::SetDoubleSpinBoxStep( double step )
GroupDimensions->SpinBox_DZ->setSingleStep(step);
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void PrimitiveGUI_BoxDlg::ConstructorsClicked (int constructorId)
{
disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 );
switch (constructorId) {
case 0:
{
//globalSelection( GEOM_POINT );
globalSelection(); // close local contexts, if any
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
GroupDimensions->hide();
GroupPoints->show();
myEditCurrentArgument = GroupPoints->LineEdit1;
GroupPoints->LineEdit1->setText( "" );
GroupPoints->LineEdit2->setText( "" );
myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil();
connect( myGeomGUI->getApp()->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
GroupPoints->PushButton1->click();
break;
}
case 1:
{
GroupPoints->hide();
GroupDimensions->show();
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
globalSelection(); // close local contexts, if any
displayPreview();
break;
}
}
@ -208,9 +196,15 @@ void PrimitiveGUI_BoxDlg::ConstructorsClicked( int constructorId )
updateGeometry();
resize(minimumSize());
if (myInitial) {
// on dialog initialization we init the first field with a selected object (if any)
SelectionIntoArgument();
myInitial = false;
}
else {
displayPreview();
}
}
//=================================================================================
// function : ClickOnOk()
@ -222,7 +216,6 @@ void PrimitiveGUI_BoxDlg::ClickOnOk()
ClickOnCancel();
}
//=================================================================================
// function : ClickOnApply()
// purpose :
@ -233,20 +226,21 @@ bool PrimitiveGUI_BoxDlg::ClickOnApply()
return false;
initName();
// activate selection and connect selection manager
ConstructorsClicked(getConstructorId());
return true;
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection as changed
// purpose : Called when selection is changed or on dialog initialization or activation
//=================================================================================
void PrimitiveGUI_BoxDlg::SelectionIntoArgument()
{
if (getConstructorId() != 0)
return;
erasePreview();
myEditCurrentArgument->setText("");
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
@ -254,10 +248,8 @@ void PrimitiveGUI_BoxDlg::SelectionIntoArgument()
aSelMgr->selectedObjects(aSelList);
if (aSelList.Extent() != 1) {
if ( myEditCurrentArgument == GroupPoints->LineEdit1 )
myPoint1 = GEOM::GEOM_Object::_nil();
else if ( myEditCurrentArgument == GroupPoints->LineEdit2 )
myPoint2 = GEOM::GEOM_Object::_nil();
if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint1 = GEOM::GEOM_Object::_nil();
else if (myEditCurrentArgument == GroupPoints->LineEdit2) myPoint2 = GEOM::GEOM_Object::_nil();
return;
}
@ -268,12 +260,16 @@ void PrimitiveGUI_BoxDlg::SelectionIntoArgument()
if (!testResult || CORBA::is_nil(aSelectedObject))
return;
TopoDS_Shape aShape;
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;
aSelMgr->GetIndexes(aSelList.First(), aMap);
if ( aMap.Extent() == 1) { // Local Selection
if (aMap.Extent() == 1) // Local Selection
{
int anIndex = aMap(1);
aName.append(":vertex_" + QString::number(anIndex));
@ -289,7 +285,8 @@ void PrimitiveGUI_BoxDlg::SelectionIntoArgument()
aSelectedObject = aFindedObject; // get Object from study
}
}
else { // Global Selection
else // Global Selection
{
if (aShape.ShapeType() != TopAbs_VERTEX) {
aSelectedObject = GEOM::GEOM_Object::_nil();
aName = "";
@ -299,15 +296,26 @@ void PrimitiveGUI_BoxDlg::SelectionIntoArgument()
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;
else if ( myEditCurrentArgument == GroupPoints->LineEdit2 )
if (!myPoint1->_is_nil() && myPoint2->_is_nil())
GroupPoints->PushButton2->click();
}
else if (myEditCurrentArgument == GroupPoints->LineEdit2) {
myPoint2 = aSelectedObject;
if (!myPoint2->_is_nil() && myPoint1->_is_nil())
GroupPoints->PushButton1->click();
}
displayPreview();
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
@ -316,19 +324,40 @@ void PrimitiveGUI_BoxDlg::SetEditCurrentArgument()
{
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;
else if ( send == GroupPoints->PushButton2 )
GroupPoints->PushButton2->setDown(false);
GroupPoints->LineEdit2->setEnabled(false);
}
else if (send == GroupPoints->PushButton2) {
myEditCurrentArgument = GroupPoints->LineEdit2;
// globalSelection( GEOM_POINT );
globalSelection(); // close local contexts, if any
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
myEditCurrentArgument->setFocus();
SelectionIntoArgument();
GroupPoints->PushButton1->setDown(false);
GroupPoints->LineEdit1->setEnabled(false);
}
// 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()
@ -343,7 +372,6 @@ void PrimitiveGUI_BoxDlg::LineEditReturnPressed()
}
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
@ -351,13 +379,17 @@ void PrimitiveGUI_BoxDlg::LineEditReturnPressed()
void PrimitiveGUI_BoxDlg::ActivateThisDialog()
{
GEOMBase_Skeleton::ActivateThisDialog();
connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
this, SLOT( SelectionIntoArgument() ) );
//if (getConstructorId() == 0) {
// 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]
// purpose :
@ -368,7 +400,6 @@ void PrimitiveGUI_BoxDlg::enterEvent( QEvent* )
ActivateThisDialog();
}
//=================================================================================
// function : ValueChangedInSpinBox()
// purpose :
@ -378,7 +409,6 @@ void PrimitiveGUI_BoxDlg::ValueChangedInSpinBox()
displayPreview();
}
//=================================================================================
// function : createOperation
// purpose :
@ -388,17 +418,15 @@ GEOM::GEOM_IOperations_ptr PrimitiveGUI_BoxDlg::createOperation()
return getGeomEngine()->GetI3DPrimOperations(getStudyId());
}
//=================================================================================
// function : isValid
// purpose :
//=================================================================================
bool PrimitiveGUI_BoxDlg::isValid( QString& msg )
bool PrimitiveGUI_BoxDlg::isValid (QString&)
{
return getConstructorId() == 0 ? !(myPoint1->_is_nil() || myPoint2->_is_nil()) : true;
}
//=================================================================================
// function : execute
// purpose :
@ -416,9 +444,8 @@ bool PrimitiveGUI_BoxDlg::execute( ObjectList& objects )
anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())->MakeBoxTwoPnt(myPoint1, myPoint2);
res = true;
}
break;
}
break;
case 1:
{
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);
res = true;
break;
}
break;
}
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
//=================================================================================
void PrimitiveGUI_BoxDlg::addSubshapesToStudy()
{
QMap<QString, GEOM::GEOM_Object_var> objMap;
if (getConstructorId() == 0) {
QMap<QString, GEOM::GEOM_Object_var> objMap;
objMap[GroupPoints->LineEdit1->text()] = myPoint1;
objMap[GroupPoints->LineEdit2->text()] = myPoint2;
addSubshapesToFather(objMap);

View File

@ -57,6 +57,9 @@ private:
private:
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_3Spin* GroupDimensions;

View File

@ -29,11 +29,12 @@
#include <GeometryGUI.h>
#include <GEOMBase.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h>
#include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h>
// OCCT Includes
#include <TopoDS_Shape.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS.hxx>
@ -52,7 +53,8 @@
//=================================================================================
PrimitiveGUI_ConeDlg::PrimitiveGUI_ConeDlg (GeometryGUI* theGeometryGUI, QWidget* parent,
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 image1 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_CONE_DXYZ")));
@ -94,7 +96,6 @@ PrimitiveGUI_ConeDlg::PrimitiveGUI_ConeDlg( GeometryGUI* theGeometryGUI, QWidget
Init();
}
//=================================================================================
// function : ~PrimitiveGUI_ConeDlg()
// 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
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void PrimitiveGUI_ConeDlg::Init()
{
/* init variables */
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 */
// 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 */
// 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_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
@ -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_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);
GroupPoints->SpinBox_DX->setValue(aRadius1);
GroupPoints->SpinBox_DY->setValue(aRadius2);
@ -138,7 +139,7 @@ void PrimitiveGUI_ConeDlg::Init()
GroupDimensions->SpinBox_DY->setValue(aRadius2);
GroupDimensions->SpinBox_DZ->setValue(aHeight);
/* signals and slots connections */
// signals and slots connections
connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
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->getApp()->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
initName(tr("GEOM_CONE"));
setConstructorId(1); // simplest constructor
ConstructorsClicked(1);
}
//=================================================================================
// function : SetDoubleSpinBoxStep()
// purpose : Double spin box management
@ -189,34 +186,23 @@ void PrimitiveGUI_ConeDlg::SetDoubleSpinBoxStep( double step )
//=================================================================================
void PrimitiveGUI_ConeDlg::ConstructorsClicked (int constructorId)
{
disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 );
switch (constructorId) {
case 0:
{
//globalSelection( GEOM_POINT );
globalSelection(); // to break prvious local selection
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
GroupDimensions->hide();
GroupPoints->show();
myEditCurrentArgument = GroupPoints->LineEdit1;
GroupPoints->LineEdit1->setText( "" );
GroupPoints->LineEdit2->setText( "" );
myPoint = myDir = GEOM::GEOM_Object::_nil();
connect( myGeomGUI->getApp()->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
GroupPoints->PushButton1->click();
break;
}
case 1:
{
globalSelection(); // close local contexts, if any
GroupPoints->hide();
GroupDimensions->show();
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
globalSelection(); // close local contexts, if any
displayPreview();
break;
}
}
@ -225,9 +211,15 @@ void PrimitiveGUI_ConeDlg::ConstructorsClicked( int constructorId )
updateGeometry();
resize(minimumSize());
if (myInitial) {
// on dialog initialization we init the first field with a selected object (if any)
SelectionIntoArgument();
myInitial = false;
}
else {
displayPreview();
}
}
//=================================================================================
// function : ClickOnOk()
@ -239,7 +231,6 @@ void PrimitiveGUI_ConeDlg::ClickOnOk()
ClickOnCancel();
}
//=================================================================================
// function : ClickOnApply()
// purpose :
@ -250,49 +241,54 @@ bool PrimitiveGUI_ConeDlg::ClickOnApply()
return false;
initName();
// activate selection and connect selection manager
ConstructorsClicked(getConstructorId());
return true;
}
//=================================================================================
// 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()
{
if (getConstructorId() != 0)
return;
erasePreview();
myEditCurrentArgument->setText("");
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList);
if (aSelList.Extent() != 1) {
if (myEditCurrentArgument == GroupPoints->LineEdit1)
myPoint = GEOM::GEOM_Object::_nil();
else if (myEditCurrentArgument == GroupPoints->LineEdit2)
myDir = GEOM::GEOM_Object::_nil();
if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint = GEOM::GEOM_Object::_nil();
else if (myEditCurrentArgument == GroupPoints->LineEdit2) myDir = GEOM::GEOM_Object::_nil();
return;
}
/* nbSel == 1 */
// nbSel == 1
Standard_Boolean testResult = Standard_False;
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult);
if (!testResult || CORBA::is_nil(aSelectedObject))
return;
TopoDS_Shape aShape;
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;
if (myEditCurrentArgument == GroupPoints->LineEdit2)
aNeedType = TopAbs_EDGE;
TColStd_IndexedMapOfInteger aMap;
aSelMgr->GetIndexes(aSelList.First(), aMap);
if ( aMap.Extent() == 1 ) {
if (aMap.Extent() == 1) // Local Selection
{
int anIndex = aMap(1);
if (aNeedType == TopAbs_EDGE)
aName.append(":edge_" + QString::number(anIndex));
@ -311,7 +307,8 @@ void PrimitiveGUI_ConeDlg::SelectionIntoArgument()
aSelectedObject = aFindedObject; // get Object from study
}
}
else {
else // Global Selection
{
if (aShape.ShapeType() != aNeedType) {
aSelectedObject = GEOM::GEOM_Object::_nil();
aName = "";
@ -321,10 +318,22 @@ void PrimitiveGUI_ConeDlg::SelectionIntoArgument()
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;
else if ( myEditCurrentArgument == GroupPoints->LineEdit2 )
if (!myPoint->_is_nil() && myDir->_is_nil())
GroupPoints->PushButton2->click();
}
else if (myEditCurrentArgument == GroupPoints->LineEdit2) {
myDir = aSelectedObject;
if (!myDir->_is_nil() && myPoint->_is_nil())
GroupPoints->PushButton1->click();
}
displayPreview();
}
@ -337,22 +346,35 @@ void PrimitiveGUI_ConeDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
if (send == GroupPoints->PushButton1) {
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);
}
else if (send == GroupPoints->PushButton2) {
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);
}
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
// enable line edit
myEditCurrentArgument->setEnabled(true);
myEditCurrentArgument->setFocus();
SelectionIntoArgument();
// after setFocus(), because it will be setDown(false) then loses focus
send->setDown(true);
}
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
@ -367,7 +389,6 @@ void PrimitiveGUI_ConeDlg::LineEditReturnPressed()
}
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
@ -375,23 +396,11 @@ void PrimitiveGUI_ConeDlg::LineEditReturnPressed()
void PrimitiveGUI_ConeDlg::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()
// purpose :
@ -402,7 +411,6 @@ void PrimitiveGUI_ConeDlg::enterEvent( QEvent* )
ActivateThisDialog();
}
//=================================================================================
// function : ValueChangedInSpinBox()
// purpose :
@ -412,7 +420,6 @@ void PrimitiveGUI_ConeDlg::ValueChangedInSpinBox()
displayPreview();
}
//=================================================================================
// function : createOperation
// purpose :
@ -426,7 +433,7 @@ GEOM::GEOM_IOperations_ptr PrimitiveGUI_ConeDlg::createOperation()
// function : isValid
// purpose :
//=================================================================================
bool PrimitiveGUI_ConeDlg::isValid( QString& msg )
bool PrimitiveGUI_ConeDlg::isValid (QString&)
{
return getConstructorId() == 0 ? !(myPoint->_is_nil() || myDir->_is_nil()) : true;
}
@ -444,18 +451,14 @@ bool PrimitiveGUI_ConeDlg::execute( ObjectList& objects )
switch (getConstructorId()) {
case 0:
if (!CORBA::is_nil(myPoint) && !CORBA::is_nil(myDir)) {
anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeConePntVecR1R2H( myPoint,
myDir,
getRadius1(),
getRadius2(),
getHeight() );
anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())->
MakeConePntVecR1R2H(myPoint, myDir, getRadius1(), getRadius2(), getHeight());
res = true;
}
break;
case 1:
anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeConeR1R2H( getRadius1(),
getRadius2(),
getHeight() );
anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())->
MakeConeR1R2H(getRadius1(), getRadius2(), getHeight());
res = true;
break;
}
@ -466,7 +469,6 @@ bool PrimitiveGUI_ConeDlg::execute( ObjectList& objects )
return res;
}
//=================================================================================
// function : getRadius1()
// purpose :
@ -481,7 +483,6 @@ double PrimitiveGUI_ConeDlg::getRadius1() const
return 0;
}
//=================================================================================
// function : getRadius2()
// purpose :
@ -496,9 +497,8 @@ double PrimitiveGUI_ConeDlg::getRadius2() const
return 0;
}
//=================================================================================
// function : getRadius2()
// function : getHeight()
// purpose :
//=================================================================================
double PrimitiveGUI_ConeDlg::getHeight() const

View File

@ -60,6 +60,9 @@ private:
private:
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_3Spin* GroupDimensions;
@ -67,7 +70,6 @@ private slots:
void ClickOnOk();
bool ClickOnApply();
void ActivateThisDialog();
void DeactivateActiveDialog();
void LineEditReturnPressed();
void SelectionIntoArgument();
void SetEditCurrentArgument();

View File

@ -26,15 +26,15 @@
#include "PrimitiveGUI_CylinderDlg.h"
#include <DlgRef.h>
#include <GeometryGUI.h>
#include <GEOMBase.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h>
#include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h>
// OCCT Includes
#include <TopoDS_Shape.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS.hxx>
@ -53,7 +53,8 @@
//=================================================================================
PrimitiveGUI_CylinderDlg::PrimitiveGUI_CylinderDlg (GeometryGUI* theGeometryGUI, QWidget* parent,
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 image1 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_CYLINDER_DXYZ")));
@ -93,7 +94,6 @@ PrimitiveGUI_CylinderDlg::PrimitiveGUI_CylinderDlg( GeometryGUI* theGeometryGUI,
Init();
}
//=================================================================================
// function : ~PrimitiveGUI_CylinderDlg()
// 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
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
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;
GroupPoints->LineEdit1->setReadOnly(true);
GroupPoints->LineEdit2->setReadOnly(true);
GroupPoints->LineEdit1->setText("");
GroupPoints->LineEdit2->setText("");
myPoint = myDir = GEOM::GEOM_Object::_nil();
/* Get setting of step value from file configuration */
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100 );
double aRadius(100.0), aHeight(300.0);
GroupPoints->SpinBox_DX->setValue(aRadius);
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 */
/* 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 */
// signals and slots connections
connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
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->getApp()->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
initName(tr("GEOM_CYLINDER"));
setConstructorId(1); // simplest constructor
ConstructorsClicked(1);
}
//=================================================================================
// function : SetDoubleSpinBoxStep()
// purpose : Double spin box management
@ -177,7 +171,6 @@ void PrimitiveGUI_CylinderDlg::SetDoubleSpinBoxStep( double step )
GroupDimensions->SpinBox_DY->setSingleStep(step);
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
@ -189,27 +182,18 @@ void PrimitiveGUI_CylinderDlg::ConstructorsClicked( int constructorId )
switch (constructorId) {
case 0:
{
globalSelection( GEOM_POINT ); // to break previous local selection
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
GroupDimensions->hide();
GroupPoints->show();
myEditCurrentArgument = GroupPoints->LineEdit1;
GroupPoints->LineEdit1->setText( "" );
GroupPoints->LineEdit2->setText( "" );
myPoint = myDir = GEOM::GEOM_Object::_nil();
connect( myGeomGUI->getApp()->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
GroupPoints->PushButton1->click();
break;
}
case 1:
{
globalSelection(); // close local contexts, if any
GroupPoints->hide();
GroupDimensions->show();
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
globalSelection(); // close local contexts, if any
break;
}
}
@ -218,9 +202,20 @@ void PrimitiveGUI_CylinderDlg::ConstructorsClicked( int constructorId )
updateGeometry();
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();
}
}
else {
displayPreview();
}
}
//=================================================================================
// function : ClickOnOk()
@ -232,7 +227,6 @@ void PrimitiveGUI_CylinderDlg::ClickOnOk()
ClickOnCancel();
}
//=================================================================================
// function : ClickOnApply()
// purpose :
@ -243,20 +237,21 @@ bool PrimitiveGUI_CylinderDlg::ClickOnApply()
return false;
initName();
// activate selection and connect selection manager
ConstructorsClicked(getConstructorId());
return true;
}
//=================================================================================
// 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()
{
if (getConstructorId() != 0)
return;
erasePreview();
myEditCurrentArgument->setText("");
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
@ -271,7 +266,7 @@ void PrimitiveGUI_CylinderDlg::SelectionIntoArgument()
return;
}
/* nbSel == 1 */
// nbSel == 1
Standard_Boolean testResult = Standard_False;
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult);
@ -279,8 +274,11 @@ void PrimitiveGUI_CylinderDlg::SelectionIntoArgument()
return;
QString aName = GEOMBase::GetName(aSelectedObject);
// Get Selected object if selected subshape
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;
if (myEditCurrentArgument == GroupPoints->LineEdit2)
aNeedType = TopAbs_EDGE;
@ -316,15 +314,26 @@ void PrimitiveGUI_CylinderDlg::SelectionIntoArgument()
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;
else if ( myEditCurrentArgument == GroupPoints->LineEdit2 )
if (!myPoint->_is_nil() && myDir->_is_nil())
GroupPoints->PushButton2->click();
}
else if (myEditCurrentArgument == GroupPoints->LineEdit2) {
myDir = aSelectedObject;
if (!myDir->_is_nil() && myPoint->_is_nil())
GroupPoints->PushButton1->click();
}
displayPreview();
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
@ -333,22 +342,35 @@ void PrimitiveGUI_CylinderDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
if (send == GroupPoints->PushButton1) {
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);
}
else if (send == GroupPoints->PushButton2) {
myEditCurrentArgument = GroupPoints->LineEdit2;
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();
SelectionIntoArgument();
// after setFocus(), because it will be setDown(false) then loses focus
send->setDown(true);
}
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
@ -363,7 +385,6 @@ void PrimitiveGUI_CylinderDlg::LineEditReturnPressed()
}
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
@ -371,13 +392,11 @@ void PrimitiveGUI_CylinderDlg::LineEditReturnPressed()
void PrimitiveGUI_CylinderDlg::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()
// purpose :
@ -388,19 +407,8 @@ void PrimitiveGUI_CylinderDlg::enterEvent( QEvent* )
ActivateThisDialog();
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose : public slot to deactivate if active
//=================================================================================
void PrimitiveGUI_CylinderDlg::DeactivateActiveDialog()
{
GEOMBase_Skeleton::DeactivateActiveDialog();
}
//=================================================================================
// function : ValueChangedInSpinBox
// function : ValueChangedInSpinBox()
// purpose :
//=================================================================================
void PrimitiveGUI_CylinderDlg::ValueChangedInSpinBox()
@ -408,7 +416,6 @@ void PrimitiveGUI_CylinderDlg::ValueChangedInSpinBox( )
displayPreview();
}
//=================================================================================
// function : createOperation
// purpose :
@ -418,12 +425,11 @@ GEOM::GEOM_IOperations_ptr PrimitiveGUI_CylinderDlg::createOperation()
return getGeomEngine()->GetI3DPrimOperations(getStudyId());
}
//=================================================================================
// function : isValid
// purpose :
//=================================================================================
bool PrimitiveGUI_CylinderDlg::isValid( QString& msg )
bool PrimitiveGUI_CylinderDlg::isValid (QString&)
{
return getConstructorId() == 0 ? !(myPoint->_is_nil() || myDir->_is_nil()) : true;
}
@ -441,14 +447,15 @@ bool PrimitiveGUI_CylinderDlg::execute( ObjectList& objects )
switch (getConstructorId()) {
case 0:
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;
}
break;
case 1:
anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeCylinderRH( getRadius(), getHeight() );
anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())->
MakeCylinderRH(getRadius(), getHeight());
res = true;
break;
}
@ -458,7 +465,6 @@ bool PrimitiveGUI_CylinderDlg::execute( ObjectList& objects )
return res;
}
//=================================================================================
// function : getRadius()
// purpose :
@ -473,7 +479,6 @@ double PrimitiveGUI_CylinderDlg::getRadius() const
return 0;
}
//=================================================================================
// function : getHeight()
// purpose :

View File

@ -59,6 +59,9 @@ private:
private:
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_2Spin* GroupDimensions;
@ -66,7 +69,6 @@ private slots:
void ClickOnOk();
bool ClickOnApply();
void ActivateThisDialog();
void DeactivateActiveDialog();
void LineEditReturnPressed();
void SelectionIntoArgument();
void SetEditCurrentArgument();

View File

@ -26,21 +26,21 @@
#include "PrimitiveGUI_DiskDlg.h"
#include <DlgRef.h>
#include <GeometryGUI.h>
#include <GEOMBase.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h>
#include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h>
#include <TColStd_IndexedMapOfInteger.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
// OCCT Includes
#include <TopoDS_Shape.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS.hxx>
#include <TopExp.hxx>
#include <TColStd_IndexedMapOfInteger.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
//=================================================================================
// class : PrimitiveGUI_DiskDlg()
@ -51,12 +51,14 @@
//=================================================================================
PrimitiveGUI_DiskDlg::PrimitiveGUI_DiskDlg (GeometryGUI* theGeometryGUI, QWidget* parent,
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" ) ) );
QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_DISK_THREE_POINTS" ) ) );
QPixmap image3( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_DISK_R" ) ) );
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_DISK_PNT_VEC_R")));
QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
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"));
@ -111,7 +113,6 @@ PrimitiveGUI_DiskDlg::PrimitiveGUI_DiskDlg( GeometryGUI* theGeometryGUI, QWidget
Init();
}
//=================================================================================
// function : ~PrimitiveGUI_DiskDlg()
// purpose : Destroys the object and frees any allocated resources
@ -120,33 +121,36 @@ PrimitiveGUI_DiskDlg::~PrimitiveGUI_DiskDlg()
{
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void PrimitiveGUI_DiskDlg::Init()
{
/* init variables */
myEditCurrentArgument = GroupPntVecR->LineEdit1;
myOrientationType = 1;
myPoint = myDir = myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil();
/* Get setting of step value from file configuration */
// Get setting of step value from file configuration
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
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
GroupPntVecR->SpinBox_DX->setValue( 100 );
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);
/* signals and slots connections */
connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) );
// signals and slots connections
connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
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->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(GroupPntVecR->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(GroupPntVecR->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(Group3Pnts->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(Group3Pnts->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(Group3Pnts->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(Group3Pnts->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(Group3Pnts->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(Group3Pnts->LineEdit3, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
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(GroupOrientation->RadioButton1, SIGNAL(clicked()), this, SLOT(RadioButtonClicked()));
connect(GroupOrientation->RadioButton2, SIGNAL(clicked()), this, SLOT(RadioButtonClicked()));
connect(GroupOrientation->RadioButton3, SIGNAL(clicked()), this, SLOT(RadioButtonClicked()));
connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
this, SLOT( SelectionIntoArgument() ) );
connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double)));
connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
initName(tr("GEOM_DISK"));
@ -186,6 +191,7 @@ void PrimitiveGUI_DiskDlg::Init()
//=================================================================================
void PrimitiveGUI_DiskDlg::SetDoubleSpinBoxStep (double step)
{
GroupDimensions->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);
myPoint = myDir = myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil();
switch (constructorId) {
case 0:
{
@ -221,31 +225,29 @@ void PrimitiveGUI_DiskDlg::ConstructorsClicked( int constructorId )
Group3Pnts->hide();
GroupDimensions->show();
GroupOrientation->show();
GroupOrientation->RadioButton1->setChecked( true );
myOrientationType = 1;
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
globalSelection(); // close local contexts, if any
break;
}
case 1:
{
Group3Pnts->hide();
GroupPntVecR->show();
GroupDimensions->hide();
GroupOrientation->hide();
myEditCurrentArgument = GroupPntVecR->LineEdit1;
GroupPntVecR->LineEdit1->setText( "" );
GroupPntVecR->LineEdit2->setText( "" );
GroupPntVecR->show();
Group3Pnts->hide();
GroupPntVecR->PushButton1->click();
break;
}
case 2:
{
GroupPntVecR->hide();
Group3Pnts->show();
GroupDimensions->hide();
GroupOrientation->hide();
myEditCurrentArgument = Group3Pnts->LineEdit1;
Group3Pnts->LineEdit1->setText( "" );
Group3Pnts->LineEdit2->setText( "" );
Group3Pnts->LineEdit3->setText( "" );
GroupPntVecR->hide();
Group3Pnts->show();
Group3Pnts->PushButton1->click();
break;
}
}
@ -254,14 +256,20 @@ void PrimitiveGUI_DiskDlg::ConstructorsClicked( int constructorId )
updateGeometry();
resize(minimumSize());
myEditCurrentArgument->setFocus();
globalSelection(); // close local contexts, if any
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged() ),
this, SLOT( SelectionIntoArgument() ) );
if (myInitial) {
myInitial = false;
if (constructorId == 1 || constructorId == 2) {
// on dialog initialization we init the first field with a selected object (if any)
SelectionIntoArgument();
}
else {
displayPreview();
}
}
else {
displayPreview();
}
}
//=================================================================================
// function : ClickOnOk()
@ -283,28 +291,28 @@ bool PrimitiveGUI_DiskDlg::ClickOnApply()
return false;
initName();
// activate selection and connect selection manager
ConstructorsClicked(getConstructorId());
return true;
}
//=================================================================================
// 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()
{
if (getConstructorId() == 0) {
displayPreview();
if (getConstructorId() == 0)
return;
}
erasePreview();
myEditCurrentArgument->setText("");
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
SALOME_ListIO aList;
aSelMgr->selectedObjects( aList );
SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList);
if ( aList.Extent() != 1 ) {
if (aSelList.Extent() != 1) {
if (myEditCurrentArgument == GroupPntVecR->LineEdit1) myPoint = GEOM::GEOM_Object::_nil();
else if (myEditCurrentArgument == GroupPntVecR->LineEdit2) myDir = GEOM::GEOM_Object::_nil();
else if (myEditCurrentArgument == Group3Pnts->LineEdit1) myPoint1 = GEOM::GEOM_Object::_nil();
@ -314,16 +322,19 @@ void PrimitiveGUI_DiskDlg::SelectionIntoArgument()
}
// 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);
// If selected Vertex or Edge on the some Shape Get selection Subshape
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;
if (myEditCurrentArgument == GroupPntVecR->LineEdit2)
aNeedType = TopAbs_EDGE;
@ -358,17 +369,41 @@ void PrimitiveGUI_DiskDlg::SelectionIntoArgument()
myEditCurrentArgument->setText(aName);
if ( myEditCurrentArgument == GroupPntVecR->LineEdit1 ) myPoint = aSelectedObject;
else if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) myDir = aSelectedObject;
else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) myPoint1 = aSelectedObject;
else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) myPoint2 = aSelectedObject;
else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) myPoint3 = aSelectedObject;
// clear selection
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
myGeomGUI->getApp()->selectionMgr()->clearSelected();
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
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();
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
@ -377,14 +412,44 @@ void PrimitiveGUI_DiskDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
if ( send == GroupPntVecR->PushButton1 ) myEditCurrentArgument = GroupPntVecR->LineEdit1;
else if ( send == GroupPntVecR->PushButton2 ) myEditCurrentArgument = GroupPntVecR->LineEdit2;
else if ( send == Group3Pnts->PushButton1 ) myEditCurrentArgument = Group3Pnts->LineEdit1;
else if ( send == Group3Pnts->PushButton2 ) myEditCurrentArgument = Group3Pnts->LineEdit2;
else if ( send == Group3Pnts->PushButton3 ) myEditCurrentArgument = Group3Pnts->LineEdit3;
if (send == GroupPntVecR->PushButton1) {
myEditCurrentArgument = GroupPntVecR->LineEdit1;
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) {
globalSelection(); // close local contexts, if any
localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE);
@ -393,8 +458,17 @@ void PrimitiveGUI_DiskDlg::SetEditCurrentArgument()
globalSelection(); // close local contexts, if any
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()
// purpose :
@ -423,13 +496,10 @@ void PrimitiveGUI_DiskDlg::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()
// purpose :
@ -440,16 +510,6 @@ void PrimitiveGUI_DiskDlg::enterEvent( QEvent* )
ActivateThisDialog();
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose : public slot to deactivate if active
//=================================================================================
void PrimitiveGUI_DiskDlg::DeactivateActiveDialog()
{
// myGeomGUI->SetState( -1 );
GEOMBase_Skeleton::DeactivateActiveDialog();
}
//=================================================================================
// function : ValueChangedInSpinBox()
// purpose :
@ -459,29 +519,13 @@ void PrimitiveGUI_DiskDlg::ValueChangedInSpinBox()
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
// purpose :
//=================================================================================
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
// purpose :
//=================================================================================
bool PrimitiveGUI_DiskDlg::isValid( QString& msg )
bool PrimitiveGUI_DiskDlg::isValid (QString&)
{
const int id = getConstructorId();
if (id == 0)
@ -522,28 +566,44 @@ bool PrimitiveGUI_DiskDlg::execute( ObjectList& objects )
switch (getConstructorId()) {
case 0:
anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeDiskR( getRadius(), myOrientationType );
anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())->
MakeDiskR(getRadius(), myOrientationType);
res = true;
break;
case 1:
anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeDiskPntVecR( myPoint, myDir, getRadius() );
anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())->
MakeDiskPntVecR(myPoint, myDir, getRadius());
res = true;
break;
case 2:
anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeDiskThreePnt( myPoint1, myPoint2, myPoint3 );
anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())->
MakeDiskThreePnt(myPoint1, myPoint2, myPoint3);
res = true;
break;
}
if (!anObj->_is_nil())
objects.push_back(anObj._retn());
else {
MESSAGE( "Execute Object is NULL!" );
}
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
// purpose : virtual method to add new SubObjects if local selection

View File

@ -62,6 +62,9 @@ private:
private:
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_3Sel* Group3Pnts;
DlgRef_1Spin* GroupDimensions;
@ -72,7 +75,6 @@ private slots:
bool ClickOnApply();
void ActivateThisDialog();
void DeactivateActiveDialog();
void SelectionIntoArgument();

View File

@ -268,6 +268,7 @@ bool PrimitiveGUI_FaceDlg::ClickOnApply()
//=================================================================================
void PrimitiveGUI_FaceDlg::ConstructorsClicked( int constructorId )
{
erasePreview();
switch ( constructorId ) {
case 0:
{
@ -302,7 +303,7 @@ void PrimitiveGUI_FaceDlg::ConstructorsClicked( int constructorId )
updateGeometry();
resize( minimumSize() );
SelectionIntoArgument();
displayPreview();
//displayPreview();
}
//=================================================================================
@ -480,14 +481,18 @@ bool PrimitiveGUI_FaceDlg::execute( ObjectList& objects )
GEOM::GEOM_Object_var anObj;
switch (getConstructorId()) {
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;
break;
case 1:
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())
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;
break;
}

View File

@ -56,9 +56,6 @@ private:
void enterEvent( QEvent* );
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 myFace;

View File

@ -29,11 +29,12 @@
#include <GeometryGUI.h>
#include <GEOMBase.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h>
#include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h>
// OCCT Includes
#include <TopoDS_Shape.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS.hxx>
@ -52,7 +53,8 @@
//=================================================================================
PrimitiveGUI_TorusDlg::PrimitiveGUI_TorusDlg (GeometryGUI* theGeometryGUI, QWidget* parent,
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();
QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_TORUS_PV")));
@ -93,7 +95,6 @@ PrimitiveGUI_TorusDlg::PrimitiveGUI_TorusDlg( GeometryGUI* theGeometryGUI, QWidg
Init();
}
//=================================================================================
// function : ~PrimitiveGUI_TorusDlg()
// 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
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void PrimitiveGUI_TorusDlg::Init()
{
/* init variables */
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 */
// 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 */
// 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, 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
// 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_DY->setValue(100.0);
GroupDimensions->SpinBox_DX->setValue(300.0);
GroupDimensions->SpinBox_DY->setValue(100.0);
/* signals and slots connections */
// signals and slots connections
connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
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->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
this, SLOT( SelectionIntoArgument() ) );
initName(tr("GEOM_TORUS"));
setConstructorId(1); // simplest constructor
@ -172,7 +171,6 @@ void PrimitiveGUI_TorusDlg::SetDoubleSpinBoxStep( double step )
GroupDimensions->SpinBox_DY->setSingleStep(step);
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
@ -184,28 +182,18 @@ void PrimitiveGUI_TorusDlg::ConstructorsClicked( int constructorId )
switch (constructorId) {
case 0:
{
globalSelection(); // close local contexts, if any
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
GroupDimensions->hide();
GroupPoints->show();
myEditCurrentArgument = GroupPoints->LineEdit1;
GroupPoints->LineEdit1->setText( "" );
GroupPoints->LineEdit2->setText( "" );
myPoint = myDir = GEOM::GEOM_Object::_nil();
connect( myGeomGUI->getApp()->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
SelectionIntoArgument();
GroupPoints->PushButton1->click();
break;
}
case 1:
{
GroupPoints->hide();
GroupDimensions->show();
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
globalSelection(); // close local contexts, if any
break;
}
}
@ -214,9 +202,20 @@ void PrimitiveGUI_TorusDlg::ConstructorsClicked( int constructorId )
updateGeometry();
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();
}
}
else {
displayPreview();
}
}
//=================================================================================
// function : ClickOnOk()
@ -228,7 +227,6 @@ void PrimitiveGUI_TorusDlg::ClickOnOk()
ClickOnCancel();
}
//=================================================================================
// function : ClickOnApply()
// purpose :
@ -239,20 +237,21 @@ bool PrimitiveGUI_TorusDlg::ClickOnApply()
return false;
initName();
// activate selection and connect selection manager
ConstructorsClicked(getConstructorId());
return true;
}
//=================================================================================
// 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()
{
if (getConstructorId() != 0)
return;
erasePreview();
myEditCurrentArgument->setText("");
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
@ -267,17 +266,19 @@ void PrimitiveGUI_TorusDlg::SelectionIntoArgument()
return;
}
/* nbSel == 1 */
// nbSel == 1
Standard_Boolean testResult = Standard_False;
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult);
if (!testResult || CORBA::is_nil(aSelectedObject))
return;
QString aName = GEOMBase::GetName(aSelectedObject);
// Get Selected object if selected subshape
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;
if (myEditCurrentArgument == GroupPoints->LineEdit2)
aNeedType = TopAbs_EDGE;
@ -299,9 +300,10 @@ void PrimitiveGUI_TorusDlg::SelectionIntoArgument()
getGeomEngine()->GetIShapesOperations(getStudyId());
aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
}
else
else {
aSelectedObject = aFindedObject; // get Object from study
}
}
else { // Global Selection
if (aShape.ShapeType() != aNeedType) {
aSelectedObject = GEOM::GEOM_Object::_nil();
@ -312,15 +314,26 @@ void PrimitiveGUI_TorusDlg::SelectionIntoArgument()
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;
else if ( myEditCurrentArgument == GroupPoints->LineEdit2 )
if (!myPoint->_is_nil() && myDir->_is_nil())
GroupPoints->PushButton2->click();
}
else if (myEditCurrentArgument == GroupPoints->LineEdit2) {
myDir = aSelectedObject;
if (!myDir->_is_nil() && myPoint->_is_nil())
GroupPoints->PushButton1->click();
}
displayPreview();
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
@ -328,22 +341,38 @@ void PrimitiveGUI_TorusDlg::SelectionIntoArgument()
void PrimitiveGUI_TorusDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
globalSelection( GEOM_POINT ); // to break previous local selection
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
if (send == GroupPoints->PushButton1) {
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);
}
else if (send == GroupPoints->PushButton2) {
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();
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()
@ -359,7 +388,6 @@ void PrimitiveGUI_TorusDlg::LineEditReturnPressed()
}
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
@ -367,13 +395,11 @@ void PrimitiveGUI_TorusDlg::LineEditReturnPressed()
void PrimitiveGUI_TorusDlg::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()
// purpose :
@ -384,9 +410,8 @@ void PrimitiveGUI_TorusDlg::enterEvent( QEvent* )
ActivateThisDialog();
}
//=================================================================================
// function : ValueChangedInSpinBox
// function : ValueChangedInSpinBox()
// purpose :
//=================================================================================
void PrimitiveGUI_TorusDlg::ValueChangedInSpinBox()
@ -394,7 +419,6 @@ void PrimitiveGUI_TorusDlg::ValueChangedInSpinBox()
displayPreview();
}
//=================================================================================
// function : createOperation
// purpose :
@ -404,17 +428,15 @@ GEOM::GEOM_IOperations_ptr PrimitiveGUI_TorusDlg::createOperation()
return getGeomEngine()->GetI3DPrimOperations(getStudyId());
}
//=================================================================================
// function : isValid
// purpose :
//=================================================================================
bool PrimitiveGUI_TorusDlg::isValid( QString& msg )
bool PrimitiveGUI_TorusDlg::isValid (QString&)
{
return getConstructorId() == 0 ? !(myPoint->_is_nil() || myDir->_is_nil()) : true;
}
//=================================================================================
// function : execute
// purpose :
@ -428,12 +450,14 @@ bool PrimitiveGUI_TorusDlg::execute( ObjectList& objects )
switch (getConstructorId()) {
case 0:
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;
}
break;
case 1:
anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeTorusRR( getRadius1(), getRadius2() );
anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())->
MakeTorusRR(getRadius1(), getRadius2());
res = true;
break;
}
@ -444,7 +468,6 @@ bool PrimitiveGUI_TorusDlg::execute( ObjectList& objects )
return res;
}
//=================================================================================
// function : getRadius1()
// purpose :
@ -459,7 +482,6 @@ double PrimitiveGUI_TorusDlg::getRadius1() const
return 0;
}
//=================================================================================
// function : getRadius2()
// purpose :

View File

@ -56,8 +56,12 @@ private:
double getRadius1() const;
double getRadius2() const;
private:
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_2Spin* GroupDimensions;