SCALAR_BAR_CURRENT_TIMESTEP
};
+ enum MEDPresentationMeshMode {
+ MESH_MODE_WIREFRAME,
+ MESH_MODE_SURFACE_EDGES,
+ MESH_MODE_SURFACE
+ };
+
+
// struct ScalarBarRange {
// // (valMin,valMax) defines the scalar bar range from:
const string DISPLAY_EUCLIDEAN_NORM = ""; // Void string to avoid clash with a real component name -- never used actually?
- enum SliceOrientation {
+ enum MEDPresentationSliceOrientation {
SLICE_NORMAL_TO_X,
SLICE_NORMAL_TO_Y,
SLICE_NORMAL_TO_Z,
const MEDPresentationViewMode VIEW_MODE_DEFAULT = VIEW_MODE_REPLACE;
const MEDPresentationColorMap COLOR_MAP_DEFAULT = COLOR_MAP_BLUE_TO_RED_RAINBOW;
const MEDPresentationScalarBarRange SCALAR_BAR_RANGE_DEFAULT = SCALAR_BAR_ALL_TIMESTEPS;
- const long SCALAR_BAR_RANGE_VAL_MIN_DEFAULT = -1;
- const long SCALAR_BAR_RANGE_VAL_MAX_DEFAULT = -1;
+ const MEDPresentationMeshMode MESH_MODE_DEFAULT = MESH_MODE_WIREFRAME;
+// const long SCALAR_BAR_RANGE_VAL_MIN_DEFAULT = -1;
+// const long SCALAR_BAR_RANGE_VAL_MAX_DEFAULT = -1;
const string DISPLAY_DEFAULT = DISPLAY_EUCLIDEAN_NORM;
- const SliceOrientation SLICE_ORIENTATION_DEFAULT = SLICE_NORMAL_TO_Z;
+ const MEDPresentationSliceOrientation SLICE_ORIENTATION_DEFAULT = SLICE_NORMAL_TO_X;
const long NB_CONTOURS_DEFAULT = 10;
const long NB_SLICES_DEFAULT = 1;
/* Structs */
+ // Just showing the mesh
+ struct MeshViewParameters {
+ long fieldHandlerId; // TODO should be a meshHandlerId really ...
+ MEDPresentationMeshMode mode;
+ };
+
+ // A simple scalar map
struct ScalarMapParameters {
long fieldHandlerId;
string displayedComponent; // DISPLAY_EUCLIDEAN_NORM or any component name
// MEDPresentationColorMap colorMap;
// };
//
-// struct SlicesParameters {
-// long fieldHandlerId;
-// string displayedComponent; // DISPLAY_EUCLIDEAN_NORM or any component name
-// MEDPresentationScalarBarRange scalarBarRange;
-// MEDPresentationColorMap colorMap;
-// SliceOrientation orientation;
-// long nbSlices;
-// };
+ struct SlicesParameters {
+ long fieldHandlerId;
+ string displayedComponent; // DISPLAY_EUCLIDEAN_NORM or any component name
+ MEDPresentationScalarBarRange scalarBarRange;
+ MEDPresentationColorMap colorMap;
+ MEDPresentationSliceOrientation orientation;
+ long nbSlices;
+ };
//
// struct DeflectionShapeParameters {
// long fieldHandlerId;
interface MEDPresentationManager : SALOME::GenericObj
{
+ long makeMeshView(in MeshViewParameters params, in MEDPresentationViewMode viewMode);
long makeScalarMap(in ScalarMapParameters params, in MEDPresentationViewMode viewMode);
long makeContour(in ContourParameters params, in MEDPresentationViewMode viewMode)
raises (SALOME::SALOME_Exception);
// long makeVectorField(in VectorFieldParameters params, in MEDPresentationViewMode viewMode);
-// long makeSlices(in SlicesParameters params, in MEDPresentationViewMode viewMode);
+ long makeSlices(in SlicesParameters params, in MEDPresentationViewMode viewMode);
// long makeDeflectionShape(in DeflectionShapeParameters params, in MEDPresentationViewMode viewMode);
// long makePointSprite(in PointSpriteParameters params, in MEDPresentationViewMode viewMode);
void setPresentationIntProperty(in long presId, in string propName, in long propValue);
long getPresentationIntProperty(in long presId, in string propName);
+ MeshViewParameters getMeshViewParameters(in long presId);
ScalarMapParameters getScalarMapParameters(in long presId);
- ContourParameters getContourParameters(in long presId);
+ ContourParameters getContourParameters(in long presId);
+ SlicesParameters getSlicesParameters(in long presId);
+ void updateMeshView(in long presId, in MeshViewParameters params);
void updateScalarMap(in long presId, in ScalarMapParameters params);
void updateContour(in long presId, in ContourParameters params);
// void updateVectorField(in long presId, in VectorFieldParameters params);
-// void updateSlices(in long presId, in SlicesParameters params);
+ void updateSlices(in long presId, in SlicesParameters params);
// void updateDeflectionShape(in long presId, in DeflectionShapeParameters params);
// void updatePointSprite(in long presId, in PointSpriteParameters params);
MEDPresentationManager_i.cxx
MEDPresentation.cxx
# presentations
+ MEDPresentationMeshView.cxx
MEDPresentationScalarMap.cxx
MEDPresentationContour.cxx
# MEDPresentationVectorField.cxx
-# MEDPresentationSlices.cxx
+ MEDPresentationSlices.cxx
# MEDPresentationDeflectionShape.cxx
# MEDPresentationPointSprite.cxx
)
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
p->setParameters(params);
}
-
/**
* Update the ParaVis pipeline so that the given component appears on screen.
* Blank means "Euclidean norm"
params.displayedComponent = newCompo.c_str();
p->setParameters(params);
-
-
int nbCompo = getIntProperty(MEDPresentation::PROP_NB_COMPONENTS);
int idx = -1;
for (int i=0; i < nbCompo; i++)
virtual ~MEDPresentationContour() {}
void updatePipeline(const MEDCALC::ContourParameters& params);
-// MEDCALC::MEDPresentationViewMode getViewMode() { return _params.viewMode; }
void getParameters(MEDCALC::ContourParameters & params) const { params = _params; } ;
void setParameters(const MEDCALC::ContourParameters & params) { _params = params; } ;
#include "Basics_Utils.hxx"
// presentations
+#include "MEDPresentationMeshView.hxx"
#include "MEDPresentationScalarMap.hxx"
#include "MEDPresentationContour.hxx"
-//#include "MEDPresentationSlices.hxx"
+#include "MEDPresentationSlices.hxx"
//#include "MEDPresentationVectorField.hxx"
//#include "MEDPresentationDeflectionShape.hxx"
//#include "MEDPresentationPointSprite.hxx"
}
+MEDPresentation::TypeID
+MEDPresentationManager_i::makeMeshView(const MEDCALC::MeshViewParameters& params, const MEDCALC::MEDPresentationViewMode viewMode)
+{
+ return _makePresentation<MEDPresentationMeshView>(params, viewMode);
+}
+
MEDPresentation::TypeID
MEDPresentationManager_i::makeScalarMap(const MEDCALC::ScalarMapParameters& params, const MEDCALC::MEDPresentationViewMode viewMode)
{
// return _makePresentation<MEDPresentationVectorField>(params);
//}
//
-//MEDPresentation::TypeID
-//MEDPresentationManager_i::makeSlices(const MEDCALC::SlicesParameters& params)
-//{
-// return _makePresentation<MEDPresentationSlices>(params);
-//}
+MEDPresentation::TypeID
+MEDPresentationManager_i::makeSlices(const MEDCALC::SlicesParameters& params, const MEDCALC::MEDPresentationViewMode viewMode)
+{
+ return _makePresentation<MEDPresentationSlices>(params, viewMode);
+}
//
//MEDPresentation::TypeID
//MEDPresentationManager_i::makeDeflectionShape(const MEDCALC::DeflectionShapeParameters& params)
// return _makePresentation<MEDPresentationPointSprite>(params);
//}
+MEDCALC::MeshViewParameters
+MEDPresentationManager_i::getMeshViewParameters(MEDPresentation::TypeID presentationID)
+{
+ MEDCALC::MeshViewParameters p;
+ _getParameters<MEDPresentationMeshView>(presentationID, p);
+ return p;
+}
+
+
MEDCALC::ScalarMapParameters*
MEDPresentationManager_i::getScalarMapParameters(MEDPresentation::TypeID presentationID)
{
return p;
}
+MEDCALC::SlicesParameters*
+MEDPresentationManager_i::getSlicesParameters(MEDPresentation::TypeID presentationID)
+{
+ MEDCALC::SlicesParameters* p = new MEDCALC::SlicesParameters();
+ _getParameters<MEDPresentationSlices>(presentationID, *p);
+ MEDCALC::SlicesParameters_var tmp(p);
+ return tmp._retn();
+}
+
+
+void
+MEDPresentationManager_i::updateMeshView(MEDPresentation::TypeID presentationID, const MEDCALC::MeshViewParameters& params)
+{
+ return _updatePresentation<MEDPresentationMeshView>(presentationID, params);
+}
+
void
MEDPresentationManager_i::updateScalarMap(MEDPresentation::TypeID presentationID, const MEDCALC::ScalarMapParameters& params)
{
// return _updatePresentation<MEDPresentationVectorField>(presentationID, params);
//}
//
-//void
-//MEDPresentationManager_i::updateSlices(MEDPresentation::TypeID presentationID, const MEDCALC::SlicesParameters& params)
-//{
-// return _updatePresentation<MEDPresentationSlices>(presentationID, params);
-//}
+void
+MEDPresentationManager_i::updateSlices(MEDPresentation::TypeID presentationID, const MEDCALC::SlicesParameters& params)
+{
+ return _updatePresentation<MEDPresentationSlices>(presentationID, params);
+}
//
//void
//MEDPresentationManager_i::updateDeflectionShape(MEDPresentation::TypeID presentationID, const MEDCALC::DeflectionShapeParameters& params)
static MEDPresentationManager_i* getInstance();
+ MEDCALC_EXPORT MEDPresentation::TypeID makeMeshView(const MEDCALC::MeshViewParameters&, const MEDCALC::MEDPresentationViewMode);
MEDCALC_EXPORT MEDPresentation::TypeID makeScalarMap(const MEDCALC::ScalarMapParameters&, const MEDCALC::MEDPresentationViewMode);
MEDCALC_EXPORT MEDPresentation::TypeID makeContour(const MEDCALC::ContourParameters&, const MEDCALC::MEDPresentationViewMode);
-// MEDCALC_EXPORT MEDPresentation::TypeID makeVectorField(const MEDCALC::VectorFieldParameters&);
-// MEDCALC_EXPORT MEDPresentation::TypeID makeSlices(const MEDCALC::SlicesParameters&);
-// MEDCALC_EXPORT MEDPresentation::TypeID makeDeflectionShape(const MEDCALC::DeflectionShapeParameters&);
-// MEDCALC_EXPORT MEDPresentation::TypeID makePointSprite(const MEDCALC::PointSpriteParameters&);
+// MEDCALC_EXPORT MEDPresentation::TypeID makeVectorField(const MEDCALC::VectorFieldParameters&, const MEDCALC::MEDPresentationViewMode);
+ MEDCALC_EXPORT MEDPresentation::TypeID makeSlices(const MEDCALC::SlicesParameters&, const MEDCALC::MEDPresentationViewMode);
+// MEDCALC_EXPORT MEDPresentation::TypeID makeDeflectionShape(const MEDCALC::DeflectionShapeParameters&, const MEDCALC::MEDPresentationViewMode);
+// MEDCALC_EXPORT MEDPresentation::TypeID makePointSprite(const MEDCALC::PointSpriteParameters&, const MEDCALC::MEDPresentationViewMode);
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 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::SlicesParameters* getSlicesParameters(MEDPresentation::TypeID presentationID);
+ MEDCALC_EXPORT void updateMeshView(MEDPresentation::TypeID, const MEDCALC::MeshViewParameters&);
MEDCALC_EXPORT void updateScalarMap(MEDPresentation::TypeID, const MEDCALC::ScalarMapParameters&);
MEDCALC_EXPORT void updateContour(MEDPresentation::TypeID, const MEDCALC::ContourParameters&);
// MEDCALC_EXPORT void updateVectorField(MEDPresentation::TypeID, const MEDCALC::VectorFieldParameters&);
-// MEDCALC_EXPORT void updateSlices(MEDPresentation::TypeID, const MEDCALC::SlicesParameters&);
+ 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&);
--- /dev/null
+// Copyright (C) 2016 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "MEDPresentationMeshView.hxx"
+
+#include <SALOME_KernelServices.hxx>
+#undef LOG // should be fixed in KERNEL - double definition
+#include <Basics_Utils.hxx>
+
+#include <sstream>
+
+const std::string MEDPresentationMeshView::TYPE_NAME = "MEDPresentationMeshView";
+const std::string MEDPresentationMeshView::PROP_MESH_MODE = "meshMode";
+
+MEDPresentationMeshView::MEDPresentationMeshView(const MEDCALC::MeshViewParameters& params,
+ const MEDCALC::MEDPresentationViewMode viewMode) :
+ // Cheating a bit here - a mesh view doesn't need a color map or a range:
+ MEDPresentation(params.fieldHandlerId, TYPE_NAME, viewMode, MEDCALC::COLOR_MAP_DEFAULT,
+ MEDCALC::SCALAR_BAR_RANGE_DEFAULT),
+ _params(params)
+{
+ setIntProperty(MEDPresentationMeshView::PROP_MESH_MODE, params.mode);
+}
+
+std::string
+MEDPresentationMeshView::getMeshViewCommand() const
+{
+ std::ostringstream oss1;
+
+ switch (_params.mode)
+ {
+ case MEDCALC::MESH_MODE_WIREFRAME:
+ oss1 << _dispVar << ".SetRepresentationType('Wireframe');";
+ break;
+ case MEDCALC::MESH_MODE_SURFACE_EDGES:
+ oss1 << _dispVar << ".SetRepresentationType('Surface With Edges');";
+ break;
+ case MEDCALC::MESH_MODE_SURFACE:
+ oss1 << _dispVar << ".SetRepresentationType('Surface');";
+ break;
+ default:
+ const char * mes = "Unexpected getMeshViewCommand error!";
+ STDLOG(mes);
+ throw KERNEL::createSalomeException(mes);
+ }
+
+ return oss1.str();
+}
+
+void
+MEDPresentationMeshView::internalGeneratePipeline()
+{
+ MEDPresentation::internalGeneratePipeline();
+
+ MEDPyLockWrapper lock;
+
+ std::ostringstream oss;
+ std::string view(getRenderViewVar());
+
+ oss << _srcObjVar << " = pvs.MEDReader(FileName='" << _fileName << "');";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ pushAndExecPyLine( getRenderViewCommand() ); // instanciate __viewXXX
+ oss << _objVar << " = " << _srcObjVar << ";";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ oss << _dispVar << " = pvs.Show(" << _objVar << ", " << view << ");";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ pushAndExecPyLine(getMeshViewCommand());
+ pushAndExecPyLine(getResetCameraCommand());
+ pushAndExecPyLine("pvs.Render();");
+}
+
+void
+MEDPresentationMeshView::updatePipeline(const MEDCALC::MeshViewParameters& params)
+{
+ if (params.fieldHandlerId != _params.fieldHandlerId)
+ throw KERNEL::createSalomeException("Unexpected updatePipeline error! Mismatching fieldHandlerId!");
+
+ if (params.mode != _params.mode)
+ updateMeshMode(params.mode);
+}
+
+void
+MEDPresentationMeshView::updateMeshMode(const MEDCALC::MEDPresentationMeshMode mode)
+{
+ _params.mode = mode;
+
+ // GUI helper:
+ setIntProperty(MEDPresentationMeshView::PROP_MESH_MODE, mode);
+
+ // Update the pipeline:
+ {
+ MEDPyLockWrapper lock;
+ std::string cmd = getMeshViewCommand();
+ pushAndExecPyLine(cmd);
+ pushAndExecPyLine("pvs.Render();");
+ }
+}
--- /dev/null
+// Copyright (C) 2016 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef SRC_MEDCALC_CMP_MEDPRESENTATION_MESHVIEW_HXX_
+#define SRC_MEDCALC_CMP_MEDPRESENTATION_MESHVIEW_HXX_
+
+#include "MEDCALC.hxx"
+#include "MEDPresentation.hxx"
+
+class MEDCALC_EXPORT MEDPresentationMeshView : public MEDPresentation
+{
+public:
+ static const std::string TYPE_NAME;
+ static const std::string PROP_MESH_MODE;
+
+ MEDPresentationMeshView(const MEDCALC::MeshViewParameters& params, const MEDCALC::MEDPresentationViewMode viewMode);
+ virtual ~MEDPresentationMeshView() {}
+
+ void updatePipeline(const MEDCALC::MeshViewParameters& params);
+
+ void getParameters(MEDCALC::MeshViewParameters & params) const { params = _params; } ;
+ void setParameters(const MEDCALC::MeshViewParameters & params) { _params = params; } ;
+
+protected:
+ void updateMeshMode(const MEDCALC::MEDPresentationMeshMode mode);
+ virtual void internalGeneratePipeline();
+
+ std::string getMeshViewCommand() const;
+
+private:
+ MEDCALC::MeshViewParameters _params;
+};
+
+#endif
throw KERNEL::createSalomeException("Unexpected updatePipeline error! Mismatching fieldHandlerId!");
if (std::string(params.displayedComponent) != std::string(_params.displayedComponent))
- {
- STDLOG("about to updateCompo in scalar map");
- STDLOG("from param " << params.displayedComponent);
- STDLOG("from intern " << _params.displayedComponent);
- updateComponent<MEDPresentationScalarMap, MEDCALC::ScalarMapParameters>(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)
#include "MEDPresentationSlices.hxx"
+#include <SALOME_KernelServices.hxx>
+#undef LOG // should be fixed in KERNEL - double definition
+#include <Basics_Utils.hxx>
+
+#include <sstream>
+
+const std::string MEDPresentationSlices::TYPE_NAME = "MEDPresentationSlices";
+const std::string MEDPresentationSlices::PROP_NB_SLICES = "nbSlices";
+const std::string MEDPresentationSlices::PROP_SLICE_ORIENTATION = "slicesOrientation";
+
+MEDPresentationSlices::MEDPresentationSlices(const MEDCALC::SlicesParameters& params,
+ const MEDCALC::MEDPresentationViewMode viewMode) :
+ MEDPresentation(params.fieldHandlerId, TYPE_NAME, viewMode, params.colorMap, params.scalarBarRange),
+ _params(params)
+{
+ setIntProperty(MEDPresentationSlices::PROP_NB_SLICES, params.nbSlices);
+ setIntProperty(MEDPresentationSlices::PROP_SLICE_ORIENTATION, params.orientation);
+}
+
+std::string
+MEDPresentationSlices::getNbSlicesCommand() const
+{
+ std::ostringstream oss1;
+ // TODO
+// oss1 << _objVar << ".SliceType.Normal = " << norm << ";";
+ return oss1.str();
+}
+
+std::string
+MEDPresentationSlices::getOrientationCommand() const
+{
+ std::ostringstream oss1;
+ std::string norm;
+
+ switch(_params.orientation)
+ {
+ case MEDCALC::SLICE_NORMAL_TO_X:
+ norm = "[1.0, 0.0, 0.0]";
+ break;
+ case MEDCALC::SLICE_NORMAL_TO_Y:
+ norm = "[0.0, 1.0, 0.0]";
+ break;
+ case MEDCALC::SLICE_NORMAL_TO_Z:
+ norm = "[0.0, 0.0, 1.0]";
+ break;
+ case MEDCALC::SLICE_NORMAL_TO_XY:
+ norm = "[1.0, 1.0, 0.0]";
+ break;
+ case MEDCALC::SLICE_NORMAL_TO_XZ:
+ norm = "[1.0, 0.0, 1.0]";
+ break;
+ case MEDCALC::SLICE_NORMAL_TO_YZ:
+ norm = "[0.0, 1.0, 1.0]";
+ break;
+ case MEDCALC::SLICE_NORMAL_TO_XYZ:
+ norm = "[1.0, 1.0, 1.0]";
+ break;
+ default:
+ const char * mes = "Unexpected getSliceOrientationCommand() error!";
+ STDLOG(mes);
+ throw KERNEL::createSalomeException(mes);
+ }
+
+ oss1 << _objVar << ".SliceType.Normal = " << norm << ";";
+ return oss1.str();
+}
+
+
void
MEDPresentationSlices::internalGeneratePipeline()
{
-// PyGILState_STATE _gil_state = PyGILState_Ensure();
-//
-// std::string cmd = std::string("import pvsimple as pvs;");
-// cmd += getRenderViewCommand(_params.viewMode); // define __view1
-//
-// cmd += std::string("__obj1 = pvs.MEDReader(FileName='") + _fileName + std::string("');");
-// cmd += std::string("__slice1 = pvs.Slice(Input=__obj1);");
-// cmd += std::string("__disp1 = pvs.Show(__slice1, __view1);");
-// cmd += std::string("pvs.ColorBy(__disp1, ('") + _fieldType + std::string("', '") + _fieldName + std::string("'));");
-// cmd += std::string("__disp1.SetScalarBarVisibility(__view1, True);");
-// cmd += std::string("__disp1.RescaleTransferFunctionToDataRangeOverTime();");
-// cmd += std::string("pvs.Render();");
-//
-// cmd += getResetCameraCommand();
-//
-// //std::cerr << "Python command:" << std::endl;
-// //std::cerr << cmd << std::endl;
-// PyRun_SimpleString(cmd.c_str());
-// // Retrieve Python object for internal storage:
-// PyObject* obj = getPythonObjectFromMain("__slice1");
-// PyObject* disp = getPythonObjectFromMain("__disp1");
-// pushInternal(obj, disp);
-//
-// PyGILState_Release(_gil_state);
+ MEDPresentation::internalGeneratePipeline();
+
+ MEDPyLockWrapper lock;
+
+ std::ostringstream oss_o, oss;
+ std::string view(getRenderViewVar());
+
+ oss << _srcObjVar << " = pvs.MEDReader(FileName='" << _fileName << "');";
+ pushAndExecPyLine(oss.str()); oss.str("");
+
+ // Populate internal array of available components:
+ fillAvailableFieldComponents();
+ pushAndExecPyLine( getRenderViewCommand() ); // instanciate __viewXXX
+ oss << _objVar << " = pvs.Slice(Input=" << _srcObjVar << ");";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ oss << _objVar << ".SliceType = 'Plane';";
+ pushAndExecPyLine(oss.str()); oss.str("");
+
+ // Set slice orientation
+ pushAndExecPyLine(getOrientationCommand());
+
+ oss << _dispVar << " = pvs.Show(" << _objVar << ", " << view << ");";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ oss << "pvs.ColorBy(" << _dispVar << ", ('" << _fieldType << "', '" << _fieldName << "'));";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ oss << _dispVar << ".SetScalarBarVisibility(" << view << ", True);";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ oss << getRescaleCommand();
+ pushAndExecPyLine(oss.str()); oss.str("");
+ oss << _lutVar << " = pvs.GetColorTransferFunction('" << _fieldName << "');";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ pushAndExecPyLine(getColorMapCommand()); oss.str("");
+ pushAndExecPyLine(getResetCameraCommand());
+ pushAndExecPyLine("pvs.Render();");
}
void
MEDPresentationSlices::updatePipeline(const MEDCALC::SlicesParameters& params)
{
- // :TODO:
+ if (params.fieldHandlerId != _params.fieldHandlerId)
+ throw KERNEL::createSalomeException("Unexpected updatePipeline error! Mismatching fieldHandlerId!");
+
+ if (std::string(params.displayedComponent) != std::string(_params.displayedComponent))
+ updateComponent<MEDPresentationSlices, MEDCALC::SlicesParameters>(std::string(params.displayedComponent));
+ if (params.scalarBarRange != _params.scalarBarRange)
+ updateScalarBarRange<MEDPresentationSlices, MEDCALC::SlicesParameters>(params.scalarBarRange);
+ if (params.colorMap != _params.colorMap)
+ updateColorMap<MEDPresentationSlices, MEDCALC::SlicesParameters>(params.colorMap);
+
+ if (params.orientation != _params.orientation)
+ updateOrientation(params.orientation);
+ if (params.nbSlices != _params.nbSlices)
+ updateNbSlices(params.nbSlices);
+}
+
+void
+MEDPresentationSlices::updateNbSlices(const int nbSlices)
+{
+ _params.nbSlices = nbSlices;
+
+ // GUI helper:
+ setIntProperty(MEDPresentationSlices::PROP_NB_SLICES, nbSlices);
+
+ // Update the pipeline:
+ {
+ MEDPyLockWrapper lock;
+ std::string cmd = getNbSlicesCommand();
+ pushAndExecPyLine(cmd);
+ pushAndExecPyLine("pvs.Render();");
+ }
+}
+
+void
+MEDPresentationSlices::updateOrientation(const MEDCALC::MEDPresentationSliceOrientation orientation)
+{
+ _params.orientation = orientation;
+
+ // GUI helper:
+ setIntProperty(MEDPresentationSlices::PROP_SLICE_ORIENTATION, orientation);
+
+ // Update the pipeline:
+ {
+ MEDPyLockWrapper lock;
+ std::string cmd = getOrientationCommand();
+ pushAndExecPyLine(cmd);
+ pushAndExecPyLine("pvs.Render();");
+ }
}
+
class MEDCALC_EXPORT MEDPresentationSlices : public MEDPresentation
{
public:
- MEDPresentationSlices(const MEDCALC::SlicesParameters& params) :
- MEDPresentation(params.fieldHandlerId, "MEDPresentationSlices"), _params(params)
- {}
+ static const std::string TYPE_NAME;
+ static const std::string PROP_NB_SLICES;
+ static const std::string PROP_SLICE_ORIENTATION;
+
+ MEDPresentationSlices(const MEDCALC::SlicesParameters& params, const MEDCALC::MEDPresentationViewMode viewMode);
virtual ~MEDPresentationSlices() {}
void updatePipeline(const MEDCALC::SlicesParameters& params);
- MEDCALC::MEDPresentationViewMode getViewMode() { return _params.viewMode; }
+
+ void getParameters(MEDCALC::SlicesParameters & params) const { params = _params; } ;
+ void setParameters(const MEDCALC::SlicesParameters & params) { _params = params; } ;
protected:
+ void updateNbSlices(const int nbSlices);
+ void updateOrientation(const MEDCALC::MEDPresentationSliceOrientation orientation);
virtual void internalGeneratePipeline();
+ std::string getNbSlicesCommand() const;
+ std::string getOrientationCommand() const;
+
private:
MEDCALC::SlicesParameters _params;
};
XmedConsoleDriver.cxx
XmedDataModel.cxx
MEDWidgetHelper.cxx
+ MEDWidgetHelperMeshView.cxx
MEDWidgetHelperScalarMap.cxx
MEDWidgetHelperContour.cxx
+ MEDWidgetHelperSlices.cxx
)
IF(SALOME_MED_WITH_QTTESTING)
PresentationController.hxx
ProcessingController.hxx
MEDWidgetHelper.hxx
+ MEDWidgetHelperMeshView.hxx
MEDWidgetHelperScalarMap.hxx
MEDWidgetHelperContour.hxx
+ MEDWidgetHelperSlices.hxx
)
IF(SALOME_MED_WITH_QTTESTING)
--- /dev/null
+// Copyright (C) 2016 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "MEDWidgetHelperMeshView.hxx"
+#include "MEDPresentationMeshView.hxx" // from component side.
+#include "PresentationController.hxx"
+
+#include <Basics_Utils.hxx>
+
+#include <sstream>
+
+MEDWidgetHelperMeshView::MEDWidgetHelperMeshView(const PresentationController * presController,
+ MEDCALC::MEDPresentationManager_ptr presManager, int presId,
+ const std::string & presName, WidgetPresentationParameters * paramW):
+ MEDWidgetHelper(presController, presManager, presId, presName, paramW)
+{
+}
+
+MEDWidgetHelperMeshView::~MEDWidgetHelperMeshView()
+{}
+
+void MEDWidgetHelperMeshView::loadParametersFromEngine()
+{
+ MEDWidgetHelper::loadParametersFromEngine();
+ _meshMode = static_cast<MEDCALC::MEDPresentationMeshMode>(
+ _presManager->getPresentationIntProperty(_presId, MEDPresentationMeshView::PROP_MESH_MODE.c_str()));
+}
+
+void MEDWidgetHelperMeshView::udpateWidget()
+{
+ MEDWidgetHelper::udpateWidget();
+
+ // MeshView presentation needs the mesh mode that's all.
+ _paramWidget->setMeshMode(_meshMode);
+ // Hide color map and scalar bar range
+ _paramWidget->toggleCommonFieldWidget(false);
+
+ // Connect combo box changes
+ QObject::connect( this, SIGNAL(presentationUpdateSignal(const PresentationEvent *)),
+ _presController, SIGNAL(presentationSignal(const PresentationEvent *)) );
+ QObject::connect( _paramWidget, SIGNAL(comboMeshIndexChanged(int)), this, SLOT(onMeshModeChanged(int)) );
+}
+
+void MEDWidgetHelperMeshView::releaseWidget()
+{
+ MEDWidgetHelper::releaseWidget();
+
+ // Show color map and scalar bar range
+ _paramWidget->toggleCommonFieldWidget(true);
+
+ QObject::disconnect( this, SIGNAL(presentationUpdateSignal(const PresentationEvent *)),
+ _presController, SIGNAL(presentationSignal(const PresentationEvent *)) );
+ QObject::disconnect( _paramWidget, SIGNAL(comboMeshIndexChanged(int)), this, SLOT(onMeshModeChanged(int)) );
+}
+
+void MEDWidgetHelperMeshView::onMeshModeChanged(int meshMode)
+{
+ STDLOG("MEDWidgetHelperMeshView::onMeshModeChanged");
+ PresentationEvent* event = new PresentationEvent();
+ event->eventtype = PresentationEvent::EVENT_CHANGE_MESH_MODE;
+ event->presentationId = _presId;
+ event->anInteger = static_cast<int>(_paramWidget->getMeshMode());
+
+ emit presentationUpdateSignal(event); // --> PresentationController::processPresentationEvent
+}
+
--- /dev/null
+// Copyright (C) 2016 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef SRC_MEDCALC_GUI_MEDWIDGETHELPERMESHVIEW_HXX_
+#define SRC_MEDCALC_GUI_MEDWIDGETHELPERMESHVIEW_HXX_
+
+#include "MEDWidgetHelper.hxx"
+
+class PresentationController;
+
+class MEDWidgetHelperMeshView: public MEDWidgetHelper
+{
+ Q_OBJECT
+
+public:
+ MEDWidgetHelperMeshView(const PresentationController* presController,
+ MEDCALC::MEDPresentationManager_ptr presManager, int presId, const std::string & presName,
+ WidgetPresentationParameters * paramW);
+ virtual ~MEDWidgetHelperMeshView();
+
+ virtual void udpateWidget();
+ virtual void releaseWidget();
+
+ virtual std::string getPythonTag() const { return "MeshView"; }
+
+protected slots:
+ void onMeshModeChanged(int index);
+
+protected:
+ virtual void loadParametersFromEngine();
+
+private:
+ MEDCALC::MEDPresentationMeshMode _meshMode;
+};
+
+#endif /* SRC_MEDCALC_GUI_MEDWIDGETHELPERMESHVIEW_HXX_ */
--- /dev/null
+// Copyright (C) 2016 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "MEDWidgetHelperSlices.hxx"
+#include "MEDPresentationSlices.hxx" // from component side.
+#include "PresentationController.hxx"
+
+#include <Basics_Utils.hxx>
+
+#include <sstream>
+
+MEDWidgetHelperSlices::MEDWidgetHelperSlices(const PresentationController * presController,
+ MEDCALC::MEDPresentationManager_ptr presManager, int presId,
+ const std::string & presName, WidgetPresentationParameters * paramW):
+ MEDWidgetHelper(presController, presManager, presId, presName, paramW),
+ _nbSlices(-1),
+ _sliceOrientation(MEDCALC::SLICE_ORIENTATION_DEFAULT)
+{}
+
+MEDWidgetHelperSlices::~MEDWidgetHelperSlices()
+{}
+
+void MEDWidgetHelperSlices::loadParametersFromEngine()
+{
+ MEDWidgetHelper::loadParametersFromEngine();
+ _nbSlices = _presManager->getPresentationIntProperty(_presId, MEDPresentationSlices::PROP_NB_SLICES.c_str());
+ _sliceOrientation = static_cast<MEDCALC::MEDPresentationSliceOrientation>(
+ _presManager->getPresentationIntProperty(_presId, MEDPresentationSlices::PROP_SLICE_ORIENTATION.c_str()));
+}
+
+void MEDWidgetHelperSlices::udpateWidget()
+{
+ MEDWidgetHelper::udpateWidget();
+ STDLOG("MEDWidgetHelperSlices::udpateWidget() nbSlices is " << _nbSlices);
+
+// _paramWidget->setNbSlices(_nbSlices); // TODO: uncomment when ready to deal with slice number
+ _paramWidget->setSliceOrientation(_sliceOrientation);
+
+ // Connect combo box changes
+ QObject::connect( this, SIGNAL(presentationUpdateSignal(const PresentationEvent *)),
+ _presController, SIGNAL(presentationSignal(const PresentationEvent *)) );
+ QObject::connect( _paramWidget, SIGNAL(spinBoxValueChanged(int)), this, SLOT(onNbSlicesChanged(int)) );
+ QObject::connect( _paramWidget, SIGNAL(comboOrientIndexChanged(int)), this, SLOT(onSliceOrientationChanged(int)) );
+}
+
+void MEDWidgetHelperSlices::releaseWidget()
+{
+ MEDWidgetHelper::releaseWidget();
+
+ QObject::disconnect( this, SIGNAL(presentationUpdateSignal(const PresentationEvent *)),
+ _presController, SIGNAL(presentationSignal(const PresentationEvent *)) );
+ QObject::disconnect( _paramWidget, SIGNAL(spinBoxValueChanged(int)), this, SLOT(onNbSlicesChanged(int)) );
+ QObject::disconnect( _paramWidget, SIGNAL(comboOrientIndexChanged(int)), this, SLOT(onSliceOrientationChanged(int)) );
+}
+
+void MEDWidgetHelperSlices::onNbSlicesChanged(int nbSlices)
+{
+ STDLOG("MEDWidgetHelperSlices::onNbSlicesChanged");
+ PresentationEvent* event = new PresentationEvent();
+ event->eventtype = PresentationEvent::EVENT_CHANGE_NB_SLICES;
+ event->presentationId = _presId;
+ event->anInteger = nbSlices;
+
+ emit presentationUpdateSignal(event); // --> PresentationController::processPresentationEvent
+}
+
+
+void MEDWidgetHelperSlices::onSliceOrientationChanged(int sliceOrient)
+{
+ STDLOG("MEDWidgetHelperSlices::onNbSlicesChanged");
+ PresentationEvent* event = new PresentationEvent();
+ event->eventtype = PresentationEvent::EVENT_CHANGE_SLICE_ORIENTATION;
+ event->presentationId = _presId;
+ event->anInteger = static_cast<int>(_paramWidget->getSliceOrientation());
+
+ emit presentationUpdateSignal(event); // --> PresentationController::processPresentationEvent
+}
--- /dev/null
+// Copyright (C) 2016 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef SRC_MEDCALC_GUI_MEDWIDGETHELPERSLICES_HXX_
+#define SRC_MEDCALC_GUI_MEDWIDGETHELPERSLICES_HXX_
+
+#include "MEDWidgetHelper.hxx"
+
+class PresentationController;
+
+class MEDWidgetHelperSlices: public MEDWidgetHelper
+{
+ Q_OBJECT
+
+public:
+ MEDWidgetHelperSlices(const PresentationController* presController,
+ MEDCALC::MEDPresentationManager_ptr presManager, int presId, const std::string & presName,
+ WidgetPresentationParameters * paramW);
+ virtual ~MEDWidgetHelperSlices();
+
+ virtual void udpateWidget();
+ virtual void releaseWidget();
+
+ virtual std::string getPythonTag() const { return "Slices"; }
+
+protected slots:
+ void onSliceOrientationChanged(int idx);
+ void onNbSlicesChanged(int nbSlices);
+
+protected:
+ virtual void loadParametersFromEngine();
+
+private:
+ int _nbSlices;
+ MEDCALC::MEDPresentationSliceOrientation _sliceOrientation;
+};
+
+#endif /* SRC_MEDCALC_GUI_MEDWIDGETHELPERSLICES_HXX_ */
<translation>workspace_save.png</translation>
</message>
<!-- Presentation toolbar icons (default theme)-->
+ <message>
+ <source>ICO_PRESENTATION_MESH_VIEW_DEFAULT</source>
+ <translation>mesh24.png</translation>
+ </message>
<message>
<source>ICO_PRESENTATION_SCALAR_MAP_DEFAULT</source>
<translation>scalarmap24.png</translation>
<translation>pqNodeMapData24.png</translation>
</message>
<!-- Presentation tree icons (default theme)-->
+ <message>
+ <source>ICO_MEDPresentationMeshView_DEFAULT</source>
+ <translation>mesh16.png</translation>
+ </message>
<message>
<source>ICO_MEDPresentationScalarMap_DEFAULT</source>
<translation>scalarmap16.png</translation>
<translation>pqNodeMapData16.png</translation>
</message>
<!-- Presentation toolbar icons (modern theme)-->
+ <message>
+ <source>ICO_PRESENTATION_MESH_VIEW_MODERN</source>
+ <translation>mesh24.png</translation>
+ </message>
<message>
<source>ICO_PRESENTATION_SCALAR_MAP_MODERN</source>
<translation>scalarmap24.png</translation>
<translation>pqNodeMapData24.png</translation>
</message>
<!-- Presentation tree icons (modern theme)-->
+ <message>
+ <source>ICO_MEDPresentationMeshView_MODERN</source>
+ <translation>mesh16.png</translation>
+ </message>
<message>
<source>ICO_MEDPresentationScalarMap_MODERN</source>
<translation>scalarmap16.png</translation>
<translation>pqNodeMapData16.png</translation>
</message>
<!-- Presentation toolbar icons (classic theme)-->
+ <message>
+ <source>ICO_PRESENTATION_MESH_VIEW_CLASSIC</source>
+ <translation>visu_mesh24.png</translation>
+ </message>
<message>
<source>ICO_PRESENTATION_SCALAR_MAP_CLASSIC</source>
<translation>visu_scalars24.png</translation>
<translation>visu_points24.png</translation>
</message>
<!-- Presentation tree icons (classic theme)-->
+ <message>
+ <source>ICO_MEDPresentationMeshView_CLASSIC</source>
+ <translation>visu_mesh16.png</translation>
+ </message>
<message>
<source>ICO_MEDPresentationScalarMap_CLASSIC</source>
<translation>visu_scalars16.png</translation>
<source>TITLE_PRESENTATION_PARAMETERS</source>
<translation>Presentation parameters</translation>
</message>
+ <message>
+ <source>LAB_PRESENTATION_MESH_VIEW</source>
+ <translation>Mesh</translation>
+ </message>
+ <message>
+ <source>TIP_PRESENTATION_MESH_VIEW</source>
+ <translation>Mesh</translation>
+ </message>
<message>
<source>LAB_PRESENTATION_SCALAR_MAP</source>
<translation>Scalar map</translation>
<source>MENU_PRESENTATIONS</source>
<translation>Presentations</translation>
</message>
+ <message>
+ <source>MEDPresentationMeshView</source>
+ <translation>Mesh view</translation>
+ </message>
<message>
<source>MEDPresentationScalarMap</source>
<translation>Scalar map</translation>
<source>LAB_COLOR_MAP</source>
<translation>Color map:</translation>
</message>
+
+ <message>
+ <source>LAB_MESH_WIREFRAME</source>
+ <translation>Wireframe</translation>
+ </message>
+ <message>
+ <source>LAB_MESH_SURFACE</source>
+ <translation>Surface</translation>
+ </message>
+ <message>
+ <source>LAB_MESH_SURF_EDGES</source>
+ <translation>Surface With Edges</translation>
+ </message>
+ <message>
+ <source>LAB_DISP_MESH_MODE</source>
+ <translation>Mesh display:</translation>
+ </message>
+ <message>
+ <source>LAB_NB_CONTOURS</source>
+ <translation>Number of contours:</translation>
+ </message>
+ <message>
+ <source>LAB_NB_SLICES</source>
+ <translation>Number of slices:</translation>
+ </message>
+ <message>
+ <source>LAB_SLICE_ORIENT</source>
+ <translation>Slice orientation:</translation>
+ </message>
+
+ <message>
+ <source>LAB_SLICE_NORMAL_TO_X</source>
+ <translation>Normal to X</translation>
+ </message>
+ <message>
+ <source>LAB_SLICE_NORMAL_TO_Y</source>
+ <translation>Normal to Y</translation>
+ </message>
+ <message>
+ <source>LAB_SLICE_NORMAL_TO_Z</source>
+ <translation>Normal to Z</translation>
+ </message>
+ <message>
+ <source>LAB_SLICE_NORMAL_TO_XY</source>
+ <translation>Normal to XY</translation>
+ </message>
+ <message>
+ <source>LAB_SLICE_NORMAL_TO_XZ</source>
+ <translation>Normal to XZ</translation>
+ </message>
+ <message>
+ <source>LAB_SLICE_NORMAL_TO_YZ</source>
+ <translation>Normal to YZ</translation>
+ </message>
+ <message>
+ <source>LAB_SLICE_NORMAL_TO_XYZ</source>
+ <translation>Normal to XYZ</translation>
+ </message>
+
</context>
<context>
<name>DlgAlias</name>
#include "MEDPresentationManager_i.hxx"
#include "XmedConsoleDriver.hxx"
+#include "MEDPresentationMeshView.hxx"
#include "MEDPresentationScalarMap.hxx"
#include "MEDPresentationContour.hxx"
+#include "MEDPresentationSlices.hxx"
+#include "MEDWidgetHelperMeshView.hxx"
#include "MEDWidgetHelperScalarMap.hxx"
#include "MEDWidgetHelperContour.hxx"
+#include "MEDWidgetHelperSlices.hxx"
#include <SalomeApp_Application.h>
#include <SalomeApp_Study.h>
int presentationToolbarId = _salomeModule->createTool("Presentations", "PresentationToolbar");
int presentationMenuId = _salomeModule->createMenu(tr("MENU_PRESENTATIONS"), -1, 1);
+ label = tr("LAB_PRESENTATION_MESH_VIEW");
+ tooltip = tr("TIP_PRESENTATION_MESH_VIEW");
+ QString icon = tr(_getIconName("ICO_PRESENTATION_MESH_VIEW").c_str());
+ int actionId;
+ actionId = _salomeModule->createStandardAction(label,this, SLOT(onVisualizeMeshView()),icon,tooltip);
+ _salomeModule->createTool(actionId, presentationToolbarId);
+ _salomeModule->action(actionId)->setIconVisibleInMenu(true);
+ _salomeModule->createMenu(actionId, presentationMenuId);
+
label = tr("LAB_PRESENTATION_SCALAR_MAP");
tooltip = tr("TIP_PRESENTATION_SCALAR_MAP");
- QString icon = tr(_getIconName("ICO_PRESENTATION_SCALAR_MAP").c_str());
- int actionId;
+ icon = tr(_getIconName("ICO_PRESENTATION_SCALAR_MAP").c_str());
actionId = _salomeModule->createStandardAction(label,this, SLOT(onVisualizeScalarMap()),icon,tooltip);
_salomeModule->createTool(actionId, presentationToolbarId);
_salomeModule->action(actionId)->setIconVisibleInMenu(true);
}
}
+void
+PresentationController::onVisualizeMeshView()
+{
+ this->visualize(PresentationEvent::EVENT_VIEW_OBJECT_MESH_VIEW);
+}
+
void
PresentationController::onVisualizeScalarMap()
{
return QString();
}
+QString
+PresentationController::getMeshModePython(const int mode) const
+{
+ MEDCALC::MEDPresentationMeshMode mod = static_cast<MEDCALC::MEDPresentationMeshMode>(mode);
+ switch(mod) {
+ case MEDCALC::MESH_MODE_WIREFRAME: return "MEDCALC.MESH_MODE_WIREFRAME";
+ case MEDCALC::MESH_MODE_SURFACE: return "MEDCALC.MESH_MODE_SURFACE";
+ case MEDCALC::MESH_MODE_SURFACE_EDGES: return "MEDCALC.MESH_MODE_SURFACE_EDGES";
+ }
+ return QString();
+}
+
+QString
+PresentationController::getSliceOrientationPython(const int orientation) const
+{
+ MEDCALC::MEDPresentationSliceOrientation orient = static_cast<MEDCALC::MEDPresentationSliceOrientation>(orientation);
+ switch(orient) {
+ case MEDCALC::SLICE_NORMAL_TO_X: return "MEDCALC.SLICE_NORMAL_TO_X";
+ case MEDCALC::SLICE_NORMAL_TO_Y: return "MEDCALC.SLICE_NORMAL_TO_Y";
+ case MEDCALC::SLICE_NORMAL_TO_Z: return "MEDCALC.SLICE_NORMAL_TO_Z";
+ case MEDCALC::SLICE_NORMAL_TO_XY: return "MEDCALC.SLICE_NORMAL_TO_XY";
+ case MEDCALC::SLICE_NORMAL_TO_XZ: return "MEDCALC.SLICE_NORMAL_TO_XZ";
+ case MEDCALC::SLICE_NORMAL_TO_YZ: return "MEDCALC.SLICE_NORMAL_TO_YZ";
+ case MEDCALC::SLICE_NORMAL_TO_XYZ: return "MEDCALC.SLICE_NORMAL_TO_XYZ";
+ }
+ return QString();
+}
+
std::string
PresentationController::getPresTypeFromWidgetHelper(int presId) const
{
QString scalarBarRange = getScalarBarRangePython();
MEDCALC::FieldHandler* fieldHandler = event->fieldHandler;
QStringList commands;
- if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_SCALAR_MAP ) {
+ if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_MESH_VIEW ) {
+ commands += QString("presentation_id = medcalc.MakeMeshView(accessField(%1), viewMode=%2)").arg(fieldHandler->id).arg(viewMode);
+ commands += QString("presentation_id");
+ }
+ else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_SCALAR_MAP ) {
commands += QString("presentation_id = medcalc.MakeScalarMap(accessField(%1), viewMode=%2, scalarBarRange=%3, colorMap=%4)")
.arg(fieldHandler->id).arg(viewMode).arg(scalarBarRange).arg(colorMap);
commands += QString("presentation_id");
// commands += QString("presentation_id = medcalc.MakeVectorField(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
// commands += QString("presentation_id");
// }
- // else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_SLICES ) {
- // commands += QString("presentation_id = medcalc.MakeSlices(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
- // commands += QString("presentation_id");
- // }
+ else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_SLICES ) {
+ commands += QString("presentation_id = medcalc.MakeSlices(accessField(%1), viewMode=%2, scalarBarRange=%3, colorMap=%4)")
+ .arg(fieldHandler->id).arg(viewMode).arg(scalarBarRange).arg(colorMap);
+ commands += QString("presentation_id");
+ }
// else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_DEFLECTION_SHAPE ) {
// commands += QString("presentation_id = medcalc.MakeDeflectionShape(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
// commands += QString("presentation_id");
commands += QString("params.nbContours = %1").arg(event->anInteger);
commands += QString("medcalc.UpdateContour(%1, params)").arg(event->presentationId);
}
+ else if ( event->eventtype == PresentationEvent::EVENT_CHANGE_MESH_MODE ) {
+ std::string typ = getPresTypeFromWidgetHelper(event->presentationId);
+ commands += QString("params = medcalc.GetMeshViewParameters(%2)").arg(event->presentationId);
+ commands += QString("params.mode = %1").arg(getMeshModePython(event->anInteger));
+ commands += QString("medcalc.UpdateMeshView(%1, params)").arg(event->presentationId);
+ }
+ else if ( event->eventtype == PresentationEvent::EVENT_CHANGE_NB_SLICES ) {
+ std::string typ = getPresTypeFromWidgetHelper(event->presentationId);
+ commands += QString("params = medcalc.GetSlicesParameters(%2)").arg(event->presentationId);
+ commands += QString("params.nbSlices = %1").arg(event->anInteger);
+ commands += QString("medcalc.UpdateSlices(%1, params)").arg(event->presentationId);
+ }
+ else if ( event->eventtype == PresentationEvent::EVENT_CHANGE_SLICE_ORIENTATION ) {
+ std::string typ = getPresTypeFromWidgetHelper(event->presentationId);
+ commands += QString("params = medcalc.GetSlicesParameters(%2)").arg(event->presentationId);
+ commands += QString("params.orientation = %1").arg(getSliceOrientationPython(event->anInteger));
+ commands += QString("medcalc.UpdateSlices(%1, params)").arg(event->presentationId);
+ }
+
else if ( event->eventtype == PresentationEvent::EVENT_DELETE_PRESENTATION ) {
commands += QString("medcalc.RemovePresentation(%1)").arg(event->presentationId);
}
if (it != _presHelperMap.end())
return (*it).second;
MEDWidgetHelper * wh;
- if (type == MEDPresentationScalarMap::TYPE_NAME)
+ if (type == MEDPresentationMeshView::TYPE_NAME)
+ wh = new MEDWidgetHelperMeshView(this, _presManager, presId, name, _widgetPresentationParameters);
+ else if (type == MEDPresentationScalarMap::TYPE_NAME)
wh = new MEDWidgetHelperScalarMap(this, _presManager, presId, name, _widgetPresentationParameters);
else if (type == MEDPresentationContour::TYPE_NAME)
wh = new MEDWidgetHelperContour(this, _presManager, presId, name, _widgetPresentationParameters);
+ else if (type == MEDPresentationSlices::TYPE_NAME)
+ wh = new MEDWidgetHelperSlices(this, _presManager, presId, name, _widgetPresentationParameters);
else
{
- // case PRES_CONTOUR:
- //// break;
- // case PRES_DEFLECTION:
- //// break;
- // case PRES_VECTOR_FIELD:
- // // break;
- // case PRES_POINT_SPRITE:
- // // break;
- // case PRES_POINT_SPRITE:
- // // break;
- // default:
STDLOG("findOrCreateWidgetHelper(): NOT IMPLEMENTED !!!");
-
}
_presHelperMap[presId] = wh;
return wh;
void presentationSignal(const PresentationEvent*);
protected slots:
+ void onVisualizeMeshView();
void onVisualizeScalarMap();
void onVisualizeContour();
void onVisualizeVectorField();
QString getViewModePython() const;
QString getColorMapPython() const;
QString getScalarBarRangePython() const;
+ QString getMeshModePython(const int mode) const;
+ QString getSliceOrientationPython(const int orient) const;
private:
MEDModule* _salomeModule;
typedef struct {
enum EventType {
+ EVENT_VIEW_OBJECT_MESH_VIEW,
EVENT_VIEW_OBJECT_CONTOUR,
EVENT_VIEW_OBJECT_DEFLECTION_SHAPE,
EVENT_VIEW_OBJECT_POINT_SPRITE,
EVENT_CHANGE_COLORMAP,
EVENT_CHANGE_TIME_RANGE,
- EVENT_CHANGE_NB_CONTOUR
+ EVENT_CHANGE_MESH_MODE,
+ EVENT_CHANGE_NB_CONTOUR,
+ EVENT_CHANGE_SLICE_ORIENTATION,
+ EVENT_CHANGE_NB_SLICES
};
EventType eventtype;
toggleWidget(false);
QObject::connect(_ui.comboBoxCompo, SIGNAL(currentIndexChanged(int)),
this, SLOT(onComboCompoIndexChanged(int)) );
+ QObject::connect(_ui.comboBoxMesh, SIGNAL(currentIndexChanged(int)),
+ this, SLOT(onComboMeshIndexChanged(int)) );
QObject::connect(_ui.comboBoxScalarBarRange, SIGNAL(currentIndexChanged(int)),
this, SLOT(onComboScalarBarRangeIndexChanged(int)) );
QObject::connect(_ui.comboBoxColorMap, SIGNAL(currentIndexChanged(int)),
this, SLOT(onComboColorMapIndexChanged(int)) );
+ QObject::connect(_ui.comboBoxSliceOrient, SIGNAL(currentIndexChanged(int)),
+ this, SLOT(onComboOrientIndexChanged(int)) );
QObject::connect(_ui.spinBox, SIGNAL(valueChanged(int)),
this, SLOT(onSpinBoxValueChanged(int)) );
}
if (!_blockSig) emit comboCompoIndexChanged(idx);
}
+void
+WidgetPresentationParameters::onComboOrientIndexChanged(int idx)
+{
+ if (!_blockSig) emit comboOrientIndexChanged(idx);
+}
+
+
+void
+WidgetPresentationParameters::onComboMeshIndexChanged(int idx)
+{
+ if (!_blockSig) emit comboMeshIndexChanged(idx);
+}
+
void
WidgetPresentationParameters::onComboColorMapIndexChanged(int idx)
{
if (!_blockSig) emit spinBoxValueChanged(val);
}
+void
+WidgetPresentationParameters::toggleCommonFieldWidget(bool show)
+{
+ _blockSig = true;
+ _ui.commonWidget->setEnabled(show);
+ _blockSig = false;
+}
+
void
WidgetPresentationParameters::toggleWidget(bool show)
{
if (!show)
{
+ toggleCommonFieldWidget(true);
+
_blockSig = true;
_ui.widgetDynamic->hide();
setPresName("Choose a presentation");
// It is the WidgetHelper responsability to re-show the widgets it needs
_ui.labelCompo->hide();
_ui.comboBoxCompo->hide();
+ _ui.labelMeshMode->hide();
+ _ui.comboBoxMesh->hide();
_ui.labelSpinBox->hide();
_ui.spinBox->hide();
_ui.labelSliceOrient->hide();
}
// Show the widget:
- _ui.labelSpinBox->setText(tr("LAB_NB_CONTOUR"));
+ _ui.labelSpinBox->setText(tr("LAB_NB_CONTOURS"));
_ui.labelSpinBox->show();
_ui.spinBox->show();
_blockSig = false;
}
+void
+WidgetPresentationParameters::setNbSlices(int nbSlices)
+{
+ if (nbSlices <= 0)
+ {
+ //TODO throw?
+ STDLOG("WidgetPresentationParameters::setNbSlices(): invalid number of slices!");
+ }
+
+ // Show the widget:
+ _ui.labelSpinBox->setText(tr("LAB_NB_SLICES"));
+ _ui.labelSpinBox->show();
+ _ui.spinBox->show();
+
+ _blockSig = true;
+ _ui.spinBox->setValue(nbSlices);
+ _blockSig = false;
+}
+
int WidgetPresentationParameters::getNbContour() const
{
return _ui.spinBox->value();
}
+int WidgetPresentationParameters::getNbSlices() const
+{
+ return _ui.spinBox->value();
+}
+
+
void
WidgetPresentationParameters::setScalarBarRange(MEDCALC::MEDPresentationScalarBarRange sbrange)
{
void
WidgetPresentationParameters::setColorMap(MEDCALC::MEDPresentationColorMap colorMap)
{
- int idx;
+ int idx = -1;
if (colorMap == MEDCALC::COLOR_MAP_BLUE_TO_RED_RAINBOW)
idx = _ui.comboBoxColorMap->findText(tr("LAB_BLUE_TO_RED"));
else if (colorMap == MEDCALC::COLOR_MAP_COOL_TO_WARM)
STDLOG("Strange!! No matching found - unable to set color map in GUI.");
}
+void
+WidgetPresentationParameters::setMeshMode(MEDCALC::MEDPresentationMeshMode mode)
+{
+ // Show the widget:
+ _ui.labelMeshMode->show();
+ _ui.comboBoxMesh->show();
+
+ int idx;
+ switch(mode)
+ {
+ case MEDCALC::MESH_MODE_WIREFRAME:
+ idx = _ui.comboBoxMesh->findText(tr("LAB_MESH_WIREFRAME"));
+ break;
+ case MEDCALC::MESH_MODE_SURFACE:
+ idx = _ui.comboBoxMesh->findText(tr("LAB_MESH_SURFACE"));
+ break;
+ case MEDCALC::MESH_MODE_SURFACE_EDGES:
+ idx = _ui.comboBoxMesh->findText(tr("LAB_MESH_SURF_EDGES"));
+ break;
+ default:
+ idx = -1;
+ }
+ if (idx >= 0)
+ {
+ _blockSig = true;
+ _ui.comboBoxMesh->setCurrentIndex(idx);
+ _blockSig = false;
+ }
+ else
+ STDLOG("Strange!! No matching found - unable to set mesh mode in GUI.");
+}
+
+void
+WidgetPresentationParameters::setSliceOrientation(MEDCALC::MEDPresentationSliceOrientation orient)
+{
+ // Show the widget:
+ _ui.labelSliceOrient->show();
+ _ui.comboBoxSliceOrient->show();
+
+ int idx;
+ switch(orient)
+ {
+ case MEDCALC::SLICE_NORMAL_TO_X:
+ idx = _ui.comboBoxSliceOrient->findText(tr("LAB_SLICE_NORMAL_TO_X"));
+ break;
+ case MEDCALC::SLICE_NORMAL_TO_Y:
+ idx = _ui.comboBoxSliceOrient->findText(tr("LAB_SLICE_NORMAL_TO_Y"));
+ break;
+ case MEDCALC::SLICE_NORMAL_TO_Z:
+ idx = _ui.comboBoxSliceOrient->findText(tr("LAB_SLICE_NORMAL_TO_Z"));
+ break;
+ case MEDCALC::SLICE_NORMAL_TO_XY:
+ idx = _ui.comboBoxSliceOrient->findText(tr("LAB_SLICE_NORMAL_TO_XY"));
+ break;
+ case MEDCALC::SLICE_NORMAL_TO_XZ:
+ idx = _ui.comboBoxSliceOrient->findText(tr("LAB_SLICE_NORMAL_TO_XZ"));
+ break;
+ case MEDCALC::SLICE_NORMAL_TO_YZ:
+ idx = _ui.comboBoxSliceOrient->findText(tr("LAB_SLICE_NORMAL_TO_YZ"));
+ break;
+ case MEDCALC::SLICE_NORMAL_TO_XYZ:
+ idx = _ui.comboBoxSliceOrient->findText(tr("LAB_SLICE_NORMAL_TO_XYZ"));
+ break;
+ default:
+ idx = -1;
+ }
+ if (idx >= 0)
+ {
+ _blockSig = true;
+ _ui.comboBoxSliceOrient->setCurrentIndex(idx);
+ _blockSig = false;
+ }
+ else
+ STDLOG("Strange!! No matching found - unable to set slice orientation in GUI.");
+}
+
+
+MEDCALC::MEDPresentationSliceOrientation
+WidgetPresentationParameters::getSliceOrientation() const
+{
+ QString sbrange = _ui.comboBoxSliceOrient->currentText();
+ if (sbrange == tr("LAB_SLICE_NORMAL_TO_X")) {
+ return MEDCALC::SLICE_NORMAL_TO_X;
+ }
+ else if (sbrange == tr("LAB_SLICE_NORMAL_TO_Y")) {
+ return MEDCALC::SLICE_NORMAL_TO_Y;
+ }
+ else if (sbrange == tr("LAB_SLICE_NORMAL_TO_Z")) {
+ return MEDCALC::SLICE_NORMAL_TO_Z;
+ }
+ else if (sbrange == tr("LAB_SLICE_NORMAL_TO_XY")) {
+ return MEDCALC::SLICE_NORMAL_TO_XY;
+ }
+ else if (sbrange == tr("LAB_SLICE_NORMAL_TO_XZ")) {
+ return MEDCALC::SLICE_NORMAL_TO_XZ;
+ }
+ else if (sbrange == tr("LAB_SLICE_NORMAL_TO_YZ")) {
+ return MEDCALC::SLICE_NORMAL_TO_YZ;
+ }
+ else if (sbrange == tr("LAB_SLICE_NORMAL_TO_XYZ")) {
+ return MEDCALC::SLICE_NORMAL_TO_XYZ;
+ }
+ // Should not happen
+ STDLOG("Strange!! No matching found - returning SLICE_NORMAL_TO_X.");
+ return MEDCALC::SLICE_NORMAL_TO_X;
+}
+
+MEDCALC::MEDPresentationMeshMode
+WidgetPresentationParameters::getMeshMode() const
+{
+ QString mesm = _ui.comboBoxMesh->currentText();
+ if (mesm == tr("LAB_MESH_WIREFRAME")) {
+ return MEDCALC::MESH_MODE_WIREFRAME;
+ }
+ else if (mesm == tr("LAB_MESH_SURFACE")) {
+ return MEDCALC::MESH_MODE_SURFACE;
+ }
+ else if (mesm == tr("LAB_MESH_SURF_EDGES")) {
+ return MEDCALC::MESH_MODE_SURFACE_EDGES;
+ }
+ // Should not happen
+ STDLOG("Strange!! No matching found - returning MESH_MODE_WIREFRAME.");
+ return MEDCALC::MESH_MODE_WIREFRAME;
+}
+
MEDCALC::MEDPresentationScalarBarRange
WidgetPresentationParameters::getScalarBarRange() const
return MEDCALC::COLOR_MAP_BLUE_TO_RED_RAINBOW;
}
-QComboBox *
-WidgetPresentationParameters::getComboBoxCompo()
-{
- return _ui.comboBoxCompo;
-}
-
void
WidgetPresentationParameters::setPresName(const std::string& name)
{
std::string getComponent() const;
void setComponents(std::vector<std::string> compos, int selecIndex);
+ MEDCALC::MEDPresentationMeshMode getMeshMode() const;
+ void setMeshMode(MEDCALC::MEDPresentationMeshMode mode);
+
MEDCALC::MEDPresentationScalarBarRange getScalarBarRange() const;
void setScalarBarRange(MEDCALC::MEDPresentationScalarBarRange);
int getNbContour() const;
void setNbContour(int nbContour);
+ int getNbSlices() const;
+ void setNbSlices(int nbSlices);
+
+ MEDCALC::MEDPresentationSliceOrientation getSliceOrientation() const;
+ void setSliceOrientation(MEDCALC::MEDPresentationSliceOrientation orient);
+
void toggleWidget(bool show);
bool isShown() const;
- QComboBox * getComboBoxCompo();
+
+ void toggleCommonFieldWidget(bool show);
signals:
void comboScalarBarRangeIndexChanged(int);
void comboColorMapIndexChanged(int);
void comboCompoIndexChanged(int);
+ void comboOrientIndexChanged(int);
+ void comboMeshIndexChanged(int);
void spinBoxValueChanged(int);
private slots:
void onComboScalarBarRangeIndexChanged(int);
void onComboColorMapIndexChanged(int);
void onComboCompoIndexChanged(int);
+ void onComboOrientIndexChanged(int);
+ void onComboMeshIndexChanged(int);
void onSpinBoxValueChanged(int);
private:
<rect>
<x>0</x>
<y>0</y>
- <width>439</width>
- <height>359</height>
+ <width>784</width>
+ <height>584</height>
</rect>
</property>
<property name="minimumSize">
</widget>
</item>
<item>
- <widget class="QWidget" name="widget" native="true">
+ <widget class="QWidget" name="commonWidget" native="true">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="1">
<widget class="QComboBox" name="comboBoxScalarBarRange">
</property>
</widget>
</item>
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_4">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>LAB_RANGE</string>
+ </property>
+ </widget>
+ </item>
<item row="2" column="1">
<widget class="QComboBox" name="comboBoxColorMap">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
<item>
<property name="text">
<string>LAB_BLUE_TO_RED</string>
</item>
</widget>
</item>
- <item row="0" column="0">
- <widget class="QLabel" name="label_4">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>LAB_RANGE</string>
- </property>
- </widget>
- </item>
</layout>
</widget>
</item>
<widget class="QWidget" name="widgetDynamic" native="true">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
+ <widget class="QLabel" name="labelMeshMode">
+ <property name="text">
+ <string>LAB_DISP_MESH_MODE</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QComboBox" name="comboBoxMesh">
+ <item>
+ <property name="text">
+ <string>LAB_MESH_WIREFRAME</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>LAB_MESH_SURFACE</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>LAB_MESH_SURF_EDGES</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="1" column="0">
<widget class="QLabel" name="labelCompo">
<property name="text">
<string>LAB_DISP_COMP</string>
</property>
</widget>
</item>
- <item row="0" column="1" colspan="2">
+ <item row="1" column="1">
<widget class="QComboBox" name="comboBoxCompo">
<item>
<property name="text">
</item>
</widget>
</item>
- <item row="1" column="0">
+ <item row="2" column="0">
<widget class="QLabel" name="labelSpinBox">
<property name="text">
<string>LAB_SPIN_BOX</string>
</property>
</widget>
</item>
- <item row="1" column="1">
+ <item row="2" column="1">
<widget class="QSpinBox" name="spinBox"/>
</item>
- <item row="1" column="2">
+ <item row="2" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</spacer>
</item>
- <item row="2" column="0">
+ <item row="3" column="0">
<widget class="QLabel" name="labelSliceOrient">
<property name="text">
<string>LAB_SLICE_ORIENT</string>
</property>
</widget>
</item>
- <item row="2" column="1" colspan="2">
+ <item row="3" column="1">
<widget class="QComboBox" name="comboBoxSliceOrient">
<item>
<property name="text">
<string>LAB_SLICE_NORMAL_TO_Z</string>
</property>
</item>
+ <item>
+ <property name="text">
+ <string>LAB_SLICE_NORMAL_TO_XY</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>LAB_SLICE_NORMAL_TO_XZ</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>LAB_SLICE_NORMAL_TO_YZ</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>LAB_SLICE_NORMAL_TO_XYZ</string>
+ </property>
+ </item>
</widget>
</item>
</layout>
SET(_test_files
medfiles/smooth_surface_and_field.med
+ medfiles/agitateur.med
)
SET(TEST_INSTALL_DIRECTORY ${SALOME_MED_INSTALL_TEST}/MEDCalc/tui)
# Field 0 = CONCENTRATION_ELEM_DOM (ON_CELLS) -> scalar
presentation_id = medcalc.MakeContour(accessField(0), MEDCALC.VIEW_MODE_REPLACE, colorMap=MEDCALC.COLOR_MAP_BLUE_TO_RED_RAINBOW)
-sleep(2)
+sleep(1)
medcalc.RemovePresentation(presentation_id)
-sleep(2)
+sleep(1)
# Field 55 = VITESSE_ELEM_DOM (ON_CELLS) -> vector field, contour should fail.
try:
sys.exit(-1);
except:
print "Contour failed as expected."
-sleep(2)
+sleep(1)
--- /dev/null
+# Copyright (C) 2016 CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+import os
+from time import sleep
+
+import medcalc
+medcalc.medconsole.setConsoleGlobals(globals())
+import MEDCALC
+from medcalc.medconsole import accessField
+
+from medcalc_testutils import GetMEDFileDirTUI
+
+datafile = os.path.join(GetMEDFileDirTUI(), "smooth_surface_and_field.med")
+source_id = medcalc.LoadDataSource(datafile)
+
+presentation_id = medcalc.MakeMeshView(accessField(0), MEDCALC.VIEW_MODE_REPLACE)
+sleep(1)
+medcalc.RemovePresentation(presentation_id)
+sleep(1)
source_id = medcalc.LoadDataSource(datafile)
presentation_id = medcalc.MakeScalarMap(accessField(0), MEDCALC.VIEW_MODE_REPLACE, colorMap=MEDCALC.COLOR_MAP_BLUE_TO_RED_RAINBOW)
-sleep(2)
+sleep(1)
medcalc.RemovePresentation(presentation_id)
-sleep(2)
+sleep(1)
--- /dev/null
+# Copyright (C) 2016 CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+import os
+from time import sleep
+
+import medcalc
+medcalc.medconsole.setConsoleGlobals(globals())
+import MEDCALC
+from medcalc.medconsole import accessField
+
+from medcalc_testutils import GetMEDFileDirTUI
+
+datafile = os.path.join(GetMEDFileDirTUI(), "agitateur.med")
+source_id = medcalc.LoadDataSource(datafile)
+
+presentation_id = medcalc.MakeSlices(accessField(0), MEDCALC.VIEW_MODE_REPLACE, colorMap=MEDCALC.COLOR_MAP_BLUE_TO_RED_RAINBOW)
+sleep(1)
+medcalc.RemovePresentation(presentation_id)
+sleep(1)
load_file
import_pvsimple
# scalar_map
+# contour
+# slices
+# mesh_view
)
from medio import LoadImageAsDataSource
# Presentations
+from medpresentation import MakeMeshView
from medpresentation import MakeScalarMap
from medpresentation import MakeContour
#from medpresentation import MakeVectorField
-#from medpresentation import MakeSlices
+from medpresentation import MakeSlices
#from medpresentation import MakeDeflectionShape
#from medpresentation import MakePointSprite
from medpresentation import RemovePresentation
+from medpresentation import GetMeshViewParameters
from medpresentation import GetScalarMapParameters
from medpresentation import GetContourParameters
+from medpresentation import GetSlicesParameters
+from medpresentation import UpdateMeshView
from medpresentation import UpdateScalarMap
from medpresentation import UpdateContour
+from medpresentation import UpdateSlices
# Console commands
import medconsole
__manager = medcalc.medcorba.factory.getPresentationManager()
+def MakeMeshView(proxy,
+ 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(proxy.id, meshMode)
+ try:
+ presentation_id = __manager.makeMeshView(params, viewMode)
+ notifyGui_addPresentation(proxy.id, presentation_id)
+ return presentation_id
+ except SALOME.SALOME_Exception as e:
+ notifyGui_error("An error occured while creating the mesh view:\n" + e.details.text)
+ raise Exception(e.details.text)
+
+
def MakeScalarMap(proxy,
viewMode=MEDCALC.VIEW_MODE_DEFAULT,
displayedComponent=MEDCALC.DISPLAY_DEFAULT,
def MakeContour(proxy,
viewMode=MEDCALC.VIEW_MODE_DEFAULT,
- displayedComponent=MEDCALC.DISPLAY_DEFAULT,
scalarBarRange=MEDCALC.SCALAR_BAR_RANGE_DEFAULT,
colorMap=MEDCALC.COLOR_MAP_DEFAULT,
nbContours=MEDCALC.NB_CONTOURS_DEFAULT
# return presentation_id
##
#
-#def MakeSlices(proxy,
-# viewMode=MEDCALC.VIEW_MODE_DEFAULT,
-# orientation=MEDCALC.SLICE_ORIENTATION_DEFAULT,
-# nbSlices=MEDCALC.NB_SLICES_DEFAULT
-# ):
-# params = MEDCALC.SlicesParameters(proxy.id, viewMode, orientation, nbSlices)
-# presentation_id = __manager.makeSlices(params)
-# notifyGui_addPresentation(proxy.id, presentation_id)
-# return presentation_id
+def MakeSlices(proxy,
+ viewMode=MEDCALC.VIEW_MODE_DEFAULT,
+ displayedComponent=MEDCALC.DISPLAY_DEFAULT,
+ scalarBarRange=MEDCALC.SCALAR_BAR_RANGE_DEFAULT,
+ colorMap=MEDCALC.COLOR_MAP_DEFAULT,
+ sliceOrientation=MEDCALC.SLICE_ORIENTATION_DEFAULT,
+ 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,
+ sliceOrientation, nbSlices)
+ try:
+ presentation_id = __manager.makeSlices(params, viewMode)
+ notifyGui_addPresentation(proxy.id, presentation_id)
+ return presentation_id
+ except SALOME.SALOME_Exception as e:
+ notifyGui_error("An error occured while creating the slices:\n" + e.details.text)
+ raise Exception(e.details.text)
##
#
#def MakeDeflectionShape(proxy,
notifyGui_removePresentation(presentation_id)
#
-def GetScalarMapParameters(presentation_id):
- # TODO: check that pres id is really a ScalarMap ...
- params = __manager.getScalarMapParameters(presentation_id)
+def GetGENERICParameters(tag, presentation_id):
+ exec "params = __manager.get%sParameters(presentation_id)" % tag
return params
-def GetContourParameters(presentation_id):
- # TODO: check that pres id is really a ScalarMap ...
- params = __manager.getContourParameters(presentation_id)
- return params
+GetMeshViewParameters = lambda pres_id: GetGENERICParameters("MeshView", pres_id)
+GetScalarMapParameters = lambda pres_id: GetGENERICParameters("ScalarMap", pres_id)
+GetContourParameters = lambda pres_id: GetGENERICParameters("Contour", pres_id)
+GetSlicesParameters = lambda pres_id: GetGENERICParameters("Slices", pres_id)
-def UpdateScalarMap(presentation_id, params):
- __manager.updateScalarMap(presentation_id, params)
-def UpdateContour(presentation_id, params):
- __manager.updateContour(presentation_id, params)
+def UpdateGENERIC(tag, presentation_id, params):
+ exec "__manager.update%s(presentation_id, params)" % tag
+UpdateMeshView = lambda pres_id, params: UpdateGENERIC("MeshView", pres_id, params)
+UpdateScalarMap = lambda pres_id, params: UpdateGENERIC("ScalarMap", pres_id, params)
+UpdateContour = lambda pres_id, params: UpdateGENERIC("Contour", pres_id, params)
+UpdateSlices = lambda pres_id, params: UpdateGENERIC("Slices", pres_id, params)