]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
0022672: SMESH: Add a "Reset" in the "Controls" menu of smesh
authormpa <mpa@opencascade.com>
Mon, 8 Sep 2014 06:30:44 +0000 (10:30 +0400)
committermpa <mpa@opencascade.com>
Mon, 8 Sep 2014 06:30:44 +0000 (10:30 +0400)
src/SMESHGUI/SMESHGUI.cxx
src/SMESHGUI/SMESHGUI_Selection.cxx
src/SMESHGUI/SMESHGUI_Selection.h

index 8723415cda627dd5cbdc57350b073a769c3644ce..cccf51ff654e78cc8dc39208d9cba7a2ca3e9310 100644 (file)
@@ -1566,111 +1566,124 @@ namespace
 
   void Control( int theCommandID )
   {
+    SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
+    switch ( theCommandID ){
+    case SMESHOp::OpFreeNode:
+      aControl = SMESH_Actor::eFreeNodes;
+      break;
+    case SMESHOp::OpEqualNode:
+      aControl = SMESH_Actor::eCoincidentNodes;
+      break;
+    case SMESHOp::OpFreeEdge:
+      aControl = SMESH_Actor::eFreeEdges;
+      break;
+    case SMESHOp::OpFreeBorder:
+      aControl = SMESH_Actor::eFreeBorders;
+      break;
+    case SMESHOp::OpLength:
+      aControl = SMESH_Actor::eLength;
+      break;
+    case SMESHOp::OpConnection:
+      aControl = SMESH_Actor::eMultiConnection;
+      break;
+    case SMESHOp::OpEqualEdge:
+      aControl = SMESH_Actor::eCoincidentElems1D;
+      break;
+    case SMESHOp::OpFreeFace:
+      aControl = SMESH_Actor::eFreeFaces;
+      break;
+    case SMESHOp::OpBareBorderFace:
+      aControl = SMESH_Actor::eBareBorderFace;
+      break;
+    case SMESHOp::OpOverConstrainedFace:
+      aControl = SMESH_Actor::eOverConstrainedFace;
+      break;
+    case SMESHOp::OpLength2D:
+      aControl = SMESH_Actor::eLength2D;
+      break;
+    case SMESHOp::OpConnection2D:
+      aControl = SMESH_Actor::eMultiConnection2D;
+      break;
+    case SMESHOp::OpArea:
+      aControl = SMESH_Actor::eArea;
+      break;
+    case SMESHOp::OpTaper:
+      aControl = SMESH_Actor::eTaper;
+      break;
+    case SMESHOp::OpAspectRatio:
+      aControl = SMESH_Actor::eAspectRatio;
+      break;
+    case SMESHOp::OpMinimumAngle:
+      aControl = SMESH_Actor::eMinimumAngle;
+      break;
+    case SMESHOp::OpWarpingAngle:
+      aControl = SMESH_Actor::eWarping;
+      break;
+    case SMESHOp::OpSkew:
+      aControl = SMESH_Actor::eSkew;
+      break;
+    case SMESHOp::OpMaxElementLength2D:
+      aControl = SMESH_Actor::eMaxElementLength2D;
+      break;
+    case SMESHOp::OpEqualFace:
+      aControl = SMESH_Actor:: eCoincidentElems2D;
+      break;
+    case SMESHOp::OpAspectRatio3D:
+      aControl = SMESH_Actor::eAspectRatio3D;
+      break;
+    case SMESHOp::OpVolume:
+      aControl = SMESH_Actor::eVolume3D;
+      break;
+    case SMESHOp::OpMaxElementLength3D:
+      aControl = SMESH_Actor::eMaxElementLength3D;
+      break;
+    case SMESHOp::OpBareBorderVolume:
+      aControl = SMESH_Actor::eBareBorderVolume;
+      break;
+    case SMESHOp::OpOverConstrainedVolume:
+      aControl = SMESH_Actor::eOverConstrainedVolume;
+      break;
+    case SMESHOp::OpEqualVolume:
+      aControl = SMESH_Actor::eCoincidentElems3D;
+      break;
+    }
+    _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
     LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
     SALOME_ListIO selected;
     if( aSel )
       aSel->selectedObjects( selected );
 
     if( !selected.IsEmpty() ){
-      Handle(SALOME_InteractiveObject) anIO = selected.First();
-      if(!anIO.IsNull()){
-        SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
-        if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())) {
-          switch ( theCommandID ){
-          case SMESHOp::OpFreeNode:
-            aControl = SMESH_Actor::eFreeNodes;
-            break;
-          case SMESHOp::OpEqualNode:
-            aControl = SMESH_Actor::eCoincidentNodes;
-            break;
-          case SMESHOp::OpFreeEdge:
-            aControl = SMESH_Actor::eFreeEdges;
-            break;
-          case SMESHOp::OpFreeBorder:
-            aControl = SMESH_Actor::eFreeBorders;
-            break;
-          case SMESHOp::OpLength:
-            aControl = SMESH_Actor::eLength;
-            break;
-          case SMESHOp::OpConnection:
-            aControl = SMESH_Actor::eMultiConnection;
-            break;
-          case SMESHOp::OpEqualEdge:
-            aControl = SMESH_Actor::eCoincidentElems1D;
-            break;
-          case SMESHOp::OpFreeFace:
-            aControl = SMESH_Actor::eFreeFaces;
-            break;
-          case SMESHOp::OpBareBorderFace:
-            aControl = SMESH_Actor::eBareBorderFace;
-            break;
-          case SMESHOp::OpOverConstrainedFace:
-            aControl = SMESH_Actor::eOverConstrainedFace;
-            break;
-          case SMESHOp::OpLength2D:
-            aControl = SMESH_Actor::eLength2D;
-            break;
-          case SMESHOp::OpConnection2D:
-            aControl = SMESH_Actor::eMultiConnection2D;
-            break;
-          case SMESHOp::OpArea:
-            aControl = SMESH_Actor::eArea;
-            break;
-          case SMESHOp::OpTaper:
-            aControl = SMESH_Actor::eTaper;
-            break;
-          case SMESHOp::OpAspectRatio:
-            aControl = SMESH_Actor::eAspectRatio;
-            break;
-          case SMESHOp::OpMinimumAngle:
-            aControl = SMESH_Actor::eMinimumAngle;
-            break;
-          case SMESHOp::OpWarpingAngle:
-            aControl = SMESH_Actor::eWarping;
-            break;
-          case SMESHOp::OpSkew:
-            aControl = SMESH_Actor::eSkew;
-            break;
-          case SMESHOp::OpMaxElementLength2D:
-            aControl = SMESH_Actor::eMaxElementLength2D;
-            break;
-          case SMESHOp::OpEqualFace:
-            aControl = SMESH_Actor:: eCoincidentElems2D;
-            break;
-          case SMESHOp::OpAspectRatio3D:
-            aControl = SMESH_Actor::eAspectRatio3D;
-            break;
-          case SMESHOp::OpVolume:
-            aControl = SMESH_Actor::eVolume3D;
-            break;
-          case SMESHOp::OpMaxElementLength3D:
-            aControl = SMESH_Actor::eMaxElementLength3D;
-            break;
-          case SMESHOp::OpBareBorderVolume:
-            aControl = SMESH_Actor::eBareBorderVolume;
-            break;
-          case SMESHOp::OpOverConstrainedVolume:
-            aControl = SMESH_Actor::eOverConstrainedVolume;
-            break;
-          case SMESHOp::OpEqualVolume:
-            aControl = SMESH_Actor::eCoincidentElems3D;
-            break;
-          }
-
-          anActor->SetControlMode(aControl);
-          anActor->GetScalarBarActor()->SetTitle( functorToString( anActor->GetFunctor() ).toLatin1().constData() );
-          SMESH::RepaintCurrentView();
+      SALOME_ListIteratorOfListIO It(selected);
+      for ( ; It.More(); It.Next())
+      {
+        Handle(SALOME_InteractiveObject) anIO = It.Value();
+        if(!anIO.IsNull()){
+          _PTR(SObject) SO = aStudy->FindObjectID( It.Value()->getEntry() );
+          if ( SO ) {
+            CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
+            SMESH::SMESH_Mesh_var      aMesh    = SMESH::SMESH_Mesh::_narrow( aObject );
+            SMESH::SMESH_subMesh_var   aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
+            SMESH::SMESH_GroupBase_var aGroup   = SMESH::SMESH_GroupBase::_narrow( aObject );
+            if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
+              if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())) {
+                anActor->SetControlMode(aControl);
+                anActor->GetScalarBarActor()->SetTitle( functorToString( anActor->GetFunctor() ).toLatin1().constData() );
+                SMESH::RepaintCurrentView();
 #ifndef DISABLE_PLOT2DVIEWER
-          if(anActor->GetPlot2Histogram()) {
-            SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
-            QString functorName = functorToString( anActor->GetFunctor());
-            QString aHistogramName("%1 : %2");
-            aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
-            aHistogram->setName(aHistogramName);
-            aHistogram->setHorTitle(functorName);
-            SMESH::ProcessIn2DViewers(anActor);
-          }
+                if(anActor->GetPlot2Histogram()) {
+                  SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
+                  QString functorName = functorToString( anActor->GetFunctor());
+                  QString aHistogramName("%1 : %2");
+                  aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
+                  aHistogram->setName(aHistogramName);
+                  aHistogram->setHorTitle(functorName);
+                  SMESH::ProcessIn2DViewers(anActor);
+                }
 #endif
+              }
+            }
+          }
         }
       }
     }
@@ -3530,19 +3543,10 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
       LightApp_SelectionMgr* mgr = selectionMgr();
       SALOME_ListIO selected; mgr->selectedObjects( selected );
 
-      if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
-        _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
-        if ( SO ) {
-          CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
-          SMESH::SMESH_Mesh_var      aMesh    = SMESH::SMESH_Mesh::_narrow( aObject );
-          SMESH::SMESH_subMesh_var   aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
-          SMESH::SMESH_GroupBase_var aGroup   = SMESH::SMESH_GroupBase::_narrow( aObject );
-          if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
-            SUIT_OverrideCursor wc;
-            ::Control( theCommandID );
-            break;
-          }
-        }
+      if( !selected.IsEmpty() ) {
+        SUIT_OverrideCursor wc;
+        ::Control( theCommandID );
+        break;
       }
       SUIT_MessageBox::warning(desktop(),
                                tr( "SMESH_WRN_WARNING" ),
@@ -3927,6 +3931,23 @@ void SMESHGUI::initialize( CAM_Application* app )
 
   createSMESHAction( SMESHOp::OpSortChild, "SORT_CHILD_ITEMS" );
 
+  QList<int> aCtrlActions;
+  aCtrlActions << SMESHOp::OpFreeNode << SMESHOp::OpEqualNode                           // node controls
+               << SMESHOp::OpFreeEdge << SMESHOp::OpFreeBorder
+               << SMESHOp::OpLength << SMESHOp::OpConnection << SMESHOp::OpEqualEdge    // edge controls
+               << SMESHOp::OpFreeFace << SMESHOp::OpLength2D << SMESHOp::OpConnection2D
+               << SMESHOp::OpArea << SMESHOp::OpTaper << SMESHOp::OpAspectRatio
+               << SMESHOp::OpMinimumAngle << SMESHOp::OpWarpingAngle << SMESHOp::OpSkew
+               << SMESHOp::OpMaxElementLength2D << SMESHOp::OpBareBorderFace
+               << SMESHOp::OpOverConstrainedFace << SMESHOp::OpEqualFace                // face controls
+               << SMESHOp::OpAspectRatio3D << SMESHOp::OpVolume
+               << SMESHOp::OpMaxElementLength3D << SMESHOp::OpBareBorderVolume
+               << SMESHOp::OpOverConstrainedVolume << SMESHOp::OpEqualVolume;           // volume controls
+  QActionGroup* aCtrlGroup = new QActionGroup( application()->desktop() );
+  aCtrlGroup->setExclusive( true );
+  for( int i = 0; i < aCtrlActions.size(); i++ )
+    aCtrlGroup->addAction( action( aCtrlActions[i] ) );
+
   // ----- create menu --------------
   int fileId    = createMenu( tr( "MEN_FILE" ),    -1,  1 ),
       editId    = createMenu( tr( "MEN_EDIT" ),    -1,  3 ),
@@ -4031,6 +4052,8 @@ void SMESHGUI::initialize( CAM_Application* app )
   createMenu( SMESHOp::OpOverConstrainedVolume, volumeId, -1 );
   createMenu( SMESHOp::OpEqualVolume,           volumeId, -1 );
   createMenu( separator(),                      ctrlId,   -1 );
+  createMenu( SMESHOp::OpReset,                 ctrlId,   -1 );
+  createMenu( separator(),                      ctrlId,   -1 );
   createMenu( SMESHOp::OpOverallMeshQuality,    ctrlId,   -1 );
 
   createMenu( SMESHOp::OpNode,                   addId, -1 );
index 80ca0346658b215125ed614f352ff6779bbe1d81..94331c90156b446112fc6377a8cc3d36f5ab0afd 100644 (file)
@@ -80,8 +80,10 @@ void SMESHGUI_Selection::init( const QString& client, LightApp_SelectionMgr* mgr
       return;
     _PTR(Study) aStudy = aSStudy->studyDS();
 
-    for( int i=0, n=count(); i<n; i++ )
+    for( int i=0, n=count(); i<n; i++ ) {
       myTypes.append( typeName( type( entry( i ), aStudy ) ) );
+      myControls.append( controlMode( i ) );
+    }
   }
 }
 
@@ -122,7 +124,6 @@ QVariant SMESHGUI_Selection::parameter( const int ind, const QString& p ) const
   else if ( p=="labeledTypes" )         val = QVariant( labeledTypes( ind ) );
   else if ( p=="shrinkMode" )           val = QVariant( shrinkMode( ind ) );
   else if ( p=="entityMode" )           val = QVariant( entityMode( ind ) );
-  else if ( p=="controlMode" )          val = QVariant( controlMode( ind ) );
   else if ( p=="isNumFunctor" )         val = QVariant( isNumFunctor( ind ) );
   else if ( p=="displayMode" )          val = QVariant( displayMode( ind ) );
   else if ( p=="isComputable" )         val = QVariant( isComputable( ind ) );
@@ -143,6 +144,21 @@ QVariant SMESHGUI_Selection::parameter( const int ind, const QString& p ) const
     return LightApp_Selection::parameter( ind, p );
 }
 
+//=======================================================================
+//function : parameter
+//purpose  :
+//=======================================================================
+QVariant SMESHGUI_Selection::parameter( const QString& p ) const
+{
+  QVariant val;
+  if ( p=="controlMode" ) val = QVariant( controlMode() );
+
+  if ( val.isValid() )
+    return val;
+  else
+    return LightApp_Selection::parameter( p );
+}
+
 //=======================================================================
 //function : getVtkOwner
 //purpose  : 
@@ -318,6 +334,23 @@ QString SMESHGUI_Selection::controlMode( int ind ) const
   return mode;
 }
 
+//=======================================================================
+//function : controlMode
+//purpose  : gets global control mode; return SMESH_Actor::eControl
+//=======================================================================
+QString SMESHGUI_Selection::controlMode() const
+{
+  if( myControls.count() > 0 ) {
+    QString mode = myControls[0];
+    for( int ind = 1; ind < myControls.count(); ind++ ) {
+      if( mode != myControls[ind] )
+        return "eNone";
+    }
+    return mode;
+  }
+  return "eNone";
+}
+
 bool SMESHGUI_Selection::isNumFunctor( int ind ) const
 {
   bool result = false;
index 0a9d46ccc57805001321ad98643dfb61aca66a34..3ba1bf4cb3809c171ed491c8c565f1fb95a4e4fa 100644 (file)
@@ -49,6 +49,7 @@ public:
 
   virtual void            init( const QString&, LightApp_SelectionMgr* );
   virtual QVariant        parameter( const int, const QString& ) const;
+  virtual QVariant        parameter( const QString& ) const;
   virtual bool            processOwner( const LightApp_DataOwner* );
 
   // got from object, not from actor
@@ -74,6 +75,7 @@ public:
   virtual QString         shrinkMode( int ) const;
   virtual QList<QVariant> entityMode( int ) const;
   virtual QString         controlMode( int ) const;
+  virtual QString         controlMode() const;
   virtual bool            isNumFunctor( int ) const;
   virtual QString         facesOrientationMode( int ) const;
   virtual QString         groupType( int ) const;
@@ -87,6 +89,7 @@ public:
 
 private:
   QStringList             myTypes;
+  QStringList             myControls;
   QList<SMESH_Actor*>     myActors;
 };