]> SALOME platform Git repositories - modules/geom.git/blobdiff - src/OperationGUI/OperationGUI_Fillet1d2dDlg.cxx
Salome HOME
0021672: [CEA 565] Dump Study from script
[modules/geom.git] / src / OperationGUI / OperationGUI_Fillet1d2dDlg.cxx
index 56f9cb31a98bbed73b9694a0c1df5428875bdd40..16cc60845500da1b2e9a64b1b967b5fd032a4638 100644 (file)
@@ -1,7 +1,4 @@
-// GEOM GEOMGUI : GUI for Geometry component
-//
-// Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 //
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
+// GEOM GEOMGUI : GUI for Geometry component
 // File   : OperationGUI_Fillet1d2dDlg.cxx
 // Author : DMV, OCN.
-//
 
 #include "OperationGUI_Fillet1d2dDlg.h"
 
@@ -88,7 +86,7 @@ OperationGUI_Fillet1d2dDlg::OperationGUI_Fillet1d2dDlg (GeometryGUI* theGeometry
 
   // Set range of spinboxes
   double SpecificStep = 10.0;
-  initSpinBox(GroupVertexes->SpinBox_DX, 0.00001, COORD_MAX, SpecificStep, 5); // VSR: TODO: DBL_DIGITS_DISPLAY
+  initSpinBox(GroupVertexes->SpinBox_DX, 0.00001, COORD_MAX, SpecificStep, "length_precision" );
 
   setHelpFileName(myIs1D ? "fillet1d_operation_page.html" : "fillet2d_operation_page.html");
 
@@ -122,6 +120,8 @@ void OperationGUI_Fillet1d2dDlg::Init()
 
   myVertexes.Clear();
 
+  showOnlyPreviewControl();
+
   // signals and slots connections
 
   connect(buttonOk(),    SIGNAL(clicked()), this, SLOT(ClickOnOk()   ));
@@ -149,6 +149,7 @@ void OperationGUI_Fillet1d2dDlg::Init()
 //=================================================================================
 void OperationGUI_Fillet1d2dDlg::ClickOnOk()
 {
+  setIsApplyAndClose( true );
   if (ClickOnApply())
     ClickOnCancel();
 }
@@ -190,52 +191,51 @@ void OperationGUI_Fillet1d2dDlg::SelectionIntoArgument()
   if (myEditCurrentArgument == GroupVertexes->LineEdit1) {
     myShape = GEOM::GEOM_Object::_nil();
     if (aSelList.Extent() == 1) {
-      Standard_Boolean aResult = Standard_False;
       GEOM::GEOM_Object_var anObj =
-        GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aResult);
+        GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
       
-      if (aResult && !anObj->_is_nil()) {
-       QString aName = GEOMBase::GetName( anObj );
-       TopoDS_Shape aShape;
-       if ( GEOMBase::GetShape( anObj, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) {
-         TColStd_IndexedMapOfInteger aMap;
-         aSelMgr->GetIndexes(aSelList.First(), aMap);
-         if ( aMap.Extent() == 1 ) { // Local Selection
-           int anIndex = aMap( 1 );
-           aName += QString( myIs1D ? ":wire_%1" : ":face_%1" ).arg( anIndex );
+      if ( !anObj->_is_nil() ) {
+        QString aName = GEOMBase::GetName( anObj );
+        TopoDS_Shape aShape;
+        if ( GEOMBase::GetShape( anObj, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) {
+          TColStd_IndexedMapOfInteger aMap;
+          aSelMgr->GetIndexes(aSelList.First(), aMap);
+          if ( aMap.Extent() == 1 ) { // Local Selection
+            int anIndex = aMap( 1 );
+            aName += QString( myIs1D ? ":wire_%1" : ":face_%1" ).arg( anIndex );
    
-           //Find SubShape Object in Father
-           GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather( anObj, aName );
-           
-           if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study
-             GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
-             anObj = aShapesOp->GetSubShape( anObj, anIndex );
-           }
-           else
-             anObj = aFindedObject; // get Object from study
-         }
-         else { // Global Selection
-           if ( aShape.ShapeType() != (myIs1D ? TopAbs_WIRE : TopAbs_FACE) ) {
-             anObj = GEOM::GEOM_Object::_nil();
-             aName = "";
-           }
-         }
-       }
-       myShape = anObj;
-       myEditCurrentArgument->setText(aName
+            //Find SubShape Object in Father
+            GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather( anObj, aName );
+            
+            if ( aFindedObject->_is_nil()) { // Object not found in study
+              GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
+              anObj = aShapesOp->GetSubShape( anObj, anIndex );
+            }
+            else
+              anObj = aFindedObject; // get Object from study
+          }
+          else { // Global Selection
+            if ((myIs1D && aShape.ShapeType() != TopAbs_WIRE) ||
+                (!myIs1D && aShape.ShapeType() != TopAbs_FACE && aShape.ShapeType() != TopAbs_SHELL)) {
+              anObj = GEOM::GEOM_Object::_nil();
+              aName = "";
+            }
+          }
+        }
+        myShape = anObj;
+        myEditCurrentArgument->setText(aName
 );
-       displayPreview();
+        processPreview();
       }
     }
   } else if (myEditCurrentArgument == GroupVertexes->LineEdit2) {
     myVertexes.Clear();
     bool isPreview = myIs1D;
     if (aSelList.Extent() == 1) {
-      Standard_Boolean aResult = Standard_False;
       GEOM::GEOM_Object_var anObj =
-        GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aResult);
+        GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
 
-      if (aResult && !anObj->_is_nil()) {
+      if ( !anObj->_is_nil() ) {
         TColStd_IndexedMapOfInteger anIndexes;
         aSelMgr->GetIndexes(aSelList.First(), anIndexes);
 
@@ -250,12 +250,12 @@ void OperationGUI_Fillet1d2dDlg::SelectionIntoArgument()
 
           isPreview = true;
           myEditCurrentArgument->setText(aName);
-         myVertexes = anIndexes;
+          myVertexes = anIndexes;
         }
       }
     }
     if ( isPreview )
-      displayPreview();
+      processPreview();
   }
 
   if (myEditCurrentArgument == GroupVertexes->LineEdit1) {
@@ -292,7 +292,7 @@ void OperationGUI_Fillet1d2dDlg::SetEditCurrentArgument()
   activateSelection();
 
   // seems we need it only to avoid preview disappearing, caused by selection mode change
-  displayPreview();
+  processPreview();
 }
 
 //=================================================================================
@@ -338,7 +338,7 @@ void OperationGUI_Fillet1d2dDlg::enterEvent (QEvent*)
 //=================================================================================
 void OperationGUI_Fillet1d2dDlg::ValueChangedInSpinBox (double)
 {
-  displayPreview();
+  processPreview();
 }
 
 //=================================================================================
@@ -350,8 +350,15 @@ void OperationGUI_Fillet1d2dDlg::activateSelection()
   disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
   globalSelection();
   if (myEditCurrentArgument == GroupVertexes->LineEdit1)
-    globalSelection( myIs1D ? GEOM_WIRE : GEOM_FACE );  // localSelection(myShape, myIs1D ? TopAbs_WIRE 
-                                                                                       // : TopAbs_FACE);
+    //localSelection(myShape, myIs1D ? TopAbs_WIRE : TopAbs_FACE);
+    if (myIs1D)
+      globalSelection(GEOM_WIRE);
+    else {
+      TColStd_MapOfInteger aMap;
+      aMap.Add(GEOM_FACE);
+      aMap.Add(GEOM_SHELL);
+      globalSelection(aMap);
+    }
   else if (!myShape->_is_nil() && myEditCurrentArgument == GroupVertexes->LineEdit2)
     localSelection(myShape, TopAbs_VERTEX);
 
@@ -372,9 +379,12 @@ GEOM::GEOM_IOperations_ptr OperationGUI_Fillet1d2dDlg::createOperation()
 // function : isValid()
 // purpose  : Verify validity of input data
 //=================================================================================
-bool OperationGUI_Fillet1d2dDlg::isValid (QString&)
+bool OperationGUI_Fillet1d2dDlg::isValid (QString& msg)
 {
-  return !myShape->_is_nil() && (myIs1D || myVertexes.Extent() > 0);
+  bool ok = !myShape->_is_nil();
+  ok = GroupVertexes->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
+  ok = (myIs1D || myVertexes.Extent() > 0) && ok;
+  return ok;
 }
 
 //=================================================================================