- Fixed a bug in MakeCurveParametric that the curve does not always reach the specified max parameter.
- Added a new idl method MakeCurvePrametricNew that takes a number of steps as input instead of a step value (to achieve the fix and a more usual interface)
- Wrapped the new idl method in python MakeCurveParametric with a flag theNewMethod = true
- Modified the associated dialog in order to use the new method and dump it
in double theParamStep,
in curve_type theCurveType);
+ /*!
+ * Creates a curve using the parametric definition of the basic points.
+ * \param thexExpr parametric equation of the coordinates X.
+ * \param theyExpr parametric equation of the coordinates Y.
+ * \param thezExpr parametric equation of the coordinates Z.
+ * \param theParamMin the minimal value of the parameter.
+ * \param theParamMax the maximum value of the parameter.
+ * \param theParamStep the number of steps of the parameter discretization.
+ * \param theCurveType the type of the curve.
+ * \return New GEOM_Object, containing the created curve.
+ */
+ GEOM_Object MakeCurveParametricNew(in string thexExpr,
+ in string theyExpr,
+ in string thezExpr,
+ in double theParamMin,
+ in double theParamMax,
+ in long theParamNbStep,
+ in curve_type theCurveType);
+
/*!
* Create a sketcher (wire or face), following the textual description,
* passed through \a theCommand argument. \n
/* min, max, step and decimals for spin boxes & initial values */
initSpinBox( myParams->myPMin, COORD_MIN, COORD_MAX, step, "length_precision" );
initSpinBox( myParams->myPMax, COORD_MIN, COORD_MAX, step, "length_precision" );
- initSpinBox( myParams->myPStep, COORD_MIN, COORD_MAX, step, "length_precision" );
+ myParams->myPStep->setValue( 10 );
+ myParams->myPStep->setMaximum( 999 );
+ myParams->myPStep->setSingleStep( 10 );
myParams->myPMin->setValue( aMin );
myParams->myPMax->setValue( aMax );
myParams->myPStep->setValue( step );
myParams->hide();
/* signals and slots connections */
- connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog( ) ) );
- connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) );
+ connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog( ) ) );
+ connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) );
- connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
- connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
+ connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
+ connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
- connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
+ connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
- connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
+ connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
- connect( GroupPoints->CheckButton1, SIGNAL( toggled(bool) ), this, SLOT( CheckButtonToggled() ) );
- connect( GroupPoints->CheckButton2, SIGNAL( toggled(bool) ), this, SLOT( CheckButtonToggled() ) );
+ connect( GroupPoints->CheckButton1, SIGNAL( toggled(bool) ), this, SLOT( CheckButtonToggled() ) );
+ connect( GroupPoints->CheckButton2, SIGNAL( toggled(bool) ), this, SLOT( CheckButtonToggled() ) );
connect( myGeomGUI->getApp()->selectionMgr(),
- SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
+ SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
- connect( myBySelectionBtn, SIGNAL( clicked() ), this, SLOT( CreationModeChanged() ) );
- connect( myAnaliticalBtn, SIGNAL( clicked() ), this, SLOT( CreationModeChanged() ) );
+ connect( myBySelectionBtn, SIGNAL( clicked() ), this, SLOT( CreationModeChanged() ) );
+ connect( myAnaliticalBtn, SIGNAL( clicked() ), this, SLOT( CreationModeChanged() ) );
- connect(myParams->myPMin, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
- connect(myParams->myPMax, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
- connect(myParams->myPStep, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
+ connect(myParams->myPMin, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
+ connect(myParams->myPMax, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
+ connect(myParams->myPStep, SIGNAL(valueChanged(int)), this, SLOT(ValueChangedInSpinBox(int)));
- connect(myParams->myXExpr, SIGNAL(editingFinished()), this, SLOT(OnEditingFinished()));
- connect(myParams->myYExpr, SIGNAL(editingFinished()), this, SLOT(OnEditingFinished()));
- connect(myParams->myZExpr, SIGNAL(editingFinished()), this, SLOT(OnEditingFinished()));
+ connect(myParams->myXExpr, SIGNAL(editingFinished()), this, SLOT(OnEditingFinished()));
+ connect(myParams->myYExpr, SIGNAL(editingFinished()), this, SLOT(OnEditingFinished()));
+ connect(myParams->myZExpr, SIGNAL(editingFinished()), this, SLOT(OnEditingFinished()));
initName( tr( "GEOM_CURVE" ) );
resize(100,100);
if( myBySelectionBtn->isChecked() )
anObj = anOper->MakePolyline( points.in(), GroupPoints->CheckButton1->isChecked() );
else
- anObj = anOper->MakeCurveParametric(qPrintable(myParams->myXExpr->text()),
+ anObj = anOper->MakeCurveParametricNew(qPrintable(myParams->myXExpr->text()),
qPrintable(myParams->myYExpr->text()),
qPrintable(myParams->myZExpr->text()),
myParams->myPMin->value(),
if( myBySelectionBtn->isChecked() )
anObj = anOper->MakeSplineBezier( points.in(), GroupPoints->CheckButton1->isChecked() );
else
- anObj = anOper->MakeCurveParametric(qPrintable(myParams->myXExpr->text()),
+ anObj = anOper->MakeCurveParametricNew(qPrintable(myParams->myXExpr->text()),
qPrintable(myParams->myYExpr->text()),
qPrintable(myParams->myZExpr->text()),
myParams->myPMin->value(),
anObj = anOper->MakeSplineInterpolation( points.in(), GroupPoints->CheckButton1->isChecked(),
GroupPoints->CheckButton2->isChecked() );
else
- anObj = anOper->MakeCurveParametric(qPrintable(myParams->myXExpr->text()),
+ anObj = anOper->MakeCurveParametricNew(qPrintable(myParams->myXExpr->text()),
qPrintable(myParams->myYExpr->text()),
qPrintable(myParams->myZExpr->text()),
myParams->myPMin->value(),
processPreview();
}
+//=================================================================================
+// function : ValueChangedInSpinBox()
+// purpose :
+//=================================================================================
+void BasicGUI_CurveDlg::ValueChangedInSpinBox(int/*theValue*/)
+{
+ processPreview();
+}
+
//=================================================================================
// function : ValueChangedInSpinBox()
// purpose :
void SetEditCurrentArgument();
void CreationModeChanged();
void ValueChangedInSpinBox(double/*theValue*/);
+ void ValueChangedInSpinBox(int /*theValue*/);
void OnEditingFinished();
};
#include <QGroupBox>
#include <SalomeApp_DoubleSpinBox.h>
+#include <SalomeApp_IntSpinBox.h>
BasicGUI_ParamCurveWidget::BasicGUI_ParamCurveWidget(QWidget* parent):
myPMax = new SalomeApp_DoubleSpinBox( groupBox );
// Step
- QLabel* textLabel6 = new QLabel( tr("GEOM_PCURVE_STEP"), groupBox );
- myPStep = new SalomeApp_DoubleSpinBox( groupBox );
+ QLabel* textLabel6 = new QLabel( tr("GEOM_PCURVE_NBSTEP"), groupBox );
+ myPStep = new SalomeApp_IntSpinBox( groupBox );
//Layout
gridLayout->addWidget(textLabel1, 0, 0, 1, 1);
class QLineEdit;
class SalomeApp_DoubleSpinBox;
+class SalomeApp_IntSpinBox;
class BasicGUI_ParamCurveWidget: public QWidget {
Q_OBJECT
SalomeApp_DoubleSpinBox* myPMin;
SalomeApp_DoubleSpinBox* myPMax;
- SalomeApp_DoubleSpinBox* myPStep;
+ SalomeApp_IntSpinBox* myPStep;
};
<message>
<source>GEOM_PCURVE_STEP</source>
<translation>Step</translation>
+ </message>
+ <message>
+ <source>GEOM_PCURVE_NBSTEP</source>
+ <translation>Number of steps</translation>
</message>
</context>
<context>
<source>GEOM_PCURVE_STEP</source>
<translation>Pas</translation>
</message>
+ <message>
+ <source>GEOM_PCURVE_NBSTEP</source>
+ <translation>Nombre de pas</translation>
+ </message>
</context>
<context>
<name>BasicGUI_EllipseDlg</name>
Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCurveParametric
(const char* thexExpr, const char* theyExpr, const char* thezExpr,
double theParamMin, double theParamMax, double theParamStep,
- CurveType theCurveType)
+ CurveType theCurveType,
+ int theParamNbStep, bool theNewMethod)
{
TCollection_AsciiString aPyScript;
aPyScript +="from math import * \n";
aPyScript += thezExpr;
aPyScript += "\n";
- aPyScript +="def coordCalculator(tmin, tmax, tstep): \n";
- aPyScript +=" coords = [] \n";
- aPyScript +=" while tmin <= tmax : \n";
- aPyScript +=" coords.append([X(tmin), Y(tmin), Z(tmin)]) \n";
- aPyScript +=" tmin = tmin + tstep \n";
- aPyScript +=" return coords \n";
+ if (theNewMethod)
+ {
+ aPyScript +="def coordCalculator(tmin, tmax, nstep): \n";
+ aPyScript +=" coords = [] \n";
+ aPyScript +=" tstep = (tmax - tmin) / nstep \n";
+ aPyScript +=" n = 0 \n";
+ aPyScript +=" while n <= nstep : \n";
+ aPyScript +=" t = tmin + n*tstep \n";
+ aPyScript +=" coords.append([X(t), Y(t), Z(t)]) \n";
+ aPyScript +=" n = n+1 \n";
+ aPyScript +=" return coords \n";
+ }
+ else
+ {
+ aPyScript +="def coordCalculator(tmin, tmax, tstep): \n";
+ aPyScript +=" coords = [] \n";
+ aPyScript +=" while tmin <= tmax : \n";
+ aPyScript +=" coords.append([X(tmin), Y(tmin), Z(tmin)]) \n";
+ aPyScript +=" tmin = tmin + tstep \n";
+ aPyScript +=" return coords \n";
+ }
SetErrorCode(KO);
return NULL;
}
- if(theParamStep <= 0.0 ) {
+ if(!theNewMethod && theParamStep <= 0.0) {
SetErrorCode("Value of the step must be positive !!!");
return NULL;
}
+ else if(theNewMethod && theParamNbStep < 0) {
+ SetErrorCode("The number of steps must be positive !!!");
+ return NULL;
+ }
/* Initialize the Python interpreter */
if (! Py_IsInitialized()) {
return NULL;
}
- PyObject* coords = PyObject_CallFunction(func,(char*)"(d, d, d)", theParamMin, theParamMax, theParamStep );
+ PyObject* coords;
+ if (theNewMethod)
+ coords = PyObject_CallFunction(func,(char*)"(d, d, i)", theParamMin, theParamMax, theParamNbStep );
+ else
+ coords = PyObject_CallFunction(func,(char*)"(d, d, d)", theParamMin, theParamMax, theParamStep );
+
PyObject* new_stderr = NULL;
if (coords == NULL){
pd << theParamMin <<", ";
pd << theParamMax <<", ";
- pd << theParamStep <<", ";
- pd << aCurveType.ToCString() <<")";
+ if (theNewMethod)
+ pd << theParamNbStep <<", ";
+ else
+ pd << theParamStep <<", ";
+ pd << aCurveType.ToCString() <<", ";
+ pd << theNewMethod <<")";
SetErrorCode(OK);
return aCurve;
Standard_EXPORT Handle(GEOM_Object) MakeCurveParametric(const char* thexExpr, const char* theyExpr, const char* thezExpr,
double theParamMin, double theParamMax, double theParamStep,
- CurveType theCurveType);
+ CurveType theCurveType,
+ int theParamNbStep=0, bool theNewMethod=false);
Standard_EXPORT Handle(GEOM_Object) MakeSketcher (const char* theCommand,
std::list<double> theWorkingPlane);
return GetObject(anObject);
}
+//=============================================================================
+/*!
+ * MakeCurveParametricNew
+ */
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCurveParametricNew(const char* thexExpr, const char* theyExpr, const char* thezExpr,
+ double theParamMin, double theParamMax, int theParamNbStep,
+ GEOM::curve_type theCurveType) {
+ GEOM::GEOM_Object_var aGEOMObject;
+ //Set a not done flag
+ GetOperations()->SetNotDone();
+
+ GEOMImpl_ICurvesOperations::CurveType aType;
+ switch(theCurveType) {
+ case GEOM::Polyline:
+ aType = GEOMImpl_ICurvesOperations::Polyline;
+ break;
+ case GEOM::Bezier:
+ aType = GEOMImpl_ICurvesOperations::Bezier;
+ break;
+ case GEOM::Interpolation:
+ aType = GEOMImpl_ICurvesOperations::Interpolation;
+ break;
+ default:
+ break;
+ }
+
+
+ // Make Polyline
+ Handle(GEOM_Object) anObject =
+ GetOperations()->MakeCurveParametric(thexExpr, theyExpr, thezExpr,
+ theParamMin, theParamMax,
+ 0.0, aType, theParamNbStep, true);
+
+ if (!GetOperations()->IsDone() || anObject.IsNull())
+ return aGEOMObject._retn();
+
+ return GetObject(anObject);
+}
+
//=============================================================================
/*!
* MakeSketcher
GEOM::GEOM_Object_ptr MakeCurveParametric(const char* thexExpr, const char* theyExpr, const char* thezExpr,
double theParamMin, double theParamMax, double theParamStep,
GEOM::curve_type theCurveType);
+
+ GEOM::GEOM_Object_ptr MakeCurveParametricNew(const char* thexExpr, const char* theyExpr, const char* thezExpr,
+ double theParamMin, double theParamMax, int theParamNbStep,
+ GEOM::curve_type theCurveType);
GEOM::GEOM_Object_ptr MakeSketcher (const char* theCommand, const GEOM::ListOfDouble& theWorkingPlane);
#
# @ref tui_creation_curve "Example"
def MakeCurveParametric(self, thexExpr, theyExpr, thezExpr,
- theParamMin, theParamMax, theParamStep, theCurveType):
+ theParamMin, theParamMax, theParamStep, theCurveType, theNewMethod=False ):
theParamMin,theParamMax,theParamStep,Parameters = ParseParameters(theParamMin,theParamMax,theParamStep)
- anObj = self.CurvesOp.MakeCurveParametric(thexExpr,theyExpr,thezExpr,theParamMin,theParamMax,theParamStep,theCurveType)
+ if theNewMethod:
+ anObj = self.CurvesOp.MakeCurveParametricNew(thexExpr,theyExpr,thezExpr,theParamMin,theParamMax,theParamStep,theCurveType)
+ else:
+ anObj = self.CurvesOp.MakeCurveParametric(thexExpr,theyExpr,thezExpr,theParamMin,theParamMax,theParamStep,theCurveType)
RaiseIfFailed("MakeSplineInterpolation", self.CurvesOp)
anObj.SetParameters(Parameters)
return anObj