1 // Copyright (C) 2016 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef _MED_PRESENTATION_TXX_
21 #define _MED_PRESENTATION_TXX_
23 #include "MEDPyLockWrapper.hxx"
25 #include <SALOME_KernelServices.hxx>
27 template<typename PresentationType, typename PresentationParameters>
29 MEDPresentation::updatePipeline(const PresentationParameters& params)
31 static_cast<PresentationType*>(this)->updatePipeline(params);
34 template<typename PresentationType, typename PresentationParameters>
36 MEDPresentation::getParameters(PresentationParameters& params) const
38 const PresentationType * p = static_cast<const PresentationType*>(this);
39 p->getParameters(params);
42 template<typename PresentationType, typename PresentationParameters>
44 MEDPresentation::setParameters(const PresentationParameters& params)
46 PresentationType * p = static_cast<PresentationType*>(this);
47 p->setParameters(params);
52 * Update the ParaVis pipeline so that the given component appears on screen.
53 * Blank means "Euclidean norm"
54 * The property PROP_SELECTED_COMPONENT holding the corresponding index selected is also updated (help for the GUI).
56 template<typename PresentationType, typename PresentationParameters>
58 MEDPresentation::updateComponent(const std::string& newCompo)
60 PresentationType * p = static_cast<PresentationType*>(this);
62 PresentationParameters params;
63 p->getParameters(params);
64 params.displayedComponent = newCompo.c_str();
65 p->setParameters(params);
69 int nbCompo = getIntProperty(MEDPresentation::PROP_NB_COMPONENTS);
71 for (int i=0; i < nbCompo; i++)
73 std::ostringstream oss_p;
74 oss_p << MEDPresentation::PROP_COMPONENT << i;
75 std::string compo = getStringProperty(oss_p.str());
76 if (compo == newCompo)
82 if (idx == -1 && newCompo != "")
84 std::string msg("updateComponent(): internal error - field component not found!");
85 throw KERNEL::createSalomeException(msg.c_str());
87 setIntProperty(MEDPresentation::PROP_SELECTED_COMPONENT, idx+1); // +1 because idx=0 means Euclidean norm
88 p->_selectedComponentIndex = idx;
90 // Update ParaView pipeline:
92 MEDPyLockWrapper lock;
94 std::ostringstream oss;
95 std::string cmd = getComponentSelectionCommand();
96 pushAndExecPyLine(cmd);
97 pushAndExecPyLine("pvs.Render();");
102 template<typename PresentationType, typename PresentationParameters>
104 MEDPresentation::updateColorMap(MEDCALC::MEDPresentationColorMap colorMap)
106 PresentationType * p = static_cast<PresentationType*>(this);
108 PresentationParameters params;
109 p->getParameters(params);
110 params.colorMap = colorMap;
111 p->setParameters(params);
113 p->_colorMap = colorMap;
116 setIntProperty(MEDPresentation::PROP_COLOR_MAP, colorMap);
118 // Update the pipeline:
120 MEDPyLockWrapper lock;
121 std::string cmd = getColorMapCommand();
122 pushAndExecPyLine(cmd);
123 pushAndExecPyLine("pvs.Render();");
127 template<typename PresentationType, typename PresentationParameters>
129 MEDPresentation::updateScalarBarRange(MEDCALC::MEDPresentationScalarBarRange sbRange)
131 PresentationType * p = static_cast<PresentationType*>(this);
133 PresentationParameters params;
134 p->getParameters(params);
135 params.scalarBarRange = sbRange;
136 p->setParameters(params);
138 p->_sbRange = sbRange;
141 setIntProperty(MEDPresentation::PROP_SCALAR_BAR_RANGE, sbRange);
143 // Update the pipeline:
145 MEDPyLockWrapper lock;
146 std::string cmd = getRescaleCommand();
147 pushAndExecPyLine(cmd);
148 pushAndExecPyLine("pvs.Render();");
153 #endif // _MED_PRESENTATION_TXX_