Commit 05da1b4dde5abfa6c3d36b8d2f6cb183dd0129ea
1 parent
e8cefd97
Exists in
master
and in
66 other branches
Draw instant plot preview
Showing
2 changed files
with
182 additions
and
13 deletions
Show diff stats
src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php
... | ... | @@ -15,6 +15,7 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass |
15 | 15 | private $interactiveMultiPlotState = array(); |
16 | 16 | private $interactiveTimeSelectionState = array(); |
17 | 17 | private $interactiveCrtTTFileIndex = -1; |
18 | + private $interactivePreview = false; | |
18 | 19 | |
19 | 20 | /* |
20 | 21 | * @brief method to unmarshall a plot request |
... | ... | @@ -206,14 +207,14 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass |
206 | 207 | |
207 | 208 | switch ($tab->{'page-mode'}) |
208 | 209 | { |
209 | - case 'color' : | |
210 | - $pageNode->setMode(RequestOutputPlotPageModeEnum::COLOR); | |
211 | - break; | |
210 | + | |
212 | 211 | case 'grayscale' : |
213 | 212 | $pageNode->setMode(RequestOutputPlotPageModeEnum::GRAYSCALE); |
214 | 213 | break; |
214 | + case 'color' : | |
215 | 215 | default: |
216 | - throw new Exception('Page mode not implemented.'); | |
216 | + $pageNode->setMode(RequestOutputPlotPageModeEnum::COLOR); | |
217 | + break; | |
217 | 218 | } |
218 | 219 | |
219 | 220 | if ($tab->{'page-margins-activated'}) |
... | ... | @@ -250,6 +251,7 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass |
250 | 251 | $this->interactiveRequestRealIndexes[PLOT_RESULT_FILE_KEY."_".$tab->{'id'}] = $tabRequestIndex; |
251 | 252 | $this->interactiveMultiPlotState[PLOT_RESULT_FILE_KEY."_".$tab->{'id'}] = $tab->{'multi-plot-linked'}; |
252 | 253 | $this->interactiveTimeSelectionState[PLOT_RESULT_FILE_KEY."_".$tab->{'id'}] = $isIntervalRequest; |
254 | + $this->interactivePreview = isset($input->{'interactive-preview'}) && ($input->{'interactive-preview'}); | |
253 | 255 | $this->paramsData->addWaitingResult(PLOT_RESULT_FILE_KEY."_".$tab->{'id'}, $waitingResultFile); |
254 | 256 | } |
255 | 257 | else |
... | ... | @@ -513,7 +515,8 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass |
513 | 515 | } |
514 | 516 | |
515 | 517 | //reverse axis |
516 | - $axisNode->setReverse($axisData->{'axis-reverse'} ? "true" : "false"); | |
518 | + if (isset($axisData->{'axis-reverse'})) | |
519 | + $axisNode->setReverse($axisData->{'axis-reverse'} ? "true" : "false"); | |
517 | 520 | |
518 | 521 | //axis scale |
519 | 522 | switch ($axisData->{'axis-scale'}) |
... | ... | @@ -528,7 +531,8 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass |
528 | 531 | //axis range |
529 | 532 | if ($axisData->{'axis-range-min'} < $axisData->{'axis-range-max'}) |
530 | 533 | $axisNode->getRange()->setMinMax($axisData->{'axis-range-min'}, $axisData->{'axis-range-max'}); |
531 | - $axisNode->getRange()->setExtend($axisData->{'axis-range-extend'} ? "true" : "false"); | |
534 | + if (isset($axisData->{'axis-range-extend'})) | |
535 | + $axisNode->getRange()->setExtend($axisData->{'axis-range-extend'} ? "true" : "false"); | |
532 | 536 | |
533 | 537 | //axis color |
534 | 538 | $axisNode->setColor($this->hexColor2KernelColor($axisData->{'axis-color'})); |
... | ... | @@ -547,20 +551,26 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass |
547 | 551 | } |
548 | 552 | |
549 | 553 | //axis minor and major grid |
550 | - $axisNode->getTick()->setMinorGrid($axisData->{'axis-grid-minor'} ? "true" : "false"); | |
551 | - $axisNode->getTick()->setMajorGrid($axisData->{'axis-grid-major'} ? "true" : "false"); | |
554 | + if (isset($axisData->{'axis-grid-minor'})) | |
555 | + $axisNode->getTick()->setMinorGrid($axisData->{'axis-grid-minor'} ? "true" : "false"); | |
556 | + if (isset($axisData->{'axis-grid-major'})) | |
557 | + $axisNode->getTick()->setMajorGrid($axisData->{'axis-grid-major'} ? "true" : "false"); | |
552 | 558 | |
553 | 559 | //legend |
554 | - if ($axisData->{'axis-legend-text'} != '') | |
560 | + if (isset($axisData->{'axis-legend-text'}) && $axisData->{'axis-legend-text'} != '') | |
561 | + { | |
555 | 562 | $axisNode->getLegend()->setText($axisData->{'axis-legend-text'}); |
556 | - $axisNode->getLegend()->setColor($this->hexColor2KernelColor($axisData->{'axis-legend-color'})); | |
557 | - $this->unmarshallLabel($axisData, "axis-legend", $axisNode->getLegend()); | |
563 | + $axisNode->getLegend()->setColor($this->hexColor2KernelColor($axisData->{'axis-legend-color'})); | |
564 | + $this->unmarshallLabel($axisData, "axis-legend", $axisNode->getLegend()); | |
565 | + } | |
558 | 566 | |
559 | 567 | //Show legend |
560 | - $axisNode->setShowLegend($axisData->{'axis-legend-activated'} ? "true" : "false"); | |
568 | + if (isset($axisData->{'axis-legend-activated'})) | |
569 | + $axisNode->setShowLegend($axisData->{'axis-legend-activated'} ? "true" : "false"); | |
561 | 570 | |
562 | 571 | //Show tick marks |
563 | - $axisNode->setShowTickMarks($axisData->{'axis-tick-showmarks'} ? "true" : "false"); | |
572 | + if (isset($axisData->{'axis-tick-showmarks'})) | |
573 | + $axisNode->setShowTickMarks($axisData->{'axis-tick-showmarks'} ? "true" : "false"); | |
564 | 574 | |
565 | 575 | //Add constants |
566 | 576 | if ($constantAxisId != '') |
... | ... | @@ -1382,6 +1392,7 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass |
1382 | 1392 | "id" => $key, |
1383 | 1393 | "index" => $this->interactiveRequestRealIndexes[$key], |
1384 | 1394 | "multiplot" => $this->interactiveMultiPlotState[$key], |
1395 | + "preview" => $this->interactivePreview, | |
1385 | 1396 | "isInterval" => $this->interactiveTimeSelectionState[$key], |
1386 | 1397 | "ttFileIndex" => $this->interactiveCrtTTFileIndex, |
1387 | 1398 | "context" => IHMPlotContextFileClass::parse($this->getWorkingPath().$contextResult), |
... | ... | @@ -1469,6 +1480,8 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass |
1469 | 1480 | return $this->unmarshallTTGoto($actionInput, $plotInput); |
1470 | 1481 | case 'synchronize' : |
1471 | 1482 | return $this->unmarshallSynchronize($actionInput, $plotInput); |
1483 | + case 'instant' : | |
1484 | + return $this->unmarshallInstant($actionInput, $plotInput); | |
1472 | 1485 | default : |
1473 | 1486 | throw new Exception('Interactive action not implemented.'); |
1474 | 1487 | } |
... | ... | @@ -1688,5 +1701,158 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass |
1688 | 1701 | $this->saveIHMRequest($plotInput); |
1689 | 1702 | return $plotInput; |
1690 | 1703 | } |
1704 | + | |
1705 | + private function unmarshallInstant($input, $plotInput) | |
1706 | + { | |
1707 | + //Find current tab | |
1708 | + $crtTab = NULL; | |
1709 | + foreach ($plotInput->{'tabs'} as $tab) | |
1710 | + { | |
1711 | + if ($input->{'tabId'} == PLOT_RESULT_FILE_KEY."_".$tab->{'id'}) | |
1712 | + { | |
1713 | + $crtTab = $tab; | |
1714 | + break; | |
1715 | + } | |
1716 | + } | |
1717 | + | |
1718 | + if (!$crtTab) | |
1719 | + throw new Exception('Cannot retrieve plot tab for instant plot.'); | |
1720 | + | |
1721 | + //Find current panel | |
1722 | + $crtPanel = NULL; | |
1723 | + foreach ($crtTab->{'panels'} as $panel) | |
1724 | + { | |
1725 | + if ($input->{'panelId'} == $panel->{'id'}) | |
1726 | + { | |
1727 | + $crtPanel = $panel; | |
1728 | + break; | |
1729 | + } | |
1730 | + } | |
1731 | + | |
1732 | + if (!$crtPanel) | |
1733 | + throw new Exception('Cannot retrieve plot panel for instant plot.'); | |
1734 | + | |
1735 | + if ($crtPanel->{'panel-plot-type'} != 'timePlot') | |
1736 | + throw new Exception('Instant plot action only available for Time plot.'); | |
1737 | + | |
1738 | + //Find spectra parameter | |
1739 | + $crtParam = NULL; | |
1740 | + foreach ($crtPanel->{'params'} as $param) | |
1741 | + { | |
1742 | + if ($param->{'param-drawing-type'} == 'spectro') | |
1743 | + { | |
1744 | + $crtParam = $param; | |
1745 | + break; | |
1746 | + } | |
1747 | + } | |
1748 | + | |
1749 | + if (!$crtParam) | |
1750 | + throw new Exception('Cannot retrieve plot param for instant plot.'); | |
1751 | + | |
1752 | + //Find table Y-axis | |
1753 | + $crtYAxis = NULL; | |
1754 | + foreach ($crtPanel->{'axes'} as $axis) | |
1755 | + { | |
1756 | + if ($crtParam->{'param-drawing-object'}->{'spectro-yaxis'} == $axis->{'id'}) | |
1757 | + { | |
1758 | + $crtYAxis = $axis; | |
1759 | + break; | |
1760 | + } | |
1761 | + } | |
1762 | + | |
1763 | + if (!$crtYAxis) | |
1764 | + throw new Exception('Cannot retrieve plot y Axis for instant plot.'); | |
1765 | + | |
1766 | + //Find color Z-axis | |
1767 | + $crtColorAxis = NULL; | |
1768 | + foreach ($crtPanel->{'axes'} as $axis) | |
1769 | + { | |
1770 | + if ($axis->{'id'} == 'color') | |
1771 | + { | |
1772 | + $crtColorAxis = $axis; | |
1773 | + break; | |
1774 | + } | |
1775 | + } | |
1776 | + | |
1777 | + if (!$crtColorAxis) | |
1778 | + throw new Exception('Cannot retrieve plot color Axis for instant plot.'); | |
1779 | + | |
1780 | + date_default_timezone_set('UTC'); | |
1781 | + $timeStamp = strtotime($input->time); | |
1782 | + | |
1783 | + $instantPlotInput = (Object)array( | |
1784 | + "interactive-preview" => true, | |
1785 | + "file-format" => "PNG", | |
1786 | + "file-output" => "INTERACTIVE", | |
1787 | + "file-prefix" => "instant", | |
1788 | + "last-plotted-tab"=> 1, | |
1789 | + "timesrc" => "Interval", | |
1790 | + "startDate" => date("Y-m-dTH:i:s", $timeStamp - 3600), | |
1791 | + "stopDate" => date("Y-m-dTH:i:s", $timeStamp + 3600), | |
1792 | + "tabs" => array() | |
1793 | + ); | |
1794 | + | |
1795 | + $instantTab = (Object)array( | |
1796 | + "id" => 1, | |
1797 | + "multi-plot-linked" => true, | |
1798 | + "page-margins-activated" => $crtTab->{"page-margins-activated"}, | |
1799 | + "page-margin-x" => $crtTab->{"page-margin-x"}, | |
1800 | + "page-margin-y" => $crtTab->{"page-margin-y"}, | |
1801 | + "page-orientation" => $crtTab->{"page-orientation"}, | |
1802 | + "page-dimension" => $crtTab->{"page-dimension"}, | |
1803 | + "page-layout-type" => "vertical", | |
1804 | + "page-layout-object" => (Object)array( | |
1805 | + "layout-expand" => true, | |
1806 | + "layout-panel-height" => 0.5, | |
1807 | + "layout-panel-spacing" => 0.05 | |
1808 | + ), | |
1809 | + "panels" => array() | |
1810 | + ); | |
1811 | + | |
1812 | + $instantPanel = (Object)array( | |
1813 | + "id" => "1", | |
1814 | + "panel-plot-type" => "instantPlot", | |
1815 | + "panel-instant-time" => $input->time, | |
1816 | + "axes" => array(), | |
1817 | + "params" => array() | |
1818 | + ); | |
1819 | + | |
1820 | + $instantXAxis = (Object)array( | |
1821 | + "id" => "xaxis_id", | |
1822 | + "axis-type" => "x", | |
1823 | + "axis-scale" => $crtYAxis->{"axis-scale"}, | |
1824 | + "axis-thickness" => 1 | |
1825 | + ); | |
1826 | + | |
1827 | + $instantYAxis = (Object)array( | |
1828 | + "id" => "y-left", | |
1829 | + "axis-type" => "y-left", | |
1830 | + "axis-scale" => $crtColorAxis->{"axis-scale"}, | |
1831 | + "axis-thickness" => 1 | |
1832 | + ); | |
1833 | + $instantPanel->{"axes"}[] = $instantXAxis; | |
1834 | + $instantPanel->{"axes"}[] = $instantYAxis; | |
1835 | + | |
1836 | + $instantParam = (Object)array( | |
1837 | + "id" => 1, | |
1838 | + "param-id" => $crtParam->{'param-id'}, | |
1839 | + "param-drawing-type" => "iserie", | |
1840 | + "param-drawing-object" => (Object)array( | |
1841 | + "iserie-tableonx" => true, | |
1842 | + "iserie-lines-activated" => true, | |
1843 | + "iserie-lines-style" => "plain", | |
1844 | + "iserie-lines-width" => 1, | |
1845 | + "iserie-lines-color" => "auto" | |
1846 | + ) | |
1847 | + ); | |
1848 | + $instantPanel->{"params"}[] = $instantParam; | |
1849 | + | |
1850 | + $instantTab->{"panels"}[] = $instantPanel; | |
1851 | + | |
1852 | + $instantPlotInput->{"tabs"}[] = $instantTab; | |
1853 | + | |
1854 | + | |
1855 | + return $instantPlotInput; | |
1856 | + } | |
1691 | 1857 | } |
1692 | 1858 | ?> |
1693 | 1859 | \ No newline at end of file |
... | ... |
src/InputOutput/IHMImpl/Tools/IHMPlotContextFileClass.php
... | ... | @@ -83,6 +83,9 @@ class IHMPlotContextFileClass { |
83 | 83 | $panelContext['plotArea']['width'] = intval($plotAreaNode->getAttribute('width')); |
84 | 84 | } |
85 | 85 | |
86 | + //hasSpectro | |
87 | + $panelContext['plotArea']['hasSpectro'] = ($plotAreaNode->getAttribute('hasSpectro') == "true"); | |
88 | + | |
86 | 89 | //<axis> |
87 | 90 | $panelContext['plotArea']['axes'] = array(); |
88 | 91 | |
... | ... |