From 3c07bccfaa576f7ac26153fa6cb2f88ec6f021ce Mon Sep 17 00:00:00 2001 From: Christophe Bourcier Date: Tue, 20 Oct 2020 08:19:47 +0200 Subject: [PATCH] Fix point sprites representation to use point gaussian --- src/MEDCalc/cmp/MEDPresentation.cxx | 8 ++- .../cmp/MEDPresentationPointSprite.cxx | 50 ++++++++++++------- 2 files changed, 38 insertions(+), 20 deletions(-) diff --git a/src/MEDCalc/cmp/MEDPresentation.cxx b/src/MEDCalc/cmp/MEDPresentation.cxx index 5c2520732..2018c7aa2 100644 --- a/src/MEDCalc/cmp/MEDPresentation.cxx +++ b/src/MEDCalc/cmp/MEDPresentation.cxx @@ -322,7 +322,7 @@ MEDPresentation::createSource() { std::ostringstream oss, oss2; oss2 << "__srcObj" << GeneratePythonId(); - oss << oss2.str() << " = pvs.GaussPoints(Input=" << _srcObjVar << ");"; + oss << oss2.str() << " = pvs.ELGAfieldToPointGaussian(Input=" << _srcObjVar << ");"; pushAndExecPyLine(oss.str()); oss.str(""); // Now the source becomes the result of the CellDatatoPointData: _srcObjVar = oss2.str(); @@ -600,6 +600,12 @@ MEDPresentation::fillAvailableFieldComponents() throw KERNEL::createSalomeException("Unexpected Python error"); } setIntProperty(MEDPresentation::PROP_NB_COMPONENTS, nbCompo); + + // if the field is not a vector (2 or 3 components), select the first component of the tensor, + // like in WidgetPresentationParameters::setComponents + if (!(nbCompo > 1 && nbCompo <= 3)) + _selectedComponentIndex = 0; + for (long i = 0; i 1) + { + if (_selectedComponentIndex == -1) + oss << _dispVar << ".ScaleArrayComponent = 'Magnitude';"; + else + oss << _dispVar << ".ScaleArrayComponent = " << _selectedComponentIndex << ";"; + pushAndExecPyLine(oss.str()); oss.str(""); + } + + // rescale transfer function to update scalar bar and get min-max range + rescaleTransferFunction(); + + // _rangeVar (to get min and max of the fields) is updated in rescaleTransferFunction + oss << _dispVar << ".ScaleTransferFunction.RescaleTransferFunction(" << _rangeVar << "[0], " << _rangeVar << "[1]);"; pushAndExecPyLine(oss.str()); oss.str(""); } @@ -73,36 +89,32 @@ MEDPresentationPointSprite::internalGeneratePipeline() showObject(); // needs to be done before cell size computation to be sure ParaView has computed bounds, etc ... - // Compute cell average size in the mesh to have a nice scaling ratio: - std::ostringstream oss; - oss << "__avgSize = medcalc.ComputeCellAverageSize(" << _srcObjVar << ");"; - pushAndExecPyLine(oss.str()); oss.str(""); - colorBy(); // see initFieldInfo() - necessarily POINTS like in Contour + std::ostringstream oss; + // Set point sprite: - oss << _dispVar << ".SetRepresentationType('Point Sprite');"; + oss << _dispVar << ".SetRepresentationType('Point Gaussian');"; pushAndExecPyLine(oss.str()); oss.str(""); - oss << _dispVar << ".PointSpriteDefaultsInitialized = 1;"; + oss << _dispVar << ".ScaleByArray = 1;"; pushAndExecPyLine(oss.str()); oss.str(""); - oss << _dispVar << ".RadiusArray = ['POINTS', '" << _fieldName << "'];"; - pushAndExecPyLine(oss.str()); oss.str(""); - oss << _dispVar << ".RadiusMode = 'Scalar';"; + oss << _dispVar << ".SetScaleArray = ['POINTS', '" << _fieldName << "'];"; pushAndExecPyLine(oss.str()); oss.str(""); - scaleBallRadius(); - oss << _dispVar << ".RadiusIsProportional = 0 ;"; - pushAndExecPyLine(oss.str()); oss.str(""); - oss << _dispVar << ".RadiusTransferFunctionEnabled = 1 ;"; + // Compute the best radius again (like reset using current data value in GUI) + oss << "pvs.ResetProperty('GaussianRadius');"; pushAndExecPyLine(oss.str()); oss.str(""); - oss << _dispVar << ".MaxPixelSize = 30 ;"; // Avoid too big balls - pushAndExecPyLine(oss.str()); oss.str(""); - oss << _dispVar << ".RadiusRange = [0.0, __avgSize];"; + + // Make the radius twice the default radius + oss << _dispVar << ".GaussianRadius = 2*" << _dispVar << ".GaussianRadius" << ";"; pushAndExecPyLine(oss.str()); oss.str(""); showScalarBar(); selectColorMap(); - rescaleTransferFunction(); + + // Scale the radius array with the component and the scalar map + scaleBallRadius(); + resetCameraAndRender(); } -- 2.39.2