From: ouv Date: Tue, 15 Mar 2011 13:56:27 +0000 (+0000) Subject: Note 0009977 of the issue 0013178: EDF243 VISU : post_processing for fields at nodes X-Git-Tag: StartingPortingMED3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4d82fac90f9739030add4944b277ffe7581148cf;p=modules%2Fvisu.git Note 0009977 of the issue 0013178: EDF243 VISU : post_processing for fields at nodes --- diff --git a/doc/salome/gui/VISU/images/point_marker_dlg3.png b/doc/salome/gui/VISU/images/point_marker_dlg3.png new file mode 100755 index 00000000..bec4a9a3 Binary files /dev/null and b/doc/salome/gui/VISU/images/point_marker_dlg3.png differ diff --git a/doc/salome/gui/VISU/images/point_sprite_marker.png b/doc/salome/gui/VISU/images/point_sprite_marker.png new file mode 100755 index 00000000..ea646309 Binary files /dev/null and b/doc/salome/gui/VISU/images/point_sprite_marker.png differ diff --git a/doc/salome/gui/VISU/input/point_marker.doc b/doc/salome/gui/VISU/input/point_marker.doc index 4df393bf..081cfb0c 100644 --- a/doc/salome/gui/VISU/input/point_marker.doc +++ b/doc/salome/gui/VISU/input/point_marker.doc @@ -19,6 +19,23 @@ form) and scale factor (defines shape size). \image html std_point_marker.png "Presentation with standard point markers" +
+ +There is also an additional type of point marker - Point Sprite marker, +which allows to display points as OpenGL point sprites with predefined +shape and alpha mask. This marker is added to the end of the list of +standard markers. + +\note The Point Sprite marker is insensitive to scale factor parameter, +but it is possible to change its magnification by pressing "m" and "M" +(Shift + "m") buttons in the view, just like for Gauss Points presentation. + +\image html point_marker_dlg3.png + +
+ +\image html point_sprite_marker.png "Presentation with Point Sprite marker" + - Custom point markers It is also possible to load a point marker shape from an external file. diff --git a/idl/VISU_Gen.idl b/idl/VISU_Gen.idl index a5949704..c7cf388d 100644 --- a/idl/VISU_Gen.idl +++ b/idl/VISU_Gen.idl @@ -92,7 +92,8 @@ module VISU { MT_O_PLUS, MT_O_STAR, MT_O_X, - MT_USER + MT_USER, + MT_POINT_SPRITE /*!< VISU specific */ }; /*! diff --git a/resources/Makefile.am b/resources/Makefile.am index 5ea587cb..44856c00 100644 --- a/resources/Makefile.am +++ b/resources/Makefile.am @@ -57,6 +57,7 @@ Visu_ok.png \ Visu_plot2d.png \ Visu_plot3d.png \ Visu_point_selection.png \ +Visu_point_sprite.png \ Visu_points.png \ Visu_recording_stop.png \ Visu_remove.png \ diff --git a/resources/Visu_point_sprite.png b/resources/Visu_point_sprite.png new file mode 100755 index 00000000..a7bd4aa2 Binary files /dev/null and b/resources/Visu_point_sprite.png differ diff --git a/src/OBJECT/VISU_IsoSurfActor.cxx b/src/OBJECT/VISU_IsoSurfActor.cxx index 52785d4c..1aec5980 100644 --- a/src/OBJECT/VISU_IsoSurfActor.cxx +++ b/src/OBJECT/VISU_IsoSurfActor.cxx @@ -133,11 +133,18 @@ int VISU_IsoSurfActor::RenderOpaqueGeometry(vtkViewport *vp) return VISU_ScalarMapAct::RenderOpaqueGeometry(vp); } - +#if (VTK_XVERSION < 0x050100) int VISU_IsoSurfActor::RenderTranslucentGeometry(vtkViewport *vp) +#else +int VISU_IsoSurfActor::RenderTranslucentPolygonalGeometry(vtkViewport *vp) +#endif { UpdateLabels(); +#if (VTK_XVERSION < 0x050100) return VISU_ScalarMapAct::RenderTranslucentGeometry(vp); +#else + return VISU_ScalarMapAct::RenderTranslucentPolygonalGeometry(vp); +#endif } void VISU_IsoSurfActor::SetVisibility(int theMode){ diff --git a/src/OBJECT/VISU_IsoSurfActor.h b/src/OBJECT/VISU_IsoSurfActor.h index 345e66f9..acbccf5f 100644 --- a/src/OBJECT/VISU_IsoSurfActor.h +++ b/src/OBJECT/VISU_IsoSurfActor.h @@ -49,7 +49,11 @@ class VISU_OBJECT_EXPORT VISU_IsoSurfActor : public VISU_ScalarMapAct virtual void RemoveFromRender( vtkRenderer* ); virtual int RenderOpaqueGeometry(vtkViewport *viewport); +#if (VTK_XVERSION < 0x050100) virtual int RenderTranslucentGeometry(vtkViewport *viewport); +#else + virtual int RenderTranslucentPolygonalGeometry(vtkViewport *viewport); +#endif //virtual void SetPipeLine(VISU_PipeLine* thePipeLine); diff --git a/src/OBJECT/VISU_ScalarMapAct.cxx b/src/OBJECT/VISU_ScalarMapAct.cxx index 35673709..d26381de 100644 --- a/src/OBJECT/VISU_ScalarMapAct.cxx +++ b/src/OBJECT/VISU_ScalarMapAct.cxx @@ -56,6 +56,163 @@ #include +//============================================================================ +class VISU_PointsDeviceActor: public VISU_GaussDeviceActorBase +{ + public: + vtkTypeMacro(VISU_PointsDeviceActor, VISU_GaussDeviceActorBase); + + static + VISU_PointsDeviceActor* + New(); + + + //---------------------------------------------------------------------------- + virtual + void + SetInput(vtkDataSet* theDataSet) + { + myGeomFilter->SetInput( theDataSet ); + } + + + //---------------------------------------------------------------------------- + void + SetInteractor(vtkRenderWindowInteractor* theInteractor) + { + if(theInteractor == myInteractor) + return; + + if(myInteractor) + myInteractor->RemoveObserver(myEventCallbackCommand); + + if(theInteractor) + theInteractor->AddObserver(vtkCommand::CharEvent, + myEventCallbackCommand, + 0.0); + + myInteractor = theInteractor; + } + + + //---------------------------------------------------------------------------- + void + DoMapperShallowCopy( vtkMapper* theMapper, + bool theIsCopyInput ) + { + Superclass::DoMapperShallowCopy( theMapper, theIsCopyInput ); + + vtkDataSet* aDataSet = theMapper->GetInput(); + vtkFloatingPointType aScaleFactor = VISU_DeformedShapePL::GetScaleFactor( aDataSet ); + + GetPointSpriteMapper()->SetAverageCellSize( aScaleFactor ); + } + + + //---------------------------------------------------------------------------- + void + DeepCopy( VISU_PointsDeviceActor *theActor ) + { + VISU::CopyPointSpriteDataMapper( GetPointSpriteMapper(), theActor->GetPointSpriteMapper(), false ); + } + + protected: + //---------------------------------------------------------------------------- + VISU_PointsDeviceActor(): + myGeomFilter( VTKViewer_GeometryFilter::New() ), + myEventCallbackCommand( vtkCallbackCommand::New() ), + myInteractor( NULL ) + { + myGeomFilter->SetInside(true); + + VISU_OpenGLPointSpriteMapper* aMapper = VISU_OpenGLPointSpriteMapper::New(); + aMapper->SetInput( myGeomFilter->GetOutput() ); + + std::string aRootDir( getenv( "VISU_ROOT_DIR") ); + std::string aMainTexture = aRootDir + "/share/salome/resources/visu/sprite_texture.bmp"; + std::string anAlphaTexture = aRootDir + "/share/salome/resources/visu/sprite_alpha.bmp"; + VISU::TTextureValue aTextureValue = VISU::GetTexture( aMainTexture, anAlphaTexture ); + aMapper->SetImageData( aTextureValue.GetPointer() ); + + aMapper->SetUseLookupTableScalarRange(true); + aMapper->SetColorModeToMapScalars(); + aMapper->SetScalarVisibility(true); + + SetPointSpriteMapper( aMapper ); + + aMapper->Delete(); + + myEventCallbackCommand->SetClientData( this ); + myEventCallbackCommand->SetCallback( VISU_PointsDeviceActor::ProcessEvents ); + } + + + //---------------------------------------------------------------------------- + ~VISU_PointsDeviceActor() + { + SetInteractor( NULL ); + myGeomFilter->Delete(); + myEventCallbackCommand->Delete(); + } + + + //---------------------------------------------------------------------------- + static + void + ProcessEvents(vtkObject* theObject, + unsigned long theEvent, + void* theClientData, + void* theCallData) + { + if ( VISU_PointsDeviceActor* self = reinterpret_cast( theClientData ) ) + self->OnInteractorEvent( theEvent ); + } + + + //---------------------------------------------------------------------------- + void + OnInteractorEvent(unsigned long theEvent) + { + switch ( theEvent ) { + case vtkCommand::CharEvent: { + switch( myInteractor->GetKeyCode() ) { + case 'M' : + case 'm' : { + if ( !GetVisibility() ) + return; + + static vtkFloatingPointType anIncrement = 2; + vtkFloatingPointType aMagnification = GetPointSpriteMapper()->GetPointSpriteMagnification(); + vtkFloatingPointType coefficient = myInteractor->GetShiftKey() ? anIncrement : 1 / anIncrement; + + GetPointSpriteMapper()->SetPointSpriteMagnification( aMagnification * coefficient ); + + myInteractor->CreateTimer(VTKI_TIMER_UPDATE); + break; + } + default: + return; + } + break; + } + default: + return; + } + } + + + //---------------------------------------------------------------------------- + vtkCallbackCommand* myEventCallbackCommand; + vtkRenderWindowInteractor* myInteractor; + VTKViewer_GeometryFilter* myGeomFilter; + + private: + VISU_PointsDeviceActor(const VISU_PointsDeviceActor&); // Not implemented + void operator=(const VISU_PointsDeviceActor&); // Not implemented +}; + +vtkStandardNewMacro(VISU_PointsDeviceActor); + //---------------------------------------------------------------------------- vtkStandardNewMacro(VISU_ScalarMapAct); static vtkFloatingPointType EPS = 1.0 / VTK_LARGE_FLOAT; @@ -90,8 +247,14 @@ VISU_ScalarMapAct myPointsActor->SetProperty(aProperty); myPointsActor->SetUserMatrix(aMatrix); + myPointSpriteActor = VISU_PointsDeviceActor::New(); + myPointSpriteActor->SetProperty(aProperty); + myPointSpriteActor->SetUserMatrix(aMatrix); + aMatrix->Delete(); + myIsPointSpriteMode = false; + SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr(); //Quadratic 2D elements representation if(aResourceMgr) { @@ -112,6 +275,7 @@ VISU_ScalarMapAct myScalarBar->Delete(); myPointsActor->Delete(); + myPointSpriteActor->Delete(); mySurfaceActor->Delete(); myEdgeActor->Delete(); @@ -125,6 +289,8 @@ VISU_ScalarMapAct myEdgeActor->GetMapper()->ScalarVisibilityOff(); + myPointSpriteActor->DoMapperShallowCopy( thePipeLine->GetMapper(), false ); + VISU::CopyMapper( myPointsActor->GetMapper(), thePipeLine->GetMapper(), false ); VISU::CopyMapper( mySurfaceActor->GetMapper(), thePipeLine->GetMapper(), false ); } @@ -141,10 +307,12 @@ VISU_ScalarMapAct // myEdgeActor->SetInput( theDataSet ); if (theDataSet->IsA("vtkPolyData")) { + myPointSpriteActor->SetInput( myPolyDataExtractor->GetOutput() ); myPointsActor->SetInput( myPolyDataExtractor->GetOutput() ); mySurfaceActor->SetInput( myPolyDataExtractor->GetOutput() ); myEdgeActor->SetInput( myPolyDataExtractor->GetOutput() ); } else { + myPointSpriteActor->SetInput( myExtractor->GetOutput() ); myPointsActor->SetInput( myExtractor->GetOutput() ); mySurfaceActor->SetInput( myExtractor->GetOutput() ); myEdgeActor->SetInput( myExtractor->GetOutput() ); @@ -159,6 +327,7 @@ VISU_ScalarMapAct Superclass::SetTransform(theTransform); myPointsActor->SetTransform(theTransform); + myPointSpriteActor->SetTransform(theTransform); mySurfaceActor->SetTransform(theTransform); myEdgeActor->SetTransform(theTransform); @@ -278,6 +447,9 @@ VISU_ScalarMapAct ::SetOpacity(vtkFloatingPointType theValue) { mySurfaceActor->GetProperty()->SetOpacity(theValue); + + vtkFloatingPointType aPointSpriteOpacity = theValue > 0.0 ? 1.0 : 0.0; + myPointSpriteActor->GetPointSpriteMapper()->SetPointSpriteOpacity(aPointSpriteOpacity); } vtkFloatingPointType @@ -309,6 +481,7 @@ VISU_ScalarMapAct if(VISU_ScalarMapAct* anActor = dynamic_cast(theActor)){ Superclass::DeepCopy(theActor); SetBarVisibility(anActor->GetBarVisibility()); + myPointSpriteActor->DeepCopy( anActor->myPointSpriteActor ); SetShading(anActor->IsShading()); } } @@ -321,6 +494,8 @@ VISU_ScalarMapAct { Superclass::AddToRender(theRenderer); + myPointSpriteActor->SetInteractor( myInteractor ); + if(myScalarBar) theRenderer->AddActor2D(myScalarBar); } @@ -334,6 +509,7 @@ VISU_ScalarMapAct theRenderer->RemoveActor(myScalarBar); if ( vtkWindow* aWindow = theRenderer->GetRenderWindow() ) { + myPointSpriteActor->ReleaseGraphicsResources( aWindow ); myPointsActor->ReleaseGraphicsResources( aWindow ); mySurfaceActor->ReleaseGraphicsResources( aWindow ); myEdgeActor->ReleaseGraphicsResources( aWindow ); @@ -349,6 +525,7 @@ VISU_ScalarMapAct { Superclass::SetVisibility( theMode ); + myPointSpriteActor->SetVisibility( theMode ); myPointsActor->SetVisibility( theMode ); if(myScalarBar) @@ -396,6 +573,7 @@ VISU_ScalarMapAct else mySurfaceActor->SetRepresentation(theMode); + myPointSpriteActor->SetProperty( mySurfaceActor->GetProperty() ); myPointsActor->SetProperty( mySurfaceActor->GetProperty() ); SetShading(anIsShanding); @@ -435,6 +613,7 @@ VISU_ScalarMapAct GetMatrix(myEdgeActor->GetUserMatrix()); GetMatrix(mySurfaceActor->GetUserMatrix()); GetMatrix(myPointsActor->GetUserMatrix()); + GetMatrix(myPointSpriteActor->GetUserMatrix()); using namespace SVTK::Representation; switch ( GetRepresentation() ) { @@ -448,8 +627,13 @@ VISU_ScalarMapAct break; case Points: - myPointsActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren); - myPointsActor->RenderOpaqueGeometry(ren); + if( myIsPointSpriteMode ) { + myPointSpriteActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren); + myPointSpriteActor->RenderOpaqueGeometry(ren); + } else { + myPointsActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren); + myPointsActor->RenderOpaqueGeometry(ren); + } break; default: @@ -462,7 +646,11 @@ VISU_ScalarMapAct int VISU_ScalarMapAct +#if (VTK_XVERSION < 0x050100) ::RenderTranslucentGeometry(vtkViewport *ren) +#else +::RenderTranslucentPolygonalGeometry(vtkViewport *ren) +#endif { GetMatrix(myEdgeActor->GetUserMatrix()); GetMatrix(mySurfaceActor->GetUserMatrix()); @@ -487,12 +675,21 @@ VISU_ScalarMapAct break; case Points: - myPointsActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren); + if( myIsPointSpriteMode ) { + myPointSpriteActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren); +#if (VTK_XVERSION < 0x050100) + myPointSpriteActor->RenderTranslucentGeometry(ren); +#else + myPointSpriteActor->RenderTranslucentPolygonalGeometry(ren); +#endif + } else { + myPointsActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren); #if (VTK_XVERSION < 0x050100) - myPointsActor->RenderTranslucentGeometry(ren); + myPointsActor->RenderTranslucentGeometry(ren); #else - myPointsActor->RenderTranslucentPolygonalGeometry(ren); + myPointsActor->RenderTranslucentPolygonalGeometry(ren); #endif + } break; default: @@ -507,6 +704,46 @@ VISU_ScalarMapAct return 1; } +//---------------------------------------------------------------------------- +#if (VTK_XVERSION >= 0x050100) +int +VISU_ScalarMapAct +::HasTranslucentPolygonalGeometry() +{ + int result = 0; + + using namespace SVTK::Representation; + switch ( GetRepresentation() ) { + case Surfaceframe: + result |= mySurfaceActor->HasTranslucentPolygonalGeometry(); + result |= myEdgeActor->HasTranslucentPolygonalGeometry(); + break; + case Points: + if( myIsPointSpriteMode ) + result |= myPointSpriteActor->HasTranslucentPolygonalGeometry(); + else + result |= myPointsActor->HasTranslucentPolygonalGeometry(); + break; + default: + result |= mySurfaceActor->HasTranslucentPolygonalGeometry(); + } + + return result; +} +#endif + +//---------------------------------------------------------------------------- +unsigned long int +VISU_ScalarMapAct +::GetMemorySize() +{ + unsigned long int aSize = Superclass::GetMemorySize(); + + aSize += myPointSpriteActor->GetMemorySize(); + + return aSize; +} + //---------------------------------------------------------------------------- VISU_Actor::EQuadratic2DRepresentation @@ -542,12 +779,16 @@ void VISU_ScalarMapAct::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::Marker { Superclass::SetMarkerStd( theMarkerType, theMarkerScale ); myPointsActor->SetMarkerStd( theMarkerType, theMarkerScale ); + + myIsPointSpriteMode = theMarkerType == VTK::MT_POINT_SPRITE; } void VISU_ScalarMapAct::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture ) { Superclass::SetMarkerTexture( theMarkerId, theMarkerTexture ); myPointsActor->SetMarkerTexture( theMarkerId, theMarkerTexture ); + + myIsPointSpriteMode = false; } /** diff --git a/src/OBJECT/VISU_ScalarMapAct.h b/src/OBJECT/VISU_ScalarMapAct.h index 3233ff90..00b7b386 100644 --- a/src/OBJECT/VISU_ScalarMapAct.h +++ b/src/OBJECT/VISU_ScalarMapAct.h @@ -32,7 +32,13 @@ #include "VISU_OBJECT.h" #include "VISU_DataSetActor.h" +namespace VTK +{ + const MarkerType MT_POINT_SPRITE = MT_USER + 1; +} + class VISU_ScalarBarActor; +class VISU_PointsDeviceActor; //---------------------------------------------------------------------------- class VISU_OBJECT_EXPORT VISU_ScalarMapAct : public VISU_DataSetActor @@ -136,7 +142,15 @@ class VISU_OBJECT_EXPORT VISU_ScalarMapAct : public VISU_DataSetActor virtual int +#if (VTK_XVERSION < 0x050100) RenderTranslucentGeometry(vtkViewport *ren); +#else + RenderTranslucentPolygonalGeometry(vtkViewport *ren); + + virtual + int + HasTranslucentPolygonalGeometry(); +#endif virtual void @@ -174,6 +188,11 @@ class VISU_OBJECT_EXPORT VISU_ScalarMapAct : public VISU_DataSetActor bool IsShading(); + //! Gets memory size used by the instance (bytes). + virtual + unsigned long int + GetMemorySize(); + virtual void SetMarkerStd( VTK::MarkerType, VTK::MarkerScale ); @@ -197,9 +216,12 @@ class VISU_OBJECT_EXPORT VISU_ScalarMapAct : public VISU_DataSetActor bool myBarVisibility; VISU_ScalarBarActor* myScalarBar; + VISU_PointsDeviceActor* myPointSpriteActor; SVTK_DeviceActor* myPointsActor; SVTK_DeviceActor* mySurfaceActor; SVTK_DeviceActor* myEdgeActor; + + bool myIsPointSpriteMode; }; //---------------------------------------------------------------------------- diff --git a/src/VISUGUI/VISU_images.ts b/src/VISUGUI/VISU_images.ts index c2e31e3c..aace6561 100644 --- a/src/VISUGUI/VISU_images.ts +++ b/src/VISUGUI/VISU_images.ts @@ -145,6 +145,10 @@ ICON_POINT_SELECTION Visu_point_selection.png + + ICON_POINT_SPRITE + Visu_point_sprite.png + ICON_POINTS Visu_points.png diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index b09336a6..0377e286 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -1448,6 +1448,10 @@ VisuGUI _PTR(Study) aCStudy = GetCStudy( GetAppStudy( this ) ); int aStudyId = aCStudy->StudyId(); + QPixmap aPointSpritePixmap; + if( SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr() ) + aPointSpritePixmap = aResourceMgr->loadPixmap( "VISU", tr( "ICON_POINT_SPRITE" ) ); + bool update = false; for( SALOME_ListIteratorOfListIO It( aListIO ); It.More(); It.Next() ) { @@ -1462,6 +1466,8 @@ VisuGUI aDlg->setCustomMarkerMap( aMarkerMap[ aStudyId ] ); + aDlg->addExtraStdMarker( VTK::MT_POINT_SPRITE, aPointSpritePixmap ); + VISU::MarkerType aMarkerTypeCurrent = aPrs->GetMarkerType(); VISU::MarkerScale aMarkerScaleCurrent = aPrs->GetMarkerScale(); int aMarkerTextureCurrent = aPrs->GetMarkerTexture(); @@ -4291,6 +4297,8 @@ void VisuGUI::createPreferences() aMarkerTypeIndicesList << i; aMarkerTypeIconsList << pixmap; } + aMarkerTypeIndicesList << VTK::MT_POINT_SPRITE; + aMarkerTypeIconsList << aResourceMgr->loadPixmap( "VISU", tr( "ICON_POINT_SPRITE" ) ); setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList ); setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList ); diff --git a/src/VISU_I/VISU_DumpPython.cc b/src/VISU_I/VISU_DumpPython.cc index 55b74b23..04b04ed9 100644 --- a/src/VISU_I/VISU_DumpPython.cc +++ b/src/VISU_I/VISU_DumpPython.cc @@ -229,6 +229,7 @@ namespace VISU case MT_O_PLUS: aParam1 = "MT_O_PLUS"; break; case MT_O_STAR: aParam1 = "MT_O_STAR"; break; case MT_O_X: aParam1 = "MT_O_X"; break; + case MT_POINT_SPRITE: aParam1 = "MT_POINT_SPRITE"; break; default: aParam1 = "MT_NONE"; break; } switch( aMarkerScale ) { @@ -245,8 +246,10 @@ namespace VISU case MS_60: aParam2 = "MS_60"; break; case MS_65: aParam2 = "MS_65"; break; case MS_70: aParam2 = "MS_70"; break; - default: aParam2 = "MT_NONE"; break; + default: aParam2 = "MS_NONE"; break; } + if( aMarkerType == MT_POINT_SPRITE ) + aParam2 = "MS_NONE"; theStr<