]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Issue 0020613: EDF 1106 : Modify Node Marker in SMESH and VISU V5_1_main_20100326 V5_1_main_20100330 V5_1_main_20100331
authorouv <ouv@opencascade.com>
Thu, 25 Mar 2010 13:48:01 +0000 (13:48 +0000)
committerouv <ouv@opencascade.com>
Thu, 25 Mar 2010 13:48:01 +0000 (13:48 +0000)
31 files changed:
doc/salome/gui/VISU/images/custom_point_marker.png [new file with mode: 0755]
doc/salome/gui/VISU/images/point_marker_dlg1.png [new file with mode: 0755]
doc/salome/gui/VISU/images/point_marker_dlg2.png [new file with mode: 0755]
doc/salome/gui/VISU/images/std_point_marker.png [new file with mode: 0755]
doc/salome/gui/VISU/input/3d_management.doc
doc/salome/gui/VISU/input/point_marker.doc [new file with mode: 0644]
doc/salome/gui/VISU/input/tui_point_marker.doc [new file with mode: 0644]
doc/salome/gui/VISU/input/viewing_3d_presentations.doc
idl/VISU_Gen.idl
resources/SalomeApp.xml
src/ENGINE/VISU_Engine_i.cc
src/ENGINE/VISU_Engine_i.hh
src/OBJECT/VISU_DataSetActor.cxx
src/OBJECT/VISU_DataSetActor.h
src/OBJECT/VISU_MeshAct.cxx
src/OBJECT/VISU_MeshAct.h
src/OBJECT/VISU_ScalarMapAct.cxx
src/OBJECT/VISU_ScalarMapAct.h
src/VISUGUI/VISU_msg_en.ts
src/VISUGUI/VisuGUI.cxx
src/VISUGUI/VisuGUI.h
src/VISUGUI/VisuGUI_ActionsDef.h
src/VISU_I/VISU_DumpPython.cc
src/VISU_I/VISU_Gen_i.cc
src/VISU_I/VISU_Gen_i.hh
src/VISU_I/VISU_PointMap3d_i.cc
src/VISU_I/VISU_PointMap3d_i.hh
src/VISU_I/VISU_Prs3d_i.cc
src/VISU_I/VISU_Prs3d_i.hh
src/VISU_SWIG/Makefile.am
src/VISU_SWIG/VISU_Example_08.py [new file with mode: 0644]

diff --git a/doc/salome/gui/VISU/images/custom_point_marker.png b/doc/salome/gui/VISU/images/custom_point_marker.png
new file mode 100755 (executable)
index 0000000..29b2dd9
Binary files /dev/null and b/doc/salome/gui/VISU/images/custom_point_marker.png differ
diff --git a/doc/salome/gui/VISU/images/point_marker_dlg1.png b/doc/salome/gui/VISU/images/point_marker_dlg1.png
new file mode 100755 (executable)
index 0000000..9bcecef
Binary files /dev/null and b/doc/salome/gui/VISU/images/point_marker_dlg1.png differ
diff --git a/doc/salome/gui/VISU/images/point_marker_dlg2.png b/doc/salome/gui/VISU/images/point_marker_dlg2.png
new file mode 100755 (executable)
index 0000000..3a67294
Binary files /dev/null and b/doc/salome/gui/VISU/images/point_marker_dlg2.png differ
diff --git a/doc/salome/gui/VISU/images/std_point_marker.png b/doc/salome/gui/VISU/images/std_point_marker.png
new file mode 100755 (executable)
index 0000000..f35b0df
Binary files /dev/null and b/doc/salome/gui/VISU/images/std_point_marker.png differ
index 962f0d57365247cffadd0fee24519bdf4306448c..2b54a0cdc06cd8df5731d55fd5abaf5c179f6f26 100755 (executable)
@@ -38,6 +38,8 @@ module are:
 presentations on fields. </li>
 <li> \subpage evolution_page - tracing of temporal evolution of a
 variable at a given point.</li>
+<li> \subpage point_marker_page - allows to change the representation
+of points, using standard or custom markers.</li>
 <li> \subpage translate_presentation_page - displacement of
 presentations in the viewer.</li>
 <li> \subpage recording_page - allows to dump user actions in an AVI
diff --git a/doc/salome/gui/VISU/input/point_marker.doc b/doc/salome/gui/VISU/input/point_marker.doc
new file mode 100644 (file)
index 0000000..efd0bcd
--- /dev/null
@@ -0,0 +1,56 @@
+/*!
+
+\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 Post-Pro 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_dlg1.png
+
+<br>
+
+\image html std_point_marker.png "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_dlg2.png
+
+<br>
+
+\image html custom_point_marker.png "Presentation with custom point markers"
+
+
+Our TUI Scripts provide you with \subpage tui_point_marker_page script.
+
+*/
+
diff --git a/doc/salome/gui/VISU/input/tui_point_marker.doc b/doc/salome/gui/VISU/input/tui_point_marker.doc
new file mode 100644 (file)
index 0000000..1199dc9
--- /dev/null
@@ -0,0 +1,48 @@
+/*!
+
+\page tui_point_marker_page Example of using Point Markers
+
+\code
+import os
+import time
+import VISU
+from visu_gui import *
+
+data_dir = os.getenv("DATA_DIR")
+sleep_delay = 2
+
+myViewManager = myVisu.GetViewManager();
+
+myView = myViewManager.Create3DView()
+myView.SetTitle("The viewer for Point Marker Example")
+print "myViewManager.Create3DView()"
+
+medFile = "fra.med"
+medFile = data_dir + '/MedFiles/' + medFile
+myResult = myVisu.ImportFile(medFile)
+
+aMeshName ="LE VOLUME"
+anEntity = VISU.NODE
+aFieldName = "VITESSE";
+aTimeStampId = 1
+
+aScalarMap = myVisu.ScalarMapOnField(myResult,aMeshName,anEntity,aFieldName,aTimeStampId)
+myView.Display(aScalarMap);
+myView.FitAll();
+
+print "Set representation type to Point"
+myView.SetPresentationType(aScalarMap, VISU.POINT)
+
+print "Set standard marker"
+aScalarMap.SetMarkerStd(VISU.MT_PLUS, VISU.MS_25)
+myView.Update()
+time.sleep(sleep_delay)
+
+print "Set custom marker"
+custom_texture = myVisu.LoadTexture(os.path.join(data_dir, "Textures", "texture1.dat"))
+aScalarMap.SetMarkerTexture(custom_texture)
+myView.Update()
+
+\endcode
+
+*/
index fb116a68cc02cd850e0ddc226961bb27a1982211..0ea0cecc5ac7c5403da3cc83b9fb1eb0cac07104 100644 (file)
@@ -102,6 +102,8 @@ are visualized: as straight lines or as arcs of circle.
   shrink_factor.png
   - <b>Edge Color</b> - allows to set the color of lines representing
   the edges of the presentation displayed in SurfaceFrame mode.
+  - \ref point_marker_page "Point Marker" - allows to change the
+  representation of points.
 
 - \ref translate_presentation_page "Translate Presentation" - allows
 to translate the presentation along coordinate axes.
index dded558f81903dfdd1eeb280aecf7b884e22cedb..c5e40f34a57569514a0d6d50c3a18f4b3399413c 100644 (file)
@@ -78,6 +78,43 @@ module VISU {
     NONE  /*!< Indicates undefined entity value */
   };
 
+  /*!
+   * Marker type (used for point rendering)
+   */
+  enum MarkerType {
+    MT_NONE,
+    MT_POINT,
+    MT_PLUS,
+    MT_STAR,
+    MT_O,
+    MT_X,
+    MT_O_POINT,
+    MT_O_PLUS,
+    MT_O_STAR,
+    MT_O_X,
+    MT_USER
+  };
+
+  /*!
+   * Marker scale (used for point rendering)
+   */
+  enum MarkerScale {
+    MS_NONE,
+    MS_10,
+    MS_15,
+    MS_20,
+    MS_25,
+    MS_30,
+    MS_35,
+    MS_40,
+    MS_45,
+    MS_50,
+    MS_55,
+    MS_60,
+    MS_65,
+    MS_70
+  };
+
   /*!
    * This enumeration contains a set of elements defining the type of the %VISU object.
    * This enumeration is used for navigation between a set of %VISU interfaces.
@@ -307,6 +344,38 @@ module VISU {
      */
     void GetOffset(out float theDx, out float theDy, out float theDz);
 
+    /*!
+     * Set standard point marker for the object
+     * \param theType standard marker type
+     * \param theScale standard marker scale
+     */
+    void SetMarkerStd(in MarkerType theType, in MarkerScale theScale);
+
+    /*!
+     * Set custom point marker for the object. The texture can be added
+     * by LoadTexture() function
+     * \param theTextureId texture ID
+     */
+    void SetMarkerTexture(in long theTextureId);
+
+    /*!
+     * Get type of the point marker assigned to the object
+     * \return current marker type (MT_NONE if no marker is set)
+     */
+    MarkerType GetMarkerType();
+
+    /*!
+     * Get scale of the point marker assigned to the object
+     * \return current marker scale (MS_NONE if no marker is set)
+     */
+    MarkerScale GetMarkerScale();
+
+    /*!
+     * Get texture idenifier of the point marker assigned to the object
+     * \return marker texture ID (0 if no marker set)
+     */
+    long GetMarkerTexture();
+
     /*!
      * Gets memory size actually used by the presentation (Mb).
      */
@@ -2492,6 +2561,12 @@ module VISU {
                      in string theMeshName,
                      in double_array theTStamps );
 
+    /*!
+     * Load texture from file
+     * \param theTextureFile texture file name
+     * \return unique texture identifier
+     */
+    long LoadTexture(in string theTextureFile);
   };
 
   /*! \brief %View interface
index e25cb85c540ed4d25597c4a4b8eb0cb8f386bb7a..2e79ca19e5fe4bc89d5015e5f6d1d7bb9d41e809 100644 (file)
@@ -63,6 +63,8 @@
     <parameter name="show_non_manifold_edges"  value="false"/>
     <parameter name="feature_edges_coloring"   value="false"/>
     <parameter name="edge_color"               value="255, 255, 255"/>
+    <parameter name="type_of_marker"           value="1"/>
+    <parameter name="marker_scale"             value="9"/>
     <parameter name="scalar_bar_horizontal_height" value="0.08"/>
     <parameter name="scalar_bar_horizontal_width"  value="0.8" />
     <parameter name="scalar_bar_horizontal_x" value="0.1"/>
index 117e547399123b073bbe8d0e40bcec8243d8d95f..291258e40f58685bd6b459b7f13eb2f6ae3ec84c 100644 (file)
@@ -546,4 +546,9 @@ namespace VISU{
     return myVisuGen->VTK2MED(theVTKFiles, theMEDFile, theMeshName, theTStamps);
   }   
 
+  /* Load texture from file */
+  CORBA::Long VISU_Gen_i::LoadTexture(const char* theTextureFile)
+  {
+    return myVisuGen->LoadTexture(theTextureFile);
+  }
 };
index 97cff3cd0d858d831b12ca02f996689aa081b3dc..ecf428c2a8cb32993a7120390fc875c456426c7b 100644 (file)
@@ -276,6 +276,9 @@ namespace VISU
                                     const char* theMEDFile,
                                     const char* theMeshName,
                                     const VISU::double_array& theTStamps );
+
+    /* Load texture from file */
+    virtual CORBA::Long LoadTexture(const char* theTextureFile);
   };
 };
 
index 128982abbe730ce84f5f002a4cb3af084aaafb5e..05fda9bae048f9b6d7008bb83e8c5bbb43d980cd 100644 (file)
@@ -28,7 +28,8 @@
 #include "VISU_UnstructuredGridPL.hxx"
 #include "VISU_PipeLineUtils.hxx"
 
-#include <vtkDataSetMapper.h>
+#include <VTKViewer_DataSetMapper.h>
+
 #include <vtkObjectFactory.h>
 #include <vtkImplicitBoolean.h>
 #include <SALOME_ExtractGeometry.h>
@@ -52,7 +53,7 @@ vtkStandardNewMacro(VISU_DataSetActor);
 //----------------------------------------------------------------------------
 VISU_DataSetActor
 ::VISU_DataSetActor():
-  myMapper(vtkDataSetMapper::New()),
+  myMapper(VTKViewer_DataSetMapper::New()),
   myExtractor(SALOME_ExtractGeometry::New()),
   myPolyDataExtractor(SALOME_ExtractPolyDataGeometry::New()),
   myFunction(vtkImplicitBoolean::New())
index b3aa197aa6fe0afb3f443007c62cb8721bbed3c0..9261b6f91a97889daa02e7b23c92b40842ae08bc 100644 (file)
@@ -31,6 +31,7 @@
 #include "VISU_Actor.h"
 
 class vtkDataSetMapper;
+class VTKViewer_DataSetMapper;
 class SALOME_ExtractGeometry;
 class SALOME_ExtractPolyDataGeometry;
 class vtkImplicitBoolean;
@@ -77,7 +78,7 @@ class VISU_OBJECT_EXPORT VISU_DataSetActor : public VISU_Actor
   SetMapperInput(vtkDataSet* theDataSet);
 
   //----------------------------------------------------------------------------
-  vtkSmartPointer<vtkDataSetMapper> myMapper;
+  vtkSmartPointer<VTKViewer_DataSetMapper> myMapper;
   vtkSmartPointer<SALOME_ExtractGeometry> myExtractor;
   vtkSmartPointer<SALOME_ExtractPolyDataGeometry> myPolyDataExtractor;
   vtkSmartPointer<vtkImplicitBoolean> myFunction;
index 13e81879493bac50d3210f29503c5989114bc876..41799765117ce0088e50cbd04f642ff4176517ea 100644 (file)
@@ -457,3 +457,15 @@ void VISU_MeshAct::SetQuadratic2DRepresentation( EQuadratic2DRepresentation theM
     break;
   }    
 }
+
+void VISU_MeshAct::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
+{
+  Superclass::SetMarkerStd( theMarkerType, theMarkerScale );
+  myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
+}
+
+void VISU_MeshAct::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
+{
+  Superclass::SetMarkerTexture( theMarkerId, theMarkerTexture );
+  myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
+}
index 1c041bde8cdafbfbad0db7f7305022f255425ff5..9e24df925a78d2df4d45ed1c927cb05aefaf7559 100644 (file)
@@ -141,6 +141,13 @@ class VISU_OBJECT_EXPORT VISU_MeshAct : public VISU_DataSetActor
   virtual void 
   SetQuadratic2DRepresentation( EQuadratic2DRepresentation theMode );
 
+  virtual
+  void
+  SetMarkerStd( VTK::MarkerType, VTK::MarkerScale );
+
+  virtual
+  void
+  SetMarkerTexture( int, VTK::MarkerTexture );
 
  protected:
   VISU_MeshAct();
index 7daf7259a8754418dff4932831d2aaf9bd90948b..54996e98798f156caeaffe45f8640b05052d42e6 100644 (file)
 #include <vtkImageData.h>
 
 
-//============================================================================
-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<VISU_PointsDeviceActor*>( 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;
@@ -241,7 +84,8 @@ VISU_ScalarMapAct
   myEdgeActor->SetUserMatrix(aMatrix);
   myEdgeActor->GetProperty()->SetColor(255.,255.,255.);
 
-  myPointsActor = VISU_PointsDeviceActor::New();
+  myPointsActor = SVTK_DeviceActor::New();
+  myPointsActor->SetRepresentation(SVTK::Representation::Points);
   myPointsActor->SetProperty(aProperty);
   myPointsActor->SetUserMatrix(aMatrix);
 
@@ -280,8 +124,7 @@ VISU_ScalarMapAct
 
   myEdgeActor->GetMapper()->ScalarVisibilityOff();
 
-  myPointsActor->DoMapperShallowCopy( thePipeLine->GetMapper(), false );
-
+  VISU::CopyMapper( myPointsActor->GetMapper(), thePipeLine->GetMapper(), false );
   VISU::CopyMapper( mySurfaceActor->GetMapper(), thePipeLine->GetMapper(), false );
 }
 
@@ -465,7 +308,6 @@ VISU_ScalarMapAct
   if(VISU_ScalarMapAct* anActor = dynamic_cast<VISU_ScalarMapAct*>(theActor)){
     Superclass::DeepCopy(theActor);
     SetBarVisibility(anActor->GetBarVisibility());
-    myPointsActor->DeepCopy( anActor->myPointsActor );
     SetShading(anActor->IsShading());
   }
 }
@@ -478,8 +320,6 @@ VISU_ScalarMapAct
 {
   Superclass::AddToRender(theRenderer);
 
-  myPointsActor->SetInteractor( myInteractor );
-
   if(myScalarBar)
     theRenderer->AddActor2D(myScalarBar);
 }
@@ -666,18 +506,6 @@ VISU_ScalarMapAct
   return 1;
 }
 
-//----------------------------------------------------------------------------
-unsigned long int
-VISU_ScalarMapAct
-::GetMemorySize()
-{
-  unsigned long int aSize = Superclass::GetMemorySize();
-
-  aSize += myPointsActor->GetMemorySize();
-
-  return aSize;
-}
-
 //----------------------------------------------------------------------------
 
 VISU_Actor::EQuadratic2DRepresentation 
@@ -708,3 +536,15 @@ void VISU_ScalarMapAct::SetQuadratic2DRepresentation( VISU_Actor::EQuadratic2DRe
     break;
   }
 }
+
+void VISU_ScalarMapAct::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
+{
+  Superclass::SetMarkerStd( theMarkerType, theMarkerScale );
+  myPointsActor->SetMarkerStd( theMarkerType, theMarkerScale );
+}
+
+void VISU_ScalarMapAct::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
+{
+  Superclass::SetMarkerTexture( theMarkerId, theMarkerTexture );
+  myPointsActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
+}
index f16e6ada2d8cd1b0929d562deb39226d210278fd..9ff48ab2a5d03918ba60cd1f83474e33b4f2ab59 100644 (file)
@@ -32,8 +32,6 @@
 #include "VISU_DataSetActor.h"
 
 class VISU_ScalarBarActor;
-class VISU_PointsDeviceActor;
-
 
 //----------------------------------------------------------------------------
 class VISU_OBJECT_EXPORT VISU_ScalarMapAct : public VISU_DataSetActor 
@@ -171,11 +169,14 @@ class VISU_OBJECT_EXPORT VISU_ScalarMapAct : public VISU_DataSetActor
   bool
   IsShading();
 
-  //! Gets memory size used by the instance (bytes).
   virtual
-  unsigned long int
-  GetMemorySize();
+  void
+  SetMarkerStd( VTK::MarkerType, VTK::MarkerScale );
+
+  virtual
+  void
+  SetMarkerTexture( int, VTK::MarkerTexture );
+
  protected:
   VISU_ScalarMapAct();
 
@@ -186,7 +187,7 @@ class VISU_OBJECT_EXPORT VISU_ScalarMapAct : public VISU_DataSetActor
   bool myBarVisibility;
   VISU_ScalarBarActor* myScalarBar;
 
-  VISU_PointsDeviceActor* myPointsActor;
+  SVTK_DeviceActor*    myPointsActor;
   SVTK_DeviceActor*    mySurfaceActor;
   SVTK_DeviceActor*    myEdgeActor;
 };
index 22d1baf4e9f2c2a335f36f56c4b0230890fc7e3e..f863f8b5cb74077be31a44b95201024c569c2e6c 100644 (file)
@@ -265,6 +265,10 @@ number of time stamps or number of components is not the same!</translation>
             <source>VISU_LOGARITHMIC_SCALING</source>
             <translation>Logarithmic</translation>
         </message>
+        <message>
+            <source>VISU_MARKER_SCALE</source>
+            <translation>Scale of marker</translation>
+        </message>
         <message>
             <source>VISU_MAX</source>
             <translation>Max:</translation>
@@ -409,6 +413,10 @@ number of time stamps or number of components is not the same!</translation>
             <source>VISU_TITLE</source>
             <translation>Title</translation>
         </message>
+        <message>
+            <source>VISU_TYPE_OF_MARKER</source>
+            <translation>Type of marker</translation>
+        </message>
         <message>
             <source>QUADRATIC_REPRESENT_MODE</source>
             <translation>Representation of the 2D quadratic elements</translation>
@@ -1241,6 +1249,10 @@ Please, refer to the documentation.</translation>
             <source>MEN_POINT_SELECTION</source>
             <translation>Point Selection</translation>
         </message>
+        <message>
+            <source>MEN_POINT_MARKER</source>
+            <translation>Point Marker</translation>
+        </message>
         <message>
             <source>MEN_POINTS</source>
             <translation>Points</translation>
index 97ba5489a79b251a22eb737a9e2d75c7a5389d25..330f6317863a1c6673fe0f917375781eb5dcd0d7 100644 (file)
@@ -64,6 +64,7 @@
 //#include "SVTK_MainWindow.h"
 
 #include "VTKViewer_Algorithm.h"
+#include "VTKViewer_MarkerDlg.h"
 
 #include "SPlot2d_ViewModel.h"
 #include "VisuGUI_SetupPlot2dDlg.h"
@@ -1428,6 +1429,67 @@ VisuGUI
   delete CursorDlg;
 }
 
+//----------------------------------------------------------------------------
+void
+VisuGUI
+::OnChangePointMarker()
+{
+  SALOME_ListIO aListIO;
+  GetSelectionMgr( this )->selectedObjects( aListIO );
+  if( aListIO.Extent() < 1 )
+    return;
+
+  VISU::StudyId2MarkerMap& aMarkerMap = GetVisuGen( this )->GetMarkerMap();
+  _PTR(Study) aCStudy = GetCStudy( GetAppStudy( this ) );
+  int aStudyId = aCStudy->StudyId();
+
+  bool update = false;
+  for( SALOME_ListIteratorOfListIO It( aListIO ); It.More(); It.Next() )
+  {
+    Handle(SALOME_InteractiveObject)& anIO = It.Value();
+    std::vector<VISU::Prs3d_i*> aPrsList = GetPrs3dList( this, anIO );
+    for( int i = 0, n = aPrsList.size(); i < n; i++ )
+    {
+      if( VISU::Prs3d_i* aPrs = aPrsList[i] )
+      {
+        VTKViewer_MarkerDlg* aDlg = new VTKViewer_MarkerDlg( GetDesktop( this ) );
+
+        aDlg->setCustomMarkerMap( aMarkerMap[ aStudyId ] );
+
+        VISU::MarkerType aMarkerTypeCurrent = aPrs->GetMarkerType();
+        VISU::MarkerScale aMarkerScaleCurrent = aPrs->GetMarkerScale();
+        int aMarkerTextureCurrent = aPrs->GetMarkerTexture();
+        if( aMarkerTypeCurrent != VISU::MT_USER )
+          aDlg->setStandardMarker( (VTK::MarkerType)aMarkerTypeCurrent, (VTK::MarkerScale)aMarkerScaleCurrent );
+        else
+          aDlg->setCustomMarker( aMarkerTextureCurrent );
+
+        if( aDlg->exec() )
+        {
+          aMarkerMap[ aStudyId ] = aDlg->getCustomMarkerMap();
+
+          VISU::MarkerType aMarkerTypeNew = (VISU::MarkerType)aDlg->getMarkerType();
+          VISU::MarkerScale aMarkerScaleNew = (VISU::MarkerScale)aDlg->getStandardMarkerScale();
+          int aMarkerTextureNew = aDlg->getCustomMarkerID();
+          if( aMarkerTypeNew != VISU::MT_USER )
+            aPrs->SetMarkerStd( aMarkerTypeNew, aMarkerScaleNew );
+          else
+            aPrs->SetMarkerTexture( aMarkerTextureNew );
+
+          aPrs->UpdateActors();
+          update = true;
+        }
+
+        delete aDlg;
+      }
+    }
+  }
+
+  if( update )
+    if( SVTK_ViewWindow* vw = GetActiveViewWindow<SVTK_ViewWindow>( this ) )
+      vw->Repaint();
+}
+
 //----------------------------------------------------------------------------
 void
 VisuGUI
@@ -2724,6 +2786,10 @@ VisuGUI
                 tr("MEN_LINE_WIDTH"), "", 0, aParent, false,
                 this, SLOT(OnChangeLines()));
 
+  createAction( VISU_POINT_MARKER, tr("MEN_POINT_MARKER"), QIcon(),
+                tr("MEN_POINT_MARKER"), "", 0, aParent, false,
+                this, SLOT(OnChangePointMarker()));
+
   createAction( VISU_SHRINK_FACTOR, tr("MEN_SHRINK_FACTOR"), QIcon(),
                 tr("MEN_SHRINK_FACTOR"), "", 0, aParent, false,
                 this, SLOT(OnChangeShrinkFactor()));
@@ -3077,6 +3143,7 @@ VisuGUI
   mgr->insert( action( VISU_COLOR )     ,    parentId, -1, -1 ); // color
   mgr->insert( action( VISU_OPACITY )   ,    parentId, -1, -1 ); // opacity
   mgr->insert( action( VISU_LINE_WIDTH ),    parentId, -1, -1 ); // line width
+  mgr->insert( action( VISU_POINT_MARKER ),  parentId, -1, -1 ); // point marker
   mgr->insert( action( VISU_SHRINK_FACTOR ), parentId, -1, -1 ); // shrink factor
 
   mgr->insert( separator(), -1, -1, -1 );
@@ -3258,6 +3325,7 @@ VisuGUI
                "or (type='VISU::TDEFORMEDSHAPE' and hasActor=1))" );
   mgr->setRule( action( VISU_OPACITY ), aRule + " and hasActor=1" );
   mgr->setRule( action( VISU_LINE_WIDTH ), aRule + aLineType + " and hasActor=1" );
+  mgr->setRule( action( VISU_POINT_MARKER ), aRule + aLineType + " and hasActor=1 and representation='VISU::POINT'" );
   mgr->setRule( action( VISU_SHRINK_FACTOR ), aRule + aShrinkType + " and isShrunk=1" );
 
   // rename command
@@ -4125,6 +4193,32 @@ void VisuGUI::createPreferences()
   addPreference( tr( "VISU_EDGE_COLOR" ), representGr, LightApp_Preferences::Color, "VISU", "edge_color" );
   addPreference( "", representGr, LightApp_Preferences::Space );
 
+  SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
+
+  int typeOfMarker = addPreference( tr( "VISU_TYPE_OF_MARKER" ), representGr, LightApp_Preferences::Selector, "VISU", "type_of_marker" );
+
+  QList<QVariant> aMarkerTypeIndicesList;
+  QList<QVariant> aMarkerTypeIconsList;
+  for ( int i = VTK::MT_POINT; i <= VTK::MT_O_X; 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( "VISU_MARKER_SCALE" ), representGr, LightApp_Preferences::Selector, "VISU", "marker_scale" );
+
+  QList<QVariant> aMarkerScaleIndicesList;
+  QStringList     aMarkerScaleValuesList;
+  for ( int i = VISU::MS_10; i <= VISU::MS_70; i++ ) {
+    aMarkerScaleIndicesList << i;
+    aMarkerScaleValuesList  << QString::number( (i-(int)VISU::MS_10)*0.5 + 1.0 );
+  }
+  setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
+  setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
+
   addPreference( tr( "VISU_USE_SHADING" ), representGr, LightApp_Preferences::Bool, "VISU", "represent_shading" );
   sp = addPreference( "", representGr, LightApp_Preferences::Space );
   setPreferenceProperty( sp, "hstretch", 0 );
index 90205718567e4edf2a3154268d8adfc49d256ac2..05f19dd84789387a528a155f32a67bfac3232c51 100644 (file)
@@ -153,6 +153,7 @@ protected slots:
   void OnChangeWireframeColor();
   void OnChangeOpacity();
   void OnChangeLines();
+  void OnChangePointMarker();
   void OnChangeShrinkFactor();
 
   void OnShowTable();
index 3b0be7fcc3011c827f090c7cb2379e290a071c00..f0717599d75eaef7412e4dbfbb947721a25fa62b 100644 (file)
@@ -92,6 +92,7 @@
 #define VISU_EDGE_COLOR             4059
 #define VISU_OPACITY                4060
 #define VISU_LINE_WIDTH             4061
+#define VISU_POINT_MARKER           40611
 #define VISU_SHRINK_FACTOR          40629
 
 #define VISU_EDIT_SCALARMAP         40620
index b8356d8519a836429142ee15ebef68a42bf0e2a3..6ef7dee1927a99f9b65862727c20e7bd70ab48bf 100644 (file)
@@ -212,6 +212,48 @@ namespace VISU
     theServant->GetOffset(x,y,z);
     theStr<<thePrefix<<theName<<".SetOffset("<<x<<", "<<y<<", "<<z<<")"<<endl;
     SetClippingPlane(theServant, theName, theStr, thePrefix);
+
+    VISU::MarkerType aMarkerType = theServant->GetMarkerType();
+    if( aMarkerType != VISU::MT_NONE ) {
+      if( aMarkerType != VISU::MT_USER ) {
+        VISU::MarkerScale aMarkerScale = theServant->GetMarkerScale();
+        std::string aParam1, aParam2;
+        switch( aMarkerType ) {
+        case MT_POINT:   aParam1 = "MT_POINT"; break;
+        case MT_PLUS:    aParam1 = "MT_PLUS"; break;
+        case MT_STAR:    aParam1 = "MT_STAR"; break;
+        case MT_O:       aParam1 = "MT_O"; break;
+        case MT_X:       aParam1 = "MT_X"; break;
+        case MT_O_POINT: aParam1 = "MT_O_POINT"; break;
+        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;
+        default:         aParam1 = "MT_NONE"; break;
+        }
+        switch( aMarkerScale ) {
+        case MS_10:      aParam2 = "MS_10"; break;
+        case MS_15:      aParam2 = "MS_15"; break;
+        case MS_20:      aParam2 = "MS_20"; break;
+        case MS_25:      aParam2 = "MS_25"; break;
+        case MS_30:      aParam2 = "MS_30"; break;
+        case MS_35:      aParam2 = "MS_35"; break;
+        case MS_40:      aParam2 = "MS_40"; break;
+        case MS_45:      aParam2 = "MS_45"; break;
+        case MS_50:      aParam2 = "MS_50"; break;
+        case MS_55:      aParam2 = "MS_55"; break;
+        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;
+        }
+        theStr<<thePrefix<<theName<<".SetMarkerStd(VISU."<<aParam1<<", VISU."<<aParam2<<")"<<endl;
+      }
+      else {
+        int aMarkerTexture = theServant->GetMarkerTexture();
+        if( aMarkerTexture >= 0 )
+          theStr<<thePrefix<<theName<<".SetMarkerTexture(texture_map["<<aMarkerTexture<<"])"<<endl;
+      }
+    }
   }
 
   //---------------------------------------------------------------------------
@@ -2205,6 +2247,38 @@ namespace VISU
   }  
 
 
+  void
+  DumpTextureMapToPython(SALOMEDS::Study_ptr theStudy,
+                         CORBA::Boolean theIsPublished,
+                         CORBA::Boolean& theIsValidScript,
+                         SALOMEDS::SObject_ptr theSObject,
+                         std::ostream& theStr,
+                         std::string thePrefix,
+                         const StudyId2MarkerMap& theMarkerMap)
+  {
+    if(!theIsPublished)
+      return;
+
+    if(CORBA::is_nil(theStudy))
+      return;
+
+    StudyId2MarkerMap::const_iterator anIter = theMarkerMap.find(theStudy->StudyId());
+    if(anIter == theMarkerMap.end())
+      return;
+
+    theStr<<thePrefix<<"texture_map = {}"<<endl<<endl;
+
+    const VTK::MarkerMap& aMarkerMap = anIter->second;
+    VTK::MarkerMap::const_iterator aMarkerIter = aMarkerMap.begin();
+    for(; aMarkerIter != aMarkerMap.end(); aMarkerIter++) {
+      int aMarkerId = aMarkerIter->first;
+      std::string aMarkerTexture = aMarkerIter->second.first;
+      theStr<<thePrefix<<"texture_map["<<aMarkerId<<"] = aVisu.LoadTexture(\""<<aMarkerTexture<<"\")"<<endl;
+    }
+    theStr<<endl;
+  }  
+
+
   //---------------------------------------------------------------------------
   Engines::TMPFile*
   VISU_Gen_i::
@@ -2252,6 +2326,13 @@ namespace VISU
                                     aPrefix, 
                                     myClippingPlaneMgr);
 
+    VISU::DumpTextureMapToPython(aStudy,
+                                 theIsPublished,
+                                 theIsValidScript,
+                                 aComponent.in(),
+                                 aStr,
+                                 aPrefix,
+                                 myMarkerMap);
 
     VISU::DumpChildrenToPython(aStudy,
                               theIsPublished,
index 1935c4ed0e74db6c64a1871df8a022aa60b8c07c..657ab889abc8359eb4996e6334b820048c2c88c0 100644 (file)
@@ -44,6 +44,7 @@
 
 #include "VISU_Actor.h"
 
+#include "HDFOI.hxx"
 #include "HDFascii.hxx"
 #include "SALOMEDS_Tool.hxx"
 
@@ -54,6 +55,7 @@
 #include "SalomeApp_Study.h"
 #include "SalomeApp_Application.h"
 #include "LightApp_SelectionMgr.h"
+#include "VTKViewer_MarkerUtils.h"
 #include "SVTK_ViewModel.h"
 #include "SVTK_ViewWindow.h"
 #include "SALOME_Event.h"
@@ -242,6 +244,181 @@ namespace VISU
   }
 
 
+  //----------------------------------------------------------------------------
+  bool
+  LoadMarkerMap(SALOMEDS::Study_ptr theStudy,
+                const char* theURL,
+                bool theIsMultiFile,
+                bool theIsASCII,
+                StudyId2MarkerMap& theStudyId2MarkerMap,
+                std::string& theMarkerMapFileName,
+                std::string& theMarkerMapFile)
+  {
+    std::string aPrefix;
+    if( theIsMultiFile ) {
+      CORBA::String_var anURL = theStudy->URL();
+      aPrefix = SALOMEDS_Tool::GetNameFromPath(anURL.in());
+    }
+
+    theMarkerMapFileName = aPrefix + "_textures";
+    theMarkerMapFile = VISU_TMP_DIR + theMarkerMapFileName;
+
+    if( theIsASCII && !HDFascii::ConvertFromASCIIToHDF( const_cast<char*>( theMarkerMapFile.c_str() ), true ) )
+      return false;
+
+    HDFfile*    aFile;
+    HDFdataset* aDataset;
+    HDFgroup*   aTopGroup;
+    HDFgroup*   aGroup;
+    HDFgroup*   aSubGroup;
+    HDFgroup*   aSubSubGroup;
+    int         aSize;
+
+    aFile = new HDFfile( (char*)theMarkerMapFile.c_str() );
+    try {
+      aFile->OpenOnDisk( HDF_RDONLY );
+    }
+    catch ( HDFexception ) {
+      INFOS( "Load(): " << theMarkerMapFile << " not found!" );
+      return false;
+    }
+
+    VTK::MarkerMap& aMarkerMap = theStudyId2MarkerMap[ theStudy->StudyId() ];
+
+    for( int i = 0, n = aFile->nInternalObjects(); i < n; i++ ) {
+      char markerGrpName[ HDF_NAME_MAX_LEN+1 ];
+      aFile->InternalObjectIndentify( i, markerGrpName );
+
+      int aMarkerId = 0;
+      std::string aMarkerFile;
+      VTK::MarkerTexture aMarkerTexture;
+
+      if( string( markerGrpName ).substr( 0, 6 ) == string( "Marker" ) ) {
+        aTopGroup = new HDFgroup( markerGrpName, aFile ); 
+        aTopGroup->OpenOnDisk();
+
+        aMarkerId = atoi( string( markerGrpName ).substr( 6 ).c_str() );
+        if( aMarkerId < 1 )
+          continue;
+
+        if( aTopGroup->ExistInternalObject( "File" ) ) {
+          aDataset = new HDFdataset( "File", aTopGroup );
+          aDataset->OpenOnDisk();
+          aSize = aDataset->GetSize();
+          char* aFileName = new char[ aSize ];
+          aDataset->ReadFromDisk( aFileName );
+          aMarkerFile = aFileName;
+          delete [] aFileName;
+          aDataset->CloseOnDisk();
+        }
+
+        if( aTopGroup->ExistInternalObject( "Texture" ) ) {
+          aDataset = new HDFdataset( "Texture", aTopGroup );
+          aDataset->OpenOnDisk();
+          aSize = aDataset->GetSize();
+          int* aTextureData = new int[ aSize ];
+          aDataset->ReadFromDisk( aTextureData );
+          for( int j = 0; j < aSize; j++ )
+            aMarkerTexture.push_back( aTextureData[j] );
+          delete [] aTextureData;
+          aDataset->CloseOnDisk();
+        }
+
+        aTopGroup->CloseOnDisk();   
+      }
+
+      if( aMarkerId > 0 )
+        aMarkerMap[ aMarkerId ] = VTK::MarkerData( aMarkerFile, aMarkerTexture );
+    }
+
+    aFile->CloseOnDisk();
+    delete aFile;
+
+    return true;
+  }
+
+  //----------------------------------------------------------------------------
+  bool
+  SaveMarkerMap(SALOMEDS::Study_ptr theStudy,
+                const char* theURL,
+                bool theIsMultiFile,
+                bool theIsASCII,
+                const StudyId2MarkerMap& theStudyId2MarkerMap,
+                std::string& theMarkerMapFileName,
+                std::string& theMarkerMapFile)
+  {
+    VISU::StudyId2MarkerMap::const_iterator aMainIter = theStudyId2MarkerMap.find( theStudy->StudyId() );
+    if( aMainIter == theStudyId2MarkerMap.end() )
+      return false;
+
+    const VTK::MarkerMap& aMarkerMap = aMainIter->second;
+    if( aMarkerMap.empty() )
+      return false;
+
+    std::string aPrefix;
+    if( theIsMultiFile ) {
+      CORBA::String_var anURL = theStudy->URL();
+      aPrefix = SALOMEDS_Tool::GetNameFromPath(anURL.in());
+    }
+
+    theMarkerMapFileName = aPrefix + "_textures";
+    theMarkerMapFile = string( theURL ) + theMarkerMapFileName;
+
+    HDFfile*    aFile;
+    HDFdataset* aDataset;
+    HDFgroup*   aTopGroup;
+    HDFgroup*   aGroup;
+    HDFgroup*   aSubGroup;
+    HDFgroup*   aSubSubGroup;
+    hdf_size    aSize[ 1 ];
+
+    aFile = new HDFfile( (char*)theMarkerMapFile.c_str() );
+    aFile->CreateOnDisk();
+
+    VTK::MarkerMap::const_iterator aMarkerIter = aMarkerMap.begin();
+    for( ; aMarkerIter != aMarkerMap.end(); aMarkerIter++ ) {
+      int aMarkerId = aMarkerIter->first;
+      const VTK::MarkerData& aMarkerData = aMarkerIter->second;
+      std::string aMarkerFile = aMarkerData.first;
+      VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
+
+      char markerGrpName[30];
+      sprintf( markerGrpName, "Marker %d", aMarkerId );
+      aTopGroup = new HDFgroup( markerGrpName, aFile );
+
+      aTopGroup->CreateOnDisk();
+
+      aSize[ 0 ] = aMarkerFile.length() + 1;
+      aDataset = new HDFdataset( "File", aTopGroup, HDF_STRING, aSize, 1 );
+      aDataset->CreateOnDisk();
+      aDataset->WriteOnDisk( ( char* )( aMarkerFile.c_str() ) );
+      aDataset->CloseOnDisk();
+
+      int* aTextureData = new int[ aMarkerTexture.size() ];
+      VTK::MarkerTexture::const_iterator anIter = aMarkerTexture.begin();
+      for( int i = 0; anIter != aMarkerTexture.end(); anIter++, i++ )
+        aTextureData[i] = *anIter;
+
+      aSize[0] = aMarkerTexture.size();
+      aDataset = new HDFdataset( "Texture", aTopGroup, HDF_INT32, aSize, 1 );
+      aDataset->CreateOnDisk();
+      aDataset->WriteOnDisk( aTextureData );
+      aDataset->CloseOnDisk();
+      delete [] aTextureData;
+
+      aTopGroup->CloseOnDisk();
+    }
+
+    aFile->CloseOnDisk();
+    delete aFile;
+
+    if( theIsASCII && !HDFascii::ConvertFromHDFToASCII( const_cast<char*>( theMarkerMapFile.c_str() ), true ) )
+      return false;
+
+    return true;
+  }
+
+
   //----------------------------------------------------------------------------
   VISU_Gen_i
   ::VISU_Gen_i(CORBA::ORB_ptr theORB, PortableServer::POA_ptr thePOA,
@@ -323,13 +500,13 @@ namespace VISU
 
   //----------------------------------------------------------------------------
   CORBA::Boolean 
-  VISU_Gen_i
-  ::Load(SALOMEDS::SComponent_ptr theComponent,
-        const SALOMEDS::TMPFile & theStream,
-        const char* theURL,
-        CORBA::Boolean theIsMultiFile)
+  LoadWithMarkerMap(SALOMEDS::SComponent_ptr theComponent,
+                    const SALOMEDS::TMPFile & theStream,
+                    const char* theURL,
+                    CORBA::Boolean theIsMultiFile,
+                    CORBA::Boolean theIsASCII,
+                    StudyId2MarkerMap& theStudyId2MarkerMap)
   {
-    Mutex mt(myMutex);
     SALOMEDS::Study_var aStudy = theComponent->GetStudy();
 
     SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator(theComponent);
@@ -340,15 +517,41 @@ namespace VISU
       CorrectSObjectType(aSObject, aStudyBuilder);      
     }
 
-   
     VISU_TMP_DIR = theIsMultiFile ? theURL : SALOMEDS_Tool::GetTmpDir();
     SALOMEDS::ListOfFileNames_var aSeq =
       SALOMEDS_Tool::PutStreamToFiles(theStream, VISU_TMP_DIR, theIsMultiFile);
     myIsMultiFile = theIsMultiFile;
+
+    // load textures of custom point markers
+    Result_i::TFileNames aTMPFileNames;
+    std::string aMarkerMapFileName, aMarkerMapFile;
+    if( LoadMarkerMap( aStudy, theURL, theIsMultiFile, theIsASCII,
+                       theStudyId2MarkerMap, aMarkerMapFileName, aMarkerMapFile ) ) {
+      aTMPFileNames.push_back( aMarkerMapFileName );
+    }
+
+    if(!theIsMultiFile && !aTMPFileNames.empty()) {
+      SALOMEDS::ListOfFileNames_var aListOfTMPFileNames = GetListOfFileNames(aTMPFileNames);
+      SALOMEDS_Tool::RemoveTemporaryFiles(VISU_TMP_DIR, aListOfTMPFileNames, true );
+    }
+
     return true;
   }
 
 
+  //----------------------------------------------------------------------------
+  CORBA::Boolean 
+  VISU_Gen_i
+  ::Load(SALOMEDS::SComponent_ptr theComponent,
+        const SALOMEDS::TMPFile & theStream,
+        const char* theURL,
+        CORBA::Boolean theIsMultiFile)
+  {
+    Mutex mt(myMutex);
+    return LoadWithMarkerMap(theComponent, theStream, theURL, theIsMultiFile, false, myMarkerMap);
+  }
+
+
   //----------------------------------------------------------------------------
   CORBA::Boolean 
   VISU_Gen_i
@@ -357,7 +560,8 @@ namespace VISU
              const char* theURL,
              bool theIsMultiFile)
   {
-    return Load(theComponent, theStream, theURL, theIsMultiFile);
+    Mutex mt(myMutex);
+    return LoadWithMarkerMap(theComponent, theStream, theURL, theIsMultiFile, true, myMarkerMap);
   }
 
 
@@ -410,6 +614,16 @@ namespace VISU
     }
     if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - aFileNames.size() - "<<aFileNames.size());
 
+    // save textures of custom point markers
+    Result_i::TFileNames aTMPFileNames;
+    std::string aMarkerMapFileName, aMarkerMapFile;
+    if( SaveMarkerMap( aStudy, theURL, theIsMultiFile, false,
+                       myMarkerMap, aMarkerMapFileName, aMarkerMapFile ) ) {
+      aTMPFileNames.push_back( aMarkerMapFileName );
+      aFileNames.push_back( aMarkerMapFileName );
+      aFiles.push_back( aMarkerMapFile );
+    }
+
     SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile(0);
     if(aFileNames.empty())
       return aStreamFile._retn();
@@ -422,6 +636,11 @@ namespace VISU
     else
       aStreamFile = SALOMEDS_Tool::PutFilesToStream(aListOfFiles.in(), aListOfFileNames.in());
 
+    if(!theIsMultiFile && !aTMPFileNames.empty()) {
+      SALOMEDS::ListOfFileNames_var aListOfTMPFileNames = GetListOfFileNames(aTMPFileNames);
+      SALOMEDS_Tool::RemoveTemporaryFiles(theURL, aListOfTMPFileNames, true);
+    }
+
     return aStreamFile._retn();
   }
 
@@ -455,6 +674,14 @@ namespace VISU
     }
     if(MYDEBUG) MESSAGE("VISU_Gen_i::SaveASCII - aFileNames.size() - "<<aFileNames.size());
 
+    // save textures of custom point markers
+    std::string aMarkerMapFileName, aMarkerMapFile;
+    if( SaveMarkerMap( aStudy, anURL.c_str(), theIsMultiFile, true,
+                       myMarkerMap, aMarkerMapFileName, aMarkerMapFile ) ) {
+      aFileNames.push_back( aMarkerMapFileName );
+      aFiles.push_back( aMarkerMapFile );
+    }
+
     SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile(0);
     if(aFileNames.empty())
       return aStreamFile._retn();
@@ -1594,4 +1821,27 @@ namespace VISU
 
     return res == 0;
   }
+
+  CORBA::Long
+  VISU_Gen_i
+  ::LoadTexture(const char* theTextureFile)
+  {
+    if( CORBA::is_nil( myStudyDocument ) )
+      return 0;
+
+    int aStudyId = myStudyDocument->StudyId();
+
+    VTK::MarkerTexture aMarkerTexture;
+    if( !VTK::LoadTextureData( theTextureFile, VTK::MS_NONE, aMarkerTexture ) )
+      return 0;
+
+    VTK::MarkerMap& aMarkerMap = myMarkerMap[ aStudyId ];
+    int aMarkerId = VTK::GetUniqueId( aMarkerMap );
+
+    VTK::MarkerData& aMarkerData = aMarkerMap[ aMarkerId ];
+    aMarkerData.first = theTextureFile;
+    aMarkerData.second = aMarkerTexture;
+
+    return aMarkerId;
+  }
 }
index 951688c973933df12ac31075fb0b03cb19abcf1f..216f0601e7d4c15d455f9ec5ff0749fff43d85ba 100644 (file)
 #include "VISU_ColoredPrs3d_i.hh"
 #include "VISU_ClippingPlaneMgr.hxx"
 
+#include <VTKViewer_MarkerDef.h>
+
+#include <map>
 #include <string>
 
 namespace VISU
 {
+  //----------------------------------------------------------------------------
+  typedef std::map<int, VTK::MarkerMap> StudyId2MarkerMap;
+
   //----------------------------------------------------------------------------
   class VISU_Gen_i : public virtual POA_VISU::VISU_Gen,
                     public virtual ::Engines_Component_i,
@@ -46,6 +52,8 @@ namespace VISU
     SALOMEDS::Study_var myStudyDocument;
     VISU_ClippingPlaneMgr myClippingPlaneMgr;
 
+    StudyId2MarkerMap myMarkerMap;
+
     VISU_Gen_i(const VISU::VISU_Gen_i &);
   public:
     VISU_Gen_i(CORBA::ORB_ptr theORB,
@@ -413,6 +421,10 @@ namespace VISU
            const char* theMeshName,
            const VISU::double_array& theTStamps);
 
+    /* Load texture from file */
+    virtual CORBA::Long LoadTexture(const char* theTextureFile);
+
+    StudyId2MarkerMap& GetMarkerMap() { return myMarkerMap; }
   };
 }
 
index f0533c30c9452035f86ff053b9c759b764c5b3dd..0bda5dbbd46b9d04bbb17ff37a3f042976b4714a 100644 (file)
@@ -727,6 +727,29 @@ void VISU::PointMap3d_i::GetOffset(CORBA::Float& theDx, CORBA::Float& theDy, COR
   theDz = myOffset[2];
 }
 
+void VISU::PointMap3d_i::SetMarkerStd(VISU::MarkerType, VISU::MarkerScale)
+{
+}
+
+void VISU::PointMap3d_i::SetMarkerTexture(CORBA::Long)
+{
+}
+
+VISU::MarkerType VISU::PointMap3d_i::GetMarkerType()
+{
+  return VISU::MT_NONE;
+}
+
+VISU::MarkerScale VISU::PointMap3d_i::GetMarkerScale()
+{
+  return VISU::MS_NONE;
+}
+
+CORBA::Long VISU::PointMap3d_i::GetMarkerTexture()
+{
+  return 0;
+}
+
 CORBA::Float VISU::PointMap3d_i::GetMemorySize()
 {
   CORBA::Float aSize = GetSpecificPL()->GetMemorySize();
index 547191d8b5624413a03fd2714366263930070632..252c00e7d4bf2a1feb46d4d1829823560271046b 100644 (file)
@@ -77,6 +77,13 @@ namespace VISU
     //! Gets offset parameters for the 3D presentation
     virtual void GetOffset(CORBA::Float& theDx, CORBA::Float& theDy, CORBA::Float& theDz);
 
+    //! Do nothing, just for compilability
+    virtual void SetMarkerStd(VISU::MarkerType, VISU::MarkerScale);
+    virtual void SetMarkerTexture(CORBA::Long);
+    virtual VISU::MarkerType GetMarkerType();
+    virtual VISU::MarkerScale GetMarkerScale();
+    virtual CORBA::Long GetMarkerTexture();
+
     //! Gets memory size actually used by the presentation (Mb).
     virtual CORBA::Float GetMemorySize();
 
index 17468de966fc0c5e2384614cecb7901f5d3a7fbc..ac0058d561cd78c05d89927c47ab0a416a54712b 100644 (file)
@@ -26,6 +26,7 @@
 //
 #include "VISU_Prs3d_i.hh"
 #include "VISU_Prs3dUtils.hh"
+#include "VISU_Gen_i.hh"
 #include "VISU_PipeLine.hxx"
 
 #include "VISU_Result_i.hh"
@@ -35,6 +36,8 @@
 #include "SUIT_ResourceMgr.h"
 #include "SUIT_MessageBox.h"
 
+#include <VTKViewer_MarkerUtils.h>
+
 #include <vtkActorCollection.h>
 #include <vtkUnstructuredGrid.h>
 #include <vtkDataSet.h>
@@ -59,6 +62,11 @@ VISU::Prs3d_i::Prs3d_i() :
   if(MYDEBUG) MESSAGE("Prs3d_i::Prs3d_i - this = "<<this);
   myOffset[0] = myOffset[1] = myOffset[2] = 0;
   myActorCollection->Delete();
+
+  SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
+  myMarkerType = (VISU::MarkerType)aResourceMgr->integerValue("VISU", "type_of_marker", 1); // dot
+  myMarkerScale = (VISU::MarkerScale)aResourceMgr->integerValue("VISU", "marker_scale", 9); // 5 pixels
+  myMarkerId = 0;
 }
 
 
@@ -73,6 +81,10 @@ VISU::Prs3d_i
     GetPipeLine()->SameAs(anOrigin->GetPipeLine());
     anOrigin->GetOffset(myOffset);
 
+    myMarkerType = anOrigin->GetMarkerType();
+    myMarkerScale = anOrigin->GetMarkerScale();
+    myMarkerId = anOrigin->GetMarkerTexture();
+
     SetForcedHidden(anOrigin->IsForcedHidden());
   }
 }
@@ -312,6 +324,9 @@ VISU::Prs3d_i
   myOffset[0] = VISU::Storable::FindValue(theMap,"myOffset[0]").toFloat();
   myOffset[1] = VISU::Storable::FindValue(theMap,"myOffset[1]").toFloat();
   myOffset[2] = VISU::Storable::FindValue(theMap,"myOffset[2]").toFloat();
+  myMarkerType = VISU::MarkerType(VISU::Storable::FindValue(theMap,"myMarkerType").toInt());
+  myMarkerScale = VISU::MarkerScale(VISU::Storable::FindValue(theMap,"myMarkerScale").toInt());
+  myMarkerId = VISU::Storable::FindValue(theMap,"myMarkerId").toInt();
   myParamsTime.Modified();
   return this;
 }
@@ -327,6 +342,9 @@ VISU::Prs3d_i
   Storable::DataToStream( theStr, "myOffset[0]", myOffset[0] );
   Storable::DataToStream( theStr, "myOffset[1]", myOffset[1] );
   Storable::DataToStream( theStr, "myOffset[2]", myOffset[2] );
+  Storable::DataToStream( theStr, "myMarkerType", int(myMarkerType) );
+  Storable::DataToStream( theStr, "myMarkerScale", int(myMarkerScale) );
+  Storable::DataToStream( theStr, "myMarkerId", myMarkerId );
 }
 
 
@@ -498,6 +516,15 @@ VISU::Prs3d_i
     theActor->SetPrs3d(this);
     theActor->SetShrinkFactor(aResourceMgr->integerValue("VISU", "shrink_factor", 80)/100.);
     theActor->SetPosition(myOffset[0],myOffset[1],myOffset[2]);
+
+    if( myMarkerType != VISU::MT_USER )
+      theActor->SetMarkerStd( (VTK::MarkerType)myMarkerType, (VTK::MarkerScale)myMarkerScale );
+    else if( myMarkerId > 0 ) {
+      VTK::MarkerTexture aMarkerTexture;
+      if( LoadMarkerTexture( myMarkerId, aMarkerTexture ) )
+        theActor->SetMarkerTexture( myMarkerId, aMarkerTexture );
+    }
+
     theActor->SetPipeLine(GetActorPipeLine());
     if(theActor->GetPipeLine() != GetPipeLine()){
        // To decrease actor'ss pipeline reference counter
@@ -546,6 +573,15 @@ VISU::Prs3d_i
   if(VISU_Actor* anActor = dynamic_cast<VISU_Actor*>(theActor)){
     if(MYDEBUG) MESSAGE("Prs3d_i::UpdateActor - this = "<<this<<"; theActor = "<<anActor);
     anActor->SetPosition(myOffset[0],myOffset[1],myOffset[2]);
+
+    if( myMarkerType != VISU::MT_USER )
+      anActor->SetMarkerStd( (VTK::MarkerType)myMarkerType, (VTK::MarkerScale)myMarkerScale );
+    else if( myMarkerId > 0 ) {
+      VTK::MarkerTexture aMarkerTexture;
+      if( LoadMarkerTexture( myMarkerId, aMarkerTexture ) )
+        anActor->SetMarkerTexture( myMarkerId, aMarkerTexture );
+    }
+
     anActor->ShallowCopyPL(GetPipeLine());
     anActor->highlight(anActor->isHighlighted());
   }
@@ -734,3 +770,75 @@ VISU::Prs3d_i
 {
   myIsForcedHidden = theFlag;
 }
+
+//----------------------------------------------------------------------------
+void
+VISU::Prs3d_i
+::SetMarkerStd(VISU::MarkerType theMarkerType, VISU::MarkerScale theMarkerScale)
+{
+  myMarkerType = theMarkerType;
+  myMarkerScale = theMarkerScale;
+  myParamsTime.Modified();
+}
+  
+//----------------------------------------------------------------------------
+void
+VISU::Prs3d_i
+::SetMarkerTexture(CORBA::Long theMarkerId)
+{
+  myMarkerType = VISU::MT_USER;
+  myMarkerId = theMarkerId;
+  myParamsTime.Modified();
+}
+  
+//----------------------------------------------------------------------------
+VISU::MarkerType
+VISU::Prs3d_i
+::GetMarkerType()
+{
+  return myMarkerType;
+}
+
+//----------------------------------------------------------------------------
+VISU::MarkerScale
+VISU::Prs3d_i
+::GetMarkerScale()
+{
+  return myMarkerScale;
+}
+
+//----------------------------------------------------------------------------
+CORBA::Long
+VISU::Prs3d_i
+::GetMarkerTexture()
+{
+  return myMarkerId;
+}
+
+//----------------------------------------------------------------------------
+bool
+VISU::Prs3d_i
+::LoadMarkerTexture(int theMarkerId, VTK::MarkerTexture& theMarkerTexture)
+{
+  VISU::VISU_Gen_i* aVisuGen = VISU::VISU_Gen_i::GetVisuGenImpl();
+  if( !aVisuGen )
+    return false;
+
+  const VISU::StudyId2MarkerMap& aStudyId2MarkerMap = aVisuGen->GetMarkerMap();
+
+  const SALOMEDS::Study_var& aStudy = GetStudyDocument();
+  if( CORBA::is_nil( aStudy.in() ) )
+    return false;
+
+  int aStudyId = aStudy->StudyId();
+  VISU::StudyId2MarkerMap::const_iterator aStudyId2MarkerIter = aStudyId2MarkerMap.find( aStudyId );
+  if( aStudyId2MarkerIter == aStudyId2MarkerMap.end() )
+    return false;
+
+  VTK::MarkerMap aMarkerMap = aStudyId2MarkerIter->second;
+  VTK::MarkerMap::const_iterator aMarkerIter = aMarkerMap.find( theMarkerId );
+  if( aMarkerIter == aMarkerMap.end() )
+    return false;
+
+  theMarkerTexture = aMarkerIter->second.second;
+}
index 6f54053ccfdbd1d2c715a54c38fca958b70a2bf8..929a7eea865e72f5ad87a690fb5a8cbb7dd84ea4 100644 (file)
@@ -262,6 +262,32 @@ namespace VISU
              CORBA::Float& theDy, 
              CORBA::Float& theDz);
 
+    //----------------------------------------------------------------------------
+    //! Set standard point marker for the object
+    virtual
+    void
+    SetMarkerStd(VISU::MarkerType theMarkerType, VISU::MarkerScale theMarkerScale);
+  
+    //! Set custom point marker
+    virtual
+    void
+    SetMarkerTexture(CORBA::Long theTextureId);
+  
+    //! Get type of the point marker
+    virtual
+    VISU::MarkerType
+    GetMarkerType();
+
+    //! Get scale of the point marker
+    virtual
+    VISU::MarkerScale
+    GetMarkerScale();
+
+    //! Get texture identifier of the point marker
+    virtual
+    CORBA::Long
+    GetMarkerTexture();
+  
     //----------------------------------------------------------------------------
     //! Gets memory size actually used by the presentation (Mb).
     virtual
@@ -332,6 +358,9 @@ namespace VISU
     void
     CheckDataSet();
 
+    bool
+    LoadMarkerTexture(int theMarkerId, VTK::MarkerTexture& theMarkerTexture);
+
   protected:
     vtkTimeStamp myUpdateTime;
     vtkTimeStamp myParamsTime;
@@ -352,6 +381,10 @@ namespace VISU
 
     CORBA::Float myOffset[3];
 
+    VISU::MarkerType myMarkerType;
+    VISU::MarkerScale myMarkerScale;
+    int myMarkerId;
+
     boost::signal0<void> myUpdateActorsSignal;
     boost::signal0<void> myRemoveActorsFromRendererSignal;
     vtkSmartPointer<vtkActorCollection> myActorCollection;
index 3b4a7ca498bb149ec8361763619069dffb6a3c18..db0513ea011130879e78057acfa59258235a22cd 100644 (file)
@@ -63,7 +63,7 @@ dist_salomescript_DATA = batchmode_visu.py batchmode_visu_table.py batchmode_vis
        visu_succcessive_animation.py visu_apply_properties.py visu_apply_properties_successive.py \
        batchmode_visu_view.py visu_cache.py visu_pointmap3d.py visu_view3d_parameters.py visu_evolution.py \
        VISU_Example_01.py VISU_Example_02.py VISU_Example_03.py VISU_Example_04.py \
-       VISU_Example_05.py VISU_Example_06.py VISU_Example_07.py
+       VISU_Example_05.py VISU_Example_06.py VISU_Example_07.py VISU_Example_08.py
 
 nodist_salomescript_DATA = libVISU_Swig.py 
 
diff --git a/src/VISU_SWIG/VISU_Example_08.py b/src/VISU_SWIG/VISU_Example_08.py
new file mode 100644 (file)
index 0000000..c58ecbd
--- /dev/null
@@ -0,0 +1,89 @@
+#  -*- coding: iso-8859-1 -*-
+#  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+#
+#  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+#  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+#  This library is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU Lesser General Public
+#  License as published by the Free Software Foundation; either
+#  version 2.1 of the License.
+#
+#  This library is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+#  Lesser General Public License for more details.
+#
+#  You should have received a copy of the GNU Lesser General Public
+#  License along with this library; if not, write to the Free Software
+#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+#  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+# Set different point markers for presentation
+#
+import salome
+
+import VISU
+import visu_gui
+
+import os
+import time
+
+data_dir = os.getenv("DATA_DIR")
+sleep_delay = 1
+
+myVisu = visu_gui.myVisu
+myVisu.SetCurrentStudy(salome.myStudy)
+myViewManager = myVisu.GetViewManager()
+myView = myViewManager.Create3DView()
+
+medFile = "fra.med"
+aMeshName ="LE VOLUME"
+anEntity = VISU.NODE
+aFieldName = "VITESSE";
+aTimeStampId = 1
+
+medFile = data_dir + "/MedFiles/" + medFile
+
+print "Build Scalar Map presentation"
+myResult = myVisu.ImportFile(medFile)
+aScalarMap = myVisu.ScalarMapOnField(myResult,aMeshName,anEntity,aFieldName,aTimeStampId)
+myView.Display(aScalarMap);
+myView.FitAll();
+
+print "Set representation type to Point"
+myView.SetPresentationType(aScalarMap, VISU.POINT)
+time.sleep(sleep_delay)
+
+print "Set standard marker 1"
+aScalarMap.SetMarkerStd(VISU.MT_PLUS, VISU.MS_10)
+myView.Update()
+time.sleep(sleep_delay)
+
+print "Set standard marker 2"
+aScalarMap.SetMarkerStd(VISU.MT_STAR, VISU.MS_35)
+myView.Update()
+time.sleep(sleep_delay)
+
+print "Set standard marker 3"
+aScalarMap.SetMarkerStd(VISU.MT_O, VISU.MS_25)
+myView.Update()
+time.sleep(sleep_delay)
+
+print "Set custom marker 1"
+texture_1 = myVisu.LoadTexture(os.path.join(data_dir, "Textures", "texture1.dat"))
+aScalarMap.SetMarkerTexture(texture_1)
+myView.Update()
+time.sleep(sleep_delay)
+
+print "Set custom marker 2"
+texture_2 = myVisu.LoadTexture(os.path.join(data_dir, "Textures", "texture2.dat"))
+aScalarMap.SetMarkerTexture(texture_2)
+myView.Update()
+time.sleep(sleep_delay)
+
+print "Set custom marker 3"
+texture_3 = myVisu.LoadTexture(os.path.join(data_dir, "Textures", "texture3.dat"))
+aScalarMap.SetMarkerTexture(texture_3)
+myView.Update()