Commit 225ac17f7f442f831b8c53d224a75a2b76746a7a
1 parent
413a6873
Exists in
master
and in
100 other branches
Fix tickmarks plot
Showing
5 changed files
with
103 additions
and
138 deletions
Show diff stats
src/ParamOutputImpl/Plot/ParameterData.cc
... | ... | @@ -14,7 +14,7 @@ |
14 | 14 | namespace plot { |
15 | 15 | |
16 | 16 | ParameterData::ParameterData() : |
17 | - _minTime(nan("")), _maxTime(nan("")), _dim1Size(-1), _dim2Size(-1) { | |
17 | + _minTime(nan("")), _maxTime(nan("")), _dim1Size(-1), _dim2Size(-1), _paramGapSize(0.) { | |
18 | 18 | } |
19 | 19 | |
20 | 20 | ParameterData::~ParameterData() { |
... | ... | @@ -44,7 +44,7 @@ void ParameterData::preAllocate(int nbData) |
44 | 44 | * @brief Adds a value by time to parameter |
45 | 45 | */ |
46 | 46 | void ParameterData::addValue(double time, double value, |
47 | - double sampling, double gapSize, bool &gapDetected, AMDA::Common::ParameterIndexComponent& index) { | |
47 | + double sampling, bool &gapDetected, AMDA::Common::ParameterIndexComponent& index) { | |
48 | 48 | int valueIndex = componentToValuesIndex(index); |
49 | 49 | if (valueIndex >= (int)_values.size()) |
50 | 50 | { |
... | ... | @@ -53,7 +53,7 @@ void ParameterData::addValue(double time, double value, |
53 | 53 | // add time if not already in |
54 | 54 | if (_dates.empty() || _dates.back() != time) { |
55 | 55 | |
56 | - if (!_dates.empty() && ((time - _dates.back()) > gapSize)) | |
56 | + if (!_dates.empty() && ((time - _dates.back()) > _paramGapSize)) | |
57 | 57 | { |
58 | 58 | //gap detected => push a NaN value in data list |
59 | 59 | if (_dates.back() + sampling > time) | ... | ... |
src/ParamOutputImpl/Plot/ParameterData.hh
... | ... | @@ -90,7 +90,7 @@ public: |
90 | 90 | /** |
91 | 91 | * @brief Adds a value by time to parameter |
92 | 92 | */ |
93 | - void addValue(double time_, double value_, double sampling, double gapSize, | |
93 | + void addValue(double time_, double value_, double sampling, | |
94 | 94 | bool &gapDetected, AMDA::Common::ParameterIndexComponent& index_); |
95 | 95 | |
96 | 96 | /** |
... | ... | @@ -209,6 +209,22 @@ public: |
209 | 209 | _dim2Size = dim2Size; |
210 | 210 | } |
211 | 211 | |
212 | + /* | |
213 | + * @brief Get param gap size (in seconds) | |
214 | + */ | |
215 | + double getParamGapSize() | |
216 | + { | |
217 | + return _paramGapSize; | |
218 | + } | |
219 | + | |
220 | + /* | |
221 | + * @brief Set param gap size | |
222 | + */ | |
223 | + void setParamGapSize(double gapSize) | |
224 | + { | |
225 | + _paramGapSize = gapSize; | |
226 | + } | |
227 | + | |
212 | 228 | /** |
213 | 229 | * Gets the index of the given time (or just after) in time array, |
214 | 230 | * returns -1 if not found |
... | ... | @@ -289,6 +305,11 @@ private: |
289 | 305 | * @brief Dim 2 Size |
290 | 306 | */ |
291 | 307 | int _dim2Size; |
308 | + | |
309 | + /* | |
310 | + * @brief Param gap size (in seconds) | |
311 | + */ | |
312 | + double _paramGapSize; | |
292 | 313 | }; |
293 | 314 | |
294 | 315 | ... | ... |
src/ParamOutputImpl/Plot/PlotOutput.cc
... | ... | @@ -623,6 +623,7 @@ void PlotOutput::visit( |
623 | 623 | bool gapDetected = false; |
624 | 624 | //ParamDataScalaireShort |
625 | 625 | ParameterData& crtParameterData = _parameterValues[_currentParamId]; |
626 | + crtParameterData.setParamGapSize(gapSize); | |
626 | 627 | AMDA::Common::ParameterIndexComponent componentIndex = AMDA::Common::ParameterIndexComponent(-1,-1); |
627 | 628 | |
628 | 629 | crtParameterData.preAllocate(_paramDataIndexInfo._nbDataToProcess |
... | ... | @@ -636,7 +637,7 @@ void PlotOutput::visit( |
636 | 637 | pParamData->getTime(index), |
637 | 638 | pParamData->get(index), |
638 | 639 | pParamData->getMinSampling(), |
639 | - gapSize, gapDetected, componentIndex); | |
640 | + gapDetected, componentIndex); | |
640 | 641 | } |
641 | 642 | } |
642 | 643 | |
... | ... | @@ -649,6 +650,7 @@ void PlotOutput::visit( |
649 | 650 | bool gapDetected = false;; |
650 | 651 | //ParamDataScalaireFloat |
651 | 652 | ParameterData& crtParameterData = _parameterValues[_currentParamId]; |
653 | + crtParameterData.setParamGapSize(gapSize); | |
652 | 654 | AMDA::Common::ParameterIndexComponent componentIndex = AMDA::Common::ParameterIndexComponent(-1,-1); |
653 | 655 | |
654 | 656 | crtParameterData.preAllocate(_paramDataIndexInfo._nbDataToProcess |
... | ... | @@ -663,7 +665,7 @@ void PlotOutput::visit( |
663 | 665 | pParamData->getTime(index), |
664 | 666 | pParamData->get(index), |
665 | 667 | pParamData->getMinSampling(), |
666 | - gapSize, gapDetected, componentIndex); | |
668 | + gapDetected, componentIndex); | |
667 | 669 | } |
668 | 670 | } |
669 | 671 | |
... | ... | @@ -676,6 +678,7 @@ void PlotOutput::visit( |
676 | 678 | bool gapDetected = false;; |
677 | 679 | //ParamDataScalaireDouble |
678 | 680 | ParameterData& crtParameterData = _parameterValues[_currentParamId]; |
681 | + crtParameterData.setParamGapSize(gapSize); | |
679 | 682 | AMDA::Common::ParameterIndexComponent componentIndex = AMDA::Common::ParameterIndexComponent(-1,-1); |
680 | 683 | |
681 | 684 | crtParameterData.preAllocate(_paramDataIndexInfo._nbDataToProcess |
... | ... | @@ -689,7 +692,7 @@ void PlotOutput::visit( |
689 | 692 | pParamData->getTime(index), |
690 | 693 | pParamData->get(index), |
691 | 694 | pParamData->getMinSampling(), |
692 | - gapSize, gapDetected, componentIndex); | |
695 | + gapDetected, componentIndex); | |
693 | 696 | } |
694 | 697 | } |
695 | 698 | |
... | ... | @@ -702,6 +705,7 @@ void PlotOutput::visit( |
702 | 705 | bool gapDetected = false;; |
703 | 706 | //ParamDataScalaireLongDouble |
704 | 707 | ParameterData& crtParameterData = _parameterValues[_currentParamId]; |
708 | + crtParameterData.setParamGapSize(gapSize); | |
705 | 709 | AMDA::Common::ParameterIndexComponent componentIndex = AMDA::Common::ParameterIndexComponent(-1,-1); |
706 | 710 | |
707 | 711 | crtParameterData.preAllocate(_paramDataIndexInfo._nbDataToProcess |
... | ... | @@ -715,7 +719,7 @@ void PlotOutput::visit( |
715 | 719 | pParamData->getTime(index), |
716 | 720 | pParamData->get(index), |
717 | 721 | pParamData->getMinSampling(), |
718 | - gapSize, gapDetected, componentIndex); | |
722 | + gapDetected, componentIndex); | |
719 | 723 | } |
720 | 724 | } |
721 | 725 | |
... | ... | @@ -728,6 +732,7 @@ void PlotOutput::visit( |
728 | 732 | bool gapDetected = false;; |
729 | 733 | //ParamDataScalaireInt |
730 | 734 | ParameterData& crtParameterData = _parameterValues[_currentParamId]; |
735 | + crtParameterData.setParamGapSize(gapSize); | |
731 | 736 | AMDA::Common::ParameterIndexComponent componentIndex = AMDA::Common::ParameterIndexComponent(-1,-1); |
732 | 737 | |
733 | 738 | crtParameterData.preAllocate(_paramDataIndexInfo._nbDataToProcess |
... | ... | @@ -741,7 +746,7 @@ void PlotOutput::visit( |
741 | 746 | pParamData->getTime(index), |
742 | 747 | pParamData->get(index), |
743 | 748 | pParamData->getMinSampling(), |
744 | - gapSize, gapDetected, componentIndex); | |
749 | + gapDetected, componentIndex); | |
745 | 750 | } |
746 | 751 | } |
747 | 752 | |
... | ... | @@ -760,6 +765,7 @@ void PlotOutput::visit(AMDA::Parameters::ParamDataTab1DShort *pParamData) { |
760 | 765 | bool gapDetected = false;; |
761 | 766 | //ParamDataTab1DShort |
762 | 767 | ParameterData& crtParameterData = _parameterValues[_currentParamId]; |
768 | + crtParameterData.setParamGapSize(gapSize); | |
763 | 769 | |
764 | 770 | //init parameter values container |
765 | 771 | if (crtParameterData._indexes.size() == 0) |
... | ... | @@ -777,7 +783,7 @@ void PlotOutput::visit(AMDA::Parameters::ParamDataTab1DShort *pParamData) { |
777 | 783 | crtParameterData.addValue(time, |
778 | 784 | pParamData->get(i)[index.getDim1Index()], |
779 | 785 | pParamData->getMinSampling(), |
780 | - gapSize, gapDetected, index); | |
786 | + gapDetected, index); | |
781 | 787 | } |
782 | 788 | } |
783 | 789 | } |
... | ... | @@ -791,6 +797,7 @@ void PlotOutput::visit( |
791 | 797 | bool gapDetected = false;; |
792 | 798 | //ParamDataTab1DFloat |
793 | 799 | ParameterData& crtParameterData = _parameterValues[_currentParamId]; |
800 | + crtParameterData.setParamGapSize(gapSize); | |
794 | 801 | |
795 | 802 | //init parameter values container |
796 | 803 | if (crtParameterData._indexes.size() == 0) |
... | ... | @@ -808,7 +815,7 @@ void PlotOutput::visit( |
808 | 815 | crtParameterData.addValue(time, |
809 | 816 | pParamData->get(i)[index.getDim1Index()], |
810 | 817 | pParamData->getMinSampling(), |
811 | - gapSize, gapDetected, index); | |
818 | + gapDetected, index); | |
812 | 819 | } |
813 | 820 | } |
814 | 821 | } |
... | ... | @@ -822,6 +829,7 @@ void PlotOutput::visit( |
822 | 829 | bool gapDetected = false;; |
823 | 830 | //ParamDataTab1DDouble |
824 | 831 | ParameterData& crtParameterData = _parameterValues[_currentParamId]; |
832 | + crtParameterData.setParamGapSize(gapSize); | |
825 | 833 | |
826 | 834 | //init parameter values container |
827 | 835 | if (crtParameterData._indexes.size() == 0) |
... | ... | @@ -839,7 +847,7 @@ void PlotOutput::visit( |
839 | 847 | crtParameterData.addValue(time, |
840 | 848 | pParamData->get(i)[index.getDim1Index()], |
841 | 849 | pParamData->getMinSampling(), |
842 | - gapSize, gapDetected, index); | |
850 | + gapDetected, index); | |
843 | 851 | } |
844 | 852 | } |
845 | 853 | } |
... | ... | @@ -853,6 +861,7 @@ void PlotOutput::visit( |
853 | 861 | bool gapDetected = false;; |
854 | 862 | //ParamDataTab1DLongDouble |
855 | 863 | ParameterData& crtParameterData = _parameterValues[_currentParamId]; |
864 | + crtParameterData.setParamGapSize(gapSize); | |
856 | 865 | |
857 | 866 | //init parameter values container |
858 | 867 | if (crtParameterData._indexes.size() == 0) |
... | ... | @@ -870,7 +879,7 @@ void PlotOutput::visit( |
870 | 879 | crtParameterData.addValue(time, |
871 | 880 | pParamData->get(i)[index.getDim1Index()], |
872 | 881 | pParamData->getMinSampling(), |
873 | - gapSize, gapDetected, index); | |
882 | + gapDetected, index); | |
874 | 883 | } |
875 | 884 | } |
876 | 885 | } |
... | ... | @@ -883,6 +892,7 @@ void PlotOutput::visit(AMDA::Parameters::ParamDataTab1DInt *pParamData) { |
883 | 892 | bool gapDetected = false;; |
884 | 893 | //ParamDataTab1DInt |
885 | 894 | ParameterData& crtParameterData = _parameterValues[_currentParamId]; |
895 | + crtParameterData.setParamGapSize(gapSize); | |
886 | 896 | |
887 | 897 | //init parameter values container |
888 | 898 | if (crtParameterData._indexes.size() == 0) |
... | ... | @@ -900,7 +910,7 @@ void PlotOutput::visit(AMDA::Parameters::ParamDataTab1DInt *pParamData) { |
900 | 910 | crtParameterData.addValue(time, |
901 | 911 | pParamData->get(i)[index.getDim1Index()], |
902 | 912 | pParamData->getMinSampling(), |
903 | - gapSize, gapDetected, index); | |
913 | + gapDetected, index); | |
904 | 914 | } |
905 | 915 | } |
906 | 916 | } |
... | ... | @@ -920,6 +930,7 @@ void PlotOutput::visit(AMDA::Parameters::ParamDataTab2DShort *pParamData) { |
920 | 930 | bool gapDetected = false;; |
921 | 931 | //ParamDataTab2DShort |
922 | 932 | ParameterData& crtParameterData = _parameterValues[_currentParamId]; |
933 | + crtParameterData.setParamGapSize(gapSize); | |
923 | 934 | |
924 | 935 | //init parameter values container |
925 | 936 | if (crtParameterData._indexes.size() == 0) |
... | ... | @@ -937,7 +948,7 @@ void PlotOutput::visit(AMDA::Parameters::ParamDataTab2DShort *pParamData) { |
937 | 948 | crtParameterData.addValue(time, |
938 | 949 | pParamData->get(i)[index.getDim1Index()][index.getDim2Index()], |
939 | 950 | pParamData->getMinSampling(), |
940 | - gapSize, gapDetected, index); | |
951 | + gapDetected, index); | |
941 | 952 | } |
942 | 953 | } |
943 | 954 | } |
... | ... | @@ -950,6 +961,7 @@ void PlotOutput::visit(AMDA::Parameters::ParamDataTab2DFloat *pParamData) { |
950 | 961 | bool gapDetected = false;; |
951 | 962 | //ParamDataTab2DFloat |
952 | 963 | ParameterData& crtParameterData = _parameterValues[_currentParamId]; |
964 | + crtParameterData.setParamGapSize(gapSize); | |
953 | 965 | |
954 | 966 | //init parameter values container |
955 | 967 | if (crtParameterData._indexes.size() == 0) |
... | ... | @@ -967,7 +979,7 @@ void PlotOutput::visit(AMDA::Parameters::ParamDataTab2DFloat *pParamData) { |
967 | 979 | crtParameterData.addValue(time, |
968 | 980 | pParamData->get(i)[index.getDim1Index()][index.getDim2Index()], |
969 | 981 | pParamData->getMinSampling(), |
970 | - gapSize, gapDetected, index); | |
982 | + gapDetected, index); | |
971 | 983 | } |
972 | 984 | } |
973 | 985 | } |
... | ... | @@ -980,6 +992,7 @@ void PlotOutput::visit(AMDA::Parameters::ParamDataTab2DDouble *pParamData) { |
980 | 992 | bool gapDetected = false;; |
981 | 993 | //ParamDataTab2DDouble |
982 | 994 | ParameterData& crtParameterData = _parameterValues[_currentParamId]; |
995 | + crtParameterData.setParamGapSize(gapSize); | |
983 | 996 | |
984 | 997 | //init parameter values container |
985 | 998 | if (crtParameterData._indexes.size() == 0) |
... | ... | @@ -997,7 +1010,7 @@ void PlotOutput::visit(AMDA::Parameters::ParamDataTab2DDouble *pParamData) { |
997 | 1010 | crtParameterData.addValue(time, |
998 | 1011 | pParamData->get(i)[index.getDim1Index()][index.getDim2Index()], |
999 | 1012 | pParamData->getMinSampling(), |
1000 | - gapSize, gapDetected, index); | |
1013 | + gapDetected, index); | |
1001 | 1014 | } |
1002 | 1015 | } |
1003 | 1016 | } |
... | ... | @@ -1010,6 +1023,7 @@ void PlotOutput::visit(AMDA::Parameters::ParamDataTab2DLongDouble *pParamData) { |
1010 | 1023 | bool gapDetected = false;; |
1011 | 1024 | //ParamDataTab2DLongDouble |
1012 | 1025 | ParameterData& crtParameterData = _parameterValues[_currentParamId]; |
1026 | + crtParameterData.setParamGapSize(gapSize); | |
1013 | 1027 | |
1014 | 1028 | //init parameter values container |
1015 | 1029 | if (crtParameterData._indexes.size() == 0) |
... | ... | @@ -1027,7 +1041,7 @@ void PlotOutput::visit(AMDA::Parameters::ParamDataTab2DLongDouble *pParamData) { |
1027 | 1041 | crtParameterData.addValue(time, |
1028 | 1042 | pParamData->get(i)[index.getDim1Index()][index.getDim2Index()], |
1029 | 1043 | pParamData->getMinSampling(), |
1030 | - gapSize, gapDetected, index); | |
1044 | + gapDetected, index); | |
1031 | 1045 | } |
1032 | 1046 | } |
1033 | 1047 | } |
... | ... | @@ -1040,6 +1054,7 @@ void PlotOutput::visit(AMDA::Parameters::ParamDataTab2DInt *pParamData) { |
1040 | 1054 | bool gapDetected = false;; |
1041 | 1055 | //ParamDataTab2DInt |
1042 | 1056 | ParameterData& crtParameterData = _parameterValues[_currentParamId]; |
1057 | + crtParameterData.setParamGapSize(gapSize); | |
1043 | 1058 | |
1044 | 1059 | //init parameter values container |
1045 | 1060 | if (crtParameterData._indexes.size() == 0) |
... | ... | @@ -1057,7 +1072,7 @@ void PlotOutput::visit(AMDA::Parameters::ParamDataTab2DInt *pParamData) { |
1057 | 1072 | crtParameterData.addValue(time, |
1058 | 1073 | pParamData->get(i)[index.getDim1Index()][index.getDim2Index()], |
1059 | 1074 | pParamData->getMinSampling(), |
1060 | - gapSize, gapDetected, index); | |
1075 | + gapDetected, index); | |
1061 | 1076 | } |
1062 | 1077 | } |
1063 | 1078 | } | ... | ... |
src/ParamOutputImpl/Plot/TickPlot/TickMarkDecorator.cc
... | ... | @@ -55,7 +55,7 @@ TickMarkDecorator& TickMarkDecorator::operator=(const TickMarkDecorator& ref_) { |
55 | 55 | } else { |
56 | 56 | _pTimeInfo->_timeFormat = ref_._pTimeInfo->_timeFormat; |
57 | 57 | _pTimeInfo->_timeTitle = ref_._pTimeInfo->_timeTitle; |
58 | - _pTimeInfo->_min = ref_._pTimeInfo->_min; | |
58 | + _pTimeInfo->_isFirstLabel = ref_._pTimeInfo->_isFirstLabel; | |
59 | 59 | _pTimeInfo->_maxLen = ref_._pTimeInfo->_maxLen; |
60 | 60 | } |
61 | 61 | _seriesInfoList = ref_._seriesInfoList; |
... | ... | @@ -342,91 +342,6 @@ void TickMarkDecorator::draw(PanelPlotOutput* pplot_, Axis* axis_, |
342 | 342 | restoreColor(pls_, lInitialColor, pplot_->_panel->_page->_mode); |
343 | 343 | |
344 | 344 | } |
345 | -/** | |
346 | - * @brief Search for each tick time, the closest parameter time in the paramdata_ and store the corresponding value. | |
347 | - * Selected parameter time is in range ]ticktime-step, ticktime+step[ where step is the space between two tick. | |
348 | - * If no such time is found for a given tick, associated value is marked as NaN. | |
349 | - * Note that this algorithm may retrieve same value twice if there is exactly one time between two ticks | |
350 | - * and it is exactly at the middle. | |
351 | - * @param seriesdata_ series data to fill | |
352 | - * @param pAxis_ related axis | |
353 | - * @param paramdata_ related parameter | |
354 | - * @param serieIndex_ series index. | |
355 | - * @return longest label to display for that series (in number of char). | |
356 | - */ | |
357 | -unsigned int TickMarkDecorator::fillSeriesData(SeriesData& seriesdata_, | |
358 | - TimeAxis* pAxis_, ParameterData& paramdata_, AMDA::Common::ParameterIndexComponent serieIndex_) { | |
359 | - LOG4CXX_DEBUG(_logger, " filling series data..."); | |
360 | - // string used to compute formattedvalue max length | |
361 | - char formattedValue [40]; | |
362 | - unsigned int maxlen = 0; | |
363 | - | |
364 | - // time range : | |
365 | - double start = pAxis_->getRange().getMin(); | |
366 | - double stop = pAxis_->getRange().getMax(); | |
367 | - double step = getMajorTickSpace(pAxis_, start, stop); | |
368 | - LOG4CXX_TRACE(_logger, | |
369 | - " for all ticks between " << start << " and " << stop << " spaced by " << step); | |
370 | - | |
371 | - int index = -1; | |
372 | - int size = paramdata_.getSize(); | |
373 | - | |
374 | - for (double tickTime = start; tickTime <= stop; tickTime += step) { | |
375 | - // search index closest value to that time : | |
376 | - double* ptime = paramdata_.getTimes(); | |
377 | - int i = index + 1; | |
378 | - while (i < size && (*(ptime + i) < tickTime)) { | |
379 | - i++; | |
380 | - } | |
381 | - | |
382 | - double cur = (i >= size) ? -1 : *(ptime + i); | |
383 | - double prev = (i == 0) ? -1 : *(ptime + i - 1); | |
384 | - | |
385 | - if (prev != -1 && prev <= (tickTime - step)) { | |
386 | - prev = -1; | |
387 | - } | |
388 | - if (cur != -1 && cur >= (tickTime + step)) { | |
389 | - cur = -1; | |
390 | - } | |
391 | - | |
392 | - if (prev == -1) { | |
393 | - // only cur can be eligible | |
394 | - if (cur == -1) { | |
395 | - index = -1; // no suitable value | |
396 | - } else { | |
397 | - index = i; | |
398 | - } | |
399 | - } else if (cur == -1) { | |
400 | - // only prev can be eligible and it is not -1 due to previous test | |
401 | - index = i - 1; | |
402 | - } else { | |
403 | - // both are eligible, choose closest one : | |
404 | - if ((tickTime - prev) > (cur - tickTime)) { | |
405 | - index = i; | |
406 | - } else { | |
407 | - index = i - 1; | |
408 | - } | |
409 | - } | |
410 | - | |
411 | - // time found, retrieve related value or put a nan one: | |
412 | - if (index == -1) { | |
413 | - LOG4CXX_TRACE(_logger, | |
414 | - "updating series data at time:"<<tickTime<<" with value:(NaN)"); | |
415 | - seriesdata_[tickTime] = nan("NaN"); | |
416 | - // restore last index for next loop : | |
417 | - index = i; | |
418 | - } else { | |
419 | - double value = *(paramdata_.getValues(serieIndex_) + index); | |
420 | - LOG4CXX_TRACE(_logger, | |
421 | - "updating series data at time:"<<tickTime<<" with value :("<<value<<")"); | |
422 | - // compute formatted value length : | |
423 | - const unsigned int len = snprintf(formattedValue, 40, getValuesFormat().c_str(), value); | |
424 | - maxlen = std::max((const unsigned int) maxlen, len); | |
425 | - seriesdata_[tickTime] = value; | |
426 | - } | |
427 | - } | |
428 | - return std::min((const unsigned int) maxlen, (const unsigned int) 40); | |
429 | -} | |
430 | 345 | |
431 | 346 | void TickMarkDecorator::installLabelGenerator(PanelPlotOutput* /*pplot_*/, TimeAxis* timeAxis_) { |
432 | 347 | |
... | ... | @@ -436,7 +351,7 @@ void TickMarkDecorator::installLabelGenerator(PanelPlotOutput* /*pplot_*/, TimeA |
436 | 351 | // install time format |
437 | 352 | _pTimeInfo->_timeFormat = getPlFormat(); |
438 | 353 | _pTimeInfo->_timeTitle = timeAxis_->_legend._text; |
439 | - _pTimeInfo->_min = timeAxis_->getRange().getMin(); | |
354 | + _pTimeInfo->_isFirstLabel = true; | |
440 | 355 | |
441 | 356 | unsigned int maxNameLen = _pTimeInfo->_timeTitle.size(); |
442 | 357 | // init maximum value len with formatted time : |
... | ... | @@ -473,15 +388,18 @@ void TickMarkDecorator::installLabelGenerator(PanelPlotOutput* /*pplot_*/, TimeA |
473 | 388 | if (pSerie->_name.size() > maxNameLen) { |
474 | 389 | maxNameLen = pSerie->_name.size(); |
475 | 390 | } |
476 | - pSerie->_min = timeAxis_->getRange().getMin(); | |
391 | + pSerie->_isFirstLabel = true; | |
477 | 392 | pSerie->_valuesFormat = getValuesFormat(); |
478 | - // get serie at index : | |
479 | - SeriesData data; | |
480 | - _maxValueLen = std::max((const unsigned int) _maxValueLen, | |
481 | - fillSeriesData(data, timeAxis_, | |
482 | - (*_pParameterValues)[p.getYSeriePropertiesAt(q).getParamId()], | |
483 | - q)); | |
484 | - pSerie->_data = data; | |
393 | + | |
394 | + //Compute max len | |
395 | + pSerie->_parameterData = &((*_pParameterValues)[p.getYSeriePropertiesAt(q).getParamId()]); | |
396 | + pSerie->_indexComponents = AMDA::Common::ParameterIndexComponent(q.getDim1Index(),q.getDim2Index()); | |
397 | + | |
398 | + for (int i = 0; i < pSerie->_parameterData->getSize(); ++i) { | |
399 | + const unsigned int len = snprintf(formattedStr, 40, getValuesFormat().c_str(), *pSerie->_parameterData->getValues(pSerie->_indexComponents, i)); | |
400 | + _maxValueLen = std::max(_maxValueLen, len); | |
401 | + } | |
402 | + | |
485 | 403 | _seriesInfoList.push_back(pSerie); |
486 | 404 | } |
487 | 405 | } |
... | ... | @@ -517,24 +435,35 @@ void generateYLabel(PLINT axis, PLFLT value, char *label, PLINT length, |
517 | 435 | SeriesInfo* pInfo = static_cast<SeriesInfo*> (data); |
518 | 436 | // if value equals min, display _name string |
519 | 437 | // otherwise, format value and display it |
520 | - if (value == pInfo->_min) { | |
438 | + if (pInfo->_isFirstLabel) { | |
521 | 439 | // do not display min value label |
522 | 440 | // but display title : |
523 | 441 | snprintf(label, length, "%*s", pInfo->_maxLen, |
524 | 442 | pInfo->_name.c_str()); |
525 | - | |
443 | + pInfo->_isFirstLabel = false; | |
526 | 444 | } else { |
527 | 445 | // display formatted value |
528 | 446 | std::ostringstream labels; |
529 | - // loops over each series and display value at this time | |
530 | - auto q = pInfo->_data.find((double) value); | |
531 | - if (q != pInfo->_data.end()) { | |
532 | - // we found it ! | |
533 | - labels << boost::format(pInfo->_valuesFormat) % q->second; | |
534 | - } else { | |
535 | - // not found just display Nan indicator | |
447 | + | |
448 | + //get nearest value | |
449 | + double crtTime = (double) value; | |
450 | + | |
451 | + int crtIndex = pInfo->_parameterData->indexOf(crtTime); | |
452 | + | |
453 | + if (crtIndex == -1 && (crtTime - (pInfo->_parameterData->getTimes()[pInfo->_parameterData->getSize()-1]) < pInfo->_parameterData->getParamGapSize())) | |
454 | + //Fix last value | |
455 | + crtIndex = pInfo->_parameterData->getSize()-1; | |
456 | + else if ((crtTime - (pInfo->_parameterData->getTimes()[crtIndex])) > pInfo->_parameterData->getParamGapSize()) | |
457 | + //Be sure that we are not in a data gap | |
458 | + crtIndex = -1; | |
459 | + | |
460 | + if (crtIndex == -1) { | |
536 | 461 | labels << "NaN" << std::endl; |
537 | 462 | } |
463 | + else { | |
464 | + labels << boost::format(pInfo->_valuesFormat) % (*pInfo->_parameterData->getValues(pInfo->_indexComponents, crtIndex)); | |
465 | + } | |
466 | + | |
538 | 467 | snprintf(label, length, "%s", labels.str().c_str()); |
539 | 468 | } |
540 | 469 | } |
... | ... | @@ -557,11 +486,12 @@ void generateOrbitTimeLabel(PLINT axis, PLFLT value, char *label, PLINT length, |
557 | 486 | // if value equals min, display an empty string |
558 | 487 | // otherwise, format time and display formatted time |
559 | 488 | |
560 | - if (value == pInfo->_min) { | |
489 | + if (pInfo->_isFirstLabel) { | |
561 | 490 | // do not display min value label |
562 | 491 | // but display title : |
563 | 492 | snprintf(label, length, "%*s", pInfo->_maxLen, |
564 | 493 | pInfo->_timeTitle.c_str()); |
494 | + pInfo->_isFirstLabel = false; | |
565 | 495 | |
566 | 496 | } else { |
567 | 497 | // display formatted time | ... | ... |
src/ParamOutputImpl/Plot/TickPlot/TickMarkDecorator.hh
... | ... | @@ -23,8 +23,6 @@ using std::map; |
23 | 23 | |
24 | 24 | namespace plot { |
25 | 25 | |
26 | -typedef std::map<double,double> SeriesData; | |
27 | - | |
28 | 26 | struct SeriesInfo{ |
29 | 27 | /** |
30 | 28 | * @brief name of that series (i.e. name of parameter and index if not a scalar parameter). |
... | ... | @@ -42,15 +40,21 @@ struct SeriesInfo{ |
42 | 40 | * @brief maximum len for value. May be useful to justify formatted output. |
43 | 41 | */ |
44 | 42 | unsigned int _maxValueLen; |
43 | + | |
45 | 44 | /** |
46 | - * @brief min time index. (used display _name instead of a value). | |
45 | + * @brief to know if it's the first label to draw | |
47 | 46 | */ |
48 | - double _min; | |
47 | + bool _isFirstLabel; | |
48 | + | |
49 | 49 | /** |
50 | - * @brief values for that series. Holds for each "time" at a tick , | |
51 | - * the related series value. | |
50 | + * @brief link to the parameter data | |
52 | 51 | */ |
53 | - SeriesData _data; | |
52 | + ParameterData* _parameterData; | |
53 | + | |
54 | + /** | |
55 | + * @brief serie components | |
56 | + */ | |
57 | + AMDA::Common::ParameterIndexComponent _indexComponents; | |
54 | 58 | }; |
55 | 59 | |
56 | 60 | typedef std::vector<boost::shared_ptr<SeriesInfo>> SeriesList; |
... | ... | @@ -71,9 +75,9 @@ struct TimeInfo{ |
71 | 75 | */ |
72 | 76 | unsigned int _maxLen; |
73 | 77 | /** |
74 | - * @brief minimum time index. (used display _timeTitle instead of a value). | |
78 | + * @brief to know if it's the first label to draw | |
75 | 79 | */ |
76 | - double _min; | |
80 | + bool _isFirstLabel; | |
77 | 81 | }; |
78 | 82 | typedef boost::shared_ptr<TimeInfo> TimeInfoPtr; |
79 | 83 | |
... | ... | @@ -123,11 +127,6 @@ protected: |
123 | 127 | private: |
124 | 128 | |
125 | 129 | /** |
126 | - * @brief Calculates tick values (closest value from the tick time) | |
127 | - */ | |
128 | - unsigned int fillSeriesData(SeriesData& seriesdata_, TimeAxis* pAxis_, ParameterData& paramdata_, AMDA::Common::ParameterIndexComponent indexSerie_); | |
129 | - | |
130 | - /** | |
131 | 130 | * @brief Calculates plot area for date display |
132 | 131 | */ |
133 | 132 | double computeStartDateWidth(PanelPlotOutput* pplot_, TimeAxis* pAxis_); | ... | ... |