Salome HOME
Update copyright notes (for 2010)
[modules/geom.git] / src / BasicGUI / BasicGUI_PointDlg.cxx
index 6d69b559acfd72e0db7bc2c28f4db40a8325caac..ef68dfb54d07a0512f9609b62631f612e7f1bdaf 100644 (file)
@@ -1,4 +1,4 @@
-//  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   : BasicGUI_PointDlg.cxx
 //  Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
-
+//
 #include "BasicGUI_PointDlg.h"
 
 #include <SUIT_ResourceMgr.h>
@@ -43,6 +44,7 @@
 #include <QLabel>
 #include <QRadioButton>
 #include <QMenu>
+#include <QTimer>
 
 #include <gp_Pnt.hxx>
 #include <TopoDS_Shape.hxx>
@@ -230,28 +232,28 @@ void BasicGUI_PointDlg::Init()
   double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100 );
 
   /* min, max, step and decimals for spin boxes */
-  initSpinBox( GroupXYZ->SpinBox_DX, COORD_MIN, COORD_MAX, step, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY
-  initSpinBox( GroupXYZ->SpinBox_DY, COORD_MIN, COORD_MAX, step, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY
-  initSpinBox( GroupXYZ->SpinBox_DZ, COORD_MIN, COORD_MAX, step, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY
+  initSpinBox( GroupXYZ->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
+  initSpinBox( GroupXYZ->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
+  initSpinBox( GroupXYZ->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
   GroupXYZ->SpinBox_DX->setValue( 0.0 );
   GroupXYZ->SpinBox_DY->setValue( 0.0 );
   GroupXYZ->SpinBox_DZ->setValue( 0.0 );
 
-  initSpinBox( GroupRefPoint->SpinBox_DX, COORD_MIN, COORD_MAX, step, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY
-  initSpinBox( GroupRefPoint->SpinBox_DY, COORD_MIN, COORD_MAX, step, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY
-  initSpinBox( GroupRefPoint->SpinBox_DZ, COORD_MIN, COORD_MAX, step, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY
+  initSpinBox( GroupRefPoint->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
+  initSpinBox( GroupRefPoint->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
+  initSpinBox( GroupRefPoint->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
   GroupRefPoint->SpinBox_DX->setValue( 0.0 );
   GroupRefPoint->SpinBox_DY->setValue( 0.0 );
   GroupRefPoint->SpinBox_DZ->setValue( 0.0 );
 
   step = 0.1;
 
-  initSpinBox( GroupOnCurve->SpinBox_DX, 0., 1., step, 6 ); // VSR:TODO : DBL_DIGITS_DISPLAY
+  initSpinBox( GroupOnCurve->SpinBox_DX, 0., 1., step, "parametric_precision" );
   GroupOnCurve->SpinBox_DX->setValue( 0.5 );
 
-  initSpinBox( GroupOnSurface->SpinBox_DX, 0., 1., step, 6 ); // VSR:TODO : DBL_DIGITS_DISPLAY
+  initSpinBox( GroupOnSurface->SpinBox_DX, 0., 1., step, "parametric_precision" );
   GroupOnSurface->SpinBox_DX->setValue( 0.5 );
-  initSpinBox( GroupOnSurface->SpinBox_DY, 0., 1., step, 6 ); // VSR:TODO : DBL_DIGITS_DISPLAY
+  initSpinBox( GroupOnSurface->SpinBox_DY, 0., 1., step, "parametric_precision" );
   GroupOnSurface->SpinBox_DY->setValue( 0.5 );
 
   /* signals and slots connections */
@@ -263,8 +265,7 @@ void BasicGUI_PointDlg::Init()
 
   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( myParamCoord,   SIGNAL( buttonClicked( int ) ), this, SLOT( ClickParamCoord( int ) ) );
   connect( GroupOnCurve->PushButton1, SIGNAL( clicked() ),       this, SLOT( SetEditCurrentArgument() ) );
   connect( GroupOnCurve->LineEdit1,   SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
 
@@ -310,8 +311,6 @@ void BasicGUI_PointDlg::SetDoubleSpinBoxStep( double step )
   GroupRefPoint->SpinBox_DX->setSingleStep(step);
   GroupRefPoint->SpinBox_DY->setSingleStep(step);
   GroupRefPoint->SpinBox_DZ->setSingleStep(step);
-  GroupOnSurface->SpinBox_DX->setSingleStep(step);
-  GroupOnSurface->SpinBox_DY->setSingleStep(step);
 }
 
 
@@ -420,9 +419,7 @@ void BasicGUI_PointDlg::ConstructorsClicked(int constructorId)
   myY->setText( "" );
   myZ->setText( "" );
 
-  qApp->processEvents();
-  updateGeometry();
-  resize( minimumSizeHint() );
+  QTimer::singleShot(50, this, SLOT(updateSize()));
 
   SelectionIntoArgument();
 }
@@ -460,6 +457,7 @@ bool BasicGUI_PointDlg::ClickOnApply()
 //=================================================================================
 void BasicGUI_PointDlg::SelectionIntoArgument()
 {
+  erasePreview();
   const int id = getConstructorId();
 
   if ( ( id == GEOM_POINT_REF || id == GEOM_POINT_EDGE || id == GEOM_POINT_SURF ) && myEditCurrentArgument != 0 )
@@ -469,6 +467,12 @@ void BasicGUI_PointDlg::SelectionIntoArgument()
     myY->setText( "" );
     myZ->setText( "" );
     myRefPoint = myEdge = myFace = GEOM::GEOM_Object::_nil();
+  } else if ( id == GEOM_POINT_INTINT ) {
+    myEditCurrentArgument->setText( "" );
+    if ( myEditCurrentArgument == GroupLineIntersection->LineEdit1 )
+      myLine1 = GEOM::GEOM_Object::_nil();
+    else if ( myEditCurrentArgument == GroupLineIntersection->LineEdit2 )
+      myLine2 = GEOM::GEOM_Object::_nil();
   }
 
   LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
@@ -851,6 +855,13 @@ bool BasicGUI_PointDlg::execute( ObjectList& objects )
     }
   case GEOM_POINT_INTINT :
     anObj = anOper->MakePointOnLinesIntersection( myLine1, myLine2 );
+    if ( !anObj->_is_nil() ) {
+      QString aName = getNewObjectName();
+      if ( anObj->GetShapeType() == GEOM::COMPOUND && aName.startsWith("Vertex") )
+        initName( tr( "GEOM_COMPOUND" ) );
+      else if (  anObj->GetShapeType() == GEOM::VERTEX && aName.startsWith("Compound"))
+        initName( tr( "GEOM_VERTEX" ) );
+    }
     res = true;
     break;
   case GEOM_POINT_SURF :
@@ -938,7 +949,7 @@ void BasicGUI_PointDlg::addSubshapesToStudy()
 // function : ClickParamCoord()
 // purpose  :
 //=================================================================================
-void BasicGUI_PointDlg::ClickParamCoord()
+void BasicGUI_PointDlg::ClickParamCoord( int id )
 {
   updateParamCoord( true );
   displayPreview();
@@ -951,7 +962,6 @@ void BasicGUI_PointDlg::ClickParamCoord()
 void BasicGUI_PointDlg::updateParamCoord(bool theIsUpdate)
 {
   bool isParam = myParamCoord->checkedId() == PARAM_VALUE;
-  GroupXYZ->setShown( !isParam );
 
   const int id = getConstructorId();
   if ( id == GEOM_POINT_EDGE ) {
@@ -964,11 +974,11 @@ void BasicGUI_PointDlg::updateParamCoord(bool theIsUpdate)
     GroupOnSurface->SpinBox_DX->setShown( isParam );
     GroupOnSurface->SpinBox_DY->setShown( isParam );
   }
-  if ( theIsUpdate ) {
-    qApp->processEvents();
-    updateGeometry();
-    resize( minimumSizeHint() );
-  }
+
+  GroupXYZ->setShown( !isParam );
+
+  if ( theIsUpdate )
+    QTimer::singleShot(50, this, SLOT(updateSize()));
 }
 
 //=================================================================================
@@ -987,3 +997,14 @@ void BasicGUI_PointDlg::onBtnPopup( QAction* a )
   
   localSelection( GEOM::GEOM_Object::_nil(), myNeedType );
 }
+
+//=================================================================================
+// function : updateSize
+// purpose  : adjust dialog size to minimum
+//=================================================================================
+void BasicGUI_PointDlg::updateSize() 
+{
+  qApp->processEvents();
+  updateGeometry();
+  resize( minimumSizeHint() );
+}