mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1469 Add checkbox for legend visibility
This commit is contained in:
parent
764a68c032
commit
4204d49f30
@ -26,6 +26,8 @@
|
||||
|
||||
#include "RiuFlowCharacteristicsPlot.h"
|
||||
|
||||
#include "cafPdmUiCheckBoxEditor.h"
|
||||
|
||||
#include <cmath> // Needed for HUGE_VAL on Linux
|
||||
|
||||
|
||||
@ -57,6 +59,8 @@ RimFlowCharacteristicsPlot::RimFlowCharacteristicsPlot()
|
||||
CAF_PDM_InitFieldNoDefault(&m_timeStepSelectionType, "TimeSelectionType", "Time Steps", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&m_selectedTimeSteps, "SelectedTimeSteps", "", "", "", "");
|
||||
|
||||
CAF_PDM_InitField(&m_showLegend, "ShowLegend", true, "Legend", "", "", "");
|
||||
|
||||
this->m_showWindow = false;
|
||||
setAsPlotMdiWindow();
|
||||
}
|
||||
@ -191,6 +195,8 @@ void RimFlowCharacteristicsPlot::defineUiOrdering(QString uiConfigName, caf::Pdm
|
||||
|
||||
if (m_timeStepSelectionType == SELECT_AVAILABLE) uiOrdering.add(&m_selectedTimeSteps);
|
||||
|
||||
uiOrdering.add(&m_showLegend);
|
||||
|
||||
uiOrdering.skipRemainingFields();
|
||||
}
|
||||
|
||||
@ -210,7 +216,6 @@ void RimFlowCharacteristicsPlot::zoomAll()
|
||||
if (m_flowCharPlotWidget) m_flowCharPlotWidget->zoomAll();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -229,7 +234,6 @@ void RimFlowCharacteristicsPlot::fieldChangedByUi(const caf::PdmFieldHandle* cha
|
||||
this->loadDataAndUpdate();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -246,8 +250,6 @@ QImage RimFlowCharacteristicsPlot::snapshotWindowContent()
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -299,6 +301,7 @@ void RimFlowCharacteristicsPlot::loadDataAndUpdate()
|
||||
flowCharResults.m_sweepEfficiencyCurve.second);
|
||||
}
|
||||
|
||||
m_flowCharPlotWidget->showLegend(m_showLegend());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -86,6 +86,7 @@ private:
|
||||
caf::PdmPtrField<RimFlowDiagSolution*> m_flowDiagSolution;
|
||||
caf::PdmField<caf::AppEnum<TimeSelectionType> > m_timeStepSelectionType;
|
||||
caf::PdmField<std::vector<int> > m_selectedTimeSteps;
|
||||
caf::PdmField<bool> m_showLegend;
|
||||
|
||||
std::vector<int> m_currentlyPlottedTimeSteps;
|
||||
|
||||
|
@ -65,9 +65,6 @@ RiuFlowCharacteristicsPlot::RiuFlowCharacteristicsPlot(RimFlowCharacteristicsPlo
|
||||
this->setPalette(pal);
|
||||
|
||||
m_lorenzPlot = new QwtPlot(this);
|
||||
QwtLegend* legend = new QwtLegend(this);
|
||||
m_lorenzPlot->insertLegend(legend, QwtPlot::BottomLegend);
|
||||
|
||||
m_flowCapVsStorageCapPlot = new QwtPlot(this);
|
||||
m_sweepEffPlot = new QwtPlot(this);
|
||||
|
||||
@ -238,6 +235,23 @@ void RiuFlowCharacteristicsPlot::zoomAll()
|
||||
zoomAllInPlot(m_flowCapVsStorageCapPlot);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuFlowCharacteristicsPlot::showLegend(bool show)
|
||||
{
|
||||
if (show)
|
||||
{
|
||||
// Will be released in plot destructor or when a new legend is set
|
||||
QwtLegend* legend = new QwtLegend(m_lorenzPlot);
|
||||
m_lorenzPlot->insertLegend(legend, QwtPlot::BottomLegend);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_lorenzPlot->insertLegend(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -57,6 +57,8 @@ public:
|
||||
void removeAllCurves();
|
||||
void zoomAll();
|
||||
|
||||
void showLegend(bool show);
|
||||
|
||||
RimFlowCharacteristicsPlot* ownerPlotDefinition();
|
||||
virtual RimViewWindow* ownerViewWindow() const override;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user