]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
Implementation of the issue 20115: [CEA 308] Quadratic elements visualization.
authorrnv <rnv@opencascade.com>
Wed, 27 May 2009 11:25:25 +0000 (11:25 +0000)
committerrnv <rnv@opencascade.com>
Wed, 27 May 2009 11:25:25 +0000 (11:25 +0000)
src/OBJECT/SMESH_Actor.cxx
src/OBJECT/SMESH_Actor.h
src/OBJECT/SMESH_ActorDef.h
src/OBJECT/SMESH_DeviceActor.cxx
src/OBJECT/SMESH_DeviceActor.h
src/SMESHGUI/SMESHGUI.cxx
src/SMESHGUI/SMESHGUI_Selection.cxx
src/SMESHGUI/SMESHGUI_Selection.h
src/SMESHGUI/SMESH_msg_en.ts

index 0bd5e0dac8283b447a1918b01d7aa8fc2d1a2d37..9291df37ccd4e5d21f0cfd93bd3d72eaef36d7a5 100644 (file)
@@ -126,7 +126,7 @@ SMESH_ActorDef::SMESH_ActorDef()
 
   vtkFloatingPointType aPointSize = SMESH::GetFloat("SMESH:node_size",3);
   vtkFloatingPointType aLineWidth = SMESH::GetFloat("SMESH:element_width",1);
-
+  
   vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
   VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
 
@@ -417,7 +417,27 @@ SMESH_ActorDef::SMESH_ActorDef()
   // Clipping planes
   myImplicitBoolean = vtkImplicitBoolean::New();
   myImplicitBoolean->SetOperationTypeToIntersection();
+  
+
 
+  //Quadratic 2D elements representation
+  //-----------------------------------------------------------------------------
+  int aQuadratic2DMode = mgr->integerValue( "SMESH", "quadratic_mode", 0);
+  if(aQuadratic2DMode == 0){
+    myHighlitableActor->SetQuadraticArcMode(false);
+    my2DActor->SetQuadraticArcMode(false);
+    my1DActor->SetQuadraticArcMode(false);
+  }
+  else if(aQuadratic2DMode == 1){
+    myHighlitableActor->SetQuadraticArcMode(true);
+    my2DActor->SetQuadraticArcMode(true);
+    my1DActor->SetQuadraticArcMode(true);
+  }
+  
+  int aQuadraticAngle = mgr->integerValue( "SMESH", "max_angle", 2);
+  myHighlitableActor->SetQuadraticArcAngle(aQuadraticAngle);
+  my2DActor->SetQuadraticArcAngle(aQuadraticAngle);
+  
   // Set color of the name actor
   SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
   myNameActor->SetBackgroundColor(anRGB[0], anRGB[1], anRGB[2]);
@@ -506,8 +526,9 @@ SMESH_ActorDef::~SMESH_ActorDef()
 
 
 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
-{
+{    
   vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
+    
   myIsPointsLabeled = theIsPointsLabeled && aGrid->GetNumberOfPoints();
 
   if ( myIsPointsLabeled )
@@ -1215,11 +1236,12 @@ void SMESH_ActorDef::SetRepresentation(int theMode){
   myNodeExtActor->SetVisibility(false);
   vtkProperty *aProp = NULL, *aBackProp = NULL;
   SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
+  SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
   switch(myRepresentation){
   case ePoint:
     myPickableActor = myNodeActor;
     myNodeActor->SetVisibility(true);
-    
+    aQuadraticMode = SMESH_Actor::eLines;
     aProp = aBackProp = myNodeProp;
     aReperesent = SMESH_DeviceActor::ePoint;
     break;
@@ -1238,6 +1260,11 @@ void SMESH_ActorDef::SetRepresentation(int theMode){
   my2DActor->SetBackfaceProperty(aBackProp);
   my2DActor->SetRepresentation(aReperesent);
 
+  if(aQuadraticMode == SMESH_Actor::eLines)
+    my2DActor->SetQuadraticArcMode(false);
+  else if(aQuadraticMode == SMESH_Actor::eArcs)
+    my2DActor->SetQuadraticArcMode(true);
+
   my2DExtActor->SetRepresentation(aReperesent);
   
   my3DActor->SetProperty(aProp);
@@ -1256,6 +1283,12 @@ void SMESH_ActorDef::SetRepresentation(int theMode){
     break;
   }
   
+  if(aQuadraticMode == SMESH_Actor::eLines)
+    my1DActor->SetQuadraticArcMode(false);
+  else if(aQuadraticMode == SMESH_Actor::eArcs)
+    my1DActor->SetQuadraticArcMode(true);
+  
+  
   my1DActor->SetProperty(aProp);
   my1DActor->SetBackfaceProperty(aBackProp);
   my1DActor->SetRepresentation(aReperesent);
@@ -1785,3 +1818,32 @@ void SMESH_ActorDef::UpdateScalarBar()
   myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
   
 }
+
+void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
+{
+  switch(theMode) {
+  case SMESH_Actor::eLines :
+    myHighlitableActor->SetQuadraticArcMode(false);
+    my2DActor->SetQuadraticArcMode(false);
+    my1DActor->SetQuadraticArcMode(false);
+    break;
+  case SMESH_Actor::eArcs :
+    myHighlitableActor->SetQuadraticArcMode(true);
+    if(GetRepresentation() != SMESH_Actor::ePoint) {
+      my2DActor->SetQuadraticArcMode(true);
+      my1DActor->SetQuadraticArcMode(true);
+    }
+    break;
+  default:
+    break;
+  }
+}
+
+
+SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
+{
+  if(myHighlitableActor->GetQuadraticArcMode())
+    return SMESH_Actor::eArcs;
+  else
+    return SMESH_Actor::eLines;
+}
index df02e86e4cbc29efb6decab87ea841ad233a6e82..111b55c164dcd2da8c98267a2205ffced62b08ec 100644 (file)
@@ -75,9 +75,15 @@ class SMESHOBJECT_EXPORT SMESH_Actor: public SALOME_Actor
   enum EReperesent { ePoint, eEdge, eSurface};
   
   enum EEntityMode { eEdges = 0x01, eFaces = 0x02, eVolumes = 0x04, eAllEntity = 0x07};
+
+  enum EQuadratic2DRepresentation { eLines = 0x01, eArcs = 0x02 };
+
   virtual void SetEntityMode(unsigned int theMode) = 0;
   virtual unsigned int GetEntityMode() const = 0;
 
+  virtual void SetQuadratic2DRepresentation(EQuadratic2DRepresentation) = 0;
+  virtual EQuadratic2DRepresentation GetQuadratic2DRepresentation() = 0;
+
   virtual void SetPointRepresentation(bool theIsPointsVisible) = 0;
   virtual bool GetPointRepresentation() = 0;
 
index 619f0096a7f8dc60fbaf999ae4e062cdcf645398..1dbb7435cd8f703692e31813d45348504ad57381 100644 (file)
@@ -189,6 +189,10 @@ class SMESH_ActorDef : public SMESH_Actor
   virtual long GetControlsPrecision() const { return myControlsPrecision; }
 
   virtual void UpdateScalarBar();
+
+
+  virtual void SetQuadratic2DRepresentation(EQuadratic2DRepresentation);
+  virtual EQuadratic2DRepresentation GetQuadratic2DRepresentation();
   
  protected:
   void SetControlMode(eControl theMode, bool theCheckEntityMode);
index 19e3451cac17516c98206eb7ebeca0921c5ea6b6..2a657eb34b87da6fb05ff0a9413aa0f1db403d74 100644 (file)
@@ -834,3 +834,29 @@ SMESH_DeviceActor
   myPolygonOffsetUnits = units;
 }
 
+/*!
+ * On/Off representation 2D quadratic element as arked polygon
+ */
+void SMESH_DeviceActor::SetQuadraticArcMode(bool theFlag){
+  myGeomFilter->SetQuadraticArcMode(theFlag);
+}
+
+/*!
+ * Return true if 2D quadratic element displayed as arked polygon
+ */
+bool SMESH_DeviceActor::GetQuadraticArcMode(){
+  return myGeomFilter->GetQuadraticArcMode();
+}
+/*!
+ * Set Max angle for representation 2D quadratic element as arked polygon
+ */
+void SMESH_DeviceActor::SetQuadraticArcAngle(vtkFloatingPointType theMaxAngle){
+  myGeomFilter->SetQuadraticArcAngle(theMaxAngle);
+}
+
+/*!
+ * Return Max angle of the representation 2D quadratic element as arked polygon
+ */
+vtkFloatingPointType SMESH_DeviceActor::GetQuadraticArcAngle(){
+  return myGeomFilter->GetQuadraticArcAngle();
+}
index 5a6169a95f3bb0f03c4c19cf7101fde21fa2f4bc..2180501608adc7c77d4990b34fd98b0c19e6c979 100644 (file)
@@ -77,6 +77,14 @@ class SMESHOBJECT_EXPORT SMESH_DeviceActor: public vtkLODActor{
   virtual void SetFacesOriented(bool theIsFacesOriented);
   virtual bool GetFacesOriented() { return myIsFacesOriented; }
 
+  //----------------------------------------------------------------------------
+  //! Setting for displaying quadratic elements
+  virtual void SetQuadraticArcMode(bool theFlag);
+  virtual bool GetQuadraticArcMode();
+  
+  virtual void SetQuadraticArcAngle(vtkFloatingPointType theMaxAngle);
+  virtual vtkFloatingPointType GetQuadraticArcAngle();
+  
   void UpdateFaceOrientation();
 
   vtkFloatingPointType GetShrinkFactor();
index 1e32987caaaaf34a4044103df4fd8686ba92b53d..e21fb81dc11bc0135736dd6b75d61838a2ad60fd 100644 (file)
            case 215:
              anActor->SetRepresentation(SMESH_Actor::ePoint);
              break;
+            case 231:
+              if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
+                anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
+              break;
+            case 232:
+              if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
+                anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
+              break;
            case 1132:{
              vtkFloatingPointType color[3];
              anActor->GetSufaceColor(color[0], color[1], color[2]);
@@ -1443,7 +1451,13 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
     ::SetDisplayMode(theCommandID);
   break;
 
-    // Display Entity
+  //2D quadratic representation
+  case 231:
+  case 232:
+    ::SetDisplayMode(theCommandID);
+  break;
+  
+  // Display Entity
   case 217: // Edges
   case 218: // Faces
   case 219: // Volumes
@@ -2743,6 +2757,10 @@ void SMESHGUI::initialize( CAM_Application* app )
   createSMESHAction(  219, "VOLUMES",        "ICON_DLG_TETRAS", 0, true );
   createSMESHAction(  220, "ALL" );
   createSMESHAction(  221, "FACE_ORIENTATION", "", 0, true );
+
+  createSMESHAction(  231, "LINE_REPRESENTATION", "", 0, true );
+  createSMESHAction(  232, "ARC_REPRESENTATION", "", 0, true );
+
   createSMESHAction( 1100, "EDIT_HYPO" );
   createSMESHAction( 1101, "RENAME", "", Qt::Key_F2 );
   createSMESHAction( 1102, "UNASSIGN" );
@@ -3188,7 +3206,7 @@ void SMESHGUI::initialize( CAM_Application* app )
     aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
 
   anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
-
+  
   popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
   popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
 
@@ -3270,6 +3288,21 @@ void SMESHGUI::initialize( CAM_Application* app )
 
   popupMgr()->insert( separator(), -1, -1 );
 
+
+  //-------------------------------------------------
+  // Representation of the 2D Quadratic elements
+  //-------------------------------------------------  
+  anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
+  popupMgr()->insert( action( 231 ), anId, -1 ); // LINE REPRESENTATION
+  popupMgr()->setRule( action( 231 ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule );
+  popupMgr()->setRule( action( 231 ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
+  
+  popupMgr()->insert( action( 232 ), anId, -1 ); // ARC REPRESENTATION
+  popupMgr()->setRule( action( 232 ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule );
+  popupMgr()->setRule( action( 232 ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
+  
+  popupMgr()->insert( separator(), -1, -1 );
+  
   //-------------------------------------------------
   // Display / Erase
   //-------------------------------------------------
@@ -3469,6 +3502,25 @@ void SMESHGUI::createPreferences()
   setPreferenceProperty( dispmode, "strings", modes );
   setPreferenceProperty( dispmode, "indexes", indices );
 
+  int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
+  setPreferenceProperty( arcgroup, "columns", 2 );
+  int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
+  QStringList quadraticModes;
+  quadraticModes.append("Lines");
+  quadraticModes.append("Arcs");
+  indices.clear();
+  indices.append( 0 );
+  indices.append( 1 );
+  setPreferenceProperty( quadraticmode, "strings", quadraticModes );
+  setPreferenceProperty( quadraticmode, "indexes", indices );
+
+  int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
+                              "SMESH", "max_angle" );
+  setPreferenceProperty( maxAngle, "min", 1 );
+  setPreferenceProperty( maxAngle, "max", 90 );
+  
+  
+
   int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
   setPreferenceProperty( exportgroup, "columns", 2 );
   addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
index c37d3559f7be5d6b2cf152e32092c4fe9eea1e6f..e49ee940bb652633b988135094f627a8d0690661 100644 (file)
@@ -117,6 +117,7 @@ QVariant SMESHGUI_Selection::parameter( const int ind, const QString& p ) const
   else if ( p=="isImported" )    val = QVariant( isImported( ind ) );
   else if ( p=="facesOrientationMode" ) val = QVariant( facesOrientationMode( ind ) );
   else if ( p=="groupType" )     val = QVariant( groupType( ind ) );
+  else if ( p=="quadratic2DMode") val =  QVariant(quadratic2DMode(ind));
 
   if( val.isValid() )
     return val;
@@ -192,6 +193,24 @@ QString SMESHGUI_Selection::displayMode( int ind ) const
   return "Unknown";
 }
 
+
+//=======================================================================
+//function : quadratic2DMode
+//purpose  : return SMESH_Actor::EQuadratic2DRepresentation
+//=======================================================================
+QString SMESHGUI_Selection::quadratic2DMode( int ind ) const
+{
+  SMESH_Actor* actor = getActor( ind );
+  if ( actor ) {
+    switch( actor->GetQuadratic2DRepresentation() ) {
+    case SMESH_Actor::eLines:    return "eLines";
+    case SMESH_Actor::eArcs: return "eArcs";
+    default: break;
+    }
+  }
+  return "Unknown";
+}
+
 //=======================================================================
 //function : shrinkMode
 //purpose  : return either 'IsSrunk', 'IsNotShrunk' or 'IsNotShrinkable'
@@ -548,3 +567,4 @@ QString SMESHGUI_Selection::groupType( int ind ) const
   }
   return type;
 }
+
index 72ed58cb4cff0e9cc0926018eed6839a3f41f17d..e1b1cc2df9385f1e2583af04190f7422dba2b6ca 100644 (file)
@@ -57,6 +57,8 @@ public:
   virtual QVariant        hasReference( int ) const;
   virtual QVariant        isVisible( int ) const;
 
+  virtual QString         quadratic2DMode(int ) const;
+
   // parameters got from actor return nothing if an actor is not visible
   virtual QList<QVariant> elemTypes( int ) const;
   virtual QList<QVariant> labeledTypes( int ) const;
index 5dc4629bc74633149b4e7a61c8ef5f42bc47c3c0..3668a6aac9284264c9003ebcfdf701cdbe52089a 100644 (file)
             <source>MEN_SHADE</source>
             <translation>Shading</translation>
         </message>
+        <message>
+            <source>MEN_QUADRATIC_REPRESENT</source>
+            <translation>2D Quadratic</translation>
+        </message>
+        <message>
+            <source>MEN_LINE_REPRESENTATION</source>
+            <translation>Lines</translation>
+        </message>
+        <message>
+            <source>MEN_ARC_REPRESENTATION</source>
+            <translation>Arcs</translation>
+        </message>
         <message>
             <source>MEN_SHOW</source>
             <translation>Show</translation>
@@ -2968,6 +2980,14 @@ Please, create VTK viewer and try again</translation>
             <translation>Display entity</translation>
         </message>
         <message>
+            <source>QUADRATIC_REPRESENT_MODE</source>
+            <translation>Representation of the 2D quadratic elements</translation>
+        </message>
+        <message>
+            <source>MAX_ARC_ANGLE</source>
+            <translation>Maximum angle</translation>
+        </message>
+       <message>
             <source>PREF_DISPLAY_MODE</source>
             <translation>Display mode</translation>
         </message>