Salome HOME
IPAL20717 4.x: information in "Basic Properties" dlg is differently styled.
[modules/geom.git] / src / MeasureGUI / MeasureGUI_NormaleDlg.cxx
index 6714e4fb19f18696f67f95cc58a1ae1a0fbad428..d095f0b4537a0658030d85988a351b782603c7f1 100644 (file)
@@ -1,6 +1,6 @@
-//  GEOM GEOMGUI : GUI for Geometry component
+//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  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
 //
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
-//
-//
+//  GEOM GEOMGUI : GUI for Geometry component
 //  File   : MeasureGUI_NormaleDlg.cxx
 //  Author : Julia DOROVSKIKH
 //  Module : GEOM
 //  $Header$
-
+//
 #include "MeasureGUI_NormaleDlg.h"
 
 #include "SUIT_Session.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 <qlabel.h>
 
 #include "GEOMImpl_Types.hxx"
@@ -177,14 +181,58 @@ void MeasureGUI_NormaleDlg::SelectionIntoArgument()
   if (!testResult)
     return;
 
+  QString aName = GEOMBase::GetName(aSelectedObject);
+
   if (myEditCurrentArgument == GroupArgs->LineEdit1) {
+    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) // Local Selection
+      {
+        GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId());
+        int anIndex = aMap( 1 );
+        aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
+        aName += QString(":face_%1").arg(anIndex);
+      }
+      else // Global Selection
+      {
+       if (aShape.ShapeType() != TopAbs_FACE) {
+          aSelectedObject = GEOM::GEOM_Object::_nil();
+          aName = "";
+       }
+      }
+    }
     myFace = aSelectedObject;
   }
   else if (myEditCurrentArgument == GroupArgs->LineEdit2) {
+    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) // Local Selection
+      {
+        GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId());
+        int anIndex = aMap( 1 );
+        aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
+        aName += QString(":vertex_%1").arg(anIndex);
+      }
+      else // Global Selection
+      {
+       if (aShape.ShapeType() != TopAbs_VERTEX) {
+          aSelectedObject = GEOM::GEOM_Object::_nil();
+          aName = "";
+       }
+      }
+    }
     myPoint = aSelectedObject;
   }
 
-  myEditCurrentArgument->setText(GEOMBase::GetName(aSelectedObject));
+  myEditCurrentArgument->setText( aName );
 
   displayPreview();
 }
@@ -211,14 +259,15 @@ void MeasureGUI_NormaleDlg::LineEditReturnPressed()
 void MeasureGUI_NormaleDlg::SetEditCurrentArgument()
 {
   QPushButton* send = (QPushButton*)sender();
+  globalSelection(GEOM_FACE);
 
   if (send == GroupArgs->PushButton1) {
     myEditCurrentArgument = GroupArgs->LineEdit1;
-    globalSelection(GEOM_FACE);
+    localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE );
   }
   else if (send == GroupArgs->PushButton2) {
     myEditCurrentArgument = GroupArgs->LineEdit2;
-    globalSelection(GEOM_POINT);
+    localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
   }
 
   myEditCurrentArgument->setFocus();