From f5f3b19aa06206bc38e8a26e8e3b740794c15955 Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=A9dric=20Aguerre?= Date: Mon, 18 Jan 2016 10:13:16 +0100 Subject: [PATCH] update MEDCalc APIs --- idl/MEDPresentationManager.idl | 34 +++- src/MEDCalc/cmp/CMakeLists.txt | 9 +- src/MEDCalc/cmp/MEDPresentation.cxx | 47 +----- src/MEDCalc/cmp/MEDPresentation.hxx | 18 +-- src/MEDCalc/cmp/MEDPresentationContour.cxx | 7 + src/MEDCalc/cmp/MEDPresentationContour.hxx | 41 +++++ .../cmp/MEDPresentationDeflectionShape.cxx | 7 + .../cmp/MEDPresentationDeflectionShape.hxx | 41 +++++ src/MEDCalc/cmp/MEDPresentationManager_i.cxx | 149 +++++++++++++++++- src/MEDCalc/cmp/MEDPresentationManager_i.hxx | 8 +- .../cmp/MEDPresentationPointSprite.cxx | 7 + .../cmp/MEDPresentationPointSprite.hxx | 41 +++++ src/MEDCalc/cmp/MEDPresentationScalarMap.cxx | 48 ++++++ src/MEDCalc/cmp/MEDPresentationScalarMap.hxx | 41 +++++ src/MEDCalc/cmp/MEDPresentationSlices.cxx | 7 + src/MEDCalc/cmp/MEDPresentationSlices.hxx | 41 +++++ .../cmp/MEDPresentationVectorField.cxx | 7 + .../cmp/MEDPresentationVectorField.hxx | 41 +++++ src/MEDCalc/gui/DatasourceController.cxx | 47 +++++- src/MEDCalc/gui/DatasourceController.hxx | 13 +- src/MEDCalc/gui/MED_msg_en.ts | 42 ++++- src/MEDCalc/gui/MED_msg_fr.ts | 40 +++++ src/MEDCalc/gui/WorkspaceController.cxx | 55 ++++++- src/MEDCalc/gui/WorkspaceController.hxx | 3 +- src/MEDCalc/tui/__init__.py | 4 +- src/MEDCalc/tui/medpresentation.py | 27 +++- 26 files changed, 736 insertions(+), 89 deletions(-) create mode 100644 src/MEDCalc/cmp/MEDPresentationContour.cxx create mode 100644 src/MEDCalc/cmp/MEDPresentationContour.hxx create mode 100644 src/MEDCalc/cmp/MEDPresentationDeflectionShape.cxx create mode 100644 src/MEDCalc/cmp/MEDPresentationDeflectionShape.hxx create mode 100644 src/MEDCalc/cmp/MEDPresentationPointSprite.cxx create mode 100644 src/MEDCalc/cmp/MEDPresentationPointSprite.hxx create mode 100644 src/MEDCalc/cmp/MEDPresentationScalarMap.cxx create mode 100644 src/MEDCalc/cmp/MEDPresentationScalarMap.hxx create mode 100644 src/MEDCalc/cmp/MEDPresentationSlices.cxx create mode 100644 src/MEDCalc/cmp/MEDPresentationSlices.hxx create mode 100644 src/MEDCalc/cmp/MEDPresentationVectorField.cxx create mode 100644 src/MEDCalc/cmp/MEDPresentationVectorField.hxx diff --git a/idl/MEDPresentationManager.idl b/idl/MEDPresentationManager.idl index 2d744bbce..e7eac75f4 100644 --- a/idl/MEDPresentationManager.idl +++ b/idl/MEDPresentationManager.idl @@ -1,4 +1,4 @@ -// Copyright (C) 2005-2015 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2005-2016 CEA/DEN, EDF R&D, OPEN CASCADE // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -37,10 +37,42 @@ module MEDCALC MEDPresentationViewMode viewMode; }; + // A contour is an isoline in 2D and an isosurface in 3D + struct ContourParameters { + long fieldHandlerId; + MEDPresentationViewMode viewMode; + }; + + struct VectorFieldParameters { + long fieldHandlerId; + MEDPresentationViewMode viewMode; + }; + + struct SlicesParameters { + long fieldHandlerId; + MEDPresentationViewMode viewMode; + }; + + struct DeflectionShapeParameters { + long fieldHandlerId; + MEDPresentationViewMode viewMode; + }; + + struct PointSpriteParameters { + long fieldHandlerId; + MEDPresentationViewMode viewMode; + }; + interface MEDPresentationManager : SALOME::GenericObj { long makeScalarMap(in ScalarMapParameters params); + long makeContour(in ContourParameters params); + long makeVectorField(in VectorFieldParameters params); + long makeSlices(in SlicesParameters params); + long makeDeflectionShape(in DeflectionShapeParameters params); + long makePointSprite(in PointSpriteParameters params); + void setPresentationProperty(in long presId, in string propName, in string propValue); string getPresentationProperty(in long presId, in string propName); diff --git a/src/MEDCalc/cmp/CMakeLists.txt b/src/MEDCalc/cmp/CMakeLists.txt index 7309619b3..51ecc9104 100644 --- a/src/MEDCalc/cmp/CMakeLists.txt +++ b/src/MEDCalc/cmp/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2015 CEA/DEN, EDF R&D +# Copyright (C) 2012-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 @@ -37,6 +37,13 @@ SET(COMMON_SOURCES MEDCalculator_i.cxx MEDPresentationManager_i.cxx MEDPresentation.cxx + # presentations + MEDPresentationScalarMap.cxx + MEDPresentationContour.cxx + MEDPresentationVectorField.cxx + MEDPresentationSlices.cxx + MEDPresentationDeflectionShape.cxx + MEDPresentationPointSprite.cxx ) SET(MEDFactoryEngine_SOURCES diff --git a/src/MEDCalc/cmp/MEDPresentation.cxx b/src/MEDCalc/cmp/MEDPresentation.cxx index 46ec07145..5ce06a707 100644 --- a/src/MEDCalc/cmp/MEDPresentation.cxx +++ b/src/MEDCalc/cmp/MEDPresentation.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2011-2015 CEA/DEN, EDF R&D +// Copyright (C) 2011-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 @@ -89,48 +89,3 @@ std::string MEDPresentation::getFieldTypeString() return ""; } } - - -void MEDPresentationScalarMap::internalGeneratePipeline() -{ - MEDCALC::MEDDataManager_ptr dataManager(MEDFactoryClient::getDataManager()); - - MEDCALC::MeshHandler* meshHandler = dataManager->getMesh(_fieldHandler->meshid); - MEDCALC::DatasourceHandler* dataSHandler = dataManager->getDatasourceHandlerFromID(meshHandler->sourceid); - - std::string fileName(dataSHandler->uri); - std::string fieldName(_fieldHandler->fieldname); - std::string fieldType = getFieldTypeString(); - - std::cout << "Generating pipeline for SCALAR MAP:" < _properties; }; -class MEDCALC_EXPORT MEDPresentationScalarMap : public MEDPresentation -{ -public: - MEDPresentationScalarMap(MEDCALC::FieldHandler* fieldHdl, bool wireframe) : - MEDPresentation(fieldHdl, "MEDPresentationScalarMap"), - _isWireframe(wireframe) - {} - virtual ~MEDPresentationScalarMap() {} - -protected: - virtual void internalGeneratePipeline(); - -private: - bool _isWireframe; -}; - #endif /* SRC_MEDCALC_CMP_MEDPRESENTATION_HXX_ */ diff --git a/src/MEDCalc/cmp/MEDPresentationContour.cxx b/src/MEDCalc/cmp/MEDPresentationContour.cxx new file mode 100644 index 000000000..abd3efbca --- /dev/null +++ b/src/MEDCalc/cmp/MEDPresentationContour.cxx @@ -0,0 +1,7 @@ +#include "MEDPresentationContour.hxx" +#include "MEDFactoryClient.hxx" + +void +MEDPresentationContour::internalGeneratePipeline() +{ +} diff --git a/src/MEDCalc/cmp/MEDPresentationContour.hxx b/src/MEDCalc/cmp/MEDPresentationContour.hxx new file mode 100644 index 000000000..56c7a01f6 --- /dev/null +++ b/src/MEDCalc/cmp/MEDPresentationContour.hxx @@ -0,0 +1,41 @@ +// 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_CONTOUR_HXX_ +#define SRC_MEDCALC_CMP_MEDPRESENTATION_CONTOUR_HXX_ + +#include "MEDCALC.hxx" +#include "MEDPresentation.hxx" + +class MEDCALC_EXPORT MEDPresentationContour : public MEDPresentation +{ +public: + MEDPresentationContour(MEDCALC::FieldHandler* fieldHdl, bool wireframe) : + MEDPresentation(fieldHdl, "MEDPresentationContour"), + _isWireframe(wireframe) + {} + virtual ~MEDPresentationContour() {} + +protected: + virtual void internalGeneratePipeline(); + +private: + bool _isWireframe; +}; + +#endif diff --git a/src/MEDCalc/cmp/MEDPresentationDeflectionShape.cxx b/src/MEDCalc/cmp/MEDPresentationDeflectionShape.cxx new file mode 100644 index 000000000..ab15b5252 --- /dev/null +++ b/src/MEDCalc/cmp/MEDPresentationDeflectionShape.cxx @@ -0,0 +1,7 @@ +#include "MEDPresentationDeflectionShape.hxx" +#include "MEDFactoryClient.hxx" + +void +MEDPresentationDeflectionShape::internalGeneratePipeline() +{ +} diff --git a/src/MEDCalc/cmp/MEDPresentationDeflectionShape.hxx b/src/MEDCalc/cmp/MEDPresentationDeflectionShape.hxx new file mode 100644 index 000000000..b46db997c --- /dev/null +++ b/src/MEDCalc/cmp/MEDPresentationDeflectionShape.hxx @@ -0,0 +1,41 @@ +// 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_DEFLECTIONSHAPE_HXX_ +#define SRC_MEDCALC_CMP_MEDPRESENTATION_DEFLECTIONSHAPE_HXX_ + +#include "MEDCALC.hxx" +#include "MEDPresentation.hxx" + +class MEDCALC_EXPORT MEDPresentationDeflectionShape : public MEDPresentation +{ +public: + MEDPresentationDeflectionShape(MEDCALC::FieldHandler* fieldHdl, bool wireframe) : + MEDPresentation(fieldHdl, "MEDPresentationDeflectionShape"), + _isWireframe(wireframe) + {} + virtual ~MEDPresentationDeflectionShape() {} + +protected: + virtual void internalGeneratePipeline(); + +private: + bool _isWireframe; +}; + +#endif diff --git a/src/MEDCalc/cmp/MEDPresentationManager_i.cxx b/src/MEDCalc/cmp/MEDPresentationManager_i.cxx index a268f47f8..35d6424ab 100644 --- a/src/MEDCalc/cmp/MEDPresentationManager_i.cxx +++ b/src/MEDCalc/cmp/MEDPresentationManager_i.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2011-2015 CEA/DEN, EDF R&D +// Copyright (C) 2011-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 @@ -20,6 +20,12 @@ #include "MEDPresentationManager_i.hxx" #include "MEDFactoryClient.hxx" #include "MEDPresentation.hxx" +#include "MEDPresentationScalarMap.hxx" +#include "MEDPresentationContour.hxx" +#include "MEDPresentationVectorField.hxx" +#include "MEDPresentationSlices.hxx" +#include "MEDPresentationDeflectionShape.hxx" +#include "MEDPresentationPointSprite.hxx" MEDPresentationManager_i* MEDPresentationManager_i::_instance = NULL; @@ -101,10 +107,145 @@ MEDPresentationManager_i::makeScalarMap(const MEDCALC::ScalarMapParameters& para // Create a new presentation instance TypeID newID = MEDPresentationManager_i::GenerateID(); - MEDPresentationScalarMap * scalarMap = new MEDPresentationScalarMap(fieldHandler, true); // on stack or on heap?? stack for now - _presentations.insert( std::pair(newID, scalarMap) ); + MEDPresentationScalarMap * presentation = new MEDPresentationScalarMap(fieldHandler, true); // on stack or on heap?? stack for now + _presentations.insert( std::pair(newID, presentation) ); - scalarMap->generatePipeline(); + presentation->generatePipeline(); + + return newID; +} + +TypeID +MEDPresentationManager_i::makeContour(const MEDCALC::ContourParameters& params) +{ + MEDCALC::MEDDataManager_ptr dataManager(MEDFactoryClient::getDataManager()); + + TypeID fieldHandlerId = params.fieldHandlerId; + MEDCALC::MEDPresentationViewMode viewMode = params.viewMode; + + MEDCALC::FieldHandler* fieldHandler = dataManager->getFieldHandler(fieldHandlerId); + MEDCALC::MeshHandler* meshHandler = dataManager->getMesh(fieldHandler->meshid); + MEDCALC::DatasourceHandler* dataSHandler = dataManager->getDatasourceHandlerFromID(meshHandler->sourceid); + + std::cout << "\tfieldHandlerId: " << fieldHandlerId << std::endl; + std::cout << "\tviewMode: " << viewMode << std::endl; + std::cout << "\tfileName: " << dataSHandler->uri << std::endl; + std::cout << "\tfiedName: " << fieldHandler->fieldname << std::endl; + + // Create a new presentation instance + TypeID newID = MEDPresentationManager_i::GenerateID(); + MEDPresentationContour * presentation = new MEDPresentationContour(fieldHandler, true); // on stack or on heap?? stack for now + _presentations.insert( std::pair(newID, presentation) ); + + presentation->generatePipeline(); + + return newID; +} + +TypeID +MEDPresentationManager_i::makeVectorField(const MEDCALC::VectorFieldParameters& params) +{ + MEDCALC::MEDDataManager_ptr dataManager(MEDFactoryClient::getDataManager()); + + TypeID fieldHandlerId = params.fieldHandlerId; + MEDCALC::MEDPresentationViewMode viewMode = params.viewMode; + + MEDCALC::FieldHandler* fieldHandler = dataManager->getFieldHandler(fieldHandlerId); + MEDCALC::MeshHandler* meshHandler = dataManager->getMesh(fieldHandler->meshid); + MEDCALC::DatasourceHandler* dataSHandler = dataManager->getDatasourceHandlerFromID(meshHandler->sourceid); + + std::cout << "\tfieldHandlerId: " << fieldHandlerId << std::endl; + std::cout << "\tviewMode: " << viewMode << std::endl; + std::cout << "\tfileName: " << dataSHandler->uri << std::endl; + std::cout << "\tfiedName: " << fieldHandler->fieldname << std::endl; + + // Create a new presentation instance + TypeID newID = MEDPresentationManager_i::GenerateID(); + MEDPresentationVectorField * presentation = new MEDPresentationVectorField(fieldHandler, true); // on stack or on heap?? stack for now + _presentations.insert( std::pair(newID, presentation) ); + + presentation->generatePipeline(); + + return newID; +} + +TypeID +MEDPresentationManager_i::makeSlices(const MEDCALC::SlicesParameters& params) +{ + MEDCALC::MEDDataManager_ptr dataManager(MEDFactoryClient::getDataManager()); + + TypeID fieldHandlerId = params.fieldHandlerId; + MEDCALC::MEDPresentationViewMode viewMode = params.viewMode; + + MEDCALC::FieldHandler* fieldHandler = dataManager->getFieldHandler(fieldHandlerId); + MEDCALC::MeshHandler* meshHandler = dataManager->getMesh(fieldHandler->meshid); + MEDCALC::DatasourceHandler* dataSHandler = dataManager->getDatasourceHandlerFromID(meshHandler->sourceid); + + std::cout << "\tfieldHandlerId: " << fieldHandlerId << std::endl; + std::cout << "\tviewMode: " << viewMode << std::endl; + std::cout << "\tfileName: " << dataSHandler->uri << std::endl; + std::cout << "\tfiedName: " << fieldHandler->fieldname << std::endl; + + // Create a new presentation instance + TypeID newID = MEDPresentationManager_i::GenerateID(); + MEDPresentationSlices * presentation = new MEDPresentationSlices(fieldHandler, true); // on stack or on heap?? stack for now + _presentations.insert( std::pair(newID, presentation) ); + + presentation->generatePipeline(); + + return newID; +} + +TypeID +MEDPresentationManager_i::makeDeflectionShape(const MEDCALC::DeflectionShapeParameters& params) +{ + MEDCALC::MEDDataManager_ptr dataManager(MEDFactoryClient::getDataManager()); + + TypeID fieldHandlerId = params.fieldHandlerId; + MEDCALC::MEDPresentationViewMode viewMode = params.viewMode; + + MEDCALC::FieldHandler* fieldHandler = dataManager->getFieldHandler(fieldHandlerId); + MEDCALC::MeshHandler* meshHandler = dataManager->getMesh(fieldHandler->meshid); + MEDCALC::DatasourceHandler* dataSHandler = dataManager->getDatasourceHandlerFromID(meshHandler->sourceid); + + std::cout << "\tfieldHandlerId: " << fieldHandlerId << std::endl; + std::cout << "\tviewMode: " << viewMode << std::endl; + std::cout << "\tfileName: " << dataSHandler->uri << std::endl; + std::cout << "\tfiedName: " << fieldHandler->fieldname << std::endl; + + // Create a new presentation instance + TypeID newID = MEDPresentationManager_i::GenerateID(); + MEDPresentationDeflectionShape * presentation = new MEDPresentationDeflectionShape(fieldHandler, true); // on stack or on heap?? stack for now + _presentations.insert( std::pair(newID, presentation) ); + + presentation->generatePipeline(); + + return newID; +} + +TypeID +MEDPresentationManager_i::makePointSprite(const MEDCALC::PointSpriteParameters& params) +{ + MEDCALC::MEDDataManager_ptr dataManager(MEDFactoryClient::getDataManager()); + + TypeID fieldHandlerId = params.fieldHandlerId; + MEDCALC::MEDPresentationViewMode viewMode = params.viewMode; + + MEDCALC::FieldHandler* fieldHandler = dataManager->getFieldHandler(fieldHandlerId); + MEDCALC::MeshHandler* meshHandler = dataManager->getMesh(fieldHandler->meshid); + MEDCALC::DatasourceHandler* dataSHandler = dataManager->getDatasourceHandlerFromID(meshHandler->sourceid); + + std::cout << "\tfieldHandlerId: " << fieldHandlerId << std::endl; + std::cout << "\tviewMode: " << viewMode << std::endl; + std::cout << "\tfileName: " << dataSHandler->uri << std::endl; + std::cout << "\tfiedName: " << fieldHandler->fieldname << std::endl; + + // Create a new presentation instance + TypeID newID = MEDPresentationManager_i::GenerateID(); + MEDPresentationPointSprite * presentation = new MEDPresentationPointSprite(fieldHandler, true); // on stack or on heap?? stack for now + _presentations.insert( std::pair(newID, presentation) ); + + presentation->generatePipeline(); return newID; } diff --git a/src/MEDCalc/cmp/MEDPresentationManager_i.hxx b/src/MEDCalc/cmp/MEDPresentationManager_i.hxx index 00f87a134..61349eb79 100644 --- a/src/MEDCalc/cmp/MEDPresentationManager_i.hxx +++ b/src/MEDCalc/cmp/MEDPresentationManager_i.hxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D +// Copyright (C) 2007-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 @@ -43,6 +43,12 @@ class MEDPresentationManager_i: public POA_MEDCALC::MEDPresentationManager, static MEDPresentationManager_i* getInstance(); MEDCALC_EXPORT TypeID makeScalarMap(const MEDCALC::ScalarMapParameters&); + MEDCALC_EXPORT TypeID makeContour(const MEDCALC::ContourParameters&); + MEDCALC_EXPORT TypeID makeVectorField(const MEDCALC::VectorFieldParameters&); + MEDCALC_EXPORT TypeID makeSlices(const MEDCALC::SlicesParameters&); + MEDCALC_EXPORT TypeID makeDeflectionShape(const MEDCALC::DeflectionShapeParameters&); + MEDCALC_EXPORT TypeID makePointSprite(const MEDCALC::PointSpriteParameters&); + MEDCALC_EXPORT void setPresentationProperty(TypeID presentationID, const char * propName, const char * propValue); MEDCALC_EXPORT char* getPresentationProperty(TypeID presentationID, const char* propName); diff --git a/src/MEDCalc/cmp/MEDPresentationPointSprite.cxx b/src/MEDCalc/cmp/MEDPresentationPointSprite.cxx new file mode 100644 index 000000000..06d8847c0 --- /dev/null +++ b/src/MEDCalc/cmp/MEDPresentationPointSprite.cxx @@ -0,0 +1,7 @@ +#include "MEDPresentationPointSprite.hxx" +#include "MEDFactoryClient.hxx" + +void +MEDPresentationPointSprite::internalGeneratePipeline() +{ +} diff --git a/src/MEDCalc/cmp/MEDPresentationPointSprite.hxx b/src/MEDCalc/cmp/MEDPresentationPointSprite.hxx new file mode 100644 index 000000000..e84b8563e --- /dev/null +++ b/src/MEDCalc/cmp/MEDPresentationPointSprite.hxx @@ -0,0 +1,41 @@ +// 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_POINTSPRITE_HXX_ +#define SRC_MEDCALC_CMP_MEDPRESENTATION_POINTSPRITE_HXX_ + +#include "MEDCALC.hxx" +#include "MEDPresentation.hxx" + +class MEDCALC_EXPORT MEDPresentationPointSprite : public MEDPresentation +{ +public: + MEDPresentationPointSprite(MEDCALC::FieldHandler* fieldHdl, bool wireframe) : + MEDPresentation(fieldHdl, "MEDPresentationPointSprite"), + _isWireframe(wireframe) + {} + virtual ~MEDPresentationPointSprite() {} + +protected: + virtual void internalGeneratePipeline(); + +private: + bool _isWireframe; +}; + +#endif diff --git a/src/MEDCalc/cmp/MEDPresentationScalarMap.cxx b/src/MEDCalc/cmp/MEDPresentationScalarMap.cxx new file mode 100644 index 000000000..17caf4366 --- /dev/null +++ b/src/MEDCalc/cmp/MEDPresentationScalarMap.cxx @@ -0,0 +1,48 @@ +#include "MEDPresentationScalarMap.hxx" +#include "MEDFactoryClient.hxx" + +#include + +void +MEDPresentationScalarMap::internalGeneratePipeline() +{ + MEDCALC::MEDDataManager_ptr dataManager(MEDFactoryClient::getDataManager()); + + MEDCALC::MeshHandler* meshHandler = dataManager->getMesh(_fieldHandler->meshid); + MEDCALC::DatasourceHandler* dataSHandler = dataManager->getDatasourceHandlerFromID(meshHandler->sourceid); + + std::string fileName(dataSHandler->uri); + std::string fieldName(_fieldHandler->fieldname); + std::string fieldType = getFieldTypeString(); + + std::cout << "Generating pipeline for SCALAR MAP:" <createStandardAction(label,this,SLOT(OnVisualizeScalarMap()),icon); _salomeModule->addActionInPopupMenu(actionId, tr("LAB_VISUALIZE")); + label = tr("LAB_VISUALIZE_CONTOUR"); + icon = tr("ICO_DATASOURCE_VIEW"); + actionId = _salomeModule->createStandardAction(label,this,SLOT(OnVisualizeContour()),icon); + _salomeModule->addActionInPopupMenu(actionId, tr("LAB_VISUALIZE")); + + label = tr("LAB_VISUALIZE_VECTORFIELD"); + icon = tr("ICO_DATASOURCE_VIEW"); + actionId = _salomeModule->createStandardAction(label,this,SLOT(OnVisualizeVectorField()),icon); + _salomeModule->addActionInPopupMenu(actionId, tr("LAB_VISUALIZE")); + + label = tr("LAB_VISUALIZE_SLICES"); + icon = tr("ICO_DATASOURCE_VIEW"); + actionId = _salomeModule->createStandardAction(label,this,SLOT(OnVisualizeSlices()),icon); + _salomeModule->addActionInPopupMenu(actionId, tr("LAB_VISUALIZE")); + + label = tr("LAB_VISUALIZE_DEFLECTIONSHAPE"); + icon = tr("ICO_DATASOURCE_VIEW"); + actionId = _salomeModule->createStandardAction(label,this,SLOT(OnVisualizeDeflectionShape()),icon); + _salomeModule->addActionInPopupMenu(actionId, tr("LAB_VISUALIZE")); + + label = tr("LAB_VISUALIZE_POINTSPRITE"); + icon = tr("ICO_DATASOURCE_VIEW"); + actionId = _salomeModule->createStandardAction(label,this,SLOT(OnVisualizePointSprite()),icon); + _salomeModule->addActionInPopupMenu(actionId, tr("LAB_VISUALIZE")); + // Use in workspace label = tr("LAB_USE_IN_WORKSPACE"); icon = tr("ICO_DATASOURCE_USE"); @@ -338,6 +363,26 @@ void DatasourceController::OnVisualizeScalarMap() { this->visualize(DatasourceEvent::EVENT_VIEW_OBJECT_SCALAR_MAP); } +void DatasourceController::OnVisualizeContour() { + this->visualize(DatasourceEvent::EVENT_VIEW_OBJECT_CONTOUR); +} + +void DatasourceController::OnVisualizeVectorField() { + this->visualize(DatasourceEvent::EVENT_VIEW_OBJECT_VECTOR_FIELD); +} + +void DatasourceController::OnVisualizeSlices() { + this->visualize(DatasourceEvent::EVENT_VIEW_OBJECT_SLICES); +} + +void DatasourceController::OnVisualizeDeflectionShape() { + this->visualize(DatasourceEvent::EVENT_VIEW_OBJECT_DEFLECTION_SHAPE); +} + +void DatasourceController::OnVisualizePointSprite() { + this->visualize(DatasourceEvent::EVENT_VIEW_OBJECT_POINT_SPRITE); +} + void DatasourceController::OnUseInWorkspace() { // We need a studyEditor updated on the active study _studyEditor->updateActiveStudy(); diff --git a/src/MEDCalc/gui/DatasourceController.hxx b/src/MEDCalc/gui/DatasourceController.hxx index a6b2cf687..69b9f8cb6 100644 --- a/src/MEDCalc/gui/DatasourceController.hxx +++ b/src/MEDCalc/gui/DatasourceController.hxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D +// Copyright (C) 2007-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 @@ -54,7 +54,13 @@ typedef struct { EVENT_IMPORT_OBJECT, // Simply import the object in the workspace EVENT_USE_OBJECT, // Import in the workspace AND define a proxy // variable in the tui console to use it + // presentations + EVENT_VIEW_OBJECT_CONTOUR, + EVENT_VIEW_OBJECT_DEFLECTION_SHAPE, + EVENT_VIEW_OBJECT_POINT_SPRITE, EVENT_VIEW_OBJECT_SCALAR_MAP, + EVENT_VIEW_OBJECT_SLICES, + EVENT_VIEW_OBJECT_VECTOR_FIELD, // these ones forward actions to workspace (and then to python console) EVENT_ADD_DATASOURCE, EVENT_ADD_IMAGE_AS_DATASOURCE, @@ -95,6 +101,11 @@ protected slots: void OnAddImagesource(); void OnExpandField(); void OnVisualizeScalarMap(); + void OnVisualizeContour(); + void OnVisualizeVectorField(); + void OnVisualizeSlices(); + void OnVisualizeDeflectionShape(); + void OnVisualizePointSprite(); void OnUseInWorkspace(); void OnChangeUnderlyingMesh(); void OnInterpolateField(); diff --git a/src/MEDCalc/gui/MED_msg_en.ts b/src/MEDCalc/gui/MED_msg_en.ts index 3f12bcf9b..c3e7b4fbb 100644 --- a/src/MEDCalc/gui/MED_msg_en.ts +++ b/src/MEDCalc/gui/MED_msg_en.ts @@ -5,7 +5,27 @@ DatasourceController MEDPresentationScalarMap - Scalar Map + Scalar map + + + MEDPresentationContour + Contour + + + MEDPresentationVectorField + Vector field + + + MEDPresentationSlices + Slices + + + MEDPresentationDeflectionShape + Deflection shape + + + MEDPresentationPointSprite + Point sprite @@ -36,6 +56,26 @@ LAB_VISUALIZE_SCALARMAP Scalar map + + LAB_VISUALIZE_CONTOUR + Contour + + + LAB_VISUALIZE_VECTORFIELD + Vector field + + + LAB_VISUALIZE_SLICES + Slices + + + LAB_VISUALIZE_DEFLECTIONSHAPE + Deflection shape + + + LAB_VISUALIZE_POINTSPRITE + Point sprite + LAB_VISUALIZE diff --git a/src/MEDCalc/gui/MED_msg_fr.ts b/src/MEDCalc/gui/MED_msg_fr.ts index c8d917f5b..3a1595300 100644 --- a/src/MEDCalc/gui/MED_msg_fr.ts +++ b/src/MEDCalc/gui/MED_msg_fr.ts @@ -7,6 +7,26 @@ MEDPresentationScalarMap Carte scalaire + + MEDPresentationContour + Contour + + + MEDPresentationVectorField + Champ de vecteurs + + + MEDPresentationSlices + Coupes + + + MEDPresentationDeflectionShape + Déformée + + + MEDPresentationPointSprite + Point Sprite + LAB_ADD_DATA_SOURCE @@ -36,6 +56,26 @@ LAB_VISUALIZE_SCALARMAP Carte scalaire + + LAB_VISUALIZE_CONTOUR + Contour + + + LAB_VISUALIZE_VECTORFIELD + Champ de vecteurs + + + LAB_VISUALIZE_SLICES + Coupes + + + LAB_VISUALIZE_DEFLECTIONSHAPE + Déformée + + + LAB_VISUALIZE_POINTSPRITE + Point sprite + LAB_VISUALIZE diff --git a/src/MEDCalc/gui/WorkspaceController.cxx b/src/MEDCalc/gui/WorkspaceController.cxx index b4c6bd2db..643bd56f1 100644 --- a/src/MEDCalc/gui/WorkspaceController.cxx +++ b/src/MEDCalc/gui/WorkspaceController.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D +// Copyright (C) 2007-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 @@ -461,6 +461,16 @@ void WorkspaceController::_viewItemList(QStringList itemNameIdList) { _consoleDriver->exec(commands); } +QString +WorkspaceController::_getViewMode() { +#define stringify( name ) # name + + QString viewMode = stringify(MEDCALC::VIEW_MODE_NEW_LAYOUT); // :TODO: change this (get value from dedicated dialog) + viewMode.replace("::", "."); + + return viewMode; +} + /** * This slot can process the event coming from the * DatasourceController. The connection between the datasource signal @@ -506,16 +516,47 @@ void WorkspaceController::processDatasourceEvent(const DatasourceEvent * event) QCHARSTAR(event->objectalias)); } else if ( event->eventtype == DatasourceEvent::EVENT_VIEW_OBJECT_SCALAR_MAP ) { - QStringList commands; - -#define stringify( name ) # name - QString viewMode = stringify(MEDCALC::VIEW_MODE_NEW_LAYOUT); // :TODO: change this (get value from dedicated dialog) - viewMode.replace("::", "."); - + QString viewMode = _getViewMode(); MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler(); + QStringList commands; commands += QString("medcalc.MakeScalarMap(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode); _consoleDriver->exec(commands); } + else if ( event->eventtype == DatasourceEvent::EVENT_VIEW_OBJECT_CONTOUR ) { + QString viewMode = _getViewMode(); + MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler(); + QStringList commands; + commands += QString("medcalc.MakeContour(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode); + _consoleDriver->exec(commands); + } + else if ( event->eventtype == DatasourceEvent::EVENT_VIEW_OBJECT_VECTOR_FIELD ) { + QString viewMode = _getViewMode(); + MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler(); + QStringList commands; + commands += QString("medcalc.MakeVectorField(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode); + _consoleDriver->exec(commands); + } + else if ( event->eventtype == DatasourceEvent::EVENT_VIEW_OBJECT_SLICES ) { + QString viewMode = _getViewMode(); + MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler(); + QStringList commands; + commands += QString("medcalc.MakeSlices(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode); + _consoleDriver->exec(commands); + } + else if ( event->eventtype == DatasourceEvent::EVENT_VIEW_OBJECT_DEFLECTION_SHAPE ) { + QString viewMode = _getViewMode(); + MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler(); + QStringList commands; + commands += QString("medcalc.MakeDeflectionShape(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode); + _consoleDriver->exec(commands); + } + else if ( event->eventtype == DatasourceEvent::EVENT_VIEW_OBJECT_POINT_SPRITE ) { + QString viewMode = _getViewMode(); + MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler(); + QStringList commands; + commands += QString("medcalc.MakePointSprite(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode); + _consoleDriver->exec(commands); + } else if ( event->eventtype == DatasourceEvent::EVENT_ADD_DATASOURCE ) { QStringList commands; commands += QString("medcalc.LoadDataSource('%1')").arg(event->objectalias); diff --git a/src/MEDCalc/gui/WorkspaceController.hxx b/src/MEDCalc/gui/WorkspaceController.hxx index cfbcb8d21..969fab86a 100644 --- a/src/MEDCalc/gui/WorkspaceController.hxx +++ b/src/MEDCalc/gui/WorkspaceController.hxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D +// Copyright (C) 2007-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 @@ -75,6 +75,7 @@ private: void _saveItemList(QStringList itemNameIdList); void _removeItemList(QStringList itemNameIdList); void _viewItemList(QStringList itemNameIdList); + QString _getViewMode(); private: XmedConsoleDriver * _consoleDriver; diff --git a/src/MEDCalc/tui/__init__.py b/src/MEDCalc/tui/__init__.py index 49ba85461..3d1778606 100644 --- a/src/MEDCalc/tui/__init__.py +++ b/src/MEDCalc/tui/__init__.py @@ -1,4 +1,4 @@ -# Copyright (C) 2015 CEA/DEN, EDF R&D +# Copyright (C) 2015, 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 @@ -40,7 +40,7 @@ from medio import LoadImageAsDataSource # Presentations from medpresentation import MakeScalarMap -from medpresentation import MakeIsoSurface +from medpresentation import MakeContour from medpresentation import MakeVectorField from medpresentation import MakeSlices from medpresentation import MakeDeflectionShape diff --git a/src/MEDCalc/tui/medpresentation.py b/src/MEDCalc/tui/medpresentation.py index 0395826b5..a6177f730 100644 --- a/src/MEDCalc/tui/medpresentation.py +++ b/src/MEDCalc/tui/medpresentation.py @@ -1,4 +1,4 @@ -# Copyright (C) 2011-2015 CEA/DEN, EDF R&D +# Copyright (C) 2011-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 @@ -36,22 +36,37 @@ def MakeScalarMap(proxy, viewMode=MEDCALC.VIEW_MODE_REPLACE): notifyGui_addPresentation(proxy.id, presentation_id) # -def MakeIsoSurface(): +def MakeContour(proxy, viewMode=MEDCALC.VIEW_MODE_REPLACE): print "Not implemented yet" + #params = MEDCALC.ContourParameters(proxy.id, viewMode) + #presentation_id = __manager.makeContour(params) + #notifyGui_addPresentation(proxy.id, presentation_id) # -def MakeVectorField(): +def MakeVectorField(proxy, viewMode=MEDCALC.VIEW_MODE_REPLACE): print "Not implemented yet" + #params = MEDCALC.VectorFieldParameters(proxy.id, viewMode) + #presentation_id = __manager.makeVectorField(params) + #notifyGui_addPresentation(proxy.id, presentation_id) # -def MakeSlices(): +def MakeSlices(proxy, viewMode=MEDCALC.VIEW_MODE_REPLACE): print "Not implemented yet" + #params = MEDCALC.SlicesParameters(proxy.id, viewMode) + #presentation_id = __manager.makeSlices(params) + #notifyGui_addPresentation(proxy.id, presentation_id) # -def MakeDeflectionShape(): +def MakeDeflectionShape(proxy, viewMode=MEDCALC.VIEW_MODE_REPLACE): print "Not implemented yet" + #params = MEDCALC.DeflectionShapeParameters(proxy.id, viewMode) + #presentation_id = __manager.makeDeflectionShape(params) + #notifyGui_addPresentation(proxy.id, presentation_id) # -def MakePointSprite(): +def MakePointSprite(proxy, viewMode=MEDCALC.VIEW_MODE_REPLACE): print "Not implemented yet" + #params = MEDCALC.PointSpriteParameters(proxy.id, viewMode) + #presentation_id = __manager.makePointSprite(params) + #notifyGui_addPresentation(proxy.id, presentation_id) # -- 2.39.2