]> SALOME platform Git repositories - modules/visu.git/blobdiff - src/VISU_I/VISU_Prs3d_i.cc
Salome HOME
Merge from BR_WIN_INDUS_514 branch 21/03/2011 (Windows industrialization)
[modules/visu.git] / src / VISU_I / VISU_Prs3d_i.cc
index 17468de966fc0c5e2384614cecb7901f5d3a7fbc..b66b023e2509f7041ceef4ec6459c8aa433ffa3c 100644 (file)
@@ -1,4 +1,4 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+//  Copyright (C) 2007-2010  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
@@ -19,6 +19,7 @@
 //
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 //  VISU OBJECT : interactive object for VISU entities implementation
 //  File   : VISU_Prs3d_i.cc
 //  Author : Alexey PETROV
@@ -26,6 +27,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 +37,8 @@
 #include "SUIT_ResourceMgr.h"
 #include "SUIT_MessageBox.h"
 
+#include <VTKViewer_MarkerUtils.h>
+
 #include <vtkActorCollection.h>
 #include <vtkUnstructuredGrid.h>
 #include <vtkDataSet.h>
@@ -59,6 +63,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 +82,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 +325,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 +343,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 );
 }
 
 
@@ -406,7 +425,7 @@ VISU::Prs3d_i
     Execute()
     {
       //TInvokeSignalEvent::Execute();
-      myRemovable->Destroy();
+      myRemovable->UnRegister();
     }
   };
 
@@ -498,6 +517,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 +574,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());
   }
@@ -638,6 +675,7 @@ void
 VISU::Prs3d_i
 ::SetOffset(const CORBA::Float* theOffsets)
 {
+  VISU::TSetModified aModified(this);
   myOffset[0] = theOffsets[0];
   myOffset[1] = theOffsets[1];
   myOffset[2] = theOffsets[2];
@@ -651,6 +689,7 @@ VISU::Prs3d_i
            CORBA::Float theDy,
            CORBA::Float theDz)
 {
+  VISU::TSetModified aModified(this);
   myOffset[0] = theDx;
   myOffset[1] = theDy;
   myOffset[2] = theDz;
@@ -734,3 +773,78 @@ VISU::Prs3d_i
 {
   myIsForcedHidden = theFlag;
 }
+
+//----------------------------------------------------------------------------
+void
+VISU::Prs3d_i
+::SetMarkerStd(VISU::MarkerType theMarkerType, VISU::MarkerScale theMarkerScale)
+{
+  myMarkerType = theMarkerType;
+  myMarkerScale = theMarkerScale;
+  if( myMarkerType == VISU::MT_POINT_SPRITE )
+    myMarkerScale = VISU::MS_NONE;
+  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;
+  return true;
+}