X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCalc%2Fcmp%2FMEDPresentation.hxx;h=07f85bb167a34fbbb39de63eab99480a587683e3;hb=bb9014c6fe3e097edd7009a00dc56f514c680365;hp=a47d1b2ff0648bfc74abff834eb5ef5a8fe0f3b7;hpb=4f9f7dab21a26bad39e3e2383dc59e4028c350d3;p=modules%2Fmed.git diff --git a/src/MEDCalc/cmp/MEDPresentation.hxx b/src/MEDCalc/cmp/MEDPresentation.hxx index a47d1b2ff..07f85bb16 100644 --- a/src/MEDCalc/cmp/MEDPresentation.hxx +++ b/src/MEDCalc/cmp/MEDPresentation.hxx @@ -1,4 +1,4 @@ -// Copyright (C) 2011-2016 CEA/DEN, EDF R&D +// Copyright (C) 2011-2022 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 @@ -16,6 +16,7 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + // Authors: A Bruneton (CEA), C Aguerre (EdF) #ifndef SRC_MEDCALC_CMP_MEDPRESENTATION_HXX_ @@ -33,6 +34,36 @@ #include #include +struct ComponentThresold { + + ComponentThresold() { + _thresholdVar = ""; + _thresholdDispVar = ""; + _thresholdLutVar = ""; + _thresholdInitialized = false; + _active = false; + } + + ///! ParaView Threshold filter variable to hide data outside custom range in Python scripting + std::string _thresholdVar; + ///! ParaView Threshold display variable to hide data outside custom range in Python scripting + std::string _thresholdDispVar; + ///! ParaView Threshold LUT variable in the Python scripting commands + std::string _thresholdLutVar; + + ///! Initialization flag + bool _thresholdInitialized; + ///! Active flag + bool _active; + + void clear() { + _thresholdInitialized = false; + _active = false; + } +}; + +typedef std::vector PresentationThresolds; + class MEDCALC_EXPORT MEDPresentation { friend class MEDPresentationManager_i; @@ -40,14 +71,22 @@ class MEDCALC_EXPORT MEDPresentation public: typedef ::CORBA::Long TypeID; + virtual void initFieldMeshInfos(); + virtual ~MEDPresentation(); - static const std::string PROP_NAME; // name of the presentation - static const std::string PROP_NB_COMPONENTS; // number of field components - static const std::string PROP_SELECTED_COMPONENT; // index of the selected component - 0 means Euclidean norm - static const std::string PROP_COMPONENT; // string prefix for all properties storing component names - static const std::string PROP_COLOR_MAP; // color map - TODO: arch fix - should be in params only - static const std::string PROP_SCALAR_BAR_RANGE; // scalar bar range - TODO: arch fix - should be in params only + static const std::string PROP_NAME; // name of the presentation + static const std::string PROP_NB_COMPONENTS; // number of field components + static const std::string PROP_SELECTED_COMPONENT; // index of the selected component - 0 means Euclidean norm + static const std::string PROP_COMPONENT; // string prefix for all properties storing component names + static const std::string PROP_COLOR_MAP; // color map - TODO: arch fix - should be in params only + static const std::string PROP_SCALAR_BAR_RANGE; // scalar bar range - TODO: arch fix - should be in params only + static const std::string PROP_VISIBILITY; // presentation visibility + static const std::string PROP_SCALAR_BAR_VISIBILITY; // scalar bar visiblity + static const std::string PROP_SCALAR_BAR_MIN_VALUE; // min value of scalar bar range + static const std::string PROP_SCALAR_BAR_MAX_VALUE; // max value of scalar bar range + static const std::string PROP_HIDE_DATA_OUTSIDE_CUSTOM_RANGE; // Hide data outside custom range + virtual void setStringProperty(const std::string& propName, const std::string& propValue); const std::string getStringProperty(const std::string& propName) const; @@ -55,52 +94,98 @@ public: virtual void setIntProperty(const std::string& propName, const int propValue); int getIntProperty(const std::string& propName) const; - void activateView(); // non const because generates a Python trace + virtual void setDoubleProperty(const std::string& propName, const double propValue); + double getDoubleProperty(const std::string& propName) const; + + // returns True if the view was still alive, False if it must have been recreated + // because the user closed it. + virtual bool activateView(); + virtual void recreateViewSetup(); void dumpIntProperties() const; void dumpStringProperties() const; + void dumpDoubleProperties() const; std::string paravisDump() const; long getPyViewID() const { return _renderViewPyId; } void setPyViewID(long id) { _renderViewPyId = id; } + static std::string toScriptCellType(const std::string&); + protected: typedef std::pair PyObjectId; static int GeneratePythonId(); - MEDPresentation(MEDPresentation::TypeID fieldHandlerId, const std::string& name, - const MEDCALC::MEDPresentationViewMode viewMode, - const MEDCALC::MEDPresentationColorMap colorMap, - const MEDCALC::MEDPresentationScalarBarRange sbRange); - std::string getRenderViewCommand() const; + MEDPresentation(MEDPresentation::TypeID handlerId, const std::string& name, + const MEDCALC::ViewModeType viewMode, + const MEDCALC::ColorMapType colorMap, + const MEDCALC::ScalarBarRangeType sbRange); std::string getRenderViewVar() const; - std::string getResetCameraCommand() const; - std::string getComponentSelectionCommand() const; - std::string getColorMapCommand() const; - std::string getRescaleCommand() const; + // The most common elements of the ParaView pipeline: + void setOrCreateRenderView(); + void createSource(); + void setTimestamp(); + void selectFieldComponent(); + void virtual showObject(); + void virtual hideObject(); + void colorBy(); + virtual void showScalarBar(); + virtual void hideScalarBar(); + void scalarBarVisibility(); + void rescaleTransferFunction(); + void selectColorMap(const bool updateFieldComponent=true); + virtual void scalarBarTitle(); + void resetCameraAndRender(); + virtual void visibility(); + void threshold(); + void thresholdPresentation(); + void unThresholdPresentation(); + void thresholdValues(); + virtual void additionalThresholdActions() {}; + virtual std::string additionalThresholdVisualizationActions() { return ""; }; + virtual std::string additionalThresholdInitializationActions() { return ""; }; + virtual void additionalUnThresholdActions() {}; + virtual std::string getFieldName() const; + virtual std::string getThresholdFieldName() const; + + std::string getScriptCellType() const; + bool isThresoldActive() const; virtual void internalGeneratePipeline(); + virtual void internalGenerateThreshold(); + const std::string& getDispVar(); + const std::string& getLutVar(); PyObject* getPythonObjectFromMain(const char* var) const; -// void pushPyObjects(PyObjectId obj, PyObjectId disp); void execPyLine(const std::string & lin); void pushAndExecPyLine(const std::string & lin); - MEDPresentation::TypeID getID() const { return _fieldHandlerId; } + MEDPresentation::TypeID getID() const { return _handlerId; } void fillAvailableFieldComponents(); + void applyCellToPointIfNeeded(); + void extractFileName(const std::string& name); +// void convertTo3DVectorField(); -// virtual MEDCALC::MEDPresentationViewMode getViewMode() = 0; + virtual MEDCALC::PresentationVisibility presentationStateInActiveView(); template void updateComponent(const std::string& newCompo); template - void updateColorMap(MEDCALC::MEDPresentationColorMap colorMap); + void updateColorMap(MEDCALC::ColorMapType colorMap); + + template + void updateScalarBarRange(MEDCALC::ScalarBarRangeType sbRange, + bool hideDataoutsideCustomRange, + double minValue, double maxValue); + + template + void updateVisibility(const bool theVisibility); template - void updateScalarBarRange(MEDCALC::MEDPresentationScalarBarRange sbRange); + void updateScalarBarVisibility(const bool theVisibility); template void getParameters(PresentationParameters& params) const; @@ -108,8 +193,12 @@ protected: template void setParameters(const PresentationParameters& params); + int getThresholdIndex() const; + + void deleteThresholds(); + private: - std::string getFieldTypeString(MEDCoupling::TypeOfField fieldType) const; + std::string getPVFieldTypeString(MEDCoupling::TypeOfField fieldType) const; // The following functions are reserved to friend class MEDPresentationManager void generatePipeline(); @@ -118,16 +207,29 @@ private: void updatePipeline(const PresentationParameters& params); protected: + std::string _meshName; std::string _fileName; std::string _fieldName; - std::string _fieldType; - MEDPresentation::TypeID _fieldHandlerId; + ///! MEDCoupling field type (ON_NODES, ON_CELLS, ON_GAUSS_PT, ON_GAUSS_NE + MEDCoupling::TypeOfField _mcFieldType; + ///! ParaView field type: "CELLS" or "POINTS" + std::string _pvFieldType; + ///! ParaView field type: "CELLS" or "POINTS" used in the ColorBy method. Not necessarily equal to _pvFieldType. + std::string _colorByType; + + MEDPresentation::TypeID _handlerId; // either a field or a mesh id (a field ID though, most of the time) int _selectedComponentIndex; - MEDCALC::MEDPresentationViewMode _viewMode; - MEDCALC::MEDPresentationColorMap _colorMap; - MEDCALC::MEDPresentationScalarBarRange _sbRange; + int _nbComponents; + int _nbComponentsInThresholdInput; + MEDCALC::ViewModeType _viewMode; + MEDCALC::ColorMapType _colorMap; + MEDCALC::ScalarBarRangeType _sbRange; + bool _presentationVisibility; + bool _scalarBarVisibility; + bool _hideDataOutsideCustomRange; + double _scalarBarRangeArray[2]; ///! Identifier (in the Python dump) of the render view int _renderViewPyId; @@ -139,17 +241,21 @@ protected: std::string _dispVar; ///! ParaView LUT variable in the Python scripting commands std::string _lutVar; + ///! ParaView variable in Python holding the data range + std::string _rangeVar; + ///! Prorgammable variable in the Python scripting commands + std::string _programmableVar; + bool _programmableInitialized; -private: - ///! Pipeline elements -// std::vector _pipeline; + //Thresolds + PresentationThresolds _presentationThresolds; - ///! Corresponding display object, if any: -// std::vector _display; +private: ///! Presentation properties std::map _propertiesStr; std::map _propertiesInt; + std::map _propertiesDouble; std::vector _pythonCmds;