-// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2010 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
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
// GEOM GEOMGUI : GUI for Geometry component
// File : EntityGUI_SketcherDlg.cxx
// Author : Damien COQUERET, Open CASCADE S.A.S.
//
#include "EntityGUI_SketcherDlg.h"
#include "EntityGUI_Widgets.h"
-#include <QtxDoubleSpinBox.h>
+#include <SalomeApp_DoubleSpinBox.h>
#include <GEOMBase.h>
#include <GeometryGUI.h>
#include <gp_Pln.hxx>
+#include <Basics_Utils.hxx>
+
//=================================================================================
// class : EntityGUI_SketcherDlg()
// purpose : Constructs a EntityGUI_SketcherDlg which is a child of 'parent', with the
/***************************************************************/
GroupBox1 = new QGroupBox(tr("GEOM_CS"), this);
- QGridLayout* OwnLayout = new QGridLayout(GroupBox1);
- OwnLayout->setSpacing(6);
- OwnLayout->setMargin(11);
+ QHBoxLayout* planeLayout = new QHBoxLayout(GroupBox1);
+ planeLayout->setSpacing(6);
+ planeLayout->setMargin(11);
ComboBox1 = new QComboBox(GroupBox1);
- OwnLayout->addWidget(ComboBox1);
+ ComboBox1->setSizePolicy( QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed) );
+ planeLayout->addWidget(ComboBox1);
+
+ planeButton = new QPushButton (GroupBox1);
+ planeButton->setText( tr( "GEOM_SKETCHER_RESTORE" ) );
+ planeLayout->addWidget(planeButton);
topLayout->addWidget(GroupBox1);
topLayout->addWidget( MainWidget );
connect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
connect( ComboBox1, SIGNAL( activated( int ) ), this, SLOT( SelectionIntoArgument() ) );
+ connect( planeButton, SIGNAL( clicked() ), this, SLOT( ActivateLocalCS() ) );
connect( myGeometryGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
/* min, max, step and decimals for spin boxes */
- initSpinBox( Group1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
- initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
- initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
- initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
- initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
- initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
- initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
- initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
- initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
- initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, 5., 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
+ initSpinBox( Group1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
+ initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
+ initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
+ initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
+ initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
+ initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
+ initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
+ // san: Note specific step values below!
+ initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
+ initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
+ initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, 5., "length_precision" );
/* displays Dialog */
MainWidget->GroupConstructors->setEnabled( false );
MainWidget->RadioButton1->setChecked( true );
- resize(100,100);
TypeClicked( 0 );
FindLocalCS();
+ resize(100,100);
+ ActivateLocalCS();
GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
}
Group2Spin->hide();
Group3Spin->hide();
Group4Spin->hide();
-
- resize(100,100);
}
}
else if ( myConstructorId == 1 ) { // ARC
GroupD2->setEnabled( false );
- MainWidget->RB_Dest1->setEnabled( false );
+ MainWidget->RB_Dest1->setEnabled( true );
MainWidget->RB_Dest2->setChecked( true );
DestClicked( 0 );
}
// Get setting of step value from file configuration
double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
- if ( myConstructorId == 0 ) { // SEGMENT
+ if ( (myConstructorId == 0) || (myConstructorId == 1) ) { // SEGMENT OR ARC
if ( constructorId == 1 ) { // XY
mySketchType = PT_ABS;
- initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
- initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
+ initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
+ initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) );
Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y2" ) );
myX = 0.0;
}
else if ( constructorId == 0 ) { // DXDY
mySketchType = PT_RELATIVE;
- initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
- initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
+ initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
+ initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_DX2" ) );
Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_DY2" ) );
myDX = 0.0;
else if ( constructorId == 2 ) { // Selection
mySketchType = PT_SEL;
myEditCurrentArgument = Group1Sel->LineEdit1;
- connect( myGeometryGUI->getApp()->selectionMgr(),
- SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
Group1Sel->show();
Group1Sel->buttonApply->setFocus();
SelectionIntoArgument();
}
+
+ connect( myGeometryGUI->getApp()->selectionMgr(),
+ SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
}
}
myY = 0.0;
myLength = 100.0;
if ( myConstructorDirId == 2 ) { // Angle
- initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 5., 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
- initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
+ initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 5., "length_precision" );
Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
Group2Spin->SpinBox_DX->setValue( myAngle );
Group2Spin->buttonApply->setFocus();
if ( constructorId == 2 ) { // Length
mySketchType = DIR_ANGLE_LENGTH;
+ initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
Group2Spin->SpinBox_DY->setValue( myLength );
}
else if ( constructorId == 0 ) { // X
mySketchType = DIR_ANGLE_X;
+ initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "angle_precision" );
Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_X3" ) );
Group2Spin->SpinBox_DY->setValue( myX );
}
else if ( constructorId == 1 ) { // Y
mySketchType = DIR_ANGLE_Y;
+ initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "angle_precision" );
Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y3" ) );
Group2Spin->SpinBox_DY->setValue( myY );
}
}
}
else if ( myConstructorDirId == 3 ) { // DXDY
- initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
- initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
- initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
+ initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
+ initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
+ initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_VX2" ) );
Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_VY2" ) );
myDX = 0.0;
if ( myConstructorDirId == 2 ) { // Angle
if ( constructorId == 2 ) { // Length
mySketchType = DIR_ANGLE_LENGTH;
- initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 5., 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
- initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
- initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, 5., 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
+ initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 5., "angle_precision" );
+ initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
+ initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, 5., "angle_precision" );
Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_ANGLE2" ));
else if ( myConstructorDirId == 0 ) { // Perpendicular
if ( constructorId == 2 ) { // Length
mySketchType = DIR_PER_LENGTH;
- initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
- initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 5., 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
+ initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
+ initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 5., "angle_precision" );
Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
myRadius = 100.0;
else if ( myConstructorDirId == 1 ) { // Tangent
if ( constructorId == 2 ) { // Length
mySketchType = DIR_TAN_LENGTH;
- initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
- initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 5., 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
+ initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
+ initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 5., "angle_precision" );
Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
myRadius = 100.0;
MainWidget->RadioButton1->setChecked( true );
TypeClicked( 0 );
+ connect( myGeometryGUI->getApp()->selectionMgr(),
+ SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
+
MainWidget->GroupConstructors->setEnabled( false );
MainWidget->GroupDest1->setEnabled( false );
setEnabledUndo( false );
void EntityGUI_SketcherDlg::SelectionIntoArgument()
{
myEditCurrentArgument->setText( "" );
+ double tmpX = myX;
+ double tmpY = myY;
myX = myLastX1;
myY = myLastY1;
+ // printf ("\nmyX = %f myY = %f", myX, myY);
+ // printf ("\nmyLastX1 = %f myLastY1 = %f", myLastX1, myLastY1);
+ // printf ("\nmyLastX2 = %f myLastY2 = %f", myLastX2, myLastY2);
+
+ if ( sender() == ComboBox1 )
+ ActivateLocalCS();
LightApp_SelectionMgr* aSelMgr = myGeometryGUI->getApp()->selectionMgr();
SALOME_ListIO aSelList;
myX = aPnt.X();
myY = aPnt.Y();
Group1Sel->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) );
+ if( Group2Spin->isVisible() && mySketchType == PT_ABS ) {
+ disconnect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
+ disconnect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
+ Group2Spin->SpinBox_DX->setValue(myX);
+ Group2Spin->SpinBox_DY->setValue(myY);
+ connect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
+ connect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
+ } else if ( Group2Spin->isVisible() && mySketchType == PT_RELATIVE ) {
+ if ( myLastX1 && myLastY1 ) {
+ Group2Spin->SpinBox_DX->setValue(myX - myLastX1);
+ Group2Spin->SpinBox_DY->setValue(myY - myLastY1);
+ } else {
+ if ( mySketchState != FIRST_POINT ) {
+ Group2Spin->SpinBox_DX->setValue(myX - tmpX);
+ Group2Spin->SpinBox_DY->setValue(myY - tmpY);
+ } else {
+ Group2Spin->SpinBox_DX->setValue(myX);
+ Group2Spin->SpinBox_DY->setValue(myY);
+ }
+ }
+ }
}
}
}
}
}
else if ( myConstructorId == 1 ) { // ARC
+ if ( mySketchType == PT_ABS ) {
+ myX = vx;
+ myY = vy;
+ myXStr = vxStr;
+ myYStr = vyStr;
+ }
+ else if ( mySketchType == PT_RELATIVE ) {
+ myDX = vx;
+ myDY = vy;
+ myDXStr = vxStr;
+ myDYStr = vyStr;
+ }
if ( mySketchType == DIR_ANGLE_LENGTH ) {
myAngle = vx;
myRadius = vy;
}
}
else if ( myConstructorId == 1 ) { // ARC
+ if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
+ myNewCommand = myNewCommand + "AA " + QString::number( myX ) + " " + QString::number( myY );
+ theParameters = myXStr + ":" + myYStr;
+ }
+ if ( mySketchType == PT_RELATIVE) {
+ myNewCommand = myNewCommand + "A " + QString::number( myDX ) + " " + QString::number( myDY );
+ theParameters = myDXStr + ":" + myDYStr;
+ }
if ( mySketchType == DIR_ANGLE_LENGTH ) {
myNewCommand = myNewCommand + "R " + QString::number( myAngle );
myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius ) + " " + QString::number( myLength );
//Test if the current point is the same as the last one
TopoDS_Shape myShape1, myShape2;
+ // Set "C" numeric locale
+ Kernel_Utils::Localizer loc;
+
//Last Shape
QString Command1 = myCommand.join( "" );
Sketcher_Profile aProfile1( Command1.toAscii() );
}
}
+//=================================================================================
+// function : initSpinBox()
+// purpose :
+//=================================================================================
void EntityGUI_SketcherDlg::initSpinBox( SalomeApp_DoubleSpinBox* spinBox,
double min, double max,
- double step, int decimals )
+ double step, const char* quantity )
{
- spinBox->setDecimals( decimals );
+ // The same stuff as in GEOMBase_Skeleton::initSpinBox()!
+ // TODO: Think how to keep the single piece of code...
+
+ // Obtain precision from preferences
+ SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+ int aPrecision = resMgr->integerValue( "Geometry", quantity, 6 );
+
+ spinBox->setPrecision( aPrecision );
+ spinBox->setDecimals( qAbs( aPrecision ) ); // it's necessary to set decimals before the range setting,
+ // by default Qt rounds boundaries to 2 decimals at setRange
spinBox->setRange( min, max );
spinBox->setSingleStep( step );
+
+ // Add a hint for the user saying how to tune precision
+ QString userPropName = QObject::tr( QString( "GEOM_PREF_%1" ).arg( quantity ).toLatin1().constData() );
+ spinBox->setProperty( "validity_tune_hint",
+ QVariant( QObject::tr( "GEOM_PRECISION_HINT" ).arg( userPropName ) ) );
}
//=================================================================================
Group3Spin->SpinBox_DX->setSingleStep(step);
Group3Spin->SpinBox_DY->setSingleStep(step);
Group3Spin->SpinBox_DZ->setSingleStep(step);
- Group4Spin->SpinBox_DX->setSingleStep(step);
- Group4Spin->SpinBox_DY->setSingleStep(step);
Group4Spin->SpinBox_DZ->setSingleStep(step);
- Group4Spin->SpinBox_DS->setSingleStep(step);
+
+ // san: Do NOT override the step when a speicifc step value is used
+ // in some input fields!
+ //Group4Spin->SpinBox_DX->setSingleStep(step);
+ //Group4Spin->SpinBox_DY->setSingleStep(step);
+ //Group4Spin->SpinBox_DS->setSingleStep(step);
}
//=================================================================================
//=================================================================================
// function : GetActiveLocalCS()
-// purpose : Find All Coordinates systems in study
+// purpose : Get Working plane
//=================================================================================
gp_Ax3 EntityGUI_SketcherDlg::GetActiveLocalCS()
{
gp_Ax3 aLCS = myLCSList.at(ind);
- myGeometryGUI->SetWorkingPlane( aLCS );
- myGeometryGUI->ActiveWorkingPlane();
return aLCS;
}
+
+//=================================================================================
+// function : ActivateLocalCS()
+// purpose : Activate & Fit Working plane
+//=================================================================================
+void EntityGUI_SketcherDlg::ActivateLocalCS()
+{
+ myGeometryGUI->SetWorkingPlane( GetActiveLocalCS() );
+ myGeometryGUI->ActiveWorkingPlane();
+}