Salome HOME
Merge from BR_Dev_For_4_0 branch (from tag mergeto_BR_QT4_Dev_17Jan08)
[modules/geom.git] / src / TransformationGUI / TransformationGUI_ScaleDlg.cxx
index 69732e560db675a9bc772a167cc89ccf2524ad38..fe2d72bba7538c27878f03498be86b7bee0e00be 100644 (file)
@@ -24,7 +24,7 @@
 
 #include "TransformationGUI_ScaleDlg.h"
 
-#include <GEOM_DlgRef.h>
+#include <DlgRef.h>
 #include <GeometryGUI.h>
 #include <GEOMBase.h>
 
 #include <SalomeApp_Application.h>
 #include <LightApp_SelectionMgr.h>
 
+#include <TopoDS_Shape.hxx>
+#include <TopoDS.hxx>
+#include <TopExp.hxx>
+#include <TColStd_IndexedMapOfInteger.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+
 #include <GEOMImpl_Types.hxx>
 
 //=================================================================================
@@ -82,7 +88,7 @@ TransformationGUI_ScaleDlg::TransformationGUI_ScaleDlg( GeometryGUI* theGeometry
   double aFactor = 2.0;
   double SpecificStep = 0.5;
   /* min, max, step and decimals for spin boxes & initial values */
-  initSpinBox( GroupPoints->SpinBox_DX, COORD_MIN, COORD_MAX, SpecificStep, 3 );
+  initSpinBox( GroupPoints->SpinBox_DX, COORD_MIN, COORD_MAX, SpecificStep, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
   GroupPoints->SpinBox_DX->setValue( aFactor );
   
   // Activate Create a Copy mode
@@ -108,7 +114,7 @@ TransformationGUI_ScaleDlg::TransformationGUI_ScaleDlg( GeometryGUI* theGeometry
   connect( myGeomGUI->getApp()->selectionMgr(), 
           SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
 
-  setHelpFileName( "scale_transform.htm" );
+  setHelpFileName( "scale_operation_page.html" );
 
   Init();
 }
@@ -189,10 +195,43 @@ void TransformationGUI_ScaleDlg::SelectionIntoArgument()
       return;
     }
     Standard_Boolean testResult = Standard_False;
-    myPoint = GEOMBase::ConvertIOinGEOMObject( firstIObject(), testResult );
+    GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( firstIObject(), testResult );
+    aName = GEOMBase::GetName( aSelectedObject );
+    
+    TopoDS_Shape aShape;
+    if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) {
+      LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
+      TColStd_IndexedMapOfInteger aMap;
+      aSelMgr->GetIndexes( firstIObject(), aMap );
+      if ( aMap.Extent() == 1 ) {
+       int anIndex = aMap( 1 );
+       aName += QString( ":vertex_%1" ).arg( anIndex );
+       
+       //Find SubShape Object in Father
+       GEOM::GEOM_Object_var aFindedObject = findObjectInFather( aSelectedObject, aName );
+       
+       if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study
+         GEOM::GEOM_IShapesOperations_var aShapesOp =
+           getGeomEngine()->GetIShapesOperations( getStudyId() );
+         aSelectedObject = aShapesOp->GetSubShape( aSelectedObject, anIndex );
+         aSelMgr->clearSelected();
+       }
+       else {
+         aSelectedObject = aFindedObject; // get Object from study
+       }
+      }
+      else {
+       if ( aShape.ShapeType() != TopAbs_VERTEX ) {
+         aSelectedObject = GEOM::GEOM_Object::_nil();
+         aName = "";
+       }
+      }
+    }
+    
+    myPoint = aSelectedObject;
+
     if ( !testResult || CORBA::is_nil( myPoint ) )
       return;
-    aName = GEOMBase::GetName( myPoint );
   }
   myEditCurrentArgument->setText( aName );
   
@@ -222,14 +261,14 @@ void TransformationGUI_ScaleDlg::LineEditReturnPressed()
 void TransformationGUI_ScaleDlg::SetEditCurrentArgument()
 {
   QPushButton* send = (QPushButton*)sender();
+  globalSelection();
   
   if ( send == GroupPoints->PushButton1 ) {
     myEditCurrentArgument = GroupPoints->LineEdit1;
-    globalSelection();
   }
   else if ( send == GroupPoints->PushButton2 ) {
     myEditCurrentArgument = GroupPoints->LineEdit2;
-    globalSelection( GEOM_POINT );
+    localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
   }
   
   myEditCurrentArgument->setFocus();
@@ -318,16 +357,6 @@ bool TransformationGUI_ScaleDlg::execute( ObjectList& objects )
 }
 
 
-//=================================================================================
-// function : closeEvent
-// purpose  :
-//=================================================================================
-void  TransformationGUI_ScaleDlg::closeEvent( QCloseEvent* e )
-{
-  GEOMBase_Skeleton::closeEvent( e );
-}
-
-
 //=================================================================================
 // function : GetFactor()
 // purpose  :
@@ -346,3 +375,19 @@ void TransformationGUI_ScaleDlg::CreateCopyModeChanged( bool isCreateCopy )
 {
   mainFrame()->GroupBoxName->setEnabled(isCreateCopy);
 }
+
+//=================================================================================
+// function : addSubshapeToStudy
+// purpose  : virtual method to add new SubObjects if local selection
+//=================================================================================
+void TransformationGUI_ScaleDlg::addSubshapesToStudy()
+{
+  bool toCreateCopy = IsPreview() || GroupPoints->CheckButton1->isChecked();
+  if ( toCreateCopy ) {
+    QMap<QString, GEOM::GEOM_Object_var> objMap;
+
+    objMap[GroupPoints->LineEdit2->text()] = myPoint;
+    
+    addSubshapesToFather( objMap );
+  }
+}