From: ouv Date: Thu, 25 Mar 2010 13:55:29 +0000 (+0000) Subject: Issue 0020613: EDF 1106 : Modify Node Marker in SMESH and VISU X-Git-Tag: V5_1_4a1~16 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4d33eed28b1bdb0f38eacdf021205fbf40a13693;p=modules%2Fsmesh.git Issue 0020613: EDF 1106 : Modify Node Marker in SMESH and VISU --- diff --git a/doc/salome/gui/SMESH/images/colors_size.png b/doc/salome/gui/SMESH/images/colors_size.png new file mode 100755 index 000000000..58210c0bc Binary files /dev/null and b/doc/salome/gui/SMESH/images/colors_size.png differ diff --git a/doc/salome/gui/SMESH/images/custom_point_marker.png b/doc/salome/gui/SMESH/images/custom_point_marker.png new file mode 100755 index 000000000..a46e33ed9 Binary files /dev/null and b/doc/salome/gui/SMESH/images/custom_point_marker.png differ diff --git a/doc/salome/gui/SMESH/images/point_marker_widget1.png b/doc/salome/gui/SMESH/images/point_marker_widget1.png new file mode 100755 index 000000000..13b8e6dab Binary files /dev/null and b/doc/salome/gui/SMESH/images/point_marker_widget1.png differ diff --git a/doc/salome/gui/SMESH/images/point_marker_widget2.png b/doc/salome/gui/SMESH/images/point_marker_widget2.png new file mode 100755 index 000000000..dbb81b40e Binary files /dev/null and b/doc/salome/gui/SMESH/images/point_marker_widget2.png differ diff --git a/doc/salome/gui/SMESH/images/std_point_marker.png b/doc/salome/gui/SMESH/images/std_point_marker.png new file mode 100755 index 000000000..2a6269309 Binary files /dev/null and b/doc/salome/gui/SMESH/images/std_point_marker.png differ diff --git a/doc/salome/gui/SMESH/input/colors_size.doc b/doc/salome/gui/SMESH/input/colors_size.doc new file mode 100644 index 000000000..aa244579b --- /dev/null +++ b/doc/salome/gui/SMESH/input/colors_size.doc @@ -0,0 +1,35 @@ +/*! + +\page colors_size_page Colors / Size + +\image html colors_size.png + +Using this dialog you can define the following set of mesh visualization +parameters: + + +*/ \ No newline at end of file diff --git a/doc/salome/gui/SMESH/input/point_marker.doc b/doc/salome/gui/SMESH/input/point_marker.doc new file mode 100644 index 000000000..c298893ef --- /dev/null +++ b/doc/salome/gui/SMESH/input/point_marker.doc @@ -0,0 +1,53 @@ +/*! + +\page point_marker_page Point Marker + +\n You can change the representation of points in +the 3D viewer either by selecting one of the predefined +shapes or by loading a custom texture from an external file. + +- Standard point markers + +The Mesh module provides a set of predefined point marker shapes +which can be used to display points in 3D viewer. +Each standard point marker has two attributes: type (defines shape +form) and scale factor (defines shape size). + +\image html point_marker_widget1.png + +
+ +\image html std_point_marker.png "Mesh presentation with standard point markers" + +- Custom point markers + +It is also possible to load a point marker shape from an external file. +This file should provide a description of the point texture as a set +of lines; each line is represented as sequence of "0" and "1" symbols, +where "1" symbol means an opaque pixel and "0" symbol means a +transparent pixel. The width of the texture correspond to the length +of the longest line in the file, expanded to the nearest byte-aligned +value. The height of the texture is equal to the number of non-empty +lines in the file. Note that missing symbols are replaced by "0". + +Here is a texture file sample: + +
+00111100
+00111100
+11111111
+11111111
+11111111
+11111111
+00111100
+00111100
+
+ +\image html point_marker_widget2.png + +
+ +\image html custom_point_marker.png "Mesh presentation with custom point markers" + +*/ + diff --git a/doc/salome/gui/SMESH/input/viewing_meshes_overview.doc b/doc/salome/gui/SMESH/input/viewing_meshes_overview.doc index 9039b9365..207c4dda5 100644 --- a/doc/salome/gui/SMESH/input/viewing_meshes_overview.doc +++ b/doc/salome/gui/SMESH/input/viewing_meshes_overview.doc @@ -40,7 +40,7 @@ of quadratic edges as broken lines or as arcs faces of the selected mesh. Vector is shown for each 2D mesh element and for each free face of 3D mesh element. Vector direction is calculated by the first three nodes of face as a cross product of vectors n1-n2 and n1-n3. -
  • Colors / Size - allows to select color and size of +
  • \subpage colors_size_page "Colors / Size" - allows to select color and size of meshes.
  • \subpage transparency_page "Transparency" - allows to change the transparency of mesh elements.
  • diff --git a/resources/SalomeApp.xml b/resources/SalomeApp.xml index 5aa23f063..690895886 100644 --- a/resources/SalomeApp.xml +++ b/resources/SalomeApp.xml @@ -33,7 +33,8 @@ - + + diff --git a/src/OBJECT/SMESH_Actor.cxx b/src/OBJECT/SMESH_Actor.cxx index 16d71448f..cef45817b 100644 --- a/src/OBJECT/SMESH_Actor.cxx +++ b/src/OBJECT/SMESH_Actor.cxx @@ -86,7 +86,6 @@ static int MYDEBUG = 0; #endif static int aLineWidthInc = 2; -static int aPointSizeInc = 2; SMESH_ActorDef* SMESH_ActorDef::New(){ @@ -129,7 +128,6 @@ SMESH_ActorDef::SMESH_ActorDef() if ( mgr && mgr->booleanValue( "SMESH", "use_precision", false ) ) myControlsPrecision = mgr->integerValue( "SMESH", "controls_precision", -1); - vtkFloatingPointType aPointSize = SMESH::GetFloat("SMESH:node_size",3); vtkFloatingPointType aElem0DSize = SMESH::GetFloat("SMESH:elem0d_size",5); vtkFloatingPointType aLineWidth = SMESH::GetFloat("SMESH:element_width",1); @@ -224,7 +222,7 @@ SMESH_ActorDef::SMESH_ActorDef() my1DProp = vtkProperty::New(); my1DProp->DeepCopy(myEdgeProp); my1DProp->SetLineWidth(aLineWidth + aLineWidthInc); - my1DProp->SetPointSize(aPointSize); + my1DProp->SetPointSize(aElem0DSize); my1DExtProp = vtkProperty::New(); my1DExtProp->DeepCopy(myEdgeProp); @@ -233,7 +231,7 @@ SMESH_ActorDef::SMESH_ActorDef() anRGB[2] = 1 - anRGB[2]; my1DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); my1DExtProp->SetLineWidth(aLineWidth + aLineWidthInc); - my1DExtProp->SetPointSize(aPointSize + aPointSizeInc); + my1DExtProp->SetPointSize(aElem0DSize); my1DExtActor = SMESH_DeviceActor::New(); my1DExtActor->SetUserMatrix(aMatrix); @@ -294,7 +292,6 @@ SMESH_ActorDef::SMESH_ActorDef() myNodeProp = vtkProperty::New(); SMESH::GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 0 ) ); myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); - myNodeProp->SetPointSize(aPointSize); myNodeActor = SMESH_DeviceActor::New(); myNodeActor->SetUserMatrix(aMatrix); @@ -312,7 +309,6 @@ SMESH_ActorDef::SMESH_ActorDef() anRGB[1] = 1 - anRGB[1]; anRGB[2] = 1 - anRGB[2]; myNodeExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); - myNodeExtProp->SetPointSize(aPointSize); myNodeExtActor = SMESH_DeviceActor::New(); myNodeExtActor->SetUserMatrix(aMatrix); @@ -342,8 +338,7 @@ SMESH_ActorDef::SMESH_ActorDef() myHighlightProp->SetSpecular(0.0); SMESH::GetColor( "SMESH", "selection_object_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) ); myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); - //myHighlightProp->SetPointSize(aPointSize); - myHighlightProp->SetPointSize(std::max(aElem0DSize,aPointSize)); // ?? + myHighlightProp->SetPointSize(aElem0DSize); // ?? myHighlightProp->SetRepresentation(1); myPreselectProp = vtkProperty::New(); @@ -352,8 +347,7 @@ SMESH_ActorDef::SMESH_ActorDef() myPreselectProp->SetSpecular(0.0); SMESH::GetColor( "SMESH", "highlight_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 255 ) ); myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); - //myPreselectProp->SetPointSize(aPointSize); - myPreselectProp->SetPointSize(std::max(aElem0DSize,aPointSize)); // ?? + myPreselectProp->SetPointSize(aElem0DSize); // ?? myPreselectProp->SetRepresentation(1); myHighlitableActor = SMESH_DeviceActor::New(); @@ -1012,6 +1006,10 @@ bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj, if( dynamic_cast( myVisualObj.get() ) ) SetIsDisplayNameActor( true ); + int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot + int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 ); // 5 pixels + SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale ); + myTimeStamp->Modified(); Modified(); return true; @@ -1219,15 +1217,15 @@ void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){ my0DActor->VisibilityOn(); } - if(myEntityMode & eEdges){ + if(myEntityMode & eEdges && GetRepresentation() != ePoint){ my1DActor->VisibilityOn(); } - if(myEntityMode & eFaces){ + if(myEntityMode & eFaces && GetRepresentation() != ePoint){ my2DActor->VisibilityOn(); } - if(myEntityMode & eVolumes){ + if(myEntityMode & eVolumes && GetRepresentation() != ePoint){ my3DActor->VisibilityOn(); } @@ -1508,6 +1506,12 @@ void SMESH_ActorDef::UpdateHighlight(){ SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints); myHighlitableActor->SetVisibility(anIsVisible); myHighlitableActor->SetRepresentation(SMESH_DeviceActor::ePoint); + + VTK::MarkerType aMarkerType = GetMarkerType(); + if(aMarkerType != VTK::MT_USER) + myHighlitableActor->SetMarkerStd(aMarkerType, GetMarkerScale()); + else + myHighlitableActor->SetMarkerTexture(GetMarkerTexture(), myMarkerTexture); } } } @@ -1712,35 +1716,8 @@ void SMESH_ActorDef::SetLineWidth(vtkFloatingPointType theVal){ } -void SMESH_ActorDef::SetNodeSize(vtkFloatingPointType theVal){ - myNodeProp->SetPointSize(theVal); - myNodeExtProp->SetPointSize(theVal); - - vtkFloatingPointType aPointSize = my0DProp->GetPointSize() > theVal ? my0DProp->GetPointSize() : theVal; - //myHighlightProp->SetPointSize(theVal); - myHighlightProp->SetPointSize(aPointSize); // ?? - //myPreselectProp->SetPointSize(theVal); - myPreselectProp->SetPointSize(aPointSize); // ?? - - my1DProp->SetPointSize(theVal + aPointSizeInc); - my1DExtProp->SetPointSize(theVal + aPointSizeInc); - - Modified(); -} - -vtkFloatingPointType SMESH_ActorDef::GetNodeSize(){ - return myNodeProp->GetPointSize(); -} - void SMESH_ActorDef::Set0DSize(vtkFloatingPointType theVal){ my0DProp->SetPointSize(theVal); - - vtkFloatingPointType aPointSize = myNodeProp->GetPointSize() > theVal ? myNodeProp->GetPointSize() : theVal; - //myHighlightProp->SetPointSize(theVal); - myHighlightProp->SetPointSize(aPointSize); // ?? - //myPreselectProp->SetPointSize(theVal); - myPreselectProp->SetPointSize(aPointSize); // ?? - Modified(); } @@ -2049,3 +2026,18 @@ SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresenta else return SMESH_Actor::eLines; } + +void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale ) +{ + SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale ); + myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale ); + myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale ); +} + +void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture ) +{ + SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture ); + myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture ); + myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture ); + myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor +} diff --git a/src/OBJECT/SMESH_Actor.h b/src/OBJECT/SMESH_Actor.h index fee096c57..6b724cc9e 100644 --- a/src/OBJECT/SMESH_Actor.h +++ b/src/OBJECT/SMESH_Actor.h @@ -72,9 +72,6 @@ class SMESHOBJECT_EXPORT SMESH_Actor: public SALOME_Actor virtual vtkFloatingPointType GetLineWidth() = 0; virtual void SetLineWidth(vtkFloatingPointType theVal) = 0; - virtual void SetNodeSize(vtkFloatingPointType size) = 0; - virtual vtkFloatingPointType GetNodeSize() = 0; - virtual void Set0DSize(vtkFloatingPointType size) = 0; virtual vtkFloatingPointType Get0DSize() = 0; diff --git a/src/OBJECT/SMESH_ActorDef.h b/src/OBJECT/SMESH_ActorDef.h index 559ffd630..186eee6d8 100644 --- a/src/OBJECT/SMESH_ActorDef.h +++ b/src/OBJECT/SMESH_ActorDef.h @@ -127,9 +127,6 @@ class SMESH_ActorDef : public SMESH_Actor virtual vtkFloatingPointType GetLineWidth(); virtual void SetLineWidth(vtkFloatingPointType theVal); - virtual void SetNodeSize(vtkFloatingPointType size) ; - virtual vtkFloatingPointType GetNodeSize() ; - virtual void Set0DSize(vtkFloatingPointType size); virtual vtkFloatingPointType Get0DSize(); @@ -209,6 +206,9 @@ class SMESH_ActorDef : public SMESH_Actor virtual void SetQuadratic2DRepresentation(EQuadratic2DRepresentation); virtual EQuadratic2DRepresentation GetQuadratic2DRepresentation(); + virtual void SetMarkerStd( VTK::MarkerType, VTK::MarkerScale ); + virtual void SetMarkerTexture( int, VTK::MarkerTexture ); + protected: void SetControlMode(eControl theMode, bool theCheckEntityMode); void SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed); @@ -283,6 +283,8 @@ class SMESH_ActorDef : public SMESH_Actor bool myIsFacesOriented; + VTK::MarkerTexture myMarkerTexture; + SMESH_ActorDef(); ~SMESH_ActorDef(); diff --git a/src/OBJECT/SMESH_DeviceActor.cxx b/src/OBJECT/SMESH_DeviceActor.cxx index f7d455ddb..4bbb7e6d5 100644 --- a/src/OBJECT/SMESH_DeviceActor.cxx +++ b/src/OBJECT/SMESH_DeviceActor.cxx @@ -31,6 +31,7 @@ #include "SMESH_ActorUtils.h" #include "SMESH_FaceOrientationFilter.h" #include "VTKViewer_CellLocationsArray.h" +#include "VTKViewer_PolyDataMapper.h" #include #include @@ -88,7 +89,7 @@ SMESH_DeviceActor myRepresentation = eSurface; myProperty = vtkProperty::New(); - myMapper = vtkPolyDataMapper::New(); + myMapper = VTKViewer_PolyDataMapper::New(); vtkMapper::GetResolveCoincidentTopologyPolygonOffsetParameters(myPolygonOffsetFactor, myPolygonOffsetUnits); @@ -703,6 +704,7 @@ SMESH_DeviceActor myGeomFilter->SetWireframeMode(false); GetProperty()->SetRepresentation(theMode); } + SetMarkerEnabled(theMode == ePoint); myRepresentation = theMode; UpdateFaceOrientation(); GetProperty()->Modified(); @@ -901,3 +903,58 @@ void SMESH_DeviceActor::SetQuadraticArcAngle(vtkFloatingPointType theMaxAngle){ vtkFloatingPointType SMESH_DeviceActor::GetQuadraticArcAngle(){ return myGeomFilter->GetQuadraticArcAngle(); } + +/*! + * Set point marker enabled + * \param theMarkerEnabled flag to enable/disable point marker + */ +void SMESH_DeviceActor::SetMarkerEnabled( bool theMarkerEnabled ) +{ + myMapper->SetMarkerEnabled( theMarkerEnabled ); +} + +/*! + * Set standard point marker + * \param theMarkerType type of the marker + */ +void SMESH_DeviceActor::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale ) +{ + myMapper->SetMarkerStd( theMarkerType, theMarkerScale ); +} + +/*! + * Set custom point marker + * \param theMarkerId id of the marker texture + * \param theMarkerTexture marker texture + */ +void SMESH_DeviceActor::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture ) +{ + myMapper->SetMarkerTexture( theMarkerId, theMarkerTexture ); +} + +/*! + * Get type of the point marker + * \return type of the point marker + */ +VTK::MarkerType SMESH_DeviceActor::GetMarkerType() +{ + return myMapper->GetMarkerType(); +} + +/*! + Get scale of the point marker + \return scale of the point marker +*/ +VTK::MarkerScale SMESH_DeviceActor::GetMarkerScale() +{ + return myMapper->GetMarkerScale(); +} + +/*! + * Get texture identifier of the point marker + * \return texture identifier of the point marker + */ +int SMESH_DeviceActor::GetMarkerTexture() +{ + return myMapper->GetMarkerTexture(); +} diff --git a/src/OBJECT/SMESH_DeviceActor.h b/src/OBJECT/SMESH_DeviceActor.h index 8b2fd6bf7..eb4c45b49 100644 --- a/src/OBJECT/SMESH_DeviceActor.h +++ b/src/OBJECT/SMESH_DeviceActor.h @@ -29,6 +29,7 @@ #define SMESH_DEVICE_ACTOR_H #include +#include #include "SMESH_Controls.hxx" #include "SMESH_Object.h" @@ -39,7 +40,6 @@ class vtkCell; class vtkProperty; class vtkMergeFilter; class vtkShrinkFilter; -class vtkPolyDataMapper; class vtkUnstructuredGrid; class vtkScalarBarActor; class vtkLookupTable; @@ -49,6 +49,7 @@ class vtkPassThroughFilter; class VTKViewer_Transform; class VTKViewer_TransformFilter; class VTKViewer_ExtractUnstructuredGrid; +class VTKViewer_PolyDataMapper; class SMESH_ExtractGeometry; class SMESH_FaceOrientationFilter; @@ -133,11 +134,18 @@ class SMESHOBJECT_EXPORT SMESH_DeviceActor: public vtkLODActor{ void SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed); bool IsImplicitFunctionUsed() const{ return myIsImplicitFunctionUsed;} + void SetMarkerEnabled( bool ); + void SetMarkerStd( VTK::MarkerType, VTK::MarkerScale ); + void SetMarkerTexture( int, VTK::MarkerTexture ); + VTK::MarkerType GetMarkerType(); + VTK::MarkerScale GetMarkerScale(); + int GetMarkerTexture(); + protected: void Init(TVisualObjPtr theVisualObj, vtkImplicitBoolean* theImplicitBoolean); void SetUnstructuredGrid(vtkUnstructuredGrid* theGrid); - vtkPolyDataMapper *myMapper; + VTKViewer_PolyDataMapper *myMapper; TVisualObjPtr myVisualObj; vtkProperty *myProperty; diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index e8c832b83..1ccc5cc65 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -153,7 +153,7 @@ void ExportMeshToFile(int theCommandID); - void SetDisplayMode(int theCommandID); + void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap); void SetDisplayEntity(int theCommandID); @@ -716,7 +716,7 @@ } } - void SetDisplayMode(int theCommandID){ + void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap){ SALOME_ListIO selected; SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); if( !app ) @@ -814,7 +814,6 @@ int Edgewidth = (int)anActor->GetLineWidth(); if(Edgewidth == 0) Edgewidth = 1; - int intValue = int(anActor->GetNodeSize()); vtkFloatingPointType Shrink = anActor->GetShrinkFactor(); vtkFloatingPointType faces_orientation_color[3]; @@ -836,11 +835,21 @@ aDlg->SetColor(5, c0D); aDlg->SetColor(6, o); aDlg->SetIntValue(1, Edgewidth); - aDlg->SetIntValue(2, intValue); - aDlg->SetIntValue(3, int(Shrink*100.)); - aDlg->SetIntValue(4, size0D); + aDlg->SetIntValue(2, int(Shrink*100.)); + aDlg->SetIntValue(3, size0D); aDlg->SetDoubleValue(1, faces_orientation_scale); aDlg->SetBooleanValue(1, faces_orientation_3dvectors); + + aDlg->setCustomMarkerMap( theMarkerMap[ aStudy->StudyId() ] ); + + VTK::MarkerType aMarkerTypeCurrent = anActor->GetMarkerType(); + VTK::MarkerScale aMarkerScaleCurrent = anActor->GetMarkerScale(); + int aMarkerTextureCurrent = anActor->GetMarkerTexture(); + if( aMarkerTypeCurrent != VTK::MT_USER ) + aDlg->setStandardMarker( aMarkerTypeCurrent, aMarkerScaleCurrent ); + else + aDlg->setCustomMarker( aMarkerTextureCurrent ); + if(aDlg->exec()){ QColor color = aDlg->GetColor(1); QColor edgecolor = aDlg->GetColor(2); @@ -862,20 +871,19 @@ vtkFloatingPointType (edgecolor.blue()) / 255.); /* Shrink factor and size edges */ - anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.); + anActor->SetShrinkFactor(aDlg->GetIntValue(2) / 100.); anActor->SetLineWidth(aDlg->GetIntValue(1)); /* Nodes color and size */ anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255., vtkFloatingPointType (nodecolor.green()) / 255., vtkFloatingPointType (nodecolor.blue()) / 255.); - anActor->SetNodeSize(aDlg->GetIntValue(2)); /* 0D elements */ anActor->Set0DColor(vtkFloatingPointType (color0D.red()) / 255., vtkFloatingPointType (color0D.green()) / 255., vtkFloatingPointType (color0D.blue()) / 255.); - anActor->Set0DSize(aDlg->GetIntValue(4)); + anActor->Set0DSize(aDlg->GetIntValue(3)); /* Faces orientation */ vtkFloatingPointType c[3] = {vtkFloatingPointType(faces_orientation_color.redF()), @@ -885,6 +893,21 @@ anActor->SetFacesOrientationScale(aDlg->GetDoubleValue(1)); anActor->SetFacesOrientation3DVectors(aDlg->GetBooleanValue(1)); + /* Point marker */ + theMarkerMap[ aStudy->StudyId() ] = aDlg->getCustomMarkerMap(); + + VTK::MarkerType aMarkerTypeNew = aDlg->getMarkerType(); + VTK::MarkerScale aMarkerScaleNew = aDlg->getStandardMarkerScale(); + int aMarkerTextureNew = aDlg->getCustomMarkerID(); + if( aMarkerTypeNew != VTK::MT_USER ) + anActor->SetMarkerStd( aMarkerTypeNew, aMarkerScaleNew ); + else { + const VTK::MarkerMap& aMarkerMap = theMarkerMap[ aStudy->StudyId() ]; + VTK::MarkerMap::const_iterator anIter = aMarkerMap.find( aMarkerTextureNew ); + if( anIter != aMarkerMap.end() ) + anActor->SetMarkerTexture( aMarkerTextureNew, anIter->second.second ); + } + SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface(IObject); if( !aGroupObject->_is_nil() ) { @@ -1618,13 +1641,13 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) case 213: // Nodes case 212: // Nodes case 211: // Nodes - ::SetDisplayMode(theCommandID); + ::SetDisplayMode(theCommandID, myMarkerMap); break; //2D quadratic representation case 231: case 232: - ::SetDisplayMode(theCommandID); + ::SetDisplayMode(theCommandID, myMarkerMap); break; // Display Entity @@ -3797,13 +3820,34 @@ void SMESHGUI::createPreferences() // Mesh tab ------------------------------------------------------------------------ int meshTab = addPreference( tr( "PREF_TAB_MESH" ) ); int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab ); - setPreferenceProperty( nodeGroup, "columns", 2 ); + setPreferenceProperty( nodeGroup, "columns", 3 ); addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" ); - int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, LightApp_Preferences::IntSpin, "SMESH", "node_size" ); - setPreferenceProperty( nodeSz, "min", 1 ); - setPreferenceProperty( nodeSz, "max", 5 ); + int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" ); + + SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this); + QList aMarkerTypeIndicesList; + QList aMarkerTypeIconsList; + for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) { + QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i ); + QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) ); + aMarkerTypeIndicesList << i; + aMarkerTypeIconsList << pixmap; + } + setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList ); + setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList ); + + int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" ); + + QList aMarkerScaleIndicesList; + QStringList aMarkerScaleValuesList; + for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) { + aMarkerScaleIndicesList << i; + aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 ); + } + setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList ); + setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList ); int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab ); setPreferenceProperty( elemGroup, "columns", 2 ); @@ -4213,6 +4257,7 @@ SALOMEDS::Color SMESHGUI::getUniqueColor( const QList& theReser const char gSeparator = '_'; // character used to separate parameter names const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b) +const char gPathSep = '|'; // character used to separate paths /*! * \brief Store visual parameters @@ -4238,6 +4283,39 @@ void SMESHGUI::storeVisualParameters (int savePoint) savePoint); _PTR(IParameters) ip = ClientFactory::getIParameters(ap); + // store map of custom markers + const VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ]; + if( !aMarkerMap.empty() ) + { + VTK::MarkerMap::const_iterator anIter = aMarkerMap.begin(); + for( ; anIter != aMarkerMap.end(); anIter++ ) + { + int anId = anIter->first; + VTK::MarkerData aMarkerData = anIter->second; + std::string aMarkerFileName = aMarkerData.first; + VTK::MarkerTexture aMarkerTexture = aMarkerData.second; + if( aMarkerTexture.size() < 3 ) + continue; // should contain at least width, height and the first value + + QString aPropertyName( "texture" ); + aPropertyName += gSeparator; + aPropertyName += QString::number( anId ); + + QString aPropertyValue = aMarkerFileName.c_str(); + aPropertyValue += gPathSep; + + VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin(); + ushort aWidth = *aTextureIter++; + ushort aHeight = *aTextureIter++; + aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep; + aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep; + for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ ) + aPropertyValue += QString::number( *aTextureIter ); + + ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() ); + } + } + // viewers counters are used for storing view_numbers in IParameters int vtkViewers = 0; @@ -4345,14 +4423,32 @@ void SMESHGUI::storeVisualParameters (int savePoint) // Sizes of lines and points QString sizeStr ("line"); sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetLineWidth()); - sizeStr += gDigitsSep; sizeStr += "node"; - sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetNodeSize()); sizeStr += gDigitsSep; sizeStr += "shrink"; sizeStr += gDigitsSep; sizeStr += QString::number(aSmeshActor->GetShrinkFactor()); param = vtkParam + "Sizes"; ip->setParameter(entry, param, sizeStr.toLatin1().data()); + // Point marker + QString markerStr; + + VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType(); + if( aMarkerType == VTK::MT_USER ) { + markerStr += "custom"; + markerStr += gDigitsSep; + markerStr += QString::number( aSmeshActor->GetMarkerTexture() ); + } + else { + markerStr += "std"; + markerStr += gDigitsSep; + markerStr += QString::number( (int)aMarkerType ); + markerStr += gDigitsSep; + markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() ); + } + + param = vtkParam + "PointMarker"; + ip->setParameter(entry, param, markerStr.toLatin1().data()); + // Opacity param = vtkParam + "Opacity"; ip->setParameter(entry, param, @@ -4411,6 +4507,63 @@ void SMESHGUI::restoreVisualParameters (int savePoint) savePoint); _PTR(IParameters) ip = ClientFactory::getIParameters(ap); + // restore map of custom markers + VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ]; + + std::vector properties = ip->getProperties(); + for (std::vector::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt) + { + std::string property = *propIt; + QString aPropertyName( property.c_str() ); + QString aPropertyValue( ip->getProperty( property ).c_str() ); + + QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts ); + if( aPropertyNameList.size() != 2 ) + continue; + + int anId = 0; + bool ok = false; + if( aPropertyNameList[0] == "texture" ) + anId = aPropertyNameList[1].toInt( &ok ); + + if( !ok || anId < 1 ) + continue; + + QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts ); + if( aPropertyValueList.size() != 2 ) + continue; + + std::string aMarkerFileName = aPropertyValueList[0].toStdString(); + QString aMarkerTextureString = aPropertyValueList[1]; + QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts ); + if( aMarkerTextureStringList.size() != 3 ) + continue; + + ok = false; + ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok ); + if( !ok ) + continue; + + ok = false; + ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok ); + if( !ok ) + continue; + + VTK::MarkerTexture aMarkerTexture; + aMarkerTexture.push_back( aWidth ); + aMarkerTexture.push_back( aHeight ); + + QString aMarkerTextureData = aMarkerTextureStringList[2]; + for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ ) + { + QChar aChar = aMarkerTextureData.at( i ); + if( aChar.isDigit() ) + aMarkerTexture.push_back( aChar.digitValue() ); + } + + aMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture ); + } + std::vector entries = ip->getEntries(); for (std::vector::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt) @@ -4557,18 +4710,49 @@ void SMESHGUI::restoreVisualParameters (int savePoint) // Sizes of lines and points else if (paramNameStr == "Sizes") { QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts); - if (sizes.count() == 6) { + if (sizes.count() == 4) { + if (sizes[0] != "line" || sizes[2] != "shrink") { + MESSAGE("Invalid order of data in Sizes, must be: " + "line:int:shrink:float"); + } + else { + aSmeshActor->SetLineWidth(sizes[1].toInt()); + aSmeshActor->SetShrinkFactor(sizes[3].toFloat()); + } + } + else if (sizes.count() == 6) { // just to support old format if (sizes[0] != "line" || sizes[2] != "node" || sizes[4] != "shrink") { MESSAGE("Invalid order of data in Sizes, must be: " "line:int:node:int:shrink:float"); } else { aSmeshActor->SetLineWidth(sizes[1].toInt()); - aSmeshActor->SetNodeSize(sizes[3].toInt()); + //aSmeshActor->SetNodeSize(sizes[3].toInt()); // made obsolete aSmeshActor->SetShrinkFactor(sizes[5].toFloat()); } } } + // Point marker + else if (paramNameStr == "PointMarker") { + QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts); + if( data.count() >= 2 ) { + bool ok = false; + int aParam1 = data[1].toInt( &ok ); + if( ok ) { + if( data[0] == "std" && data.count() == 3 ) { + int aParam2 = data[2].toInt( &ok ); + aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 ); + } + else if( data[0] == "custom" ) { + VTK::MarkerMap::const_iterator markerIt = aMarkerMap.find( aParam1 ); + if( markerIt != aMarkerMap.end() ) { + VTK::MarkerData aMarkerData = markerIt->second; + aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second ); + } + } + } + } + } // Opacity else if (paramNameStr == "Opacity") { aSmeshActor->SetOpacity(val.toFloat()); diff --git a/src/SMESHGUI/SMESHGUI.h b/src/SMESHGUI/SMESHGUI.h index 66ac986ec..6b9036e72 100644 --- a/src/SMESHGUI/SMESHGUI.h +++ b/src/SMESHGUI/SMESHGUI.h @@ -31,6 +31,7 @@ // SALOME GUI includes #include +#include #include // IDL includes @@ -52,6 +53,8 @@ class LightApp_SelectionMgr; class SMESHGUI_FilterLibraryDlg; +typedef std::map SMESHGUI_StudyId2MarkerMap; + //================================================================================= // class : SMESHGUI // purpose : @@ -166,6 +169,8 @@ private : LightApp_Displayer* myDisplayer; SMESHGUI_FilterLibraryDlg* myFilterLibraryDlg; + + SMESHGUI_StudyId2MarkerMap myMarkerMap; }; #endif // SMESHGUI_H diff --git a/src/SMESHGUI/SMESHGUI_Preferences_ColorDlg.cxx b/src/SMESHGUI/SMESHGUI_Preferences_ColorDlg.cxx index 7e0981d63..3b86bb27e 100644 --- a/src/SMESHGUI/SMESHGUI_Preferences_ColorDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_Preferences_ColorDlg.cxx @@ -34,6 +34,7 @@ #include #include #include +#include // Qt includes #include @@ -124,24 +125,26 @@ SMESHGUI_Preferences_ColorDlg::SMESHGUI_Preferences_ColorDlg( SMESHGUI* theModul // ------------------------------- QGroupBox* ButtonGroup2 = new QGroupBox( tr( "Nodes" ), this ); - QHBoxLayout* ButtonGroup2Layout = new QHBoxLayout( ButtonGroup2 ); + QGridLayout* ButtonGroup2Layout = new QGridLayout( ButtonGroup2 ); ButtonGroup2Layout->setSpacing( SPACING ); ButtonGroup2Layout->setMargin( MARGIN ); QLabel* TextLabel_Nodes_Color = new QLabel( tr( "Color" ), ButtonGroup2 ); btnNodeColor = new QtxColorButton( ButtonGroup2 ); - QLabel* TextLabel_Nodes_Size = new QLabel( tr( "Size" ), ButtonGroup2 ); - SpinBox_Nodes_Size = new QSpinBox( ButtonGroup2 ); - SpinBox_Nodes_Size->setRange( 0, 5 ); - SpinBox_Nodes_Size->setSingleStep( 1 ); - SpinBox_Nodes_Size->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - SpinBox_Nodes_Size->setButtonSymbols( QSpinBox::PlusMinus ); + QGroupBox* MarkerGroup = new QGroupBox( tr( "Marker" ), ButtonGroup2 ); + QVBoxLayout* MarkerGroupLayout = new QVBoxLayout( MarkerGroup ); + MarkerGroupLayout->setSpacing( 0 ); + MarkerGroupLayout->setMargin( 0 ); - ButtonGroup2Layout->addWidget( TextLabel_Nodes_Color ); - ButtonGroup2Layout->addWidget( btnNodeColor ); - ButtonGroup2Layout->addWidget( TextLabel_Nodes_Size ); - ButtonGroup2Layout->addWidget( SpinBox_Nodes_Size ); + MarkerWidget = new VTKViewer_MarkerWidget( MarkerGroup ); + + MarkerGroupLayout->addWidget( MarkerWidget ); + + ButtonGroup2Layout->addWidget( TextLabel_Nodes_Color, 0, 0 ); + ButtonGroup2Layout->addWidget( btnNodeColor, 0, 1 ); + ButtonGroup2Layout->addWidget( MarkerGroup, 1, 0, 1, 3 ); + ButtonGroup2Layout->setColumnStretch( 2, 1 ); // ------------------------------- QGroupBox* ButtonGroup3 = new QGroupBox( tr( "Orientation of faces" ), this ); @@ -304,9 +307,8 @@ void SMESHGUI_Preferences_ColorDlg::SetIntValue( int type, int value ) { switch ( type ) { case 1 : SpinBox_Width->setValue( value ); break; // width - case 2 : SpinBox_Nodes_Size->setValue( value ); break; // nodes size = value; break; - case 3 : SpinBox_Shrink->setValue( value ); break; // shrink coeff - case 4 : SpinBox_0DElements_Size->setValue( value ); break; // 0d elements + case 2 : SpinBox_Shrink->setValue( value ); break; // shrink coeff + case 3 : SpinBox_0DElements_Size->setValue( value ); break; // 0d elements default: break; } } @@ -320,9 +322,8 @@ int SMESHGUI_Preferences_ColorDlg::GetIntValue( int type ) int res = 0; switch ( type ) { case 1 : res = SpinBox_Width->value(); break; // width - case 2 : res = SpinBox_Nodes_Size->value(); break; // nodes size - case 3 : res = SpinBox_Shrink->value(); break; // shrink coeff - case 4 : res = SpinBox_0DElements_Size->value(); break; // 0d elements + case 2 : res = SpinBox_Shrink->value(); break; // shrink coeff + case 3 : res = SpinBox_0DElements_Size->value(); break; // 0d elements default: break; } return res; @@ -379,3 +380,67 @@ bool SMESHGUI_Preferences_ColorDlg::GetBooleanValue( int type ) } return res; } + +//================================================================================= +// function : setCustomMarkerMap() +// purpose : +//================================================================================= +void SMESHGUI_Preferences_ColorDlg::setCustomMarkerMap( VTK::MarkerMap theMarkerMap ) +{ + MarkerWidget->setCustomMarkerMap( theMarkerMap ); +} + +//================================================================================= +// function : getCustomMarkerMap() +// purpose : +//================================================================================= +VTK::MarkerMap SMESHGUI_Preferences_ColorDlg::getCustomMarkerMap() +{ + return MarkerWidget->getCustomMarkerMap(); +} + +//================================================================================= +// function : setStandardMarker() +// purpose : +//================================================================================= +void SMESHGUI_Preferences_ColorDlg::setStandardMarker( VTK::MarkerType theMarkerType, + VTK::MarkerScale theMarkerScale ) +{ + MarkerWidget->setStandardMarker( theMarkerType, theMarkerScale ); +} + +//================================================================================= +// function : setCustomMarker() +// purpose : +//================================================================================= +void SMESHGUI_Preferences_ColorDlg::setCustomMarker( int theId ) +{ + MarkerWidget->setCustomMarker( theId ); +} + +//================================================================================= +// function : getMarkerType() +// purpose : +//================================================================================= +VTK::MarkerType SMESHGUI_Preferences_ColorDlg::getMarkerType() const +{ + return MarkerWidget->getMarkerType(); +} + +//================================================================================= +// function : getStandardMarkerScale() +// purpose : +//================================================================================= +VTK::MarkerScale SMESHGUI_Preferences_ColorDlg::getStandardMarkerScale() const +{ + return MarkerWidget->getStandardMarkerScale(); +} + +//================================================================================= +// function : getCustomMarkerID() +// purpose : +//================================================================================= +int SMESHGUI_Preferences_ColorDlg::getCustomMarkerID() const +{ + return MarkerWidget->getCustomMarkerID(); +} diff --git a/src/SMESHGUI/SMESHGUI_Preferences_ColorDlg.h b/src/SMESHGUI/SMESHGUI_Preferences_ColorDlg.h index 5b23b4e6b..cf899f3ad 100644 --- a/src/SMESHGUI/SMESHGUI_Preferences_ColorDlg.h +++ b/src/SMESHGUI/SMESHGUI_Preferences_ColorDlg.h @@ -29,6 +29,9 @@ // SMESH includes #include "SMESH_SMESHGUI.hxx" +// SALOME GUI includes +#include + // Qt includes #include @@ -38,6 +41,7 @@ class SMESHGUI; class QtxDoubleSpinBox; class QtxIntSpinBox; class QtxColorButton; +class VTKViewer_MarkerWidget; class SMESHGUI_EXPORT SMESHGUI_Preferences_ColorDlg : public QDialog { @@ -56,6 +60,15 @@ public: void SetBooleanValue( int, bool ); bool GetBooleanValue( int ); + void setCustomMarkerMap( VTK::MarkerMap ); + VTK::MarkerMap getCustomMarkerMap(); + + void setStandardMarker( VTK::MarkerType, VTK::MarkerScale ); + void setCustomMarker( int ); + VTK::MarkerType getMarkerType() const; + VTK::MarkerScale getStandardMarkerScale() const; + int getCustomMarkerID() const; + protected: void closeEvent( QCloseEvent* ); @@ -76,7 +89,7 @@ private: QSpinBox* SpinBox_Width; QtxIntSpinBox* SpinBox_Shrink; QtxColorButton* btnNodeColor; - QSpinBox* SpinBox_Nodes_Size; + VTKViewer_MarkerWidget* MarkerWidget; QtxColorButton* btnOrientationColor; QtxDoubleSpinBox* SpinBox_Orientation_Scale; QCheckBox* CheckBox_Orientation_3DVectors; diff --git a/src/SMESHGUI/SMESHGUI_VTKUtils.cxx b/src/SMESHGUI/SMESHGUI_VTKUtils.cxx index ba884ff79..afcea77ca 100644 --- a/src/SMESHGUI/SMESHGUI_VTKUtils.cxx +++ b/src/SMESHGUI/SMESHGUI_VTKUtils.cxx @@ -822,10 +822,9 @@ namespace SMESH PW = mgr->integerValue( "SMESH", "highlight_width", 5 ); // adjust highlight_width to the width of mesh entities - int aPointSize = mgr->integerValue("SMESH", "node_size", 3); int aElem0DSize = mgr->integerValue("SMESH", "elem0d_size", 5); int aLineWidth = mgr->integerValue("SMESH", "element_width", 1); - int maxSize = aPointSize; + int maxSize = aElem0DSize; if (aElem0DSize > maxSize) maxSize = aElem0DSize; if (aLineWidth > maxSize) maxSize = aLineWidth; if (PW < maxSize + 2) PW = maxSize + 2; diff --git a/src/SMESHGUI/SMESH_msg_en.ts b/src/SMESHGUI/SMESH_msg_en.ts index 5aa706b4b..7d6253610 100644 --- a/src/SMESHGUI/SMESH_msg_en.ts +++ b/src/SMESHGUI/SMESH_msg_en.ts @@ -3278,6 +3278,10 @@ Please, create VTK viewer and try again PREF_LABELS_COLOR Labels color + + PREF_MARKER_SCALE + Scale of marker + PREF_NODES Nodes @@ -3310,10 +3314,6 @@ Please, create VTK viewer and try again PREF_SHRINK_COEFF Shrink coef. - - PREF_SIZE - Size - PREF_TAB_GENERAL General @@ -3330,6 +3330,10 @@ Please, create VTK viewer and try again PREF_TITLE_COLOR Title color + + PREF_TYPE_OF_MARKER + Type of marker + PREF_COLOR_0D 0D elements