Salome HOME
0020095: EDF 896 SMESH : Advanced Mesh info on a group
[modules/smesh.git] / src / StdMeshersGUI / StdMeshersGUI_StdHypothesisCreator.cxx
index cdcdcc8f1cad9a5284eaa72fb0eec2270238390c..43563ea4593f41387b49a5356493ac8abebb08b2 100644 (file)
@@ -33,6 +33,8 @@
 #include <SMESH_NumberFilter.hxx>
 #include "StdMeshersGUI_ObjectReferenceParamWdg.h"
 #include "StdMeshersGUI_LayerDistributionParamWdg.h"
+//#include "StdMeshersGUI_EdgeDirectionParamWdg.h"
+#include "StdMeshersGUI_SubShapeSelectorWdg.h"
 #include <SALOMEDSClient_Study.hxx>
 
 // SALOME GUI includes
@@ -444,10 +446,20 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
       StdMeshers::StdMeshers_Arithmetic1D_var h =
        StdMeshers::StdMeshers_Arithmetic1D::_narrow( hypothesis() );
 
-      h->SetLength( params[0].myValue.toDouble(), true );
+      //StdMeshersGUI_EdgeDirectionParamWdg* w = 
+      //  widget< StdMeshersGUI_EdgeDirectionParamWdg >( 2 );
+      StdMeshersGUI_SubShapeSelectorWdg* w = 
+        widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 );
+
+      h->SetStartLength( params[0].myValue.toDouble() );
       h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList));
-      h->SetLength( params[1].myValue.toDouble(), false );
+      h->SetEndLength( params[1].myValue.toDouble() );
       h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList));
+      if (w) {
+       h->SetReversedEdges( w->GetListOfIDs() );
+       const char * entry = w->GetMainShapeEntry();
+       h->SetObjectEntry( entry );
+      }
     }
     else if( hypType()=="MaxElementArea" )
     {
@@ -469,10 +481,17 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
       StdMeshers::StdMeshers_StartEndLength_var h =
        StdMeshers::StdMeshers_StartEndLength::_narrow( hypothesis() );
 
-      h->SetLength( params[0].myValue.toDouble(), true );
+      StdMeshersGUI_SubShapeSelectorWdg* w = 
+        widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 );
+
+      h->SetStartLength( params[0].myValue.toDouble() );
       h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList));
-      h->SetLength( params[1].myValue.toDouble(), false );
+      h->SetEndLength( params[1].myValue.toDouble() );
       h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList));
+      if (w) {
+       h->SetReversedEdges( w->GetListOfIDs() );
+       h->SetObjectEntry( w->GetMainShapeEntry() );
+      }
     }
     else if( hypType()=="Deflection1D" )
     {
@@ -541,6 +560,20 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
                                geomFromWdg ( getWidgetForParam( 3 )), // tgt1
                                geomFromWdg ( getWidgetForParam( 5 ))); // tgt2
     }
+    else if( hypType()=="QuadrangleParams" )
+    {
+      StdMeshers::StdMeshers_QuadrangleParams_var h =
+       StdMeshers::StdMeshers_QuadrangleParams::_narrow( hypothesis() );
+      StdMeshersGUI_SubShapeSelectorWdg* w = 
+        widget< StdMeshersGUI_SubShapeSelectorWdg >( 0 );
+      if (w) {
+       if( w->GetListOfIDs()->length()>0 ) {
+         h->SetTriaVertex( w->GetListOfIDs()[0] );
+       }
+       const char * entry = w->GetMainShapeEntry();
+       h->SetObjectEntry( entry );
+      }
+    }
   }
   return valueStr;
 }
@@ -650,10 +683,29 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
       item.myValue = h->GetLength( true );
     p.append( item );
 
+    customWidgets()->append (0);
+
     item.myName = tr( "SMESH_END_LENGTH_PARAM" );
     if(!initVariableName(aParameters,item,1))
       item.myValue = h->GetLength( false );
     p.append( item );
+
+    customWidgets()->append (0);
+
+    item.myName = tr( "SMESH_REVERCE_EDGES" );
+    p.append( item );
+
+    //StdMeshersGUI_EdgeDirectionParamWdg* aDirectionWidget =
+    //  new StdMeshersGUI_EdgeDirectionParamWdg();
+    StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
+      new StdMeshersGUI_SubShapeSelectorWdg();
+    QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
+    if ( anEntry == "" )
+      anEntry = h->GetObjectEntry();
+    aDirectionWidget->SetMainShapeEntry( anEntry );
+    aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
+    aDirectionWidget->showPreview( true );
+    customWidgets()->append ( aDirectionWidget );
   }
   else if( hypType()=="MaxElementArea" )
   {
@@ -686,12 +738,29 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
     if(!initVariableName(aParameters,item,0)) 
       item.myValue = h->GetLength( true );
     p.append( item );
+    customWidgets()->append(0);
 
     item.myName = tr( "SMESH_END_LENGTH_PARAM" );
     if(!initVariableName(aParameters,item,1)) 
       item.myValue = h->GetLength( false );
     p.append( item );
-    
+    customWidgets()->append(0);
+
+    item.myName = tr( "SMESH_REVERCE_EDGES" );
+    p.append( item );
+
+    //StdMeshersGUI_EdgeDirectionParamWdg* aDirectionWidget =
+    //  new StdMeshersGUI_EdgeDirectionParamWdg();
+    StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
+      new StdMeshersGUI_SubShapeSelectorWdg();
+    QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
+    if ( anEntry == "" )
+      anEntry = h->GetObjectEntry();
+    aDirectionWidget->SetMainShapeEntry( anEntry );
+    aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
+    aDirectionWidget->SetMainShapeEntry( h->GetObjectEntry() );
+    aDirectionWidget->showPreview( true );
+    customWidgets()->append ( aDirectionWidget );
   }
   else if( hypType()=="Deflection1D" )
   {
@@ -808,6 +877,32 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
                                                h->GetTargetVertex( 2 )));
   }
+  else if( hypType()=="QuadrangleParams" )
+  {
+    StdMeshers::StdMeshers_QuadrangleParams_var h =
+      StdMeshers::StdMeshers_QuadrangleParams::_narrow( hyp );
+
+    item.myName = tr( "SMESH_BASE_VERTEX" );
+    p.append( item );
+
+    StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
+      new StdMeshersGUI_SubShapeSelectorWdg();
+    aDirectionWidget->SetMaxSize(1);
+    aDirectionWidget->SetSubShType(TopAbs_VERTEX);
+    QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
+    if ( anEntry == "" )
+      anEntry = h->GetObjectEntry();
+    aDirectionWidget->SetMainShapeEntry( anEntry );
+    SMESH::long_array_var aVec = new SMESH::long_array;
+    int vertID = h->GetTriaVertex();
+    if(vertID>0) {
+      aVec->length(1);
+      aVec[0] = vertID;
+    }
+    aDirectionWidget->SetListOfIDs( aVec );
+    aDirectionWidget->showPreview( true );
+    customWidgets()->append ( aDirectionWidget );
+  }
   else
     res = false;
   return res;
@@ -928,6 +1023,7 @@ QString StdMeshersGUI_StdHypothesisCreator::hypTypeName( const QString& t ) cons
     types.insert( "LayerDistribution", "LAYER_DISTRIBUTION" );
     types.insert( "SegmentLengthAroundVertex", "SEGMENT_LENGTH_AROUND_VERTEX" );
     types.insert( "MaxLength", "MAX_LENGTH" );
+    types.insert( "QuadrangleParams", "QUADRANGLE_PARAMS" );
   }
 
   QString res;
@@ -1000,6 +1096,20 @@ bool StdMeshersGUI_StdHypothesisCreator::getParamFromCustomWidget( StdParam & pa
     param.myValue = w->GetValue();
     return true;
   }
+  //if ( widget->inherits( "StdMeshersGUI_EdgeDirectionParamWdg" ))
+  //{
+  //  const StdMeshersGUI_EdgeDirectionParamWdg * w =
+  //    static_cast<const StdMeshersGUI_EdgeDirectionParamWdg*>( widget );
+  //  param.myValue = w->GetValue();
+  //  return true;
+  //}
+  if ( widget->inherits( "StdMeshersGUI_SubShapeSelectorWdg" ))
+  {
+    const StdMeshersGUI_SubShapeSelectorWdg * w =
+      static_cast<const StdMeshersGUI_SubShapeSelectorWdg*>( widget );
+    param.myValue = w->GetValue();
+    return true;
+  }
   return false;
 }