long nbContours;
};
-// struct VectorFieldParameters {
-// long fieldHandlerId;
-// string displayedComponent; // DISPLAY_EUCLIDEAN_NORM or any component name
-// ScalarBarRangeType scalarBarRange;
-// ColorMapType colorMap;
-// };
-//
+ struct VectorFieldParameters {
+ long fieldHandlerId;
+ string displayedComponent; // DISPLAY_EUCLIDEAN_NORM or any component name - only used to color the glyphs
+ ScalarBarRangeType scalarBarRange;
+ ColorMapType colorMap;
+ };
+
struct SlicesParameters {
long fieldHandlerId;
string displayedComponent; // DISPLAY_EUCLIDEAN_NORM or any component name
// long fieldHandlerId;
// };
//
-// struct PointSpriteParameters {
-// long fieldHandlerId;
-// string displayedComponent; // DISPLAY_EUCLIDEAN_NORM or any component name
-// ScalarBarRangeType scalarBarRange;
-// ColorMapType colorMap;
-// };
+ struct PointSpriteParameters {
+ long fieldHandlerId;
+ string displayedComponent; // DISPLAY_EUCLIDEAN_NORM or any component name
+ ScalarBarRangeType scalarBarRange;
+ ColorMapType colorMap;
+ };
typedef sequence<long> PresentationsList;
interface MEDPresentationManager : SALOME::GenericObj
{
- long makeMeshView(in MeshViewParameters params, in ViewModeType viewMode);
- long makeScalarMap(in ScalarMapParameters params, in ViewModeType viewMode);
- long makeContour(in ContourParameters params, in ViewModeType viewMode)
- raises (SALOME::SALOME_Exception);
-// long makeVectorField(in VectorFieldParameters params, in ViewModeType viewMode);
- long makeSlices(in SlicesParameters params, in ViewModeType viewMode);
+ long makeMeshView(in MeshViewParameters params, in ViewModeType viewMode) raises (SALOME::SALOME_Exception);
+ long makeScalarMap(in ScalarMapParameters params, in ViewModeType viewMode) raises (SALOME::SALOME_Exception);
+ long makeContour(in ContourParameters params, in ViewModeType viewMode) raises (SALOME::SALOME_Exception);
+ long makeVectorField(in VectorFieldParameters params, in ViewModeType viewMode) raises (SALOME::SALOME_Exception);
+ long makeSlices(in SlicesParameters params, in ViewModeType viewMode) raises (SALOME::SALOME_Exception);
// long makeDeflectionShape(in DeflectionShapeParameters params, in ViewModeType viewMode);
-// long makePointSprite(in PointSpriteParameters params, in ViewModeType viewMode);
+ long makePointSprite(in PointSpriteParameters params, in ViewModeType viewMode);
void setPresentationStringProperty(in long presId, in string propName, in string propValue);
string getPresentationStringProperty(in long presId, in string propName);
ScalarMapParameters getScalarMapParameters(in long presId);
ContourParameters getContourParameters(in long presId);
SlicesParameters getSlicesParameters(in long presId);
+ VectorFieldParameters getVectorFieldParameters(in long presId);
+ PointSpriteParameters getPointSpriteParameters(in long presId);
void updateMeshView(in long presId, in MeshViewParameters params);
void updateScalarMap(in long presId, in ScalarMapParameters params);
void updateContour(in long presId, in ContourParameters params);
-// void updateVectorField(in long presId, in VectorFieldParameters params);
+ void updateVectorField(in long presId, in VectorFieldParameters params);
void updateSlices(in long presId, in SlicesParameters params);
// void updateDeflectionShape(in long presId, in DeflectionShapeParameters params);
-// void updatePointSprite(in long presId, in PointSpriteParameters params);
+ void updatePointSprite(in long presId, in PointSpriteParameters params);
boolean removePresentation(in long presId);
MEDPresentationMeshView.cxx
MEDPresentationScalarMap.cxx
MEDPresentationContour.cxx
-# MEDPresentationVectorField.cxx
+ MEDPresentationVectorField.cxx
MEDPresentationSlices.cxx
-# MEDPresentationDeflectionShape.cxx
-# MEDPresentationPointSprite.cxx
+ MEDPresentationPointSprite.cxx
+# MEDPresentationDeflectionShape.cxx
)
SET(MEDFactoryEngine_SOURCES
_fileName = dataSHandler->uri;
_fieldName = fieldHandler->fieldname;
_fieldType = getFieldTypeString((MEDCoupling::TypeOfField) fieldHandler->type);
+ _meshName = meshHandler->name;
if (_fileName.substr(0, 7) != std::string("file://")) {
const char* msg = "MEDPresentation(): Data source is not a file! Can not proceed.";
}
+/**
+* @return a borrowed reference. Do not DECRREF!
+*/
PyObject*
MEDPresentation::getPythonObjectFromMain(const char* python_var) const
{
return oss.str();
}
-std::string
-MEDPresentation::getRenderViewCommand() const
+void
+MEDPresentation::createSource()
{
- std::ostringstream oss, oss2;
+ std::ostringstream oss;
+ oss << _srcObjVar << " = pvs.MEDReader(FileName='" << _fileName << "');";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ oss << _srcObjVar << ".GenerateVectors = 1;";
+ pushAndExecPyLine(oss.str()); oss.str("");
+}
+
+void
+MEDPresentation::setOrCreateRenderView()
+{
+ std::ostringstream oss2;
std::string view(getRenderViewVar());
- oss2 << "pvs._DisableFirstRenderCameraReset();" << std::endl;
+ oss2 << "pvs._DisableFirstRenderCameraReset();";
+ pushAndExecPyLine(oss2.str()); oss2.str("");
if (_viewMode == MEDCALC::VIEW_MODE_OVERLAP) {
// this might potentially re-assign to an existing view variable, but this is OK, we
// normally reassign exaclty the same RenderView object.
- oss2 << view << " = pvs.GetActiveViewOrCreate('RenderView');" << std::endl;
+ oss2 << view << " = pvs.GetActiveViewOrCreate('RenderView');";
+ pushAndExecPyLine(oss2.str()); oss2.str("");
} else if (_viewMode == MEDCALC::VIEW_MODE_REPLACE) {
// same as above
- oss2 << view << " = pvs.GetActiveViewOrCreate('RenderView');" << std::endl;
- oss2 << "pvs.active_objects.source and pvs.Hide(view=" << view << ");" << std::endl;
- oss2 << "pvs.Render();" << std::endl;
+ oss2 << view << " = pvs.GetActiveViewOrCreate('RenderView');";
+ pushAndExecPyLine(oss2.str()); oss2.str("");
+ oss2 << "pvs.active_objects.source and pvs.Hide(view=" << view << ");";
+ pushAndExecPyLine(oss2.str()); oss2.str("");
+ oss2 << "pvs.Render();";
+ pushAndExecPyLine(oss2.str()); oss2.str("");
} else if (_viewMode == MEDCALC::VIEW_MODE_NEW_LAYOUT) {
- oss2 << "__layout1 = pvs.servermanager.misc.ViewLayout(registrationGroup='layouts');" << std::endl;
- oss2 << view << " = pvs.CreateView('RenderView');" << std::endl;
+ oss2 << "__layout1 = pvs.servermanager.misc.ViewLayout(registrationGroup='layouts');";
+ pushAndExecPyLine(oss2.str()); oss2.str("");
+ oss2 << view << " = pvs.CreateView('RenderView');";
+ pushAndExecPyLine(oss2.str()); oss2.str("");
} else if (_viewMode == MEDCALC::VIEW_MODE_SPLIT_VIEW) {
- oss2 << view << " = pvs.CreateView('RenderView');" << std::endl;
+ oss2 << view << " = pvs.CreateView('RenderView');";
+ pushAndExecPyLine(oss2.str()); oss2.str("");
}
- return oss2.str();
}
-std::string
-MEDPresentation::getResetCameraCommand() const
+void
+MEDPresentation::resetCameraAndRender()
{
- return getRenderViewVar() + ".ResetCamera();";
+ pushAndExecPyLine(getRenderViewVar() + ".ResetCamera();");
+ pushAndExecPyLine("pvs.Render();");
}
-std::string
-MEDPresentation::getComponentSelectionCommand() const
+void
+MEDPresentation::selectFieldComponent()
{
std::ostringstream oss, oss_l;
std::string ret;
if (_selectedComponentIndex != -1)
{
- oss << _lutVar << ".VectorMode = 'Component';\n";
+ oss << _lutVar << ".VectorMode = 'Component';";
+ pushAndExecPyLine(oss.str()); oss.str("");
oss << _lutVar << ".VectorComponent = " << _selectedComponentIndex << ";";
+ pushAndExecPyLine(oss.str()); oss.str("");
}
else // Euclidean norm
{
oss << _lutVar << ".VectorMode = 'Magnitude';";
+ pushAndExecPyLine(oss.str()); oss.str("");
}
- return oss.str();
}
-std::string
-MEDPresentation::getColorMapCommand() const
+void
+MEDPresentation::selectColorMap()
{
- std::string ret;
+ std::ostringstream oss, oss2;
+
+ oss2 << _lutVar << " = pvs.GetColorTransferFunction('" << _fieldName << "');";
+ pushAndExecPyLine(oss2.str());
+
switch (_colorMap) {
case MEDCALC::COLOR_MAP_BLUE_TO_RED_RAINBOW:
- ret = _lutVar + ".ApplyPreset('Blue to Red Rainbow',True);";
+ oss << _lutVar << ".ApplyPreset('Blue to Red Rainbow',True);";
break;
case MEDCALC::COLOR_MAP_COOL_TO_WARM:
- ret = _lutVar + ".ApplyPreset('Cool to Warm',True);";
+ oss << _lutVar << ".ApplyPreset('Cool to Warm',True);";
break;
default:
STDLOG("MEDPresentation::getColorMapCommand(): invalid colormap!");
throw KERNEL::createSalomeException("MEDPresentation::getColorMapCommand(): invalid colormap!");
}
- return ret;
+ pushAndExecPyLine(oss.str());
}
-std::string
-MEDPresentation::getRescaleCommand() const
+
+void
+MEDPresentation::showObject()
+{
+ std::ostringstream oss;
+ oss << _dispVar << " = pvs.Show(" << _objVar << ", " << getRenderViewVar() << ");";
+ pushAndExecPyLine(oss.str());
+}
+
+void
+MEDPresentation::showScalarBar()
+{
+ std::ostringstream oss;
+ oss << _dispVar << ".SetScalarBarVisibility(" << getRenderViewVar() << ", True);";
+ pushAndExecPyLine(oss.str());
+}
+
+void
+MEDPresentation::colorBy(const std::string & fieldType)
+{
+ std::ostringstream oss;
+ oss << "pvs.ColorBy(" << _dispVar << ", ('" << fieldType << "', '" << _fieldName << "'));";
+ pushAndExecPyLine(oss.str());
+}
+
+void
+MEDPresentation::rescaleTransferFunction()
{
std::string ret;
switch(_sbRange)
STDLOG("MEDPresentation::getRescaleCommand(): invalid range!");
throw KERNEL::createSalomeException("MEDPresentation::getRescaleCommand(): invalid range!");
}
- return ret;
+ pushAndExecPyLine(ret);
}
int
}
}
+/**
+ * In case where a CELLS field needs to be converted to POINT field.
+ * This updates the source object to become the result of the CellDatatoPointData filter.
+ */
+void
+MEDPresentation::applyCellToPointIfNeeded()
+{
+ std::ostringstream oss, oss2;
+ // Apply Cell data to point data:
+ oss2 << "__srcObj" << GeneratePythonId();
+ oss << oss2.str() << " = pvs.CellDatatoPointData(Input=" << _srcObjVar << ");";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ // Now the source becomes the result of the CellDatatoPointData:
+ _srcObjVar = oss2.str();
+}
+
+/**
+ * Convert a vector field into a 3D vector field:
+ * - if the vector field is already 3D, nothing to do
+ * - if it is 2D, then add a null component
+ * - otherwise (tensor field, scalar field) throw
+ */
+void
+MEDPresentation::convertTo3DVectorField()
+{
+ std::ostringstream oss, oss1, oss2, oss3;
+
+ int nbCompo = getIntProperty(MEDPresentation::PROP_NB_COMPONENTS);
+ if (nbCompo < 2 || nbCompo > 3)
+ {
+ oss << "The field '" << _fieldName << "' must have 2 or 3 components for this presentation!";
+ STDLOG(oss.str());
+ throw KERNEL::createSalomeException(oss.str().c_str());
+ }
+ if (nbCompo == 3)
+ return;
+
+ // Apply calculator:
+ oss2 << "__srcObj" << GeneratePythonId();
+ oss << oss2.str() << " = pvs.Calculator(Input=" << _srcObjVar << ");";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ // Now the source becomes the result of the CellDatatoPointData:
+ _srcObjVar = oss2.str();
+ std::string typ;
+ if(_fieldType == "CELLS")
+ typ = "Cell Data";
+ else if(_fieldType == "POINTS")
+ typ = "Point Data";
+ else
+ {
+ oss3 << "Field '" << _fieldName << "' has invalid field type";
+ STDLOG(oss3.str());
+ throw KERNEL::createSalomeException(oss3.str().c_str());
+ }
+ oss << _srcObjVar << ".AttributeMode = '" << typ << "';";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ oss << _srcObjVar << ".ResultArrayName = '" << _fieldName << "_CALC';"; // will never be needed I think
+ pushAndExecPyLine(oss.str()); oss.str("");
+ oss << _srcObjVar << ".Function = '" << _fieldName << "_0*iHat + " << _fieldName << "_1*jHat + 0.0*zHat';";
+ pushAndExecPyLine(oss.str()); oss.str("");
+}
+
+//double
+//MEDPresentation::computeCellAverageSize()
+//{
+// std::ostringstream oss;
+// oss << "import MEDLoader;";
+// pushAndExecPyLine(oss.str()); oss.str("");
+// oss << "__mesh = MEDLoader.ReadMeshFromFile('" << _fileName << "', '" << _meshName << "');";
+// pushAndExecPyLine(oss.str()); oss.str("");
+//
+// oss << "__bb = __mesh.getBoundingBox()";
+// pushAndExecPyLine(oss.str()); oss.str("");
+// oss << "__deltas = [x[1]-x[0] for x in __bb];";
+// pushAndExecPyLine(oss.str()); oss.str("");
+// oss << "__vol = reduce(lambda x,y:x*y, __deltas, 1.0);";
+// pushAndExecPyLine(oss.str()); oss.str("");
+// // Average cell size is the the n-th root of average volume of a cell, with n being the space dimension
+// oss << "__cellSize = (__vol/__mesh.getNumberOfCells())**(1.0/len(__bb));";
+// pushAndExecPyLine(oss.str()); oss.str("");
+//
+// PyObject * pyObj = getPythonObjectFromMain("__cellSize");
+// bool err = false;
+// if (!pyObj || !PyFloat_Check(pyObj)) { /* nothing to do, err handler below */}
+// else {
+// double ret= PyFloat_AsDouble(pyObj);
+// if(!PyErr_Occurred())
+// return ret;
+// }
+// // From here, an error for sure.
+// const char * msg = "MEDPresentation::computeCellAverageSize(): Python error.";
+// STDLOG(msg);
+// throw KERNEL::createSalomeException(msg);
+//}
const MEDCALC::ViewModeType viewMode,
const MEDCALC::ColorMapType colorMap,
const MEDCALC::ScalarBarRangeType sbRange);
- std::string getRenderViewCommand() const;
std::string getRenderViewVar() const;
- std::string getResetCameraCommand() const;
- std::string getComponentSelectionCommand() const;
- std::string getColorMapCommand() const;
- std::string getRescaleCommand() const;
+ // The most common elements of the ParaView pipeline:
+ void setOrCreateRenderView();
+ void createSource();
+ void selectFieldComponent();
+ void showObject();
+ void colorBy(const std::string & fieldType);
+ void showScalarBar();
+ void rescaleTransferFunction();
+ void selectColorMap();
+ void resetCameraAndRender();
virtual void internalGeneratePipeline();
PyObject* getPythonObjectFromMain(const char* var) const;
MEDPresentation::TypeID getID() const { return _fieldHandlerId; }
void fillAvailableFieldComponents();
+ void applyCellToPointIfNeeded();
+ void convertTo3DVectorField();
+// double computeCellAverageSize();
+ //void computeFieldRange
// virtual MEDCALC::ViewModeType getViewMode() = 0;
void updatePipeline(const PresentationParameters& params);
protected:
+ std::string _meshName;
std::string _fileName;
std::string _fieldName;
std::string _fieldType;
MEDPyLockWrapper lock;
std::ostringstream oss;
- std::string cmd = getComponentSelectionCommand();
- pushAndExecPyLine(cmd);
+ selectFieldComponent();
pushAndExecPyLine("pvs.Render();");
}
// Update the pipeline:
{
MEDPyLockWrapper lock;
- std::string cmd = getColorMapCommand();
- pushAndExecPyLine(cmd);
+ selectColorMap();
pushAndExecPyLine("pvs.Render();");
}
}
// Update the pipeline:
{
MEDPyLockWrapper lock;
- std::string cmd = getRescaleCommand();
- pushAndExecPyLine(cmd);
+ rescaleTransferFunction();
pushAndExecPyLine("pvs.Render();");
}
}
setIntProperty(MEDPresentationContour::PROP_NB_CONTOUR, params.nbContours);
}
-std::string
-MEDPresentationContour::getContourCommand() const
+void
+MEDPresentationContour::setNumberContours()
{
- std::ostringstream oss1;
+ std::ostringstream oss;
- oss1 << "min_max = " << _srcObjVar << ".PointData.GetArray('" << _fieldName << "').GetRange();\n";
- oss1 << "delta = (min_max[1]-min_max[0])/float(" << _params.nbContours << ");\n";
- oss1 << _objVar << ".Isosurfaces = [min_max[0]+0.5*delta+i*delta for i in range(" << _params.nbContours << ")];\n";
- return oss1.str();
+ oss << "min_max = " << _srcObjVar << ".PointData.GetArray('" << _fieldName << "').GetRange();";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ oss << "delta = (min_max[1]-min_max[0])/float(" << _params.nbContours << ");";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ oss << _objVar << ".Isosurfaces = [min_max[0]+0.5*delta+i*delta for i in range(" << _params.nbContours << ")];";
+ pushAndExecPyLine(oss.str()); oss.str("");
}
void
MEDPyLockWrapper lock;
- std::ostringstream oss_o, oss;
- std::string view(getRenderViewVar());
-
- oss << _srcObjVar << " = pvs.MEDReader(FileName='" << _fileName << "');";
- pushAndExecPyLine(oss.str()); oss.str("");
+ createSource();
// Populate internal array of available components:
fillAvailableFieldComponents();
throw KERNEL::createSalomeException(msg);
}
- pushAndExecPyLine( getRenderViewCommand() ); // instanciate __viewXXX
+ setOrCreateRenderView(); // instanciate __viewXXX
- if(_fieldType == "CELLS")
- {
- // In case of a CELLS field need to convert to POINT field, and update source
- STDLOG("Applying CellDatatoPointData filter");
- std::ostringstream oss2, oss4;
- // Apply Cell data to point data:
- oss2 << "__obj" << GeneratePythonId();
- oss << oss2.str() << " = pvs.CellDatatoPointData(Input=" << _srcObjVar << ");";
- pushAndExecPyLine(oss.str()); oss.str("");
- // Now the source becomes the result of the CellDatatoPointData:
- _srcObjVar = oss2.str();
- }
+ // Contour needs point data:
+ applyCellToPointIfNeeded();
+
+ std::ostringstream oss;
oss << _objVar << " = pvs.Contour(Input=" << _srcObjVar << ");";
pushAndExecPyLine(oss.str()); oss.str("");
+
+ showObject();
+
oss << _objVar << ".ContourBy = ['POINTS', '" << _fieldName << "'];";
pushAndExecPyLine(oss.str()); oss.str("");
// Set number of contours
- pushAndExecPyLine(getContourCommand());
-
- oss << _dispVar << " = pvs.Show(" << _objVar << ", " << view << ");";
- pushAndExecPyLine(oss.str()); oss.str("");
- oss << "pvs.ColorBy(" << _dispVar << ", ('POINTS', '" << _fieldName << "'));"; // necessarily POINTS
- pushAndExecPyLine(oss.str()); oss.str("");
- oss << _dispVar << ".SetScalarBarVisibility(" << view << ", True);";
- pushAndExecPyLine(oss.str()); oss.str("");
- oss << getRescaleCommand();
- pushAndExecPyLine(oss.str()); oss.str("");
- oss << _lutVar << " = pvs.GetColorTransferFunction('" << _fieldName << "');";
- pushAndExecPyLine(oss.str()); oss.str("");
- pushAndExecPyLine(getColorMapCommand()); oss.str("");
- pushAndExecPyLine(getResetCameraCommand());
- pushAndExecPyLine("pvs.Render();");
+ setNumberContours();
+ colorBy("POINTS"); // necessarily POINTS because of the conversion above
+ showScalarBar();
+ rescaleTransferFunction();
+ selectColorMap();
+ resetCameraAndRender();
}
void
// Update the pipeline:
{
MEDPyLockWrapper lock;
- std::string cmd = getContourCommand();
- pushAndExecPyLine(cmd);
+ setNumberContours();
pushAndExecPyLine("pvs.Render();");
}
}
void updateNbContours(const int nbContours);
virtual void internalGeneratePipeline();
- std::string getContourCommand() const;
+ void setNumberContours();
private:
MEDCALC::ContourParameters _params;
#include "MEDPresentationScalarMap.hxx"
#include "MEDPresentationContour.hxx"
#include "MEDPresentationSlices.hxx"
-//#include "MEDPresentationVectorField.hxx"
+#include "MEDPresentationVectorField.hxx"
//#include "MEDPresentationDeflectionShape.hxx"
-//#include "MEDPresentationPointSprite.hxx"
+#include "MEDPresentationPointSprite.hxx"
#include <SALOME_KernelServices.hxx>
return _makePresentation<MEDPresentationContour>(params, viewMode);
}
-//MEDPresentation::TypeID
-//MEDPresentationManager_i::makeVectorField(const MEDCALC::VectorFieldParameters& params)
-//{
-// return _makePresentation<MEDPresentationVectorField>(params);
-//}
-//
+MEDPresentation::TypeID
+MEDPresentationManager_i::makeVectorField(const MEDCALC::VectorFieldParameters& params, const MEDCALC::ViewModeType viewMode)
+{
+ return _makePresentation<MEDPresentationVectorField>(params, viewMode);
+}
+
MEDPresentation::TypeID
MEDPresentationManager_i::makeSlices(const MEDCALC::SlicesParameters& params, const MEDCALC::ViewModeType viewMode)
{
//{
// return _makePresentation<MEDPresentationDeflectionShape>(params);
//}
-//
-//MEDPresentation::TypeID
-//MEDPresentationManager_i::makePointSprite(const MEDCALC::PointSpriteParameters& params)
-//{
-// return _makePresentation<MEDPresentationPointSprite>(params);
-//}
+
+MEDPresentation::TypeID
+MEDPresentationManager_i::makePointSprite(const MEDCALC::PointSpriteParameters& params, const MEDCALC::ViewModeType viewMode)
+{
+ return _makePresentation<MEDPresentationPointSprite>(params, viewMode);
+}
MEDCALC::MeshViewParameters
MEDPresentationManager_i::getMeshViewParameters(MEDPresentation::TypeID presentationID)
return tmp._retn();
}
+MEDCALC::VectorFieldParameters*
+MEDPresentationManager_i::getVectorFieldParameters(MEDPresentation::TypeID presentationID)
+{
+ MEDCALC::VectorFieldParameters* p = new MEDCALC::VectorFieldParameters();
+ _getParameters<MEDPresentationVectorField>(presentationID, *p);
+ MEDCALC::VectorFieldParameters_var tmp(p);
+ return tmp._retn();
+}
+
+MEDCALC::PointSpriteParameters*
+MEDPresentationManager_i::getPointSpriteParameters(MEDPresentation::TypeID presentationID)
+{
+ MEDCALC::PointSpriteParameters* p = new MEDCALC::PointSpriteParameters();
+ _getParameters<MEDPresentationPointSprite>(presentationID, *p);
+ MEDCALC::PointSpriteParameters_var tmp(p);
+ return tmp._retn();
+}
void
MEDPresentationManager_i::updateMeshView(MEDPresentation::TypeID presentationID, const MEDCALC::MeshViewParameters& params)
return _updatePresentation<MEDPresentationContour>(presentationID, params);
}
-//void
-//MEDPresentationManager_i::updateVectorField(MEDPresentation::TypeID presentationID, const MEDCALC::VectorFieldParameters& params)
-//{
-// return _updatePresentation<MEDPresentationVectorField>(presentationID, params);
-//}
-//
+void
+MEDPresentationManager_i::updateVectorField(MEDPresentation::TypeID presentationID, const MEDCALC::VectorFieldParameters& params)
+{
+ return _updatePresentation<MEDPresentationVectorField>(presentationID, params);
+}
+
void
MEDPresentationManager_i::updateSlices(MEDPresentation::TypeID presentationID, const MEDCALC::SlicesParameters& params)
{
//{
// return _updatePresentation<MEDPresentationDeflectionShape>(presentationID, params);
//}
-//
-//void
-//MEDPresentationManager_i::updatePointSprite(MEDPresentation::TypeID presentationID, const MEDCALC::PointSpriteParameters& params)
-//{
-// return _updatePresentation<MEDPresentationPointSprite>(presentationID, params);
-//}
+
+void
+MEDPresentationManager_i::updatePointSprite(MEDPresentation::TypeID presentationID, const MEDCALC::PointSpriteParameters& params)
+{
+ return _updatePresentation<MEDPresentationPointSprite>(presentationID, params);
+}
CORBA::Boolean
MEDPresentationManager_i::removePresentation(MEDPresentation::TypeID presentationID)
MEDCALC_EXPORT MEDPresentation::TypeID makeMeshView(const MEDCALC::MeshViewParameters&, const MEDCALC::ViewModeType);
MEDCALC_EXPORT MEDPresentation::TypeID makeScalarMap(const MEDCALC::ScalarMapParameters&, const MEDCALC::ViewModeType);
MEDCALC_EXPORT MEDPresentation::TypeID makeContour(const MEDCALC::ContourParameters&, const MEDCALC::ViewModeType);
-// MEDCALC_EXPORT MEDPresentation::TypeID makeVectorField(const MEDCALC::VectorFieldParameters&, const MEDCALC::ViewModeType);
+ MEDCALC_EXPORT MEDPresentation::TypeID makeVectorField(const MEDCALC::VectorFieldParameters&, const MEDCALC::ViewModeType);
MEDCALC_EXPORT MEDPresentation::TypeID makeSlices(const MEDCALC::SlicesParameters&, const MEDCALC::ViewModeType);
// MEDCALC_EXPORT MEDPresentation::TypeID makeDeflectionShape(const MEDCALC::DeflectionShapeParameters&, const MEDCALC::ViewModeType);
-// MEDCALC_EXPORT MEDPresentation::TypeID makePointSprite(const MEDCALC::PointSpriteParameters&, const MEDCALC::ViewModeType);
+ MEDCALC_EXPORT MEDPresentation::TypeID makePointSprite(const MEDCALC::PointSpriteParameters&, const MEDCALC::ViewModeType);
MEDCALC_EXPORT void setPresentationStringProperty(MEDPresentation::TypeID presentationID, const char* propName, const char* propValue);
MEDCALC_EXPORT char* getPresentationStringProperty(MEDPresentation::TypeID presentationID, const char* propName);
MEDCALC_EXPORT MEDCALC::ScalarMapParameters* getScalarMapParameters(MEDPresentation::TypeID presentationID);
MEDCALC_EXPORT MEDCALC::ContourParameters getContourParameters(MEDPresentation::TypeID presentationID);
MEDCALC_EXPORT MEDCALC::SlicesParameters* getSlicesParameters(MEDPresentation::TypeID presentationID);
+ MEDCALC_EXPORT MEDCALC::VectorFieldParameters* getVectorFieldParameters(MEDPresentation::TypeID presentationID);
+ MEDCALC_EXPORT MEDCALC::PointSpriteParameters* getPointSpriteParameters(MEDPresentation::TypeID presentationID);
MEDCALC_EXPORT void updateMeshView(MEDPresentation::TypeID, const MEDCALC::MeshViewParameters&);
MEDCALC_EXPORT void updateScalarMap(MEDPresentation::TypeID, const MEDCALC::ScalarMapParameters&);
MEDCALC_EXPORT void updateContour(MEDPresentation::TypeID, const MEDCALC::ContourParameters&);
-// MEDCALC_EXPORT void updateVectorField(MEDPresentation::TypeID, const MEDCALC::VectorFieldParameters&);
+ MEDCALC_EXPORT void updateVectorField(MEDPresentation::TypeID, const MEDCALC::VectorFieldParameters&);
MEDCALC_EXPORT void updateSlices(MEDPresentation::TypeID, const MEDCALC::SlicesParameters&);
// MEDCALC_EXPORT void updateDeflectionShape(MEDPresentation::TypeID, const MEDCALC::DeflectionShapeParameters&);
-// MEDCALC_EXPORT void updatePointSprite(MEDPresentation::TypeID, const MEDCALC::PointSpriteParameters&);
+ MEDCALC_EXPORT void updatePointSprite(MEDPresentation::TypeID, const MEDCALC::PointSpriteParameters&);
MEDCALC_EXPORT CORBA::Boolean removePresentation(MEDPresentation::TypeID);
MEDCALC_EXPORT CORBA::Boolean activateView(MEDPresentation::TypeID);
setIntProperty(MEDPresentationMeshView::PROP_MESH_MODE, params.mode);
}
-std::string
-MEDPresentationMeshView::getMeshViewCommand() const
+void
+MEDPresentationMeshView::representationType()
{
std::ostringstream oss1;
STDLOG(mes);
throw KERNEL::createSalomeException(mes);
}
-
- return oss1.str();
+ pushAndExecPyLine(oss1.str());
}
void
MEDPyLockWrapper lock;
- std::ostringstream oss;
- std::string view(getRenderViewVar());
+ createSource();
+ setOrCreateRenderView();
- oss << _srcObjVar << " = pvs.MEDReader(FileName='" << _fileName << "');";
- pushAndExecPyLine(oss.str()); oss.str("");
- pushAndExecPyLine( getRenderViewCommand() ); // instanciate __viewXXX
+ std::ostringstream oss;
oss << _objVar << " = " << _srcObjVar << ";";
pushAndExecPyLine(oss.str()); oss.str("");
- oss << _dispVar << " = pvs.Show(" << _objVar << ", " << view << ");";
- pushAndExecPyLine(oss.str()); oss.str("");
- pushAndExecPyLine(getMeshViewCommand());
- pushAndExecPyLine(getResetCameraCommand());
- pushAndExecPyLine("pvs.Render();");
+
+ showObject();
+ representationType();
+ resetCameraAndRender();
}
void
// Update the pipeline:
{
MEDPyLockWrapper lock;
- std::string cmd = getMeshViewCommand();
- pushAndExecPyLine(cmd);
+ representationType();
pushAndExecPyLine("pvs.Render();");
}
}
void updateMeshMode(const MEDCALC::MeshModeType mode);
virtual void internalGeneratePipeline();
- std::string getMeshViewCommand() const;
+ void representationType();
private:
MEDCALC::MeshViewParameters _params;
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+#include "MEDPyLockWrapper.hxx"
+
#include "MEDPresentationPointSprite.hxx"
+#include "MEDPresentationException.hxx"
+
+#include <SALOME_KernelServices.hxx>
+#undef LOG // should be fixed in KERNEL - double definition
+#include <Basics_Utils.hxx>
+
+#include <sstream>
+
+const std::string MEDPresentationPointSprite::TYPE_NAME = "MEDPresentationPointSprite";
+
+MEDPresentationPointSprite::MEDPresentationPointSprite(const MEDCALC::PointSpriteParameters& params,
+ const MEDCALC::ViewModeType viewMode) :
+ MEDPresentation(params.fieldHandlerId, TYPE_NAME, viewMode, params.colorMap, params.scalarBarRange), _params(params)
+{
+}
void
MEDPresentationPointSprite::internalGeneratePipeline()
{
-// PyGILState_STATE _gil_state = PyGILState_Ensure();
-//
-// std::string cmd = std::string("import pvsimple as pvs;");
-// cmd += getRenderViewCommand(_params.viewMode); // define __view1
-//
-// cmd += std::string("__obj1 = pvs.MEDReader(FileName='") + _fileName + std::string("');");
-// cmd += std::string("__disp1 = pvs.Show(__obj1, __view1);");
-// cmd += std::string("pvs.ColorBy(__disp1, ('") + _fieldType + std::string("', '") + _fieldName + std::string("'));");
-// cmd += std::string("__disp1.SetScalarBarVisibility(__view1, True);");
-// cmd += std::string("__disp1.RescaleTransferFunctionToDataRangeOverTime();");
-// cmd += std::string("__disp1.SetRepresentationType('Point Sprite');");
-// cmd += std::string("pvs.Render();");
-//
-// cmd += getResetCameraCommand();
-//
-// //std::cerr << "Python command:" << std::endl;
-// //std::cerr << cmd << std::endl;
-// PyRun_SimpleString(cmd.c_str());
-// // Retrieve Python object for internal storage:
-// PyObject* obj = getPythonObjectFromMain("__obj1");
-// PyObject* disp = getPythonObjectFromMain("__disp1");
-// pushInternal(obj, disp);
-//
-// PyGILState_Release(_gil_state);
+ MEDPresentation::internalGeneratePipeline();
+
+ MEDPyLockWrapper lock;
+
+ setOrCreateRenderView(); // instanciate __viewXXX
+ createSource();
+
+ // Populate internal array of available components:
+ fillAvailableFieldComponents();
+ int nbCompo = getIntProperty(MEDPresentation::PROP_NB_COMPONENTS);
+
+ // Point sprite needs point data:
+ applyCellToPointIfNeeded();
+
+ pushAndExecPyLine(_objVar + " = " + _srcObjVar);
+
+ 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 << "import medcalc; __avgSize=medcalc.ComputeCellAverageSize(" << _srcObjVar << ");";
+ pushAndExecPyLine(oss.str()); oss.str("");
+
+ colorBy("POINTS"); // like in Contour
+
+ // Set point sprite:
+ oss << _dispVar << ".SetRepresentationType('Point Sprite');";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ oss << _dispVar << ".PointSpriteDefaultsInitialized = 1;";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ oss << _dispVar << ".RadiusArray = ['POINTS', '" << _fieldName << "'];";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ oss << _dispVar << ".RadiusMode = 'Scalar';";
+ pushAndExecPyLine(oss.str()); oss.str("");
+
+ oss << _dispVar << ".RadiusVectorComponent = " << _selectedComponentIndex << ";";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ oss << _dispVar << ".RadiusIsProportional = 0 ;";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ oss << _dispVar << ".RadiusTransferFunctionEnabled = 1 ;";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ oss << _dispVar << ".MaxPixelSize = 30 ;"; // Avoid too big balls
+ pushAndExecPyLine(oss.str()); oss.str("");
+ oss << _dispVar << ".RadiusRange = [0.0, __avgSize];";
+ pushAndExecPyLine(oss.str()); oss.str("");
+
+ showScalarBar();
+ rescaleTransferFunction();
+ selectColorMap();
+ resetCameraAndRender();
}
void
MEDPresentationPointSprite::updatePipeline(const MEDCALC::PointSpriteParameters& params)
{
- // :TODO:
+ if (params.fieldHandlerId != _params.fieldHandlerId)
+ throw KERNEL::createSalomeException("Unexpected updatePipeline error! Mismatching fieldHandlerId!");
+
+ if (std::string(params.displayedComponent) != std::string(_params.displayedComponent))
+ updateComponent<MEDPresentationPointSprite, MEDCALC::PointSpriteParameters>(std::string(params.displayedComponent));
+ if (params.scalarBarRange != _params.scalarBarRange)
+ updateScalarBarRange<MEDPresentationPointSprite, MEDCALC::PointSpriteParameters>(params.scalarBarRange);
+ if (params.colorMap != _params.colorMap)
+ updateColorMap<MEDPresentationPointSprite, MEDCALC::PointSpriteParameters>(params.colorMap);
}
class MEDCALC_EXPORT MEDPresentationPointSprite : public MEDPresentation
{
public:
- MEDPresentationPointSprite(const MEDCALC::PointSpriteParameters& params) :
- MEDPresentation(params.fieldHandlerId, "MEDPresentationPointSprite"), _params(params)
- {}
+ static const std::string TYPE_NAME;
+
+ MEDPresentationPointSprite(const MEDCALC::PointSpriteParameters& params, const MEDCALC::ViewModeType viewMode);
virtual ~MEDPresentationPointSprite() {}
void updatePipeline(const MEDCALC::PointSpriteParameters& params);
- MEDCALC::ViewModeType getViewMode() { return _params.viewMode; }
+
+ void getParameters(MEDCALC::PointSpriteParameters & params) const { params = _params; } ;
+ void setParameters(const MEDCALC::PointSpriteParameters & params) { _params = params; } ;
protected:
virtual void internalGeneratePipeline();
MEDPyLockWrapper lock;
- std::ostringstream oss;
- std::string view(getRenderViewVar());
-
- pushAndExecPyLine( getRenderViewCommand() ); // instanciate __viewXXX
-
- oss << _srcObjVar << " = pvs.MEDReader(FileName='" << _fileName << "');";
- pushAndExecPyLine(oss.str()); oss.str("");
+ setOrCreateRenderView(); // instanciate __viewXXX
+ createSource();
// Populate internal array of available components:
fillAvailableFieldComponents();
-// dumpIntProperties();
-// dumpStringProperties();
+ // Nothing to do in a scalar map, obj = source:
pushAndExecPyLine(_objVar + " = " + _srcObjVar);
- oss << _dispVar << " = pvs.Show(" << _objVar << ", " << view << ");";
- pushAndExecPyLine(oss.str()); oss.str("");
- oss << "pvs.ColorBy(" << _dispVar << ", ('" << _fieldType << "', '" << _fieldName << "'));";
- pushAndExecPyLine(oss.str()); oss.str("");
- oss << _dispVar << ".SetScalarBarVisibility(" << view << ", True);";
- pushAndExecPyLine(oss.str()); oss.str("");
- oss << getRescaleCommand();
- pushAndExecPyLine(oss.str()); oss.str("");
- oss << _lutVar << " = pvs.GetColorTransferFunction('" << _fieldName << "');";
- pushAndExecPyLine(oss.str()); oss.str("");
- pushAndExecPyLine(getColorMapCommand()); oss.str("");
- pushAndExecPyLine(getResetCameraCommand());
- pushAndExecPyLine("pvs.Render();");
+ showObject();
+ colorBy(_fieldType);
+ showScalarBar();
+ rescaleTransferFunction();
+ selectColorMap();
+ resetCameraAndRender();
// Retrieve Python object for internal storage:
// PyObject* p_obj = getPythonObjectFromMain(obj.c_str());
setIntProperty(MEDPresentationSlices::PROP_SLICE_ORIENTATION, params.orientation);
}
-std::string
-MEDPresentationSlices::getNbSlicesCommand() const
+void
+MEDPresentationSlices::setNumberOfSlices()
{
std::ostringstream oss1;
// TODO
// oss1 << _objVar << ".SliceType.Normal = " << norm << ";";
- return oss1.str();
}
-std::string
-MEDPresentationSlices::getOrientationCommand() const
+void
+MEDPresentationSlices::selectSliceOrientation()
{
std::ostringstream oss1;
std::string norm;
}
oss1 << _objVar << ".SliceType.Normal = " << norm << ";";
- return oss1.str();
+ pushAndExecPyLine(oss1.str()); oss1.str("");
}
MEDPyLockWrapper lock;
std::ostringstream oss_o, oss;
- std::string view(getRenderViewVar());
- oss << _srcObjVar << " = pvs.MEDReader(FileName='" << _fileName << "');";
- pushAndExecPyLine(oss.str()); oss.str("");
+ createSource();
// Populate internal array of available components:
fillAvailableFieldComponents();
- pushAndExecPyLine( getRenderViewCommand() ); // instanciate __viewXXX
+ setOrCreateRenderView(); // instanciate __viewXXX
+
oss << _objVar << " = pvs.Slice(Input=" << _srcObjVar << ");";
pushAndExecPyLine(oss.str()); oss.str("");
+
+ showObject();
+
oss << _objVar << ".SliceType = 'Plane';";
pushAndExecPyLine(oss.str()); oss.str("");
// Set slice orientation
- pushAndExecPyLine(getOrientationCommand());
-
- oss << _dispVar << " = pvs.Show(" << _objVar << ", " << view << ");";
- pushAndExecPyLine(oss.str()); oss.str("");
- oss << "pvs.ColorBy(" << _dispVar << ", ('" << _fieldType << "', '" << _fieldName << "'));";
- pushAndExecPyLine(oss.str()); oss.str("");
- oss << _dispVar << ".SetScalarBarVisibility(" << view << ", True);";
- pushAndExecPyLine(oss.str()); oss.str("");
- oss << getRescaleCommand();
- pushAndExecPyLine(oss.str()); oss.str("");
- oss << _lutVar << " = pvs.GetColorTransferFunction('" << _fieldName << "');";
- pushAndExecPyLine(oss.str()); oss.str("");
- pushAndExecPyLine(getColorMapCommand()); oss.str("");
- pushAndExecPyLine(getResetCameraCommand());
- pushAndExecPyLine("pvs.Render();");
+ selectSliceOrientation();
+ colorBy(_fieldType);
+ showScalarBar();
+ rescaleTransferFunction();
+ selectColorMap();
+ resetCameraAndRender();
}
void
// Update the pipeline:
{
MEDPyLockWrapper lock;
- std::string cmd = getNbSlicesCommand();
- pushAndExecPyLine(cmd);
+ setNumberOfSlices();
pushAndExecPyLine("pvs.Render();");
}
}
// Update the pipeline:
{
MEDPyLockWrapper lock;
- std::string cmd = getOrientationCommand();
- pushAndExecPyLine(cmd);
+ selectSliceOrientation();
pushAndExecPyLine("pvs.Render();");
}
}
void updateOrientation(const MEDCALC::SliceOrientationType orientation);
virtual void internalGeneratePipeline();
- std::string getNbSlicesCommand() const;
- std::string getOrientationCommand() const;
+ void setNumberOfSlices();
+ void selectSliceOrientation();
private:
MEDCALC::SlicesParameters _params;
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+#include "MEDPyLockWrapper.hxx"
+
#include "MEDPresentationVectorField.hxx"
+#include "MEDPresentationException.hxx"
+
+#include <SALOME_KernelServices.hxx>
+#undef LOG // should be fixed in KERNEL - double definition
+#include <Basics_Utils.hxx>
+
+#include <sstream>
+
+const std::string MEDPresentationVectorField::TYPE_NAME = "MEDPresentationVectorField";
+
+MEDPresentationVectorField::MEDPresentationVectorField(const MEDCALC::VectorFieldParameters& params,
+ const MEDCALC::ViewModeType viewMode) :
+ MEDPresentation(params.fieldHandlerId, TYPE_NAME, viewMode, params.colorMap, params.scalarBarRange), _params(params)
+{
+}
void
MEDPresentationVectorField::internalGeneratePipeline()
{
-// PyGILState_STATE _gil_state = PyGILState_Ensure();
-//
-// std::string cmd = std::string("import pvsimple as pvs;");
-// cmd += getRenderViewCommand(_params.viewMode); // define __view1
-//
-// cmd += std::string("__obj1 = pvs.MEDReader(FileName='") + _fileName + std::string("');");
-// cmd += std::string("__disp1 = pvs.Show(__obj1, __view1);");
-// cmd += std::string("pvs.ColorBy(__disp1, ('") + _fieldType + std::string("', '") + _fieldName + std::string("'));");
-// cmd += std::string("__disp1.SetScalarBarVisibility(__view1, True);");
-// cmd += std::string("__disp1.RescaleTransferFunctionToDataRangeOverTime();");
-// cmd += std::string("__disp1.SetRepresentationType('3D Glyphs');");
-// cmd += std::string("pvs.Render();");
-//
-// cmd += getResetCameraCommand();
-//
-// //std::cerr << "Python command:" << std::endl;
-// //std::cerr << cmd << std::endl;
-// PyRun_SimpleString(cmd.c_str());
-// // Retrieve Python object for internal storage:
-// PyObject* obj = getPythonObjectFromMain("__obj1");
-// PyObject* disp = getPythonObjectFromMain("__disp1");
-// pushInternal(obj, disp);
-//
-// PyGILState_Release(_gil_state);
+ MEDPresentation::internalGeneratePipeline();
+
+ MEDPyLockWrapper lock;
+
+ setOrCreateRenderView();
+ createSource();
+
+ // Populate internal array of available components:
+ fillAvailableFieldComponents();
+ if (getIntProperty(MEDPresentation::PROP_NB_COMPONENTS) <= 1)
+ {
+ const char * msg = "Vector field presentation does not work for scalar field!"; // this message will appear in GUI too
+ STDLOG(msg);
+ throw KERNEL::createSalomeException(msg);
+ }
+
+ std::ostringstream oss;
+ oss << _objVar << " = pvs.Glyph(Input=" << _srcObjVar << ", GlyphType='Arrow');";
+ pushAndExecPyLine(oss.str()); oss.str("");
+
+ showObject(); // to be done first so that the scale factor computation properly works
+
+ oss << _objVar << ".Scalars = ['"<< _fieldType << "', 'None'];";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ oss << _objVar << ".Vectors = ['"<< _fieldType << "', '" << _fieldName << "'];";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ oss << _objVar << ".ScaleMode = 'vector';";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ oss << _objVar << ".GlyphMode = 'All Points';";
+ pushAndExecPyLine(oss.str()); oss.str("");
+// oss << _objVar << "GlyphTransform = 'Transform2';"; // not sure this is really needed?
+// pushAndExecPyLine(oss.str()); oss.str("");
+ oss << _objVar << ".ScaleFactor = 0.1;";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ // Auto-tuning of the scale factor:
+// oss << "import medcalc; medcalc.SetDefaultScaleFactor(active=" << _objVar << ");";
+// pushAndExecPyLine(oss.str()); oss.str("");
+
+ colorBy("POINTS");
+ showScalarBar();
+ rescaleTransferFunction();
+ selectColorMap();
+ resetCameraAndRender();
}
void
MEDPresentationVectorField::updatePipeline(const MEDCALC::VectorFieldParameters& params)
{
- // :TODO:
+ if (params.fieldHandlerId != _params.fieldHandlerId)
+ throw KERNEL::createSalomeException("Unexpected updatePipeline error! Mismatching fieldHandlerId!");
+
+ if (std::string(params.displayedComponent) != std::string(_params.displayedComponent))
+ updateComponent<MEDPresentationVectorField, MEDCALC::VectorFieldParameters>(std::string(params.displayedComponent));
+ if (params.scalarBarRange != _params.scalarBarRange)
+ updateScalarBarRange<MEDPresentationVectorField, MEDCALC::VectorFieldParameters>(params.scalarBarRange);
+ if (params.colorMap != _params.colorMap)
+ updateColorMap<MEDPresentationVectorField, MEDCALC::VectorFieldParameters>(params.colorMap);
}
class MEDCALC_EXPORT MEDPresentationVectorField : public MEDPresentation
{
public:
- MEDPresentationVectorField(const MEDCALC::VectorFieldParameters& params) :
- MEDPresentation(params.fieldHandlerId, "MEDPresentationVectorField"), _params(params)
- {}
+ static const std::string TYPE_NAME;
+
+ MEDPresentationVectorField(const MEDCALC::VectorFieldParameters& params, const MEDCALC::ViewModeType viewMode);
virtual ~MEDPresentationVectorField() {}
void updatePipeline(const MEDCALC::VectorFieldParameters& params);
- MEDCALC::ViewModeType getViewMode() { return _params.viewMode; }
+
+ void getParameters(MEDCALC::VectorFieldParameters & params) const { params = _params; } ;
+ void setParameters(const MEDCALC::VectorFieldParameters & params) { _params = params; } ;
protected:
virtual void internalGeneratePipeline();
private:
MEDCALC::VectorFieldParameters _params;
+
};
#endif
XmedDataModel.cxx
MEDWidgetHelper.cxx
MEDWidgetHelperMeshView.cxx
- MEDWidgetHelperScalarMap.cxx
+ MEDWidgetHelperComponent.cxx
MEDWidgetHelperContour.cxx
MEDWidgetHelperSlices.cxx
)
ProcessingController.hxx
MEDWidgetHelper.hxx
MEDWidgetHelperMeshView.hxx
+ MEDWidgetHelperComponent.hxx
MEDWidgetHelperScalarMap.hxx
MEDWidgetHelperContour.hxx
MEDWidgetHelperSlices.hxx
+ MEDWidgetHelperPointSprite.hxx
+ MEDWidgetHelperVectorField.hxx
)
IF(SALOME_MED_WITH_QTTESTING)
--- /dev/null
+// Copyright (C) 2016 CEA/DEN, EDF R&D
+//
+// 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, or (at your option) any later version.
+//
+// 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
+//
+
+#include "MEDWidgetHelperComponent.hxx"
+#include "PresentationController.hxx"
+
+MEDWidgetHelperComponent::MEDWidgetHelperComponent(const PresentationController * presController, MEDCALC::MEDPresentationManager_ptr presManager, int presId,
+ const std::string & presName, WidgetPresentationParameters * paramW):
+ MEDWidgetHelper(presController, presManager, presId, presName, paramW)
+{}
+
+MEDWidgetHelperComponent::~MEDWidgetHelperComponent()
+{}
+
+void MEDWidgetHelperComponent::udpateWidget()
+{
+ MEDWidgetHelper::udpateWidget();
+
+ _paramWidget->setComponents(_allCompos, _selectedCompo);
+
+ // Connect combo box changes
+ QObject::connect( this, SIGNAL(presentationUpdateSignal(const PresentationEvent *)),
+ _presController, SIGNAL(presentationSignal(const PresentationEvent *)) );
+ QObject::connect( _paramWidget, SIGNAL(comboCompoIndexChanged(int)), this, SLOT(onComponentChanged(int)) );
+}
+
+void MEDWidgetHelperComponent::releaseWidget()
+{
+ MEDWidgetHelper::releaseWidget();
+
+ QObject::disconnect( this, SIGNAL(presentationUpdateSignal(const PresentationEvent *)),
+ _presController, SIGNAL(presentationSignal(const PresentationEvent *)) );
+ QObject::disconnect( _paramWidget, SIGNAL(comboCompoIndexChanged(int)), this, SLOT(onComponentChanged(int)) );
+}
--- /dev/null
+// Copyright (C) 2016 CEA/DEN, EDF R&D
+//
+// 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, or (at your option) any later version.
+//
+// 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
+//
+
+#ifndef SRC_MEDCALC_GUI_MEDWIDGETHELPERCOMPONENT_HXX_
+#define SRC_MEDCALC_GUI_MEDWIDGETHELPERCOMPONENT_HXX_
+
+#include "MEDWidgetHelper.hxx"
+
+class PresentationController;
+
+/**
+ * Abstract class to manage all presentations having only the component name to change.
+ */
+class MEDWidgetHelperComponent: public MEDWidgetHelper
+{
+ Q_OBJECT
+
+public:
+ MEDWidgetHelperComponent(const PresentationController* presController,
+ MEDCALC::MEDPresentationManager_ptr presManager, int presId, const std::string & presName,
+ WidgetPresentationParameters * paramW);
+ virtual ~MEDWidgetHelperComponent();
+
+ virtual void udpateWidget();
+ virtual void releaseWidget();
+
+ virtual std::string getPythonTag() const = 0;
+};
+
+#endif /* SRC_MEDCALC_GUI_MEDWIDGETHELPERCOMPONENT_HXX_ */
--- /dev/null
+// Copyright (C) 2016 CEA/DEN, EDF R&D
+//
+// 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, or (at your option) any later version.
+//
+// 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
+//
+
+#ifndef SRC_MEDCALC_GUI_MEDWIDGETHELPERPOINTSPRITE_HXX_
+#define SRC_MEDCALC_GUI_MEDWIDGETHELPERPOINTSPRITE_HXX_
+
+#include "MEDWidgetHelperComponent.hxx"
+
+class PresentationController;
+
+class MEDWidgetHelperPointSprite: public MEDWidgetHelperComponent
+{
+ Q_OBJECT
+
+public:
+ MEDWidgetHelperPointSprite(const PresentationController* presController,
+ MEDCALC::MEDPresentationManager_ptr presManager, int presId, const std::string & presName,
+ WidgetPresentationParameters * paramW):
+ MEDWidgetHelperComponent(presController, presManager, presId, presName, paramW)
+ {}
+
+ virtual ~MEDWidgetHelperPointSprite() {}
+
+ virtual std::string getPythonTag() const { return "PointSprite"; }
+};
+
+#endif /* SRC_MEDCALC_GUI_MEDWIDGETHELPERPOINTSPRITE_HXX_ */
+++ /dev/null
-// Copyright (C) 2016 CEA/DEN, EDF R&D
-//
-// 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, or (at your option) any later version.
-//
-// 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
-//
-
-#include "MEDWidgetHelperScalarMap.hxx"
-#include "MEDPresentationScalarMap.hxx" // from component side.
-#include "PresentationController.hxx"
-
-#include <sstream>
-
-MEDWidgetHelperScalarMap::MEDWidgetHelperScalarMap(const PresentationController * presController, MEDCALC::MEDPresentationManager_ptr presManager, int presId,
- const std::string & presName, WidgetPresentationParameters * paramW):
- MEDWidgetHelper(presController, presManager, presId, presName, paramW)
-{
-}
-
-MEDWidgetHelperScalarMap::~MEDWidgetHelperScalarMap()
-{}
-
-void MEDWidgetHelperScalarMap::udpateWidget()
-{
- MEDWidgetHelper::udpateWidget();
-
- // Scalar map presentation needs the component name, that's all.
- _paramWidget->setComponents(_allCompos, _selectedCompo);
-
- // Connect combo box changes
- QObject::connect( this, SIGNAL(presentationUpdateSignal(const PresentationEvent *)),
- _presController, SIGNAL(presentationSignal(const PresentationEvent *)) );
- QObject::connect( _paramWidget, SIGNAL(comboCompoIndexChanged(int)), this, SLOT(onComponentChanged(int)) );
-}
-
-void MEDWidgetHelperScalarMap::releaseWidget()
-{
- MEDWidgetHelper::releaseWidget();
-
- QObject::disconnect( this, SIGNAL(presentationUpdateSignal(const PresentationEvent *)),
- _presController, SIGNAL(presentationSignal(const PresentationEvent *)) );
- QObject::disconnect( _paramWidget, SIGNAL(comboCompoIndexChanged(int)), this, SLOT(onComponentChanged(int)) );
-}
#ifndef SRC_MEDCALC_GUI_MEDWIDGETHELPERSCALARMAP_HXX_
#define SRC_MEDCALC_GUI_MEDWIDGETHELPERSCALARMAP_HXX_
-#include "MEDWidgetHelper.hxx"
+#include "MEDWidgetHelperComponent.hxx"
class PresentationController;
-class MEDWidgetHelperScalarMap: public MEDWidgetHelper
+class MEDWidgetHelperScalarMap: public MEDWidgetHelperComponent
{
Q_OBJECT
public:
MEDWidgetHelperScalarMap(const PresentationController* presController,
MEDCALC::MEDPresentationManager_ptr presManager, int presId, const std::string & presName,
- WidgetPresentationParameters * paramW);
- virtual ~MEDWidgetHelperScalarMap();
+ WidgetPresentationParameters * paramW):
+ MEDWidgetHelperComponent(presController, presManager, presId, presName, paramW)
+ {}
- virtual void udpateWidget();
- virtual void releaseWidget();
+ virtual ~MEDWidgetHelperScalarMap() {}
virtual std::string getPythonTag() const { return "ScalarMap"; }
};
--- /dev/null
+// Copyright (C) 2016 CEA/DEN, EDF R&D
+//
+// 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, or (at your option) any later version.
+//
+// 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
+//
+
+#ifndef SRC_MEDCALC_GUI_MEDWIDGETHELPERVECTORFIELD_HXX_
+#define SRC_MEDCALC_GUI_MEDWIDGETHELPERVECTORFIELD_HXX_
+
+#include "MEDWidgetHelperComponent.hxx"
+
+class PresentationController;
+
+class MEDWidgetHelperVectorField: public MEDWidgetHelperComponent
+{
+ Q_OBJECT
+
+public:
+ MEDWidgetHelperVectorField(const PresentationController* presController,
+ MEDCALC::MEDPresentationManager_ptr presManager, int presId, const std::string & presName,
+ WidgetPresentationParameters * paramW):
+ MEDWidgetHelperComponent(presController, presManager, presId, presName, paramW)
+ {}
+
+ virtual ~MEDWidgetHelperVectorField() {}
+
+ virtual std::string getPythonTag() const { return "VectorField"; }
+};
+
+#endif /* SRC_MEDCALC_GUI_MEDWIDGETHELPERVECTORFIELD_HXX_ */
#include "MEDPresentationScalarMap.hxx"
#include "MEDPresentationContour.hxx"
#include "MEDPresentationSlices.hxx"
+#include "MEDPresentationPointSprite.hxx"
+#include "MEDPresentationVectorField.hxx"
+//#include "MEDPresentationDeflectionShape.hxx"
#include "MEDWidgetHelperMeshView.hxx"
#include "MEDWidgetHelperScalarMap.hxx"
#include "MEDWidgetHelperContour.hxx"
#include "MEDWidgetHelperSlices.hxx"
+#include "MEDWidgetHelperPointSprite.hxx"
+#include "MEDWidgetHelperVectorField.hxx"
+//#include "MEDWidgetHelperDeflectionShape.hxx"
#include <SalomeApp_Application.h>
#include <SalomeApp_Study.h>
}
else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_CONTOUR ) {
commands += QString("presentation_id = medcalc.MakeContour(accessField(%1), viewMode=%2, scalarBarRange=%3, colorMap=%4)")
- .arg(fieldHandler->id).arg(viewMode).arg(scalarBarRange).arg(colorMap);
+ .arg(fieldHandler->id).arg(viewMode).arg(scalarBarRange).arg(colorMap);
commands += QString("presentation_id");
}
- // else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_VECTOR_FIELD ) {
- // commands += QString("presentation_id = medcalc.MakeVectorField(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
- // commands += QString("presentation_id");
- // }
- else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_SLICES ) {
+ else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_SLICES ) {
commands += QString("presentation_id = medcalc.MakeSlices(accessField(%1), viewMode=%2, scalarBarRange=%3, colorMap=%4)")
- .arg(fieldHandler->id).arg(viewMode).arg(scalarBarRange).arg(colorMap);
+ .arg(fieldHandler->id).arg(viewMode).arg(scalarBarRange).arg(colorMap);
commands += QString("presentation_id");
- }
+ }
+ else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_VECTOR_FIELD ) {
+ commands += QString("presentation_id = medcalc.MakeVectorField(accessField(%1), viewMode=%2, scalarBarRange=%3, colorMap=%4)")
+ .arg(fieldHandler->id).arg(viewMode).arg(scalarBarRange).arg(colorMap);
+ commands += QString("presentation_id");
+ }
+ else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_POINT_SPRITE ) {
+ commands += QString("presentation_id = medcalc.MakePointSprite(accessField(%1), viewMode=%2, scalarBarRange=%3, colorMap=%4)")
+ .arg(fieldHandler->id).arg(viewMode).arg(scalarBarRange).arg(colorMap);
+ commands += QString("presentation_id");
+ }
+
// else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_DEFLECTION_SHAPE ) {
// commands += QString("presentation_id = medcalc.MakeDeflectionShape(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
// commands += QString("presentation_id");
- // }
- // else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_POINT_SPRITE ) {
- // commands += QString("presentation_id = medcalc.MakePointSprite(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
- // commands += QString("presentation_id");
- // }
// [ABN] using event mechanism for this is awkward? TODO: direct implementation in each
// dedicated widget helper class?
std::map<int, MEDWidgetHelper *>::const_iterator it =_presHelperMap.find(presId);
if (it != _presHelperMap.end())
return (*it).second;
- MEDWidgetHelper * wh;
+ MEDWidgetHelper * wh = 0;
if (type == MEDPresentationMeshView::TYPE_NAME)
wh = new MEDWidgetHelperMeshView(this, _presManager, presId, name, _widgetPresentationParameters);
else if (type == MEDPresentationScalarMap::TYPE_NAME)
else if (type == MEDPresentationContour::TYPE_NAME)
wh = new MEDWidgetHelperContour(this, _presManager, presId, name, _widgetPresentationParameters);
else if (type == MEDPresentationSlices::TYPE_NAME)
- wh = new MEDWidgetHelperSlices(this, _presManager, presId, name, _widgetPresentationParameters);
+ wh = new MEDWidgetHelperSlices(this, _presManager, presId, name, _widgetPresentationParameters);
+ else if (type == MEDPresentationVectorField::TYPE_NAME)
+ wh = new MEDWidgetHelperVectorField(this, _presManager, presId, name, _widgetPresentationParameters);
+ else if (type == MEDPresentationPointSprite::TYPE_NAME)
+ wh = new MEDWidgetHelperPointSprite(this, _presManager, presId, name, _widgetPresentationParameters);
else
{
- STDLOG("findOrCreateWidgetHelper(): NOT IMPLEMENTED !!!");
+ const char * msg ="findOrCreateWidgetHelper(): NOT IMPLEMENTED !!!";
+ STDLOG(msg);
}
_presHelperMap[presId] = wh;
return wh;
EVENT_VIEW_OBJECT_SCALAR_MAP,
EVENT_VIEW_OBJECT_SLICES,
EVENT_VIEW_OBJECT_VECTOR_FIELD,
+
EVENT_DELETE_PRESENTATION,
EVENT_CHANGE_COMPONENT,
EVENT_CHANGE_TIME_RANGE,
EVENT_CHANGE_MESH_MODE,
+
EVENT_CHANGE_NB_CONTOUR,
+
EVENT_CHANGE_SLICE_ORIENTATION,
EVENT_CHANGE_NB_SLICES
};
--- /dev/null
+# Copyright (C) 2016 CEA/DEN, EDF R&D
+#
+# 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, or (at your option) any later version.
+#
+# 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
+#
+
+import os
+from time import sleep
+
+import medcalc
+medcalc.medconsole.setConsoleGlobals(globals())
+import MEDCALC
+from medcalc.medconsole import accessField
+
+from medcalc_testutils import GetMEDFileDirTUI
+
+if 1:
+ datafile = os.path.join(GetMEDFileDirTUI(), "smooth_surface_and_field.med")
+ source_id = medcalc.LoadDataSource(datafile)
+ presentation_id = medcalc.MakePointSprite(accessField(0), MEDCALC.VIEW_MODE_REPLACE, colorMap=MEDCALC.COLOR_MAP_BLUE_TO_RED_RAINBOW)
+else:
+ datafile = os.path.join(GetMEDFileDirTUI(), "agitateur.med")
+ source_id = medcalc.LoadDataSource(datafile)
+ presentation_id = medcalc.MakePointSprite(accessField(55), MEDCALC.VIEW_MODE_REPLACE, colorMap=MEDCALC.COLOR_MAP_BLUE_TO_RED_RAINBOW)
+
+sleep(1)
+medcalc.RemovePresentation(presentation_id)
datafile = os.path.join(GetMEDFileDirTUI(), "agitateur.med")
source_id = medcalc.LoadDataSource(datafile)
-presentation_id = medcalc.MakeSlices(accessField(0), MEDCALC.VIEW_MODE_REPLACE, colorMap=MEDCALC.COLOR_MAP_BLUE_TO_RED_RAINBOW)
+presentation_id = medcalc.MakeSlices(accessField(0), MEDCALC.VIEW_MODE_REPLACE,
+ colorMap=MEDCALC.COLOR_MAP_BLUE_TO_RED_RAINBOW,
+ sliceOrientation=MEDCALC.SLICE_NORMAL_TO_Z) # normal to Z to see something!
sleep(1)
medcalc.RemovePresentation(presentation_id)
sleep(1)
# contour
# slices
# mesh_view
+# point_sprite
+# vector_field
+# deflection_shape
)
--- /dev/null
+# Copyright (C) 2016 CEA/DEN, EDF R&D
+#
+# 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, or (at your option) any later version.
+#
+# 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
+#
+
+import os
+from time import sleep
+
+import medcalc
+medcalc.medconsole.setConsoleGlobals(globals())
+import MEDCALC
+from medcalc.medconsole import accessField
+
+from medcalc_testutils import GetMEDFileDirTUI
+
+datafile = os.path.join(GetMEDFileDirTUI(), "agitateur.med")
+source_id = medcalc.LoadDataSource(datafile)
+
+# Field 55 = VITESSE_ELEM_DOM (ON_CELLS)
+presentation_id = medcalc.MakeVectorField(accessField(57), viewMode=MEDCALC.VIEW_MODE_REPLACE,
+ colorMap=MEDCALC.COLOR_MAP_BLUE_TO_RED_RAINBOW,
+ scalarBarRange=MEDCALC.SCALAR_BAR_CURRENT_TIMESTEP
+ )
+sleep(1)
+medcalc.RemovePresentation(presentation_id)
+sleep(1)
from medpresentation import MakeMeshView
from medpresentation import MakeScalarMap
from medpresentation import MakeContour
-#from medpresentation import MakeVectorField
+from medpresentation import MakeVectorField
from medpresentation import MakeSlices
-#from medpresentation import MakeDeflectionShape
-#from medpresentation import MakePointSprite
+from medpresentation import MakePointSprite
from medpresentation import RemovePresentation
+#from medpresentation import MakeDeflectionShape
from medpresentation import GetMeshViewParameters
from medpresentation import GetScalarMapParameters
from medpresentation import GetContourParameters
from medpresentation import GetSlicesParameters
+from medpresentation import GetPointSpriteParameters
+from medpresentation import GetVectorFieldParameters
+#from medpresentation import GetDeflectionShapeParameters
from medpresentation import UpdateMeshView
from medpresentation import UpdateScalarMap
from medpresentation import UpdateContour
from medpresentation import UpdateSlices
+from medpresentation import UpdateVectorField
+from medpresentation import UpdatePointSprite
+#from medpresentation import UpdateDeflectionShape
+
+from medpresentation import SetDefaultScaleFactor, ComputeCellAverageSize, GetDomainCenter
# Console commands
import medconsole
notifyGui_error("An error occured while creating the contour:\n" + e.details.text)
raise Exception(e.details.text)
-##
-#
-#def MakeVectorField(proxy,
-# viewMode=MEDCALC.VIEW_MODE_DEFAULT
-# ):
-# params = MEDCALC.VectorFieldParameters(proxy.id, viewMode)
-# presentation_id = __manager.makeVectorField(params)
-# notifyGui_addPresentation(proxy.id, presentation_id)
-# return presentation_id
-##
#
+
+def MakeVectorField(proxy,
+ viewMode=MEDCALC.VIEW_MODE_DEFAULT,
+ displayedComponent=MEDCALC.DISPLAY_DEFAULT,
+ scalarBarRange=MEDCALC.SCALAR_BAR_RANGE_DEFAULT,
+ colorMap=MEDCALC.COLOR_MAP_DEFAULT
+ ):
+ # Create the presentation instance in CORBA engine
+ # The engine in turn creates the ParaView pipeline elements
+ params = MEDCALC.VectorFieldParameters(proxy.id, displayedComponent, scalarBarRange, colorMap)
+ try:
+ presentation_id = __manager.makeVectorField(params, viewMode)
+ notifyGui_addPresentation(proxy.id, presentation_id)
+ return presentation_id
+ except SALOME.SALOME_Exception as e:
+ notifyGui_error("An error occured while creating the vector field:\n" + e.details.text)
+ raise Exception(e.details.text)
+
def MakeSlices(proxy,
viewMode=MEDCALC.VIEW_MODE_DEFAULT,
displayedComponent=MEDCALC.DISPLAY_DEFAULT,
# return presentation_id
##
#
-#def MakePointSprite(proxy,
-# viewMode=MEDCALC.VIEW_MODE_DEFAULT,
-# displayedComponent=MEDCALC.DISPLAY_DEFAULT,
-# scalarBarRange=MEDCALC.SCALAR_BAR_RANGE_DEFAULT,
-# colorMap=MEDCALC.COLOR_MAP_DEFAULT,
-# ):
-# params = MEDCALC.PointSpriteParameters(proxy.id, viewMode, displayedComponent, scalarBarRange, colorMap)
-# presentation_id = __manager.makePointSprite(params)
-# notifyGui_addPresentation(proxy.id, presentation_id)
-# return presentation_id
-#
+def MakePointSprite(proxy,
+ viewMode=MEDCALC.VIEW_MODE_DEFAULT,
+ displayedComponent=MEDCALC.DISPLAY_DEFAULT,
+ scalarBarRange=MEDCALC.SCALAR_BAR_RANGE_DEFAULT,
+ colorMap=MEDCALC.COLOR_MAP_DEFAULT
+ ):
+ # Create the presentation instance in CORBA engine
+ # The engine in turn creates the ParaView pipeline elements
+ params = MEDCALC.PointSpriteParameters(proxy.id, displayedComponent, scalarBarRange, colorMap)
+ try:
+ presentation_id = __manager.makePointSprite(params, viewMode)
+ notifyGui_addPresentation(proxy.id, presentation_id)
+ return presentation_id
+ except SALOME.SALOME_Exception as e:
+ notifyGui_error("An error occured while creating the point sprite:\n" + e.details.text)
+ raise Exception(e.details.text)
def RemovePresentation(presentation_id):
ok = __manager.removePresentation(presentation_id)
notifyGui_removePresentation(presentation_id)
#
-def GetGENERICParameters(tag, presentation_id):
+def __GetGENERICParameters(tag, presentation_id):
exec "params = __manager.get%sParameters(presentation_id)" % tag
return params
-GetMeshViewParameters = lambda pres_id: GetGENERICParameters("MeshView", pres_id)
-GetScalarMapParameters = lambda pres_id: GetGENERICParameters("ScalarMap", pres_id)
-GetContourParameters = lambda pres_id: GetGENERICParameters("Contour", pres_id)
-GetSlicesParameters = lambda pres_id: GetGENERICParameters("Slices", pres_id)
+GetMeshViewParameters = lambda pres_id: __GetGENERICParameters("MeshView", pres_id)
+GetScalarMapParameters = lambda pres_id: __GetGENERICParameters("ScalarMap", pres_id)
+GetContourParameters = lambda pres_id: __GetGENERICParameters("Contour", pres_id)
+GetSlicesParameters = lambda pres_id: __GetGENERICParameters("Slices", pres_id)
+GetPointSpriteParameters = lambda pres_id: __GetGENERICParameters("PointSprite", pres_id)
+GetVectorFieldParameters = lambda pres_id: __GetGENERICParameters("VectorField", pres_id)
+#GetDeflectionShapeParameters = lambda pres_id: __GetGENERICParameters("DeflectionShape", pres_id)
-def UpdateGENERIC(tag, presentation_id, params):
+def __UpdateGENERIC(tag, presentation_id, params):
exec "__manager.update%s(presentation_id, params)" % tag
-UpdateMeshView = lambda pres_id, params: UpdateGENERIC("MeshView", pres_id, params)
-UpdateScalarMap = lambda pres_id, params: UpdateGENERIC("ScalarMap", pres_id, params)
-UpdateContour = lambda pres_id, params: UpdateGENERIC("Contour", pres_id, params)
-UpdateSlices = lambda pres_id, params: UpdateGENERIC("Slices", pres_id, params)
+UpdateMeshView = lambda pres_id, params: __UpdateGENERIC("MeshView", pres_id, params)
+UpdateScalarMap = lambda pres_id, params: __UpdateGENERIC("ScalarMap", pres_id, params)
+UpdateContour = lambda pres_id, params: __UpdateGENERIC("Contour", pres_id, params)
+UpdateSlices = lambda pres_id, params: __UpdateGENERIC("Slices", pres_id, params)
+UpdateVectorField = lambda pres_id, params: __UpdateGENERIC("VectorField", pres_id, params)
+UpdatePointSprite = lambda pres_id, params: __UpdateGENERIC("PointSprite", pres_id, params)
+#UpdateDeflectionShape = lambda pres_id, params: __UpdateGENERIC("DeflectionShape", pres_id, params)
+
+def ComputeCellAverageSize(obj):
+ """
+ @return the average cell size
+ """
+ bb, nCells = obj.GetDataInformation().GetBounds(), obj.GetDataInformation().GetNumberOfCells()
+ bb = zip(bb[::2], bb[1::2])
+ deltas = [x[1]-x[0] for x in bb]
+ vol = reduce(lambda x,y:x*y, deltas, 1.0)
+ cellSize = (vol/nCells)**(1.0/3.0) # necessarily 3D in ParaView
+ return cellSize
+
+def GetDomainCenter(obj):
+ """
+ @return the center of the domain as the central point of the bounding box
+ """
+ bb = obj.GetDataInformation().GetBounds()
+ bb = zip(bb[::2], bb[1::2])
+ mids = [x[0] + 0.5*(x[1]-x[0]) for x in bb]
+ return mids
+
+# Taken from paraview.simple from CEA ParaView's version:
+def SetDefaultScaleFactor(active=None):
+ """Provides a good display to the bounding box of the mesh and min / max of the field.
+ This method available for filters: Warp By Vector, Glyph and Tensor Glyph"""
+ if not active:
+ active = GetActiveSource()
+ if not active:
+ return
+ name = active.__class__.__name__
+ if (name == 'WarpByVector' or name == 'TensorGlyph') and hasattr(active, 'ScaleFactor'):
+ import math
+ datainfo = active.GetProperty("Input").SMProperty.GetProxy(0).GetDataInformation()
+ if not datainfo:
+ active.ScaleFactor = 1.0
+ return
+ nbcells = datainfo.GetNumberOfCells()
+ nbpoints = datainfo.GetNumberOfPoints()
+ nbelem = nbcells
+ if nbelem == 0:
+ nbelem = nbpoints
+ abounds = datainfo.GetBounds()
+ volume = 1
+ vol = 0
+ idim = 0
+ i = 0
+ eps = 1.0e-38
+ while i < 6 :
+ vol = math.fabs( abounds[i+1] - abounds[i] )
+ if vol > 0:
+ idim += 1
+ volume *= vol
+ i += 2
+ if nbelem == 0 or math.fabs(idim) < eps:
+ active.ScaleFactor = 0.0
+ return
+ volume /= nbelem
+ scalefactor = pow( volume, 1.0 / idim )
+ maximum = 1.0
+ property = active.GetProperty('ScaleFactor')
+ domain = None
+ if property.GetDomain('vector_range').__class__.__name__ == 'vtkSMArrayRangeDomain':
+ domain = property.GetDomain('vector_range')
+ if property.GetDomain('tensor_range').__class__.__name__ == 'vtkSMArrayRangeDomain':
+ domain = property.GetDomain('tensor_range')
+ if not domain is None:
+ if domain.GetMaximumExists(3):
+ maximum = domain.GetMaximum(3)
+ if math.fabs(maximum) > eps:
+ scalefactor /= maximum
+ active.ScaleFactor = scalefactor
+ return
+ if name == 'Glyph' and hasattr(active, 'ScaleFactor') and hasattr(active, 'UseCellsCenter') and hasattr(active, 'ScaleMode'):
+ import math
+ scaledextent = 1.0
+ property = active.GetProperty('ScaleFactor')
+ bounds_domain = property.GetDomain('bounds')
+ if bounds_domain.__class__.__name__ == 'vtkSMBoundsDomain':
+ if bounds_domain.GetMaximumExists(0):
+ scaledextent = bounds_domain.GetMaximum(0)
+ usecellscenter = active.GetProperty('UseCellsCenter').GetData()
+ sdomain = "cells_"
+ if usecellscenter == 0:
+ sdomain = "points_"
+ divisor = 1.0
+ scalemode_domain = active.GetProperty('ScaleMode')
+ scalemode = scalemode_domain.ConvertValue(scalemode_domain.GetData())
+ if scalemode == 0:
+ sdomain += "scalar_range"
+ domain = property.GetDomain(sdomain)
+ if domain.__class__.__name__ == 'vtkSMArrayRangeDomain':
+ if domain.GetMaximumExists(0):
+ divisor = domain.GetMaximum(0)
+ if scalemode == 1 or scalemode == 2:
+ sdomain += "vector_range"
+ domain = property.GetDomain(sdomain)
+ if domain.__class__.__name__ == 'vtkSMArrayRangeDomain':
+ if domain.GetMaximumExists(3):
+ divisor = domain.GetMaximum(3)
+ divisor = math.fabs(divisor)
+ if divisor < 0.000000001:
+ divisor = 1
+ scalefactor = scaledextent / divisor
+ active.ScaleFactor = scalefactor
+ return