From: abn Date: Tue, 12 Apr 2016 13:38:15 +0000 (+0200) Subject: [MEDCalc] Reset camera X-Git-Tag: V8_1_0a1~11 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b93b64f594b76acc150329fe0d4d2be34738c674;p=modules%2Fmed.git [MEDCalc] Reset camera --- diff --git a/src/MEDCalc/cmp/MEDPresentation.cxx b/src/MEDCalc/cmp/MEDPresentation.cxx index 09ce776ae..24d36c5a6 100644 --- a/src/MEDCalc/cmp/MEDPresentation.cxx +++ b/src/MEDCalc/cmp/MEDPresentation.cxx @@ -70,10 +70,11 @@ void MEDPresentation::setProperty(const std::string& propName, const std::string } const std::string -MEDPresentation::getProperty(const std::string& propName) +MEDPresentation::getProperty(const std::string& propName) const { - if (_properties.find(propName) != _properties.end()) { - return _properties[propName]; + std::map::const_iterator it = _properties.find(propName); + if (it != _properties.end()) { + return (*it).second; } else { std::cerr << "getProperty(): no property named " << propName << std::endl; @@ -81,7 +82,7 @@ MEDPresentation::getProperty(const std::string& propName) } } -PyObject * MEDPresentation::getPythonObjectFromMain(const char * python_var) +PyObject * MEDPresentation::getPythonObjectFromMain(const char * python_var) const { // TODO: improve to avoid getting dict at each call @@ -91,7 +92,7 @@ PyObject * MEDPresentation::getPythonObjectFromMain(const char * python_var) return PyDict_GetItemString(global_dict, python_var); } -std::string MEDPresentation::getFieldTypeString(MEDCoupling::TypeOfField fieldType) +std::string MEDPresentation::getFieldTypeString(MEDCoupling::TypeOfField fieldType) const { switch(fieldType) { @@ -106,7 +107,7 @@ std::string MEDPresentation::getFieldTypeString(MEDCoupling::TypeOfField fieldTy } std::string -MEDPresentation::getRenderViewCommand(MEDCALC::MEDPresentationViewMode viewMode) +MEDPresentation::getRenderViewCommand(MEDCALC::MEDPresentationViewMode viewMode) const { std::string cmd = std::string("pvs._DisableFirstRenderCameraReset();"); if (viewMode == MEDCALC::VIEW_MODE_OVERLAP) { @@ -121,12 +122,18 @@ MEDPresentation::getRenderViewCommand(MEDCALC::MEDPresentationViewMode viewMode) } else if (viewMode == MEDCALC::VIEW_MODE_SPLIT_VIEW) { cmd += std::string("__view1 = pvs.CreateView('RenderView');"); } - cmd += std::string("__view1.ResetCamera();"); return cmd; } std::string -MEDPresentation::getColorMapCommand(MEDCALC::MEDPresentationColorMap colorMap) +MEDPresentation::getResetCameraCommand() const +{ + return std::string("__view1.ResetCamera();"); +} + + +std::string +MEDPresentation::getColorMapCommand(MEDCALC::MEDPresentationColorMap colorMap) const { switch(colorMap) { case MEDCALC::COLOR_MAP_BLUE_TO_RED_RAINBOW: return "Blue to Red Rainbow"; diff --git a/src/MEDCalc/cmp/MEDPresentation.hxx b/src/MEDCalc/cmp/MEDPresentation.hxx index f9abab44b..aac5c5a00 100644 --- a/src/MEDCalc/cmp/MEDPresentation.hxx +++ b/src/MEDCalc/cmp/MEDPresentation.hxx @@ -44,24 +44,25 @@ public: virtual ~MEDPresentation() {} void setProperty(const std::string& propName, const std::string& propValue); - const std::string getProperty(const std::string& propName); + const std::string getProperty(const std::string& propName) const; protected: MEDPresentation(MEDPresentation::TypeID fieldHandlerId, std::string name); - std::string getRenderViewCommand(MEDCALC::MEDPresentationViewMode viewMode); - std::string getColorMapCommand(MEDCALC::MEDPresentationColorMap colorMap); + std::string getRenderViewCommand(MEDCALC::MEDPresentationViewMode viewMode) const; + std::string getResetCameraCommand() const; + std::string getColorMapCommand(MEDCALC::MEDPresentationColorMap colorMap) const; virtual void internalGeneratePipeline() = 0; - PyObject * getPythonObjectFromMain(const char * var); + PyObject * getPythonObjectFromMain(const char * var) const; void pushInternal(PyObject * obj, PyObject * disp = NULL); - MEDPresentation::TypeID getID() { return _fieldHandlerId; } + MEDPresentation::TypeID getID() const { return _fieldHandlerId; } private: void generatePipeline(); // reserved to friend class MEDPresentationManager - std::string getFieldTypeString(MEDCoupling::TypeOfField fieldType); + std::string getFieldTypeString(MEDCoupling::TypeOfField fieldType) const; protected: diff --git a/src/MEDCalc/cmp/MEDPresentationContour.cxx b/src/MEDCalc/cmp/MEDPresentationContour.cxx index c704099ee..883cfb176 100644 --- a/src/MEDCalc/cmp/MEDPresentationContour.cxx +++ b/src/MEDCalc/cmp/MEDPresentationContour.cxx @@ -35,6 +35,8 @@ MEDPresentationContour::internalGeneratePipeline() 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()); diff --git a/src/MEDCalc/cmp/MEDPresentationDeflectionShape.cxx b/src/MEDCalc/cmp/MEDPresentationDeflectionShape.cxx index 65da5e468..1a20da493 100644 --- a/src/MEDCalc/cmp/MEDPresentationDeflectionShape.cxx +++ b/src/MEDCalc/cmp/MEDPresentationDeflectionShape.cxx @@ -35,6 +35,8 @@ MEDPresentationDeflectionShape::internalGeneratePipeline() 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()); diff --git a/src/MEDCalc/cmp/MEDPresentationPointSprite.cxx b/src/MEDCalc/cmp/MEDPresentationPointSprite.cxx index 381c0716a..3d618575f 100644 --- a/src/MEDCalc/cmp/MEDPresentationPointSprite.cxx +++ b/src/MEDCalc/cmp/MEDPresentationPointSprite.cxx @@ -35,6 +35,8 @@ MEDPresentationPointSprite::internalGeneratePipeline() cmd += std::string("__disp1.SetRepresentationType('Point Sprite');"); cmd += std::string("pvs.Render();"); + cmd += getResetCameraCommand(); + //std::cerr << "Python command:" << std::endl; //std::cerr << cmd << std::endl; PyRun_SimpleString(cmd.c_str()); diff --git a/src/MEDCalc/cmp/MEDPresentationScalarMap.cxx b/src/MEDCalc/cmp/MEDPresentationScalarMap.cxx index b518a4c3f..a09da3feb 100644 --- a/src/MEDCalc/cmp/MEDPresentationScalarMap.cxx +++ b/src/MEDCalc/cmp/MEDPresentationScalarMap.cxx @@ -36,6 +36,8 @@ MEDPresentationScalarMap::internalGeneratePipeline() cmd += std::string("__lut.ApplyPreset('")+getColorMapCommand(_params.colorMap)+std::string("',True);"); cmd += std::string("pvs.Render();"); + cmd += getResetCameraCommand(); + //std::cerr << "Python command:" << std::endl; //std::cerr << cmd << std::endl; PyRun_SimpleString(cmd.c_str()); diff --git a/src/MEDCalc/cmp/MEDPresentationSlices.cxx b/src/MEDCalc/cmp/MEDPresentationSlices.cxx index 30386223b..4b5636aad 100644 --- a/src/MEDCalc/cmp/MEDPresentationSlices.cxx +++ b/src/MEDCalc/cmp/MEDPresentationSlices.cxx @@ -35,6 +35,8 @@ MEDPresentationSlices::internalGeneratePipeline() 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()); diff --git a/src/MEDCalc/cmp/MEDPresentationVectorField.cxx b/src/MEDCalc/cmp/MEDPresentationVectorField.cxx index 33290a631..ae03a030d 100644 --- a/src/MEDCalc/cmp/MEDPresentationVectorField.cxx +++ b/src/MEDCalc/cmp/MEDPresentationVectorField.cxx @@ -35,6 +35,8 @@ MEDPresentationVectorField::internalGeneratePipeline() cmd += std::string("__disp1.SetRepresentationType('3D Glyphs');"); cmd += std::string("pvs.Render();"); + cmd += getResetCameraCommand(); + //std::cerr << "Python command:" << std::endl; //std::cerr << cmd << std::endl; PyRun_SimpleString(cmd.c_str());