Salome HOME
Better timestamp management to synchronize the timestamp of the view and the field id
[modules/med.git] / src / MEDCalc / cmp / MEDPresentationDeflectionShape.cxx
index fdb5d5c3ac34bb467228e02b0d810ff1dbf7dfd6..b3a81b05c7bab2363944703deb7950749e526b48 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2016  CEA/DEN, EDF R&D
+// Copyright (C) 2016-2020  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,6 +36,13 @@ MEDPresentationDeflectionShape::MEDPresentationDeflectionShape(const MEDCALC::De
 {
 }
 
+void
+MEDPresentationDeflectionShape::initFieldMeshInfos()
+{
+  MEDPresentation::initFieldMeshInfos();
+  _colorByType = "POINTS";
+}
+
 void
 MEDPresentationDeflectionShape::autoScale()
 {
@@ -54,18 +61,21 @@ MEDPresentationDeflectionShape::internalGeneratePipeline()
 
   MEDPyLockWrapper lock;
 
-  setOrCreateRenderView();
   createSource();
+  setTimestamp();
 
   // Populate internal array of available components:
   fillAvailableFieldComponents();
-  if (getIntProperty(MEDPresentation::PROP_NB_COMPONENTS) <= 1)
+  int nbCompo = getIntProperty(MEDPresentation::PROP_NB_COMPONENTS);
+  if (nbCompo <= 1)
     {
       const char * msg = "Deflection shape presentation does not work for scalar field!"; // this message will appear in GUI too
       STDLOG(msg);
       throw KERNEL::createSalomeException(msg);
     }
 
+  setOrCreateRenderView(); // needs to be after the exception above otherwise previous elements in the view will be hidden.
+
   // Warp needs point data:
   applyCellToPointIfNeeded();
 
@@ -75,10 +85,11 @@ MEDPresentationDeflectionShape::internalGeneratePipeline()
 
   showObject(); // to be done first so that the scale factor computation properly works
 
-  oss << _objVar << ".Vectors = ['POINTS', '" << _fieldName << "'];";
+  std::string fieldName = nbCompo <= 2 ? _fieldName + "_Vector" : _fieldName;
+  oss << _objVar << ".Vectors = ['POINTS', '" << fieldName << "'];";
   pushAndExecPyLine(oss.str()); oss.str("");
 
-  colorBy("POINTS");
+  colorBy();    // see initFieldInfo() - necessarily POINTS
   showScalarBar();
   selectColorMap();
   rescaleTransferFunction();