Salome HOME
0022765: [EDF] Improvement of local selection mechanism
[modules/geom.git] / src / MeasureGUI / MeasureGUI_WhatisDlg.cxx
index 55acc91955246541744ad37c2429b9d529f498db..bef4de91ea68f49e6d07cc31660ec9aacc827fb7 100644 (file)
@@ -187,6 +187,18 @@ void MeasureGUI_WhatisDlg::processObject()
   myParamsDlg->adjustSize();
 }
 
+//=================================================================================
+// function : activateSelection()
+// purpose  :
+//=================================================================================
+void MeasureGUI_WhatisDlg::activateSelection()
+{
+  MeasureGUI_Skeleton::activateSelection();
+  std::list<int> needTypes;
+  needTypes.push_back( TopAbs_VERTEX ), needTypes.push_back( TopAbs_EDGE ), needTypes.push_back( TopAbs_WIRE ), needTypes.push_back( TopAbs_FACE ), needTypes.push_back( TopAbs_SHELL ), needTypes.push_back( TopAbs_SOLID ), needTypes.push_back( TopAbs_COMPOUND );
+  localSelection(GEOM::GEOM_Object::_nil(), needTypes );
+}
+
 //=================================================================================
 // function : ClickOnProperties()
 // purpose  :
@@ -202,13 +214,13 @@ void MeasureGUI_WhatisDlg::ClickOnProperties()
 //=================================================================================
 bool MeasureGUI_WhatisDlg::getParameters( QString& theText )
 {
-  if ( myObj->_is_nil() )
+  if ( !myObj )
     return false;
 
   GEOM::GEOM_IMeasureOperations_var anOper = GEOM::GEOM_IMeasureOperations::_narrow( getOperation() );
   try
   {
-    theText = anOper->WhatIs( myObj );
+    theText = anOper->WhatIs( myObj.get() );
   }
   catch( const SALOME::SALOME_Exception& e )
   {
@@ -231,7 +243,7 @@ QString MeasureGUI_WhatisDlg::getKindOfShape( QString& theParameters )
   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
   int aLenPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
 
-  if ( myObj->_is_nil() )
+  if ( !myObj )
     return aKindStr;
 
   GEOM::GEOM_IKindOfShape::shape_kind aKind;
@@ -242,7 +254,7 @@ QString MeasureGUI_WhatisDlg::getKindOfShape( QString& theParameters )
 
   try
   {
-    aKind = anOper->KindOfShape( myObj, anInts, aDbls );
+    aKind = anOper->KindOfShape( myObj.get(), anInts, aDbls );
   }
   catch( const SALOME::SALOME_Exception& e ) {
     SalomeApp_Tools::QtCatchCorbaException( e );
@@ -601,3 +613,20 @@ QString MeasureGUI_WhatisDlg::getKindOfShape( QString& theParameters )
 
   return aKindStr;
 }
+
+void MeasureGUI_WhatisDlg::SelectionIntoArgument()
+{
+  myObj.nullify();
+  myObj = getSelected( TopAbs_SHAPE );
+  if (!myObj) {
+    mySelEdit->setText("");
+    processObject();
+    erasePreview();
+    return;
+  }
+
+  mySelEdit->setText(GEOMBase::GetName(myObj.get()));
+  processObject();
+  redisplayPreview();
+}
\ No newline at end of file