-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
// GEOM GEOMGUI : GUI for Geometry component
// File : BasicGUI_CurveDlg.cxx
// Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
#include "BasicGUI_CurveDlg.h"
+#include "BasicGUI_ParamCurveWidget.h"
#include <DlgRef.h>
#include <GeometryGUI.h>
mainFrame()->RadioButton2->setIcon( image3 );
mainFrame()->RadioButton3->setIcon( image2 );
+ QGroupBox* creationModeCroup = new QGroupBox(this);
+ QButtonGroup* bg = new QButtonGroup(this);
+
+ creationModeCroup->setTitle( tr( "GEOM_CURVE_CRMODE" ) );
+ QHBoxLayout * creationModeLayout = new QHBoxLayout(creationModeCroup);
+ myBySelectionBtn = new QRadioButton( tr( "GEOM_CURVE_SELECTION" ) ,creationModeCroup );
+ myAnaliticalBtn = new QRadioButton( tr( "GEOM_CURVE_ANALITICAL" ) ,creationModeCroup );
+
+ bg->addButton(myBySelectionBtn);
+ bg->addButton(myAnaliticalBtn);
+
+ creationModeLayout->addWidget(myBySelectionBtn);
+ creationModeLayout->addWidget(myAnaliticalBtn);
+
GroupPoints = new DlgRef_1Sel3Check( centralWidget() );
GroupPoints->GroupBox1->setTitle( tr( "GEOM_NODES" ) );
GroupPoints->CheckButton3->hide();
+ myParams = new BasicGUI_ParamCurveWidget( centralWidget() );
+
QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
layout->setMargin( 0 ); layout->setSpacing( 6 );
+ layout->addWidget( creationModeCroup );
layout->addWidget( GroupPoints );
+ layout->addWidget( myParams );
/***************************************************************/
setHelpFileName( "create_curve_page.html" );
globalSelection(); // close local contexts, if any
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
+ showOnlyPreviewControl();
+ myBySelectionBtn->setChecked(true);
+
+ /* Get setting of step value from file configuration */
+ SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+ double step = resMgr ? resMgr->doubleValue( "Geometry", "SettingsGeomStep", 10. ) : 10.;
+
+ double aMax( 100. ), aMin( 0.0 );
+
+ /* 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" );
+ 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->myXExpr->setText("t");
+ myParams->myYExpr->setText("t");
+ myParams->myZExpr->setText("t");
+
+ 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(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()));
initName( tr( "GEOM_CURVE" ) );
resize(100,100);
- ConstructorsClicked( 0 );
+ ConstructorsClicked( 0 );
}
//=================================================================================
//=================================================================================
void BasicGUI_CurveDlg::CheckButtonToggled()
{
- displayPreview();
+ processPreview();
}
//=================================================================================
//=================================================================================
void BasicGUI_CurveDlg::ClickOnOk()
{
+ setIsApplyAndClose( true );
if ( ClickOnApply() )
ClickOnCancel();
}
GroupPoints->LineEdit1->setText( QString::number( myPoints.count() ) + "_" + tr( "GEOM_POINT" ) + tr( "_S_" ) );
else
GroupPoints->LineEdit1->setText( "" );
- displayPreview();
+ processPreview();
}
//=================================================================================
bool BasicGUI_CurveDlg::isValid( QString& msg )
{
- return myPoints.count() > 1;
+ if( myBySelectionBtn->isChecked() )
+ return myPoints.count() > 1;
+ else {
+ bool ok = myParams->myPMin->isValid( msg, !IsPreview() ) &&
+ myParams->myPMax->isValid( msg, !IsPreview() ) &&
+ myParams->myPStep->isValid( msg, !IsPreview() );
+ ok &= !myParams->myXExpr->text().isEmpty();
+ ok &= !myParams->myYExpr->text().isEmpty();
+ ok &= !myParams->myZExpr->text().isEmpty();
+ return ok;
+ }
}
//=================================================================================
switch ( getConstructorId() ) {
case 0 :
- anObj = anOper->MakePolyline( points.in(), GroupPoints->CheckButton1->isChecked() );
+ if( myBySelectionBtn->isChecked() )
+ anObj = anOper->MakePolyline( points.in(), GroupPoints->CheckButton1->isChecked() );
+ else
+ anObj = anOper->MakeCurveParametricNew(qPrintable(myParams->myXExpr->text()),
+ qPrintable(myParams->myYExpr->text()),
+ qPrintable(myParams->myZExpr->text()),
+ myParams->myPMin->value(),
+ myParams->myPMax->value(),
+ myParams->myPStep->value(),
+ GEOM::Polyline);
res = true;
break;
case 1 :
- anObj = anOper->MakeSplineBezier( points.in(), GroupPoints->CheckButton1->isChecked() );
+ if( myBySelectionBtn->isChecked() )
+ anObj = anOper->MakeSplineBezier( points.in(), GroupPoints->CheckButton1->isChecked() );
+ else
+ anObj = anOper->MakeCurveParametricNew(qPrintable(myParams->myXExpr->text()),
+ qPrintable(myParams->myYExpr->text()),
+ qPrintable(myParams->myZExpr->text()),
+ myParams->myPMin->value(),
+ myParams->myPMax->value(),
+ myParams->myPStep->value(),
+ GEOM::Bezier);
+
res = true;
break;
case 2 :
- anObj = anOper->MakeSplineInterpolation( points.in(), GroupPoints->CheckButton1->isChecked(),
- GroupPoints->CheckButton2->isChecked() );
+ if( myBySelectionBtn->isChecked() )
+ anObj = anOper->MakeSplineInterpolation( points.in(), GroupPoints->CheckButton1->isChecked(),
+ GroupPoints->CheckButton2->isChecked() );
+ else
+ anObj = anOper->MakeCurveParametricNew(qPrintable(myParams->myXExpr->text()),
+ qPrintable(myParams->myYExpr->text()),
+ qPrintable(myParams->myZExpr->text()),
+ myParams->myPMin->value(),
+ myParams->myPMax->value(),
+ myParams->myPStep->value(),
+ GEOM::Interpolation);
res = true;
break;
}
- if ( !anObj->_is_nil() )
+ if ( !anObj->_is_nil() ) {
+ if(myAnaliticalBtn->isChecked() && !IsPreview()) {
+ QStringList aParameters;
+ aParameters<<myParams->myPMin->text();
+ aParameters<<myParams->myPMax->text();
+ aParameters<<myParams->myPStep->text();
+ anObj->SetParameters(aParameters.join(":").toLatin1().constData());
+ }
objects.push_back( anObj._retn() );
-
+ }
+
return res;
}
for ( int i = 0; i < myPoints.count(); i++ )
GEOMBase::PublishSubObject( myPoints[i].get() );
}
+
+//=================================================================================
+// function : CreationModeChanged
+// purpose :
+//=================================================================================
+void BasicGUI_CurveDlg::CreationModeChanged() {
+ const QObject* s = sender();
+ GroupPoints->setVisible(myBySelectionBtn == s);
+ myParams->setVisible(myBySelectionBtn != s);
+
+ ConstructorsClicked( getConstructorId() );
+}
+
+//=================================================================================
+// function : ValueChangedInSpinBox()
+// purpose :
+//=================================================================================
+void BasicGUI_CurveDlg::ValueChangedInSpinBox(double/*theValue*/)
+{
+ processPreview();
+}
+
+//=================================================================================
+// function : ValueChangedInSpinBox()
+// purpose :
+//=================================================================================
+void BasicGUI_CurveDlg::ValueChangedInSpinBox(int/*theValue*/)
+{
+ processPreview();
+}
+
+//=================================================================================
+// function : ValueChangedInSpinBox()
+// purpose :
+//=================================================================================
+void BasicGUI_CurveDlg::OnEditingFinished() {
+ processPreview();
+}