Commit 6b5f32846ef7f483a4bc5beb5f40239916d6ca1b

Authored by Benjamin Renard
2 parents c22a2dbd ee9a5027

Merge branch 'FER_7618' into amdadev

src/ParamOutputImpl/Plot/ColorAxis.cc
... ... @@ -36,3 +36,26 @@ ColorAxis::Format ColorAxis::getFormat()
36 36 return DigitalAxis::Format::SCIENTIFIC;
37 37 }
38 38  
  39 +void ColorAxis::writeContext(ContextFileWriter& writer) {
  40 + writer.startElement("axis");
  41 +
  42 + writer.addAttribute("id", _id.c_str());
  43 +
  44 + writer.addAttribute("logarithmic", (_scale == Scale::LOGARITHMIC) ? "true" : "false");
  45 +
  46 + std::ostringstream outMin;
  47 + outMin << std::setprecision(12) << getRange().getMin();
  48 + std::ostringstream outMax;
  49 + outMax << std::setprecision(12) << getRange().getMax();
  50 +
  51 + writer.addAttribute("min", outMin.str().c_str());
  52 + writer.addAttribute("max", outMax.str().c_str());
  53 + std::ostringstream colorListStr;
  54 +
  55 + for (unsigned int i(0); i < _colorsList.size(); ++i){
  56 + colorListStr << "[" << _colorsList[i][0] << "," << _colorsList[i][1] << "," << _colorsList[i][2] << "]|";
  57 + }
  58 + writer.addAttribute("colorsList",colorListStr.str().c_str());
  59 +
  60 + writer.endElement();
  61 +}
39 62 \ No newline at end of file
... ...
src/ParamOutputImpl/Plot/ColorAxis.hh
... ... @@ -48,10 +48,27 @@ public:
48 48 return _maxValColor;
49 49 }
50 50  
  51 + // Getter function to retrieve the colorsList
  52 + const std::vector<std::array<int, 3>>& getColorsList() const {
  53 + return _colorsList;
  54 + }
  55 +
  56 + // Setter function to set the colorsList
  57 + void setColorsList(const std::vector<std::array<int, 3>>& newList) {
  58 + _colorsList = newList;
  59 + }
  60 +
  61 + /**
  62 + * @brief Write axis context
  63 + */
  64 + void writeContext(ContextFileWriter& writer);
  65 +
51 66 private :
52 67 Color _minValColor;
53 68  
54 69 Color _maxValColor;
  70 +
  71 + std::vector<std::array<int, 3>> _colorsList;
55 72 };
56 73  
57 74 } /* namespace plot */
... ...
src/ParamOutputImpl/Plot/PanelPlotOutput.cc
... ... @@ -1120,6 +1120,17 @@ namespace plot
1120 1120 _pls->spal1(
1121 1121 ColormapManager::getInstance().getColorAxis(pZAxis->_color._colorMapIndex).c_str(), true);
1122 1122  
  1123 +
  1124 + PLStream *p_pls = NULL;
  1125 + plgpls(&p_pls);
  1126 +
  1127 + std::vector<std::array<int,3>> colorsList;
  1128 + for (int i = 0; i < p_pls->ncol1; i++ ) {
  1129 + colorsList.push_back({(int)p_pls->cmap1[i].r ,(int)p_pls->cmap1[i].g,(int)p_pls->cmap1[i].b});
  1130 + }
  1131 + // Get colored axis
  1132 + boost::shared_ptr<ColorAxis> lZAxis = _panel->getColorAxis();
  1133 + lZAxis->setColorsList(colorsList);
1123 1134 // set color bar and legend position
1124 1135 PLINT position = PL_POSITION_OUTSIDE | PL_POSITION_VIEWPORT;
1125 1136 PLINT label_opts[1];
... ... @@ -2366,7 +2377,11 @@ namespace plot
2366 2377 writer.addAttribute("width", std::to_string(_plotAreaBounds._width * std::get<0>(_panel->_page->getSize())).c_str());
2367 2378 writer.addAttribute("height", std::to_string(_plotAreaBounds._height * std::get<1>(_panel->_page->getSize())).c_str());
2368 2379 }
2369   -
  2380 + std::ostringstream plotAreaBGColorStr;
  2381 + plotAreaBGColorStr << "[" << _panel->_plotAreaBackgroundColor._red << ","
  2382 + << _panel->_plotAreaBackgroundColor._green << ","
  2383 + << _panel->_plotAreaBackgroundColor._blue << "]";
  2384 + writer.addAttribute("plotAreaBackgroundColor", plotAreaBGColorStr.str().c_str());
2370 2385 writer.addAttribute("hasSpectro", hasSpectro ? "true" : "false");
2371 2386 writer.addAttribute("hasSauvaud", hasSauvaud ? "true" : "false");
2372 2387  
... ... @@ -2377,8 +2392,12 @@ namespace plot
2377 2392 if (lAxis == nullptr)
2378 2393 continue;
2379 2394  
2380   - if (lAxis->_visible && lAxis->_used)
2381   - lAxis->writeContext(writer);
  2395 + if (lAxis->_visible && lAxis->_used){
  2396 + if(lAxis->isZAxis())
  2397 + _panel->getColorAxis()->writeContext(writer);
  2398 + else
  2399 + lAxis->writeContext(writer);
  2400 + }
2382 2401 }
2383 2402  
2384 2403 writer.endElement();
... ...