#include <GEOMImpl_Types.hxx>
#include <QApplication>
+#include <QButtonGroup>
+#include <QHBoxLayout>
#include <QLabel>
+#include <QRadioButton>
#include <gp_Pnt.hxx>
#include <TopoDS_Shape.hxx>
#include <TColStd_IndexedMapOfInteger.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
+#define PARAM_VALUE 0
+#define COORD_VALUE 1
+
+#define GEOM_POINT_XYZ 0
+#define GEOM_POINT_REF 1
+#define GEOM_POINT_EDGE 2
+#define GEOM_POINT_INTINT 3
+#define GEOM_POINT_SURF 4
+
+
//=================================================================================
// class : BasicGUI_PointDlg()
// purpose : Constructs a BasicGUI_PointDlg which is a child of 'parent', with the
mainFrame()->RadioButton5->show();
mainFrame()->RadioButton5->setIcon( image5 );
+ QGroupBox* paramGrp = new QGroupBox( centralWidget() );
+ myParamCoord = new QButtonGroup( paramGrp );
+ QHBoxLayout* boxLayout = new QHBoxLayout( paramGrp );
+ boxLayout->setMargin( 0 ); boxLayout->setSpacing( 6 );
+ QRadioButton* btn = new QRadioButton( tr( "GEOM_PARAM_VALUE" ), paramGrp );
+ myParamCoord->addButton( btn, PARAM_VALUE );
+ boxLayout->addWidget( btn );
+ btn = new QRadioButton( tr( "GEOM_COORD_VALUE" ), paramGrp );
+ myParamCoord->addButton( btn, COORD_VALUE );
+ boxLayout->addWidget( btn );
+ myParamCoord->setExclusive( true );
+ myParamCoord->button( PARAM_VALUE )->setChecked( true );
+
GroupXYZ = new DlgRef_3Spin( centralWidget() );
GroupXYZ->GroupBox1->setTitle( tr( "GEOM_COORDINATES" ) );
GroupXYZ->TextLabel1->setText( tr( "GEOM_X" ) );
GroupXYZ->TextLabel3->setText( tr( "GEOM_Z" ) );
GroupOnCurve = new DlgRef_1Sel1Spin( centralWidget() );
- GroupOnCurve->GroupBox1->setTitle( tr( "GEOM_PARAM_POINT" ) );
+ GroupOnCurve->GroupBox1->setTitle( tr( "GEOM_POINT_ON_EDGE" ) );
GroupOnCurve->TextLabel1->setText( tr( "GEOM_EDGE" ) );
GroupOnCurve->TextLabel2->setText( tr( "GEOM_PARAMETER" ) );
GroupOnCurve->PushButton1->setIcon( image2 );
GroupOnSurface = new DlgRef_1Sel2Spin( centralWidget() );
- GroupOnSurface->GroupBox1->setTitle( tr( "GEOM_PARAM_POINT" ) );
+ GroupOnSurface->GroupBox1->setTitle( tr( "GEOM_POINT_ON_FACE" ) );
GroupOnSurface->TextLabel1->setText( tr( "GEOM_FACE" ) );
GroupOnSurface->TextLabel2->setText( tr( "GEOM_UPARAMETER" ) );
GroupOnSurface->TextLabel3->setText( tr( "GEOM_VPARAMETER" ) );
GroupLineIntersection->PushButton2->setIcon( image2 );
GroupLineIntersection->LineEdit2->setEnabled(false);
- myCoordGrp = new QGroupBox( tr( "GEOM_COORDINATES" ), centralWidget() );
+ myCoordGrp = new QGroupBox( tr( "GEOM_COORDINATES_RES" ), centralWidget() );
QGridLayout* myCoordGrpLayout = new QGridLayout( myCoordGrp );
myCoordGrpLayout->addWidget( new QLabel( tr( "GEOM_X" ), myCoordGrp ), 0, 0 );
myX = new QLineEdit( myCoordGrp );
QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
layout->setMargin( 0 ); layout->setSpacing( 6 );
+ layout->addWidget( paramGrp );
layout->addWidget( GroupXYZ );
layout->addWidget( GroupOnCurve );
layout->addWidget( GroupOnSurface );
connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
+
+ connect( myParamCoord->button( PARAM_VALUE ), SIGNAL( clicked() ), this, SLOT( ClickParamCoord() ) );
+ connect( myParamCoord->button( COORD_VALUE ), SIGNAL( clicked() ), this, SLOT( ClickParamCoord() ) );
connect( GroupOnCurve->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( GroupOnCurve->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
globalSelection(); // close local contexts, if any
switch ( constructorId ) {
- case 0:
+ case GEOM_POINT_XYZ:
{
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
myCoordGrp->hide();
+ myParamCoord->button( PARAM_VALUE )->hide();
+ myParamCoord->button( COORD_VALUE )->hide();
GroupXYZ->show();
break;
}
- case 1:
+ case GEOM_POINT_REF:
{
myEditCurrentArgument = GroupRefPoint->LineEdit1;
myEditCurrentArgument->setText( "" );
GroupRefPoint->PushButton1->setDown(true);
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
+ myParamCoord->button( PARAM_VALUE )->hide();
+ myParamCoord->button( COORD_VALUE )->hide();
GroupXYZ->hide();
GroupOnCurve->hide();
GroupLineIntersection->hide();
myCoordGrp->show();
break;
}
- case 2:
+ case GEOM_POINT_EDGE:
{
myEditCurrentArgument = GroupOnCurve->LineEdit1;
myEditCurrentArgument->setText( "" );
GroupOnCurve->PushButton1->setDown(true);
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
- GroupXYZ->hide();
GroupRefPoint->hide();
GroupLineIntersection->hide();
GroupOnSurface->hide();
+ myParamCoord->button( PARAM_VALUE )->show();
+ myParamCoord->button( COORD_VALUE )->show();
GroupOnCurve->show();
-
myCoordGrp->show();
+
+ updateParamCoord( false );
break;
}
- case 3:
+ case GEOM_POINT_INTINT:
{
myEditCurrentArgument = GroupLineIntersection->LineEdit1;
GroupLineIntersection->LineEdit1->setText( "" );
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
+ myParamCoord->button( PARAM_VALUE )->hide();
+ myParamCoord->button( COORD_VALUE )->hide();
GroupXYZ->hide();
GroupRefPoint->hide();
GroupOnCurve->hide();
GroupLineIntersection->show();
break;
}
- case 4:
+ case GEOM_POINT_SURF:
{
myEditCurrentArgument = GroupOnSurface->LineEdit1;
myEditCurrentArgument->setText( "" );
GroupOnSurface->PushButton1->setDown(true);
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE );
- GroupXYZ->hide();
GroupRefPoint->hide();
GroupOnCurve->hide();
GroupLineIntersection->hide();
+ myParamCoord->button( PARAM_VALUE )->show();
+ myParamCoord->button( COORD_VALUE )->show();
GroupOnSurface->show();
-
myCoordGrp->show();
+
+ updateParamCoord( false );
break;
}
}
{
const int id = getConstructorId();
- if ( ( id == 1 || id == 2 || id == 4 ) && myEditCurrentArgument != 0 )
+ if ( ( id == GEOM_POINT_REF || id == GEOM_POINT_EDGE || id == GEOM_POINT_SURF ) && myEditCurrentArgument != 0 )
{
myEditCurrentArgument->setText( "" );
myX->setText( "" );
TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
TopoDS_Shape aShape;
if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) {
- if ( id == 2 || id == 3 )
+ if ( id == GEOM_POINT_EDGE || id == GEOM_POINT_INTINT )
aNeedType = TopAbs_EDGE;
- else if ( id == 4 )
+ else if ( id == GEOM_POINT_SURF )
aNeedType = TopAbs_FACE;
TColStd_IndexedMapOfInteger aMap;
if ( aShape.ShapeType() != aNeedType ) {
aSelectedObject = GEOM::GEOM_Object::_nil();
aName = "";
- if ( id == 0 ) return;
+ if ( id == GEOM_POINT_XYZ ) return;
}
}
}
if ( aShape.IsNull() || aShape.ShapeType() != aNeedType)
return;
- if ( id == 0 ) {
+ if ( id == GEOM_POINT_XYZ ) {
gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );
GroupXYZ->SpinBox_DX->setValue( aPnt.X() );
GroupXYZ->SpinBox_DY->setValue( aPnt.Y() );
GroupXYZ->SpinBox_DZ->setValue( aPnt.Z() );
}
- else if ( id == 1 ) {
+ else if ( id == GEOM_POINT_REF ) {
myRefPoint = aSelectedObject;
GroupRefPoint->LineEdit1->setText( aName );
}
- else if ( id == 2 ) {
+ else if ( id == GEOM_POINT_EDGE ) {
myEdge = aSelectedObject;
GroupOnCurve->LineEdit1->setText( aName );
}
- else if ( id == 3 ) {
+ else if ( id == GEOM_POINT_INTINT ) {
myEditCurrentArgument->setText( aName );
globalSelection();
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
GroupLineIntersection->PushButton1->click();
}
}
- else if ( id == 4 )
+ else if ( id == GEOM_POINT_SURF )
{
myFace = aSelectedObject;
GroupOnSurface->LineEdit1->setText( aName );
void BasicGUI_PointDlg::ActivateThisDialog( )
{
GEOMBase_Skeleton::ActivateThisDialog();
- // myGeomGUI->SetState( 0 );
+
+ connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
+ this, SLOT( SelectionIntoArgument() ) );
+
ConstructorsClicked( getConstructorId() );
}
//=================================================================================
void BasicGUI_PointDlg::OnPointSelected( const gp_Pnt& thePnt )
{
- if ( getConstructorId() == 0 ) {
+ if ( getConstructorId() == GEOM_POINT_XYZ ) {
GroupXYZ->SpinBox_DX->setValue( thePnt.X() );
GroupXYZ->SpinBox_DY->setValue( thePnt.Y() );
GroupXYZ->SpinBox_DZ->setValue( thePnt.Z() );
bool BasicGUI_PointDlg::isValid( QString& msg )
{
const int id = getConstructorId();
- if ( id == 0 ) {
+ if ( id == GEOM_POINT_XYZ ) {
bool ok = true;
ok = GroupXYZ->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
ok = GroupXYZ->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
ok = GroupXYZ->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok;
return ok;
}
- else if ( id == 1 ) {
+ else if ( id == GEOM_POINT_REF ) {
bool ok = true;
ok = GroupRefPoint->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
ok = GroupRefPoint->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
return !myRefPoint->_is_nil() && ok;
}
- else if ( id == 2 ) {
- bool ok = GroupOnCurve->SpinBox_DX->isValid( msg, !IsPreview() );
+ else if ( id == GEOM_POINT_EDGE ) {
+ bool ok = true;
+ if ( myParamCoord->checkedId() == PARAM_VALUE )
+ ok = GroupOnCurve->SpinBox_DX->isValid( msg, !IsPreview() );
+ else {
+ ok = GroupXYZ->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
+ ok = GroupXYZ->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
+ ok = GroupXYZ->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok;
+ }
return !myEdge->_is_nil() && ok;
}
- else if ( id == 3 )
+ else if ( id == GEOM_POINT_INTINT )
return ( !myLine1->_is_nil() && !myLine2->_is_nil() );
- else if ( id == 4 ) {
+ else if ( id == GEOM_POINT_SURF ) {
bool ok = true;
- ok = GroupOnSurface->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
- ok = GroupOnSurface->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
+ if ( myParamCoord->checkedId() == PARAM_VALUE ) {
+ ok = GroupOnSurface->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
+ ok = GroupOnSurface->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
+ }
+ else {
+ ok = GroupXYZ->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
+ ok = GroupXYZ->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
+ ok = GroupXYZ->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok;
+ }
return !myFace->_is_nil() && ok;
}
GEOM::GEOM_Object_var anObj;
QStringList aParameters;
+ GEOM::GEOM_IBasicOperations_var anOper = GEOM::GEOM_IBasicOperations::_narrow( getOperation() );
+
switch ( getConstructorId() ) {
- case 0 :
+ case GEOM_POINT_XYZ :
{
double x = GroupXYZ->SpinBox_DX->value();
double y = GroupXYZ->SpinBox_DY->value();
aParameters << GroupXYZ->SpinBox_DY->text();
aParameters << GroupXYZ->SpinBox_DZ->text();
- anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->MakePointXYZ( x, y, z );
+ anObj = anOper->MakePointXYZ( x, y, z );
res = true;
break;
}
- case 1 :
+ case GEOM_POINT_REF :
{
double dx = GroupRefPoint->SpinBox_DX->value();
double dy = GroupRefPoint->SpinBox_DY->value();
aParameters << GroupRefPoint->SpinBox_DY->text();
aParameters << GroupRefPoint->SpinBox_DZ->text();
- anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->
- MakePointWithReference( myRefPoint, dx, dy, dz );
+ anObj = anOper->MakePointWithReference( myRefPoint, dx, dy, dz );
res = true;
break;
}
- case 2 :
- anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->
- MakePointOnCurve( myEdge, getParameter() );
- aParameters<<GroupOnCurve->SpinBox_DX->text();
- res = true;
- break;
- case 3 :
- anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->
- MakePointOnLinesIntersection( myLine1, myLine2 );
- res = true;
- break;
- case 4 :
- anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->
- MakePointOnSurface( myFace, getUParameter(), getVParameter() );
- aParameters<<GroupOnSurface->SpinBox_DX->text();
- aParameters<<GroupOnSurface->SpinBox_DY->text();
+ case GEOM_POINT_EDGE :
+ {
+ if ( myParamCoord->checkedId() == PARAM_VALUE ) {
+ anObj = anOper->MakePointOnCurve( myEdge, getParameter() );
+ aParameters<<GroupOnCurve->SpinBox_DX->text();
+ } else {
+ double x = GroupXYZ->SpinBox_DX->value();
+ double y = GroupXYZ->SpinBox_DY->value();
+ double z = GroupXYZ->SpinBox_DZ->value();
+
+ aParameters << GroupXYZ->SpinBox_DX->text();
+ aParameters << GroupXYZ->SpinBox_DY->text();
+ aParameters << GroupXYZ->SpinBox_DZ->text();
+
+ anObj = anOper->MakePointOnCurveByCoord( myEdge, x, y, z );
+ }
+ res = true;
+ break;
+ }
+ case GEOM_POINT_INTINT :
+ anOper->MakePointOnLinesIntersection( myLine1, myLine2 );
res = true;
break;
+ case GEOM_POINT_SURF :
+ {
+ if ( myParamCoord->checkedId() == PARAM_VALUE ) {
+ anObj = anOper->MakePointOnSurface( myFace, getUParameter(), getVParameter() );
+ aParameters<<GroupOnSurface->SpinBox_DX->text();
+ aParameters<<GroupOnSurface->SpinBox_DY->text();
+ } else {
+ double x = GroupXYZ->SpinBox_DX->value();
+ double y = GroupXYZ->SpinBox_DY->value();
+ double z = GroupXYZ->SpinBox_DZ->value();
+
+ aParameters << GroupXYZ->SpinBox_DX->text();
+ aParameters << GroupXYZ->SpinBox_DY->text();
+ aParameters << GroupXYZ->SpinBox_DZ->text();
+
+ anObj = anOper->MakePointOnSurfaceByCoord( myFace, x, y, z );
+ }
+ res = true;
+ break;
+ }
}
- if(!anObj->_is_nil() && !IsPreview() && (getConstructorId()==0 ||
- getConstructorId() == 1 ||
- getConstructorId() == 2 ||
- getConstructorId() == 4) ) {
- anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters));
+ const int id = getConstructorId();
+ if(!anObj->_is_nil() && !IsPreview() && (id == GEOM_POINT_XYZ ||
+ id == GEOM_POINT_REF ||
+ id == GEOM_POINT_EDGE ||
+ id == GEOM_POINT_SURF) ) {
+ anObj->SetParameters(aParameters.join(":").toLatin1().constData());
}
- if ( getConstructorId() == 1 || getConstructorId() == 2 ||
- getConstructorId() == 4 ) {
+ if ( id == GEOM_POINT_REF || id == GEOM_POINT_EDGE || id == GEOM_POINT_SURF ) {
TopoDS_Shape aShape;
if ( GEOMBase::GetShape( anObj, aShape ) && !aShape.IsNull() &&
aShape.ShapeType() == TopAbs_VERTEX ) {
QMap<QString, GEOM::GEOM_Object_var> objMap;
switch ( getConstructorId() ) {
- case 0:
+ case GEOM_POINT_XYZ:
break;
- case 1:
+ case GEOM_POINT_REF:
objMap[GroupRefPoint->LineEdit1->text()] = myRefPoint;
break;
- case 2:
+ case GEOM_POINT_EDGE:
objMap[GroupOnCurve->LineEdit1->text()] = myEdge;
break;
- case 3:
+ case GEOM_POINT_INTINT:
objMap[GroupLineIntersection->LineEdit1->text()] = myLine1;
objMap[GroupLineIntersection->LineEdit2->text()] = myLine2;
break;
- case 4:
+ case GEOM_POINT_SURF:
objMap[GroupOnSurface->LineEdit1->text()] = myFace;
break;
}
addSubshapesToFather( objMap );
}
+
+//=================================================================================
+// function : ClickParamCoord()
+// purpose :
+//=================================================================================
+void BasicGUI_PointDlg::ClickParamCoord()
+{
+ updateParamCoord( true );
+ displayPreview();
+}
+
+//=================================================================================
+// function : updateParamCoord
+// purpose :
+//=================================================================================
+void BasicGUI_PointDlg::updateParamCoord(bool theIsUpdate)
+{
+ bool isParam = myParamCoord->checkedId() == PARAM_VALUE;
+ GroupXYZ->setShown( !isParam );
+
+ const int id = getConstructorId();
+ if ( id == GEOM_POINT_EDGE ) {
+ GroupOnCurve->TextLabel2->setShown( isParam );
+ GroupOnCurve->SpinBox_DX->setShown( isParam );
+ }
+ else if ( id == GEOM_POINT_SURF ) {
+ GroupOnSurface->TextLabel2->setShown( isParam );
+ GroupOnSurface->TextLabel3->setShown( isParam );
+ GroupOnSurface->SpinBox_DX->setShown( isParam );
+ GroupOnSurface->SpinBox_DY->setShown( isParam );
+ }
+ if ( theIsUpdate ) {
+ qApp->processEvents();
+ updateGeometry();
+ resize( minimumSizeHint() );
+ }
+}