EVENT_MODIFY_PRESENTATION,
EVENT_CHANGE_UNDERLYING_MESH,
EVENT_INTERPOLATE_FIELD,
+ EVENT_VISIBILITY_CHANGED,
EVENT_PLAY_TEST,
EVENT_QUIT_SALOME,
EVENT_ERROR,
enum ScalarBarRangeType {
SCALAR_BAR_ALL_TIMESTEPS,
- SCALAR_BAR_CURRENT_TIMESTEP
+ SCALAR_BAR_CURRENT_TIMESTEP,
+ SCALAR_BAR_CUSTOM_RANGE
};
enum MeshModeType {
MESH_MODE_SURFACE_EDGES,
MESH_MODE_SURFACE
};
-
+
+ enum PresentationVisibility {
+ PRESENTATION_INVISIBLE,
+ PRESENTATION_VISIBLE,
+ PRESENTATION_NOT_IN_VIEW
+ };
+
+ enum IntegrationDirType {
+ INTEGRATION_DIR_BOTH,
+ INTEGRATION_DIR_FORWARD,
+ INTEGRATION_DIR_BACKWARD
+ };
+
+ typedef sequence<double> DoubleArray;
// struct ScalarBarRange {
// const long SCALAR_BAR_RANGE_VAL_MAX_DEFAULT = -1;
const string DISPLAY_DEFAULT = DISPLAY_EUCLIDEAN_NORM;
const SliceOrientationType SLICE_ORIENTATION_DEFAULT = SLICE_NORMAL_TO_X;
+ const IntegrationDirType INTEGRATION_DIR_DEFAULT = INTEGRATION_DIR_BOTH;
const long NB_CONTOURS_DEFAULT = 10;
const long NB_SLICES_DEFAULT = 1;
struct MeshViewParameters {
long meshHandlerId;
MeshModeType mode;
+ boolean visibility;
};
// A simple scalar map
string displayedComponent; // DISPLAY_EUCLIDEAN_NORM or any component name
ScalarBarRangeType scalarBarRange;
ColorMapType colorMap;
+ boolean visibility;
+ boolean scalarBarVisibility;
+ DoubleArray scalarBarRangeArray;
+ boolean hideDataOutsideCustomRange;
};
// A contour is an isoline in 2D and an isosurface in 3D
long fieldHandlerId;
ScalarBarRangeType scalarBarRange;
ColorMapType colorMap;
+ boolean visibility;
+ boolean scalarBarVisibility;
+ DoubleArray scalarBarRangeArray;
+ boolean hideDataOutsideCustomRange;
long nbContours;
+ string contourComponent;
};
struct VectorFieldParameters {
long fieldHandlerId;
ScalarBarRangeType scalarBarRange;
ColorMapType colorMap;
+ boolean visibility;
+ boolean scalarBarVisibility;
+ DoubleArray scalarBarRangeArray;
+ boolean hideDataOutsideCustomRange;
+ double scaleFactor;
+ boolean customScaleFactor;
};
struct SlicesParameters {
string displayedComponent; // DISPLAY_EUCLIDEAN_NORM or any component name
ScalarBarRangeType scalarBarRange;
ColorMapType colorMap;
+ boolean visibility;
+ boolean scalarBarVisibility;
+ DoubleArray scalarBarRangeArray;
+ boolean hideDataOutsideCustomRange;
SliceOrientationType orientation;
long nbSlices;
};
+
struct DeflectionShapeParameters {
long fieldHandlerId;
ScalarBarRangeType scalarBarRange;
ColorMapType colorMap;
+ boolean visibility;
+ boolean scalarBarVisibility;
+ DoubleArray scalarBarRangeArray;
+ boolean hideDataOutsideCustomRange;
};
struct PointSpriteParameters {
string displayedComponent; // DISPLAY_EUCLIDEAN_NORM or any component name
ScalarBarRangeType scalarBarRange;
ColorMapType colorMap;
+ boolean visibility;
+ boolean scalarBarVisibility;
+ DoubleArray scalarBarRangeArray;
+ boolean hideDataOutsideCustomRange;
+ };
+
+ struct Plot3DParameters {
+ long fieldHandlerId;
+ ScalarBarRangeType scalarBarRange;
+ ColorMapType colorMap;
+ boolean visibility;
+ boolean scalarBarVisibility;
+ DoubleArray scalarBarRangeArray;
+ boolean hideDataOutsideCustomRange;
+ DoubleArray planeNormal;
+ double planePos;
+ };
+
+ struct StreamLinesParameters {
+ long fieldHandlerId;
+ ScalarBarRangeType scalarBarRange;
+ ColorMapType colorMap;
+ boolean visibility;
+ boolean scalarBarVisibility;
+ DoubleArray scalarBarRangeArray;
+ boolean hideDataOutsideCustomRange;
+ IntegrationDirType integrDir;
+ };
+
+ struct CutSegmentParameters {
+ long fieldHandlerId;
+ ScalarBarRangeType scalarBarRange;
+ ColorMapType colorMap;
+ boolean visibility;
+ boolean scalarBarVisibility;
+ DoubleArray scalarBarRangeArray;
+ boolean hideDataOutsideCustomRange;
+ DoubleArray point1;
+ DoubleArray point2;
};
typedef sequence<long> PresentationsList;
long makeSlices(in SlicesParameters params, in ViewModeType viewMode) raises (SALOME::SALOME_Exception);
long makeDeflectionShape(in DeflectionShapeParameters params, in ViewModeType viewMode) raises (SALOME::SALOME_Exception);
long makePointSprite(in PointSpriteParameters params, in ViewModeType viewMode) raises (SALOME::SALOME_Exception);
+ long makePlot3D(in Plot3DParameters params, in ViewModeType viewMode) raises (SALOME::SALOME_Exception);
+ long makeStreamLines(in StreamLinesParameters params, in ViewModeType viewMode) raises (SALOME::SALOME_Exception);
+ long makeCutSegment(in CutSegmentParameters params, in ViewModeType viewMode) raises (SALOME::SALOME_Exception);
void setPresentationStringProperty(in long presId, in string propName, in string propValue);
string getPresentationStringProperty(in long presId, in string propName);
void setPresentationIntProperty(in long presId, in string propName, in long propValue);
- long getPresentationIntProperty(in long presId, in string propName);
+ long getPresentationIntProperty(in long presId, in string propName);
+ void setPresentationDoubleProperty(in long presId, in string propName, in double propValue);
+ double getPresentationDoubleProperty(in long presId, in string propName);
+
MeshViewParameters getMeshViewParameters(in long presId);
ScalarMapParameters getScalarMapParameters(in long presId);
SlicesParameters getSlicesParameters(in long presId);
VectorFieldParameters getVectorFieldParameters(in long presId);
PointSpriteParameters getPointSpriteParameters(in long presId);
+ Plot3DParameters getPlot3DParameters(in long presId);
DeflectionShapeParameters getDeflectionShapeParameters(in long presId);
+ StreamLinesParameters getStreamLinesParameters(in long presId);
+ CutSegmentParameters getCutSegmentParameters(in long presId);
void updateMeshView(in long presId, in MeshViewParameters params) raises (SALOME::SALOME_Exception);
void updateScalarMap(in long presId, in ScalarMapParameters params) raises (SALOME::SALOME_Exception);
void updateSlices(in long presId, in SlicesParameters params) raises (SALOME::SALOME_Exception);
void updateDeflectionShape(in long presId, in DeflectionShapeParameters params) raises (SALOME::SALOME_Exception);
void updatePointSprite(in long presId, in PointSpriteParameters params) raises (SALOME::SALOME_Exception);
+ void updatePlot3D(in long presId, in Plot3DParameters params) raises (SALOME::SALOME_Exception);
+ void updateStreamLines(in long presId, in StreamLinesParameters params) raises (SALOME::SALOME_Exception);
+ void updateCutSegment(in long presId, in CutSegmentParameters params) raises (SALOME::SALOME_Exception);
boolean removePresentation(in long presId) raises (SALOME::SALOME_Exception);
PresentationsList getAllPresentations();
+// Visibility State in the active ParaView viewer
+ PresentationVisibility stateInActiveView(in long presId);
+
void cleanUp() raises (SALOME::SALOME_Exception);
};
};
OpSlices = 2504, // Menu Slices
OpDeflectionShape = 2505, // Menu Deflection
OpPointSprite = 2506, // Menu PointSprite
+ OpPlot3D = 2507, // Menu Plot3D
+ OpStreamLines = 2508, // Menu StreamLines
+ OpCutSegment = 2509, // Menu CutSegment
// Interpolation
OpProcessingInterpolation = 2601, // Menu Processing interpolation
};
MEDPresentationVectorField.cxx
MEDPresentationSlices.cxx
MEDPresentationPointSprite.cxx
- MEDPresentationDeflectionShape.cxx
+ MEDPresentationPlot3D.cxx
+ MEDPresentationDeflectionShape.cxx
+ MEDPresentationStreamLines.cxx
+ MEDPresentationCutSegment.cxx
)
SET(MEDEngineCommon_SOURCES
SALOMEDS::StudyBuilder_var studyBuilder = aStudy->NewBuilder();
SALOMEDS::UseCaseBuilder_var useCaseBuilder = aStudy->GetUseCaseBuilder();
SALOMEDS::SObject_var soPresentation = studyBuilder->NewObject(soFieldseries);
- useCaseBuilder->AppendTo(soPresentation->GetFather(), soPresentation);
-
+
soPresentation->SetAttrString("AttributeName", name);
soPresentation->SetAttrString("AttributePixMap", ico);
aParam->SetInt(PRESENTATION_ID, presentationId);
aParam->SetString(PRESENTATION_TYPE, type);
+ useCaseBuilder->AppendTo(soPresentation->GetFather(), soPresentation);
+
return MED_ORB::OP_OK;
}
const std::string MEDPresentation::PROP_COMPONENT = "component_";
const std::string MEDPresentation::PROP_COLOR_MAP = "colorMap";
const std::string MEDPresentation::PROP_SCALAR_BAR_RANGE = "scalarBarRange";
+const std::string MEDPresentation::PROP_VISIBILITY = "visibility";
+const std::string MEDPresentation::PROP_SCALAR_BAR_VISIBILITY = "scalarBarVisibility";
+const std::string MEDPresentation::PROP_SCALAR_BAR_MIN_VALUE = "scalarBarMinValue";
+const std::string MEDPresentation::PROP_SCALAR_BAR_MAX_VALUE = "scalarBarMaxValue";
+const std::string MEDPresentation::PROP_HIDE_DATA_OUTSIDE_CUSTOM_RANGE = "hideDataOutsideCustomRange";
+
+#define PROGRAMMABLE "__programmable"
MEDPresentation::MEDPresentation(MEDPresentation::TypeID handlerId, const std::string& name,
const MEDCALC::ViewModeType viewMode,
_colorMap(colorMap),
_sbRange(sbRange),
_renderViewPyId(-1), // will be set by MEDPresentationManager_i::_makePresentation()
- _globalDict(0)
+ _globalDict(0),
+ _presentationVisibility(true),
+ _scalarBarVisibility(true),
+ _scalarBarRangeArray{ 0.0, 100.0 },
+ _programmableInitialized(false),
+ _hideDataOutsideCustomRange(false),
+ _nbComponents(0),
+ _nbComponentsInThresholdInput(0)
{
setStringProperty(MEDPresentation::PROP_NAME, name);
setIntProperty(MEDPresentation::PROP_COLOR_MAP, static_cast<int>(colorMap));
setIntProperty(MEDPresentation::PROP_SCALAR_BAR_RANGE, static_cast<int>(sbRange));
+ setIntProperty(MEDPresentation::PROP_VISIBILITY, static_cast<int>(_presentationVisibility));
+ setIntProperty(MEDPresentation::PROP_SCALAR_BAR_VISIBILITY, static_cast<int>(_scalarBarVisibility));
+ setDoubleProperty(MEDPresentation::PROP_SCALAR_BAR_MIN_VALUE, _scalarBarRangeArray[0]);
+ setDoubleProperty(MEDPresentation::PROP_SCALAR_BAR_MAX_VALUE, _scalarBarRangeArray[1]);
+ setIntProperty(MEDPresentation::PROP_HIDE_DATA_OUTSIDE_CUSTOM_RANGE, static_cast<int>(_hideDataOutsideCustomRange));
+
// Python variables:
int id = GeneratePythonId();
- std::ostringstream oss_o, oss_d, oss_l, oss_s, oss_r;
+ std::ostringstream oss_o, oss_d, oss_l, oss_s, oss_r, oss_cl, oss_p;
oss_o << "__obj" << id;
oss_s << "__srcObj" << id;
oss_d << "__disp" << id;
oss_l << "__lut" << id;
oss_r << "__range" << id;
+ oss_p << PROGRAMMABLE << id;
_objVar = oss_o.str();
_srcObjVar = oss_s.str();
_dispVar = oss_d.str();
_lutVar = oss_l.str();
_rangeVar = oss_r.str();
+ _programmableVar = oss_p.str();
}
/**
_fieldName = fieldHandler->fieldname;
_mcFieldType = (MEDCoupling::TypeOfField) fieldHandler->type;
_pvFieldType = getPVFieldTypeString(_mcFieldType);
- _colorByType = _pvFieldType; // by default the same; overridden in DeflectionShape, VectorField, PointSprite and Contour
+ _colorByType = _pvFieldType; // by default the same; overridden in DeflectionShape, VectorField, PointSprite and Contour, Plot3D
_meshName = meshHandler->name;
}
try {
oss << "pvs.Hide(" << _objVar << ", view=" << getRenderViewVar() << ");";
+ for (auto& value : _presentationThresolds) {
+ if (value._active) {
+ oss << "pvs.Hide(" << value._thresholdVar << ", view=" << getRenderViewVar() << ");";
+ }
+ }
execPyLine(oss.str());
// :TRICKY: The two following lines raise an exception when closing MED module
// after sequence: MED - load file - PARAVIS - MED - close SALOME
this->internalGeneratePipeline();
}
+void MEDPresentation::internalGenerateThreshold() {
+ std::ostringstream oss;
+ std::string inputFieldName = getFieldName();
+ if (!_programmableInitialized) {
+ if (_nbComponentsInThresholdInput > 1) {
+ std::string typ = toScriptCellType(_colorByType);
+ oss << _programmableVar << " = pvs.ProgrammableFilter(Input = " << _objVar << ");";
+ oss << _programmableVar << ".Script = \"\"\"import numpy as np" << std::endl;
+ oss << "import paraview.vtk.numpy_interface.dataset_adapter as dsa" << std::endl;
+ oss << "input0 = inputs[0]" << std::endl;
+ oss << "inputDataArray=input0." << typ << "['" << inputFieldName << "']" << std::endl;
+ oss << "if type(inputDataArray) == dsa.VTKCompositeDataArray:" << std::endl;
+ oss << "\tnpa = inputDataArray.GetArrays()" << std::endl;
+ oss << "else:" << std::endl;
+ oss << "\tnpa = inputDataArray" << std::endl;
+ oss << "if type(npa) == list:" << std::endl;
+ oss << "\tarrs = []" << std::endl;
+ oss << "\tfor a in npa:" << std::endl;
+ oss << "\t\tmgm = np.linalg.norm(a, axis = -1)" << std::endl;
+ oss << "\t\tmga = mgm.reshape(mgm.size, 1)" << std::endl;
+ oss << "\t\tarrs.append(mga)" << std::endl;
+ oss << "\tca = dsa.VTKCompositeDataArray(arrs)" << std::endl;
+ oss << "\toutput." << typ << ".append(ca, '" << inputFieldName << "_magnitude')" << std::endl;
+ oss << "else:" << std::endl;
+ oss << "\tmgm = np.linalg.norm(npa, axis = -1)" << std::endl;
+ oss << "\tmga = mgm.reshape(mgm.size, 1)" << std::endl;
+ oss << "\toutput." << typ << ".append(mga, '" << inputFieldName << "_magnitude')" << std::endl;
+ for (std::vector<std::string>::size_type ii = 1; ii < _nbComponentsInThresholdInput + 1 ; ii++) {
+ oss << "dataArray" << ii << " = inputDataArray[:, [" << ii - 1 << "]]" << std::endl;
+ oss << "output." << typ << ".append(dataArray" << ii << ", '" << inputFieldName << "_" << ii << "')" << std::endl;
+ }
+ oss << "\"\"\"" << std::endl;
+ _programmableInitialized = true;
+ }
+ }
+
+ ComponentThresold& currentThreshold = _presentationThresolds[getThresholdIndex()];
+ if (!currentThreshold._thresholdInitialized) {
+ std::string& thInput = (_nbComponentsInThresholdInput > 1 ) ? _programmableVar : _objVar;
+ std::string arrayName = getThresholdFieldName();
+ oss << currentThreshold._thresholdVar << " = pvs.Threshold(Input = " << thInput << ");";
+ oss << currentThreshold._thresholdVar << ".Scalars = ['" << _colorByType << "', '" << arrayName << "'];";
+ oss << additionalThresholdInitializationActions();
+ oss << currentThreshold._thresholdDispVar << " = pvs.Show(" << currentThreshold._thresholdVar << ", "
+ << getRenderViewVar() << ");";
+ oss << currentThreshold._thresholdLutVar << " = pvs.GetColorTransferFunction('" << arrayName << "', "
+ << currentThreshold._thresholdDispVar << ", separate=True);";
+ oss << "pvs.ColorBy(" << currentThreshold._thresholdDispVar << ", ('" << _colorByType << "', '"
+ << arrayName << "'), separate = True);";
+ oss << additionalThresholdVisualizationActions();
+ currentThreshold._thresholdInitialized = true;
+ }
+ if (oss.str().length() > 0) {
+ pushAndExecPyLine(oss.str());
+ }
+}
+
//void
//MEDPresentation::pushPyObjects(PyObjectId obj, PyObjectId disp)
//{
}
}
+ void
+ MEDPresentation::setDoubleProperty(const std::string& propName, const double propValue)
+ {
+ _propertiesDouble[propName] = propValue;
+ }
+
+ double
+ MEDPresentation::getDoubleProperty(const std::string& propName) const
+ {
+ std::map<std::string, double>::const_iterator it = _propertiesDouble.find(propName);
+ if (it != _propertiesDouble.end()) {
+ return (*it).second;
+ }
+ else {
+ STDLOG("MEDPresentation::getDoubleProperty(): no property named " + propName);
+ throw MEDPresentationException("MEDPresentation::getDoubleProperty(): no property named " + propName);
+ }
+ }
+
+ void
+ MEDPresentation::dumpDoubleProperties() const
+ {
+ std::map<std::string, double>::const_iterator it = _propertiesDouble.begin();
+ STDLOG("@@@ Dumping DOUBLE properties");
+ for (; it != _propertiesDouble.end(); ++it)
+ {
+ std::ostringstream oss;
+ oss << (*it).first << " -> " << (*it).second;
+ STDLOG(oss.str());
+ }
+ }
+
void
MEDPresentation::dumpStringProperties() const
{
if (_viewMode == MEDCALC::VIEW_MODE_OVERLAP) {
// this might potentially re-assign to an existing view variable, but this is OK, we
// normally reassign exactly the same RenderView object.
- oss2 << view << " = pvs.GetActiveViewOrCreate('RenderView');";
+ oss2 << view << " = medcalc.FindOrCreateView('RenderView');";
pushAndExecPyLine(oss2.str()); oss2.str("");
} else if (_viewMode == MEDCALC::VIEW_MODE_REPLACE) {
// same as above
- oss2 << view << " = pvs.GetActiveViewOrCreate('RenderView');";
+ oss2 << view << " = medcalc.FindOrCreateView('RenderView');";
pushAndExecPyLine(oss2.str()); oss2.str("");
oss2 << "pvs.active_objects.source and pvs.Hide(view=" << view << ");";
pushAndExecPyLine(oss2.str()); oss2.str("");
{
std::ostringstream oss, oss_l;
std::string ret;
-
- if (_selectedComponentIndex != -1)
+ if (!_hideDataOutsideCustomRange) {
+ if (_selectedComponentIndex != -1)
{
oss << _lutVar << ".VectorMode = 'Component';";
pushAndExecPyLine(oss.str()); oss.str("");
oss << _lutVar << ".VectorComponent = " << _selectedComponentIndex << ";";
pushAndExecPyLine(oss.str()); oss.str("");
}
- else // Euclidean norm
+ else // Euclidean norm
{
oss << _lutVar << ".VectorMode = 'Magnitude';";
pushAndExecPyLine(oss.str()); oss.str("");
}
+ }
+ else {
+ // Make sure that threshold is initialized
+ internalGenerateThreshold();
+ // Set range
+ thresholdValues();
+
+ // Color map setting
+ selectColorMap(false);
+
+ if (!_presentationThresolds[getThresholdIndex()]._active) {
+ std::vector<std::string>::size_type idx = (_nbComponentsInThresholdInput > 1) ? -1 : 0;
+ for (auto& value : _presentationThresolds) {
+ // Hide previous threshold
+ if (value._active) {
+ bool currentVisibility = _presentationVisibility;
+ std::vector<std::string>::size_type currentIndex = _selectedComponentIndex;
+ _presentationVisibility = false;
+ _selectedComponentIndex = idx;
+ visibility();
+ _selectedComponentIndex = currentIndex;
+ _presentationVisibility = currentVisibility;
+ value._active = false;
+ }
+ idx++;
+ }
+ // Show new threshold
+ visibility();
+ _presentationThresolds[getThresholdIndex()]._active = true;
+ scalarBarTitle();
+ }
+ }
}
/**
compoName = "Magnitude";
}
std::ostringstream oss;
- oss << "pvs.GetScalarBar(" << _lutVar << ").ComponentTitle = '" << compoName << "';";
+ if (_hideDataOutsideCustomRange) {
+ oss << "pvs.GetScalarBar(" << getLutVar() << ").Title = '" << _fieldName << "';";
+ }
+ oss << "pvs.GetScalarBar(" << getLutVar() << ").ComponentTitle = '" << compoName << "';";
pushAndExecPyLine(oss.str()); oss.str("");
}
void
-MEDPresentation::selectColorMap()
+MEDPresentation::selectColorMap(const bool updateFieldComponent)
{
- std::ostringstream oss, oss2;
-
- oss2 << _lutVar << " = pvs.GetColorTransferFunction('" << _fieldName << "');";
- pushAndExecPyLine(oss2.str());
+ std::ostringstream oss;
switch (_colorMap) {
case MEDCALC::COLOR_MAP_BLUE_TO_RED_RAINBOW:
- oss << _lutVar << ".ApplyPreset('Blue to Red Rainbow',True);";
+ oss << getLutVar() << ".ApplyPreset('Blue to Red Rainbow',True);";
break;
case MEDCALC::COLOR_MAP_COOL_TO_WARM:
- oss << _lutVar << ".ApplyPreset('Cool to Warm',True);";
+ oss << getLutVar() << ".ApplyPreset('Cool to Warm',True);";
break;
default:
STDLOG("MEDPresentation::getColorMapCommand(): invalid colormap!");
}
pushAndExecPyLine(oss.str());
- selectFieldComponent(); // somehow PV keeps the LUT parameters of the previous presentation, so better reset this.
+ if(updateFieldComponent) {
+ selectFieldComponent(); // somehow PV keeps the LUT parameters of the previous presentation, so better reset this.
+ }
}
void
{
std::ostringstream oss;
oss << _dispVar << " = pvs.Show(" << _objVar << ", " << getRenderViewVar() << ");";
+ oss << _lutVar << " = pvs.GetColorTransferFunction('" << getFieldName() << "', " << _dispVar << ", separate=True);";
+ pushAndExecPyLine(oss.str());
+}
+
+void
+MEDPresentation::hideObject()
+{
+ std::ostringstream oss;
+ oss <<"pvs.Hide(" << _objVar << ", " << getRenderViewVar() << ");";
pushAndExecPyLine(oss.str());
}
void
MEDPresentation::showScalarBar()
+{
+ // Display Scalar Bar only if presentation is visible
+ if (_presentationVisibility) {
+ std::ostringstream oss;
+ oss << getDispVar() << ".SetScalarBarVisibility(" << getRenderViewVar() << ", True);";
+ pushAndExecPyLine(oss.str());
+ }
+}
+
+void
+MEDPresentation::hideScalarBar()
{
std::ostringstream oss;
- oss << _dispVar << ".SetScalarBarVisibility(" << getRenderViewVar() << ", True);";
+ oss << getDispVar() << ".SetScalarBarVisibility(" << getRenderViewVar() << ", False);";
pushAndExecPyLine(oss.str());
}
+void
+MEDPresentation::scalarBarVisibility() {
+ _scalarBarVisibility ? showScalarBar() : hideScalarBar();
+}
+
void
MEDPresentation::colorBy()
{
std::ostringstream oss;
- oss << "pvs.ColorBy(" << _dispVar << ", ('" << _colorByType << "', '" << _fieldName << "'));";
+ oss << "pvs.ColorBy(" << getDispVar() << ", ('" << _colorByType << "', '" << getFieldName() << "'), separate=True);";
+ pushAndExecPyLine(oss.str());
+}
+
+void MEDPresentation::visibility() {
+ std::ostringstream oss;
+ oss << getDispVar() << ".Visibility = " << (_presentationVisibility ? "True" : "False") << ";";
+ pushAndExecPyLine(oss.str());
+
+ // Hide scalar bar with the presentation
+ if (!_presentationVisibility && _scalarBarVisibility)
+ hideScalarBar();
+
+ // Show scalar bar with the presentation
+ if (_presentationVisibility && _scalarBarVisibility)
+ showScalarBar();
+}
+
+void MEDPresentation::threshold() {
+ _hideDataOutsideCustomRange ? thresholdPresentation() : unThresholdPresentation();
+}
+
+void MEDPresentation::thresholdPresentation() {
+ if (!_hideDataOutsideCustomRange)
+ return;
+
+ internalGenerateThreshold();
+
+ // Hide _dispVar, for that temporary switch the _presentationVisibility and _hideDataOutsideCustomRange
+ // flag to false and call visibility() method
+ bool prevVisibility = _presentationVisibility;
+ bool prevHideDataOutsideCustomRange = _hideDataOutsideCustomRange;
+ _presentationVisibility = false;
+ _hideDataOutsideCustomRange = false;
+ visibility();
+ _presentationVisibility = prevVisibility;
+ _hideDataOutsideCustomRange = prevHideDataOutsideCustomRange;
+
+ // Display _thresholdDispVar var
+ visibility();
+
+ // Select target colormap
+ selectColorMap();
+
+ // Adapt scalar bar title
+ scalarBarTitle();
+
+ // Additional threshold actions to be done
+ additionalThresholdActions();
+
+ _presentationThresolds[getThresholdIndex()]._active = true;
+}
+
+void MEDPresentation::thresholdValues() {
+ if (!_hideDataOutsideCustomRange)
+ return;
+ std::ostringstream oss;
+ oss << _presentationThresolds[getThresholdIndex()]._thresholdVar << ".ThresholdRange = [ " << _scalarBarRangeArray[0] << ", " << _scalarBarRangeArray[1] << "];";
+ oss << _presentationThresolds[getThresholdIndex()]._thresholdLutVar <<".RescaleTransferFunction(" << _scalarBarRangeArray[0] << ", " << _scalarBarRangeArray[1] << ");";
pushAndExecPyLine(oss.str());
}
+void MEDPresentation::unThresholdPresentation() {
+
+ if (_presentationThresolds[getThresholdIndex()]._active) {
+ // Hide _dispVar, for that temporary switch the _presentationVisibility to talse and _hideDataOutsideCustomRange
+ // flag to true and call visibility() method
+ bool prevVisibility = _presentationVisibility;
+ bool prevHideDataOutsideCustomRange = _hideDataOutsideCustomRange;
+ _presentationVisibility = false;
+ _hideDataOutsideCustomRange = true;
+ visibility();
+ _presentationVisibility = prevVisibility;
+ _hideDataOutsideCustomRange = prevHideDataOutsideCustomRange;
+
+ // Range
+ rescaleTransferFunction();
+
+ // Display _dispVar var
+ visibility();
+
+ // Select target colormap
+ selectColorMap();
+
+ // Adapt scalar bar title
+ scalarBarTitle();
+
+ // Additional unthreshold actions to be done
+ additionalUnThresholdActions();
+
+ _presentationThresolds[getThresholdIndex()]._active = false;
+ }
+}
+
+int MEDPresentation::getThresholdIndex() const {
+ if (_nbComponentsInThresholdInput > 1 && _nbComponentsInThresholdInput <= 3) {
+ return _selectedComponentIndex + 1;
+ }
+ else {
+ return _selectedComponentIndex;
+ }
+}
+
+/*!
+ Return _dispVar or _thresholdDispVar depending on _hideDataOutsideCustomRange flag:
+ _hideDataOutsideCustomRange == false : _dispVar is used
+ _hideDataOutsideCustomRange == true : _thresholdDispVar is used
+*/
+const std::string& MEDPresentation::getDispVar() {
+ return (_hideDataOutsideCustomRange ? _presentationThresolds[getThresholdIndex()]._thresholdDispVar : _dispVar);
+}
+
+/*!
+ Return _dispVar or _thresholdDispVar depending on _hideDataOutsideCustomRange flag:
+ _hideDataOutsideCustomRange == false : _dispVar is used
+ _hideDataOutsideCustomRange == true : _thresholdDispVar is used
+*/
+const std::string& MEDPresentation::getLutVar() {
+ return (_hideDataOutsideCustomRange ? _presentationThresolds[getThresholdIndex()]._thresholdLutVar : _lutVar);
+}
+
void
MEDPresentation::rescaleTransferFunction()
{
+ if (_hideDataOutsideCustomRange)
+ return;
+
std::ostringstream oss;
switch(_sbRange)
{
case MEDCALC::SCALAR_BAR_CURRENT_TIMESTEP:
oss << _dispVar << ".RescaleTransferFunctionToDataRange(False);";
break;
+ case MEDCALC::SCALAR_BAR_CUSTOM_RANGE:
+ oss << _lutVar << ".RescaleTransferFunction("<< _scalarBarRangeArray[0]<<", "<< _scalarBarRangeArray[1]<<");";
+ break;
default:
STDLOG("MEDPresentation::getRescaleCommand(): invalid range!");
throw KERNEL::createSalomeException("MEDPresentation::getRescaleCommand(): invalid range!");
}
pushAndExecPyLine(oss.str()); oss.str("");
// Get min-max
- oss << _rangeVar << " = [" << _dispVar << ".LookupTable.RGBPoints[0], " << _dispVar << ".LookupTable.RGBPoints[-4]];";
- pushAndExecPyLine(oss.str());
+ oss << _rangeVar << " = [" << _lutVar << ".RGBPoints[0], " << _lutVar << ".RGBPoints[-4]];";
+ execPyLine(oss.str());
+ //Update _scalarBarRange internal variable in case of rescaling to "Data Range" or "Data Range Over All Times"
+ if (_sbRange == MEDCALC::SCALAR_BAR_ALL_TIMESTEPS ||
+ _sbRange == MEDCALC::SCALAR_BAR_CURRENT_TIMESTEP) {
+ MEDPyLockWrapper lock;
+ PyObject * obj = getPythonObjectFromMain(_rangeVar.c_str());
+ if (obj && PyList_Check(obj)) {
+ PyObject* objL0 = PyList_GetItem(obj, 0);
+ PyObject* objL1 = PyList_GetItem(obj, 1);
+ if (PyFloat_Check(objL0)) {
+ double min = PyFloat_AsDouble(objL0);
+ _scalarBarRangeArray[0] = min;
+ }
+ if (PyFloat_Check(objL1)) {
+ double max = PyFloat_AsDouble(objL1);
+ _scalarBarRangeArray[1] = max;
+ }
+ }
+ setDoubleProperty(MEDPresentation::PROP_SCALAR_BAR_MIN_VALUE, _scalarBarRangeArray[0]);
+ setDoubleProperty(MEDPresentation::PROP_SCALAR_BAR_MAX_VALUE, _scalarBarRangeArray[1]);
+ }
// Adapt scalar bar title
scalarBarTitle();
}
+MEDCALC::PresentationVisibility
+MEDPresentation::presentationStateInActiveView() {
+ MEDPyLockWrapper lock;
+ MEDCALC::PresentationVisibility result = MEDCALC::PRESENTATION_NOT_IN_VIEW;
+ execPyLine("__isInView = ( " + getRenderViewVar() + " == pvs.GetActiveView() )");
+ PyObject * obj = getPythonObjectFromMain("__isInView");
+
+ if (obj && PyBool_Check(obj) && (obj == Py_True)) {
+ result = _presentationVisibility ? MEDCALC::PRESENTATION_VISIBLE : MEDCALC::PRESENTATION_INVISIBLE;
+ }
+ return result;
+}
int
MEDPresentation::GeneratePythonId()
return INIT_ID++;
}
+bool MEDPresentation::isThresoldActive() const {
+ bool active = false;
+ for (auto const& value : _presentationThresolds) {
+ active = active || value._active;
+ }
+ return active;
+}
+
bool
MEDPresentation::activateView()
{
void
MEDPresentation::recreateViewSetup()
{
+ bool prevHideDataOutsideCustomRange = _hideDataOutsideCustomRange;
+ _hideDataOutsideCustomRange = false;
showObject();
colorBy();
showScalarBar();
selectColorMap();
rescaleTransferFunction();
+ _hideDataOutsideCustomRange = prevHideDataOutsideCustomRange;
+ threshold();
resetCameraAndRender();
}
MEDPresentation::fillAvailableFieldComponents()
{
MEDPyLockWrapper lock; // GIL!
- std::string typ;
-
- if(_pvFieldType == "CELLS") {
- typ = "CellData";
- }
- else if (_pvFieldType == "POINTS") {
- typ = "PointData";
- }
- else {
- std::string msg("Unsupported spatial discretisation: " + _pvFieldType);
- STDLOG(msg);
- throw KERNEL::createSalomeException(msg.c_str());
- }
+ std::string typ = getScriptCellType();
std::ostringstream oss;
oss << "__nbCompo = " << _srcObjVar << "." << typ << ".GetArray('" << _fieldName << "').GetNumberOfComponents();";
STDLOG("Unexpected Python error");
throw KERNEL::createSalomeException("Unexpected Python error");
}
+ _nbComponents = nbCompo;
+ _nbComponentsInThresholdInput = _nbComponents;
setIntProperty(MEDPresentation::PROP_NB_COMPONENTS, nbCompo);
// if the field is not a vector (2 or 3 components), select the first component of the tensor,
oss_n << compo << "(" << val << ")";
aCompos.push_back(oss_n.str());
}
- aCompoMap[compo] = aCompoMap[compo]++;
+ aCompoMap[compo] = aCompoMap[compo] + 1;
}
}
- for (std::vector<std::string>::size_type i = 0; i != aCompos.size(); i++) {
+ std::string aCopy = _programmableVar;
+ std::string id = aCopy.replace(aCopy.find(PROGRAMMABLE), std::string(aCopy).length() - 1, "");
+
+ std::vector<std::string>::size_type up = (nbCompo > 1) ? nbCompo + 1 : nbCompo;
+ for (std::vector<std::string>::size_type i = 0; i != up; i++) {
std::ostringstream oss_p;
- oss_p << MEDPresentation::PROP_COMPONENT << i;
- setStringProperty(oss_p.str(), aCompos[i]);
+ if (i != 0 || nbCompo == 1) {
+ std::vector<std::string>::size_type idx = (nbCompo > 1) ? i - 1 : i;
+ oss_p << MEDPresentation::PROP_COMPONENT << idx;
+ setStringProperty(oss_p.str(), aCompos[idx]);
+ }
+ std::ostringstream oss_thd, oss_th, oss_thl;
+ oss_th << "__threshold" << id <<"_"<<i;
+ oss_thd << "__thresholdDisp" << id << "_" << i;
+ oss_thl << "__thresholdLut" << id << "_" << i;
+ ComponentThresold ct = ComponentThresold();
+ ct._thresholdVar = oss_th.str();
+ ct._thresholdDispVar = oss_thd.str();
+ ct._thresholdLutVar = oss_thl.str();
+ _presentationThresolds.push_back(ct);
+ }
+}
+
+std::string MEDPresentation::getThresholdFieldName() const {
+ std::string result = getFieldName();
+ if (_nbComponentsInThresholdInput > 1 && _hideDataOutsideCustomRange) {
+ std::ostringstream oss;
+ if (_selectedComponentIndex == -1) {
+ oss << _fieldName << "_magnitude";
+ }
+ else {
+ oss << _fieldName << "_" << _selectedComponentIndex + 1;
+ }
+ result = oss.str();
+ }
+ return result;
+}
+
+std::string MEDPresentation::getFieldName() const {
+ return _fieldName;
+}
+
+std::string MEDPresentation::toScriptCellType(const std::string& pvType) {
+ std::string typ = "";
+ if (pvType == "CELLS") {
+ typ = "CellData";
+ }
+ else if (pvType == "POINTS") {
+ typ = "PointData";
}
+ else {
+ std::string msg("Unsupported spatial discretisation: " + pvType);
+ STDLOG(msg);
+ throw KERNEL::createSalomeException(msg.c_str());
+ }
+ return typ;
+}
+std::string MEDPresentation::getScriptCellType() const {
+ return toScriptCellType(_pvFieldType);
}
/**
}
}
+/**
+* Delete threshold filters and programmable filter
+*/
+void
+MEDPresentation::deleteThresholds() {
+ std::ostringstream oss;
+ for (auto& value : _presentationThresolds) {
+ if (value._active) {
+ oss << "pvs.Hide(" << value._thresholdVar << ");";
+ }
+ if (value._thresholdInitialized) {
+ oss << "pvs.Delete(" << value._thresholdVar <<");";
+ value.clear();
+ }
+ }
+ if (_programmableInitialized) {
+ oss << "pvs.Delete(" << _programmableVar << ");";
+ _programmableInitialized = false;
+ }
+ pushAndExecPyLine(oss.str());
+}
+
///**
// * Convert a vector field into a 3D vector field:
// * - if the vector field is already 3D, nothing to do
#include <map>
#include <string>
+struct ComponentThresold {
+
+ ComponentThresold() {
+ _thresholdVar = "";
+ _thresholdDispVar = "";
+ _thresholdLutVar = "";
+ _thresholdInitialized = false;
+ _active = false;
+ }
+
+ ///! ParaView Threshold filter variable to hide data outside custom range in Python scripting
+ std::string _thresholdVar;
+ ///! ParaView Threshold display variable to hide data outside custom range in Python scripting
+ std::string _thresholdDispVar;
+ ///! ParaView Threshold LUT variable in the Python scripting commands
+ std::string _thresholdLutVar;
+
+ ///! Initialization flag
+ bool _thresholdInitialized;
+ ///! Active flag
+ bool _active;
+
+ void clear() {
+ _thresholdInitialized = false;
+ _active = false;
+ }
+};
+
+typedef std::vector<ComponentThresold> PresentationThresolds;
+
class MEDCALC_EXPORT MEDPresentation
{
friend class MEDPresentationManager_i;
virtual ~MEDPresentation();
- static const std::string PROP_NAME; // name of the presentation
- static const std::string PROP_NB_COMPONENTS; // number of field components
- static const std::string PROP_SELECTED_COMPONENT; // index of the selected component - 0 means Euclidean norm
- static const std::string PROP_COMPONENT; // string prefix for all properties storing component names
- static const std::string PROP_COLOR_MAP; // color map - TODO: arch fix - should be in params only
- static const std::string PROP_SCALAR_BAR_RANGE; // scalar bar range - TODO: arch fix - should be in params only
+ static const std::string PROP_NAME; // name of the presentation
+ static const std::string PROP_NB_COMPONENTS; // number of field components
+ static const std::string PROP_SELECTED_COMPONENT; // index of the selected component - 0 means Euclidean norm
+ static const std::string PROP_COMPONENT; // string prefix for all properties storing component names
+ static const std::string PROP_COLOR_MAP; // color map - TODO: arch fix - should be in params only
+ static const std::string PROP_SCALAR_BAR_RANGE; // scalar bar range - TODO: arch fix - should be in params only
+ static const std::string PROP_VISIBILITY; // presentation visibility
+ static const std::string PROP_SCALAR_BAR_VISIBILITY; // scalar bar visiblity
+ static const std::string PROP_SCALAR_BAR_MIN_VALUE; // min value of scalar bar range
+ static const std::string PROP_SCALAR_BAR_MAX_VALUE; // max value of scalar bar range
+ static const std::string PROP_HIDE_DATA_OUTSIDE_CUSTOM_RANGE; // Hide data outside custom range
+
virtual void setStringProperty(const std::string& propName, const std::string& propValue);
const std::string getStringProperty(const std::string& propName) const;
virtual void setIntProperty(const std::string& propName, const int propValue);
int getIntProperty(const std::string& propName) const;
+ virtual void setDoubleProperty(const std::string& propName, const double propValue);
+ double getDoubleProperty(const std::string& propName) const;
+
// returns True if the view was still alive, False if it must have been recreated
// because the user closed it.
- bool activateView();
+ virtual bool activateView();
virtual void recreateViewSetup();
void dumpIntProperties() const;
void dumpStringProperties() const;
+ void dumpDoubleProperties() const;
std::string paravisDump() const;
long getPyViewID() const { return _renderViewPyId; }
void setPyViewID(long id) { _renderViewPyId = id; }
+ static std::string toScriptCellType(const std::string&);
+
protected:
typedef std::pair<int, PyObject *> PyObjectId;
static int GeneratePythonId();
void createSource();
void setTimestamp();
void selectFieldComponent();
- void showObject();
+ void virtual showObject();
+ void virtual hideObject();
void colorBy();
- void showScalarBar();
+ virtual void showScalarBar();
+ virtual void hideScalarBar();
+ void scalarBarVisibility();
void rescaleTransferFunction();
- void selectColorMap();
- void scalarBarTitle();
+ void selectColorMap(const bool updateFieldComponent=true);
+ virtual void scalarBarTitle();
void resetCameraAndRender();
+ virtual void visibility();
+ void threshold();
+ void thresholdPresentation();
+ void unThresholdPresentation();
+ void thresholdValues();
+ virtual void additionalThresholdActions() {};
+ virtual std::string additionalThresholdVisualizationActions() { return ""; };
+ virtual std::string additionalThresholdInitializationActions() { return ""; };
+ virtual void additionalUnThresholdActions() {};
+ virtual std::string getFieldName() const;
+ virtual std::string getThresholdFieldName() const;
+
+ std::string getScriptCellType() const;
+ bool isThresoldActive() const;
virtual void internalGeneratePipeline();
+ virtual void internalGenerateThreshold();
+ const std::string& getDispVar();
+ const std::string& getLutVar();
PyObject* getPythonObjectFromMain(const char* var) const;
void execPyLine(const std::string & lin);
void pushAndExecPyLine(const std::string & lin);
void extractFileName(const std::string& name);
// void convertTo3DVectorField();
+ virtual MEDCALC::PresentationVisibility presentationStateInActiveView();
+
template<typename PresentationType, typename PresentationParameters>
void updateComponent(const std::string& newCompo);
void updateColorMap(MEDCALC::ColorMapType colorMap);
template<typename PresentationType, typename PresentationParameters>
- void updateScalarBarRange(MEDCALC::ScalarBarRangeType sbRange);
+ void updateScalarBarRange(MEDCALC::ScalarBarRangeType sbRange,
+ bool hideDataoutsideCustomRange,
+ double minValue, double maxValue);
+
+ template<typename PresentationType, typename PresentationParameters>
+ void updateVisibility(const bool theVisibility);
+
+ template<typename PresentationType, typename PresentationParameters>
+ void updateScalarBarVisibility(const bool theVisibility);
template<typename PresentationType, typename PresentationParameters>
void getParameters(PresentationParameters& params) const;
template<typename PresentationType, typename PresentationParameters>
void setParameters(const PresentationParameters& params);
+ int getThresholdIndex() const;
+
+ void deleteThresholds();
+
private:
std::string getPVFieldTypeString(MEDCoupling::TypeOfField fieldType) const;
MEDPresentation::TypeID _handlerId; // either a field or a mesh id (a field ID though, most of the time)
int _selectedComponentIndex;
+ int _nbComponents;
+ int _nbComponentsInThresholdInput;
MEDCALC::ViewModeType _viewMode;
MEDCALC::ColorMapType _colorMap;
MEDCALC::ScalarBarRangeType _sbRange;
+ bool _presentationVisibility;
+ bool _scalarBarVisibility;
+ bool _hideDataOutsideCustomRange;
+ double _scalarBarRangeArray[2];
///! Identifier (in the Python dump) of the render view
int _renderViewPyId;
std::string _lutVar;
///! ParaView variable in Python holding the data range
std::string _rangeVar;
+ ///! Prorgammable variable in the Python scripting commands
+ std::string _programmableVar;
+ bool _programmableInitialized;
+
+ //Thresolds
+ PresentationThresolds _presentationThresolds;
+
private:
///! Presentation properties <key,value>
std::map<std::string, std::string> _propertiesStr;
std::map<std::string, int> _propertiesInt;
+ std::map<std::string, double> _propertiesDouble;
std::vector<std::string> _pythonCmds;
template<typename PresentationType, typename PresentationParameters>
void
-MEDPresentation::updateScalarBarRange(MEDCALC::ScalarBarRangeType sbRange)
+MEDPresentation::updateScalarBarRange(MEDCALC::ScalarBarRangeType sbRange,
+ bool hideDataOutsideCustomRange,
+ double minValue, double maxValue)
{
PresentationType * p = static_cast<PresentationType*>(this);
-
PresentationParameters params;
p->getParameters(params);
+ bool prevHideDataoutsideCustomRange = params.hideDataOutsideCustomRange;
+
params.scalarBarRange = sbRange;
+ params.scalarBarRangeArray[0] = minValue;
+ params.scalarBarRangeArray[1] = maxValue;
+ params.hideDataOutsideCustomRange = hideDataOutsideCustomRange;
p->setParameters(params);
p->_sbRange = sbRange;
+ p->_scalarBarRangeArray[0] = minValue;
+ p->_scalarBarRangeArray[1] = maxValue;
+ p->_hideDataOutsideCustomRange = hideDataOutsideCustomRange;
// GUI helper:
setIntProperty(MEDPresentation::PROP_SCALAR_BAR_RANGE, sbRange);
+ setDoubleProperty(MEDPresentation::PROP_SCALAR_BAR_MIN_VALUE, minValue);
+ setDoubleProperty(MEDPresentation::PROP_SCALAR_BAR_MAX_VALUE, maxValue);
+ setIntProperty(MEDPresentation::PROP_HIDE_DATA_OUTSIDE_CUSTOM_RANGE, static_cast<int>(hideDataOutsideCustomRange));
+
+ // Update the pipeline:
+ if (hideDataOutsideCustomRange || hideDataOutsideCustomRange != prevHideDataoutsideCustomRange) {
+ MEDPyLockWrapper lock;
+ threshold(); //Swith on/off threshould or update threshould range
+ pushAndExecPyLine("pvs.Render();");
+ }
+ else
+ {
+ MEDPyLockWrapper lock;
+ rescaleTransferFunction();
+ pushAndExecPyLine("pvs.Render();");
+ }
+}
+
+template<typename PresentationType, typename PresentationParameters>
+void
+MEDPresentation::updateVisibility(const bool theVisibility)
+{
+ PresentationType * p = static_cast<PresentationType*>(this);
+
+ PresentationParameters params;
+ p->getParameters(params);
+ params.visibility = theVisibility;
+ p->setParameters(params);
+
+ p->_presentationVisibility = theVisibility;
+
+ // GUI helper:
+ setIntProperty(MEDPresentation::PROP_VISIBILITY, theVisibility);
// Update the pipeline:
{
MEDPyLockWrapper lock;
- rescaleTransferFunction();
+ visibility();
+ pushAndExecPyLine("pvs.Render();");
+ }
+}
+
+template<typename PresentationType, typename PresentationParameters>
+void
+MEDPresentation::updateScalarBarVisibility(const bool theVisibility)
+{
+ PresentationType * p = static_cast<PresentationType*>(this);
+
+ PresentationParameters params;
+ p->getParameters(params);
+ params.scalarBarVisibility = theVisibility;
+ p->setParameters(params);
+
+ p->_scalarBarVisibility = theVisibility;
+
+ // GUI helper:
+ setIntProperty(MEDPresentation::PROP_SCALAR_BAR_VISIBILITY, theVisibility);
+
+ // Update the pipeline:
+ {
+ MEDPyLockWrapper lock;
+ scalarBarVisibility();
pushAndExecPyLine("pvs.Render();");
}
}
const std::string MEDPresentationContour::TYPE_NAME = "MEDPresentationContour";
const std::string MEDPresentationContour::PROP_NB_CONTOUR = "nbContour";
+const std::string MEDPresentationContour::PROB_CONTOUR_COMPONENT_ID = "contourComponent";
MEDPresentationContour::MEDPresentationContour(const MEDCALC::ContourParameters& params,
const MEDCALC::ViewModeType viewMode) :
_params(params)
{
setIntProperty(MEDPresentationContour::PROP_NB_CONTOUR, params.nbContours);
+ setIntProperty(MEDPresentationContour::PROB_CONTOUR_COMPONENT_ID, 0);
+ std::stringstream oss;
+ oss << "__contourProgrammable" << GeneratePythonId();
+ _countourProgrammableVar = oss.str();
+}
+
+void
+MEDPresentationContour::initProgFilter() {
+ std::ostringstream oss;
+ std::string typ = "PointData"; // Contour Filter is applicable only to Point Data
+ oss << _countourProgrammableVar << " = pvs.ProgrammableFilter(Input = " << _srcObjVar << ");";
+ oss << _countourProgrammableVar << ".Script = \"\"\"import numpy as np" << std::endl;
+ oss << "import paraview.vtk.numpy_interface.dataset_adapter as dsa" << std::endl;
+ oss << "input0 = inputs[0]" << std::endl;
+ oss << "inputDataArray=input0." << typ << "['" << _fieldName << "']" << std::endl;
+ oss << "npa = inputDataArray.GetArrays()" << std::endl;
+ oss << "if type(npa) == list:" << std::endl;
+ oss << "\tarrs = []" << std::endl;
+ oss << "\tfor a in npa:" << std::endl;
+ oss << "\t\tmgm = np.linalg.norm(a, axis = -1)" << std::endl;
+ oss << "\t\tmga = mgm.reshape(mgm.size, 1)" << std::endl;
+ oss << "\t\tarrs.append(mga)" << std::endl;
+ oss << "\tca = dsa.VTKCompositeDataArray(arrs)" << std::endl;
+ oss << "\toutput." << typ << ".append(ca, '" << _fieldName << "_magnitude')" << std::endl;
+ oss << "else:" << std::endl;
+ oss << "\tmgm = np.linalg.norm(npa, axis = -1)" << std::endl;
+ oss << "\tmga = mgm.reshape(mgm.size, 1)" << std::endl;
+ oss << "\toutput." << typ << ".append(mga, '" << _fieldName << "_magnitude')" << std::endl;
+ for (std::vector<std::string>::size_type ii = 1; ii < _nbComponents + 1 ; ii++) {
+ oss << "dataArray" << ii << " = inputDataArray[:, [" << ii - 1 << "]]" << std::endl;
+ oss << "output." << typ << ".append(dataArray" << ii << ", '" << _fieldName << "_" << ii << "')" << std::endl;
+ }
+ oss << "\"\"\"" << std::endl;
+ pushAndExecPyLine(oss.str());
}
void
MEDPresentationContour::setNumberContours()
{
std::ostringstream oss;
+ std::string aVar = _srcObjVar;
+ if (_nbComponents > 1) {
+ aVar = _countourProgrammableVar;
+ }
- oss << "min_max = " << _srcObjVar << ".PointData.GetArray('" << _fieldName << "').GetRange();";
+ oss << "min_max = " << aVar << ".PointData.GetArray('" << getContourComponentName() << "').GetRange();";
pushAndExecPyLine(oss.str()); oss.str("");
oss << "delta = (min_max[1]-min_max[0])/float(" << _params.nbContours << ");";
pushAndExecPyLine(oss.str()); oss.str("");
// Populate internal array of available components:
fillAvailableFieldComponents();
- if (getIntProperty(MEDPresentation::PROP_NB_COMPONENTS) > 1)
- {
- const char * msg = "Contour presentation only works for scalar field!"; // this message will appear in GUI too
- STDLOG(msg);
- throw KERNEL::createSalomeException(msg);
- }
if (_params.nbContours < 1)
- {
- const char * mes = "Invalid number of contours!";
- STDLOG(mes);
- throw KERNEL::createSalomeException(mes);
- }
-
+ {
+ const char * mes = "Invalid number of contours!";
+ STDLOG(mes);
+ throw KERNEL::createSalomeException(mes);
+ }
setOrCreateRenderView(); // instantiate __viewXXX, needs to be after the exception above otherwise previous elements in the view will be hidden.
// Contour needs point data:
applyCellToPointIfNeeded();
-
std::ostringstream oss;
- oss << _objVar << " = pvs.Contour(Input=" << _srcObjVar << ");";
- pushAndExecPyLine(oss.str()); oss.str("");
- showObject();
+ // Calculate component
+ if (_nbComponents > 1)
+ {
+ pushAndExecPyLine(oss.str()); oss.str("");
+ initProgFilter();
+ _nbComponentsInThresholdInput = 1; // Because we extract all components as a separate array usign Programmable Filter
+ _selectedComponentIndex = 0;
+ oss << _objVar << " = pvs.Contour(Input=" << _countourProgrammableVar << ");";
+ pushAndExecPyLine(oss.str()); oss.str("");
- oss << _objVar << ".ContourBy = ['POINTS', '" << _fieldName << "'];";
- pushAndExecPyLine(oss.str()); oss.str("");
+ oss << _objVar << ".ContourBy = ['POINTS', '" << _fieldName << "_magnitude" << "'];";
+ pushAndExecPyLine(oss.str());
+ }
+ else
+ {
+ oss << _objVar << " = pvs.Contour(Input=" << _srcObjVar << ");";
+ pushAndExecPyLine(oss.str()); oss.str("");
+
+ oss << _objVar << ".ContourBy = ['POINTS', '" << _fieldName << "'];";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ }
// Colorize contour
oss << _objVar << ".ComputeScalars = 1;";
// Set number of contours
setNumberContours();
- colorBy(); // see initFieldInfo() - necessarily POINTS because of the conversion above
+ showObject();
+ colorBy();
showScalarBar();
selectColorMap();
rescaleTransferFunction();
if (params.fieldHandlerId != _params.fieldHandlerId)
throw KERNEL::createSalomeException("Unexpected updatePipeline error! Mismatching fieldHandlerId!");
- if (params.scalarBarRange != _params.scalarBarRange)
- updateScalarBarRange<MEDPresentationContour, MEDCALC::ContourParameters>(params.scalarBarRange);
+ if (params.scalarBarRange != _params.scalarBarRange ||
+ params.hideDataOutsideCustomRange != _params.hideDataOutsideCustomRange ||
+ params.scalarBarRangeArray[0] != _params.scalarBarRangeArray[0] ||
+ params.scalarBarRangeArray[1] != _params.scalarBarRangeArray[1])
+ updateScalarBarRange<MEDPresentationContour, MEDCALC::ContourParameters>(params.scalarBarRange,
+ params.hideDataOutsideCustomRange,
+ params.scalarBarRangeArray[0],
+ params.scalarBarRangeArray[1]);
if (params.colorMap != _params.colorMap)
updateColorMap<MEDPresentationContour, MEDCALC::ContourParameters>(params.colorMap);
}
updateNbContours(params.nbContours);
}
+
+ if (std::string(params.contourComponent) != std::string(_params.contourComponent))
+ updateContourComponent(std::string(params.contourComponent));
+
+ if (params.visibility != _params.visibility)
+ updateVisibility<MEDPresentationContour, MEDCALC::ContourParameters>(params.visibility);
+
+ if (params.scalarBarVisibility != _params.scalarBarVisibility)
+ updateScalarBarVisibility<MEDPresentationContour, MEDCALC::ContourParameters>(params.scalarBarVisibility);
+
}
void
pushAndExecPyLine("pvs.Render();");
}
}
+
+void
+MEDPresentationContour::updateContourComponent(const std::string& newCompo)
+{
+ _params.contourComponent = newCompo.c_str();
+
+ int id = getContourComponentId();
+
+ // GUI helper:
+ setIntProperty(MEDPresentationContour::PROB_CONTOUR_COMPONENT_ID, id);
+
+ // Update the pipeline:
+ {
+ MEDPyLockWrapper lock;
+ std::ostringstream oss;
+ oss << _objVar << ".ContourBy = ['POINTS', '" << getContourComponentName() << "'];";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ scalarBarTitle();
+ pushAndExecPyLine("pvs.Render();");
+ }
+}
+
+
+int MEDPresentationContour::getContourComponentId() const {
+ int result = -1;
+ if (std::string(_params.contourComponent) == "") { // Magnitude
+ result = 0;
+ }
+ for (std::vector<std::string>::size_type i = 0; i < _nbComponents; i++) {
+ std::ostringstream oss_p;
+ oss_p << MEDPresentation::PROP_COMPONENT << i;
+ std::string compo = getStringProperty(oss_p.str());
+ if (std::string(_params.contourComponent) == compo) {
+ result = i + 1;
+ break;
+ }
+ }
+ if (result == -1) {
+ std::ostringstream oss;
+ oss << "MEDPresentationContour::getContourComponentId(): unknown component '" <<_params.contourComponent
+ << "' !\n";
+ STDLOG(oss.str());
+ throw KERNEL::createSalomeException(oss.str().c_str());
+ }
+ return result;
+}
+
+std::string MEDPresentationContour::getContourComponentName() const {
+ std::ostringstream result;
+ result << _fieldName;
+ if (_nbComponents > 1) {
+ int id = getContourComponentId();
+ switch (id) {
+ case 0: result << "_magnitude"; break;
+ default: result << "_" << id; break;
+ }
+ }
+ return result.str();
+}
+
+std::string MEDPresentationContour::getFieldName() const {
+ return getContourComponentName();
+}
+
+void
+MEDPresentationContour::scalarBarTitle()
+{
+ if (_nbComponents > 1) {
+ // get selected component name:
+ int id = getContourComponentId();
+ std::string compoName;
+ if (id != 0)
+ {
+ std::ostringstream oss1;
+ oss1 << MEDPresentation::PROP_COMPONENT << id - 1;
+ compoName = getStringProperty(oss1.str());
+ }
+ else
+ {
+ compoName = "Magnitude";
+ }
+ std::ostringstream oss;
+ oss << "pvs.GetScalarBar(" << getLutVar() << ").Title = '" << _fieldName << "';";
+ oss << "pvs.GetScalarBar(" << getLutVar() << ").ComponentTitle = '" << compoName << "';";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ }
+ else {
+ MEDPresentation::scalarBarTitle();
+ }
+}
\ No newline at end of file
public:
static const std::string TYPE_NAME;
static const std::string PROP_NB_CONTOUR;
+ static const std::string PROB_CONTOUR_COMPONENT_ID;
MEDPresentationContour(const MEDCALC::ContourParameters& params, const MEDCALC::ViewModeType viewMode);
virtual ~MEDPresentationContour() {}
void setParameters(const MEDCALC::ContourParameters & params) { _params = params; } ;
protected:
+ void initProgFilter();
void updateNbContours(const int nbContours);
+ void updateContourComponent(const std::string& newCompo);
virtual void internalGeneratePipeline();
-
+ int getContourComponentId() const;
+ std::string getContourComponentName() const;
void setNumberContours();
+ std::string getFieldName() const override;
+ void scalarBarTitle() override;
private:
MEDCALC::ContourParameters _params;
+ std::string _countourProgrammableVar;
};
#endif
--- /dev/null
+// Copyright (C) 2016-2021 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 "MEDPyLockWrapper.hxx"
+
+#include "MEDPresentationCutSegment.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 MEDPresentationCutSegment::TYPE_NAME = "MEDPresentationCutSegment";
+const std::string MEDPresentationCutSegment::PROP_POINT1_X = "cutPoint1_X";
+const std::string MEDPresentationCutSegment::PROP_POINT1_Y = "cutPoint1_Y";
+const std::string MEDPresentationCutSegment::PROP_POINT1_Z = "cutPoint1_Z";
+const std::string MEDPresentationCutSegment::PROP_POINT2_X = "cutPoint2_X";
+const std::string MEDPresentationCutSegment::PROP_POINT2_Y = "cutPoint2_Y";
+const std::string MEDPresentationCutSegment::PROP_POINT2_Z = "cutPoint2_Z";
+
+
+MEDPresentationCutSegment::MEDPresentationCutSegment(const MEDCALC::CutSegmentParameters& params,
+ const MEDCALC::ViewModeType viewMode) :
+ MEDPresentation(params.fieldHandlerId, TYPE_NAME, viewMode, params.colorMap, params.scalarBarRange),
+ _params(params)
+{
+ setDoubleProperty(MEDPresentationCutSegment::PROP_POINT1_X, params.point1[0]);
+ setDoubleProperty(MEDPresentationCutSegment::PROP_POINT1_Y, params.point1[1]);
+ setDoubleProperty(MEDPresentationCutSegment::PROP_POINT1_Z, params.point1[2]);
+ setDoubleProperty(MEDPresentationCutSegment::PROP_POINT2_X, params.point2[0]);
+ setDoubleProperty(MEDPresentationCutSegment::PROP_POINT2_Y, params.point2[1]);
+ setDoubleProperty(MEDPresentationCutSegment::PROP_POINT2_Z, params.point2[2]);
+
+ int id = GeneratePythonId();
+ std::ostringstream oss_ch;
+ oss_ch << "__chartViewDisp" << id;
+ _chartViewDispVar = oss_ch.str();
+}
+
+MEDPresentationCutSegment::~MEDPresentationCutSegment() {
+ //3D Presentation is erased by base class descructor,
+ // hide only 2D Presentation here:
+ std::ostringstream oss;
+ oss << "pvs.Hide(" << _objVar << ", " << getChartViewVar() << ");";
+ oss << getChartViewVar() << ".Update();";
+ pushAndExecPyLine(oss.str());
+}
+
+void
+MEDPresentationCutSegment::internalGeneratePipeline()
+{
+ MEDPresentation::internalGeneratePipeline();
+
+ MEDPyLockWrapper lock;
+
+ createSource();
+ setTimestamp();
+
+ fillAvailableFieldComponents();
+ setOrCreateRenderView();
+ setOrCreateChartView();
+
+ std::ostringstream oss;
+ oss << _objVar << "= pvs.PlotOverLine(Input=" << _srcObjVar << ");";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ // Get bouding box "min" and "max" as initial values of
+ oss << "P1 = " << _objVar << ".Source.Point1.GetData()"; // Source.Point1 is paraview.servermanager.VectorProperty, so call GetData()
+ execPyLine(oss.str()); oss.str("");
+ PyObject * obj1 = getPythonObjectFromMain("P1");
+ if (obj1 && PyList_Check(obj1)) {
+ PyObject* objP0 = PyList_GetItem(obj1, 0);
+ PyObject* objP1 = PyList_GetItem(obj1, 1);
+ PyObject* objP2 = PyList_GetItem(obj1, 2);
+ if (PyFloat_Check(objP0) && PyFloat_Check(objP1) && PyFloat_Check(objP2)) {
+ _params.point1[0] = PyFloat_AsDouble(objP0);
+ _params.point1[1] = PyFloat_AsDouble(objP1);
+ _params.point1[2] = PyFloat_AsDouble(objP2);
+ }
+ }
+
+ oss << "P2 = " << _objVar << ".Source.Point2.GetData()"; // Source.Point2 is paraview.servermanager.VectorProperty, so call GetData()
+ execPyLine(oss.str()); oss.str("");
+ PyObject * obj2 = getPythonObjectFromMain("P2");
+ if (obj2 && PyList_Check(obj2)) {
+ PyObject* objP0 = PyList_GetItem(obj2, 0);
+ PyObject* objP1 = PyList_GetItem(obj2, 1);
+ PyObject* objP2 = PyList_GetItem(obj2, 2);
+ if (PyFloat_Check(objP0) && PyFloat_Check(objP1) && PyFloat_Check(objP2)) {
+ _params.point2[0] = PyFloat_AsDouble(objP0);
+ _params.point2[1] = PyFloat_AsDouble(objP1);
+ _params.point2[2] = PyFloat_AsDouble(objP2);
+ }
+ }
+
+ // To update GUI
+ setDoubleProperty(MEDPresentationCutSegment::PROP_POINT1_X, _params.point1[0]);
+ setDoubleProperty(MEDPresentationCutSegment::PROP_POINT1_Y, _params.point1[1]);
+ setDoubleProperty(MEDPresentationCutSegment::PROP_POINT1_Z, _params.point1[2]);
+ setDoubleProperty(MEDPresentationCutSegment::PROP_POINT2_X, _params.point2[0]);
+ setDoubleProperty(MEDPresentationCutSegment::PROP_POINT2_Y, _params.point2[1]);
+ setDoubleProperty(MEDPresentationCutSegment::PROP_POINT2_Z, _params.point2[2]);
+
+ showObject();
+ colorBy(); // see initFieldInfo() - necessarily POINTS because of the conversion above
+ showScalarBar();
+ selectColorMap();
+ rescaleTransferFunction();
+ resetCameraAndRender();
+}
+
+void
+MEDPresentationCutSegment::updatePipeline(const MEDCALC::CutSegmentParameters& params)
+{
+ if (params.fieldHandlerId != _params.fieldHandlerId)
+ throw KERNEL::createSalomeException("Unexpected updatePipeline error! Mismatching fieldHandlerId!");
+
+ if (params.colorMap != _params.colorMap)
+ updateColorMap<MEDPresentationCutSegment, MEDCALC::CutSegmentParameters>(params.colorMap);
+
+ if (params.scalarBarRange != _params.scalarBarRange ||
+ params.hideDataOutsideCustomRange != _params.hideDataOutsideCustomRange ||
+ params.scalarBarRangeArray[0] != _params.scalarBarRangeArray[0] ||
+ params.scalarBarRangeArray[1] != _params.scalarBarRangeArray[1])
+ updateScalarBarRange<MEDPresentationCutSegment, MEDCALC::CutSegmentParameters>(params.scalarBarRange,
+ params.hideDataOutsideCustomRange,
+ params.scalarBarRangeArray[0],
+ params.scalarBarRangeArray[1]);
+
+ if (params.point1[0] != _params.point1[0] ||
+ params.point1[2] != _params.point1[1] ||
+ params.point1[1] != _params.point1[2])
+ updatePoint1(params.point1);
+
+ if (params.point2[0] != _params.point2[0] ||
+ params.point2[2] != _params.point2[1] ||
+ params.point2[1] != _params.point2[2])
+ updatePoint2(params.point2);
+
+ if (params.visibility != _params.visibility)
+ updateVisibility<MEDPresentationCutSegment, MEDCALC::CutSegmentParameters>(params.visibility);
+ if (params.scalarBarVisibility != _params.scalarBarVisibility)
+ updateScalarBarVisibility<MEDPresentationCutSegment, MEDCALC::CutSegmentParameters>(params.scalarBarVisibility);
+}
+
+void
+MEDPresentationCutSegment::updatePoint1(MEDCALC::DoubleArray point1)
+{
+ _params.point1[0] = point1[0];
+ _params.point1[1] = point1[1];
+ _params.point1[2] = point1[2];
+
+ // GUI helper:
+ setDoubleProperty(MEDPresentationCutSegment::PROP_POINT1_X, point1[0]);
+ setDoubleProperty(MEDPresentationCutSegment::PROP_POINT1_Y, point1[1]);
+ setDoubleProperty(MEDPresentationCutSegment::PROP_POINT1_Z, point1[2]);
+
+ // Update Point1
+ std::ostringstream oss;
+ oss << _objVar << ".Source.Point1 = [" <<
+ _params.point1[0] << ", " <<
+ _params.point1[1] << ", " <<
+ _params.point1[2] << "];";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ oss << getChartViewVar() << ".Update();";
+ oss << "pvs.Render();";
+ pushAndExecPyLine(oss.str());
+}
+
+void
+MEDPresentationCutSegment::updatePoint2(MEDCALC::DoubleArray point2)
+{
+ _params.point2[0] = point2[0];
+ _params.point2[1] = point2[1];
+ _params.point2[2] = point2[2];
+
+ // GUI helper:
+ setDoubleProperty(MEDPresentationCutSegment::PROP_POINT2_X, point2[0]);
+ setDoubleProperty(MEDPresentationCutSegment::PROP_POINT2_Y, point2[1]);
+ setDoubleProperty(MEDPresentationCutSegment::PROP_POINT2_Z, point2[2]);
+
+ // Update Point2
+ std::ostringstream oss;
+ oss << _objVar << ".Source.Point2 = [" <<
+ _params.point2[0] << ", " <<
+ _params.point2[1] << ", " <<
+ _params.point2[2] << "];";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ oss << getChartViewVar() << ".Update();";
+ oss << "pvs.Render();";
+ pushAndExecPyLine(oss.str());
+}
+
+std::string MEDPresentationCutSegment::getChartViewVar() const {
+ std::ostringstream oss;
+ oss << "__chartView" << getPyViewID();
+ return oss.str();
+}
+
+void MEDPresentationCutSegment::setOrCreateChartView() {
+ std::string lineChartViewName = getChartViewVar();
+ std::ostringstream oss;
+ oss << lineChartViewName << " = medcalc.FindOrCreateView('XYChartView');";
+ pushAndExecPyLine(oss.str());
+}
+
+void MEDPresentationCutSegment::visibility() {
+ // Base class implementation: hide 3D presentation in the RenderView
+ MEDPresentation::visibility();
+ // Show/Hide 2D Presenation
+ std::ostringstream oss;
+ oss << getChartViewDispVar() << ".Visibility = " << (_presentationVisibility ? "True" : "False") << ";";
+ oss << getChartViewVar() << ".Update();";
+ pushAndExecPyLine(oss.str());
+}
+
+void MEDPresentationCutSegment::showObject() {
+ // 3D Presentation:
+ MEDPresentation::showObject();
+
+ // 2D Presentation:
+ std::ostringstream oss;
+ std::ostringstream oss_series;
+ oss_series << _fieldName;
+ if (_nbComponents > 1) {
+ oss_series << "_Magnitude";
+ }
+ oss << _chartViewDispVar << " = pvs.Show(" << _objVar << ", " << getChartViewVar() << ", 'XYChartRepresentation');";
+ oss << _chartViewDispVar << ".SeriesVisibility = ['" << oss_series.str() << "'];";
+ oss << getChartViewVar() << ".Update();";
+ pushAndExecPyLine(oss.str());
+}
+
+void MEDPresentationCutSegment::hideObject() {
+ // 3D Presentation:
+ MEDPresentation::hideObject();
+
+ // 2D Presentation:
+ std::ostringstream oss;
+ oss << "pvs.Hide(" << _objVar << ", " << getChartViewVar() << ");";
+ oss << getChartViewVar() << ".Update();";
+ pushAndExecPyLine(oss.str());
+}
+
+std::string MEDPresentationCutSegment::getChartViewDispVar() {
+ return _chartViewDispVar;
+}
+
+bool MEDPresentationCutSegment::activateView() {
+ // if XYChartView of current MEDPresentationCutSegment is active, keep it active
+ // Owerwise call impplementation of base class
+ MEDPyLockWrapper lock;
+ execPyLine("__XYChartViewAlive = " + getChartViewDispVar() + " in pvs.GetActiveView()");
+ PyObject * obj = getPythonObjectFromMain("__XYChartViewAlive");
+ bool XYChartViewAlive = true;
+ if (obj && PyBool_Check(obj))
+ XYChartViewAlive = (obj == Py_True);
+ if (!XYChartViewAlive) {
+ return MEDPresentation::activateView();
+ }
+ return XYChartViewAlive;
+}
+
+MEDCALC::PresentationVisibility
+MEDPresentationCutSegment::presentationStateInActiveView() {
+ MEDPyLockWrapper lock;
+ MEDCALC::PresentationVisibility result = MEDCALC::PRESENTATION_NOT_IN_VIEW;
+
+ execPyLine("__isInView = ( " + getRenderViewVar() + " == pvs.GetActiveView() or "\
+ + getChartViewVar() +" == pvs.GetActiveView())");
+ PyObject * obj = getPythonObjectFromMain("__isInView");
+
+ if (obj && PyBool_Check(obj) && (obj == Py_True)) {
+ result = _presentationVisibility ? MEDCALC::PRESENTATION_VISIBLE : MEDCALC::PRESENTATION_INVISIBLE;
+ }
+ return result;
+}
+
+std::string MEDPresentationCutSegment::additionalThresholdInitializationActions() {
+ if (_hideDataOutsideCustomRange) {
+ std::ostringstream oss;
+ ComponentThresold& currentThreshold = _presentationThresolds[getThresholdIndex()];
+ oss << currentThreshold._thresholdVar << ".AllScalars = 0;";
+ return oss.str();
+ }
+ return "";
+}
--- /dev/null
+// Copyright (C) 2016-2021 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_CMP_MEDPRESENTATION_CUT_SEGMENT_HXX_
+#define SRC_MEDCALC_CMP_MEDPRESENTATION_CUT_SEGMENT_HXX_
+
+#include "MEDCALC.hxx"
+#include "MEDPresentation.hxx"
+#include <string>
+
+class MEDCALC_EXPORT MEDPresentationCutSegment : public MEDPresentation
+{
+public:
+ static const std::string TYPE_NAME;
+ static const std::string PROP_POINT1_X;
+ static const std::string PROP_POINT1_Y;
+ static const std::string PROP_POINT1_Z;
+ static const std::string PROP_POINT2_X;
+ static const std::string PROP_POINT2_Y;
+ static const std::string PROP_POINT2_Z;
+
+ MEDPresentationCutSegment(const MEDCALC::CutSegmentParameters& params, const MEDCALC::ViewModeType viewMode);
+ virtual ~MEDPresentationCutSegment();
+
+ void updatePipeline(const MEDCALC::CutSegmentParameters& params);
+
+ void getParameters(MEDCALC::CutSegmentParameters & params) const { params = _params; } ;
+ void setParameters(const MEDCALC::CutSegmentParameters & params) { _params = params; } ;
+
+ bool activateView() override;
+ MEDCALC::PresentationVisibility presentationStateInActiveView() override;
+
+protected:
+ virtual void internalGeneratePipeline();
+ void updatePoint1(const MEDCALC::DoubleArray);
+ void updatePoint2(const MEDCALC::DoubleArray);
+
+ std::string getChartViewVar() const;
+ void setOrCreateChartView();
+ std::string getChartViewDispVar();
+
+ std::string additionalThresholdInitializationActions() override;
+ void visibility() override;
+ void showObject() override;
+ void hideObject() override;
+
+
+private:
+ MEDCALC::CutSegmentParameters _params;
+ std::string _chartViewDispVar;
+};
+
+#endif
\ No newline at end of file
if (params.fieldHandlerId != _params.fieldHandlerId)
throw KERNEL::createSalomeException("Unexpected updatePipeline error! Mismatching fieldHandlerId!");
- if (params.scalarBarRange != _params.scalarBarRange)
+ if (params.scalarBarRange != _params.scalarBarRange ||
+ params.hideDataOutsideCustomRange != _params.hideDataOutsideCustomRange ||
+ params.scalarBarRangeArray[0] != _params.scalarBarRangeArray[0] ||
+ params.scalarBarRangeArray[1] != _params.scalarBarRangeArray[1])
{
- updateScalarBarRange<MEDPresentationDeflectionShape, MEDCALC::DeflectionShapeParameters>(params.scalarBarRange);
+ updateScalarBarRange<MEDPresentationDeflectionShape, MEDCALC::DeflectionShapeParameters>(params.scalarBarRange,
+ params.hideDataOutsideCustomRange,
+ params.scalarBarRangeArray[0],
+ params.scalarBarRangeArray[1]);
autoScale();
pushAndExecPyLine("pvs.Render();");
}
if (params.colorMap != _params.colorMap)
updateColorMap<MEDPresentationDeflectionShape, MEDCALC::DeflectionShapeParameters>(params.colorMap);
+
+ if (params.visibility != _params.visibility)
+ updateVisibility<MEDPresentationDeflectionShape, MEDCALC::DeflectionShapeParameters>(params.visibility);
+
+ if (params.scalarBarVisibility != _params.scalarBarVisibility)
+ updateScalarBarVisibility<MEDPresentationDeflectionShape, MEDCALC::DeflectionShapeParameters>(params.scalarBarVisibility);
}
#include "MEDPresentationVectorField.hxx"
#include "MEDPresentationDeflectionShape.hxx"
#include "MEDPresentationPointSprite.hxx"
+#include "MEDPresentationPlot3D.hxx"
+#include "MEDPresentationStreamLines.hxx"
+#include "MEDPresentationCutSegment.hxx"
#include <SALOME_KernelServices.hxx>
STDLOG("Get presentation " << presentationID);
std::map<MEDPresentation::TypeID, MEDPresentation*>::const_iterator citr = _presentations.find(presentationID);
if (citr == _presentations.end())
- return NULL;
+ return nullptr;
return (*citr).second;
}
}
+void
+MEDPresentationManager_i::setPresentationDoubleProperty(MEDPresentation::TypeID presentationID, const char* propName,
+ const CORBA::Double propValue)
+{
+ MEDPresentation* pres = _getPresentation(presentationID);
+ if (pres)
+ pres->setDoubleProperty(propName, propValue);
+ else
+ throw KERNEL::createSalomeException("setPresentationDoubleProperty(): presentation not found!!");
+}
+
+CORBA::Double
+MEDPresentationManager_i::getPresentationDoubleProperty(MEDPresentation::TypeID presentationID, const char* propName)
+{
+ MEDPresentation* pres = _getPresentation(presentationID);
+ if (pres) {
+ return (CORBA::Double) pres->getDoubleProperty(propName);
+ }
+ else
+ throw KERNEL::createSalomeException("getPresentationIntProperty(): presentation not found!!");
+
+}
+
+
MEDPresentation::TypeID
MEDPresentationManager_i::makeMeshView(const MEDCALC::MeshViewParameters& params, const MEDCALC::ViewModeType viewMode)
{
return _makePresentation<MEDPresentationPointSprite>(params, viewMode);
}
+MEDPresentation::TypeID
+MEDPresentationManager_i::makePlot3D(const MEDCALC::Plot3DParameters& params, const MEDCALC::ViewModeType viewMode)
+{
+ return _makePresentation<MEDPresentationPlot3D>(params, viewMode);
+}
+
+MEDPresentation::TypeID
+MEDPresentationManager_i::makeStreamLines(const MEDCALC::StreamLinesParameters& params, const MEDCALC::ViewModeType viewMode)
+{
+ return _makePresentation<MEDPresentationStreamLines>(params, viewMode);
+}
+
+MEDPresentation::TypeID
+MEDPresentationManager_i::makeCutSegment(const MEDCALC::CutSegmentParameters& params, const MEDCALC::ViewModeType viewMode)
+{
+ return _makePresentation<MEDPresentationCutSegment>(params, viewMode);
+}
+
MEDCALC::MeshViewParameters
MEDPresentationManager_i::getMeshViewParameters(MEDPresentation::TypeID presentationID)
{
return tmp._retn();
}
-MEDCALC::ContourParameters
+MEDCALC::ContourParameters*
MEDPresentationManager_i::getContourParameters(MEDPresentation::TypeID presentationID)
{
MEDCALC::ContourParameters* p = new MEDCALC::ContourParameters();
return tmp._retn();
}
-MEDCALC::VectorFieldParameters
+MEDCALC::VectorFieldParameters*
MEDPresentationManager_i::getVectorFieldParameters(MEDPresentation::TypeID presentationID)
{
- MEDCALC::VectorFieldParameters* p = new MEDCALC::VectorFieldParameters();
+ MEDCALC::VectorFieldParameters* p = new MEDCALC::VectorFieldParameters;
_getParameters<MEDPresentationVectorField>(presentationID, *p);
MEDCALC::VectorFieldParameters_var tmp(p);
return tmp._retn();
return tmp._retn();
}
-MEDCALC::DeflectionShapeParameters
+MEDCALC::Plot3DParameters*
+MEDPresentationManager_i::getPlot3DParameters(MEDPresentation::TypeID presentationID)
+{
+ MEDCALC::Plot3DParameters* p = new MEDCALC::Plot3DParameters();
+ _getParameters<MEDPresentationPlot3D>(presentationID, *p);
+ MEDCALC::Plot3DParameters_var tmp(p);
+ return tmp._retn();
+}
+
+MEDCALC::StreamLinesParameters*
+MEDPresentationManager_i::getStreamLinesParameters(MEDPresentation::TypeID presentationID)
+{
+ MEDCALC::StreamLinesParameters* p = new MEDCALC::StreamLinesParameters();
+ _getParameters<MEDPresentationStreamLines>(presentationID, *p);
+ MEDCALC::StreamLinesParameters_var tmp(p);
+ return tmp._retn();
+}
+
+MEDCALC::CutSegmentParameters*
+MEDPresentationManager_i::getCutSegmentParameters(MEDPresentation::TypeID presentationID)
+{
+ MEDCALC::CutSegmentParameters* p = new MEDCALC::CutSegmentParameters();
+ _getParameters<MEDPresentationCutSegment>(presentationID, *p);
+ MEDCALC::CutSegmentParameters_var tmp(p);
+ return tmp._retn();
+}
+
+MEDCALC::DeflectionShapeParameters*
MEDPresentationManager_i::getDeflectionShapeParameters(MEDPresentation::TypeID presentationID)
{
MEDCALC::DeflectionShapeParameters* p = new MEDCALC::DeflectionShapeParameters();
return _updatePresentation<MEDPresentationPointSprite>(presentationID, params);
}
+void
+MEDPresentationManager_i::updatePlot3D(MEDPresentation::TypeID presentationID, const MEDCALC::Plot3DParameters& params)
+{
+ return _updatePresentation<MEDPresentationPlot3D>(presentationID, params);
+}
+
+void
+MEDPresentationManager_i::updateStreamLines(MEDPresentation::TypeID presentationID, const MEDCALC::StreamLinesParameters& params)
+{
+ return _updatePresentation<MEDPresentationStreamLines>(presentationID, params);
+}
+
+void
+MEDPresentationManager_i::updateCutSegment(MEDPresentation::TypeID presentationID, const MEDCALC::CutSegmentParameters& params)
+{
+ return _updatePresentation<MEDPresentationCutSegment>(presentationID, params);
+}
+
CORBA::Boolean
MEDPresentationManager_i::removePresentation(MEDPresentation::TypeID presentationID)
{
STDLOG("Remove presentation " << presentationID);
- std::map<MEDPresentation::TypeID, MEDPresentation*>::const_iterator citr = _presentations.find(presentationID);
- if (citr == _presentations.end()) {
- std::cerr << "removePresentation(): presentation not found!!" << std::endl;
+ MEDPresentation* presentation = _getPresentation(presentationID);
+
+ if (!presentation)
return false;
- }
- MEDPresentation* presentation = (*citr).second;
- if (presentation)
- delete presentation;
+
+ delete presentation;
_presentations.erase(presentationID);
STDLOG("Presentation " << presentationID << " has been removed.");
return presList;
}
+MEDCALC::PresentationVisibility
+MEDPresentationManager_i::stateInActiveView(MEDPresentation::TypeID presentationID)
+{
+ MEDPresentation* pres = _getPresentation(presentationID);
+ if (pres)
+ return pres->presentationStateInActiveView();
+ else
+ throw KERNEL::createSalomeException("stateInActiveView(): presentation not found!!");
+}
+
+
void
MEDPresentationManager_i::cleanUp()
{
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 makePlot3D(const MEDCALC::Plot3DParameters&, const MEDCALC::ViewModeType);
+ MEDCALC_EXPORT MEDPresentation::TypeID makeStreamLines(const MEDCALC::StreamLinesParameters&, const MEDCALC::ViewModeType);
+ MEDCALC_EXPORT MEDPresentation::TypeID makeCutSegment(const MEDCALC::CutSegmentParameters&, 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 void setPresentationIntProperty(MEDPresentation::TypeID presentationID, const char* propName, const CORBA::Long propValue);
MEDCALC_EXPORT CORBA::Long getPresentationIntProperty(MEDPresentation::TypeID presentationID, const char* propName);
+ MEDCALC_EXPORT void setPresentationDoubleProperty(MEDPresentation::TypeID presentationID, const char* propName, const CORBA::Double propValue);
+ MEDCALC_EXPORT CORBA::Double getPresentationDoubleProperty(MEDPresentation::TypeID presentationID, const char* propName);
+
MEDCALC_EXPORT MEDCALC::MeshViewParameters getMeshViewParameters(MEDPresentation::TypeID presentationID);
MEDCALC_EXPORT MEDCALC::ScalarMapParameters* getScalarMapParameters(MEDPresentation::TypeID presentationID);
- MEDCALC_EXPORT MEDCALC::ContourParameters getContourParameters(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::VectorFieldParameters* getVectorFieldParameters(MEDPresentation::TypeID presentationID);
MEDCALC_EXPORT MEDCALC::PointSpriteParameters* getPointSpriteParameters(MEDPresentation::TypeID presentationID);
- MEDCALC_EXPORT MEDCALC::DeflectionShapeParameters getDeflectionShapeParameters(MEDPresentation::TypeID presentationID);
+ MEDCALC_EXPORT MEDCALC::Plot3DParameters* getPlot3DParameters(MEDPresentation::TypeID presentationID);
+ MEDCALC_EXPORT MEDCALC::DeflectionShapeParameters* getDeflectionShapeParameters(MEDPresentation::TypeID presentationID);
+ MEDCALC_EXPORT MEDCALC::StreamLinesParameters* getStreamLinesParameters(MEDPresentation::TypeID presentationID);
+ MEDCALC_EXPORT MEDCALC::CutSegmentParameters* getCutSegmentParameters(MEDPresentation::TypeID presentationID);
MEDCALC_EXPORT void updateMeshView(MEDPresentation::TypeID, const MEDCALC::MeshViewParameters&);
MEDCALC_EXPORT void updateScalarMap(MEDPresentation::TypeID, const MEDCALC::ScalarMapParameters&);
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 updatePlot3D(MEDPresentation::TypeID, const MEDCALC::Plot3DParameters&);
+ MEDCALC_EXPORT void updateStreamLines(MEDPresentation::TypeID, const MEDCALC::StreamLinesParameters&);
+ MEDCALC_EXPORT void updateCutSegment(MEDPresentation::TypeID, const MEDCALC::CutSegmentParameters&);
MEDCALC_EXPORT CORBA::Boolean removePresentation(MEDPresentation::TypeID);
MEDCALC_EXPORT CORBA::Boolean activateView(MEDPresentation::TypeID);
MEDCALC_EXPORT char * getParavisDump(MEDPresentation::TypeID presentationID);
MEDCALC_EXPORT MEDCALC::PresentationsList* getAllPresentations();
MEDCALC_EXPORT void cleanUp();
+ MEDCALC_EXPORT MEDCALC::PresentationVisibility stateInActiveView(MEDPresentation::TypeID presentationID);
private:
MEDPresentationManager_i();
if (params.mode != _params.mode)
updateMeshMode(params.mode);
+ if (params.visibility != _params.visibility)
+ updateVisibility<MEDPresentationMeshView, MEDCALC::MeshViewParameters>(params.visibility);
+
}
void
virtual void recreateViewSetup();
+ virtual void showScalarBar() override {};
+ virtual void hideScalarBar() override {};
+
protected:
void updateMeshMode(const MEDCALC::MeshModeType mode);
virtual void internalGeneratePipeline();
--- /dev/null
+// Copyright (C) 2016-2021 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 "MEDPyLockWrapper.hxx"
+
+#include "MEDPresentationPlot3D.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 MEDPresentationPlot3D::TYPE_NAME = "MEDPresentationPlot3D";
+const std::string MEDPresentationPlot3D::PROP_PLANE_NORMAL_X = "planeNormalX";
+const std::string MEDPresentationPlot3D::PROP_PLANE_NORMAL_Y = "planeNormalY";
+const std::string MEDPresentationPlot3D::PROP_PLANE_NORMAL_Z = "planeNormalZ";
+const std::string MEDPresentationPlot3D::PROP_PLANE_POS = "planePos";
+const std::string MEDPresentationPlot3D::PROP_IS_PLANAR = "isPlanar";
+
+
+MEDPresentationPlot3D::MEDPresentationPlot3D(const MEDCALC::Plot3DParameters& params,
+ const MEDCALC::ViewModeType viewMode) :
+ MEDPresentation(params.fieldHandlerId, TYPE_NAME, viewMode, params.colorMap, params.scalarBarRange),
+ _params(params)
+{
+ setDoubleProperty(MEDPresentationPlot3D::PROP_PLANE_NORMAL_X, params.planeNormal[0]);
+ setDoubleProperty(MEDPresentationPlot3D::PROP_PLANE_NORMAL_Y, params.planeNormal[1]);
+ setDoubleProperty(MEDPresentationPlot3D::PROP_PLANE_NORMAL_Z, params.planeNormal[2]);
+ setDoubleProperty(MEDPresentationPlot3D::PROP_PLANE_POS, params.planePos);
+
+ _isPlanar = 0;
+ setIntProperty(MEDPresentationPlot3D::PROP_IS_PLANAR, _isPlanar);
+}
+
+void
+MEDPresentationPlot3D::initFieldMeshInfos()
+{
+ MEDPresentation::initFieldMeshInfos();
+ _colorByType = "POINTS";
+}
+
+
+void
+MEDPresentationPlot3D::getSliceObj()
+{
+ std::ostringstream oss;
+ oss << "__objSlice";
+ _objSlice = oss.str(); oss.str("");
+
+ oss << _objSlice << " = pvs.Slice(" << _srcObjVar << ");";
+ pushAndExecPyLine(oss.str()); oss.str("");
+
+ oss << _objSlice << ".SliceType.Normal = [" <<
+ _params.planeNormal[0] << ", " <<
+ _params.planeNormal[1] << ", " <<
+ _params.planeNormal[2] << "];";
+ pushAndExecPyLine(oss.str()); oss.str("");
+
+ oss << "slicePos = medcalc.GetPositions(" << _srcObjVar << ", [" <<
+ _params.planeNormal[0] << ", " <<
+ _params.planeNormal[1] << ", " <<
+ _params.planeNormal[2] << "]," <<
+ _params.planePos << ");";
+ pushAndExecPyLine(oss.str()); oss.str("");
+
+ oss << _objSlice << ".SliceType.Origin = slicePos";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ oss << _objVar << " = " << _objSlice;
+ execPyLine(oss.str()); oss.str("");
+}
+
+void
+MEDPresentationPlot3D::getMagnitude()
+{
+ std::ostringstream oss;
+ oss << "__objCalc";
+ _objCalc = oss.str(); oss.str("");
+
+ oss << _objCalc <<"= pvs.Calculator(Input=" << _objSlice << ");";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ if (_pvFieldType == "CELLS") {
+ oss << _objCalc << ".AttributeType = 'Cell Data'";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ }
+ oss << _objCalc << ".ResultArrayName = 'resCalcMag'";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ std::string fieldName = _fieldName;
+ if(_nbComponents == 2)
+ fieldName += "_Vector";
+ oss << _objCalc << ".Function = 'mag(" << fieldName << ")'";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ execPyLine(oss.str()); oss.str("");
+}
+
+void
+MEDPresentationPlot3D::internalGeneratePipeline()
+{
+ MEDPresentation::internalGeneratePipeline();
+
+ MEDPyLockWrapper lock;
+
+ createSource();
+ setTimestamp();
+
+ fillAvailableFieldComponents();
+ setOrCreateRenderView();
+
+ std::ostringstream oss;
+ oss << "is_planar = medcalc.IsPlanarObj("<< _srcObjVar<<");";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ getPythonObjectFromMain("is_planar");
+ PyObject * obj = getPythonObjectFromMain("is_planar");
+
+ // Planar mesh?
+ if (obj && PyBool_Check(obj) && (obj == Py_False))
+ {
+ getSliceObj();
+ }
+ else
+ {
+ oss << "__objSlice";
+ _objSlice = oss.str(); oss.str("");
+ oss << _objSlice << " = " << _srcObjVar;
+ execPyLine(oss.str()); oss.str("");
+ _isPlanar = 1;
+ setIntProperty(MEDPresentationPlot3D::PROP_IS_PLANAR, _isPlanar);
+ }
+ // Vector field?
+ if(_nbComponents > 1)
+ {
+ getMagnitude();
+ oss << "scalarArray = "<< _objCalc << ".ResultArrayName;";
+ execPyLine(oss.str()); oss.str("");
+ }
+ else
+ {
+ oss << "__objCalc";
+ _objCalc = oss.str(); oss.str("");
+ oss << _objCalc << " = " << _objSlice;
+ execPyLine(oss.str()); oss.str("");
+ }
+ // cell data?
+ if (_pvFieldType == "CELLS")
+ {
+ oss << _objCalc << " = pvs.CellDatatoPointData(" << _objCalc << ");";
+ oss << _objCalc << ".PassCellData = 1;";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ }
+
+ oss << _objVar << " = pvs.WarpByScalar(Input=" << _objCalc << ");";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ if(_nbComponents > 1)
+ oss << _objVar << ".Scalars = ['" << "POINTS" << "', " << "scalarArray]";
+ else
+ oss << _objVar << ".Scalars = ['" << "POINTS" << "', '" << _fieldName << "']";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ if (obj && PyBool_Check(obj) && (obj == Py_False))
+ {
+ oss << _objVar << ".Normal = [" <<
+ _params.planeNormal[0] << ", " <<
+ _params.planeNormal[1] << ", " <<
+ _params.planeNormal[2] << "];";
+ }
+ else
+ {
+ oss << "P2 = " << "medcalc.GetPlaneNormalVector(" << _objSlice << ")";
+ execPyLine(oss.str()); oss.str("");
+ PyObject * obj2 = getPythonObjectFromMain("P2");
+ if (obj2 && PyList_Check(obj2)) {
+ PyObject* objP0 = PyList_GetItem(obj2, 0);
+ PyObject* objP1 = PyList_GetItem(obj2, 1);
+ PyObject* objP2 = PyList_GetItem(obj2, 2);
+ if (PyFloat_Check(objP0) && PyFloat_Check(objP1) && PyFloat_Check(objP2)) {
+ _params.planeNormal[0] = PyFloat_AsDouble(objP0);
+ _params.planeNormal[1] = PyFloat_AsDouble(objP1);
+ _params.planeNormal[2] = PyFloat_AsDouble(objP2);
+ }
+ }
+
+ setDoubleProperty(MEDPresentationPlot3D::PROP_PLANE_NORMAL_X, _params.planeNormal[0]);
+ setDoubleProperty(MEDPresentationPlot3D::PROP_PLANE_NORMAL_Y, _params.planeNormal[1]);
+ setDoubleProperty(MEDPresentationPlot3D::PROP_PLANE_NORMAL_Z, _params.planeNormal[2]);
+ oss << _objVar << ".Normal = " << "medcalc.GetPlaneNormalVector(" << _objSlice << ")";
+ }
+ pushAndExecPyLine(oss.str()); oss.str("");
+
+ showObject();
+ colorBy(); // see initFieldInfo() - necessarily POINTS because of the conversion above
+ showScalarBar();
+ selectColorMap();
+ rescaleTransferFunction();
+ resetCameraAndRender();
+}
+
+void
+MEDPresentationPlot3D::updatePipeline(const MEDCALC::Plot3DParameters& params)
+{
+ if (params.fieldHandlerId != _params.fieldHandlerId)
+ throw KERNEL::createSalomeException("Unexpected updatePipeline error! Mismatching fieldHandlerId!");
+
+ if (params.colorMap != _params.colorMap)
+ updateColorMap<MEDPresentationPlot3D, MEDCALC::Plot3DParameters>(params.colorMap);
+
+ if (params.scalarBarRange != _params.scalarBarRange ||
+ params.hideDataOutsideCustomRange != _params.hideDataOutsideCustomRange ||
+ params.scalarBarRangeArray[0] != _params.scalarBarRangeArray[0] ||
+ params.scalarBarRangeArray[1] != _params.scalarBarRangeArray[1])
+ updateScalarBarRange<MEDPresentationPlot3D, MEDCALC::Plot3DParameters>(params.scalarBarRange,
+ params.hideDataOutsideCustomRange,
+ params.scalarBarRangeArray[0],
+ params.scalarBarRangeArray[1]);
+
+ if (params.planeNormal[0] != _params.planeNormal[0] ||
+ params.planeNormal[1] != _params.planeNormal[1] ||
+ params.planeNormal[2] != _params.planeNormal[2])
+ updatePlaneNormal(params.planeNormal);
+
+ if (_isPlanar == 0 && params.planePos != _params.planePos)
+ updatePlanePos(params.planePos);
+
+ if (params.visibility != _params.visibility)
+ updateVisibility<MEDPresentationPlot3D, MEDCALC::Plot3DParameters>(params.visibility);
+ if (params.scalarBarVisibility != _params.scalarBarVisibility)
+ updateScalarBarVisibility<MEDPresentationPlot3D, MEDCALC::Plot3DParameters>(params.scalarBarVisibility);
+}
+
+void
+MEDPresentationPlot3D::updatePlaneNormal(MEDCALC::DoubleArray planeNormal)
+{
+ _params.planeNormal[0] = planeNormal[0];
+ _params.planeNormal[1] = planeNormal[1];
+ _params.planeNormal[2] = planeNormal[2];
+
+ // GUI helper:
+ setDoubleProperty(MEDPresentationPlot3D::PROP_PLANE_NORMAL_X, planeNormal[0]);
+ setDoubleProperty(MEDPresentationPlot3D::PROP_PLANE_NORMAL_Y, planeNormal[1]);
+ setDoubleProperty(MEDPresentationPlot3D::PROP_PLANE_NORMAL_Z, planeNormal[2]);
+
+ // Update Plane Normal
+ {
+ MEDPyLockWrapper lock;
+ std::ostringstream oss;
+ if(_isPlanar == 0)
+ {
+ oss << _objSlice << ".SliceType.Normal = [" <<
+ _params.planeNormal[0] << ", " <<
+ _params.planeNormal[1] << ", " <<
+ _params.planeNormal[2] << "];";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ updatePlanePos(_params.planePos);
+ }
+
+ oss << _objVar << ".Normal = [" <<
+ _params.planeNormal[0] << ", " <<
+ _params.planeNormal[1] << ", " <<
+ _params.planeNormal[2] << "];";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ pushAndExecPyLine("pvs.Render();");
+ }
+}
+
+void
+MEDPresentationPlot3D::updatePlanePos(const double planePos)
+{
+ _params.planePos = planePos;
+
+ // GUI helper:
+ setDoubleProperty(MEDPresentationPlot3D::PROP_PLANE_POS, planePos);
+
+ // Update Plane Position
+ {
+ MEDPyLockWrapper lock;
+ std::ostringstream oss;
+ oss << "slicePos = medcalc.GetPositions(" << _srcObjVar << ", [" <<
+ _params.planeNormal[0] << ", " <<
+ _params.planeNormal[1] << ", " <<
+ _params.planeNormal[2] << "]," <<
+ _params.planePos << ");";
+ pushAndExecPyLine(oss.str()); oss.str("");
+
+ oss << _objSlice << ".SliceType.Origin = slicePos";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ pushAndExecPyLine("pvs.Render();");
+ }
+}
\ No newline at end of file
--- /dev/null
+// Copyright (C) 2016-2021 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_CMP_MEDPRESENTATION_PLOT3D_HXX_
+#define SRC_MEDCALC_CMP_MEDPRESENTATION_PLOT3D_HXX_
+
+#include "MEDCALC.hxx"
+#include "MEDPresentation.hxx"
+#include <string>
+
+class MEDCALC_EXPORT MEDPresentationPlot3D : public MEDPresentation
+{
+public:
+ static const std::string TYPE_NAME;
+ static const std::string PROP_PLANE_NORMAL_X;
+ static const std::string PROP_PLANE_NORMAL_Y;
+ static const std::string PROP_PLANE_NORMAL_Z;
+ static const std::string PROP_PLANE_POS;
+ static const std::string PROP_IS_PLANAR;
+
+ MEDPresentationPlot3D(const MEDCALC::Plot3DParameters& params, const MEDCALC::ViewModeType viewMode);
+ virtual ~MEDPresentationPlot3D() {}
+
+ void updatePipeline(const MEDCALC::Plot3DParameters& params);
+
+ void getParameters(MEDCALC::Plot3DParameters & params) const { params = _params; } ;
+ void setParameters(const MEDCALC::Plot3DParameters & params) { _params = params; } ;
+
+ void initFieldMeshInfos() override;
+
+
+protected:
+ virtual void internalGeneratePipeline();
+ void getSliceObj();
+ void getMagnitude();
+ void updatePlaneNormal(const MEDCALC::DoubleArray);
+ void updatePlanePos(const double);
+ std::string _objSlice;
+ std::string _objCalc;
+
+private:
+ MEDCALC::Plot3DParameters _params;
+ int _isPlanar;
+};
+
+#endif
\ No newline at end of file
MEDPresentationPointSprite::MEDPresentationPointSprite(const MEDCALC::PointSpriteParameters& params,
const MEDCALC::ViewModeType viewMode) :
- MEDPresentation(params.fieldHandlerId, TYPE_NAME, viewMode, params.colorMap, params.scalarBarRange), _params(params)
+ MEDPresentation(params.fieldHandlerId, TYPE_NAME, viewMode, params.colorMap, params.scalarBarRange), _params(params),
+ _gaussianRadius(0.0)
{
}
int nbCompo = getIntProperty(MEDPresentation::PROP_NB_COMPONENTS);
// set component or euclidean norm as the array to scale the ball radius
- if (nbCompo > 1)
- {
- if (_selectedComponentIndex == -1)
- oss << _dispVar << ".ScaleArrayComponent = 'Magnitude';";
- else
- oss << _dispVar << ".ScaleArrayComponent = " << _selectedComponentIndex << ";";
- pushAndExecPyLine(oss.str()); oss.str("");
+ if (!_hideDataOutsideCustomRange) {
+ if (nbCompo > 1)
+ {
+ if (_selectedComponentIndex == -1)
+ oss << _dispVar << ".ScaleArrayComponent = 'Magnitude';";
+ else
+ oss << _dispVar << ".ScaleArrayComponent = " << _selectedComponentIndex << ";";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ }
+ }
+ else {
+ oss << getDispVar() << ".SetScaleArray = ['POINTS', '" << getThresholdFieldName() << "'];";
+ oss << getDispVar() << ".ScaleArrayComponent = " << 0 << ";";
}
// 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("");
+ oss << getDispVar() << ".ScaleTransferFunction.RescaleTransferFunction(" << _rangeVar << "[0], " << _rangeVar << "[1]);";
+ pushAndExecPyLine(oss.str());
}
// Make the radius twice the default radius
oss << _dispVar << ".GaussianRadius = 2*" << _dispVar << ".GaussianRadius" << ";";
+ oss <<"__gr = "<< _dispVar << ".GaussianRadius";
pushAndExecPyLine(oss.str()); oss.str("");
+
+ PyObject * obj = getPythonObjectFromMain("__gr");
+ if (obj && PyFloat_Check(obj)) {
+ _gaussianRadius = PyFloat_AsDouble(obj);
+ }
showScalarBar();
selectColorMap();
scaleBallRadius();
pushAndExecPyLine("pvs.Render();");
}
- if (params.scalarBarRange != _params.scalarBarRange)
- updateScalarBarRange<MEDPresentationPointSprite, MEDCALC::PointSpriteParameters>(params.scalarBarRange);
+ if (params.scalarBarRange != _params.scalarBarRange ||
+ params.hideDataOutsideCustomRange != _params.hideDataOutsideCustomRange ||
+ params.scalarBarRangeArray[0] != _params.scalarBarRangeArray[0] ||
+ params.scalarBarRangeArray[1] != _params.scalarBarRangeArray[1])
+ updateScalarBarRange<MEDPresentationPointSprite, MEDCALC::PointSpriteParameters>(params.scalarBarRange,
+ params.hideDataOutsideCustomRange,
+ params.scalarBarRangeArray[0],
+ params.scalarBarRangeArray[1]);
if (params.colorMap != _params.colorMap)
updateColorMap<MEDPresentationPointSprite, MEDCALC::PointSpriteParameters>(params.colorMap);
+ if (params.visibility != _params.visibility)
+ updateVisibility<MEDPresentationPointSprite, MEDCALC::PointSpriteParameters>(params.visibility);
+ if (params.scalarBarVisibility != _params.scalarBarVisibility)
+ updateScalarBarVisibility<MEDPresentationPointSprite, MEDCALC::PointSpriteParameters>(params.scalarBarVisibility);
+}
+
+std::string
+MEDPresentationPointSprite::additionalThresholdVisualizationActions() {
+ if (_hideDataOutsideCustomRange) {
+ // Set point sprite:
+ std::ostringstream oss;
+ std::string aDispVar = getDispVar();
+ oss << aDispVar << ".SetRepresentationType('Point Gaussian');";
+ oss << aDispVar << ".ScaleByArray = 1;";
+ oss << aDispVar << ".SetScaleArray = ['POINTS', '" << getThresholdFieldName() << "'];";
+ oss << aDispVar << ".GaussianRadius = " << _gaussianRadius << ";";
+ oss << aDispVar << ".ScaleTransferFunction.RescaleTransferFunction(" << _rangeVar << "[0], " << _rangeVar << "[1]);";
+ return oss.str();
+ }
}
+
+void
+MEDPresentationPointSprite::additionalThresholdActions() {
+ scaleBallRadius();
+}
+
+void
+MEDPresentationPointSprite::additionalUnThresholdActions() {
+ scaleBallRadius();
+}
\ No newline at end of file
protected:
virtual void internalGeneratePipeline();
void scaleBallRadius();
+ void additionalThresholdActions() override;
+ std::string additionalThresholdVisualizationActions() override;
+ void additionalUnThresholdActions() override;
private:
MEDCALC::PointSpriteParameters _params;
+ double _gaussianRadius;
};
#endif
if (params.fieldHandlerId != _params.fieldHandlerId)
throw KERNEL::createSalomeException("Unexpected updatePipeline error! Mismatching fieldHandlerId!");
- if (std::string(params.displayedComponent) != std::string(_params.displayedComponent))
- updateComponent<MEDPresentationScalarMap, MEDCALC::ScalarMapParameters>(std::string(params.displayedComponent));
- if (params.scalarBarRange != _params.scalarBarRange)
- updateScalarBarRange<MEDPresentationScalarMap, MEDCALC::ScalarMapParameters>(params.scalarBarRange);
if (params.colorMap != _params.colorMap)
updateColorMap<MEDPresentationScalarMap, MEDCALC::ScalarMapParameters>(params.colorMap);
+
+ if (std::string(params.displayedComponent) != std::string(_params.displayedComponent))
+ updateComponent<MEDPresentationScalarMap, MEDCALC::ScalarMapParameters>(std::string(params.displayedComponent));
+ if (params.scalarBarRange != _params.scalarBarRange ||
+ params.hideDataOutsideCustomRange != _params.hideDataOutsideCustomRange ||
+ params.scalarBarRangeArray[0] != _params.scalarBarRangeArray[0] ||
+ params.scalarBarRangeArray[1] != _params.scalarBarRangeArray[1] )
+ updateScalarBarRange<MEDPresentationScalarMap, MEDCALC::ScalarMapParameters>(params.scalarBarRange,
+ params.hideDataOutsideCustomRange,
+ params.scalarBarRangeArray[0],
+ params.scalarBarRangeArray[1]);
+ if (params.visibility != _params.visibility)
+ updateVisibility<MEDPresentationScalarMap, MEDCALC::ScalarMapParameters>(params.visibility);
+ if (params.scalarBarVisibility != _params.scalarBarVisibility)
+ updateScalarBarVisibility<MEDPresentationScalarMap, MEDCALC::ScalarMapParameters>(params.scalarBarVisibility);
}
void
MEDPresentationSlices::deleteGroup()
{
+ deleteThresholds();
std::ostringstream oss;
- oss << "pvs.Delete(" << _objVar << ");";
+ oss << "pvs.Hide(" << _objVar << ");";
+ oss << "pvs.Delete(" << _objVar << ");del " <<_objVar<<";";
pushAndExecPyLine(oss.str()); oss.str("");
}
std::ostringstream oss;
int nbSlices = getIntProperty(MEDPresentationSlices::PROP_NB_SLICES);
- oss << "for _ in range(max(len(" << _sliceListVar << ")-" << nbSlices << ", 0)):\n";
+ oss << "for _ in range(int(max(len(" << _sliceListVar << ")-" << nbSlices << ", 0))):\n";
oss << " pvs.Delete(" << _sliceListVar << ".pop());\n";
pushAndExecPyLine(oss.str()); oss.str("");
- oss << "for _ in range(" << nbSlices << "-max(len(" << _sliceListVar << "), 0)):\n";
+ oss << "for _ in range(" << nbSlices << "-int(max(len(" << _sliceListVar << "), 0))):\n";
oss << " obj = pvs.Slice(Input=" << _srcObjVar << ");\n";
oss << " obj.SliceType = 'Plane';\n";
oss << " " << _sliceListVar << ".append(obj);\n";
{
adaptNumberOfSlices();
setSliceParametersAndGroup();
-
recreateViewSetup();
}
if (std::string(params.displayedComponent) != std::string(_params.displayedComponent))
updateComponent<MEDPresentationSlices, MEDCALC::SlicesParameters>(std::string(params.displayedComponent));
- if (params.scalarBarRange != _params.scalarBarRange)
- updateScalarBarRange<MEDPresentationSlices, MEDCALC::SlicesParameters>(params.scalarBarRange);
+ if (params.scalarBarRange != _params.scalarBarRange ||
+ params.hideDataOutsideCustomRange != _params.hideDataOutsideCustomRange ||
+ params.scalarBarRangeArray[0] != _params.scalarBarRangeArray[0] ||
+ params.scalarBarRangeArray[1] != _params.scalarBarRangeArray[1])
+ updateScalarBarRange<MEDPresentationSlices, MEDCALC::SlicesParameters>(params.scalarBarRange,
+ params.hideDataOutsideCustomRange,
+ params.scalarBarRangeArray[0],
+ params.scalarBarRangeArray[1]);
if (params.colorMap != _params.colorMap)
updateColorMap<MEDPresentationSlices, MEDCALC::SlicesParameters>(params.colorMap);
}
updateNbSlices(params.nbSlices);
}
+ if (params.visibility != _params.visibility)
+ updateVisibility<MEDPresentationSlices, MEDCALC::SlicesParameters>(params.visibility);
+
+ if (params.scalarBarVisibility != _params.scalarBarVisibility)
+ updateScalarBarVisibility<MEDPresentationSlices, MEDCALC::SlicesParameters>(params.scalarBarVisibility);
}
void
--- /dev/null
+// Copyright (C) 2016-2021 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 "MEDPyLockWrapper.hxx"
+
+#include "MEDPresentationStreamLines.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 MEDPresentationStreamLines::TYPE_NAME = "MEDPresentationStreamLines";
+const std::string MEDPresentationStreamLines::PROP_INTEGR_DIR_TYPE = "intDirType";
+
+MEDPresentationStreamLines::MEDPresentationStreamLines(const MEDCALC::StreamLinesParameters& params,
+ const MEDCALC::ViewModeType viewMode) :
+ MEDPresentation(params.fieldHandlerId, TYPE_NAME, viewMode, params.colorMap, params.scalarBarRange),
+ _params(params)
+{
+ setIntProperty(MEDPresentationStreamLines::PROP_INTEGR_DIR_TYPE, params.integrDir);
+}
+
+std::string
+MEDPresentationStreamLines::getIntegrDirType() const
+{
+ switch(_params.integrDir)
+ {
+ case MEDCALC::INTEGRATION_DIR_BOTH:
+ return "BOTH";
+ case MEDCALC::INTEGRATION_DIR_FORWARD:
+ return "FORWARD";
+ case MEDCALC::INTEGRATION_DIR_BACKWARD:
+ return "BACKWARD";
+ default:
+ const char * mes = "Unexpected getIntegrDirType() error!";
+ STDLOG(mes);
+ throw KERNEL::createSalomeException(mes);
+ }
+ return ""; // never happens
+}
+
+void
+MEDPresentationStreamLines::addThirdZeroComponent()
+{
+ std::ostringstream oss;
+
+ oss << _objStreamCalc << " = pvs.Calculator(Input=" << _objStreamCalc << ");";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ std::string typ = "Point Data"; // Because CellDatatoPointData filter has been applied erlier
+ oss << _objStreamCalc << ".AttributeType = '" << typ << "';";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ oss << _objStreamCalc << ".ResultArrayName = '" << _fieldName << "_CALC';";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ oss << _objStreamCalc << ".Function = '" << _fieldName << "_X*iHat + " << _fieldName << "_Y*jHat + 0.0*kHat';";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ /*
+ oss << _dispVar << " = pvs.Show(" << _objStreamCalc << ", " << getRenderViewVar() << ");";
+ oss << _lutVar << " = pvs.GetColorTransferFunction('" << _fieldName << "', " << _dispVar << ", separate=True);";
+ execPyLine(oss.str()); oss.str("");
+ oss << "pvs.ColorBy(" << getDispVar() << ", ('" << "POINTS" << "', '" << _fieldName << "_CALC'), separate=True);";
+ execPyLine(oss.str()); oss.str("");
+ oss << "pvs.Hide(" << _objStreamCalc << ", " << getRenderViewVar() << ");";
+ execPyLine(oss.str()); oss.str("");
+ */
+}
+
+void
+MEDPresentationStreamLines::internalGeneratePipeline()
+{
+ MEDPresentation::internalGeneratePipeline();
+
+ MEDPyLockWrapper lock;
+
+ createSource();
+ setTimestamp();
+
+ fillAvailableFieldComponents();
+ int nbCompo = getIntProperty(MEDPresentation::PROP_NB_COMPONENTS);
+ if (nbCompo <= 1)
+ {
+ const char * msg = "Stream Lines field presentation does not work for scalar field!";
+ STDLOG(msg);
+ throw KERNEL::createSalomeException(msg);
+ }
+
+ setOrCreateRenderView();
+
+ std::ostringstream oss;
+ if (_pvFieldType == "CELLS")
+ {
+ oss << "__objStreamCalc";
+ _objStreamCalc = oss.str(); oss.str("");
+ oss << _objStreamCalc << " = pvs.CellDatatoPointData(" << _srcObjVar << ");";
+ oss << _objStreamCalc << ".PassCellData = 1;";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ }
+ else
+ {
+ oss << "__objStreamCalc";
+ _objStreamCalc = oss.str(); oss.str("");
+ oss << _objStreamCalc << "=" << _srcObjVar;
+ pushAndExecPyLine(oss.str()); oss.str("");
+ }
+
+ if (_nbComponents == 2)
+ addThirdZeroComponent();
+
+ std::string dirType = getIntegrDirType();
+
+ oss.str("");
+ oss << _objVar << " = " << _objStreamCalc << ";";
+ oss << _objVar << ".UpdatePipeline();";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ oss << _objVar << " = pvs.StreamTracer(Input=" << _objVar << ", SeedType='Point Cloud' if pvs.GetParaViewVersion().GetVersion() > 5.8 else 'Point Source');";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ oss << _objVar << ".IntegrationDirection = '" << dirType << "';";
+ pushAndExecPyLine(oss.str()); oss.str("");
+
+ showObject();
+
+ oss << "pvs.ColorBy(" << getDispVar() << ", ('" << "POINTS" << "', '" << getFieldName() << "'), separate=True);";
+ pushAndExecPyLine(oss.str()); oss.str("");
+
+ showScalarBar();
+ selectColorMap();
+ rescaleTransferFunction();
+ scalarBarTitle();
+ resetCameraAndRender();
+}
+
+void
+MEDPresentationStreamLines::updatePipeline(const MEDCALC::StreamLinesParameters& params)
+{
+ if (params.fieldHandlerId != _params.fieldHandlerId)
+ throw KERNEL::createSalomeException("Unexpected updatePipeline error! Mismatching fieldHandlerId!");
+
+ if (params.colorMap != _params.colorMap)
+ updateColorMap<MEDPresentationStreamLines, MEDCALC::StreamLinesParameters>(params.colorMap);
+
+ if (params.scalarBarRange != _params.scalarBarRange ||
+ params.hideDataOutsideCustomRange != _params.hideDataOutsideCustomRange ||
+ params.scalarBarRangeArray[0] != _params.scalarBarRangeArray[0] ||
+ params.scalarBarRangeArray[1] != _params.scalarBarRangeArray[1])
+ updateScalarBarRange<MEDPresentationStreamLines, MEDCALC::StreamLinesParameters>(params.scalarBarRange,
+ params.hideDataOutsideCustomRange,
+ params.scalarBarRangeArray[0],
+ params.scalarBarRangeArray[1]);
+
+ if (params.integrDir != _params.integrDir)
+ updateIntegrDir(params.integrDir);
+
+ if (params.visibility != _params.visibility)
+ updateVisibility<MEDPresentationStreamLines, MEDCALC::StreamLinesParameters>(params.visibility);
+ if (params.scalarBarVisibility != _params.scalarBarVisibility)
+ updateScalarBarVisibility<MEDPresentationStreamLines, MEDCALC::StreamLinesParameters>(params.scalarBarVisibility);
+}
+
+void
+MEDPresentationStreamLines::updateIntegrDir(const MEDCALC::IntegrationDirType integrDir)
+{
+ _params.integrDir = integrDir;
+
+ // GUI helper:
+ setIntProperty(MEDPresentationStreamLines::PROP_INTEGR_DIR_TYPE, integrDir);
+
+ // Update the pipeline:
+ {
+ MEDPyLockWrapper lock;
+ std::ostringstream oss;
+ std::string dirType = getIntegrDirType();
+ oss << _objVar << ".IntegrationDirection = '" << dirType << "'";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ pushAndExecPyLine("pvs.Render();");
+ }
+}
+
+void
+MEDPresentationStreamLines::initFieldMeshInfos()
+{
+ MEDPresentation::initFieldMeshInfos();
+ _colorByType = "POINTS";
+}
+
+std::string MEDPresentationStreamLines::additionalThresholdInitializationActions() {
+ if (_hideDataOutsideCustomRange) {
+ std::ostringstream oss;
+ ComponentThresold& currentThreshold = _presentationThresolds[getThresholdIndex()];
+ oss << currentThreshold._thresholdVar << ".AllScalars = 0;";
+ return oss.str();
+ }
+ return "";
+}
+
+std::string MEDPresentationStreamLines::getFieldName() const {
+ std::ostringstream oss;
+ oss << _fieldName;
+ if (_nbComponents == 2) {
+ oss << "_CALC";
+ }
+ return oss.str();
+}
+
+void
+MEDPresentationStreamLines::scalarBarTitle()
+{
+ if (_nbComponents == 2 && !_hideDataOutsideCustomRange) {
+ std::ostringstream oss;
+ oss << "pvs.GetScalarBar(" << getLutVar() << ").Title = '" << _fieldName << "';";
+ pushAndExecPyLine(oss.str());
+ }
+ MEDPresentation::scalarBarTitle();
+}
\ No newline at end of file
--- /dev/null
+// Copyright (C) 2016-2021 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_CMP_MEDPRESENTATION_STREAM_LINES_HXX_
+#define SRC_MEDCALC_CMP_MEDPRESENTATION_STREAM_LINES_HXX_
+
+#include "MEDCALC.hxx"
+#include "MEDPresentation.hxx"
+#include <string>
+
+class MEDCALC_EXPORT MEDPresentationStreamLines : public MEDPresentation
+{
+public:
+ static const std::string TYPE_NAME;
+ static const std::string PROP_INTEGR_DIR_TYPE;
+
+ MEDPresentationStreamLines(const MEDCALC::StreamLinesParameters& params, const MEDCALC::ViewModeType viewMode);
+ virtual ~MEDPresentationStreamLines() {}
+
+ void updatePipeline(const MEDCALC::StreamLinesParameters& params);
+
+ void getParameters(MEDCALC::StreamLinesParameters & params) const { params = _params; } ;
+ void setParameters(const MEDCALC::StreamLinesParameters & params) { _params = params; } ;
+
+ void initFieldMeshInfos() override;
+
+protected:
+ void updateIntegrDir(const MEDCALC::IntegrationDirType mode);
+ virtual void internalGeneratePipeline();
+ std::string additionalThresholdInitializationActions() override;
+ std::string getFieldName() const override;
+ void scalarBarTitle() override;
+
+
+private:
+ std::string getIntegrDirType() const;
+ std::string _objStreamCalc;
+ void addThirdZeroComponent();
+ MEDCALC::StreamLinesParameters _params;
+};
+
+#endif
\ No newline at end of file
#include <sstream>
const std::string MEDPresentationVectorField::TYPE_NAME = "MEDPresentationVectorField";
+const std::string MEDPresentationVectorField::PROP_SCALE_FACTOR = "scaleFactor";
+const std::string MEDPresentationVectorField::PROP_CUSTOM_SCALE_FACTOR = "customScaleFactor";
MEDPresentationVectorField::MEDPresentationVectorField(const MEDCALC::VectorFieldParameters& params,
const MEDCALC::ViewModeType viewMode) :
MEDPresentation(params.fieldHandlerId, TYPE_NAME, viewMode, params.colorMap, params.scalarBarRange), _params(params)
{
+ setDoubleProperty(MEDPresentationVectorField::PROP_SCALE_FACTOR, params.scaleFactor);
+ setIntProperty(MEDPresentationVectorField::PROP_CUSTOM_SCALE_FACTOR, params.customScaleFactor);
}
void
MEDPresentationVectorField::autoScale()
{
std::ostringstream oss;
-// oss << "import medcalc;";
-// pushAndExecPyLine(oss.str()); oss.str("");
- oss << _objVar << ".ScaleFactor = 2.0*medcalc.ComputeCellAverageSize(" << _srcObjVar << ")/(" << _rangeVar
+ oss << "__autoScaleF = 2.0*medcalc.ComputeCellAverageSize(" << _srcObjVar << ")/(" << _rangeVar
<< "[1]-" << _rangeVar << "[0]);";
- pushAndExecPyLine(oss.str()); oss.str("");
+ MEDPyLockWrapper lock;
+ execPyLine(oss.str());
+ PyObject * obj = getPythonObjectFromMain("__autoScaleF");
+ if (obj && PyFloat_Check(obj)) {
+ _params.scaleFactor = PyFloat_AsDouble(obj);
+ setDoubleProperty(MEDPresentationVectorField::PROP_SCALE_FACTOR, _params.scaleFactor);
+ }
+
}
void
selectColorMap();
rescaleTransferFunction();
- autoScale(); // to be called after transfer function so we have the range
+ scale(); // to be called after transfer function so we have the range
resetCameraAndRender();
}
if (params.fieldHandlerId != _params.fieldHandlerId)
throw KERNEL::createSalomeException("Unexpected updatePipeline error! Mismatching fieldHandlerId!");
- if (params.scalarBarRange != _params.scalarBarRange)
+ if (params.scalarBarRange != _params.scalarBarRange ||
+ params.hideDataOutsideCustomRange != _params.hideDataOutsideCustomRange ||
+ params.scalarBarRangeArray[0] != _params.scalarBarRangeArray[0] ||
+ params.scalarBarRangeArray[1] != _params.scalarBarRangeArray[1])
{
- updateScalarBarRange<MEDPresentationVectorField, MEDCALC::VectorFieldParameters>(params.scalarBarRange);
- autoScale();
+ updateScalarBarRange<MEDPresentationVectorField, MEDCALC::VectorFieldParameters>(params.scalarBarRange,
+ params.hideDataOutsideCustomRange,
+ params.scalarBarRangeArray[0],
+ params.scalarBarRangeArray[1]);
+ scale();
pushAndExecPyLine("pvs.Render();");
}
+ if (params.scaleFactor != _params.scaleFactor ||
+ params.customScaleFactor != _params.customScaleFactor) {
+ updateScaleFactor(params.scaleFactor, params.customScaleFactor);
+ }
+
if (params.colorMap != _params.colorMap)
updateColorMap<MEDPresentationVectorField, MEDCALC::VectorFieldParameters>(params.colorMap);
+
+ if (params.visibility != _params.visibility)
+ updateVisibility<MEDPresentationVectorField, MEDCALC::VectorFieldParameters>(params.visibility);
+
+ if (params.scalarBarVisibility != _params.scalarBarVisibility)
+ updateScalarBarVisibility<MEDPresentationVectorField, MEDCALC::VectorFieldParameters>(params.scalarBarVisibility);
+
+}
+
+void
+MEDPresentationVectorField::updateScaleFactor(const double scaleFactor, const bool customScaleFactor)
+{
+ if (customScaleFactor) {
+ _params.scaleFactor = scaleFactor;
+ setDoubleProperty(MEDPresentationVectorField::PROP_SCALE_FACTOR, _params.scaleFactor);
+ }
+
+ _params.customScaleFactor = customScaleFactor;
+
+ setIntProperty(MEDPresentationVectorField::PROP_CUSTOM_SCALE_FACTOR, _params.customScaleFactor);
+ scale();
+}
+
+void
+MEDPresentationVectorField::scale()
+{
+ if (!_params.customScaleFactor) {
+ autoScale();
+ }
+ // Update Scale Factor
+ MEDPyLockWrapper lock;
+ std::ostringstream oss;
+ oss << _objVar << ".ScaleFactor = " << _params.scaleFactor << ";";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ pushAndExecPyLine("pvs.Render();");
}
{
public:
static const std::string TYPE_NAME;
+ static const std::string PROP_SCALE_FACTOR;
+ static const std::string PROP_CUSTOM_SCALE_FACTOR;
MEDPresentationVectorField(const MEDCALC::VectorFieldParameters& params, const MEDCALC::ViewModeType viewMode);
virtual ~MEDPresentationVectorField() {}
protected:
virtual void internalGeneratePipeline();
+ void updateScaleFactor(const double, const bool);
void autoScale();
-
+ void scale();
private:
MEDCALC::VectorFieldParameters _params;
MEDWidgetHelperComponent.cxx
MEDWidgetHelperContour.cxx
MEDWidgetHelperSlices.cxx
+ MEDWidgetHelperPlot3D.cxx
+ MEDWidgetHelperStreamLines.cxx
+ MEDWidgetHelperCutSegment.cxx
+ MEDWidgetHelperVectorField.cxx
+ MEDCALCGUI_Displayer.cxx
)
IF(SALOME_FIELDS_WITH_QTTESTING)
LIST(APPEND MEDCALCGUI_SOURCES TestController.cxx)
ENDIF()
-SET(MEDCALCGUI_HEADERS
+SET(MEDCALCGUI_MOC_HEADERS
MEDModule.hxx
MEDEventListener_i.hxx
WorkspaceController.hxx
MEDWidgetHelperContour.hxx
MEDWidgetHelperSlices.hxx
MEDWidgetHelperPointSprite.hxx
+ MEDWidgetHelperPlot3D.hxx
+ MEDWidgetHelperStreamLines.hxx
+ MEDWidgetHelperCutSegment.hxx
MEDWidgetHelperVectorField.hxx
MEDWidgetHelperDeflectionShape.hxx
)
+
+SET(MEDCALCGUI_HEADERS
+ MEDCALCGUI_Displayer.hxx
+ )
IF(SALOME_FIELDS_WITH_QTTESTING)
- LIST(APPEND MEDCALCGUI_HEADERS TestController.hxx)
+ LIST(APPEND MEDCALCGUI_MOC_HEADERS TestController.hxx)
ENDIF()
-QT_WRAP_MOC(MEDCALCGUI_HEADERS_MOC ${MEDCALCGUI_HEADERS})
+QT_WRAP_MOC(MEDCALCGUI_HEADERS_MOC ${MEDCALCGUI_MOC_HEADERS})
INCLUDE_DIRECTORIES(
${OMNIORB_INCLUDE_DIR} ${OMNIORB_INCLUDE_DIRS}
<source>ICO_PRESENTATION_POINT_SPRITE_DEFAULT</source>
<translation>pqNodeMapData24.png</translation>
</message>
+ <message>
+ <source>ICO_PRESENTATION_PLOT3D_DEFAULT</source>
+ <translation>pqPlot24.png</translation>
+ </message>
+ <message>
+ <source>ICO_PRESENTATION_STREAM_LINES_DEFAULT</source>
+ <translation>pqStreamTracer24.png</translation>
+ </message>
+ <message>
+ <source>ICO_PRESENTATION_CUT_SEGMENT_DEFAULT</source>
+ <translation>pqPlotOverLine24.png</translation>
+ </message>
<!-- Presentation tree icons (default theme)-->
<message>
<source>ICO_MEDPresentationMeshView_DEFAULT</source>
<source>ICO_MEDPresentationPointSprite_DEFAULT</source>
<translation>pqNodeMapData16.png</translation>
</message>
+ <message>
+ <source>ICO_MEDPresentationPlot3D_DEFAULT</source>
+ <translation>pqPlot16.png</translation>
+ </message>
+ <message>
+ <source>ICO_MEDPresentationStreamLines_DEFAULT</source>
+ <translation>pqStreamTracer16.png</translation>
+ </message>
+ <message>
+ <source>ICO_MEDPresentationCutSegment_DEFAULT</source>
+ <translation>pqPlotOverLine16.png</translation>
+ </message>
<!-- Presentation toolbar icons (modern theme)-->
<message>
<source>ICO_PRESENTATION_MESH_VIEW_MODERN</source>
<source>ICO_PRESENTATION_POINT_SPRITE_MODERN</source>
<translation>pqNodeMapData24.png</translation>
</message>
+ <message>
+ <source>ICO_PRESENTATION_PLOT3D_MODERN</source>
+ <translation>pqPlot24.png</translation>
+ </message>
+ <message>
+ <source>ICO_PRESENTATION_STREAM_LINES_MODERN</source>
+ <translation>pqStreamTracer24.png</translation>
+ </message>
+ <message>
+ <source>ICO_PRESENTATION_CUT_SEGMENT_MODERN</source>
+ <translation>pqPlotOverLine24.png</translation>
+ </message>
<!-- Presentation tree icons (modern theme)-->
<message>
<source>ICO_MEDPresentationMeshView_MODERN</source>
<source>ICO_MEDPresentationPointSprite_MODERN</source>
<translation>pqNodeMapData16.png</translation>
</message>
+ <message>
+ <source>ICO_MEDPresentationPlot3D_MODERN</source>
+ <translation>pqPlot16.png</translation>
+ </message>
+ <message>
+ <source>ICO_MEDPresentationStreamLines_MODERN</source>
+ <translation>pqStreamTracer16.png</translation>
+ </message>
+ <message>
+ <source>ICO_MEDPresentationCutSegment_MODERN</source>
+ <translation>pqPlotOverLine16.png</translation>
+ </message>
<!-- Presentation toolbar icons (classic theme)-->
<message>
<source>ICO_PRESENTATION_MESH_VIEW_CLASSIC</source>
<source>ICO_PRESENTATION_POINT_SPRITE_CLASSIC</source>
<translation>visu_points24.png</translation>
</message>
+ <message>
+ <source>ICO_PRESENTATION_PLOT3D_CLASSIC</source>
+ <translation>visu_plot3d24.png</translation>
+ </message>
+ <message>
+ <source>ICO_PRESENTATION_STREAM_LINES_CLASSIC</source>
+ <translation>visu_streamlines24.png</translation>
+ </message>
+ <message>
+ <source>ICO_PRESENTATION_CUT_SEGMENT_CLASSIC</source>
+ <translation>visu_cutsegment24.png</translation>
+ </message>
<!-- Presentation tree icons (classic theme)-->
<message>
<source>ICO_MEDPresentationMeshView_CLASSIC</source>
<source>ICO_MEDPresentationPointSprite_CLASSIC</source>
<translation>visu_points16.png</translation>
</message>
+ <message>
+ <source>ICO_MEDPresentationPlot3D_CLASSIC</source>
+ <translation>visu_plot3d16.png</translation>
+ </message>
+ <message>
+ <source>ICO_MEDPresentationStreamLines_CLASSIC</source>
+ <translation>visu_streamlines16.png</translation>
+ </message>
+ <message>
+ <source>ICO_MEDPresentationCutSegment_CLASSIC</source>
+ <translation>visu_cutsegment16.png</translation>
+ </message>
<message>
<source>ICO_DELETE_PRESENTATION</source>
<translation>close.png</translation>
<source>TIP_PRESENTATION_POINT_SPRITE</source>
<translation>Point sprite</translation>
</message>
+ <message>
+ <source>LAB_PRESENTATION_PLOT3D</source>
+ <translation>Plot3D</translation>
+ </message>
+ <message>
+ <source>TIP_PRESENTATION_PLOT3D</source>
+ <translation>Plot3D</translation>
+ </message>
+ <message>
+ <source>LAB_PRESENTATION_STREAM_LINES</source>
+ <translation>Stream Lines</translation>
+ </message>
+ <message>
+ <source>TIP_PRESENTATION_STREAM_LINES</source>
+ <translation>Stream Lines</translation>
+ </message>
+ <message>
+ <source>LAB_PRESENTATION_CUT_SEGMENT</source>
+ <translation>Cut Segment</translation>
+ </message>
+ <message>
+ <source>TIP_PRESENTATION_CUT_SEGMENT</source>
+ <translation>Cut Segment</translation>
+ </message>
<message>
<source>LAB_DELETE_PRESENTATION</source>
<translation>Delete presentation</translation>
<source>MEDPresentationPointSprite</source>
<translation>Point sprite</translation>
</message>
+ <message>
+ <source>MEDPresentationPlot3D</source>
+ <translation>Plot3D</translation>
+ </message>
+ <message>
+ <source>MEDPresentationStreamLines</source>
+ <translation>Stream Lines</translation>
+ </message>
+ <message>
+ <source>MEDPresentationCutSegment</source>
+ <translation>Cut Segment</translation>
+ </message>
</context>
<context>
<name>ProcessingController</name>
<source>LAB_RANGE</source>
<translation>Range:</translation>
</message>
+ <message>
+ <source>LAB_SHOW_SCALAR_BAR</source>
+ <translation>Show Scalar Bar</translation>
+ </message>
+ <message>
+ <source>LAB_CUSTOM_RANGE</source>
+ <translation>Custom Range:</translation>
+ </message>
+ <message>
+ <source>LAB_HIDE_DATA_OUTSIDE_CR</source>
+ <translation>Hide Data outside Custom Range</translation>
+ </message>
<message>
<source>LAB_ALL_TIMESTEPS</source>
<translation>All timesteps</translation>
<source>LAB_MESH_SURF_EDGES</source>
<translation>Surface With Edges</translation>
</message>
+ <message>
+ <source>LAB_INTEGR_DIR_BOTH</source>
+ <translation>BOTH</translation>
+ </message>
+ <message>
+ <source>LAB_INTEGR_DIR_FORWARD</source>
+ <translation>FORWARD</translation>
+ </message>
+ <message>
+ <source>LAB_INTEGR_DIR_BACKWARD</source>
+ <translation>BACKWARD</translation>
+ </message>
<message>
<source>LAB_DISP_MESH_MODE</source>
<translation>Mesh display:</translation>
</message>
+ <message>
+ <source>LAB_INTEGR_DIR</source>
+ <translation>Integration Direction:</translation>
+ </message>
<message>
<source>LAB_NB_CONTOURS</source>
<translation>Number of contours (max. %1):</translation>
<source>LAB_COOL_TO_WARM</source>
<translation>Cool to warm</translation>
</message>
+ <message>
+ <source>LAB_CUT_PLANE_NORMAL</source>
+ <translation>Plane Normal:</translation>
+ </message>
+ <message>
+ <source>LAB_CUT_PLANE_POS</source>
+ <translation>Cutting Plane Position:</translation>
+ </message>
+ <message>
+ <source>LAB_CUT_POINT1</source>
+ <translation>Point 1:</translation>
+ </message>
+ <message>
+ <source>LAB_CUT_POINT2</source>
+ <translation>Point 2:</translation>
+ </message>
+ <message>
+ <source>LAB_CONTOUR_COMP</source>
+ <translation>Contour By:</translation>
+ </message>
+ <message>
+ <source>LAB_SCALE_FACTOR</source>
+ <translation>Scale Factor</translation>
+ </message>
</context>
<context>
<name>DlgAlias</name>
<source>TIP_PRESENTATION_POINT_SPRITE</source>
<translation>Point sprite</translation>
</message>
+ <message>
+ <source>LAB_PRESENTATION_PLOT3D</source>
+ <translation>Plot3D</translation>
+ </message>
+ <message>
+ <source>TIP_PRESENTATION_PLOT3D</source>
+ <translation>Plot3D</translation>
+ </message>
+ <message>
+ <source>LAB_PRESENTATION_STREAM_LINES</source>
+ <translation>Les Lignes DÉcoulement</translation>
+ </message>
+ <message>
+ <source>TIP_PRESENTATION_STREAM_LINES</source>
+ <translation>Les Lignes DÉcoulement</translation>
+ </message>
+ <message>
+ <source>LAB_PRESENTATION_CUT_SEGMENT</source>
+ <translation>Couper Des Segment</translation>
+ </message>
+ <message>
+ <source>TIP_PRESENTATION_CUT_SEGMENT</source>
+ <translation>Couper Des Segment</translation>
+ </message>
<message>
<source>LAB_DELETE_PRESENTATION</source>
<translation>Supprimer</translation>
<source>MEDPresentationPointSprite</source>
<translation>Point sprite</translation>
</message>
+ <message>
+ <source>MEDPresentationPlot3D</source>
+ <translation>Plot3D</translation>
+ </message>
+ <message>
+ <source>MEDPresentationStreamLines</source>
+ <translation>Les Lignes DeÉcoulement</translation>
+ </message>
+ <message>
+ <source>MEDPresentationCutSegment</source>
+ <translation>Couper Des Segment</translation>
+ </message>
</context>
<context>
<name>ProcessingController</name>
<source>LAB_RANGE</source>
<translation>Intervalle :</translation>
</message>
+ <message>
+ <source>LAB_SHOW_SCALAR_BAR</source>
+ <translation>Afficher la barre scalaire</translation>
+ </message>
+ <message>
+ <source>LAB_CUSTOM_RANGE</source>
+ <translation>Gamme personnalisée:</translation>
+ </message>
+ <message>
+ <source>LAB_HIDE_DATA_OUTSIDE_CR</source>
+ <translation>Masquer les données en dehors de la plage personnalisée</translation>
+ </message>
<message>
<source>LAB_ALL_TIMESTEPS</source>
<translation>Tous les pas de temps</translation>
<source>LAB_MESH_SURF_EDGES</source>
<translation>Surface Avec Arrêtes</translation>
</message>
+ <message>
+ <source>LAB_INTEGR_DIR_BOTH</source>
+ <translation>Les DEUX</translation>
+ </message>
+ <message>
+ <source>LAB_INTEGR_DIR_FORWARD</source>
+ <translation>TRANSMETTRE</translation>
+ </message>
+ <message>
+ <source>LAB_INTEGR_DIR_BACKWARD</source>
+ <translation>ARRIÉRÉ</translation>
+ </message>
<message>
<source>LAB_DISP_MESH_MODE</source>
<translation>Affichage du maillage:</translation>
</message>
+ <message>
+ <source>LAB_INTEGR_DIR</source>
+ <translation>Intégration De Direction:</translation>
+ </message>
<message>
<source>LAB_NB_CONTOURS</source>
<translation>Nombre de contours (max. %1) :</translation>
<source>LAB_COOL_TO_WARM</source>
<translation>Froid vers chaud</translation>
</message>
+ <message>
+ <source>LAB_CUT_PLANE_NORMAL</source>
+ <translation>Plan Normal:</translation>
+ </message>
+ <message>
+ <source>LAB_CUT_PLANE_POS</source>
+ <translation>Position Du Plan De Coupe:</translation>
+ </message>
+ <message>
+ <source>LAB_CUT_POINT1</source>
+ <translation>Point 1:</translation>
+ </message>
+ <message>
+ <source>LAB_CUT_POINT2</source>
+ <translation>Point 2:</translation>
+ </message>
+ <message>
+ <source>LAB_SCALE_FACTOR</source>
+ <translation>Facteur Déchelle</translation>
+ </message>
</context>
<context>
<name>DlgAlias</name>
<source>TIP_PRESENTATION_POINT_SPRITE</source>
<translation>点スプライト</translation>
</message>
+ <message>
+ <source>LAB_PRESENTATION_PLOT3D</source>
+ <translation>プロット3D</translation>
+ </message>
+ <message>
+ <source>TIP_PRESENTATION_PLOT3D</source>
+ <translation>プロット3D</translation>
+ </message>
+ <message>
+ <source>LAB_PRESENTATION_STREAM_LINES</source>
+ <translation>ストリーム線</translation>
+ </message>
+ <message>
+ <source>TIP_PRESENTATION_STREAM_LINES</source>
+ <translation>ストリーム線</translation>
+ </message>
+ <message>
+ <source>LAB_PRESENTATION_CUT_SEGMENT</source>
+ <translation>カット部分</translation>
+ </message>
+ <message>
+ <source>TIP_PRESENTATION_CUT_SEGMENT</source>
+ <translation>カット部分</translation>
+ </message>
<message>
<source>LAB_DELETE_PRESENTATION</source>
<translation>プレゼンテーションの削除</translation>
<source>MEDPresentationPointSprite</source>
<translation>点スプライト描画</translation>
</message>
+ <message>
+ <source>MEDPresentationPlot3D</source>
+ <translation>プロット3D</translation>
+ </message>
+ <message>
+ <source>MEDPresentationStreamLines</source>
+ <translation>ストリーム線</translation>
+ </message>
+ <message>
+ <source>MEDPresentationCutSegment</source>
+ <translation>カットセグ</translation>
+ </message>
</context>
<context>
<name>ProcessingController</name>
<source>LAB_MESH_SURF_EDGES</source>
<translation>エッジを持った表面</translation>
</message>
+ <message>
+ <source>LAB_INTEGR_DIR_BOTH</source>
+ <translation>どちらも</translation>
+ </message>
+ <message>
+ <source>LAB_INTEGR_DIR_FORWARD</source>
+ <translation>フォワード</translation>
+ </message>
+ <message>
+ <source>LAB_INTEGR_DIR_BACKWARD</source>
+ <translation>後ろ向き</translation>
+ </message>
<message>
<source>LAB_DISP_MESH_MODE</source>
<translation>メッシュ表示:</translation>
</message>
+ <message>
+ <source>LAB_INTEGR_DIR</source>
+ <translation>統合の方向:</translation>
+ </message>
<message>
<source>LAB_NB_CONTOURS</source>
<translation>コンタ数 (max. %1):</translation>
<source>LAB_COOL_TO_WARM</source>
<translation>冷却から温め</translation>
</message>
+ <message>
+ <source>LAB_CUT_PLANE_NORMAL</source>
+ <translation>平面ノーマル:</translation>
+ </message>
+ <message>
+ <source>LAB_CUT_PLANE_POS</source>
+ <translation>切断の平面の位置:</translation>
+ </message>
+ <message>
+ <source>LAB_CUT_POINT1</source>
+ <translation>ポイント 1:</translation>
+ </message>
+ <message>
+ <source>LAB_CUT_POINT2</source>
+ <translation>ポイント 2:</translation>
+ </message>
+ <message>
+ <source>LAB_SCALE_FACTOR</source>
+ <translation>スケール係数</translation>
+ </message>
</context>
<context>
<name>DlgAlias</name>
--- /dev/null
+// Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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
+//
+
+// File : MEDCALCGUI_Displayer.cxx
+// Author : Roman NIKOLAEV, Open CASCADE S.A.S. (roman.nikolaev@opencascade.com)
+
+// Local includes
+#include "PresentationController.hxx"
+#include "MEDCALCGUI_Displayer.hxx"
+#include <MEDCalcConstants.hxx>
+#include <MEDFactoryClient.hxx>
+
+// KERNEL includes
+#include <Basics_Utils.hxx>
+#include <SALOME_KernelServices.hxx>
+#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
+#include <SALOMEDSImpl_AttributeParameter.hxx>
+
+// GUI includes
+#include <PVViewer_ViewModel.h>
+
+
+MEDCALCGUI_Displayer::MEDCALCGUI_Displayer(PresentationController* presentationController):
+ LightApp_Displayer(),
+ _presentationController(presentationController)
+{
+}
+MEDCALCGUI_Displayer::~MEDCALCGUI_Displayer()
+{
+ _presentationController = nullptr;
+}
+
+void MEDCALCGUI_Displayer::Display(const QStringList& list, const bool /*val*/, SALOME_View* /*theView*/)
+{
+ STDLOG("MEDCALCGUI_Displayer::Display");
+ changeVisibility(list, true);
+}
+
+void MEDCALCGUI_Displayer::Erase(const QStringList& list, const bool forced, const bool updateViewer, SALOME_View* theView) {
+ STDLOG( "MEDCALCGUI_Displayer::Erase" );
+ changeVisibility(list, false);
+}
+
+bool MEDCALCGUI_Displayer::canBeDisplayed(const QString& entry, const QString& viewer_type) const {
+ bool result = false;
+ if (viewer_type != PVViewer_Viewer::Type())
+ return result;
+ MEDCALC::PresentationVisibility aState = visibilityState(entry);
+ result = (aState != MEDCALC::PRESENTATION_NOT_IN_VIEW);
+ STDLOG("MEDCALCGUI_Displayer::canBeDisplayed result is " << entry.toUtf8().constData() << " = " << result);
+ return result;
+}
+
+bool MEDCALCGUI_Displayer::IsDisplayed(const QString& entry, SALOME_View* /*view*/) const
+{
+ return (visibilityState(entry) == MEDCALC::PRESENTATION_VISIBLE);
+}
+
+void MEDCALCGUI_Displayer::changeVisibility(const QStringList& list, const bool visible)
+{
+ SALOMEDS::Study_var aStudy = KERNEL::getStudyServant();
+ if (aStudy->_is_nil())
+ return;
+ QStringList::const_iterator it = list.constBegin();
+ for (; it != list.constEnd(); ++it)
+ {
+ QString entry = *it;
+ SALOMEDS::SObject_var sobject = aStudy->FindObjectID(entry.toUtf8().constData());
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::AttributeParameter_var aParam;
+ if (sobject->FindAttribute(anAttr, "AttributeParameter")) {
+ aParam = SALOMEDS::AttributeParameter::_narrow(anAttr);
+ if (!aParam->_is_nil() && aParam->IsSet(PRESENTATION_ID, PT_INTEGER)) {
+ int presId = aParam->GetInt(PRESENTATION_ID);
+ if (aParam->IsSet(PRESENTATION_TYPE, PT_STRING)) {
+ std::string type = aParam->GetString(PRESENTATION_TYPE);
+ PresentationEvent* event = new PresentationEvent();
+ event->eventtype = visible ?
+ PresentationEvent::EVENT_DISPLAY_PRESENTATION : PresentationEvent::EVENT_ERASE_PRESENTATION;
+ event->presentationId = presId;
+ event->presentationType = PresentationController::presentationName2Type(type);
+ _presentationController->emitPresentationSignal(event);
+ }
+ }
+ }
+ }
+}
+
+MEDCALC::PresentationVisibility
+MEDCALCGUI_Displayer::visibilityState(const QString& entry) const
+{
+ MEDCALC::PresentationVisibility result = MEDCALC::PRESENTATION_NOT_IN_VIEW;
+ SALOMEDS::Study_var aStudy = KERNEL::getStudyServant();
+ if (aStudy->_is_nil())
+ return result;
+
+ SALOMEDS::SObject_var sobject = aStudy->FindObjectID(entry.toUtf8().constData());
+ if (!sobject->_is_nil()) {
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::AttributeParameter_var aParam;
+ if (sobject->FindAttribute(anAttr, "AttributeParameter")) {
+ aParam = SALOMEDS::AttributeParameter::_narrow(anAttr);
+ if (!aParam->_is_nil() && aParam->IsSet(IS_PRESENTATION, PT_BOOLEAN)) {
+ if (aParam->IsSet(PRESENTATION_ID, PT_INTEGER)) {
+ long prsId = aParam->GetInt(PRESENTATION_ID);
+ MEDCALC::MEDPresentationManager_var presentationManager =
+ MEDFactoryClient::getFactory()->getPresentationManager();
+ result = presentationManager->stateInActiveView(prsId);
+ }
+ }
+ }
+ }
+ STDLOG("MEDCALCGUI_Displayer::state result is " << entry.toUtf8().constData() << " = " << result);
+ return result;
+}
\ No newline at end of file
--- /dev/null
+// Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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
+//
+
+// File : MEDCALCGUI_Displayer.h
+// Author : Roman NIKOLAEV, Open CASCADE S.A.S. (roman.nikolaev@opencascade.com)
+//
+#ifndef MEDCALCGUI_DISPLAYER_H
+#define MEDCALCGUI_DISPLAYER_H
+#include <SALOMEconfig.h>
+#include CORBA_CLIENT_HEADER(MEDPresentationManager)
+#include <LightApp_Displayer.h>
+
+#include "MEDCALCGUI.hxx"
+
+class PresentationController;
+
+class MEDCALCGUI_EXPORT MEDCALCGUI_Displayer : public LightApp_Displayer
+{
+
+public:
+ /* Constructor */
+ MEDCALCGUI_Displayer(PresentationController* presentationController);
+ /* Destructor */
+ virtual ~MEDCALCGUI_Displayer() override;
+ virtual void Display(const QStringList&, const bool = true, SALOME_View* = 0) override;
+ virtual void Erase(const QStringList&, const bool forced = false, const bool updateViewer = true, SALOME_View* = 0) override;
+ virtual bool canBeDisplayed( const QString& /*entry*/, const QString& /*viewer_type*/ ) const override;
+ virtual bool IsDisplayed(const QString& /*entry*/, SALOME_View* = 0) const override;
+
+private:
+ void changeVisibility(const QStringList& list, const bool visible);
+ MEDCALC::PresentationVisibility visibilityState(const QString& entry) const;
+
+private:
+ PresentationController* _presentationController;
+};
+
+#endif // MEDCALCGUI_DISPLAYER_H
+
#include "MEDModule.hxx"
#include "QtHelper.hxx"
#include <MEDCalcConstants.hxx>
+#include "MEDCALCGUI_Displayer.hxx"
#include "SALOME_LifeCycleCORBA.hxx"
#include "QtxPopupMgr.h"
#include <SalomeApp_Study.h>
#include <SalomeApp_DataObject.h>
#include <SalomeApp_DataModel.h>
+#include <SUIT_ViewManager.h>
+#include <SUIT_ViewWindow.h>
#include <SALOMEconfig.h>
#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
#include <pqAnimationManager.h>
#include <pqPVApplicationCore.h>
#include <pqAnimationScene.h>
+#include <pqActiveObjects.h>
+#include <pqView.h>
//! The only instance of the reference to engine
MED_ORB::MED_Gen_var MEDModule::_MED_engine;
MEDModule::MEDModule() :
SalomeApp_Module("FIELDS"), _studyEditor(0),
_datasourceController(0), _workspaceController(0), _presentationController(0),
- _processingController(0), _pvGuiElements(0)
+ _processingController(0), _pvGuiElements(0),
+ _displayer(nullptr),
+ _enableVisibilityStateUpdate(true)
{
STDLOG("MEDModule::MEDModule()");
// Note also that we can't use the getApp() function here because
if (! getApp()->objectBrowser())
getApp()->getWindow(SalomeApp_Application::WT_ObjectBrowser);
- getApp()->objectBrowser()->setAutoOpenLevel(5);
+ // rnv: #20430 [CEA 20428] FIELDS : improvement of simplified visualisations:
+ // Disable auto expanding
+ //getApp()->objectBrowser()->setAutoOpenLevel(5);
if (app && app->desktop()) {
connect((QObject*) (getApp()->objectBrowser()->treeView()), SIGNAL(doubleClicked(const QModelIndex&)),
int av5 = ip->addAction(action(FIELDSOp::OpSlices) , gv);
int av6 = ip->addAction(action(FIELDSOp::OpDeflectionShape) , gv);
int av7 = ip->addAction(action(FIELDSOp::OpPointSprite) , gv);
+ int av8 = ip->addAction(action(FIELDSOp::OpPlot3D) , gv);
+ int av9 = ip->addAction(action(FIELDSOp::OpStreamLines) , gv);
+ int av10 = ip->addAction(action(FIELDSOp::OpCutSegment) , gv);
// getting started interpolation
int gi = ip->addGroup(tr("HELP_GRP_INTERPOLATION"));
// QTimer::singleShot(0, this, SLOT(onEventLoopStarted()));
// return the activation status
+
+ QObject::connect(&pqActiveObjects::instance(), SIGNAL(viewChanged(pqView*)), this,
+ SLOT(onViewChanged()), Qt::QueuedConnection);
+
return bOk;
}
connect(_workspaceController, SIGNAL(workspaceSignal(const MEDCALC::MedEvent*)),
_presentationController, SLOT(processWorkspaceEvent(const MEDCALC::MedEvent*)));
+
+ connect(&pqActiveObjects::instance(), &pqActiveObjects::viewChanged, [this](pqView* view) { this->updateVisibilityState(); });
+
+}
+
+
+void MEDModule::updateVisibilityState(const bool all, const QStringList& entries)
+{
+ if (!_enableVisibilityStateUpdate) {
+ return;
+ }
+ QStringList allPrsEntries = QStringList();
+ const QStringList& workList = ( all ? allPrsEntries : entries );
+ if (all) {
+ SALOMEDS::Study_var aStudy = KERNEL::getStudyServant();
+ if (aStudy->_is_nil())
+ return;
+ SALOMEDS::SComponent_var father = aStudy->FindComponent("FIELDS");
+ if (father->_is_nil())
+ return;
+ SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(father);
+ SALOMEDS::GenericAttribute_var anAttribute;
+ for (it->InitEx(true); it->More(); it->Next())
+ {
+ SALOMEDS::SObject_var child(it->Value());
+ if (child->FindAttribute(anAttribute, "AttributeParameter"))
+ {
+ SALOMEDS::AttributeParameter_var attrParam = SALOMEDS::AttributeParameter::_narrow(anAttribute);
+ if (!attrParam->IsSet(IS_PRESENTATION, PT_BOOLEAN) || !attrParam->GetBool(IS_PRESENTATION) || !attrParam->IsSet(PRESENTATION_ID, PT_INTEGER))
+ continue;
+ allPrsEntries.append(child->GetID());
+ }
+ }
+ }
+
+ // update visibility state of objects
+ LightApp_Application* app = dynamic_cast<LightApp_Application*>(SUIT_Session::session()->activeApplication());
+ if (!app)
+ return;
+ SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
+ if (!appStudy)
+ return;
+ SUIT_Study* activeStudy = app->activeStudy();
+ if (!activeStudy)
+ return;
+ SUIT_ViewWindow* aViewWindow = app->desktop()->activeWindow();
+ if (!aViewWindow)
+ return;
+ SUIT_ViewManager* aViewManager = aViewWindow->getViewManager();
+ if (!aViewManager)
+ return;
+
+ SUIT_ViewModel * aViewModel = aViewManager->getViewModel();
+ DataObjectList aList;
+ for(const auto& str : workList) {
+ aList.append(appStudy->findObjectByEntry(str));
+ }
+ app->updateVisibilityState(aList, aViewModel);
+
}
void
}
return -1;
}
+
+LightApp_Displayer* MEDModule::displayer()
+{
+ if (!_displayer)
+ _displayer = new MEDCALCGUI_Displayer(_presentationController);
+ return _displayer;
+}
+
+void MEDModule::visibilityStateUpdateOff() {
+ _enableVisibilityStateUpdate = false;
+}
+void MEDModule::visibilityStateUpdateOn() {
+ _enableVisibilityStateUpdate = true;
+}
\ No newline at end of file
class SalomeApp_Application;
class PVViewer_GUIElements;
class MEDPresentationManager_i;
+class LightApp_Displayer;
/*!
* This class defines the gui of the MED module.
double getCurrentAnimationTimestamp();
+ virtual LightApp_Displayer* displayer() override;
+
+ void updateVisibilityState(const bool all=true, const QStringList& entries = QStringList());
+
+ void visibilityStateUpdateOff();
+ void visibilityStateUpdateOn();
+
signals:
void presentationSelected(int presId, const QString& presType, const QString& presName);
PVViewer_GUIElements* _pvGuiElements;
static MED_ORB::MED_Gen_var _MED_engine;
+
+ LightApp_Displayer* _displayer;
+
+ bool _enableVisibilityStateUpdate;
#ifdef MED_HAS_QTTESTING
TestController * _testController;
_presManager->getPresentationIntProperty(_presId, MEDPresentation::PROP_COLOR_MAP.c_str()));
_scalarBarRange = static_cast<MEDCALC::ScalarBarRangeType>(
_presManager->getPresentationIntProperty(_presId, MEDPresentation::PROP_SCALAR_BAR_RANGE.c_str()));
+
+ _scalarBarVisibility = static_cast<bool>(
+ _presManager->getPresentationIntProperty(_presId, MEDPresentation::PROP_SCALAR_BAR_VISIBILITY.c_str()));
+
+ _scalarBarRangeArray[0] = _presManager->getPresentationDoubleProperty(_presId, MEDPresentation::PROP_SCALAR_BAR_MIN_VALUE.c_str());
+ _scalarBarRangeArray[1] = _presManager->getPresentationDoubleProperty(_presId, MEDPresentation::PROP_SCALAR_BAR_MAX_VALUE.c_str());
+
+ _hideDataOutsideCustomRange = _presManager->getPresentationIntProperty(_presId, MEDPresentation::PROP_HIDE_DATA_OUTSIDE_CUSTOM_RANGE.c_str());
}
void MEDWidgetHelper::updateWidget(bool connect)
STDLOG("MEDWidgetHelper::udpateWidget() scalarBarRange is " << _scalarBarRange);
_paramWidget->setScalarBarRange(_scalarBarRange);
+ _paramWidget->setScalarBarVisibility(_scalarBarVisibility);
+
+ _paramWidget->setScalarBarRangeValue(_scalarBarRangeArray[0], _scalarBarRangeArray[1]);
+
+ _paramWidget->setHideDataOutsideCustomRange(_hideDataOutsideCustomRange);
+
if (connect)
{
QObject::connect( this, SIGNAL(presentationUpdateSignal(const PresentationEvent *)),
_presController, SIGNAL(presentationSignal(const PresentationEvent *)) );
QObject::connect( _paramWidget, SIGNAL(comboScalarBarRangeIndexChanged(int)), this, SLOT(onScalarBarRangeChanged(int)) );
QObject::connect( _paramWidget, SIGNAL(comboColorMapIndexChanged(int)), this, SLOT(onColorMapChanged(int)) );
- }
+ QObject::connect( _paramWidget, SIGNAL(checkboxScalarBarVisibilityChanged(int)), this, SLOT(onScalarBarVisibilityChanged(int)) );
+ QObject::connect( _paramWidget, SIGNAL(checkboxCustomRangeChanged(int)), this, SLOT(onUseCustomRangeChanged(int)));
+ QObject::connect( _paramWidget, SIGNAL(spinboxCustomRangeChanged(double, double)), this, SLOT(onCustomRangeValueChanged(double, double)));
+ QObject::connect( _paramWidget, SIGNAL(checkboxHideDataOutsideCustomRangeChanged(int)), this, SLOT(onHideDataOutsideCustomRangeChanged(int)));
+ }
}
void MEDWidgetHelper::releaseWidget()
_presController, SIGNAL(presentationSignal(const PresentationEvent *)) );
QObject::disconnect( _paramWidget, SIGNAL(comboScalarBarRangeIndexChanged(int)), this, SLOT(onScalarBarRangeChanged(int)) );
QObject::disconnect( _paramWidget, SIGNAL(comboColorMapIndexChanged(int)), this, SLOT(onColorMapChanged(int)) );
+ QObject::disconnect( _paramWidget, SIGNAL(checkboxScalarBarVisibilityChanged(int)), this, SLOT(onScalarBarVisibilityChanged(int)));
+ QObject::disconnect( _paramWidget, SIGNAL(checkboxCustomRangeChanged(int)), this, SLOT(onUseCustomRangeChanged(int)));
+ QObject::disconnect( _paramWidget, SIGNAL(spinboxCustomRangeChanged(double, double)), this, SLOT(onCustomRangeChanged(double, double)));
+ QObject::disconnect( _paramWidget, SIGNAL(checkboxHideDataOutsideCustomRangeChanged(int)), this, SLOT(onHideDataOutsideCustomRangeChanged(int)));
+
+
// Reset default for color map and scalar bar range
_paramWidget->setColorMap(MEDCALC::COLOR_MAP_DEFAULT);
_paramWidget->setScalarBarRange(MEDCALC::SCALAR_BAR_RANGE_DEFAULT);
}
+void MEDWidgetHelper::onScalarBarVisibilityChanged(int flag) {
+ STDLOG("MEDWidgetHelper::onScalarBarVisibilityChanged");
+ PresentationEvent* event = new PresentationEvent();
+ event->eventtype = PresentationEvent::EVENT_SCALAR_BAR_VISIBILITY_CHANGED;
+ event->presentationId = _presId;
+ event->anInteger = flag;
+
+ emit presentationUpdateSignal(event); // --> PresentationController::processPresentationEvent
+}
+
void MEDWidgetHelper::onComponentChanged(int idx)
{
STDLOG("MEDWidgetHelper::onComponentChanged");
emit presentationUpdateSignal(event); // --> PresentationController::processPresentationEvent
}
+
+void MEDWidgetHelper::onUseCustomRangeChanged(int flag) {
+ STDLOG("MEDWidgetHelper::onUseCustomRangeChanged");
+ PresentationEvent* event = new PresentationEvent();
+ event->eventtype = PresentationEvent::EVENT_CHANGE_TIME_RANGE;
+ event->presentationId = _presId;
+ event->anInteger = flag ? _paramWidget->getRangeComboBox()->count() : _paramWidget->getRangeComboBox()->currentIndex();
+ event->aDouble1 = _paramWidget->getMixCustomRange();
+ event->aDouble2 = _paramWidget->getMaxCustomRange();
+
+ emit presentationUpdateSignal(event); // --> PresentationController::processPresentationEvent
+}
+
+void MEDWidgetHelper::onCustomRangeValueChanged(double min, double max) {
+ STDLOG("MEDWidgetHelper::onCustomRangeChanged");
+ PresentationEvent* event = new PresentationEvent();
+ event->eventtype = PresentationEvent::EVENT_CUSTOM_RANGE_CHANGED;
+ event->presentationId = _presId;
+ event->aDouble1 = min;
+ event->aDouble2 = max;
+
+ emit presentationUpdateSignal(event); // --> PresentationController::processPresentationEvent
+}
+
+void MEDWidgetHelper::onHideDataOutsideCustomRangeChanged(int flag) {
+ STDLOG("MEDWidgetHelper::onCustomRangeFlagChanged");
+ PresentationEvent* event = new PresentationEvent();
+ event->eventtype = PresentationEvent::EVENT_HIDE_DATA_OUTSIDE_CUSTOM_RANGE_CHANGED;
+ event->presentationId = _presId;
+ event->anInteger = flag;
+ event->aDouble1 = _paramWidget->getMixCustomRange();
+ event->aDouble2 = _paramWidget->getMaxCustomRange();
+
+ emit presentationUpdateSignal(event); // --> PresentationController::processPresentationEvent
+}
\ No newline at end of file
void onComponentChanged(int idx);
void onColorMapChanged(int idx);
void onScalarBarRangeChanged(int idx);
+ void onScalarBarVisibilityChanged(int idx);
+ void onUseCustomRangeChanged(int idx);
+ void onCustomRangeValueChanged(double min, double max);
+ void onHideDataOutsideCustomRangeChanged(int idx);
+
protected:
///! GUI needs to talk directly to the pres manager to activate a view, get some params, etc ...:
int _selectedCompo; // Selected field component
int _nbCompos; // Total number of available components
std::vector<std::string> _allCompos; // All available components
+ bool _scalarBarVisibility;
+ double _scalarBarRangeArray[2];
+ bool _hideDataOutsideCustomRange;
// Color map
MEDCALC::ColorMapType _colorMap;
MEDCALC::MEDPresentationManager_ptr presManager, int presId,
const std::string & presName, WidgetPresentationParameters * paramW):
MEDWidgetHelper(presController, presManager, presId, presName, paramW),
- _nbContours(-1)
+ _nbContours(-1),
+ _contourComponent(0)
{}
MEDWidgetHelperContour::~MEDWidgetHelperContour()
{
MEDWidgetHelper::loadParametersFromEngine();
_nbContours = _presManager->getPresentationIntProperty(_presId, MEDPresentationContour::PROP_NB_CONTOUR.c_str());
+ _contourComponent = _presManager->getPresentationIntProperty(_presId, MEDPresentationContour::PROB_CONTOUR_COMPONENT_ID.c_str());
+
}
void MEDWidgetHelperContour::updateWidget(bool connect)
// Contour presentation needs the number of contours
_paramWidget->setNbContour(_nbContours);
+ _paramWidget->setContourComponents(_allCompos, _contourComponent);
// Connect combo box changes
if (connect)
QObject::connect( this, SIGNAL(presentationUpdateSignal(const PresentationEvent *)),
_presController, SIGNAL(presentationSignal(const PresentationEvent *)) );
QObject::connect( _paramWidget, SIGNAL(spinBoxValueChanged(int)), this, SLOT(onNbContourChanged(int)) );
+ QObject::connect( _paramWidget, SIGNAL(comboContCompIndexChanged(int)), this, SLOT(onContourComponentTypeChanged(int)) );
}
+ if(_nbCompos == 1)
+ _paramWidget->hideContourComponent();
}
void MEDWidgetHelperContour::releaseWidget()
QObject::disconnect( this, SIGNAL(presentationUpdateSignal(const PresentationEvent *)),
_presController, SIGNAL(presentationSignal(const PresentationEvent *)) );
-// QObject::disconnect( _paramWidget, SIGNAL(comboCompoIndexChanged(int)), this, SLOT(onComponentChanged(int)) );
QObject::disconnect( _paramWidget, SIGNAL(spinBoxValueChanged(int)), this, SLOT(onNbContourChanged(int)) );
+ QObject::disconnect( _paramWidget, SIGNAL(comboContCompIndexChanged(int)), this, SLOT(onContourComponentTypeChanged(int)) );
}
void MEDWidgetHelperContour::onNbContourChanged(int nbContour)
emit presentationUpdateSignal(event); // --> PresentationController::processPresentationEvent
}
+void MEDWidgetHelperContour::onContourComponentTypeChanged(int index)
+{
+ STDLOG("MEDWidgetHelperContour::onContourComponentTypeChanged");
+ PresentationEvent* event = new PresentationEvent();
+ event->eventtype = PresentationEvent::EVENT_CHANGE_CONTOUR_COMPONENT;
+ event->presentationId = _presId;
+ event->anInteger = index;
+ event->aString = _paramWidget->getContourComponent();
+
+ emit presentationUpdateSignal(event); // --> PresentationController::processPresentationEvent
+}
\ No newline at end of file
protected slots:
void onNbContourChanged(int nbContour);
+ void onContourComponentTypeChanged(int index);
protected:
virtual void loadParametersFromEngine();
private:
int _nbContours;
+ int _contourComponent;
};
#endif /* SRC_MEDCALC_GUI_MEDWIDGETHELPERCONTOUR_HXX_ */
--- /dev/null
+// Copyright (C) 2016-2021 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 "MEDWidgetHelperCutSegment.hxx"
+#include "MEDPresentationCutSegment.hxx" // from component side.
+#include "PresentationController.hxx"
+
+#include <Basics_Utils.hxx>
+
+#include <sstream>
+
+MEDWidgetHelperCutSegment::MEDWidgetHelperCutSegment(const PresentationController* presController,
+ MEDCALC::MEDPresentationManager_ptr presManager, int presId, const std::string & presName,
+ WidgetPresentationParameters * paramW):
+ MEDWidgetHelper(presController, presManager, presId, presName, paramW)
+ {}
+
+MEDWidgetHelperCutSegment::~MEDWidgetHelperCutSegment()
+{}
+
+void MEDWidgetHelperCutSegment::loadParametersFromEngine()
+{
+ MEDWidgetHelper::loadParametersFromEngine();
+ _point1[0] = _presManager->getPresentationDoubleProperty(_presId, MEDPresentationCutSegment::PROP_POINT1_X.c_str());
+ _point1[1] = _presManager->getPresentationDoubleProperty(_presId, MEDPresentationCutSegment::PROP_POINT1_Y.c_str());
+ _point1[2] = _presManager->getPresentationDoubleProperty(_presId, MEDPresentationCutSegment::PROP_POINT1_Z.c_str());
+ _point2[0] = _presManager->getPresentationDoubleProperty(_presId, MEDPresentationCutSegment::PROP_POINT2_X.c_str());
+ _point2[1] = _presManager->getPresentationDoubleProperty(_presId, MEDPresentationCutSegment::PROP_POINT2_Y.c_str());
+ _point2[2] = _presManager->getPresentationDoubleProperty(_presId, MEDPresentationCutSegment::PROP_POINT2_Z.c_str());
+}
+
+void MEDWidgetHelperCutSegment::updateWidget(bool connect)
+{
+ MEDWidgetHelper::updateWidget(connect);
+
+ _paramWidget->setCutPoint1(_point1[0], _point1[1], _point1[2]);
+ _paramWidget->setCutPoint2(_point2[0], _point2[1], _point2[2]);
+
+ // Connect spin boxes changes
+ if (connect)
+ {
+ QObject::connect( _paramWidget, SIGNAL(spinCutPoint1ValuesChanged(double, double, double)), this, SLOT(onCutPoint1Changed(double, double, double)) );
+ QObject::connect( _paramWidget, SIGNAL(spinCutPoint2ValuesChanged(double, double, double)), this, SLOT(onCutPoint2Changed(double, double, double)) );
+ }
+}
+
+void MEDWidgetHelperCutSegment::releaseWidget()
+{
+ MEDWidgetHelper::releaseWidget();
+
+ QObject::disconnect( _paramWidget, SIGNAL(spinCutPoint1ValuesChanged(double, double, double)), this, SLOT(onCutPoint1Changed(double, double, double)) );
+ QObject::disconnect( _paramWidget, SIGNAL(spinCutPoint2ValuesChanged(double, double, double)), this, SLOT(onCutPoint2Changed(double, double, double)) );
+}
+
+void MEDWidgetHelperCutSegment::onCutPoint1Changed(double x, double y, double z)
+{
+ STDLOG("MEDWidgetHelperCutSegment::onCutPoint1Changed");
+ PresentationEvent* event = new PresentationEvent();
+ event->eventtype = PresentationEvent::EVENT_CHANGE_CUT_POINT1;
+ event->presentationId = _presId;
+ event->aDoubleP1[0] = x;
+ event->aDoubleP1[1] = y;
+ event->aDoubleP1[2] = z;
+
+ emit presentationUpdateSignal(event); // --> PresentationController::processPresentationEvent
+}
+
+void MEDWidgetHelperCutSegment::onCutPoint2Changed(double x, double y, double z)
+{
+ STDLOG("MEDWidgetHelperCutSegment::onCutPoint2Changed");
+ PresentationEvent* event = new PresentationEvent();
+ event->eventtype = PresentationEvent::EVENT_CHANGE_CUT_POINT2;
+ event->presentationId = _presId;
+ event->aDoubleP2[0] = x;
+ event->aDoubleP2[1] = y;
+ event->aDoubleP2[2] = z;
+
+ emit presentationUpdateSignal(event); // --> PresentationController::processPresentationEvent
+}
\ No newline at end of file
--- /dev/null
+// Copyright (C) 2016-2021 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_MEDWIDGETHELPERCUTSEGMENT_HXX_
+#define SRC_MEDCALC_GUI_MEDWIDGETHELPERCUTSEGMENT_HXX_
+
+#include "MEDWidgetHelperComponent.hxx"
+
+class PresentationController;
+
+class MEDWidgetHelperCutSegment: public MEDWidgetHelper
+{
+ Q_OBJECT
+
+public:
+ MEDWidgetHelperCutSegment(const PresentationController* presController,
+ MEDCALC::MEDPresentationManager_ptr presManager, int presId, const std::string & presName,
+ WidgetPresentationParameters * paramW);
+
+ virtual ~MEDWidgetHelperCutSegment();
+
+ virtual void updateWidget(bool connect);
+ virtual void releaseWidget();
+
+ virtual std::string getPythonTag() const { return "CutSegment"; }
+
+protected slots:
+ void onCutPoint1Changed(double, double, double);
+ void onCutPoint2Changed(double, double, double);
+
+protected:
+ virtual void loadParametersFromEngine();
+
+private:
+ double _point1[3];
+ double _point2[3];
+};
+
+#endif /* SRC_MEDCALC_GUI_MEDWIDGETHELPERCUTSEGMENT_HXX_ */
--- /dev/null
+// Copyright (C) 2016-2021 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 "MEDWidgetHelperPlot3D.hxx"
+#include "MEDPresentationPlot3D.hxx" // from component side.
+#include "PresentationController.hxx"
+
+#include <Basics_Utils.hxx>
+
+#include <sstream>
+
+MEDWidgetHelperPlot3D::MEDWidgetHelperPlot3D(const PresentationController* presController,
+ MEDCALC::MEDPresentationManager_ptr presManager, int presId, const std::string & presName,
+ WidgetPresentationParameters * paramW):
+ MEDWidgetHelper(presController, presManager, presId, presName, paramW)
+ {}
+
+MEDWidgetHelperPlot3D::~MEDWidgetHelperPlot3D()
+{}
+
+void MEDWidgetHelperPlot3D::loadParametersFromEngine()
+{
+ MEDWidgetHelper::loadParametersFromEngine();
+ _planeNormal[0] = _presManager->getPresentationDoubleProperty(_presId, MEDPresentationPlot3D::PROP_PLANE_NORMAL_X.c_str());
+ _planeNormal[1] = _presManager->getPresentationDoubleProperty(_presId, MEDPresentationPlot3D::PROP_PLANE_NORMAL_Y.c_str());
+ _planeNormal[2] = _presManager->getPresentationDoubleProperty(_presId, MEDPresentationPlot3D::PROP_PLANE_NORMAL_Z.c_str());
+ _planePos = _presManager->getPresentationDoubleProperty(_presId, MEDPresentationPlot3D::PROP_PLANE_POS.c_str());
+ _isPlanar = _presManager->getPresentationIntProperty(_presId, MEDPresentationPlot3D::PROP_IS_PLANAR.c_str());
+}
+
+void MEDWidgetHelperPlot3D::updateWidget(bool connect)
+{
+ MEDWidgetHelper::updateWidget(connect);
+
+ _paramWidget->setNormal(_planeNormal[0], _planeNormal[1], _planeNormal[2]);
+ _paramWidget->setPlanePosition(_planePos);
+
+ // Connect spin boxes changes
+ if (connect)
+ {
+ QObject::connect( _paramWidget, SIGNAL(spinNormalValuesChanged(double, double, double)), this, SLOT(onPlaneNormalChanged(double, double, double)) );
+ QObject::connect( _paramWidget, SIGNAL(spinPlanePosValueChanged(double)), this, SLOT(onPlanePositionChanged(double)) );
+ }
+ if(_isPlanar)
+ _paramWidget->hidePlot3D();
+}
+
+void MEDWidgetHelperPlot3D::releaseWidget()
+{
+ MEDWidgetHelper::releaseWidget();
+
+ QObject::disconnect( _paramWidget, SIGNAL(spinNormalValuesChanged(double, double, double)), this, SLOT(onPlaneNormalChanged(double, double, double)) );
+ QObject::disconnect( _paramWidget, SIGNAL(spinPlanePosValueChanged(double)), this, SLOT(onPlanePositionChanged(double)) );
+}
+
+void MEDWidgetHelperPlot3D::onPlaneNormalChanged(double normX, double normY, double normZ)
+{
+ STDLOG("MEDWidgetHelperSlices::onNbSlicesChanged");
+ PresentationEvent* event = new PresentationEvent();
+ event->eventtype = PresentationEvent::EVENT_CHANGE_NORMAL;
+ event->presentationId = _presId;
+ event->aDoubleN[0] = normX;
+ event->aDoubleN[1] = normY;
+ event->aDoubleN[2] = normZ;
+
+ emit presentationUpdateSignal(event); // --> PresentationController::processPresentationEvent
+}
+
+void MEDWidgetHelperPlot3D::onPlanePositionChanged(double planePos)
+{
+ STDLOG("MEDWidgetHelperSlices::onNbSlicesChanged");
+ PresentationEvent* event = new PresentationEvent();
+ event->eventtype = PresentationEvent::EVENT_CHANGE_PLANE_POS;
+ event->presentationId = _presId;
+ event->aDouble3 = planePos;
+
+ emit presentationUpdateSignal(event); // --> PresentationController::processPresentationEvent
+}
\ No newline at end of file
--- /dev/null
+// Copyright (C) 2016-2021 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_MEDWIDGETHELPERPLOT3D_HXX_
+#define SRC_MEDCALC_GUI_MEDWIDGETHELPERPLOT3D_HXX_
+
+#include "MEDWidgetHelper.hxx"
+
+class PresentationController;
+
+class MEDWidgetHelperPlot3D: public MEDWidgetHelper
+{
+ Q_OBJECT
+
+public:
+ MEDWidgetHelperPlot3D(const PresentationController* presController,
+ MEDCALC::MEDPresentationManager_ptr presManager, int presId, const std::string & presName,
+ WidgetPresentationParameters * paramW);
+
+ virtual ~MEDWidgetHelperPlot3D();
+
+ virtual void updateWidget(bool connect);
+ virtual void releaseWidget();
+
+ virtual std::string getPythonTag() const { return "Plot3D"; }
+
+protected slots:
+ void onPlaneNormalChanged(double, double, double);
+ void onPlanePositionChanged(double);
+
+protected:
+ virtual void loadParametersFromEngine();
+
+private:
+ double _planeNormal[3];
+ double _planePos;
+ int _isPlanar;
+};
+
+#endif /* SRC_MEDCALC_GUI_MEDWIDGETHELPERPLOT3D_HXX_ */
--- /dev/null
+// Copyright (C) 2016-2021 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 "MEDWidgetHelperStreamLines.hxx"
+#include "MEDPresentationStreamLines.hxx" // from component side.
+#include "PresentationController.hxx"
+
+#include <Basics_Utils.hxx>
+
+#include <sstream>
+
+MEDWidgetHelperStreamLines::MEDWidgetHelperStreamLines(const PresentationController* presController,
+ MEDCALC::MEDPresentationManager_ptr presManager, int presId, const std::string & presName,
+ WidgetPresentationParameters * paramW):
+ MEDWidgetHelper(presController, presManager, presId, presName, paramW)
+ {}
+
+MEDWidgetHelperStreamLines::~MEDWidgetHelperStreamLines()
+{}
+
+void MEDWidgetHelperStreamLines::loadParametersFromEngine()
+{
+ MEDWidgetHelper::loadParametersFromEngine();
+ _intDirType = static_cast<MEDCALC::IntegrationDirType>(
+ _presManager->getPresentationIntProperty(_presId, MEDPresentationStreamLines::PROP_INTEGR_DIR_TYPE.c_str()));
+}
+
+void MEDWidgetHelperStreamLines::updateWidget(bool connect)
+{
+ MEDWidgetHelper::updateWidget(connect);
+
+ _paramWidget->setIntegrationDir(_intDirType);
+
+ // Connect spin boxes changes
+ if (connect)
+ {
+ QObject::connect( _paramWidget, SIGNAL(comboIntegrDirIndexChanged(int)), this, SLOT(onIntegrDirTypeChanged(int)) );
+ }
+}
+
+void MEDWidgetHelperStreamLines::releaseWidget()
+{
+ MEDWidgetHelper::releaseWidget();
+
+ QObject::disconnect( _paramWidget, SIGNAL(comboIntegrDirIndexChanged(int)), this, SLOT(onIntegrDirTypeChanged(int)) );
+}
+
+void MEDWidgetHelperStreamLines::onIntegrDirTypeChanged(int index)
+{
+ STDLOG("MEDWidgetHelperStreamLines::onIntegrDirTypeChanged");
+ PresentationEvent* event = new PresentationEvent();
+ event->eventtype = PresentationEvent::EVENT_CHANGE_INTEGR_DIR;
+ event->presentationId = _presId;
+ event->anInteger = static_cast<int>(_paramWidget->getIntegrationDir());
+
+ emit presentationUpdateSignal(event); // --> PresentationController::processPresentationEvent
+}
+
--- /dev/null
+// Copyright (C) 2016-2021 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_MEDWIDGETHELPERSTREAMLINES_HXX_
+#define SRC_MEDCALC_GUI_MEDWIDGETHELPERSTREAMLINES_HXX_
+
+#include "MEDWidgetHelper.hxx"
+
+class PresentationController;
+
+class MEDWidgetHelperStreamLines: public MEDWidgetHelper
+{
+ Q_OBJECT
+
+public:
+ MEDWidgetHelperStreamLines(const PresentationController* presController,
+ MEDCALC::MEDPresentationManager_ptr presManager, int presId, const std::string & presName,
+ WidgetPresentationParameters * paramW);
+
+ virtual ~MEDWidgetHelperStreamLines();
+
+ virtual void updateWidget(bool connect);
+ virtual void releaseWidget();
+
+ virtual std::string getPythonTag() const { return "StreamLines"; }
+
+protected slots:
+ void onIntegrDirTypeChanged(int index);
+
+protected:
+ virtual void loadParametersFromEngine();
+
+private:
+ MEDCALC::IntegrationDirType _intDirType;
+};
+
+#endif /* SRC_MEDCALC_GUI_MEDWIDGETHELPERSTREAMLINES_HXX_ */
--- /dev/null
+// Copyright (C) 2016-2021 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 "MEDWidgetHelperVectorField.hxx"
+#include "MEDPresentationVectorField.hxx" // from component side.
+#include "PresentationController.hxx"
+
+#include <Basics_Utils.hxx>
+
+#include <sstream>
+
+
+MEDWidgetHelperVectorField::MEDWidgetHelperVectorField(const PresentationController* presController,
+ MEDCALC::MEDPresentationManager_ptr presManager, int presId, const std::string & presName,
+ WidgetPresentationParameters * paramW):
+ MEDWidgetHelper(presController, presManager, presId, presName, paramW)
+ {}
+MEDWidgetHelperVectorField::~MEDWidgetHelperVectorField() {}
+
+void MEDWidgetHelperVectorField::loadParametersFromEngine()
+{
+ MEDWidgetHelper::loadParametersFromEngine();
+ _scaleFactor = _presManager->getPresentationDoubleProperty(_presId, MEDPresentationVectorField::PROP_SCALE_FACTOR.c_str());
+ _customScaleFactor = _presManager->getPresentationIntProperty(_presId, MEDPresentationVectorField::PROP_CUSTOM_SCALE_FACTOR.c_str());
+}
+
+void MEDWidgetHelperVectorField::updateWidget(bool connect)
+{
+ MEDWidgetHelper::updateWidget(connect);
+ _paramWidget->setScaleFactor(_scaleFactor);
+ _paramWidget->setScaleFactorFlag(_customScaleFactor);
+
+ // Connect spin boxes changes
+ if (connect)
+ {
+ QObject::connect( _paramWidget, SIGNAL(spinboxScaleFactorChaged(double)), this, SLOT(onScaleFactorChanged(double)) );
+ QObject::connect( _paramWidget, SIGNAL(checkboxCustomScaleFactorChanged(int)), this, SLOT(onCustomScaleFactorChanged(int)));
+
+ }
+}
+
+void MEDWidgetHelperVectorField::releaseWidget()
+{
+ MEDWidgetHelper::releaseWidget();
+
+ QObject::disconnect( _paramWidget, SIGNAL(spinboxScaleFactorChaged(double)), this, SLOT(onScaleFactorChanged(double)) );
+}
+
+void MEDWidgetHelperVectorField::onScaleFactorChanged(double scale)
+{
+ STDLOG("MEDWidgetHelperVectorField::onScaleFactorChanged");
+ PresentationEvent* event = new PresentationEvent();
+ event->eventtype = PresentationEvent::EVENT_CHANGE_SCALE_FACTOR;
+ event->presentationId = _presId;
+ event->aDouble3 = scale;
+
+ emit presentationUpdateSignal(event); // --> PresentationController::processPresentationEvent
+}
+
+void MEDWidgetHelperVectorField::onCustomScaleFactorChanged(int flag)
+{
+ STDLOG("MEDWidgetHelperVectorField::onScaleFactorChanged");
+ PresentationEvent* event = new PresentationEvent();
+ event->eventtype = PresentationEvent::EVENT_CHANGE_CUSTOM_SCALE_FACTOR;
+ event->presentationId = _presId;
+ event->anInteger = flag;
+ event->aDouble3 = _paramWidget->getScaleFactor();
+
+ emit presentationUpdateSignal(event); // --> PresentationController::processPresentationEvent
+}
\ No newline at end of file
public:
MEDWidgetHelperVectorField(const PresentationController* presController,
MEDCALC::MEDPresentationManager_ptr presManager, int presId, const std::string & presName,
- WidgetPresentationParameters * paramW):
- MEDWidgetHelper(presController, presManager, presId, presName, paramW)
- {}
- virtual ~MEDWidgetHelperVectorField() {}
+ WidgetPresentationParameters * paramW);
+
+ virtual ~MEDWidgetHelperVectorField();
+
+ virtual void updateWidget(bool connect);
+ virtual void releaseWidget();
virtual std::string getPythonTag() const { return "VectorField"; }
+protected slots:
+ void onScaleFactorChanged(double);
+ void onCustomScaleFactorChanged(int);
+
+protected:
+ virtual void loadParametersFromEngine();
+ double _scaleFactor;
+ bool _customScaleFactor;
};
#endif /* SRC_MEDCALC_GUI_MEDWIDGETHELPERVECTORFIELD_HXX_ */
#include "MEDPresentationSlices.hxx"
#include "MEDPresentationPointSprite.hxx"
#include "MEDPresentationVectorField.hxx"
+#include "MEDPresentationPlot3D.hxx"
+#include "MEDPresentationStreamLines.hxx"
+#include "MEDPresentationCutSegment.hxx"
#include "MEDPresentationDeflectionShape.hxx"
#include "MEDWidgetHelperMeshView.hxx"
#include "MEDWidgetHelperContour.hxx"
#include "MEDWidgetHelperSlices.hxx"
#include "MEDWidgetHelperPointSprite.hxx"
+#include "MEDWidgetHelperPlot3D.hxx"
+#include "MEDWidgetHelperStreamLines.hxx"
+#include "MEDWidgetHelperCutSegment.hxx"
#include "MEDWidgetHelperVectorField.hxx"
#include "MEDWidgetHelperDeflectionShape.hxx"
#include <SUIT_ResourceMgr.h>
#include <QMessageBox>
#include <sstream>
+#include <regex>
#include "MEDFactoryClient.hxx"
_salomeModule->action(actionId)->setIconVisibleInMenu(true);
_salomeModule->createMenu(actionId, presentationMenuId);
+ label = tr("LAB_PRESENTATION_PLOT3D");
+ tooltip = tr("TIP_PRESENTATION_PLOT3D");
+ icon = tr(_getIconName("ICO_PRESENTATION_PLOT3D").c_str());
+ actionId = _salomeModule->createStandardAction(label, this, SLOT(onVisualizePlot3D()),
+ icon, tooltip, FIELDSOp::OpPlot3D);
+ _salomeModule->createTool(actionId, presentationToolbarId);
+ _salomeModule->action(actionId)->setIconVisibleInMenu(true);
+ _salomeModule->createMenu(actionId, presentationMenuId);
+
+ label = tr("LAB_PRESENTATION_STREAM_LINES");
+ tooltip = tr("TIP_PRESENTATION_STREAM_LINES");
+ icon = tr(_getIconName("ICO_PRESENTATION_STREAM_LINES").c_str());
+ actionId = _salomeModule->createStandardAction(label, this, SLOT(onVisualizeStreamLines()),
+ icon, tooltip, FIELDSOp::OpStreamLines);
+ _salomeModule->createTool(actionId, presentationToolbarId);
+ _salomeModule->action(actionId)->setIconVisibleInMenu(true);
+ _salomeModule->createMenu(actionId, presentationMenuId);
+
+ label = tr("LAB_PRESENTATION_CUT_SEGMENT");
+ tooltip = tr("TIP_PRESENTATION_CUT_SEGMENT");
+ icon = tr(_getIconName("ICO_PRESENTATION_CUT_SEGMENT").c_str());
+ actionId = _salomeModule->createStandardAction(label, this, SLOT(onVisualizeCutSegment()),
+ icon, tooltip, FIELDSOp::OpCutSegment);
+ _salomeModule->createTool(actionId, presentationToolbarId);
+ _salomeModule->action(actionId)->setIconVisibleInMenu(true);
+ _salomeModule->createMenu(actionId, presentationMenuId);
+
+
// Separator
_salomeModule->createMenu(_salomeModule->separator(), presentationMenuId);
this->visualize(PresentationEvent::EVENT_VIEW_OBJECT_POINT_SPRITE);
}
+void
+PresentationController::onVisualizePlot3D()
+{
+ this->visualize(PresentationEvent::EVENT_VIEW_OBJECT_PLOT3D);
+}
+
+void
+PresentationController::onVisualizeStreamLines()
+{
+ this->visualize(PresentationEvent::EVENT_VIEW_OBJECT_STREAM_LINES);
+}
+
+void
+PresentationController::onVisualizeCutSegment()
+{
+ // Cut segment presentation "creates" new view, so switch off visibility state update
+ // because pqActiveObjects::viewChanged is emmited
+ _salomeModule->visibilityStateUpdateOff();
+ this->visualize(PresentationEvent::EVENT_VIEW_OBJECT_CUT_SEGMENT);
+ _salomeModule->visibilityStateUpdateOn();
+ _salomeModule->updateVisibilityState();
+}
+
void
PresentationController::onDeletePresentation()
{
QString
PresentationController::getScalarBarRangePython() const
{
- MEDCALC::ScalarBarRangeType colorMap = getSelectedScalarBarRange();
- switch(colorMap) {
+ MEDCALC::ScalarBarRangeType scalarBarRange = getSelectedScalarBarRange();
+ switch(scalarBarRange) {
case MEDCALC::SCALAR_BAR_ALL_TIMESTEPS: return "MEDCALC.SCALAR_BAR_ALL_TIMESTEPS";
case MEDCALC::SCALAR_BAR_CURRENT_TIMESTEP: return "MEDCALC.SCALAR_BAR_CURRENT_TIMESTEP";
+ case MEDCALC::SCALAR_BAR_CUSTOM_RANGE: return "MEDCALC.SCALAR_BAR_CUSTOM_RANGE";
}
return QString();
}
return QString();
}
+QString
+PresentationController::getIntegrDirTypePython(const int intDir) const
+{
+ MEDCALC::IntegrationDirType type = static_cast<MEDCALC::IntegrationDirType>(intDir);
+ switch(type) {
+ case MEDCALC::INTEGRATION_DIR_BOTH: return "MEDCALC.INTEGRATION_DIR_BOTH";
+ case MEDCALC::INTEGRATION_DIR_FORWARD: return "MEDCALC.INTEGRATION_DIR_FORWARD";
+ case MEDCALC::INTEGRATION_DIR_BACKWARD: return "MEDCALC.INTEGRATION_DIR_BACKWARD";
+ }
+ return QString();
+}
+
+
std::string
PresentationController::getPresTypeFromWidgetHelper(int presId) const
{
return "UNKNOWN";
}
+void
+PresentationController::emitPresentationSignal(const PresentationEvent* event)
+{
+ emit presentationSignal(event);
+}
+
void
PresentationController::processPresentationEvent(const PresentationEvent* event) {
// --> Send commands to SALOME Python console
.arg(fieldHandler->id).arg(viewMode).arg(scalarBarRange).arg(colorMap);
commands += QString("presentation_id");
}
- else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_DEFLECTION_SHAPE ) {
+ else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_PLOT3D ) {
+ commands += QString("presentation_id = medcalc.MakePlot3D(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_STREAM_LINES ) {
+ commands += QString("presentation_id = medcalc.MakeStreamLines(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_CUT_SEGMENT ) {
+ commands += QString("presentation_id = medcalc.MakeCutSegment(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), viewMode=%2, scalarBarRange=%3, colorMap=%4)")
.arg(fieldHandler->id).arg(viewMode).arg(scalarBarRange).arg(colorMap);
commands += QString("presentation_id");
commands += QString("medcalc.Update%1(%2, params)").arg(QString::fromStdString(typ)).arg(event->presentationId);
}
else if ( event->eventtype == PresentationEvent::EVENT_CHANGE_TIME_RANGE ) {
+ bool customRangeFlag =
+ (bool)_presManager->getPresentationIntProperty(event->presentationId, MEDPresentation::PROP_HIDE_DATA_OUTSIDE_CUSTOM_RANGE.c_str());
std::string typ = getPresTypeFromWidgetHelper(event->presentationId);
commands += QString("params = medcalc.Get%1Parameters(%2)").arg(QString::fromStdString(typ)).arg(event->presentationId);
commands += QString("params.scalarBarRange = %1").arg(getScalarBarRangePython());
+ if (getSelectedScalarBarRange() == MEDCALC::SCALAR_BAR_CUSTOM_RANGE) {
+ commands += QString("params.scalarBarRangeArray = [%1, %2]").arg(event->aDouble1).arg(event->aDouble2);
+ }
+ else {
+ if (customRangeFlag) // switch off hideDataOutsideCustomRange
+ {
+ commands += QString("params.hideDataOutsideCustomRange = False");
+ }
+ }
commands += QString("medcalc.Update%1(%2, params)").arg(QString::fromStdString(typ)).arg(event->presentationId);
}
else if ( event->eventtype == PresentationEvent::EVENT_CHANGE_NB_CONTOUR ) {
commands += QString("params.orientation = %1").arg(getSliceOrientationPython(event->anInteger));
commands += QString("medcalc.UpdateSlices(%1, params)").arg(event->presentationId);
}
+ else if ( event->eventtype == PresentationEvent::EVENT_CHANGE_PLANE_POS ) {
+ std::string typ = getPresTypeFromWidgetHelper(event->presentationId);
+ commands += QString("params = medcalc.GetPlot3DParameters(%2)").arg(event->presentationId);
+ commands += QString("params.planePos = %1").arg(event->aDouble3);
+ commands += QString("medcalc.UpdatePlot3D(%1, params)").arg(event->presentationId);
+ }
+ else if ( event->eventtype == PresentationEvent::EVENT_CHANGE_NORMAL ) {
+ std::string typ = getPresTypeFromWidgetHelper(event->presentationId);
+ commands += QString("params = medcalc.GetPlot3DParameters(%2)").arg(event->presentationId);
+ commands += QString("params.planeNormal = [%1, %2, %3]").arg(event->aDoubleN[0]).arg(event->aDoubleN[1]).arg(event->aDoubleN[2]);
+ commands += QString("medcalc.UpdatePlot3D(%1, params)").arg(event->presentationId);
+ }
+ else if ( event->eventtype == PresentationEvent::EVENT_CHANGE_CUT_POINT1 ) {
+ std::string typ = getPresTypeFromWidgetHelper(event->presentationId);
+ commands += QString("params = medcalc.GetCutSegmentParameters(%2)").arg(event->presentationId);
+ commands += QString("params.point1 = [%1, %2, %3]").arg(event->aDoubleP1[0]).arg(event->aDoubleP1[1]).arg(event->aDoubleP1[2]);
+ commands += QString("medcalc.UpdateCutSegment(%1, params)").arg(event->presentationId);
+ }
+ else if ( event->eventtype == PresentationEvent::EVENT_CHANGE_CUT_POINT2 ) {
+ std::string typ = getPresTypeFromWidgetHelper(event->presentationId);
+ commands += QString("params = medcalc.GetCutSegmentParameters(%2)").arg(event->presentationId);
+ commands += QString("params.point2 = [%1, %2, %3]").arg(event->aDoubleP2[0]).arg(event->aDoubleP2[1]).arg(event->aDoubleP2[2]);
+ commands += QString("medcalc.UpdateCutSegment(%1, params)").arg(event->presentationId);
+ }
+ else if ( event->eventtype == PresentationEvent::EVENT_CHANGE_INTEGR_DIR ) {
+ std::string typ = getPresTypeFromWidgetHelper(event->presentationId);
+ commands += QString("params = medcalc.GetStreamLinesParameters(%2)").arg(event->presentationId);
+ commands += QString("params.integrDir = %1").arg(getIntegrDirTypePython(event->anInteger));
+ commands += QString("medcalc.UpdateStreamLines(%1, params)").arg(event->presentationId);
+ }
+ else if ( event->eventtype == PresentationEvent::EVENT_CHANGE_CONTOUR_COMPONENT) {
+ std::string typ = getPresTypeFromWidgetHelper(event->presentationId);
+ commands += QString("params = medcalc.GetContourParameters(%2)").arg(event->presentationId);
+ commands += QString("params.contourComponent = '%1'").arg(event->aString.c_str());
+ commands += QString("medcalc.UpdateContour(%1, params)").arg(event->presentationId);
+ }
+ else if ( event->eventtype == PresentationEvent::EVENT_CHANGE_SCALE_FACTOR ) {
+ std::string typ = getPresTypeFromWidgetHelper(event->presentationId);
+ commands += QString("params = medcalc.GetVectorFieldParameters(%2)").arg(event->presentationId);
+ commands += QString("params.scaleFactor = %1").arg(event->aDouble3);
+ commands += QString("medcalc.UpdateVectorField(%1, params)").arg(event->presentationId);
+ }
+
+ else if (event->eventtype == PresentationEvent::EVENT_CHANGE_CUSTOM_SCALE_FACTOR) {
+ std::string typ = getPresTypeFromWidgetHelper(event->presentationId);
+ commands += QString("params = medcalc.GetVectorFieldParameters(%2)").arg(event->presentationId);
+ commands += QString("params.customScaleFactor = %1").arg(event->anInteger);
+ if(event->anInteger) {
+ commands += QString("params.scaleFactor = %1").arg(event->aDouble3);
+ }
+ commands += QString("medcalc.UpdateVectorField(%1, params)").arg(event->presentationId);
+ }
else if ( event->eventtype == PresentationEvent::EVENT_DELETE_PRESENTATION ) {
commands += QString("medcalc.RemovePresentation(%1)").arg(event->presentationId);
+
+ }
+ else if (event->eventtype == PresentationEvent::EVENT_DISPLAY_PRESENTATION ||
+ event->eventtype == PresentationEvent::EVENT_ERASE_PRESENTATION) {
+ commands += QString("params = medcalc.Get%1Parameters(%2)").arg(QString::fromStdString(getPresTypeFromWidgetHelper(event->presentationId)))
+ .arg(event->presentationId);
+ QString visility = event->eventtype == PresentationEvent::EVENT_DISPLAY_PRESENTATION ? QString("True") : QString("False");
+ commands += QString("params.visibility = %1").arg(visility);
+ commands += QString("medcalc.Update%1(%2, params)").arg(QString::fromStdString(getPresTypeFromWidgetHelper(event->presentationId)))
+ .arg(event->presentationId);
+ }
+ else if (event->eventtype == PresentationEvent::EVENT_SCALAR_BAR_VISIBILITY_CHANGED ||
+ event->eventtype == PresentationEvent::EVENT_HIDE_DATA_OUTSIDE_CUSTOM_RANGE_CHANGED) {
+ std::string typ = getPresTypeFromWidgetHelper(event->presentationId);
+ QString param;
+ switch (event->eventtype) {
+ case PresentationEvent::EVENT_SCALAR_BAR_VISIBILITY_CHANGED:
+ param = QString("scalarBarVisibility");
+ break;
+ case PresentationEvent::EVENT_HIDE_DATA_OUTSIDE_CUSTOM_RANGE_CHANGED:
+ param = QString("hideDataOutsideCustomRange");
+ break;
+ default: break;
+ }
+ commands += QString("params = medcalc.Get%1Parameters(%2)").arg(QString::fromStdString(typ)).arg(event->presentationId);
+ commands += QString("params.%1 = %2").arg(param).arg( event->anInteger ? QString("True") : QString("False"));
+ if (event->eventtype == PresentationEvent::EVENT_HIDE_DATA_OUTSIDE_CUSTOM_RANGE_CHANGED && event->anInteger) {
+ commands += QString("params.scalarBarRangeArray = [%1, %2]").arg(event->aDouble1).arg(event->aDouble2);
+ }
+ commands += QString("medcalc.Update%1(%2, params)").arg(QString::fromStdString(typ)).arg(event->presentationId);
+ }
+ else if (event->eventtype == PresentationEvent::EVENT_CUSTOM_RANGE_CHANGED)
+ {
+ std::string typ = getPresTypeFromWidgetHelper(event->presentationId);
+ commands += QString("params = medcalc.Get%1Parameters(%2)").arg(QString::fromStdString(typ)).arg(event->presentationId);
+ commands += QString("params.scalarBarRangeArray = [%1, %2]").arg(event->aDouble1).arg(event->aDouble2);
+ commands += QString("medcalc.Update%1(%2, params)").arg(QString::fromStdString(typ)).arg(event->presentationId);
}
else {
STDLOG("The event "<<event->eventtype<<" is not implemented yet");
wh = new MEDWidgetHelperVectorField(this, _presManager, presId, name, _widgetPresentationParameters);
else if (type == MEDPresentationPointSprite::TYPE_NAME)
wh = new MEDWidgetHelperPointSprite(this, _presManager, presId, name, _widgetPresentationParameters);
+ else if (type == MEDPresentationPlot3D::TYPE_NAME)
+ wh = new MEDWidgetHelperPlot3D(this, _presManager, presId, name, _widgetPresentationParameters);
+ else if (type == MEDPresentationStreamLines::TYPE_NAME)
+ wh = new MEDWidgetHelperStreamLines(this, _presManager, presId, name, _widgetPresentationParameters);
+ else if (type == MEDPresentationCutSegment::TYPE_NAME)
+ wh = new MEDWidgetHelperCutSegment(this, _presManager, presId, name, _widgetPresentationParameters);
else if (type == MEDPresentationDeflectionShape::TYPE_NAME)
wh = new MEDWidgetHelperDeflectionShape(this, _presManager, presId, name, _widgetPresentationParameters);
else
int presId = -1;
_salomeModule->itemClickGeneric(name, type, presId);
onPresentationSelected(presId, QString::fromStdString(type), QString::fromStdString(name));
+ updateVisibilityState(presId);
}
void
else {
updateTreeViewWithNewPresentation(event->dataId, event->presentationId);
_dealWithReplaceMode();
+ // Update parameter widget if shown: some parameters should be updated after presentation has been added
+ if (_currentWidgetHelper)
+ _currentWidgetHelper->updateWidget(false);
}
}
else if ( event->type == MEDCALC::EVENT_REMOVE_PRESENTATION ) {
if(_currentWidgetHelper)
_currentWidgetHelper->updateWidget(false);
}
+ else if (event->type == MEDCALC::EVENT_VISIBILITY_CHANGED) {
+ updateVisibilityState(event->presentationId);
+ }
}
void
{
_dockWidget->setVisible(isVisible);
}
+
+void PresentationController::updateVisibilityState(long presId)
+{
+ char* str = _salomeModule->engine()->getStudyPresentationEntry(presId);
+ if (str) {
+ QStringList entries;
+ entries.append(str);
+ _salomeModule->updateVisibilityState(false, entries);
+ }
+}
+
+std::string PresentationController::presentationName2Type(const std::string& name) {
+ return std::regex_replace(name, std::regex("MEDPresentation"), std::string(""));
+}
\ No newline at end of file
void showDockWidgets(bool isVisible);
std::string getPresTypeFromWidgetHelper(int presId) const;
+ static std::string presentationName2Type(const std::string& name);
void setConsoleDriver(XmedConsoleDriver* driver) { _consoleDriver = driver; };
+ void emitPresentationSignal(const PresentationEvent* event);
+
signals:
void presentationSignal(const PresentationEvent*);
void onVisualizeSlices();
void onVisualizeDeflectionShape();
void onVisualizePointSprite();
+ void onVisualizePlot3D();
+ void onVisualizeStreamLines();
+ void onVisualizeCutSegment();
void onDeletePresentation();
void onParavisDump();
void visualize(PresentationEvent::EventType);
void updateTreeViewWithNewPresentation(long dataId, long presentationId);
void updateTreeViewForPresentationRemoval(long presId);
+ void updateVisibilityState(long presId);
std::string _getIconName(const std::string&);
MEDWidgetHelper * findOrCreateWidgetHelper(MEDCALC::MEDPresentationManager_ptr presManager,
int presId, const std::string& type, const std::string& name);
QString getScalarBarRangePython() const;
QString getMeshModePython(const int mode) const;
QString getSliceOrientationPython(const int orient) const;
+ QString getIntegrDirTypePython(const int intDir) const;
+ QString getContourComponentTypePython(const int comp) const;
void _dealWithReplaceMode();
EVENT_VIEW_OBJECT_CONTOUR,
EVENT_VIEW_OBJECT_DEFLECTION_SHAPE,
EVENT_VIEW_OBJECT_POINT_SPRITE,
+ EVENT_VIEW_OBJECT_PLOT3D,
+ EVENT_VIEW_OBJECT_STREAM_LINES,
+ EVENT_VIEW_OBJECT_CUT_SEGMENT,
EVENT_VIEW_OBJECT_SCALAR_MAP,
EVENT_VIEW_OBJECT_SLICES,
EVENT_VIEW_OBJECT_VECTOR_FIELD,
EVENT_CHANGE_NB_CONTOUR,
EVENT_CHANGE_SLICE_ORIENTATION,
- EVENT_CHANGE_NB_SLICES
+ EVENT_CHANGE_NB_SLICES,
+
+ EVENT_CHANGE_NORMAL,
+ EVENT_CHANGE_PLANE_POS,
+
+ EVENT_CHANGE_INTEGR_DIR,
+
+ EVENT_CHANGE_CUT_POINT1,
+ EVENT_CHANGE_CUT_POINT2,
+
+ EVENT_CHANGE_CONTOUR_COMPONENT,
+
+ EVENT_CHANGE_SCALE_FACTOR,
+ EVENT_CHANGE_CUSTOM_SCALE_FACTOR,
+
+ EVENT_DISPLAY_PRESENTATION,
+ EVENT_ERASE_PRESENTATION,
+
+ EVENT_SCALAR_BAR_VISIBILITY_CHANGED,
+
+ EVENT_CUSTOM_RANGE_CHANGED,
+
+ EVENT_HIDE_DATA_OUTSIDE_CUSTOM_RANGE_CHANGED
};
EventType eventtype;
MEDCALC::FieldHandler * fieldHandler;
MEDCALC::MeshHandler * meshHandler;
int presentationId;
+ std::string presentationType; // presentation type (can be empty)
int anInteger; // multi-purpose variable
//int anInteger2; // multi-purpose variable
std::string aString; // multi-purpose variable
+ double aDouble1; // multi-purpose variable
+ double aDouble2; // multi-purpose variable
+ double aDouble3;
+ double aDoubleN[3]; // multi-purpose variable
+ double aDoubleP1[3]; // multi-purpose variable
+ double aDoubleP2[3]; // multi-purpose variable
} PresentationEvent;
#endif
else if ( event->type == MEDCALC::EVENT_REMOVE_PRESENTATION ) {
emit workspaceSignal(event); // forward to PresentationController
}
+ else if ( event->type == MEDCALC::EVENT_VISIBILITY_CHANGED ) {
+ emit workspaceSignal(event); // forward to PresentationController
+ }
else if ( event->type == MEDCALC::EVENT_MODIFY_PRESENTATION ) {
emit workspaceSignal(event); // forward to PresentationController
}
#include "WidgetPresentationParameters.hxx"
#include <Basics_Utils.hxx>
+#include <limits>
+
using namespace std;
WidgetPresentationParameters::WidgetPresentationParameters(QWidget* parent)
toggleWidget(false);
QObject::connect(_ui.comboBoxCompo, SIGNAL(activated(int)),
this, SLOT(onComboCompoIndexChanged(int)) );
- QObject::connect(_ui.comboBoxMesh, SIGNAL(activated(int)),
- this, SLOT(onComboMeshIndexChanged(int)) );
+ QObject::connect(_ui.comboBoxMesh, SIGNAL(activated(int)),
+ this, SLOT(onComboMeshIndexChanged(int)) );
QObject::connect(_ui.comboBoxScalarBarRange, SIGNAL(activated(int)),
this, SLOT(onComboScalarBarRangeIndexChanged(int)) );
QObject::connect(_ui.comboBoxColorMap, SIGNAL(activated(int)),
this, SLOT(onComboColorMapIndexChanged(int)) );
- QObject::connect(_ui.comboBoxSliceOrient, SIGNAL(activated(int)),
+ QObject::connect(_ui.comboBoxSliceOrient, SIGNAL(activated(int)),
this, SLOT(onComboOrientIndexChanged(int)) );
+ QObject::connect(_ui.comboBoxIntegrDir, SIGNAL(activated(int)),
+ this, SLOT(onComboIntegrDirIndexChanged(int)) );
+ QObject::connect(_ui.comboBoxContComp, SIGNAL(activated(int)),
+ this, SLOT(onComboContCompIndexChanged(int)) );
QObject::connect(_ui.spinBox, SIGNAL(editingFinished()),
this, SLOT(onSpinBoxEditingFinished()) );
+ QObject::connect(_ui.checkBoxShowScalarBar, SIGNAL(stateChanged(int)),
+ this, SLOT(onCheckboxScalarBarVisibilityChanged(int)));
+ QObject::connect(_ui.checkBoxCustomRange, SIGNAL(stateChanged(int)),
+ this, SLOT(onCheckboxCustomRangeChanged(int)));
+ QObject::connect(_ui.checkBoxScaleFactor, SIGNAL(stateChanged(int)),
+ this, SLOT(onCheckboxScaleFactorChanged(int)));
+ QObject::connect(_ui.checkBoxScaleFactor, SIGNAL(stateChanged(int)),
+ this, SLOT(onCheckboxCustomScaleFactorChanged(int)));
+ QObject::connect(_ui.spinCustomRangeMin, SIGNAL(editingFinished()),
+ this, SLOT(onSpinboxCustomRangeChanged()));
+ QObject::connect(_ui.spinCustomRangeMax, SIGNAL(editingFinished()),
+ this, SLOT(onSpinboxCustomRangeChanged()));
+ QObject::connect(_ui.spinScaleFactor, SIGNAL(editingFinished()),
+ this, SLOT(onSpinboxScaleFactorChanged()));
+ QObject::connect(_ui.checkBoxHideDataOutsideCR, SIGNAL(stateChanged(int)),
+ this, SLOT(onCheckboxHideDataOutsideCustomRangeChanged(int)));
+ QObject::connect(_ui.spinNormalX, SIGNAL(editingFinished()),
+ this, SLOT(onSpinNormalEditingFinished()) );
+ QObject::connect(_ui.spinNormalY, SIGNAL(editingFinished()),
+ this, SLOT(onSpinNormalEditingFinished()) );
+ QObject::connect(_ui.spinNormalZ, SIGNAL(editingFinished()),
+ this, SLOT(onSpinNormalEditingFinished()) );
+ QObject::connect(_ui.spinPoint1_X, SIGNAL(editingFinished()),
+ this, SLOT(onSpinCutPoint1EditingFinished()) );
+ QObject::connect(_ui.spinPoint1_Y, SIGNAL(editingFinished()),
+ this, SLOT(onSpinCutPoint1EditingFinished()) );
+ QObject::connect(_ui.spinPoint1_Z, SIGNAL(editingFinished()),
+ this, SLOT(onSpinCutPoint1EditingFinished()) );
+ QObject::connect(_ui.spinPoint2_X, SIGNAL(editingFinished()),
+ this, SLOT(onSpinCutPoint2EditingFinished()) );
+ QObject::connect(_ui.spinPoint2_Y, SIGNAL(editingFinished()),
+ this, SLOT(onSpinCutPoint2EditingFinished()) );
+ QObject::connect(_ui.spinPoint2_Z, SIGNAL(editingFinished()),
+ this, SLOT(onSpinCutPoint2EditingFinished()) );
+ QObject::connect(_ui.spinPlanePos, SIGNAL(editingFinished()),
+ this, SLOT(onSpinPlanePosEditingFinished()) );
+
+ // Disable Custom Range Spin boxes
+ _ui.spinCustomRangeMax->setEnabled(false);
+ _ui.spinCustomRangeMin->setEnabled(false);
+ _ui.spinScaleFactor->setEnabled(false);
+ _ui.checkBoxHideDataOutsideCR->setEnabled(false);
+
+ // Min and max values
+ _ui.spinCustomRangeMin->setRange(std::numeric_limits<double>::lowest(), std::numeric_limits<double>::max());
+ _ui.spinCustomRangeMax->setRange(std::numeric_limits<double>::lowest(), std::numeric_limits<double>::max());
+ _ui.spinNormalX->setRange(0.0, 1.0);
+ _ui.spinNormalY->setRange(0.0, 1.0);
+ _ui.spinNormalZ->setRange(0.0, 1.0);
+ _ui.spinPlanePos->setRange(0.0, 1.0);
}
void
if (!_blockSig) emit comboScalarBarRangeIndexChanged(idx);
}
+void
+WidgetPresentationParameters::onComboIntegrDirIndexChanged(int idx)
+{
+ if (!_blockSig) emit comboIntegrDirIndexChanged(idx);
+}
+
+void
+WidgetPresentationParameters::onComboContCompIndexChanged(int idx)
+{
+ if (!_blockSig) emit comboContCompIndexChanged(idx);
+}
+
+void
+WidgetPresentationParameters::onCheckboxScalarBarVisibilityChanged(int flag)
+{
+ if (!_blockSig) emit checkboxScalarBarVisibilityChanged(flag);
+}
+
+void
+WidgetPresentationParameters::onCheckboxCustomRangeChanged(int flag)
+{
+ _ui.spinCustomRangeMin->setEnabled(flag);
+ _ui.spinCustomRangeMax->setEnabled(flag);
+ _ui.checkBoxHideDataOutsideCR->setEnabled(flag);
+ _ui.comboBoxScalarBarRange->setEnabled(!flag);
+ if (!_blockSig) emit checkboxCustomRangeChanged(flag);
+}
+
+void
+WidgetPresentationParameters::onCheckboxScaleFactorChanged(int flag)
+{
+ _ui.spinScaleFactor->setEnabled(flag);
+ if (!_blockSig) emit checkboxScaleFactorChanged(flag);
+}
+
+void
+WidgetPresentationParameters::onSpinboxCustomRangeChanged()
+{
+ if (!_blockSig) emit spinboxCustomRangeChanged(_ui.spinCustomRangeMin->value(),
+ _ui.spinCustomRangeMax->value());
+}
+
+void
+WidgetPresentationParameters::onSpinboxScaleFactorChanged()
+{
+ if (!_blockSig) emit spinboxScaleFactorChaged(_ui.spinScaleFactor->value());
+}
+
+void
+WidgetPresentationParameters::
+onCheckboxHideDataOutsideCustomRangeChanged(int flag)
+{
+ if (!_blockSig) emit checkboxHideDataOutsideCustomRangeChanged(flag);
+}
+
+void
+WidgetPresentationParameters::
+onCheckboxCustomScaleFactorChanged(int flag) {
+ if (!_blockSig) emit checkboxCustomScaleFactorChanged(flag);
+}
+
void
WidgetPresentationParameters::onSpinBoxEditingFinished()
{
if (!_blockSig) emit spinBoxValueChanged(_ui.spinBox->value());
}
+void
+WidgetPresentationParameters::onSpinNormalEditingFinished()
+{
+ if (!_blockSig) emit spinNormalValuesChanged(_ui.spinNormalX->value(),
+ _ui.spinNormalY->value(),
+ _ui.spinNormalZ->value());
+}
+
+void
+WidgetPresentationParameters::onSpinCutPoint1EditingFinished()
+{
+ if (!_blockSig) emit spinCutPoint1ValuesChanged(_ui.spinPoint1_X->value(),
+ _ui.spinPoint1_Y->value(),
+ _ui.spinPoint1_Z->value());
+}
+
+void
+WidgetPresentationParameters::onSpinCutPoint2EditingFinished()
+{
+ if (!_blockSig) emit spinCutPoint2ValuesChanged(_ui.spinPoint2_X->value(),
+ _ui.spinPoint2_Y->value(),
+ _ui.spinPoint2_Z->value());
+}
+
+void
+WidgetPresentationParameters::onSpinPlanePosEditingFinished()
+{
+ if (!_blockSig) emit spinPlanePosValueChanged(_ui.spinPlanePos->value());
+}
+
+void
+WidgetPresentationParameters::hidePlot3D()
+{
+ _ui.labelCutPlanePosition->hide();
+ _ui.spinPlanePos->hide();
+}
+
+void
+WidgetPresentationParameters::hideContourComponent()
+{
+ _ui.labelContourComp->hide();
+ _ui.comboBoxContComp->hide();
+}
+
void
WidgetPresentationParameters::toggleCommonFieldWidget(bool show)
{
_ui.spinBox->hide();
_ui.labelSliceOrient->hide();
_ui.comboBoxSliceOrient->hide();
+ _ui.labelCutPlaneNormal->hide();
+ _ui.labelCutPlanePosition->hide();
+ _ui.spinNormalX->hide();
+ _ui.spinNormalY->hide();
+ _ui.spinNormalZ->hide();
+ _ui.spinPlanePos->hide();
+ _ui.labelIntegrDir->hide();
+ _ui.comboBoxIntegrDir->hide();
+ _ui.labelPoint1->hide();
+ _ui.spinPoint1_X->hide();
+ _ui.spinPoint1_Y->hide();
+ _ui.spinPoint1_Z->hide();
+ _ui.labelPoint2->hide();
+ _ui.spinPoint2_X->hide();
+ _ui.spinPoint2_Y->hide();
+ _ui.spinPoint2_Z->hide();
+ _ui.labelContourComp->hide();
+ _ui.comboBoxContComp->hide();
+ _ui.checkBoxScaleFactor->hide();
+ _ui.spinScaleFactor->hide();
_blockSig = false;
}
}
else if (sbrange == MEDCALC::SCALAR_BAR_CURRENT_TIMESTEP)
idx = _ui.comboBoxScalarBarRange->findText(tr("LAB_CURRENT_TIMESTEP"));
- if (idx >= 0)
- {
- _ui.comboBoxScalarBarRange->setCurrentIndex(idx);
+ if (idx >= 0) {
+ _ui.comboBoxScalarBarRange->setCurrentIndex(idx);
+ _ui.checkBoxCustomRange->setChecked(false);
}
- else
- {
- STDLOG("Strange!! No matching found - unable to set scalar bar range in GUI.");
+ else {
+ if (sbrange == MEDCALC::SCALAR_BAR_CUSTOM_RANGE) {
+ _ui.checkBoxCustomRange->setChecked(true);
+ } else {
+ STDLOG("Strange!! No matching found - unable to set scalar bar range in GUI.");
+ }
}
-
_blockSig = false;
}
_blockSig = false;
}
+void
+WidgetPresentationParameters::setIntegrationDir(MEDCALC::IntegrationDirType iDir)
+{
+ _blockSig = true;
+
+ // Show the widget;
+ _ui.labelIntegrDir->show();
+ _ui.comboBoxIntegrDir->show();
+
+ int idx;
+ switch(iDir)
+ {
+ case MEDCALC::INTEGRATION_DIR_BOTH:
+ idx = _ui.comboBoxIntegrDir->findText(tr("LAB_INTEGR_DIR_BOTH"));
+ break;
+ case MEDCALC::INTEGRATION_DIR_FORWARD:
+ idx = _ui.comboBoxIntegrDir->findText(tr("LAB_INTEGR_DIR_FORWARD"));
+ break;
+ case MEDCALC::INTEGRATION_DIR_BACKWARD:
+ idx = _ui.comboBoxIntegrDir->findText(tr("LAB_INTEGR_DIR_BACKWARD"));
+ break;
+ default:
+ idx = -1;
+ }
+ if (idx >= 0)
+ {
+ _ui.comboBoxIntegrDir->setCurrentIndex(idx);
+ }
+ else
+ {
+ STDLOG("Strange!! No matching found - unable to set integration direction in GUI.");
+ }
+
+ _blockSig = false;
+}
+
+void
+WidgetPresentationParameters::setContourComponents(std::vector<std::string> compos, int selecIndex)
+{
+ _blockSig = true;
+
+ // Show the widget;
+ _ui.labelContourComp->show();
+ _ui.comboBoxContComp->show();
+
+ _ui.comboBoxContComp->clear();
+ bool vectorField = (compos.size() > 1 && compos.size() <= 3);
+ if (vectorField)
+ _ui.comboBoxContComp->addItem(tr("LAB_EUCLIDEAN_NORM"));
+ for (vector<string>::const_iterator it = compos.begin(); it != compos.end(); ++it)
+ _ui.comboBoxContComp->addItem(QString::fromStdString(*it));
+ if (!vectorField)
+ _ui.comboBoxContComp->setCurrentIndex(std::max(0, selecIndex - 1));
+ else
+ _ui.comboBoxContComp->setCurrentIndex(selecIndex);
+
+ _blockSig = false;
+}
+
void
WidgetPresentationParameters::setSliceOrientation(MEDCALC::SliceOrientationType orient)
{
return MEDCALC::MESH_MODE_WIREFRAME;
}
+MEDCALC::IntegrationDirType
+WidgetPresentationParameters::getIntegrationDir() const
+{
+ QString iDir = _ui.comboBoxIntegrDir->currentText();
+ if (iDir == tr("LAB_INTEGR_DIR_BOTH")) {
+ return MEDCALC::INTEGRATION_DIR_BOTH;
+ }
+ else if (iDir == tr("LAB_INTEGR_DIR_FORWARD")) {
+ return MEDCALC::INTEGRATION_DIR_FORWARD;
+ }
+ else if (iDir == tr("LAB_INTEGR_DIR_BACKWARD")) {
+ return MEDCALC::INTEGRATION_DIR_BACKWARD;
+ }
+ // Should not happen
+ STDLOG("Strange!! No matching found - returning LAB_INTEGR_DIR_BOTH.");
+ return MEDCALC::INTEGRATION_DIR_BOTH;
+}
+
+std::string
+WidgetPresentationParameters::getContourComponent() const
+{
+ if (_ui.comboBoxContComp->count() > 1 && _ui.comboBoxContComp->count() <= 4)
+ if (_ui.comboBoxContComp->currentIndex() == 0) // Euclidean norm
+ return "";
+ return _ui.comboBoxContComp->currentText().toStdString();
+}
MEDCALC::ScalarBarRangeType
WidgetPresentationParameters::getScalarBarRange() const
{
+ if (_ui.checkBoxCustomRange->isChecked()) {
+ return MEDCALC::SCALAR_BAR_CUSTOM_RANGE;
+ }
QString sbrange = _ui.comboBoxScalarBarRange->currentText();
if (sbrange == tr("LAB_ALL_TIMESTEPS")) {
return MEDCALC::SCALAR_BAR_ALL_TIMESTEPS;
f.setItalic(true);
_ui.labelPresName->setFont(f);
}
+
+
+void
+WidgetPresentationParameters::getScalarBarRangeValue(double* arr) const
+{
+ arr[0] = _ui.spinCustomRangeMin->value();
+ arr[1] = _ui.spinCustomRangeMax->value();
+}
+
+void WidgetPresentationParameters::setScalarBarRangeValue(double aMin, double aMax) {
+ _blockSig = true;
+ _ui.spinCustomRangeMin->setValue(aMin);
+ _ui.spinCustomRangeMax->setValue(aMax);
+ _blockSig = false;
+}
+
+void WidgetPresentationParameters::setScaleFactor(double scale) {
+ _blockSig = true;
+
+ // Show widget:
+ _ui.checkBoxScaleFactor->show();
+ _ui.spinScaleFactor->show();
+
+ _ui.spinScaleFactor->setValue(scale);
+ _blockSig = false;
+}
+
+void WidgetPresentationParameters::getNormal(double* arr) const
+{
+ arr[0] = _ui.spinNormalX->value();
+ arr[1] = _ui.spinNormalY->value();
+ arr[2] = _ui.spinNormalZ->value();
+}
+
+void
+WidgetPresentationParameters::setNormal(const double normX, const double normY, const double normZ)
+{
+ _blockSig = true;
+ _ui.labelCutPlaneNormal->show();
+ _ui.spinNormalX->show();
+ _ui.spinNormalY->show();
+ _ui.spinNormalZ->show();
+ _ui.spinNormalX->setValue(normX);
+ _ui.spinNormalY->setValue(normY);
+ _ui.spinNormalZ->setValue(normZ);
+ _blockSig = false;
+}
+
+void WidgetPresentationParameters::getCutPoint1(double* arr) const
+{
+ arr[0] = _ui.spinPoint1_X->value();
+ arr[1] = _ui.spinPoint1_Y->value();
+ arr[2] = _ui.spinPoint1_Z->value();
+}
+
+void
+WidgetPresentationParameters::setCutPoint1(const double x, const double y, const double z)
+{
+ _blockSig = true;
+ _ui.labelPoint1->show();
+ _ui.spinPoint1_X->show();
+ _ui.spinPoint1_Y->show();
+ _ui.spinPoint1_Z->show();
+ _ui.spinPoint1_X->setValue(x);
+ _ui.spinPoint1_Y->setValue(y);
+ _ui.spinPoint1_Z->setValue(z);
+ _blockSig = false;
+}
+
+void WidgetPresentationParameters::getCutPoint2(double* arr) const
+{
+ arr[0] = _ui.spinPoint2_X->value();
+ arr[1] = _ui.spinPoint2_Y->value();
+ arr[2] = _ui.spinPoint2_Z->value();
+}
+
+void
+WidgetPresentationParameters::setCutPoint2(const double x, const double y, const double z)
+{
+ _blockSig = true;
+ _ui.labelPoint2->show();
+ _ui.spinPoint2_X->show();
+ _ui.spinPoint2_Y->show();
+ _ui.spinPoint2_Z->show();
+ _ui.spinPoint2_X->setValue(x);
+ _ui.spinPoint2_Y->setValue(y);
+ _ui.spinPoint2_Z->setValue(z);
+ _blockSig = false;
+}
+
+double WidgetPresentationParameters::getPlanePosition() const
+{
+ return _ui.spinPlanePos->value();
+}
+
+void WidgetPresentationParameters::setPlanePosition(double pos)
+{
+ _blockSig = true;
+ _ui.labelCutPlanePosition->show();
+ _ui.spinPlanePos->show();
+ _ui.spinPlanePos->setValue(pos);
+ _blockSig = false;
+}
+
+bool WidgetPresentationParameters::getScalarBarVisibility() const {
+ return _ui.checkBoxShowScalarBar->isChecked();
+}
+
+void WidgetPresentationParameters::setScalarBarVisibility(const bool visibility) {
+ _blockSig = true;
+ _ui.checkBoxShowScalarBar->setChecked(visibility);
+ _blockSig = false;
+}
+
+bool WidgetPresentationParameters::getHideDataOutsideCustomRange() const {
+ return _ui.checkBoxHideDataOutsideCR->isChecked();
+}
+
+void WidgetPresentationParameters::setHideDataOutsideCustomRange(const bool flag) {
+ _blockSig = true;
+ _ui.checkBoxHideDataOutsideCR->setChecked(flag);
+ _blockSig = false;
+}
+
+void WidgetPresentationParameters::setScaleFactorFlag(const bool flag) {
+ _blockSig = true;
+ _ui.checkBoxScaleFactor->setChecked(flag);
+ _blockSig = false;
+}
\ No newline at end of file
MEDCALC::ScalarBarRangeType getScalarBarRange() const;
void setScalarBarRange(MEDCALC::ScalarBarRangeType);
+ MEDCALC::IntegrationDirType getIntegrationDir() const;
+ void setIntegrationDir(MEDCALC::IntegrationDirType);
+
+ std::string getContourComponent() const;
+ void setContourComponents(std::vector<std::string> compos, int selecIndex);
+
+ bool getScalarBarVisibility() const;
+ void setScalarBarVisibility(const bool);
+
+ bool getHideDataOutsideCustomRange() const;
+ void setHideDataOutsideCustomRange(const bool);
+
+ void getScalarBarRangeValue( double* ) const;
+ void setScalarBarRangeValue(const double, const double);
+
+ double getScaleFactor() { return _ui.spinScaleFactor->value(); }
+ void setScaleFactor(double);
+
+ bool getScaleFactorFlag() { return _ui.checkBoxScaleFactor->isChecked(); }
+ void setScaleFactorFlag(const bool);
+
+ void getNormal( double * ) const;
+ void setNormal(const double, const double, const double);
+
+ void getCutPoint1( double *) const;
+ void setCutPoint1(const double, const double, const double);
+ void getCutPoint2( double *) const;
+ void setCutPoint2(const double, const double, const double);
+
+ void hidePlot3D();
+ void hideContourComponent();
+
+ double getPlanePosition() const;
+ void setPlanePosition( double );
+
// double getScalarBarTimestep() const;
// double getScalarBarMinVal() const;
// double getScalarBarMaxVal() const;
void toggleCommonFieldWidget(bool show);
+ QComboBox* getRangeComboBox() { return _ui.comboBoxScalarBarRange; }
+ double getMixCustomRange() { return _ui.spinCustomRangeMin->value(); }
+ double getMaxCustomRange() { return _ui.spinCustomRangeMax->value(); }
+
signals:
void comboScalarBarRangeIndexChanged(int);
void comboColorMapIndexChanged(int);
void comboCompoIndexChanged(int);
void comboOrientIndexChanged(int);
void comboMeshIndexChanged(int);
+ void comboIntegrDirIndexChanged(int);
+ void comboContCompIndexChanged(int);
void spinBoxValueChanged(int);
+ void spinNormalValuesChanged(double, double, double);
+ void spinCutPoint1ValuesChanged(double, double, double);
+ void spinCutPoint2ValuesChanged(double, double, double);
+ void spinPlanePosValueChanged(double);
+ void checkboxScalarBarVisibilityChanged(int);
+ void checkboxCustomRangeChanged(int);
+ void checkboxScaleFactorChanged(int);
+ void spinboxCustomRangeChanged(double, double);
+ void spinboxScaleFactorChaged(double);
+ void checkboxCustomScaleFactorChanged(int);
+ void checkboxHideDataOutsideCustomRangeChanged(int);
+
private slots:
void onComboScalarBarRangeIndexChanged(int);
void onComboCompoIndexChanged(int);
void onComboOrientIndexChanged(int);
void onComboMeshIndexChanged(int);
+ void onComboIntegrDirIndexChanged(int);
+ void onComboContCompIndexChanged(int);
void onSpinBoxEditingFinished();
-
+ void onSpinNormalEditingFinished();
+ void onSpinCutPoint1EditingFinished();
+ void onSpinCutPoint2EditingFinished();
+ void onSpinPlanePosEditingFinished();
+ void onCheckboxScalarBarVisibilityChanged(int);
+ void onCheckboxCustomRangeChanged(int);
+ void onCheckboxScaleFactorChanged(int);
+ void onSpinboxCustomRangeChanged();
+ void onSpinboxScaleFactorChanged();
+ void onCheckboxCustomScaleFactorChanged(int);
+ void onCheckboxHideDataOutsideCustomRangeChanged(int);
private:
- Ui_WidgetPresentationParameters _ui; // instance of the class defined in ui_WidgetPresentationParameters.h
+ Ui_WidgetPresentationParameters _ui; // instancte of the class defined in ui_WidgetPresentationParameters.h
bool _blockSig;
};
<rect>
<x>0</x>
<y>0</y>
- <width>784</width>
- <height>584</height>
+ <width>319</width>
+ <height>527</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>300</width>
- <height>200</height>
+ <height>310</height>
</size>
</property>
<property name="windowTitle">
<item>
<widget class="QWidget" name="commonWidget" native="true">
<layout class="QGridLayout" name="gridLayout_2">
- <item row="0" column="1">
- <widget class="QComboBox" name="comboBoxScalarBarRange">
+ <item row="2" column="1" colspan="2">
+ <widget class="QComboBox" name="comboBoxColorMap">
<property name="enabled">
<bool>true</bool>
</property>
<item>
<property name="text">
- <string>LAB_ALL_TIMESTEPS</string>
+ <string>LAB_BLUE_TO_RED</string>
</property>
</item>
<item>
<property name="text">
- <string>LAB_CURRENT_TIMESTEP</string>
+ <string>LAB_COOL_TO_WARM</string>
</property>
</item>
</widget>
</item>
- <item row="2" column="0">
- <widget class="QLabel" name="label_3">
+ <item row="3" column="1">
+ <widget class="QDoubleSpinBox" name="spinCustomRangeMin"/>
+ </item>
+ <item row="4" column="0" colspan="3">
+ <widget class="QCheckBox" name="checkBoxHideDataOutsideCR">
<property name="text">
- <string>LAB_COLOR_MAP</string>
+ <string>LAB_HIDE_DATA_OUTSIDE_CR</string>
</property>
</widget>
</item>
- <item row="0" column="0">
+ <item row="1" column="0">
<widget class="QLabel" name="label_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
</property>
</widget>
</item>
- <item row="2" column="1">
- <widget class="QComboBox" name="comboBoxColorMap">
+ <item row="3" column="0">
+ <widget class="QCheckBox" name="checkBoxCustomRange">
+ <property name="text">
+ <string>LAB_CUSTOM_RANGE</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>LAB_COLOR_MAP</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="2">
+ <widget class="QDoubleSpinBox" name="spinCustomRangeMax">
+ <property name="maximum">
+ <double>9999999999999999583119736832.000000000000000</double>
+ </property>
+ <property name="singleStep">
+ <double>0.500000000000000</double>
+ </property>
+ <property name="value">
+ <double>100.000000000000000</double>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1" colspan="2">
+ <widget class="QComboBox" name="comboBoxScalarBarRange">
<property name="enabled">
<bool>true</bool>
</property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<item>
<property name="text">
- <string>LAB_BLUE_TO_RED</string>
+ <string>LAB_ALL_TIMESTEPS</string>
</property>
</item>
<item>
<property name="text">
- <string>LAB_COOL_TO_WARM</string>
+ <string>LAB_CURRENT_TIMESTEP</string>
</property>
</item>
</widget>
</item>
+ <item row="0" column="0" colspan="3">
+ <widget class="QCheckBox" name="checkBoxShowScalarBar">
+ <property name="text">
+ <string>LAB_SHOW_SCALAR_BAR</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</item>
</property>
</widget>
</item>
- <item row="0" column="1">
+ <item row="0" column="1" colspan="3">
<widget class="QComboBox" name="comboBoxMesh">
<item>
<property name="text">
</property>
</widget>
</item>
- <item row="1" column="1">
+ <item row="1" column="1" colspan="3">
<widget class="QComboBox" name="comboBoxCompo">
<item>
<property name="text">
</property>
</widget>
</item>
- <item row="2" column="1">
+ <item row="2" column="1" colspan="3">
<widget class="QSpinBox" name="spinBox">
<property name="toolTip">
<string>LAB_SPINBOX_TOOLTIP</string>
</property>
</widget>
</item>
- <item row="2" column="2">
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>235</width>
- <height>20</height>
- </size>
+ <item row="3" column="0">
+ <widget class="QLabel" name="labelContourComp">
+ <property name="text">
+ <string>LAB_CONTOUR_COMP</string>
</property>
- </spacer>
+ </widget>
</item>
- <item row="3" column="0">
+ <item row="3" column="1" colspan="3">
+ <widget class="QComboBox" name="comboBoxContComp">
+ <item>
+ <property name="text">
+ <string>LAB_CONTOUR_MAGN</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>LAB_CONTOUR_X</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>LAB_CONTOUR_Y</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>LAB_CONTOUR_Z</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="4" column="0">
<widget class="QLabel" name="labelSliceOrient">
<property name="text">
<string>LAB_SLICE_ORIENT</string>
</property>
</widget>
</item>
- <item row="3" column="1">
+ <item row="4" column="1" colspan="3">
<widget class="QComboBox" name="comboBoxSliceOrient">
<item>
<property name="text">
</item>
</widget>
</item>
+ <item row="5" column="0">
+ <widget class="QLabel" name="labelCutPlaneNormal">
+ <property name="text">
+ <string>LAB_CUT_PLANE_NORMAL</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="1">
+ <widget class="QDoubleSpinBox" name="spinNormalX">
+ <property name="singleStep">
+ <double>0.050000000000000</double>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="2">
+ <widget class="QDoubleSpinBox" name="spinNormalY">
+ <property name="singleStep">
+ <double>0.050000000000000</double>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="3">
+ <widget class="QDoubleSpinBox" name="spinNormalZ">
+ <property name="singleStep">
+ <double>0.050000000000000</double>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="0">
+ <widget class="QLabel" name="labelCutPlanePosition">
+ <property name="text">
+ <string>LAB_CUT_PLANE_POS</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="1" colspan="3">
+ <widget class="QDoubleSpinBox" name="spinPlanePos">
+ <property name="singleStep">
+ <double>0.100000000000000</double>
+ </property>
+ </widget>
+ </item>
+ <item row="7" column="0">
+ <widget class="QLabel" name="labelIntegrDir">
+ <property name="text">
+ <string>LAB_INTEGR_DIR</string>
+ </property>
+ </widget>
+ </item>
+ <item row="7" column="1" colspan="3">
+ <widget class="QComboBox" name="comboBoxIntegrDir">
+ <property name="currentText">
+ <string>LAB_INTEGR_DIR_BOTH</string>
+ </property>
+ <property name="currentIndex">
+ <number>0</number>
+ </property>
+ <item>
+ <property name="text">
+ <string>LAB_INTEGR_DIR_BOTH</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>LAB_INTEGR_DIR_FORWARD</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>LAB_INTEGR_DIR_BACKWARD</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="8" column="0">
+ <widget class="QLabel" name="labelPoint1">
+ <property name="text">
+ <string>LAB_CUT_POINT1</string>
+ </property>
+ </widget>
+ </item>
+ <item row="8" column="1">
+ <widget class="QDoubleSpinBox" name="spinPoint1_X">
+ <property name="singleStep">
+ <double>0.010000000000000</double>
+ </property>
+ </widget>
+ </item>
+ <item row="8" column="2">
+ <widget class="QDoubleSpinBox" name="spinPoint1_Y">
+ <property name="singleStep">
+ <double>0.010000000000000</double>
+ </property>
+ </widget>
+ </item>
+ <item row="8" column="3">
+ <widget class="QDoubleSpinBox" name="spinPoint1_Z">
+ <property name="singleStep">
+ <double>0.010000000000000</double>
+ </property>
+ </widget>
+ </item>
+ <item row="9" column="0">
+ <widget class="QLabel" name="labelPoint2">
+ <property name="text">
+ <string>LAB_CUT_POINT2</string>
+ </property>
+ </widget>
+ </item>
+ <item row="9" column="1">
+ <widget class="QDoubleSpinBox" name="spinPoint2_X">
+ <property name="singleStep">
+ <double>0.010000000000000</double>
+ </property>
+ </widget>
+ </item>
+ <item row="9" column="2">
+ <widget class="QDoubleSpinBox" name="spinPoint2_Y">
+ <property name="singleStep">
+ <double>0.010000000000000</double>
+ </property>
+ </widget>
+ </item>
+ <item row="9" column="3">
+ <widget class="QDoubleSpinBox" name="spinPoint2_Z">
+ <property name="singleStep">
+ <double>0.010000000000000</double>
+ </property>
+ </widget>
+ </item>
+ <item row="10" column="1" colspan="3">
+ <widget class="QDoubleSpinBox" name="spinScaleFactor">
+ <property name="singleStep">
+ <double>0.020000000000000</double>
+ </property>
+ </widget>
+ </item>
+ <item row="10" column="0">
+ <widget class="QCheckBox" name="checkBoxScaleFactor">
+ <property name="text">
+ <string>LAB_SCALE_FACTOR</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</item>
from .medpresentation import MakePointSprite
from .medpresentation import RemovePresentation
from .medpresentation import MakeDeflectionShape
+from .medpresentation import MakePlot3D
+from .medpresentation import MakeStreamLines
+from .medpresentation import MakeCutSegment
from .medpresentation import GetMeshViewParameters
from .medpresentation import GetScalarMapParameters
from .medpresentation import GetPointSpriteParameters
from .medpresentation import GetVectorFieldParameters
from .medpresentation import GetDeflectionShapeParameters
+from .medpresentation import GetPlot3DParameters
+from .medpresentation import GetStreamLinesParameters
+from .medpresentation import GetCutSegmentParameters
from .medpresentation import UpdateMeshView
from .medpresentation import UpdateScalarMap
from .medpresentation import UpdateVectorField
from .medpresentation import UpdatePointSprite
from .medpresentation import UpdateDeflectionShape
+from .medpresentation import UpdatePlot3D
+from .medpresentation import UpdateStreamLines
+from .medpresentation import UpdateCutSegment
from .medpresentation import ComputeCellAverageSize, GetDomainCenter, GetSliceOrigins, SelectSourceField
+from .medpresentation import IsPlanarObj, GetPositions, GetPlaneNormalVector, FindOrCreateView
# Processing
from .medprocessing import ChangeUnderlyingMesh
#
def notifyGui_modifyPresentation(presId):
__notifyGui(MEDCALC.EVENT_MODIFY_PRESENTATION, presentationId=presId)
+#
+def notifyGui_visibilityChanged(presId):
+ __notifyGui(MEDCALC.EVENT_VISIBILITY_CHANGED, presentationId=presId)
def notifyGui_playQtTestingScenario(filename):
__notifyGui(MEDCALC.EVENT_PLAY_TEST, filename=filename)
import medcalc
import MEDCALC, SALOME
-from medcalc.medevents import notifyGui_addPresentation, notifyGui_removePresentation, notifyGui_error, notifyGui_modifyPresentation
+from medcalc.medevents import notifyGui_addPresentation, notifyGui_removePresentation, notifyGui_error, notifyGui_modifyPresentation, notifyGui_visibilityChanged
from functools import reduce
+import pvsimple as pvs
__manager = medcalc.medcorba.factory.getPresentationManager()
+DEFAULT_VISIBILITY = True
+DEFAULT_SCALAR_BAR_VISIBILITY = True
+DEFAULT_USE_CUSTOM_RANGE = False
+DEFAULT_SCALAR_BAR_RANGE = [0.0, 100.0]
+DEFAULT_PLANE_NORMAL = [0.0, 0.0, 1.0]
+DEFAULT_PLANE_POS = 1.0
+DEFAULT_SCALE_FACTOR = 0.2
+DEFAULT_CUT_POINT1 = [0.0, 0.0, 0.0]
+DEFAULT_CUT_POINT2 = [1.0, 1.0, 1.0]
+DEFAULT_HIDE_DATA_OUTSIDE_CUSTOM_RANGE = False
+DEFAULT_CUSTOM_SCALE_FACTOR = False
+DEFAULT_CONTOUR_COMPONENT = ""
def MakeMeshView(meshID,
viewMode=MEDCALC.VIEW_MODE_DEFAULT,
meshMode=MEDCALC.MESH_MODE_DEFAULT):
# Create the presentation instance in CORBA engine
# The engine in turn creates the ParaView pipeline elements
- params = MEDCALC.MeshViewParameters(meshID, meshMode)
+ visibility=True
+ params = MEDCALC.MeshViewParameters(meshID, meshMode, visibility)
try:
presentation_id = __manager.makeMeshView(params, viewMode)
notifyGui_addPresentation(meshID, presentation_id)
):
# Create the presentation instance in CORBA engine
# The engine in turn creates the ParaView pipeline elements
- params = MEDCALC.ScalarMapParameters(proxy.id, displayedComponent, scalarBarRange, colorMap)
+ visibility = DEFAULT_VISIBILITY
+ scalarBarVisibility = DEFAULT_SCALAR_BAR_VISIBILITY
+ scalarBarRangeArray = DEFAULT_SCALAR_BAR_RANGE
+ hideDataOutsideCustomRange = DEFAULT_HIDE_DATA_OUTSIDE_CUSTOM_RANGE
+ params = MEDCALC.ScalarMapParameters(proxy.id, displayedComponent, scalarBarRange, colorMap, visibility,
+ scalarBarVisibility, scalarBarRangeArray, hideDataOutsideCustomRange)
try:
presentation_id = __manager.makeScalarMap(params, viewMode)
notifyGui_addPresentation(proxy.id, presentation_id)
colorMap=MEDCALC.COLOR_MAP_DEFAULT,
nbContours=MEDCALC.NB_CONTOURS_DEFAULT
):
- params = MEDCALC.ContourParameters(proxy.id, scalarBarRange, colorMap, nbContours)
+ visibility = DEFAULT_VISIBILITY
+ scalarBarVisibility = DEFAULT_SCALAR_BAR_VISIBILITY
+ hideDataOutsideCustomRange = DEFAULT_HIDE_DATA_OUTSIDE_CUSTOM_RANGE
+ scalarBarRangeArray = DEFAULT_SCALAR_BAR_RANGE
+ contourComponent = DEFAULT_CONTOUR_COMPONENT
+ params = MEDCALC.ContourParameters(proxy.id, scalarBarRange, colorMap, visibility, scalarBarVisibility,
+ scalarBarRangeArray, hideDataOutsideCustomRange, nbContours, contourComponent)
try:
presentation_id = __manager.makeContour(params, viewMode)
- notifyGui_addPresentation(proxy.id, presentation_id)
+ notifyGui_addPresentation(proxy.id, presentation_id)
return presentation_id
except SALOME.SALOME_Exception as e:
notifyGui_error("An error occurred while creating the contour:\n" + e.details.text)
):
# Create the presentation instance in CORBA engine
# The engine in turn creates the ParaView pipeline elements
- params = MEDCALC.VectorFieldParameters(proxy.id, scalarBarRange, colorMap)
+ visibility = DEFAULT_VISIBILITY
+ scalarBarVisibility = DEFAULT_SCALAR_BAR_VISIBILITY
+ scalarBarRangeArray = DEFAULT_SCALAR_BAR_RANGE
+ hideDataOutsideCustomRange = DEFAULT_HIDE_DATA_OUTSIDE_CUSTOM_RANGE
+ scaleFactor = DEFAULT_SCALE_FACTOR
+ customScaleFactor = DEFAULT_CUSTOM_SCALE_FACTOR
+ params = MEDCALC.VectorFieldParameters(proxy.id, scalarBarRange, colorMap, visibility, scalarBarVisibility,
+ scalarBarRangeArray, hideDataOutsideCustomRange, scaleFactor, customScaleFactor)
try:
presentation_id = __manager.makeVectorField(params, viewMode)
notifyGui_addPresentation(proxy.id, presentation_id)
nbSlices=MEDCALC.NB_SLICES_DEFAULT):
# Create the presentation instance in CORBA engine
# The engine in turn creates the ParaView pipeline elements
- params = MEDCALC.SlicesParameters(proxy.id, displayedComponent,scalarBarRange, colorMap,
+ visibility = DEFAULT_VISIBILITY
+ scalarBarVisibility = DEFAULT_SCALAR_BAR_VISIBILITY
+ scalarBarRangeArray = DEFAULT_SCALAR_BAR_RANGE
+ hideDataOutsideCustomRange = DEFAULT_HIDE_DATA_OUTSIDE_CUSTOM_RANGE
+ params = MEDCALC.SlicesParameters(proxy.id, displayedComponent,scalarBarRange, colorMap, visibility,
+ scalarBarVisibility, scalarBarRangeArray, hideDataOutsideCustomRange,
sliceOrientation, nbSlices)
try:
presentation_id = __manager.makeSlices(params, viewMode)
):
# Create the presentation instance in CORBA engine
# The engine in turn creates the ParaView pipeline elements
- params = MEDCALC.DeflectionShapeParameters(proxy.id, scalarBarRange, colorMap)
+ visibility = DEFAULT_VISIBILITY
+ scalarBarVisibility = DEFAULT_SCALAR_BAR_VISIBILITY
+ scalarBarRangeArray = DEFAULT_SCALAR_BAR_RANGE
+ hideDataOutsideCustomRange = DEFAULT_HIDE_DATA_OUTSIDE_CUSTOM_RANGE
+ params = MEDCALC.DeflectionShapeParameters(proxy.id, scalarBarRange, colorMap, visibility,
+ scalarBarVisibility, scalarBarRangeArray, hideDataOutsideCustomRange)
try:
presentation_id = __manager.makeDeflectionShape(params, viewMode)
notifyGui_addPresentation(proxy.id, presentation_id)
):
# Create the presentation instance in CORBA engine
# The engine in turn creates the ParaView pipeline elements
- params = MEDCALC.PointSpriteParameters(proxy.id, displayedComponent, scalarBarRange, colorMap)
+ visibility = DEFAULT_VISIBILITY
+ scalarBarVisibility = DEFAULT_SCALAR_BAR_VISIBILITY
+ scalarBarRangeArray = DEFAULT_SCALAR_BAR_RANGE
+ hideDataOutsideCustomRange = DEFAULT_HIDE_DATA_OUTSIDE_CUSTOM_RANGE
+ params = MEDCALC.PointSpriteParameters(proxy.id, displayedComponent, scalarBarRange, colorMap, visibility,
+ scalarBarVisibility, scalarBarRangeArray, hideDataOutsideCustomRange)
try:
presentation_id = __manager.makePointSprite(params, viewMode)
notifyGui_addPresentation(proxy.id, presentation_id)
notifyGui_error("An error occurred while creating the point sprite:\n" + e.details.text)
raise Exception(e.details.text)
+
+def MakePlot3D(proxy,
+ viewMode=MEDCALC.VIEW_MODE_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
+ visibility = DEFAULT_VISIBILITY
+ scalarBarVisibility = DEFAULT_SCALAR_BAR_VISIBILITY
+ scalarBarRangeArray = DEFAULT_SCALAR_BAR_RANGE
+ hideDataOutsideCustomRange = DEFAULT_HIDE_DATA_OUTSIDE_CUSTOM_RANGE
+ scalarBarRangeArray = DEFAULT_SCALAR_BAR_RANGE
+ planeNormal = DEFAULT_PLANE_NORMAL
+ planePos = DEFAULT_PLANE_POS
+ params = MEDCALC.Plot3DParameters(proxy.id, scalarBarRange, colorMap, visibility,
+ scalarBarVisibility, scalarBarRangeArray, hideDataOutsideCustomRange, planeNormal, planePos)
+ try:
+ presentation_id = __manager.makePlot3D(params, viewMode)
+ notifyGui_addPresentation(proxy.id, presentation_id)
+ return presentation_id
+ except SALOME.SALOME_Exception as e:
+ notifyGui_error("An error occurred while creating the Plot3D:\n" + e.details.text)
+ raise Exception(e.details.text)
+
+
+def MakeStreamLines(proxy,
+ viewMode=MEDCALC.VIEW_MODE_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
+ visibility = DEFAULT_VISIBILITY
+ scalarBarVisibility = DEFAULT_SCALAR_BAR_VISIBILITY
+ scalarBarRangeArray = DEFAULT_SCALAR_BAR_RANGE
+ hideDataOutsideCustomRange = DEFAULT_HIDE_DATA_OUTSIDE_CUSTOM_RANGE
+ integrDir = MEDCALC.INTEGRATION_DIR_DEFAULT
+ params = MEDCALC.StreamLinesParameters(proxy.id, scalarBarRange, colorMap, visibility,
+ scalarBarVisibility, scalarBarRangeArray, hideDataOutsideCustomRange, integrDir)
+ try:
+ presentation_id = __manager.makeStreamLines(params, viewMode)
+ notifyGui_addPresentation(proxy.id, presentation_id)
+ return presentation_id
+ except SALOME.SALOME_Exception as e:
+ notifyGui_error("An error occurred while creating the StreamLines:\n" + e.details.text)
+ raise Exception(e.details.text)
+
+
+def MakeCutSegment(proxy,
+ viewMode=MEDCALC.VIEW_MODE_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
+ visibility = DEFAULT_VISIBILITY
+ scalarBarVisibility = DEFAULT_SCALAR_BAR_VISIBILITY
+ hideDataOutsideCustomRange = DEFAULT_HIDE_DATA_OUTSIDE_CUSTOM_RANGE
+ scalarBarRangeArray = DEFAULT_SCALAR_BAR_RANGE
+ point1 = DEFAULT_CUT_POINT1
+ point2 = DEFAULT_CUT_POINT2
+ params = MEDCALC.CutSegmentParameters(proxy.id, scalarBarRange, colorMap, visibility,
+ scalarBarVisibility, scalarBarRangeArray, hideDataOutsideCustomRange, point1, point2)
+ try:
+ presentation_id = __manager.makeCutSegment(params, viewMode)
+ notifyGui_addPresentation(proxy.id, presentation_id)
+ return presentation_id
+ except SALOME.SALOME_Exception as e:
+ notifyGui_error("An error occurred while creating the CutSegment:\n" + e.details.text)
+ raise Exception(e.details.text)
+
+
def RemovePresentation(presentation_id):
ok = __manager.removePresentation(presentation_id)
if ok:
GetPointSpriteParameters = lambda pres_id: __GetGENERICParameters("PointSprite", pres_id)
GetVectorFieldParameters = lambda pres_id: __GetGENERICParameters("VectorField", pres_id)
GetDeflectionShapeParameters = lambda pres_id: __GetGENERICParameters("DeflectionShape", pres_id)
+GetPlot3DParameters = lambda pres_id: __GetGENERICParameters("Plot3D", pres_id)
+GetStreamLinesParameters = lambda pres_id: __GetGENERICParameters("StreamLines", pres_id)
+GetCutSegmentParameters = lambda pres_id: __GetGENERICParameters("CutSegment", pres_id)
def __UpdateGENERIC(tag, presentation_id, params):
+ old_params = __GetGENERICParameters(tag, presentation_id)
exec("__manager.update%s(presentation_id, params)" % tag)
notifyGui_modifyPresentation(presentation_id)
+ if old_params.visibility != params.visibility:
+ # visibility is changed
+ notifyGui_visibilityChanged(presentation_id)
UpdateMeshView = lambda pres_id, params: __UpdateGENERIC("MeshView", pres_id, params)
UpdateScalarMap = lambda pres_id, params: __UpdateGENERIC("ScalarMap", 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)
+UpdatePlot3D = lambda pres_id, params: __UpdateGENERIC("Plot3D", pres_id, params)
+UpdateStreamLines = lambda pres_id, params: __UpdateGENERIC("StreamLines", pres_id, params)
+UpdateCutSegment = lambda pres_id, params: __UpdateGENERIC("CutSegment", pres_id, params)
+
+
+def get_bound_project(bound_box, planeNormal):
+ """Get bounds projection"""
+ EPS = 1E-3
+
+ def dot_product(a, b):
+ """Dot product of two 3-vectors."""
+ dot = a[0] * b[0] + a[1] * b[1] + a[2] * b[2]
+ return dot
+
+ bound_points = [[bound_box[1], bound_box[2], bound_box[4]],
+ [bound_box[0], bound_box[3], bound_box[4]],
+ [bound_box[0], bound_box[2], bound_box[5]]]
+ print(bound_points)
+
+ bound_prj = [0.0, 0.0, 0.0]
+
+ for i in range(0, 3):
+ tmp = dot_product(planeNormal, bound_points[i])
+ bound_prj[i] = tmp
+
+ return bound_prj
+
+
+def GetPositions(obj, planeNormal, displacement):
+ """Compute plane positions."""
+ positions = []
+ bounds = obj.GetDataInformation().GetBounds()
+ bound_prj = get_bound_project(bounds, planeNormal)
+ positions = [i * displacement for i in bound_prj]
+ return positions
+
+def IsPlanarObj(obj):
+ """
+ Check if the given input is planar
+ """
+ bounds_info = obj.GetDataInformation().GetBounds()
+ FLT_MIN = 1E-37
+
+ if (abs(bounds_info[0] - bounds_info[1]) <= FLT_MIN or
+ abs(bounds_info[2] - bounds_info[3]) <= FLT_MIN or
+ abs(bounds_info[4] - bounds_info[5]) <= FLT_MIN):
+ return True
+
+ return False
+
+def GetPlaneNormalVector(obj):
+ """Get Normal Vector"""
+ bounds = obj.GetDataInformation().GetBounds()
+ FLT_MIN = 1E-37
+
+ if abs(bounds[4] - bounds[5]) <= FLT_MIN:
+ p0 = [bounds[0], bounds[2], 0]
+ p1 = [bounds[1], bounds[2], 0]
+ p2 = [bounds[0], bounds[3], 0]
+ elif abs(bounds[2] - bounds[3]) <= FLT_MIN:
+ p0 = [bounds[0], 0, bounds[4]]
+ p1 = [bounds[1], 0, bounds[4]]
+ p2 = [bounds[0], 0, bounds[5]]
+ else:
+ p0 = [0, bounds[2], bounds[4]]
+ p1 = [0, bounds[3], bounds[4]]
+ p2 = [0, bounds[2], bounds[5]]
+
+ x0, y0, z0 = p0
+ x1, y1, z1 = p1
+ x2, y2, z2 = p2
+ ux, uy, uz = u = [x1-x0, y1-y0, z1-z0]
+ vx, vy, vz = v = [x2-x0, y2-y0, z2-z0]
+ u_cross_v = [uy*vz-uz*vy, uz*vx-ux*vz, ux*vy-uy*vx]
+
+ return u_cross_v
def ComputeCellAverageSize(obj):
"""
obj.AllArrays = [t]
return
raise Exception("Field not found")
+
+
+def FindOrCreateView(vtype):
+ """
+ Find and active or create a view with type vtype
+ """
+ result = None
+ view = pvs.GetActiveView()
+ if not view:
+ result = pvs.GetActiveViewOrCreate(vtype)
+ else:
+ if view.SMProxy.GetXMLName() == vtype:
+ result = view
+ else:
+ layout1 = pvs.GetLayout(view)
+ views = pvs.GetViewsInLayout(layout1)
+ view = next((v for v in views if v.SMProxy.GetXMLName() == vtype), None)
+ if view is None:
+ result = pvs.CreateView(vtype)
+ pvs.AssignViewToLayout(view=view, layout=layout1, hint=0)
+ else:
+ pvs.SetActiveView(view)
+ result = view
+ return result
\ No newline at end of file