Commit ece01261fabc0069c7ec5d2c1440aec7a29bdf01

Authored by Benjamin Renard
2 parents 0ed02826 9f851085

Merge branch 'amdadev' into test-merge

src/Info/ParamTable.cc
... ... @@ -760,6 +760,15 @@ namespace AMDA {
760 760 }
761 761 return res;
762 762 }
  763 + bool ParamTable::isInvertedOrder(ParameterManager *parameterManager){
  764 + if(this->getSize(parameterManager) <2)
  765 + return true;
  766 +
  767 + double fist_ = getBound(parameterManager, 0).min;
  768 + double second_ = getBound(parameterManager, 1).min;
  769 +
  770 + return (fist_ > second_);
  771 + }
763 772  
764 773 } /* namespace Info */
765 774 } /* namespace AMDA */
... ...
src/Info/ParamTable.hh
... ... @@ -82,6 +82,8 @@ namespace AMDA {
82 82 void addSemiVariableTableInfo(ParameterManager *parameterManager, int dim, std::string paramId, std::string key, std::vector<std::pair<std::string, std::string>>&infoMap);
83 83  
84 84 void addRelatedParams(ParameterManager *parameterManager, std::string paramId, std::list<std::string>relatedParams);
  85 +
  86 + bool isInvertedOrder(ParameterManager *parameterManager);
85 87  
86 88 protected:
87 89 /** logger of paramTable */
... ...
src/ParamOutputImpl/Plot/PanelPlotOutput.cc
... ... @@ -1491,97 +1491,6 @@ void PanelPlotOutput::drawMatrix(MatrixGrid&amp; matrixGrid, double minDataVal, doub
1491 1491 restoreColor(_pls, lInitialColor, _panel->_page->_mode);
1492 1492 }
1493 1493  
1494   -/*
1495   - * @brief Draw a sauvaud
1496   -
1497   -void PanelPlotOutput::draw2DMatrix(SauvaudGrid& sauvaudGrid, double minDataVal, double maxDataVal,
1498   - Color minValColor, Color maxValColor, int colorMapIndex, bool useLog0AsMin)
1499   -{
1500   - //set color map
1501   - _pls->spal1(
1502   - ColormapManager::getInstance().getColorAxis(colorMapIndex).c_str(), true);
1503   -
1504   - Color lInitialColor;
1505   - _pls->gcol0(0, lInitialColor._red, lInitialColor._green, lInitialColor._blue);
1506   -
1507   - //plot sauvaud
1508   - PLFLT x[4], y[4];
1509   - PLFLT col;
1510   -
1511   - for ( auto part : sauvaudGrid )
1512   - {
1513   - x[0] = part.x[0];
1514   - x[1] = part.x[1];
1515   - x[2] = x[1];
1516   - x[3] = x[0];
1517   -
1518   - y[0] = part.y[0];
1519   - y[1] = y[0];
1520   - y[2] = part.y[1];
1521   - y[3] = y[2];
1522   -
1523   - if (isNAN(part.value))
1524   - continue;
1525   -
1526   - if (!part.isColorIndex)
1527   - {
1528   - if (!getColoredValue(part.value, minDataVal, maxDataVal, useLog0AsMin, col))
1529   - continue;
1530   - }
1531   - else
1532   - {
1533   - Color dataValueColor(colorMapIndex, (int)part.value);
1534   - restoreColor(_pls, dataValueColor, _panel->_page->_mode);
1535   - _pls->fill(4, x, y);
1536   - _pls->spal1(ColormapManager::getInstance().getColorAxis(colorMapIndex).c_str(), true);
1537   - continue;
1538   - }
1539   -
1540   - if(col <= 0.)
1541   - {
1542   - if (minValColor.isSet())
1543   - {
1544   - restoreColor(_pls, minValColor, _panel->_page->_mode);
1545   - _pls->fill(4, x, y);
1546   - _pls->spal1(ColormapManager::getInstance().getColorAxis(colorMapIndex).c_str(), true);
1547   - }
1548   - else
1549   - {
1550   - _pls->col1(0);
1551   - _pls->fill(4, x, y);
1552   - }
1553   - }
1554   - else if (col>=1.)
1555   - {
1556   - if (maxValColor.isSet())
1557   - {
1558   - restoreColor(_pls, maxValColor, _panel->_page->_mode);
1559   - _pls->fill(4, x, y);
1560   - _pls->spal1(ColormapManager::getInstance().getColorAxis(colorMapIndex).c_str(), true);
1561   - }
1562   - else
1563   - {
1564   - _pls->col1(1);
1565   - _pls->fill(4, x, y);
1566   - }
1567   - }
1568   - else
1569   - {
1570   - _pls->col1(col);
1571   - _pls->fill(4, x, y);
1572   - }
1573   - }
1574   -
1575   - //restore to initial color context
1576   - _pls->spal1(
1577   - ColormapManager::getInstance().get(_panel->_page->_mode,
1578   - ColormapManager::DEFAULT_COLORMAP_1).c_str(), true);
1579   - _pls->scol0(0, lInitialColor._red, lInitialColor._green, lInitialColor._blue);
1580   -
1581   - // Restore color.
1582   - restoreColor(_pls, lInitialColor, _panel->_page->_mode);
1583   -}*/
1584   -
1585 1494 /**
1586 1495 * Draw errors segments
1587 1496 */
... ... @@ -2513,17 +2422,17 @@ void PanelPlotOutput::drawSauvaud(double /*startDate*/, double /*stopDate*/, std
2513 2422 Font font_(label.getFont());
2514 2423 int size_ = font_.getSize();
2515 2424 if( font_.getSize() == 0){
2516   - int size_ = std::round(314.5*width-2.7);
  2425 + size_ = std::round(314.5*width-2.7);
2517 2426 size_ = std::max(size_,2);
2518 2427 size_ = std::min(size_,8);
2519   - font_.setSize(std::round(size_));
  2428 + font_.setSize(size_);
2520 2429 label.setFont(font_);
2521 2430 lYAxis->_legend.setLabel(label);
2522 2431 }
2523 2432 bool changed = false;
2524 2433  
2525 2434  
2526   - // Draw legend.
  2435 + // Draw legend for the last spectro.
2527 2436 if(subIndex ==subsNumber -1){
2528 2437 lYAxis->setShowTickMark(true);
2529 2438  
... ... @@ -2535,9 +2444,8 @@ void PanelPlotOutput::drawSauvaud(double /*startDate*/, double /*stopDate*/, std
2535 2444 label._text = opositeLegend;
2536 2445 changed = true;
2537 2446 }
2538   - if(lYAxis->_scale ==Axis::Scale::LOGARITHMIC ){
  2447 + if(lYAxis->_scale ==Axis::Scale::LOGARITHMIC && font_.getSize()>3){
2539 2448 font_.setSize(3);
2540   - label.setFont(font_);
2541 2449 changed = true;
2542 2450 }
2543 2451 lYAxis->_legend.clearLabels();
... ...
src/ParamOutputImpl/Plot/SauvaudProperties.hh
... ... @@ -55,11 +55,21 @@ namespace plot {
55 55 _rightDim = dim;
56 56 }
57 57  
  58 + int getLastIndex(){
  59 + return _lastIndex;
  60 + }
  61 +
  62 + void setLastIndex(int lastIndex){
  63 + _lastIndex= lastIndex;
  64 + }
  65 +
58 66 private:
59 67  
60 68 /***/
61 69 int _rightDim;
62 70  
  71 + int _lastIndex;
  72 +
63 73 };
64 74  
65 75  
... ...
src/ParamOutputImpl/Plot/Time/TimePlot.cc
... ... @@ -505,26 +505,17 @@ namespace plot
505 505  
506 506 ParameterSPtr p = _parameterManager.getParameter(param._originalParamId);
507 507 int rightParameterDimension;
508   - int leftParameterDimension;
509 508 int rightDim = sauvaudPropertiesPtr->getRightDim();
510   - int leftDim = (rightDim ==0) ? 1 :0;
511 509 if (rightDim == 0){
512 510 rightParameterDimension = (*_pParameterValues)[sauvaudPropertiesPtr->getParamId()].getDim1Size();
513   - leftParameterDimension = (*_pParameterValues)[sauvaudPropertiesPtr->getParamId()].getDim2Size();
514 511 }else{
515 512 rightParameterDimension = (*_pParameterValues)[sauvaudPropertiesPtr->getParamId()].getDim2Size();
516   - leftParameterDimension = (*_pParameterValues)[sauvaudPropertiesPtr->getParamId()].getDim1Size();
517 513 }
518 514 //set Y axis range
519 515  
520 516  
521 517 AMDA::Info::ParamInfoSPtr paramInfo = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(p->getInfoId());
522 518  
523   - if(_panel->getTitle()->_text.empty()){
524   - std::string title_ = paramInfo->getShortName().empty() ? paramInfo->getName(): paramInfo->getShortName();
525   - _panel->setTitleText(title_.c_str());
526   - }
527   -
528 519 // configure right axis
529 520 Range lYAxisRequestRange = lYAxis->Axis::getRequestedRange();
530 521 Range lYAxisRange = lYAxis->Axis::getRange();
... ... @@ -1381,7 +1372,8 @@ namespace plot
1381 1372 int rightDim = pSauvaud.getRightDim();
1382 1373 int leftDim = (rightDim ==0) ? 1 :0;
1383 1374 int rightDimSize =-1;
1384   - int leftDimSize =-1;
  1375 + int leftDimSize =-1;
  1376 + bool invertedTable = false;
1385 1377 if(rightDim ==0){
1386 1378 rightDimSize = data.getDim1Size();
1387 1379 leftDimSize = data.getDim2Size() ;
... ... @@ -1399,8 +1391,9 @@ namespace plot
1399 1391 boost::shared_ptr<AMDA::Info::ParamTable> leftTableSPtr;
1400 1392 AMDA::Info::ParamInfoSPtr paramInfo = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(p->getInfoId());
1401 1393 if (paramInfo != nullptr){
1402   - rightTableSPtr = paramInfo->getTable(rightDim);
1403   - leftTableSPtr = paramInfo->getTable(leftDim);
  1394 + rightTableSPtr = paramInfo->getTable(rightDim);
  1395 + leftTableSPtr = paramInfo->getTable(leftDim);
  1396 + invertedTable = leftTableSPtr->isInvertedOrder(&_parameterManager);
1404 1397 }
1405 1398  
1406 1399 //get axis
... ... @@ -1414,22 +1407,15 @@ namespace plot
1414 1407 data.getIntervalBounds(startDate, stopDate, startIndex, nbValues);
1415 1408  
1416 1409 LOG4CXX_DEBUG(gLogger, "TimePlot::drawSauvaud - Build data grid");
  1410 +
  1411 + int plotIndex;
1417 1412  
1418   - for(int spectroIndex =0; spectroIndex <= leftDimSize; spectroIndex ++){
  1413 + for(int spectroIndex =0; spectroIndex < leftDimSize; spectroIndex ++){
1419 1414 // This will configure window, draw axes (if needed) and legend of axes.
1420 1415  
  1416 + plotIndex = (!invertedTable)? spectroIndex : leftDimSize-spectroIndex-1;
  1417 +
1421 1418 // set left label for each sub-plot label table value or index
1422   - if(spectroIndex == leftDimSize){
1423   - std::string plotLabel = " "+leftTableSPtr ->getName(&_parameterManager);
1424   - plotLabel = plotLabel + "\n ["+leftTableSPtr ->getUnits(&_parameterManager)+"]";
1425   -
1426   - Label label(lYAxis->_legend.getFont(), lYAxis->_legend.getColor());
1427   - label._text = plotLabel;
1428   - lYAxis->_legend.setLabel(label);
1429   -
1430   - PanelPlotOutput::drawSauvaud(startDate, stopDate, pParamId, pSauvaud, spectroIndex , leftDimSize, "");
1431   - break;
1432   - }
1433 1419 std::string plotLabel = std::to_string(spectroIndex);
1434 1420 if ((leftTableSPtr == nullptr) || !leftTableSPtr->isVariable(&_parameterManager))
1435 1421 {
... ... @@ -1472,9 +1458,9 @@ namespace plot
1472 1458 if(spectroIndex == leftDimSize -1){
1473 1459 opositeLabel = " "+rightTableSPtr ->getName(&_parameterManager);
1474 1460 opositeLabel = opositeLabel + "\n ["+rightTableSPtr ->getUnits(&_parameterManager)+"]";
1475   - PanelPlotOutput::drawSauvaud(startDate, stopDate, pParamId, pSauvaud, spectroIndex , leftDimSize, opositeLabel);
  1461 + PanelPlotOutput::drawSauvaud(startDate, stopDate, pParamId, pSauvaud,plotIndex , leftDimSize, opositeLabel);
1476 1462 }else{
1477   - PanelPlotOutput::drawSauvaud(startDate, stopDate, pParamId, pSauvaud, spectroIndex , leftDimSize, "");
  1463 + PanelPlotOutput::drawSauvaud(startDate, stopDate, pParamId, pSauvaud,plotIndex , leftDimSize, "");
1478 1464 }
1479 1465  
1480 1466  
... ... @@ -1623,6 +1609,15 @@ namespace plot
1623 1609 }
1624 1610 }
1625 1611 }
  1612 + // draw legend
  1613 + std::string plotLabel = " "+leftTableSPtr ->getName(&_parameterManager);
  1614 + plotLabel = plotLabel + "\n ["+leftTableSPtr ->getUnits(&_parameterManager)+"]";
  1615 +
  1616 + Label label(lYAxis->_legend.getFont(), lYAxis->_legend.getColor());
  1617 + label._text = plotLabel;
  1618 + lYAxis->_legend.setLabel(label);
  1619 +
  1620 + PanelPlotOutput::drawSauvaud(startDate, stopDate, pParamId, pSauvaud, leftDimSize, leftDimSize, "");
1626 1621 }
1627 1622  
1628 1623  
... ...