]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Geometrical Sphere.
authorouv <ouv@opencascade.com>
Fri, 2 Dec 2005 15:50:40 +0000 (15:50 +0000)
committerouv <ouv@opencascade.com>
Fri, 2 Dec 2005 15:50:40 +0000 (15:50 +0000)
src/OBJECT/VISU_GaussPtsAct.cxx
src/PIPELINE/VISU_GaussPointsPL.cxx
src/PIPELINE/VISU_GaussPointsPL.hxx
src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx
src/VISUGUI/VisuGUI_GaussPointsDlg.cxx
src/VVTK/VVTK_SegmentationCursorDlg.cxx

index 5743b3baf138c614989cf162972b3fd0fdba0eee..ff17fb3a9d656697440d7cf2ce4f414c30a8a32e 100644 (file)
@@ -543,7 +543,7 @@ VISU_GaussPtsAct
          vtkDataSet* aDataSet = GetInput();
          vtkCellData* aCellData = aDataSet->GetCellData();
          if(vtkDataArray *aScalarArray = aCellData->GetScalars()){
-           float aRadius = myGaussPointsPL->GetPointSize(aVtkId,aScalarArray);
+           float aRadius = myGaussPointsPL->GetPointSize(aVtkId,aScalarArray) / 2.;
            float aPyramidHeight = myPickingSettings->GetPyramidHeight();
            aPyramidHeight = aPyramidHeight*myGaussPointsPL->GetMaxPointSize();
            //float aColor[3] = myPreHighlightActor->GetProperty()->GetColor();
@@ -749,7 +749,7 @@ VISU_GaussPtsAct
     //
     if(vtkDataArray* aScalarArray = aDataSetAttributes->GetScalars()){
       aVal = aScalarArray->GetTuple1(aVtkId);
-      aRadius = myGaussPointsPL->GetPointSize(aVtkId, aScalarArray);
+      aRadius = myGaussPointsPL->GetPointSize(aVtkId, aScalarArray) / 2.;
       //
       GetScalarBarCtrl()->SetIsMarked(true);
       GetScalarBarCtrl()->SetMarkValue(aVal);
@@ -913,11 +913,19 @@ VISU_GaussPtsAct
   aPipeline->SetClamp( myInsideCursorSettings->GetClamp() );
   aPipeline->SetImageData( myInsideCursorSettings->GetTexture() );
   aPipeline->SetAlphaThreshold( myInsideCursorSettings->GetAlphaThreshold() );
+  aPipeline->SetResolution( myInsideCursorSettings->GetResolution() );
   aPipeline->SetMinSize( myInsideCursorSettings->GetMinSize() );
   aPipeline->SetMaxSize( myInsideCursorSettings->GetMaxSize() );
   aPipeline->SetMagnification( myInsideCursorSettings->GetMagnification() );
   aPipeline->SetMagnificationIncrement( myInsideCursorSettings->GetIncrement() );
 
+  if( myInsideCursorSettings->GetPrimitiveType() != VISU_OpenGLPointSpriteMapper::GeomSphere )
+    theActor->GetProperty()->SetRepresentation( VTK_POINTS );
+  else
+    theActor->GetProperty()->SetRepresentation( VTK_SURFACE );
+
+  //aPipeLine->Update();
+
   Update();
 }
 
@@ -936,7 +944,6 @@ VISU_GaussPtsAct1
 
   myEventCallbackCommand->SetCallback(VISU_GaussPtsAct1::ProcessEvents);
 
-  myInsideDeviceActor->SetProperty(GetProperty());
   myInsideDeviceActor->SetVisibility(false);
   myInsideDeviceActor->SetPickable(false);
   myInsideDeviceActor->Delete();
@@ -1136,9 +1143,16 @@ VISU_GaussPtsAct1
   anExtractGeometry->SetExtractInside(true);
 
   aPipeline->SetPrimitiveType( myOutsideCursorSettings->GetPrimitiveType() );
+
+  if( myOutsideCursorSettings->GetPrimitiveType() != VISU_OpenGLPointSpriteMapper::GeomSphere )
+    myOutsideDeviceActor->GetProperty()->SetRepresentation( VTK_POINTS );
+  else
+    myOutsideDeviceActor->GetProperty()->SetRepresentation( VTK_SURFACE );
+
   aPipeline->SetClamp( myOutsideCursorSettings->GetClamp() );
   aPipeline->SetImageData( myOutsideCursorSettings->GetTexture() );
   aPipeline->SetAlphaThreshold( myOutsideCursorSettings->GetAlphaThreshold() );
+  aPipeline->SetResolution( myOutsideCursorSettings->GetResolution() );
   aPipeline->SetSize( myOutsideCursorSettings->GetSize() );
 
   if( myOutsideCursorSettings->GetUniform() )
@@ -1153,6 +1167,8 @@ VISU_GaussPtsAct1
     myOutsideDeviceActor->GetPSMapper()->ScalarVisibilityOn();
   }
 
+  aPipeline->Update();
+
   Update();
 }
 
index 143f3a6f73a0239f4097b48fa07ddc120e97a3c5..3c180fa76e0623566ce035fc4546f810a210abb4 100644 (file)
@@ -113,6 +113,19 @@ VISU_GaussPointsPL
 }
 
 
+//----------------------------------------------------------------------------
+void
+CopyGlyph( vtkGlyph3D* source, vtkGlyph3D* dest )
+{
+  dest->SetRange( source->GetRange() );
+  dest->SetScaling( source->GetScaling() );
+  dest->SetClamping( source->GetClamping() );
+  dest->SetScaleMode( source->GetScaleMode() );
+  dest->SetColorMode( source->GetColorMode() );
+  dest->SetScaleFactor( source->GetScaleFactor() );
+}
+
+
 //----------------------------------------------------------------------------
 void
 VISU_GaussPointsPL
@@ -138,6 +151,9 @@ VISU_GaussPointsPL
 
     SetIsDeformed( aPipeLine->GetIsDeformed() );
     SetScale( aPipeLine->GetScale() );
+
+    mySphereSource->SetRadius( aPipeLine->mySphereSource->GetRadius() );
+    CopyGlyph( aPipeLine->myGlyph, this->myGlyph );
   }
   Superclass::ShallowCopy(thePipeLine);
 }
@@ -206,20 +222,21 @@ VISU_GaussPointsPL
 void
 VISU_GaussPointsPL
 ::Build()
-{}
+{
+}
 
 //----------------------------------------------------------------------------
 void
 VISU_GaussPointsPL
 ::Update()
 {
+  //cout << "VISU_GaussPointsPL::Update()" << endl;
+
   GetSourceRange(mySourceScalarRange);
   myDeltaScalarRange = mySourceScalarRange[1] - mySourceScalarRange[0];
 
   SetAverageCellSize( VISU_DeformedShapePL::GetScaleFactor( GetParentMesh() ) );
 
-  mySphereSource->SetRadius( GetMagnification() * GetAverageCellSize() / 2. );
-
   vtkMapper* aMapper = GetMapper();
   vtkDataSet* aDataSet = aMapper->GetInput();
   vtkCellData* aCellData = aDataSet->GetCellData();
@@ -228,9 +245,61 @@ VISU_GaussPointsPL
   myPSMapper->SetLookupTable( myMapperTable );
   myPSMapper->SetScalarRange( mySourceScalarRange );
 
+  this->UpdateGlyph();
+
   VISU_ScalarMapPL::Update();
 }
 
+//----------------------------------------------------------------------------
+void
+VISU_GaussPointsPL
+::UpdateGlyph()
+{
+  //cout << "VISU_GaussPointsPL::UpdateGlyph()" << endl;
+
+  float aScalarRange[2];
+  GetSourceRange( aScalarRange );
+
+  if( myPSMapper->GetPointSpriteMode() == 0 ) // Results
+  {
+    //cout << "Results" << endl;
+    myGlyph->ClampingOn();
+    myGlyph->SetScaleModeToScaleByScalar();
+    myGlyph->SetColorModeToColorByScalar();
+
+    float aRange = 0;
+    float aMinSize = GetMinSize();
+    float aMaxSize = GetMaxSize();
+    if( fabs( aMaxSize - aMinSize ) > 0.0001 )
+      aRange = ( aScalarRange[1] - aScalarRange[0] ) / ( aMaxSize - aMinSize );
+    float aMinRange = aScalarRange[0] - aMinSize * aRange;
+    float aMaxRange = aMinRange + aRange;
+
+    myGlyph->SetRange( aMinRange, aMaxRange );
+    myGlyph->SetScaleFactor( 1.0 );
+  }
+  else if( myPSMapper->GetPointSpriteMode() == 1 ) // Geometry
+  {
+    //cout << "Geometry" << endl;
+    myGlyph->ClampingOff();
+    myGlyph->SetScaleModeToDataScalingOff();
+    myGlyph->SetColorModeToColorByScale();
+
+    myGlyph->SetScaleFactor( GetSize() );
+  }
+  else if( myPSMapper->GetPointSpriteMode() == 2 ) // Outside
+  {
+    //cout << "Outside" << endl;
+    myGlyph->ClampingOff();
+    myGlyph->SetScaleModeToDataScalingOff();
+    myGlyph->SetColorModeToColorByScalar();
+
+    myGlyph->SetScaleFactor( GetSize() );
+  }
+
+  mySphereSource->SetRadius( GetMagnification() * GetAverageCellSize() / 2. );
+}
+
 //----------------------------------------------------------------------------
 VISU::TGaussPointID 
 VISU_GaussPointsPL
@@ -322,6 +391,7 @@ VISU_GaussPointsPL
 ::SetIsColored(bool theIsColored)
 {
   myPSMapper->SetPointSpriteMode( theIsColored ? 0 : 1 ); // Results / Geometry
+  Modified();
 }
 
 //----------------------------------------------------------------------------
@@ -392,30 +462,12 @@ VISU_GaussPointsPL
   return myPSMapper->GetPointSpriteSize();
 }
 
-//----------------------------------------------------------------------------
-void
-VISU_GaussPointsPL
-::UpdateGlyphRange()
-{
-  float aScalarRange[2];
-  GetSourceRange( aScalarRange );
-
-  float aMinSize = GetMinSize();
-  float aMaxSize = GetMaxSize();
-  float aRange = ( aScalarRange[1] - aScalarRange[0] ) / ( aMaxSize - aMinSize );
-  float aMinRange = aScalarRange[0] - aMinSize * aRange;
-  float aMaxRange = aMinRange + aRange;
-
-  myGlyph->SetRange( aMinRange, aMaxRange );
-}
-
 //----------------------------------------------------------------------------
 void
 VISU_GaussPointsPL
 ::SetMinSize(float theMinSize)
 {
   myPSMapper->SetPointSpriteMinSize( theMinSize );
-  UpdateGlyphRange();
   Modified();
 }
 
@@ -433,7 +485,6 @@ VISU_GaussPointsPL
 ::SetMaxSize(float theMaxSize)
 {
   myPSMapper->SetPointSpriteMaxSize( theMaxSize );
-  UpdateGlyphRange();
   Modified();
 }
 
index 19e0079642ed51e9ec5353ff9b371408ff13af53..86d63dc94cad55ed151e2f024c2bc8a94f5cceb0 100644 (file)
@@ -98,6 +98,10 @@ public:
   void
   Update();
 
+  //! Update glyph.
+  void
+  UpdateGlyph();
+
   virtual 
   VISU::TGaussPointID 
   GetObjID(vtkIdType theID) const;
@@ -237,10 +241,6 @@ public:
   float
   GetAverageCellSize();
 
-  //! Update scalar range of the glyph.
-  void
-  UpdateGlyphRange();
-
   //! Set image data for the Point Sprite texture.
   void
   SetImageData(vtkImageData* theImageData);
index f4640aee25565e431019ee7ec993227ddb9b43c8..511b3b3e04dc5553586b5b2c149ab81a4df99b18 100755 (executable)
@@ -671,6 +671,26 @@ struct TVertex
   GLfloat vx, vy, vz;
 };
 
+float ViewToDisplay( vtkRenderer* theRenderer )
+{
+  float p1[3], p2[3];
+
+  theRenderer->SetViewPoint( 0.0, 0.0, 0.0 );
+  theRenderer->ViewToDisplay();
+  theRenderer->GetDisplayPoint( p1 );
+
+  theRenderer->SetViewPoint( 1.0, 1.0, 1.0 );
+  theRenderer->ViewToDisplay();
+  theRenderer->GetDisplayPoint( p2 );
+
+  float coefficient = sqrt( pow( p2[0] - p1[0], 2 ) + pow( p2[1] - p1[1], 2 ) ) / sqrt( 2 );
+  //cout << p1[0] << " " << p1[1] << " " << p1[2] << endl;
+  //cout << p2[0] << " " << p2[1] << " " << p2[2] << endl;
+  //cout << "ZOOM  : " << coefficient << endl;
+
+  return coefficient;
+}
+
 //-----------------------------------------------------------------------------
 void VISU_OpenGLPointSpriteMapper::DrawPoints(vtkPoints *p,
                                              vtkUnsignedCharArray *colors,
@@ -681,23 +701,11 @@ void VISU_OpenGLPointSpriteMapper::DrawPoints(vtkPoints *p,
                                              vtkRenderer *ren,
                                              vtkActor* act)
 {
-  if( this->UsePointSprites )
+  if( this->UsePointSprites ) //&& this->PrimitiveType == VISU_OpenGLPointSpriteMapper::PointSprite )
     this->InitPointSprites();
 
-  float p1[3], p2[3];
-
-  ren->SetViewPoint( 0.0, 0.0, 0.0 );
-  ren->ViewToDisplay();
-  ren->GetDisplayPoint( p1 );
-
-  ren->SetViewPoint( 1.0, 1.0, 1.0 );
-  ren->ViewToDisplay();
-  ren->GetDisplayPoint( p2 );
-
-  float coefficient = sqrt( pow( p2[0] - p1[0], 2 ) + pow( p2[1] - p1[1], 2 ) ) / sqrt( 2 );
-  //cout << p1[0] << " " << p1[1] << " " << p1[2] << endl;
-  //cout << p2[0] << " " << p2[1] << " " << p2[2] << endl;
-  //cout << "ZOOM  : " << coefficient << endl;
+  if( this->PrimitiveType == VISU_OpenGLPointSpriteMapper::OpenGLPoint )
+    glEnable( GL_POINT_SMOOTH );
 
   glPointSize( this->DefaultPointSize );
 
@@ -749,7 +757,7 @@ void VISU_OpenGLPointSpriteMapper::DrawPoints(vtkPoints *p,
     else
       size = this->PointSpriteSize;
 
-    aVertex[i].hue =  coefficient * this->AverageCellSize * this->PointSpriteMagnification * size;
+    aVertex[i].hue = ViewToDisplay( ren ) * this->AverageCellSize * this->PointSpriteMagnification * size;
   }
 
   GLuint aBufferObjectID = 0;
@@ -779,8 +787,11 @@ void VISU_OpenGLPointSpriteMapper::DrawPoints(vtkPoints *p,
 
   vglUseProgramObjectARB( 0 );
 
-  if( this->UsePointSprites )
+  if( this->UsePointSprites ) //&& this->PrimitiveType == VISU_OpenGLPointSpriteMapper::PointSprite )
     this->CleanupPointSprites();
+
+  if( this->PrimitiveType == VISU_OpenGLPointSpriteMapper::OpenGLPoint )
+    glDisable( GL_POINT_SMOOTH );
 }
 
 //-----------------------------------------------------------------------------
index 097ffdd6be2c0c38155b2cadcd2562e874609d0e..2d33325f887213096a9a3e7195e37b9b709309f5 100644 (file)
@@ -599,6 +599,7 @@ void VisuGUI_GaussPointsDlg::initFromPrsObject( VISU::GaussPoints_i* thePrs )
   bool isDeformed = thePrs->GetIsDeformed();
   myScaleSpinBox->setValue( thePrs->GetScaleFactor() );
   myDefShapeButton->setChecked( isDeformed );
+  myDefShapeButton->setEnabled( thePrs->GetField()->myNbComp > 1 );
   onToggleDefShape( isDeformed );
 
   bool isResults = thePrs->GetIsColored();
index 1fa96fd21a6892844c26ecf62ae6befb7feb0c6b..c81d39cbc44ab0473167f8feae8407c32e951973 100644 (file)
@@ -356,6 +356,7 @@ void VVTK_SegmentationCursorDlg::UpdateInsideGaussPoints()
   QString aMainTexture = QString( getenv( "VISU_ROOT_DIR") ) + "/share/salome/resources/sprite_texture.bmp";
   QString anAlphaTexture = QString( getenv( "VISU_ROOT_DIR") ) + "/share/salome/resources/sprite_alpha.bmp";
   float anAlphaThreshold = 0.1;
+  int aResolution = 8;
   int aMinSize = 3;
   int aMaxSize = 33;
   int aMagnification = 100;
@@ -368,6 +369,7 @@ void VVTK_SegmentationCursorDlg::UpdateInsideGaussPoints()
     myInsidePrimitiveBox->setMainTexture( myInsideMainTexture );
     myInsidePrimitiveBox->setAlphaTexture( myInsideAlphaTexture );
     myInsidePrimitiveBox->setAlphaThreshold( myInsideCursorSettings->GetAlphaThreshold() );
+    myInsidePrimitiveBox->setResolution( myInsideCursorSettings->GetResolution() );
 
     myInsideSizeBox->setMinSize( myInsideCursorSettings->GetMinSize() );
     myInsideSizeBox->setMaxSize( myInsideCursorSettings->GetMaxSize() );
@@ -394,6 +396,9 @@ void VVTK_SegmentationCursorDlg::UpdateInsideGaussPoints()
   anAlphaThreshold = aResourceMgr->doubleValue( "VISU", "inside_point_sprite_alpha_threshold", anAlphaThreshold );
   myInsidePrimitiveBox->setAlphaThreshold( anAlphaThreshold );
 
+  aResolution = aResourceMgr->integerValue( "VISU", "inside_geom_sphere_resolution", aResolution );
+  myInsidePrimitiveBox->setResolution( aResolution );
+
   aMinSize = aResourceMgr->integerValue( "VISU", "inside_point_sprite_min_size", aMinSize );
   myInsideSizeBox->setMinSize( aMinSize / 100.0 );
 
@@ -416,6 +421,7 @@ void VVTK_SegmentationCursorDlg::UpdateOutsideGaussPoints()
   QString aMainTexture = QString( getenv( "VISU_ROOT_DIR") ) + "/share/salome/resources/sprite_texture.bmp";
   QString anAlphaTexture = QString( getenv( "VISU_ROOT_DIR") ) + "/share/salome/resources/sprite_alpha.bmp";
   float anAlphaThreshold = 0.1;
+  int aResolution = 8;
   int aSize = 25;
   bool aUniform = false;
   QColor aColor = Qt::blue;
@@ -427,6 +433,7 @@ void VVTK_SegmentationCursorDlg::UpdateOutsideGaussPoints()
     myOutsidePrimitiveBox->setMainTexture( myOutsideMainTexture );
     myOutsidePrimitiveBox->setAlphaTexture( myOutsideAlphaTexture );
     myOutsidePrimitiveBox->setAlphaThreshold( myOutsideCursorSettings->GetAlphaThreshold() );
+    myOutsidePrimitiveBox->setResolution( myOutsideCursorSettings->GetResolution() );
 
     myOutsideSizeBox->setOutsideSize( myOutsideCursorSettings->GetSize() );
     myOutsideSizeBox->setUniform( myOutsideCursorSettings->GetUniform() );
@@ -456,6 +463,9 @@ void VVTK_SegmentationCursorDlg::UpdateOutsideGaussPoints()
   anAlphaThreshold = aResourceMgr->doubleValue( "VISU", "outside_point_sprite_alpha_threshold", anAlphaThreshold );
   myOutsidePrimitiveBox->setAlphaThreshold( anAlphaThreshold );
 
+  aResolution = aResourceMgr->integerValue( "VISU", "outside_geom_sphere_resolution", aResolution );
+  myOutsidePrimitiveBox->setResolution( aResolution );
+
   aSize = aResourceMgr->integerValue( "VISU", "outside_point_sprite_size", aSize );
   myOutsideSizeBox->setOutsideSize( aSize / 100.0 );
 
@@ -593,6 +603,7 @@ void VVTK_SegmentationCursorDlg::ApplyInsideGaussPoints()
   myInsideCursorSettings->SetPrimitiveType( myInsidePrimitiveBox->getPrimitiveType() );
   myInsideCursorSettings->SetClamp( myInsidePrimitiveBox->getClamp() );
   myInsideCursorSettings->SetAlphaThreshold( myInsidePrimitiveBox->getAlphaThreshold() );
+  myInsideCursorSettings->SetResolution( myInsidePrimitiveBox->getResolution() );
 
   myInsideCursorSettings->SetMinSize( myInsideSizeBox->getMinSize() );
   myInsideCursorSettings->SetMaxSize( myInsideSizeBox->getMaxSize() );
@@ -615,6 +626,7 @@ void VVTK_SegmentationCursorDlg::ApplyOutsideGaussPoints()
   myOutsideCursorSettings->SetPrimitiveType( myOutsidePrimitiveBox->getPrimitiveType() );
   myOutsideCursorSettings->SetClamp( myOutsidePrimitiveBox->getClamp() );
   myOutsideCursorSettings->SetAlphaThreshold( myOutsidePrimitiveBox->getAlphaThreshold() );
+  myOutsideCursorSettings->SetResolution( myOutsidePrimitiveBox->getResolution() );
 
   myOutsideCursorSettings->SetSize( myOutsideSizeBox->getOutsideSize() );
   myOutsideCursorSettings->SetUniform( myOutsideSizeBox->getUniform() );