]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Fix for NPAL15484.
authormzn <mzn@opencascade.com>
Thu, 8 May 2008 05:42:59 +0000 (05:42 +0000)
committermzn <mzn@opencascade.com>
Thu, 8 May 2008 05:42:59 +0000 (05:42 +0000)
23 files changed:
idl/VISU_Gen.idl
src/OBJECT/Makefile.in
src/OBJECT/VISU_IsoSurfActor.cxx [new file with mode: 0644]
src/OBJECT/VISU_IsoSurfActor.h [new file with mode: 0644]
src/PIPELINE/Makefile.in
src/PIPELINE/VISU_LabelPointsFilter.cxx [new file with mode: 0644]
src/PIPELINE/VISU_LabelPointsFilter.hxx [new file with mode: 0644]
src/VISUGUI/VISU_msg_en.po
src/VISUGUI/VisuGUI_IsoSurfacesDlg.cxx
src/VISUGUI/VisuGUI_IsoSurfacesDlg.h
src/VISU_I/Makefile.in
src/VISU_I/VISU_DeformedShape_i.cc
src/VISU_I/VISU_DeformedShape_i.hh
src/VISU_I/VISU_DumpPython.cc
src/VISU_I/VISU_IsoSurfaces_i.cc
src/VISU_I/VISU_IsoSurfaces_i.hh
src/VISU_I/VISU_MonoColorPrs_i.cc [new file with mode: 0644]
src/VISU_I/VISU_MonoColorPrs_i.hh [new file with mode: 0644]
src/VISU_I/VISU_PrsMerger_i.cc
src/VISU_I/VISU_PrsMerger_i.hh
src/VISU_I/VISU_StreamLines_i.cc
src/VISU_I/VISU_StreamLines_i.hh
src/VISU_I/VISU_Vectors_i.cc

index ac0d71b79405c4251c50908d16b9ab505139fd17..04036c712d27ef16b71a7b62b713393212804f29 100644 (file)
@@ -577,30 +577,11 @@ module VISU {
     void RemoveAllGeom();
   };
 
-  //-------------------------------------------------------
-  /*! \brief Gauss Points presentation interface
-   *
-   * Presentation parameters of the Gauss Points presentation.
-   */
-  //-------------------------------------------------------
-  interface GaussPoints : ColoredPrs3d {
-  };
-
-  /*! \brief Deformed shape presentation interface
+  /*! \brief MonoColor presentation presentation interface
    *
-   * Presentation parameters of the deformed shape presentation.
+   * Presentation parameters of the MonoColor presentation.
    */
-  interface DeformedShape : ScalarMap {
-    /*!
-     * Sets the scale of the presentatable object.
-     * \param theScale Double value defining the scale of this presentable object.
-     */
-    void SetScale(in double theScale);
-
-    /*!
-     * Gets the scale of the presentatable object.
-     */
-    double GetScale();
+  interface MonoColorPrs : ScalarMap {
 
     /*! This boolean method returns True if this deformed shape presentation is colored.
      */
@@ -625,6 +606,35 @@ module VISU {
   };
 
 
+  //-------------------------------------------------------
+  /*! \brief Gauss Points presentation interface
+   *
+   * Presentation parameters of the Gauss Points presentation.
+   */
+  //-------------------------------------------------------
+  interface GaussPoints : ColoredPrs3d 
+  {
+  };
+
+
+  /*! \brief Deformed shape presentation interface
+   *
+   * Presentation parameters of the deformed shape presentation.
+   */
+  interface DeformedShape : MonoColorPrs {
+    /*!
+     * Sets the scale of the presentatable object.
+     * \param theScale Double value defining the scale of this presentable object.
+     */
+    void SetScale(in double theScale);
+
+    /*!
+     * Gets the scale of the presentatable object.
+     */
+    double GetScale();
+  };
+
+
   //-------------------------------------------------------
   /*! \brief Scalar Map on Deformed shape presentation interface
    *
@@ -1057,7 +1067,7 @@ module VISU {
    * Streamlines are used to convey the structure of a vector field.
    * Usually streamlines are created to explore the most interesting features in the field.
    */
-  interface StreamLines : DeformedShape {
+  interface StreamLines : MonoColorPrs {
     /*! This enumerations contains a set of elements necessary
      * for definition of direction of the stream lines.
      */
@@ -1127,7 +1137,7 @@ module VISU {
    * values on the cells and on the basis of them constructs
    * isobaric surfaces, which form this presentation.
    */
-  interface IsoSurfaces : ScalarMap {
+  interface IsoSurfaces : MonoColorPrs {
     /*!
      * Sets the number of isometric surfaces.
      * \param theNb A long value defining the number of isometric surfaces
@@ -1139,6 +1149,21 @@ module VISU {
      * Gets the number of isometric surfaces
      */
     long GetNbSurfaces();
+    
+    /*!
+     * Returns TRUE if labels with values are shown
+     */
+    boolean IsLabeled();
+    
+    /*!
+     * Set show or not value labels
+     */
+    void ShowLabels(in boolean theShow, in long theNb);
+    
+    /*!
+     * Returns Nb of labels per surface
+     */
+    long GetNbLabels();
   };
 
   //-------------------------------------------------------
index 92c9b0148cd463bad280b3241022451befd74b48..0d3e75232ff0437ab48724b7379399b3c6151ef4 100644 (file)
@@ -42,7 +42,8 @@ EXPORT_HEADERS = \
        VISU_MeshAct.h \
        VISU_ScalarMapAct.h \
        VISU_GaussPtsAct.h \
-       VISU_VectorsAct.h
+       VISU_VectorsAct.h \
+       VISU_IsoSurfActor.h
 
 # Libraries targets
 
@@ -54,7 +55,8 @@ LIB_SRC = \
        VISU_GaussPtsDeviceActor.cxx \
        VISU_GaussPtsSettings.cxx \
        VISU_GaussPtsAct.cxx \
-       VISU_VectorsAct.cxx
+       VISU_VectorsAct.cxx \
+       VISU_IsoSurfActor.cxx
 
 LIB_CLIENT_IDL = 
 
diff --git a/src/OBJECT/VISU_IsoSurfActor.cxx b/src/OBJECT/VISU_IsoSurfActor.cxx
new file mode 100644 (file)
index 0000000..3c58fc4
--- /dev/null
@@ -0,0 +1,165 @@
+//  VISU OBJECT : interactive object for VISU entities implementation
+//
+//  Copyright (C) 2003  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
+//
+//
+//
+//  File   : VISU_IsoSurfActor.cxx
+//  Author : Vitaly Smetannikov
+//  Module : VISU
+
+
+#include "VISU_IsoSurfActor.h"
+#include "VISU_PipeLine.hxx"
+#include "VISU_LabelPointsFilter.hxx"
+
+
+#include <vtkObjectFactory.h>
+#include <vtkUnstructuredGrid.h>
+#include <vtkPolyData.h>
+#include <vtkActor2D.h>
+//#include <vtkMaskPoints.h>
+#include <vtkLabeledDataMapper.h>
+#include <vtkProperty2D.h>
+#include <vtkRenderer.h>
+#include <vtkCellArray.h>
+#include <vtkPointData.h>
+
+
+
+//----------------------------------------------------------------------------
+vtkStandardNewMacro(VISU_IsoSurfActor);
+
+
+//----------------------------------------------------------------------------
+VISU_IsoSurfActor::VISU_IsoSurfActor():
+  VISU_ScalarMapAct(),
+  myIsLinesLabeled(true)
+{
+  myLabelsDataSet = vtkPolyData::New();
+
+//   myMaskPoints = vtkMaskPoints::New();
+//   myMaskPoints->SetInput(myLabelsDataSet);
+//   myMaskPoints->SetOnRatio(100);
+
+  myMaskPoints = VISU_LabelPointsFilter::New();
+  myMaskPoints->SetInput(myLabelsDataSet);
+
+  myLabeledDataMapper = vtkLabeledDataMapper::New();
+  myLabeledDataMapper->SetInput(myMaskPoints->GetOutput());
+  //myLabeledDataMapper->SetLabelFormat("%e");
+  myLabeledDataMapper->SetLabelModeToLabelScalars();
+    
+  myLabels = vtkActor2D::New();
+  myLabels->SetMapper(myLabeledDataMapper);
+  myLabels->GetProperty()->SetColor(1,1,1);
+  myLabels->SetVisibility(myIsLinesLabeled);
+}
+
+
+//----------------------------------------------------------------------------
+VISU_IsoSurfActor::~VISU_IsoSurfActor()
+{
+  myLabelsDataSet->Delete();
+  myMaskPoints->Delete();
+  myLabeledDataMapper->Delete();
+  myLabels->Delete();
+}
+
+//----------------------------------------------------------------------------
+void VISU_IsoSurfActor::SetLinesLabeled(bool theIsLinesLabeled, int theNbLbl)
+{
+  myIsLinesLabeled = theIsLinesLabeled;
+  myMaskPoints->SetPointsNb(theNbLbl);
+  Modified();
+}
+//----------------------------------------------------------------------------
+int VISU_IsoSurfActor::GetNbLabels() const 
+{ 
+  return myMaskPoints->GetPointsNb(); 
+}
+
+
+//----------------------------------------------------------------------------
+void VISU_IsoSurfActor::UpdateLabels()
+{
+  if (myIsLinesLabeled) {
+    vtkDataSet* aDataSet = GetPipeLine()->GetOutput();
+    if (aDataSet != NULL) {
+      unsigned long aTime = myLabelsDataSet->GetMTime();
+      unsigned long anObjTime = GetMTime();
+      if (aTime < anObjTime) {
+       myLabelsDataSet->ShallowCopy(aDataSet);
+       myLabelsDataSet->Modified();
+      }
+    }
+  }
+  myLabels->SetVisibility(myIsLinesLabeled);
+}
+
+
+//----------------------------------------------------------------------------
+void VISU_IsoSurfActor::AddToRender(vtkRenderer* theRenderer)
+{
+  VISU_ScalarMapAct::AddToRender(theRenderer);
+  theRenderer->AddActor2D(myLabels);
+}
+
+//----------------------------------------------------------------------------
+void VISU_IsoSurfActor::RemoveFromRender(vtkRenderer* theRenderer)
+{
+  VISU_ScalarMapAct::RemoveFromRender(theRenderer);
+  theRenderer->RemoveActor(myLabels);
+}
+
+//From vtkFollower
+int VISU_IsoSurfActor::RenderOpaqueGeometry(vtkViewport *vp)
+{
+  UpdateLabels();
+  return VISU_ScalarMapAct::RenderOpaqueGeometry(vp);
+}
+
+
+int VISU_IsoSurfActor::RenderTranslucentGeometry(vtkViewport *vp)
+{
+  UpdateLabels();
+  return VISU_ScalarMapAct::RenderTranslucentGeometry(vp);
+}
+
+void VISU_IsoSurfActor::SetVisibility(int theMode){
+  VISU_ScalarMapAct::SetVisibility(theMode);
+  if(GetVisibility())
+    myLabels->VisibilityOn();
+  else
+    myLabels->VisibilityOff();
+  Modified();
+}
+
+
+///!!!! For test purposes only
+// void VISU_IsoSurfActor::SetMapperInput(vtkDataSet* theDataSet)
+// {
+//   VISU_ScalarMapAct::SetMapperInput(theDataSet);
+
+//   vtkFeatureEdges* aFilter = vtkFeatureEdges::New();
+//   aFilter->SetInput(VISU_ScalarMapAct::GetInput());
+//   SetInput(aFilter->GetOutput());
+// }
diff --git a/src/OBJECT/VISU_IsoSurfActor.h b/src/OBJECT/VISU_IsoSurfActor.h
new file mode 100644 (file)
index 0000000..6231419
--- /dev/null
@@ -0,0 +1,88 @@
+//  VISU OBJECT : interactive object for VISU entities implementation
+//
+//  Copyright (C) 2003  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
+//
+//
+//
+//  File   : VISU_IsoSurfActor.h
+//  Author : Vitaly Smetannikov
+//  Module : VISU
+
+
+#ifndef VISU_IsoSurfActor_HeaderFile
+#define VISU_IsoSurfActor_HeaderFile
+
+#include "VISU_ScalarMapAct.h"
+
+class vtkActor2D;
+//class vtkMaskPoints;
+class vtkLabeledDataMapper;
+class vtkPolyData;
+class VISU_LabelPointsFilter;
+
+
+class VTKOCC_EXPORT VISU_IsoSurfActor : public VISU_ScalarMapAct 
+{
+ public:
+  vtkTypeMacro(VISU_IsoSurfActor, VISU_ScalarMapAct);
+  
+  static VISU_IsoSurfActor* New();
+  
+  
+  //----------------------------------------------------------------------------
+  virtual void AddToRender( vtkRenderer* ); 
+  
+  virtual void RemoveFromRender( vtkRenderer* );
+
+  virtual int RenderOpaqueGeometry(vtkViewport *viewport);
+  virtual int RenderTranslucentGeometry(vtkViewport *viewport);
+  
+  //virtual void SetPipeLine(VISU_PipeLine* thePipeLine);
+
+  void SetLinesLabeled(bool theIsLinesLabeled, int theNbLbl);
+  bool GetLinesLabeled() const { return myIsLinesLabeled;}
+   
+  int GetNbLabels() const;
+
+
+  //----------------------------------------------------------------------------
+  //! Visibility management
+  virtual void SetVisibility( int );
+
+
+ protected:
+
+  VISU_IsoSurfActor();
+  ~VISU_IsoSurfActor();
+
+  void UpdateLabels();
+
+  vtkActor2D *myLabels;
+  vtkLabeledDataMapper* myLabeledDataMapper;
+  //vtkMaskPoints* myMaskPoints;
+  VISU_LabelPointsFilter* myMaskPoints;
+  vtkPolyData* myLabelsDataSet;
+
+  bool myIsLinesLabeled;
+  //int myNbLabels;
+};
+
+
+#endif
index ea47ffc3f99506e7cfa324fd1b6779d96324c781..da599120e524520c379eab7c4ec0b888198da979 100644 (file)
@@ -59,7 +59,8 @@ EXPORT_HEADERS = \
        VISU_WidgetCtrl.hxx \
        VISU_ScalarMapOnDeformedShapePL.hxx \
        VISU_PrsMergerPL.hxx \
-       VISU_CellDataToPointData.hxx
+       VISU_CellDataToPointData.hxx \
+       VISU_LabelPointsFilter.hxx
 
 # Libraries targets
 
@@ -91,7 +92,8 @@ LIB_SRC = \
        VISU_ScalarBarCtrl.cxx \
        VISU_ScalarMapOnDeformedShapePL.cxx \
        VISU_PrsMergerPL.cxx \
-       VISU_CellDataToPointData.cxx
+       VISU_CellDataToPointData.cxx \
+       VISU_LabelPointsFilter.cxx
 
 # Executables targets
 
diff --git a/src/PIPELINE/VISU_LabelPointsFilter.cxx b/src/PIPELINE/VISU_LabelPointsFilter.cxx
new file mode 100644 (file)
index 0000000..6c93ccc
--- /dev/null
@@ -0,0 +1,266 @@
+//  VISU OBJECT : interactive object for VISU entities implementation
+//
+//  Copyright (C) 2003  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
+//
+//
+//
+// File:    VISU_LabelPointsFilter.cxx
+// Author:  Vitaly Smetannikov
+// Module : VISU
+
+
+
+#include "VISU_LabelPointsFilter.hxx"
+
+#include <vtkPolyData.h>
+#include <vtkObjectFactory.h>
+#include <vtkFeatureEdges.h>
+#include <vtkCellArray.h>
+#include <vtkPointData.h>
+#include <vtkCellData.h>
+#include <vtkDataArray.h>
+#include <vtkDoubleArray.h>
+#include <vtkGeometryFilter.h>
+#include <vtkPolyDataConnectivityFilter.h>
+#include <vtkMath.h>
+
+#include <set>
+#include <vector>
+
+
+#define CONTAINS(SET, PT) (SET.find(PT) != SET.end())
+
+struct ltIdType 
+{
+  bool operator()(const vtkIdType a1, const vtkIdType a2) const
+  {
+    return a1 < a2;
+  }
+};
+
+
+
+//----------------------------------------------------------------------------
+vtkStandardNewMacro(VISU_LabelPointsFilter);
+
+
+//----------------------------------------------------------------------------
+void VISU_LabelPointsFilter::SetPointsNb(int theNb)
+{
+  if (myPointsNb == theNb) return;
+  myPointsNb = (theNb < 1)? 1:theNb;
+  Modified();
+}
+
+//----------------------------------------------------------------------------
+VISU_LabelPointsFilter::VISU_LabelPointsFilter():
+  vtkPolyDataToPolyDataFilter(),
+  myPointsNb(3)
+{
+}
+
+//----------------------------------------------------------------------------
+VISU_LabelPointsFilter::~VISU_LabelPointsFilter()
+{}
+
+//----------------------------------------------------------------------------
+void VISU_LabelPointsFilter::Execute()
+{
+  vtkPolyData *input= this->GetInput();
+  vtkPolyData *output = this->GetOutput();
+  
+  GetRegions(input, output);
+}
+
+int VISU_LabelPointsFilter::GetRegions(vtkPolyData* theInput, 
+                                      vtkPolyData* theOutput)
+{
+  vtkIdType cellId, i;
+  vtkIdType numPts, numCells;
+  vtkPoints *inPts;
+
+  vtkPointData *aInpPD=theInput->GetPointData(), *aOutPD=theOutput->GetPointData();
+  vtkCellData *aInpCD=theInput->GetCellData(), *aOutCD=theOutput->GetCellData();
+  
+  //  Check input/allocate storage
+  //
+  inPts = theInput->GetPoints();
+
+  if (inPts == NULL)
+    return 1;
+
+  numPts = inPts->GetNumberOfPoints();
+  numCells = theInput->GetNumberOfCells();
+
+  if ( numPts < 1 || numCells < 1 )
+    return 1;
+
+  // Build cell structure
+  //
+  vtkPolyData* aMesh = vtkPolyData::New();
+  aMesh->CopyStructure(theInput);
+  aMesh->BuildLinks();
+
+  // Initialize.  Keep track of points and cells visited.
+  //
+  vtkIdTypeArray* aRegionSizes = vtkIdTypeArray::New();
+  int* aVisited = new int[numCells];
+  for ( i=0; i < numCells; i++ )
+     aVisited[i] = -1;
+
+  vtkIdType* aPointMap = new vtkIdType[numPts];  
+  for ( i=0; i < numPts; i++ )
+    aPointMap[i] = -1;
+
+  vtkPoints* newPts = vtkPoints::New();
+  newPts->Allocate(numPts);
+
+  // Traverse all cells marking those visited.  Each new search
+  // starts a new connected region. Connected region grows 
+  // using a connected wave propagation.
+  //
+  vtkIdList* aWave = vtkIdList::New();
+  aWave->Allocate(numPts/4+1,numPts);
+  vtkIdList* aWave2 = vtkIdList::New();
+  aWave2->Allocate(numPts/4+1,numPts);
+
+  vtkIdType aPointNumber = 0;
+  int aRegionNumber = 0;
+
+  vtkIdList* aCellIds = vtkIdList::New(); 
+  aCellIds->Allocate(8, VTK_CELL_SIZE);
+  vtkIdList* aPointIds = vtkIdList::New(); 
+  aPointIds->Allocate(8, VTK_CELL_SIZE);
+
+  //  vtkIdType aNumCellsInRegion;
+
+  aOutPD->CopyAllocate(aInpPD);
+  aOutCD->CopyAllocate(aInpCD);
+
+  //visit all cells marking with region number
+  for (cellId=0; cellId < numCells; cellId++) {
+    if ( aVisited[cellId] < 0 ) {
+      aWave->InsertNextId(cellId);
+      aPointNumber = 0;
+      TraverseAndMark(aWave, aWave2, aVisited, aPointMap, 
+                     aRegionNumber, aPointNumber, aMesh);
+      
+      if (aPointNumber >= myPointsNb) {
+       std::set<vtkIdType, ltIdType> aIdxSet;
+       for (i=0; i < numPts; i++) {
+         if ( aPointMap[i] > -1 ) {
+           aIdxSet.insert(i);
+           aPointMap[i] = -1;
+         }
+       }
+       std::vector<vtkIdType> aIdx(aIdxSet.begin(), aIdxSet.end());
+       int aActualPts = aIdx.size();
+       int aNewId;
+       if (myPointsNb > 2) {
+         int k = aActualPts/(myPointsNb - 1);
+         int count;
+         for (i=0, count = 0; i < aActualPts; i+=k, count++) {
+           aNewId = newPts->InsertNextPoint(inPts->GetPoint(aIdx[i]));
+           aOutPD->CopyData(aInpPD, aIdx[i], aNewId);
+         }
+         if (count < myPointsNb) {
+           aNewId = newPts->InsertNextPoint(inPts->GetPoint(aIdx[aActualPts - 1]));
+           aOutPD->CopyData(aInpPD, aIdx[aActualPts - 1], aNewId);
+         }
+       } else {          
+         aNewId = newPts->InsertNextPoint(inPts->GetPoint(aIdx[0]));
+         aOutPD->CopyData(aInpPD, aIdx[0], aNewId);
+         if (myPointsNb == 2) {
+           aNewId = newPts->InsertNextPoint(inPts->GetPoint(aIdx[aActualPts - 1]));
+           aOutPD->CopyData(aInpPD, aIdx[aActualPts - 1], aNewId);
+         }
+       }
+      }
+      aWave->Reset();
+      aWave2->Reset(); 
+    }
+  }
+
+  aWave->Delete();
+  aWave2->Delete();
+
+  theOutput->SetPoints(newPts);
+  newPts->Delete();
+
+
+  delete [] aVisited;
+  delete [] aPointMap;
+  aMesh->Delete();
+  theOutput->Squeeze();
+  aCellIds->Delete();
+  aPointIds->Delete();
+
+  return aRegionSizes->GetMaxId() + 1;
+}
+
+
+// Mark current cell as visited and assign region number.  Note:
+// traversal occurs across shared vertices.
+//
+void VISU_LabelPointsFilter::TraverseAndMark (vtkIdList* theWave, 
+                                             vtkIdList* theWave2, 
+                                             int* theVisited,
+                                             vtkIdType* thePointMap,
+                                             int& theRegionNumber,
+                                             vtkIdType& thePointNumber,
+                                             vtkPolyData* theMesh)
+{
+  vtkIdType cellId, ptId, numIds, i;
+  int j, k;
+  vtkIdType *pts, *cells, npts;
+  vtkIdList *tmpWave;
+  unsigned short ncells;
+  vtkIdList* aNeighborCellPointIds = vtkIdList::New();
+
+
+  while ( (numIds=theWave->GetNumberOfIds()) > 0 ) {
+    for ( i=0; i < numIds; i++ ) {
+      cellId = theWave->GetId(i);
+      if ( theVisited[cellId] < 0 ) {
+        theVisited[cellId] = theRegionNumber;
+        theMesh->GetCellPoints(cellId, npts, pts);
+       
+        for (j=0; j < npts; j++) {
+          if ( thePointMap[ptId=pts[j]] < 0 ) {
+            thePointMap[ptId] = thePointNumber++;
+         }       
+          theMesh->GetPointCells(ptId,ncells,cells);
+         
+          // check connectivity criterion (geometric + scalar)
+          for (k=0; k < ncells; k++) {
+            cellId = cells[k];
+           theWave2->InsertNextId(cellId);
+           //              }
+         }//for all cells using this point
+       }//for all points of this cell
+      }//if cell not yet visited
+    }//for all cells in this wave
+    
+    tmpWave = theWave;
+    theWave = theWave2;
+    theWave2 = tmpWave;
+    tmpWave->Reset();
+  } //while wave is not empty
+}
diff --git a/src/PIPELINE/VISU_LabelPointsFilter.hxx b/src/PIPELINE/VISU_LabelPointsFilter.hxx
new file mode 100644 (file)
index 0000000..8bd7829
--- /dev/null
@@ -0,0 +1,68 @@
+//  VISU OBJECT : interactive object for VISU entities implementation
+//
+//  Copyright (C) 2003  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
+//
+//
+// File:    VISU_LabelPointsFilter.hxx
+// Author:  Vitaly Smetannikov
+// Module : VISU
+
+#ifndef VISU_LabelPointsFilter_HeaderFile
+#define VISU_LabelPointsFilter_HeaderFile
+
+#include <vtkPolyDataToPolyDataFilter.h>
+
+class vtkIdList;
+class vtkPolyData;
+
+class VISU_LabelPointsFilter : public vtkPolyDataToPolyDataFilter
+{
+public:
+  vtkTypeMacro(VISU_LabelPointsFilter, vtkPolyDataToPolyDataFilter);
+
+  static VISU_LabelPointsFilter* New();
+
+  void SetPointsNb(int theNb);
+
+  int GetPointsNb() const { return myPointsNb; }
+
+protected:
+  VISU_LabelPointsFilter();
+
+  virtual ~VISU_LabelPointsFilter();
+
+  virtual void Execute();
+
+  void TraverseAndMark(vtkIdList* theWave, 
+                      vtkIdList* theWave2, 
+                      int* theVisited,
+                      vtkIdType* thePointMap,
+                      int& theRegionNumber,
+                      vtkIdType& thePointNumber,
+                      vtkPolyData* theMesh);
+  
+  int GetRegions(vtkPolyData* theInput, 
+                vtkPolyData* theOutput);
+
+  int myPointsNb;
+};
+
+
+#endif
index d7e80745f243cd5e6ccc1c7fe1ffdde6caeab07f..e0f45914bee1d86797d56ed12f0e9f935e3f1a49 100644 (file)
@@ -712,6 +712,14 @@ msgstr "Number of surfaces:"
 msgid "VisuGUI_IsoSurfacesDlg::DEFINE_ISOSURFACES"
 msgstr "Iso Surfaces Definition"
 
+msgid "VisuGUI_IsoSurfPane::MAGNITUDE_COLORING_CHK"
+msgstr "Magnitude coloring"
+
+msgid "VisuGUI_IsoSurfPane::SEL_COLOR_BTN"
+msgstr "Select Color"
+
+msgid "VisuGUI_IsoSurfPane::SHOW_VALUES_CHK"
+msgstr "Show values (nb per surface)"
 
 #: VisuGUI_NonIsometricDlg.cxx
 
index 909c730df5e6dd48e38b57dcad960b606954f6aa..e8cd10e70aca5c3e757ebb32c72ac025dc497f98 100644 (file)
@@ -43,6 +43,7 @@
 #include <qlayout.h>
 #include <qvalidator.h>
 #include <qtabwidget.h>
+#include <qcolordialog.h>
 
 using namespace std;
 
@@ -85,13 +86,31 @@ VisuGUI_IsoSurfPane::VisuGUI_IsoSurfPane (QWidget* parent)
   LabelMax->setBuddy(MaxIso);
   TopGroupLayout->addWidget( MaxIso, 2, 1 );
 
+  myUseMagnitude = new QCheckBox(tr("MAGNITUDE_COLORING_CHK"), TopGroup, "myUseMagnitude");
+  myUseMagnitude->setChecked(true);
+  TopGroupLayout->addWidget( myUseMagnitude, 3, 0 );
+  mySelColor = new QPushButton(tr("SEL_COLOR_BTN"), TopGroup, "mySelColor");
+  mySelColor->setPaletteBackgroundColor(Qt::black);
+  mySelColor->setPaletteForegroundColor(Qt::gray);
+  mySelColor->setDisabled(true);
+  TopGroupLayout->addWidget( mySelColor, 3, 1 );
+  connect( mySelColor, SIGNAL( clicked() ), this, SLOT( setColor() ) );
+  connect( myUseMagnitude, SIGNAL( toggled(bool) ), mySelColor, SLOT( setDisabled(bool) ) );
+
+  myUseLabels = new QCheckBox(tr("SHOW_VALUES_CHK"), TopGroup, "myUseLabels");
+  myUseLabels->setChecked(false);
+  TopGroupLayout->addWidget( myUseLabels, 4, 0 );
+  myNbLabels = new QSpinBox( 1, 100, 1, TopGroup, "myNbLabels" );
+  myNbLabels->setEnabled(false);
+  TopGroupLayout->addWidget( myNbLabels, 4, 1 );
+  connect( myUseLabels, SIGNAL( toggled(bool) ), myNbLabels, SLOT( setEnabled(bool) ) );
 
 //   CBUpdate = new QCheckBox ( tr( "Update scalar bar with these values" ), TopGroup);
 //   CBUpdate->setSizePolicy( QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed) );
 //   TopGroupLayout->addMultiCellWidget( CBUpdate, 4, 4, 0, 1);
 //   CBUpdate->setChecked(false);
   QPushButton* aUpdateBtn = new QPushButton( "Update scalar bar range with these values", TopGroup);
-  TopGroupLayout->addMultiCellWidget( aUpdateBtn, 3, 3, 0, 1);
+  TopGroupLayout->addMultiCellWidget( aUpdateBtn, 5, 5, 0, 1);
   connect( aUpdateBtn, SIGNAL( clicked() ), this, SLOT(onCBUpdate() ) );
 
 //   CBLog = new QCheckBox ( tr( "Logarithmic scaling" ), TopGroup);
@@ -104,6 +123,13 @@ void VisuGUI_IsoSurfPane::initFromPrsObject (VISU::IsoSurfaces_i* thePrs)
   NbrIso->setValue(thePrs->GetNbSurfaces());
   MinIso->setText(QString::number(thePrs->GetSubMin()));
   MaxIso->setText(QString::number(thePrs->GetSubMax()));
+  myUseMagnitude->setChecked(thePrs->IsColored());
+  SALOMEDS::Color anOldColor = thePrs->GetColor();
+  QColor aColor = QColor(int(255*anOldColor.R),int(255*anOldColor.G),int(255*anOldColor.B));
+  setColor(aColor);
+
+  myUseLabels->setChecked(thePrs->IsLabeled());
+  myNbLabels->setValue(thePrs->GetNbLabels());
 //   switch(thePrs->GetScaling()){
 //   case VISU::LOGARITHMIC :
 //     CBLog->setChecked(true);
@@ -117,6 +143,17 @@ int VisuGUI_IsoSurfPane::storeToPrsObject (VISU::IsoSurfaces_i* thePrs)
 {
   thePrs->SetNbSurfaces(NbrIso->value());
   thePrs->SetSubRange(MinIso->text().toDouble(), MaxIso->text().toDouble());
+  thePrs->ShowLabels(myUseLabels->isOn(), myNbLabels->value());
+  thePrs->ShowColored(myUseMagnitude->isOn());
+  if(!thePrs->IsColored()){
+    QColor aQColor = color();
+    SALOMEDS::Color aColor;
+    aColor.R = aQColor.red()/255.;
+    aColor.G = aQColor.green()/255.;
+    aColor.B = aQColor.blue()/255.;
+    thePrs->SetColor(aColor);
+  }
+
   return 1;
 //   if (CBUpdate->isChecked())
 //     {
@@ -156,8 +193,22 @@ bool VisuGUI_IsoSurfPane::check()
   return true;
 }
 
+void VisuGUI_IsoSurfPane::setColor()
+{
+  QColor cnew = QColorDialog::getColor( mySelColor->paletteBackgroundColor(), this );
+  if ( cnew.isValid() )
+    setColor(cnew);
+}
 
+void VisuGUI_IsoSurfPane::setColor(const QColor& theColor)
+{
+  mySelColor->setPaletteBackgroundColor(theColor);
+}
 
+QColor VisuGUI_IsoSurfPane::color() const
+{
+  return mySelColor->paletteBackgroundColor();
+}
 
 
 /*!
index 385fa64668810116542701e2ace9cf0d09f97229..9724e6b89441f4d9cc470897889a1fc700ecd75c 100644 (file)
@@ -58,14 +58,22 @@ class VisuGUI_IsoSurfPane : public QVBox
 
   bool check();
 
+  void setColor(const QColor& theColor);
+  QColor color() const;
+
  protected slots:
   void onCBUpdate();
+  void setColor();
 
  private:
   QLineEdit* MinIso;
   QLineEdit* MaxIso;
   QSpinBox*  NbrIso;
   VisuGUI_ScalarBarPane* myScalarPane;
+  QCheckBox*   myUseMagnitude;
+  QPushButton* mySelColor;
+  QCheckBox*   myUseLabels;
+  QSpinBox*    myNbLabels;
 };
 
 
index df26fa84862703959425d6406bad9d114525df0b..b28f6ec99eca43c3b524a5d1fc91952a1449cd7d 100644 (file)
@@ -57,6 +57,7 @@ LIB_SRC = \
        VISU_DumpPython.cc \
        VISU_ScalarMapOnDeformedShape_i.cc \
        VISU_PrsMerger_i.cc \
+       VISU_MonoColorPrs_i.cc \
        SALOME_GenericObjPointer.cc
 
 LIB_MOC = \
@@ -105,6 +106,7 @@ EXPORT_HEADERS = \
        VISU_TimeAnimation.h \
        VISU_ScalarMapOnDeformedShape_i.hh \
        VISU_PrsMerger_i.hh \
+       VISU_MonoColorPrs_i.hh \
        SALOME_GenericObjPointer.hh
 
 # additionnal information to compil and link file
index 41657e8c495839520841a79dd7f3b1870dd02c4b..0544307426558c45f3e57c29f9076ec640a09b0f 100644 (file)
@@ -74,6 +74,7 @@ DeformedShape_i(Result_i* theResult,
   Prs3d_i(theResult,theAddToStudy),
   ColoredPrs3d_i(theResult,theAddToStudy),
   ScalarMap_i(theResult,theAddToStudy),
+  PrsMerger_i(theResult,theAddToStudy),
   TSuperClass(theResult,theAddToStudy),
   myDeformedShapePL(NULL)
 {
@@ -88,6 +89,7 @@ DeformedShape_i(Result_i* theResult,
   Prs3d_i(theResult,theSObject),
   ColoredPrs3d_i(theResult,theSObject),
   ScalarMap_i(theResult,theSObject),
+  PrsMerger_i(theResult,theSObject),
   TSuperClass(theResult,theSObject),
   myDeformedShapePL(NULL)
 {
@@ -196,18 +198,3 @@ VISU::DeformedShape_i
 {
   return CreateActor(theIO, false);
 }
-
-void VISU::DeformedShape_i::UpdateActor(VISU_Actor* theActor) {
-  if(VISU_ScalarMapAct* anActor = dynamic_cast<VISU_ScalarMapAct*>(theActor)){
-    if(IsColored()){
-      anActor->SetBarVisibility(true);
-      myPipeLine->GetMapper()->SetScalarVisibility(1);
-    }else{
-      anActor->SetBarVisibility(false);
-      myPipeLine->GetMapper()->SetScalarVisibility(0);
-      SALOMEDS::Color aColor = GetColor();
-      anActor->GetProperty()->SetColor(aColor.R,aColor.G,aColor.B);
-    }
-    TSuperClass::UpdateActor(theActor);
-  }
-}
index f7a072224dd8127470223aca6ba226f6135c1c7c..e786a0ec62c2363708f3ec560d9eb7b4a430f4eb 100644 (file)
 #ifndef VISU_DeformedShape_i_HeaderFile
 #define VISU_DeformedShape_i_HeaderFile
 
-#include "VISU_PrsMerger_i.hh"
+#include "VISU_MonoColorPrs_i.hh"
 
 class VISU_DeformedShapePL;
 
 namespace VISU{
   class DeformedShape_i : public virtual POA_VISU::DeformedShape,
-                         public virtual PrsMerger_i
+                         public virtual MonoColorPrs_i
   {
     static int myNbPresent;
     DeformedShape_i();
     DeformedShape_i(const DeformedShape_i&);
 
   public:
-    typedef PrsMerger_i TSuperClass;
+    typedef MonoColorPrs_i TSuperClass;
 
     explicit
     DeformedShape_i(Result_i* theResult,
@@ -56,12 +56,6 @@ namespace VISU{
     virtual void SetScale(CORBA::Double theScale);
     virtual CORBA::Double GetScale();
 
-    virtual CORBA::Boolean IsColored() { return PrsMerger_i::IsColored(); }
-    virtual void ShowColored(CORBA::Boolean theColored) { PrsMerger_i::ShowColored( theColored ); }
-
-    virtual SALOMEDS::Color GetColor() { return PrsMerger_i::GetColor();}
-    virtual void SetColor(const SALOMEDS::Color& theColor) { PrsMerger_i::SetColor( theColor ); }
-
     typedef VISU::DeformedShape TInterface;
     VISU_DeformedShapePL* GetDeformedShapePL(){ return myDeformedShapePL;}
 
@@ -97,8 +91,6 @@ namespace VISU{
     virtual 
     VISU_Actor* 
     CreateActor(const Handle(SALOME_InteractiveObject)& theIO, bool toSupressShrinking);
-
-    virtual void UpdateActor(VISU_Actor* theActor) ;
   };
 }
 
index 9b5af88c38a9e0c695034d81e513d6c696443f9d..c42377ad588ad9519d947cb30cafaa0073d2fac3 100644 (file)
@@ -271,6 +271,26 @@ namespace VISU
     return thePrefix;
   }
   
+  //===========================================================================
+  std::string
+  MonoColorPrsToPython(SALOMEDS::SObject_ptr theSObject,
+                      VISU::MonoColorPrs_i* theServant,
+                      std::ostream& theStr,
+                      std::string& theName,
+                      const std::string& theConstructorName,
+                      const std::string& theArgumentName,
+                      std::string thePrefix)
+  {
+    thePrefix = PrsMergerToPython(theSObject,theServant,theStr,theName,theConstructorName,theArgumentName,thePrefix);
+    theStr<<thePrefix<<endl;
+    theStr<<thePrefix<<theName<<".ShowColored("<<theServant->IsColored()<<")"<<endl;
+    SALOMEDS::Color aColor = theServant->GetColor();
+    theStr<<thePrefix<<theName<<".SetColor(SALOMEDS.Color("<<
+      aColor.R<<","<<aColor.G<<","<<aColor.B<<"))"<<endl;
+
+    return thePrefix;
+  }
+  
   //===========================================================================
   std::string
   DeformedShapeToPython(SALOMEDS::SObject_ptr theSObject,
@@ -281,13 +301,9 @@ namespace VISU
                        const std::string& theArgumentName,
                        std::string thePrefix)
   {
-    thePrefix = PrsMergerToPython(theSObject,theServant,theStr,theName,theConstructorName,theArgumentName,thePrefix);
+    thePrefix = MonoColorPrsToPython(theSObject,theServant,theStr,theName,theConstructorName,theArgumentName,thePrefix);
     theStr<<thePrefix<<theName<<".SetScale("<<theServant->GetScale()<<")"<<endl;
-    theStr<<thePrefix<<theName<<".ShowColored("<<theServant->IsColored()<<")"<<endl;
-    SALOMEDS::Color aColor = theServant->GetColor();
-    theStr<<thePrefix<<theName<<".SetColor(SALOMEDS.Color("<<
-      aColor.R<<","<<aColor.G<<","<<aColor.B<<"))"<<endl;
-
+    
     return thePrefix;
   }
 
@@ -752,7 +768,7 @@ namespace VISU
           return;
         case VISU::TSTREAMLINES:
           if(StreamLines_i* aServant = dynamic_cast<StreamLines_i*>(GetServant(anObj).in())){
-           thePrefix = DeformedShapeToPython(theSObject,aServant,theStr,aName,"StreamLinesOnField",theArgumentName,thePrefix);
+           thePrefix = MonoColorPrsToPython(theSObject,aServant,theStr,aName,"StreamLinesOnField",theArgumentName,thePrefix);
 
            std::string aParam;
            switch(aServant->GetDirection()){
index 0f8b392b75229e067cda2649e03c18d15292ca76..49071278b47c314e68bc677897c3bdd6598ce714 100644 (file)
@@ -28,6 +28,8 @@
 #include "VISU_Result_i.hh"
 #include "VISU_IsoSurfaces_i.hh"
 #include "VISU_Actor.h"
+#include "VISU_ScalarMapAct.h"
+#include "VISU_IsoSurfActor.h"
 
 #include "SUIT_ResourceMgr.h"
 #include "SALOME_Event.hxx"
@@ -61,8 +63,11 @@ IsoSurfaces_i(Result_i* theResult,
   Prs3d_i(theResult,theAddToStudy),
   ColoredPrs3d_i(theResult,theAddToStudy),
   ScalarMap_i(theResult,theAddToStudy),
+  PrsMerger_i(theResult,theAddToStudy),
   TSuperClass(theResult,theAddToStudy),
-  myIsoSurfacesPL(NULL)
+  myIsoSurfacesPL(NULL),
+  myIsLabeled(false),
+  myNbLabels(3)
 {}
 
 
@@ -73,8 +78,11 @@ IsoSurfaces_i(Result_i* theResult,
   Prs3d_i(theResult,theSObject),
   ColoredPrs3d_i(theResult,theSObject),
   ScalarMap_i(theResult,theSObject),
+  PrsMerger_i(theResult,theSObject),
   TSuperClass(theResult,theSObject),
-  myIsoSurfacesPL(NULL)
+  myIsoSurfacesPL(NULL),
+  myIsLabeled(false),
+  myNbLabels(3)
 {
 }
 
@@ -82,7 +90,11 @@ IsoSurfaces_i(Result_i* theResult,
 VISU::Storable* VISU::IsoSurfaces_i::Create(const char* theMeshName, VISU::Entity theEntity, 
                                            const char* theFieldName, int theIteration)
 {
-  return TSuperClass::Create(theMeshName,theEntity,theFieldName,theIteration);
+  VISU::Storable* aRes = TSuperClass::Create(theMeshName,theEntity,theFieldName,theIteration);
+  myIsColored = true;
+  myColor.R = myColor.G = myColor.B = 0.;
+
+  return aRes;
 }
 
 
@@ -93,6 +105,8 @@ VISU::Storable* VISU::IsoSurfaces_i::Restore(const Storable::TRestoringMap& theM
   SetNbSurfaces(VISU::Storable::FindValue(theMap,"myNbSurface").toInt());
   float aMin = VISU::Storable::FindValue(theMap,"myRange[0]").toDouble();
   float aMax = VISU::Storable::FindValue(theMap,"myRange[1]").toDouble();
+  myNbLabels = VISU::Storable::FindValue(theMap,"myNbLabels").toInt();
+  myIsLabeled = VISU::Storable::FindValue(theMap,"myIsLabeled").toInt();
   SetSubRange(aMin,aMax);
     
   return this;
@@ -104,8 +118,19 @@ void VISU::IsoSurfaces_i::ToStream(std::ostringstream& theStr){
   Storable::DataToStream( theStr, "myNbSurface", int(GetNbSurfaces()) );
   Storable::DataToStream( theStr, "myRange[0]", GetSubMin() );
   Storable::DataToStream( theStr, "myRange[1]", GetSubMax() );
+  Storable::DataToStream( theStr, "myNbLabels", (int)myNbLabels );
+  Storable::DataToStream( theStr, "myIsLabeled", myIsLabeled );
 }
 
+void VISU::IsoSurfaces_i::SameAs(const Prs3d_i* theOrigin)
+{
+  TSuperClass::SameAs(theOrigin);
+
+  if(const IsoSurfaces_i* aPrs3d = dynamic_cast<const IsoSurfaces_i*>(theOrigin)){
+    IsoSurfaces_i* anOrigin = const_cast<IsoSurfaces_i*>(aPrs3d);
+    ShowLabels(anOrigin->IsLabeled(), anOrigin->GetNbLabels());
+  }
+}
 
 VISU::IsoSurfaces_i::~IsoSurfaces_i(){
   if(MYDEBUG) MESSAGE("IsoSurfaces_i::~IsoSurfaces_i()");
@@ -172,16 +197,47 @@ VISU_Actor*
 VISU::IsoSurfaces_i
 ::CreateActor(const Handle(SALOME_InteractiveObject)& theIO)
 {
-  if(VISU_Actor* anActor = TSuperClass::CreateActor(theIO)){
+  VISU_IsoSurfActor* anActor = VISU_IsoSurfActor::New();
+  try{
+    VISU::Prs3d_i::CreateActor(anActor);
+    anActor->SetBarVisibility(true);
     anActor->SetVTKMapping(true);
     SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
     int  aDispMode = aResourceMgr->integerValue("VISU" , "iso_surfaces_represent", 2);
     anActor->SetRepresentation(aDispMode);
-    return anActor;
+    UpdateActor(anActor);
+  }catch(...){
+    anActor->Delete();
+    throw ;
+  }
+  
+  return anActor;
+}
+
+void VISU::IsoSurfaces_i::UpdateActor(VISU_Actor* theActor) 
+{
+  if(VISU_IsoSurfActor* anActor = dynamic_cast<VISU_IsoSurfActor*>(theActor)){
+    anActor->SetLinesLabeled(myIsLabeled, myNbLabels);
   }
-  return NULL;
+  TSuperClass::UpdateActor(theActor);
 }
 
 void VISU::IsoSurfaces_i::SetMapScale(double theMapScale){
   myIsoSurfacesPL->SetMapScale(theMapScale);
 }
+
+CORBA::Boolean VISU::IsoSurfaces_i::IsLabeled()
+{
+  return myIsLabeled;
+}
+
+void VISU::IsoSurfaces_i::ShowLabels(CORBA::Boolean theShow, CORBA::Long theNb)
+{
+  myIsLabeled = theShow;
+  myNbLabels = theNb;
+}
+
+CORBA::Long VISU::IsoSurfaces_i::GetNbLabels()
+{
+  return myNbLabels;
+}
index 96b87ddd9d2ba5ddc8013e4acd45f7e93069bf46..1e279002149024add620d583e9237f33a556662b 100644 (file)
 #ifndef VISU_IsoSurfaces_i_HeaderFile
 #define VISU_IsoSurfaces_i_HeaderFile
 
-#include "VISU_PrsMerger_i.hh"
+#include "VISU_MonoColorPrs_i.hh"
 
 class VISU_IsoSurfacesPL;
 
 namespace VISU{
   class IsoSurfaces_i : public virtual POA_VISU::IsoSurfaces,
-                       public virtual PrsMerger_i
+                       public virtual MonoColorPrs_i
   {
     static int myNbPresent;
     IsoSurfaces_i();
     IsoSurfaces_i(const IsoSurfaces_i&);
 
   public:
-    typedef PrsMerger_i TSuperClass;
+    typedef MonoColorPrs_i TSuperClass;
 
     explicit
     IsoSurfaces_i(Result_i* theResult,
@@ -48,6 +48,9 @@ namespace VISU{
     explicit
     IsoSurfaces_i(Result_i* theResult,
                  SALOMEDS::SObject_ptr theSObject);
+    
+    virtual void SameAs(const Prs3d_i* theOrigin);
+    
     virtual ~IsoSurfaces_i();
 
     virtual VISU::VISUType GetType() { return VISU::TISOSURFACE;};
@@ -62,12 +65,20 @@ namespace VISU{
     typedef VISU::IsoSurfaces TInterface;
     VISU_IsoSurfacesPL* GetIsoSurfacesPL(){ return myIsoSurfacesPL;}
 
+    virtual CORBA::Boolean IsLabeled();
+    virtual void ShowLabels(CORBA::Boolean theShow, CORBA::Long theNb);
+    
+    virtual CORBA::Long GetNbLabels();
+
   protected:
     virtual void DoHook();
     virtual const char* GetIconName();
 
     VISU_IsoSurfacesPL* myIsoSurfacesPL;
 
+    bool myIsLabeled;
+    CORBA::Long myNbLabels;
+
   public:
     static int IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity,
                          const char* theFieldName, int theIteration, int isMemoryCheck = true);
@@ -87,6 +98,8 @@ namespace VISU{
     CreateActor(const Handle(SALOME_InteractiveObject)& theIO = NULL);
 
     virtual void SetMapScale(double theMapScale = 1.0);
+
+    virtual void UpdateActor(VISU_Actor* theActor);
   };
 }
 
diff --git a/src/VISU_I/VISU_MonoColorPrs_i.cc b/src/VISU_I/VISU_MonoColorPrs_i.cc
new file mode 100644 (file)
index 0000000..bd98e58
--- /dev/null
@@ -0,0 +1,188 @@
+//  VISU OBJECT : interactive object for VISU entities implementation
+//
+//  Copyright (C) 2003  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
+//
+//
+//  File   : VISU_MonoColorPrs_i.cxx
+//  Author : Vitaly Smetannikov
+//  Module : VISU
+
+
+#include "VISU_MonoColorPrs_i.hh"
+#include "VISU_Result_i.hh"
+
+#include "VISU_PipeLineUtils.hxx"
+#include "VISU_ScalarMapAct.h"
+
+#include "VISU_PipeLine.hxx"
+
+#include <vtkDataSetMapper.h>
+#include <vtkProperty.h>
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+//---------------------------------------------------------------
+VISU::MonoColorPrs_i::
+MonoColorPrs_i(Result_i* theResult, 
+              bool theAddToStudy) :
+  PrsObject_i(theResult->GetStudyDocument()), 
+  Prs3d_i(theResult,theAddToStudy),
+  ColoredPrs3d_i(theResult,theAddToStudy),
+  ScalarMap_i(theResult,theAddToStudy),
+  TSuperClass(theResult,theAddToStudy)
+{
+}
+
+VISU::MonoColorPrs_i::
+MonoColorPrs_i(Result_i* theResult, 
+              SALOMEDS::SObject_ptr theSObject) :
+  PrsObject_i(theResult->GetStudyDocument()), 
+  Prs3d_i(theResult,theSObject),
+  ColoredPrs3d_i(theResult,theSObject),
+  ScalarMap_i(theResult,theSObject),
+  TSuperClass(theResult,theSObject)
+{
+}
+
+//---------------------------------------------------------------
+void 
+VISU::MonoColorPrs_i
+::SameAs(const Prs3d_i* theOrigin)
+{
+  TSuperClass::SameAs(theOrigin);
+
+  if(const MonoColorPrs_i* aPrs3d = dynamic_cast<const MonoColorPrs_i*>(theOrigin)){
+    MonoColorPrs_i* anOrigin = const_cast<MonoColorPrs_i*>(aPrs3d);
+    SetColor(anOrigin->GetColor());
+    ShowColored(anOrigin->IsColored());
+  }
+}
+
+
+//---------------------------------------------------------------
+VISU::Storable* 
+VISU::MonoColorPrs_i
+::Create(const char* theMeshName, VISU::Entity theEntity, 
+        const char* theFieldName, int theIteration)
+{
+  myIsColored = true;
+  myColor.R = myColor.G = myColor.B = 0.5;
+  TSuperClass::Create(theMeshName,theEntity,theFieldName,theIteration);
+
+  return this;
+}
+
+//---------------------------------------------------------------
+VISU::Storable* 
+VISU::MonoColorPrs_i
+::Restore(const Storable::TRestoringMap& theMap)
+{
+  if(!TSuperClass::Restore(theMap))
+    return NULL;
+  
+  myIsColored = VISU::Storable::FindValue(theMap,"myIsColored").toInt();
+  myColor.R = VISU::Storable::FindValue(theMap,"myColor.R").toDouble();
+  myColor.G = VISU::Storable::FindValue(theMap,"myColor.G").toDouble();
+  myColor.B = VISU::Storable::FindValue(theMap,"myColor.B").toDouble();
+
+  return this;
+}
+
+//---------------------------------------------------------------
+void
+VISU::MonoColorPrs_i
+::ToStream(std::ostringstream& theStr)
+{
+  TSuperClass::ToStream(theStr);
+
+  Storable::DataToStream( theStr, "myIsColored", myIsColored );
+  Storable::DataToStream( theStr, "myColor.R", myColor.R );
+  Storable::DataToStream( theStr, "myColor.G", myColor.G );
+  Storable::DataToStream( theStr, "myColor.B", myColor.B );
+}
+
+
+//---------------------------------------------------------------
+VISU::MonoColorPrs_i::~MonoColorPrs_i()
+{
+  if(MYDEBUG) MESSAGE("MonoColorPrs_i::~MonoColorPrs_i()");
+}
+
+//---------------------------------------------------------------
+CORBA::Boolean VISU::MonoColorPrs_i::IsColored()
+{
+  return myIsColored;
+}
+
+//---------------------------------------------------------------
+void
+VISU::MonoColorPrs_i::ShowColored(CORBA::Boolean theColored)
+{
+  myIsColored = theColored; 
+}
+
+//---------------------------------------------------------------
+SALOMEDS::Color VISU::MonoColorPrs_i::GetColor()
+{
+  return myColor;
+}
+
+//---------------------------------------------------------------
+void VISU::MonoColorPrs_i::SetColor(const SALOMEDS::Color& theColor)
+{
+  myColor = theColor;
+}
+
+VISU_Actor* 
+VISU::MonoColorPrs_i
+::CreateActor(const Handle(SALOME_InteractiveObject)& theIO, bool toSupressShrinking) 
+{
+  VISU_Actor* anActor = TSuperClass::CreateActor(theIO, toSupressShrinking);
+  anActor->GetProperty()->SetColor(myColor.R,myColor.G,myColor.B);
+
+  return anActor;
+}
+
+//---------------------------------------------------------------
+VISU_Actor* VISU::MonoColorPrs_i::CreateActor(const Handle(SALOME_InteractiveObject)& theIO) 
+{
+  return CreateActor(theIO, false);
+}
+
+//---------------------------------------------------------------
+void VISU::MonoColorPrs_i::UpdateActor(VISU_Actor* theActor) 
+{
+  if(VISU_ScalarMapAct* anActor = dynamic_cast<VISU_ScalarMapAct*>(theActor)){
+    if(IsColored()){
+      anActor->SetBarVisibility(true);
+      GetPL()->GetMapper()->SetScalarVisibility(1);
+    }else{
+      anActor->SetBarVisibility(false);
+      GetPL()->GetMapper()->SetScalarVisibility(0);
+      anActor->GetProperty()->SetColor(myColor.R,myColor.G,myColor.B);
+    }
+    TSuperClass::UpdateActor(theActor);
+  }
+}
+
diff --git a/src/VISU_I/VISU_MonoColorPrs_i.hh b/src/VISU_I/VISU_MonoColorPrs_i.hh
new file mode 100644 (file)
index 0000000..c18d59f
--- /dev/null
@@ -0,0 +1,84 @@
+//  VISU OBJECT : interactive object for VISU entities implementation
+//
+//  Copyright (C) 2003  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
+//
+//
+//  File   : VISU_MonoColorPrs_i.hxx
+//  Author : Vitaly Smetannikov
+//  Module : VISU
+
+
+#ifndef VISU_MonoColorPrs_i_HeaderFile
+#define VISU_MonoColorPrs_i_HeaderFile
+
+#include "VISU_PrsMerger_i.hh"
+
+namespace VISU
+{
+  //----------------------------------------------------------------------------
+  class MonoColorPrs_i : public virtual POA_VISU::MonoColorPrs,
+                        public virtual PrsMerger_i
+  {
+    MonoColorPrs_i(const MonoColorPrs_i&);
+
+  public:
+    //----------------------------------------------------------------------------
+    typedef PrsMerger_i TSuperClass;
+    typedef VISU::MonoColorPrs TInterface;
+
+    explicit
+    MonoColorPrs_i(Result_i* theResult,
+                  bool theAddToStudy);
+    explicit
+    MonoColorPrs_i(Result_i* theResult,
+                  SALOMEDS::SObject_ptr theSObject);
+
+    virtual void SameAs(const Prs3d_i* theOrigin);
+
+    virtual ~MonoColorPrs_i();
+
+    virtual CORBA::Boolean IsColored();
+
+    virtual void ShowColored(CORBA::Boolean theColored);
+
+    virtual SALOMEDS::Color GetColor();
+
+    virtual void SetColor(const SALOMEDS::Color& theColor);
+
+  protected:
+    SALOMEDS::Color myColor;
+    bool myIsColored;
+
+  public:
+    virtual Storable* Create(const char* theMeshName, VISU::Entity theEntity,
+                            const char* theFieldName, int theIteration);
+
+    virtual void ToStream(std::ostringstream& theStr);
+
+    virtual Storable* Restore(const Storable::TRestoringMap& theMap);
+
+    virtual VISU_Actor* CreateActor(const Handle(SALOME_InteractiveObject)& theIO = NULL);
+
+    virtual VISU_Actor* CreateActor(const Handle(SALOME_InteractiveObject)& theIO, bool toSupressShrinking);
+
+    virtual void UpdateActor(VISU_Actor* theActor);
+  };
+};
+#endif
index 878cd2ed1f25907cffb6cb2f6e7c3bf19dd51327..d781e99b259ef63675d5c1f5b2f8ad8dc83280f1 100644 (file)
@@ -154,8 +154,6 @@ VISU::Storable* VISU::PrsMerger_i::Create(const char* theMeshName, VISU::Entity
 {
   if (MYDEBUG) MESSAGE("PrsMerger_i::Create");
 
-  myIsColored = true;
-  myColor.R = myColor.G = myColor.B = 0.5;
   VISU::Storable* aRes = TSuperClass::Create(theMeshName,theEntity,theFieldName,theIteration);
   this->SetScalarMap(theMeshName,theEntity,theFieldName,theIteration);
 
@@ -165,11 +163,6 @@ VISU::Storable* VISU::PrsMerger_i::Create(const char* theMeshName, VISU::Entity
 VISU::Storable* VISU::PrsMerger_i::Restore(const Storable::TRestoringMap& theMap)
 {
   if (MYDEBUG) MESSAGE("VISU::PrsMerger_i::Restore");
-  
-  myIsColored = VISU::Storable::FindValue(theMap,"myIsColored",QString( "1" )).toInt();
-  myColor.R = VISU::Storable::FindValue(theMap,"myColor.R",QString( "0.5" )).toDouble();
-  myColor.G = VISU::Storable::FindValue(theMap,"myColor.G",QString( "0.5" )).toDouble();
-  myColor.B = VISU::Storable::FindValue(theMap,"myColor.B",QString( "0.5" )).toDouble();
 
   TSuperClass::Restore(theMap);
   
@@ -239,13 +232,6 @@ void VISU::PrsMerger_i::ToStream(std::ostringstream& theStr)
   Storable::DataToStream( theStr, "myMeshName", myMeshName.c_str() );
   Storable::DataToStream( theStr, "myGeomNameList",  aStrSubMeshName.latin1());
   Storable::DataToStream( theStr, "myGeomEntityList",  aStrEntity.latin1());
-
-  Storable::DataToStream( theStr, "myIsColored", myIsColored );
-  Storable::DataToStream( theStr, "myColor.R", myColor.R );
-  Storable::DataToStream( theStr, "myColor.G", myColor.G );
-  Storable::DataToStream( theStr, "myColor.B", myColor.B );
-
-  
 }
 
 void VISU::PrsMerger_i::clearMeshList()
@@ -491,7 +477,6 @@ VISU::PrsMerger_i
 ::DoHook(){
   if(!myPipeLine) myPipeLine = VISU_PrsMergerPL::New();
   myPrsMergerPL = dynamic_cast<VISU_PrsMergerPL*>(myPipeLine);
-  myPipeLine->GetMapper()->SetScalarVisibility(IsColored());
   TSuperClass::DoHook();
 }
 
index 2583b17ae81e7c3571c62c4dfb406b0a3c889e83..f37a3cbea1124bbcc568f5b5ce56a206226ff493 100644 (file)
@@ -67,12 +67,6 @@ namespace VISU{
 
     virtual VISU::VISUType GetType() { return VISU::TPRSMERGER;};
 
-    virtual CORBA::Boolean IsColored() { return myIsColored; }
-    virtual void ShowColored(CORBA::Boolean theColored) { myIsColored = theColored; }
-
-    virtual SALOMEDS::Color GetColor() { return myColor;}
-    virtual void SetColor(const SALOMEDS::Color& theColor) { myColor = theColor;}
-
     VISU_PrsMergerPL* GetPrsMergerPL(){ return myPrsMergerPL;}
 
     virtual void Update();
@@ -90,12 +84,6 @@ namespace VISU{
      * you we will need in different mesh entities (ENTITY,FAMILY,GROUP) as geometries.
      */
     TNameAndEntityList myGeomNameEntityList;
-
-  private:
-
-    SALOMEDS::Color myColor;
-    bool myIsColored;
-
     
   public:
     static int IsCompatibleCellTypes(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity,
index b8449008619f4f398d496f4097df8d2650c747c0..5ca2632af361e2dd477c968ec477cd6ae6f8fefd 100644 (file)
@@ -90,7 +90,7 @@ StreamLines_i(Result_i* theResult,
   ColoredPrs3d_i(theResult,theAddToStudy),
   ScalarMap_i(theResult,theAddToStudy),
   PrsMerger_i(theResult,theAddToStudy),
-  DeformedShape_i(theResult,theAddToStudy),
+  MonoColorPrs_i(theResult,theAddToStudy),
   myStreamLinesPL(NULL),
   myAppendFilter(vtkAppendFilter::New())
 {
@@ -105,7 +105,7 @@ StreamLines_i(Result_i* theResult,
   ColoredPrs3d_i(theResult,theSObject),
   ScalarMap_i(theResult,theSObject),
   PrsMerger_i(theResult,theSObject),
-  DeformedShape_i(theResult,theSObject),
+  MonoColorPrs_i(theResult,theSObject),
   myStreamLinesPL(NULL),
   myAppendFilter(vtkAppendFilter::New())
 {
@@ -126,7 +126,7 @@ void VISU::StreamLines_i::SameAs(const Prs3d_i* theOrigin)
 VISU::Storable* VISU::StreamLines_i::Create(const char* theMeshName, VISU::Entity theEntity, 
                                            const char* theFieldName, int theIteration)
 {
-  return DeformedShape_i::Create(theMeshName,theEntity,theFieldName,theIteration);
+  return TSuperClass::Create(theMeshName,theEntity,theFieldName,theIteration);
 }
 
 
@@ -152,7 +152,7 @@ VISU::Storable* VISU::StreamLines_i::Restore(const Storable::TRestoringMap& theM
 
 
 void VISU::StreamLines_i::ToStream(std::ostringstream& theStr){
-  DeformedShape_i::ToStream(theStr);
+  TSuperClass::ToStream(theStr);
 
   Storable::DataToStream( theStr, "myIntegrationStep", GetIntegrationStep());
   Storable::DataToStream( theStr, "myPropagationTime", GetPropagationTime());
@@ -266,7 +266,7 @@ void VISU::StreamLines_i::DoHook(){
   if(!myPipeLine) myPipeLine = VISU_StreamLinesPL::New();
   myStreamLinesPL = dynamic_cast<VISU_StreamLinesPL*>(myPipeLine);
 
-  DeformedShape_i::DoHook();
+  TSuperClass::DoHook();
 }
 
 const char*
@@ -281,7 +281,7 @@ VISU::StreamLines_i
 
 void VISU::StreamLines_i::Update() {
   SetSource();
-  VISU::DeformedShape_i::Update();
+  TSuperClass::Update();
 }
 
 
@@ -289,7 +289,7 @@ VISU_Actor*
 VISU::StreamLines_i
 ::CreateActor(const Handle(SALOME_InteractiveObject)& theIO) 
 {
-  if(VISU_Actor* anActor = VISU::DeformedShape_i::CreateActor(theIO, true)){
+  if(VISU_Actor* anActor = TSuperClass::CreateActor(theIO, true)){
     anActor->SetVTKMapping(true);
     SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
     int  aDispMode = aResourceMgr->integerValue("VISU", "stream_lines_represent", 1);
@@ -301,5 +301,5 @@ VISU::StreamLines_i
 
 
 void VISU::StreamLines_i::UpdateActor(VISU_Actor* theActor) {
-  VISU::DeformedShape_i::UpdateActor(theActor);
+  TSuperClass::UpdateActor(theActor);
 }
index f02c591f953cf2a1260dd27043ff508c9a9ba5be..4492da026094c102d5a53d39063efbf2e5de96c4 100644 (file)
 #ifndef VISU_StreamLines_i_HeaderFile
 #define VISU_StreamLines_i_HeaderFile
 
-#include "VISU_DeformedShape_i.hh"
+#include "VISU_MonoColorPrs_i.hh"
 
 class VISU_StreamLinesPL;
 class vtkAppendFilter;
 
 namespace VISU{
   class StreamLines_i : public virtual POA_VISU::StreamLines,
-                       public virtual DeformedShape_i
+                       public virtual MonoColorPrs_i
   {
     static int myNbPresent;
     StreamLines_i();
     StreamLines_i(const StreamLines_i&);
 
   public:
-    typedef DeformedShape_i TSuperClass;
+    typedef MonoColorPrs_i TSuperClass;
 
     explicit
     StreamLines_i(Result_i* theResult,
index a44102669977ed01f2fcf1b9b31bb99ed485279a..06ac8411b03b9285e9091e7ed025e14371c3e187 100644 (file)
@@ -83,6 +83,7 @@ Vectors_i(Result_i* theResult,
   ColoredPrs3d_i(theResult,theAddToStudy),
   ScalarMap_i(theResult,theAddToStudy),
   PrsMerger_i(theResult,theAddToStudy),
+  MonoColorPrs_i(theResult,theAddToStudy),
   DeformedShape_i(theResult,theAddToStudy),
   myVectorsPL(NULL)
 {
@@ -97,6 +98,7 @@ Vectors_i(Result_i* theResult,
   ColoredPrs3d_i(theResult,theSObject),
   ScalarMap_i(theResult,theSObject),
   PrsMerger_i(theResult,theSObject),
+  MonoColorPrs_i(theResult,theSObject),
   DeformedShape_i(theResult,theSObject),
   myVectorsPL(NULL)
 {
@@ -175,7 +177,7 @@ VISU::Vectors::GlyphPos VISU::Vectors_i::GetGlyphPos() {
 void VISU::Vectors_i::DoHook(){
   if(!myPipeLine) myPipeLine = VISU_VectorsPL::New();
   myVectorsPL = dynamic_cast<VISU_VectorsPL*>(myPipeLine);
-
+  
   DeformedShape_i::DoHook();
 }