From: rnv Date: Wed, 27 May 2009 11:25:25 +0000 (+0000) Subject: Implementation of the issue 20115: [CEA 308] Quadratic elements visualization. X-Git-Tag: V5_1_2rc1~8 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c66c06508b5678be76d5b17c40c14ebd0fb4614f;p=modules%2Fsmesh.git Implementation of the issue 20115: [CEA 308] Quadratic elements visualization. --- diff --git a/src/OBJECT/SMESH_Actor.cxx b/src/OBJECT/SMESH_Actor.cxx index 0bd5e0dac..9291df37c 100644 --- a/src/OBJECT/SMESH_Actor.cxx +++ b/src/OBJECT/SMESH_Actor.cxx @@ -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; +} diff --git a/src/OBJECT/SMESH_Actor.h b/src/OBJECT/SMESH_Actor.h index df02e86e4..111b55c16 100644 --- a/src/OBJECT/SMESH_Actor.h +++ b/src/OBJECT/SMESH_Actor.h @@ -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; diff --git a/src/OBJECT/SMESH_ActorDef.h b/src/OBJECT/SMESH_ActorDef.h index 619f0096a..1dbb7435c 100644 --- a/src/OBJECT/SMESH_ActorDef.h +++ b/src/OBJECT/SMESH_ActorDef.h @@ -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); diff --git a/src/OBJECT/SMESH_DeviceActor.cxx b/src/OBJECT/SMESH_DeviceActor.cxx index 19e3451ca..2a657eb34 100644 --- a/src/OBJECT/SMESH_DeviceActor.cxx +++ b/src/OBJECT/SMESH_DeviceActor.cxx @@ -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(); +} diff --git a/src/OBJECT/SMESH_DeviceActor.h b/src/OBJECT/SMESH_DeviceActor.h index 5a6169a95..218050160 100644 --- a/src/OBJECT/SMESH_DeviceActor.h +++ b/src/OBJECT/SMESH_DeviceActor.h @@ -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(); diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index 1e32987ca..e21fb81dc 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -644,6 +644,14 @@ 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" ); diff --git a/src/SMESHGUI/SMESHGUI_Selection.cxx b/src/SMESHGUI/SMESHGUI_Selection.cxx index c37d3559f..e49ee940b 100644 --- a/src/SMESHGUI/SMESHGUI_Selection.cxx +++ b/src/SMESHGUI/SMESHGUI_Selection.cxx @@ -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; } + diff --git a/src/SMESHGUI/SMESHGUI_Selection.h b/src/SMESHGUI/SMESHGUI_Selection.h index 72ed58cb4..e1b1cc2df 100644 --- a/src/SMESHGUI/SMESHGUI_Selection.h +++ b/src/SMESHGUI/SMESHGUI_Selection.h @@ -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 elemTypes( int ) const; virtual QList labeledTypes( int ) const; diff --git a/src/SMESHGUI/SMESH_msg_en.ts b/src/SMESHGUI/SMESH_msg_en.ts index 5dc4629bc..3668a6aac 100644 --- a/src/SMESHGUI/SMESH_msg_en.ts +++ b/src/SMESHGUI/SMESH_msg_en.ts @@ -549,6 +549,18 @@ MEN_SHADE Shading + + MEN_QUADRATIC_REPRESENT + 2D Quadratic + + + MEN_LINE_REPRESENTATION + Lines + + + MEN_ARC_REPRESENTATION + Arcs + MEN_SHOW Show @@ -2968,6 +2980,14 @@ Please, create VTK viewer and try again Display entity + QUADRATIC_REPRESENT_MODE + Representation of the 2D quadratic elements + + + MAX_ARC_ANGLE + Maximum angle + + PREF_DISPLAY_MODE Display mode