--- /dev/null
+/*!
+
+\page colors_size_page Colors / Size
+
+\image html colors_size.png
+
+Using this dialog you can define the following set of mesh visualization
+parameters:
+<ul>
+<li><b>Elements</b></li>
+<ul>
+<li><b>Fill</b> - color of surface of elements (seen in Shading mode).</li>
+<li><b>Back Face</b> - color of interior surface of elements.</li>
+<li><b>Outline</b> - color of borders of elements.</li>
+<li><b>0D slements</b> - color of 0D elements.</li>
+<li><b>Size of 0D slements</b> - size of 0D elements.</li>
+<li><b>Width</b> - width of lines (edges and borders of elements).</li>
+<li><b>Shrink coef.</b> - relative space of elements compared to gaps between
+ them in shrink mode.</li>
+</ul>
+<li><b>Nodes</b></li>
+<ul>
+<li><b>Color</b> - color of nodes.</li>
+<li><b>Marker</b> - group of options allowing to change the representation of
+ points (see \subpage point_marker_page "Point Marker" page).</li>
+</ul>
+<li><b>Orientation of faces</b></li>
+<ul>
+<li><b>Color</b> - color of orientation vertors.</li>
+<li><b>Scale</b> - size of orientation vectors.</li>
+<li><b>3D vectors</b> - allows to choose between 2D planar and 3D vectors.</li>
+</ul>
+</ul>
+
+*/
\ No newline at end of file
--- /dev/null
+/*!
+
+\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
+
+<br>
+
+\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:
+
+<pre>
+00111100
+00111100
+11111111
+11111111
+11111111
+11111111
+00111100
+00111100
+</pre>
+
+\image html point_marker_widget2.png
+
+<br>
+
+\image html custom_point_marker.png "Mesh presentation with custom point markers"
+
+*/
+
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.</li>
-<li><b>Colors / Size</b> - allows to select color and size of
+<li>\subpage colors_size_page "Colors / Size" - allows to select color and size of
meshes.</li>
<li>\subpage transparency_page "Transparency" - allows to change the
transparency of mesh elements.</li>
<parameter name="backface_color" value="0, 0, 255"/>
<parameter name="elem0d_color" value="0, 255, 0"/>
<parameter name="highlight_color" value="0, 255, 255"/>
- <parameter name="node_size" value="3" />
+ <parameter name="type_of_marker" value="1" />
+ <parameter name="marker_scale" value="9" />
<parameter name="elem0d_size" value="5" />
<parameter name="element_width" value="1" />
<parameter name="shrink_coeff" value="75"/>
#endif
static int aLineWidthInc = 2;
-static int aPointSizeInc = 2;
SMESH_ActorDef* SMESH_ActorDef::New(){
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);
my1DProp = vtkProperty::New();
my1DProp->DeepCopy(myEdgeProp);
my1DProp->SetLineWidth(aLineWidth + aLineWidthInc);
- my1DProp->SetPointSize(aPointSize);
+ my1DProp->SetPointSize(aElem0DSize);
my1DExtProp = vtkProperty::New();
my1DExtProp->DeepCopy(myEdgeProp);
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);
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);
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);
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();
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();
if( dynamic_cast<SMESH_GroupObj*>( 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;
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();
}
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);
}
}
}
}
-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();
}
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
+}
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;
virtual vtkFloatingPointType GetLineWidth();
virtual void SetLineWidth(vtkFloatingPointType theVal);
- virtual void SetNodeSize(vtkFloatingPointType size) ;
- virtual vtkFloatingPointType GetNodeSize() ;
-
virtual void Set0DSize(vtkFloatingPointType size);
virtual vtkFloatingPointType Get0DSize();
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);
bool myIsFacesOriented;
+ VTK::MarkerTexture myMarkerTexture;
+
SMESH_ActorDef();
~SMESH_ActorDef();
#include "SMESH_ActorUtils.h"
#include "SMESH_FaceOrientationFilter.h"
#include "VTKViewer_CellLocationsArray.h"
+#include "VTKViewer_PolyDataMapper.h"
#include <VTKViewer_Transform.h>
#include <VTKViewer_TransformFilter.h>
myRepresentation = eSurface;
myProperty = vtkProperty::New();
- myMapper = vtkPolyDataMapper::New();
+ myMapper = VTKViewer_PolyDataMapper::New();
vtkMapper::GetResolveCoincidentTopologyPolygonOffsetParameters(myPolygonOffsetFactor,
myPolygonOffsetUnits);
myGeomFilter->SetWireframeMode(false);
GetProperty()->SetRepresentation(theMode);
}
+ SetMarkerEnabled(theMode == ePoint);
myRepresentation = theMode;
UpdateFaceOrientation();
GetProperty()->Modified();
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();
+}
#define SMESH_DEVICE_ACTOR_H
#include <VTKViewer_GeometryFilter.h>
+#include <VTKViewer_MarkerDef.h>
#include "SMESH_Controls.hxx"
#include "SMESH_Object.h"
class vtkProperty;
class vtkMergeFilter;
class vtkShrinkFilter;
-class vtkPolyDataMapper;
class vtkUnstructuredGrid;
class vtkScalarBarActor;
class vtkLookupTable;
class VTKViewer_Transform;
class VTKViewer_TransformFilter;
class VTKViewer_ExtractUnstructuredGrid;
+class VTKViewer_PolyDataMapper;
class SMESH_ExtractGeometry;
class SMESH_FaceOrientationFilter;
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;
void ExportMeshToFile(int theCommandID);
- void SetDisplayMode(int theCommandID);
+ void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap);
void SetDisplayEntity(int theCommandID);
}
}
- 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 )
int Edgewidth = (int)anActor->GetLineWidth();
if(Edgewidth == 0)
Edgewidth = 1;
- int intValue = int(anActor->GetNodeSize());
vtkFloatingPointType Shrink = anActor->GetShrinkFactor();
vtkFloatingPointType faces_orientation_color[3];
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);
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()),
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<SMESH::SMESH_GroupBase>(IObject);
if( !aGroupObject->_is_nil() )
{
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
// 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<QVariant> aMarkerTypeIndicesList;
+ QList<QVariant> 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<QVariant> 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 );
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
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;
// 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,
savePoint);
_PTR(IParameters) ip = ClientFactory::getIParameters(ap);
+ // restore map of custom markers
+ VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
+
+ std::vector<std::string> properties = ip->getProperties();
+ for (std::vector<std::string>::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<std::string> entries = ip->getEntries();
for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
// 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());
// SALOME GUI includes
#include <SalomeApp_Module.h>
+#include <VTKViewer_MarkerDef.h>
#include <SALOME_InteractiveObject.hxx>
// IDL includes
class SMESHGUI_FilterLibraryDlg;
+typedef std::map<int, VTK::MarkerMap> SMESHGUI_StudyId2MarkerMap;
+
//=================================================================================
// class : SMESHGUI
// purpose :
LightApp_Displayer* myDisplayer;
SMESHGUI_FilterLibraryDlg* myFilterLibraryDlg;
+
+ SMESHGUI_StudyId2MarkerMap myMarkerMap;
};
#endif // SMESHGUI_H
#include <QtxColorButton.h>
#include <QtxDoubleSpinBox.h>
#include <QtxIntSpinBox.h>
+#include <VTKViewer_MarkerWidget.h>
// Qt includes
#include <QGroupBox>
// -------------------------------
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 );
{
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;
}
}
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;
}
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();
+}
// SMESH includes
#include "SMESH_SMESHGUI.hxx"
+// SALOME GUI includes
+#include <VTKViewer_MarkerDef.h>
+
// Qt includes
#include <QDialog>
class QtxDoubleSpinBox;
class QtxIntSpinBox;
class QtxColorButton;
+class VTKViewer_MarkerWidget;
class SMESHGUI_EXPORT SMESHGUI_Preferences_ColorDlg : public QDialog
{
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* );
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;
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;
<source>PREF_LABELS_COLOR</source>
<translation>Labels color</translation>
</message>
+ <message>
+ <source>PREF_MARKER_SCALE</source>
+ <translation>Scale of marker</translation>
+ </message>
<message>
<source>PREF_NODES</source>
<translation>Nodes</translation>
<source>PREF_SHRINK_COEFF</source>
<translation>Shrink coef.</translation>
</message>
- <message>
- <source>PREF_SIZE</source>
- <translation>Size</translation>
- </message>
<message>
<source>PREF_TAB_GENERAL</source>
<translation>General</translation>
<source>PREF_TITLE_COLOR</source>
<translation>Title color</translation>
</message>
+ <message>
+ <source>PREF_TYPE_OF_MARKER</source>
+ <translation>Type of marker</translation>
+ </message>
<message>
<source>PREF_COLOR_0D</source>
<translation>0D elements</translation>