mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-09 23:16:00 -06:00
Merge with branch 'dev'
This commit is contained in:
commit
c3eb692afe
@ -10,6 +10,7 @@ ${CEE_CURRENT_LIST_DIR}RicNewSummaryPlotFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicNewSummaryCurveFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicNewSummaryCurveFilterFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicViewZoomAllFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicSummaryCurveSwitchAxisFeature.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
@ -17,6 +18,7 @@ ${CEE_CURRENT_LIST_DIR}RicNewSummaryPlotFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicNewSummaryCurveFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicNewSummaryCurveFilterFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicViewZoomAllFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicSummaryCurveSwitchAxisFeature.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
@ -0,0 +1,111 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2016- Statoil ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RicSummaryCurveSwitchAxisFeature.h"
|
||||
|
||||
#include "RimSummaryCurve.h"
|
||||
#include "RimSummaryCurveFilter.h"
|
||||
#include "RimSummaryPlot.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicSummaryCurveSwitchAxisFeature, "RicSummaryCurveSwitchAxisFeature");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicSummaryCurveSwitchAxisFeature::isCommandEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSummaryCurveSwitchAxisFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
RimSummaryCurve* summaryCurve = RicSummaryCurveSwitchAxisFeature::selectedSummaryCurve();
|
||||
RimSummaryCurveFilter* summaryCurveFilter = RicSummaryCurveSwitchAxisFeature::selectedSummaryCurveFilter();
|
||||
if (summaryCurve)
|
||||
{
|
||||
RimDefines::PlotAxis plotAxis = summaryCurve->associatedPlotAxis();
|
||||
|
||||
if (plotAxis == RimDefines::PLOT_AXIS_LEFT)
|
||||
{
|
||||
summaryCurve->setPlotAxis(RimDefines::PLOT_AXIS_RIGHT);
|
||||
}
|
||||
else
|
||||
{
|
||||
summaryCurve->setPlotAxis(RimDefines::PLOT_AXIS_LEFT);
|
||||
}
|
||||
|
||||
summaryCurve->updateQwtPlotAxis();
|
||||
summaryCurve->updateConnectedEditors();
|
||||
|
||||
RimSummaryPlot* plot = nullptr;
|
||||
summaryCurve->firstAncestorOrThisOfType(plot);
|
||||
if (plot) plot->updateAxes();
|
||||
}
|
||||
else if (summaryCurveFilter)
|
||||
{
|
||||
RimDefines::PlotAxis plotAxis = summaryCurveFilter->associatedPlotAxis();
|
||||
|
||||
if (plotAxis == RimDefines::PLOT_AXIS_LEFT)
|
||||
{
|
||||
summaryCurveFilter->setPlotAxis(RimDefines::PLOT_AXIS_RIGHT);
|
||||
}
|
||||
else
|
||||
{
|
||||
summaryCurveFilter->setPlotAxis(RimDefines::PLOT_AXIS_LEFT);
|
||||
}
|
||||
|
||||
summaryCurveFilter->updateConnectedEditors();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSummaryCurveSwitchAxisFeature::setupActionLook(QAction* actionToSetup)
|
||||
{
|
||||
actionToSetup->setText("Switch Plot Axis");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryCurve* RicSummaryCurveSwitchAxisFeature::selectedSummaryCurve()
|
||||
{
|
||||
std::vector<RimSummaryCurve*> selection;
|
||||
caf::SelectionManager::instance()->objectsByType(&selection);
|
||||
return selection.size() > 0 ? selection[0] : nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryCurveFilter* RicSummaryCurveSwitchAxisFeature::selectedSummaryCurveFilter()
|
||||
{
|
||||
std::vector<RimSummaryCurveFilter*> selection;
|
||||
caf::SelectionManager::instance()->objectsByType(&selection);
|
||||
return selection.size() > 0 ? selection[0] : nullptr;
|
||||
}
|
||||
|
@ -0,0 +1,41 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2016- Statoil ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
class RimSummaryCurve;
|
||||
class RimSummaryCurveFilter;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicSummaryCurveSwitchAxisFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
protected:
|
||||
// Overrides
|
||||
virtual bool isCommandEnabled() override;
|
||||
virtual void onActionTriggered( bool isChecked ) override;
|
||||
virtual void setupActionLook( QAction* actionToSetup ) override;
|
||||
|
||||
private:
|
||||
static RimSummaryCurve* selectedSummaryCurve();
|
||||
static RimSummaryCurveFilter* selectedSummaryCurveFilter();
|
||||
};
|
@ -92,6 +92,9 @@ ${CEE_CURRENT_LIST_DIR}RimPlotCurve.h
|
||||
${CEE_CURRENT_LIST_DIR}RimSummaryCurveAppearanceCalculator.h
|
||||
${CEE_CURRENT_LIST_DIR}RimEclipseInputCaseOpm.h
|
||||
${CEE_CURRENT_LIST_DIR}RimIntersectionBox.h
|
||||
${CEE_CURRENT_LIST_DIR}RimSummaryYAxisProperties.h
|
||||
${CEE_CURRENT_LIST_DIR}RimSummaryCurvesCalculator.h
|
||||
${CEE_CURRENT_LIST_DIR}RimSummaryTimeAxisProperties.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
@ -182,6 +185,9 @@ ${CEE_CURRENT_LIST_DIR}RimPlotCurve.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimSummaryCurveAppearanceCalculator.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimEclipseInputCaseOpm.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimIntersectionBox.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimSummaryYAxisProperties.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimSummaryCurvesCalculator.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimSummaryTimeAxisProperties.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
@ -280,6 +280,7 @@ QStringList RimContextCommandBuilder::commandsFromSelection()
|
||||
{
|
||||
commandIds << "RicNewSummaryCurveFilterFeature";
|
||||
commandIds << "RicNewSummaryCurveFeature";
|
||||
commandIds << "RicSummaryCurveSwitchAxisFeature";
|
||||
commandIds << "Separator";
|
||||
commandIds << "RicDeleteItemFeature";
|
||||
}
|
||||
@ -287,6 +288,7 @@ QStringList RimContextCommandBuilder::commandsFromSelection()
|
||||
{
|
||||
commandIds << "RicNewSummaryCurveFilterFeature";
|
||||
commandIds << "RicNewSummaryCurveFeature";
|
||||
commandIds << "RicSummaryCurveSwitchAxisFeature";
|
||||
commandIds << "Separator";
|
||||
commandIds << "RicDeleteItemFeature";
|
||||
}
|
||||
|
@ -52,6 +52,16 @@ namespace caf
|
||||
|
||||
setDefault(RimDefines::UNIT_METER);
|
||||
}
|
||||
|
||||
template<>
|
||||
void caf::AppEnum< RimDefines::PlotAxis >::setUp()
|
||||
{
|
||||
addItem(RimDefines::PLOT_AXIS_LEFT, "PLOT_AXIS_LEFT", "Left");
|
||||
addItem(RimDefines::PLOT_AXIS_RIGHT, "PLOT_AXIS_RIGHT", "Right");
|
||||
|
||||
setDefault(RimDefines::PLOT_AXIS_LEFT);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -80,5 +80,17 @@ public:
|
||||
};
|
||||
|
||||
static double feetPerMeter() { return 3.2808399; }
|
||||
|
||||
|
||||
// Defines relate to plotting
|
||||
|
||||
enum PlotAxis
|
||||
{
|
||||
PLOT_AXIS_LEFT,
|
||||
PLOT_AXIS_RIGHT
|
||||
};
|
||||
|
||||
static double minimumDefaultValuePlot() { return - 10.0; }
|
||||
static double maximumDefaultValuePlot() { return 100.0; }
|
||||
};
|
||||
|
||||
|
@ -76,11 +76,11 @@ RimEclipseCase::RimEclipseCase()
|
||||
|
||||
m_matrixModelResults = new RimReservoirCellResultsStorage;
|
||||
m_matrixModelResults.uiCapability()->setUiHidden(true);
|
||||
m_matrixModelResults.uiCapability()->setUiChildrenHidden(true);
|
||||
m_matrixModelResults.uiCapability()->setUiTreeChildrenHidden(true);
|
||||
|
||||
m_fractureModelResults = new RimReservoirCellResultsStorage;
|
||||
m_fractureModelResults.uiCapability()->setUiHidden(true);
|
||||
m_fractureModelResults.uiCapability()->setUiChildrenHidden(true);
|
||||
m_fractureModelResults.uiCapability()->setUiTreeChildrenHidden(true);
|
||||
|
||||
this->setReservoirData( NULL );
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ bool RimEclipseFaultColors::hasValidCustomResult()
|
||||
void RimEclipseFaultColors::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/)
|
||||
{
|
||||
if (m_customFaultResultColors()->ternaryLegendConfig()
|
||||
&& !m_customFaultResultColors()->ternaryLegendConfig.uiCapability()->isUiChildrenHidden(uiConfigName))
|
||||
&& !m_customFaultResultColors()->ternaryLegendConfig.uiCapability()->isUiTreeChildrenHidden(uiConfigName))
|
||||
{
|
||||
uiTreeOrdering.add(m_customFaultResultColors()->ternaryLegendConfig());
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ RimEclipsePropertyFilter::RimEclipsePropertyFilter()
|
||||
// Set to hidden to avoid this item to been displayed as a child item
|
||||
// Fields in this object are displayed using defineUiOrdering()
|
||||
resultDefinition.uiCapability()->setUiHidden(true);
|
||||
resultDefinition.uiCapability()->setUiChildrenHidden(true);
|
||||
resultDefinition.uiCapability()->setUiTreeChildrenHidden(true);
|
||||
|
||||
CAF_PDM_InitField(&m_lowerBound, "LowerBound", 0.0, "Min", "", "", "");
|
||||
m_lowerBound.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName());
|
||||
|
@ -51,7 +51,7 @@ RimGeoMechPropertyFilter::RimGeoMechPropertyFilter()
|
||||
// Set to hidden to avoid this item to been displayed as a child item
|
||||
// Fields in this object are displayed using defineUiOrdering()
|
||||
resultDefinition.uiCapability()->setUiHidden(true);
|
||||
resultDefinition.uiCapability()->setUiChildrenHidden(true);
|
||||
resultDefinition.uiCapability()->setUiTreeChildrenHidden(true);
|
||||
|
||||
CAF_PDM_InitField(&lowerBound, "LowerBound", 0.0, "Min", "", "", "");
|
||||
lowerBound.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName());
|
||||
|
@ -92,7 +92,7 @@ RimIntersection::RimIntersection()
|
||||
|
||||
inputFromViewerEnabled = false;
|
||||
|
||||
uiCapability()->setUiChildrenHidden(true);
|
||||
uiCapability()->setUiTreeChildrenHidden(true);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -86,7 +86,7 @@ RimProject::RimProject(void)
|
||||
CAF_PDM_InitFieldNoDefault(&wellPathImport, "WellPathImport", "WellPathImport", "", "", "");
|
||||
wellPathImport = new RimWellPathImport();
|
||||
wellPathImport.uiCapability()->setUiHidden(true);
|
||||
wellPathImport.uiCapability()->setUiChildrenHidden(true);
|
||||
wellPathImport.uiCapability()->setUiTreeChildrenHidden(true);
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&mainPlotCollection, "MainPlotCollection", "Plots", "", "", "");
|
||||
mainPlotCollection.uiCapability()->setUiHidden(true);
|
||||
|
@ -19,22 +19,28 @@
|
||||
#include "RimSummaryCurve.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "RifReaderEclipseSummary.h"
|
||||
|
||||
#include "RigSummaryCaseData.h"
|
||||
|
||||
#include "RimDefines.h"
|
||||
#include "RimEclipseResultCase.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimSummaryCase.h"
|
||||
#include "RimSummaryCurveFilter.h"
|
||||
#include "RimSummaryFilter.h"
|
||||
#include "RimSummaryPlot.h"
|
||||
#include "RimSummaryPlotCollection.h"
|
||||
|
||||
#include "RiuLineSegmentQwtPlotCurve.h"
|
||||
#include "RiuSummaryQwtPlot.h"
|
||||
|
||||
#include "cafPdmUiComboBoxEditor.h"
|
||||
#include "cafPdmUiListEditor.h"
|
||||
#include "cafPdmUiTreeOrdering.h"
|
||||
#include "RiuLineSegmentQwtPlotCurve.h"
|
||||
|
||||
#include "qwt_date.h"
|
||||
#include "RimSummaryCase.h"
|
||||
#include "RigSummaryCaseData.h"
|
||||
#include "RimSummaryFilter.h"
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimSummaryAddress, "SummaryAddress");
|
||||
|
||||
@ -137,7 +143,7 @@ RimSummaryCurve::RimSummaryCurve()
|
||||
CAF_PDM_InitObject("Summary Curve", ":/SummaryCurve16x16.png", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_summaryCase, "SummaryCase", "Case", "", "", "");
|
||||
m_summaryCase.uiCapability()->setUiChildrenHidden(true);
|
||||
m_summaryCase.uiCapability()->setUiTreeChildrenHidden(true);
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_selectedVariableDisplayField, "SelectedVariableDisplayVar", "Vector", "", "", "");
|
||||
m_selectedVariableDisplayField.xmlCapability()->setIOWritable(false);
|
||||
@ -147,7 +153,7 @@ RimSummaryCurve::RimSummaryCurve()
|
||||
CAF_PDM_InitFieldNoDefault(&m_summaryFilter, "VarListFilter", "Filter", "", "", "");
|
||||
m_summaryFilter.xmlCapability()->setIOWritable(false);
|
||||
m_summaryFilter.xmlCapability()->setIOReadable(false);
|
||||
m_summaryFilter.uiCapability()->setUiChildrenHidden(true);
|
||||
m_summaryFilter.uiCapability()->setUiTreeChildrenHidden(true);
|
||||
m_summaryFilter.uiCapability()->setUiHidden(true);
|
||||
|
||||
m_summaryFilter = new RimSummaryFilter();
|
||||
@ -162,7 +168,9 @@ RimSummaryCurve::RimSummaryCurve()
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_curveVariable, "SummaryAddress", "SummaryAddress", "", "", "");
|
||||
m_curveVariable.uiCapability()->setUiHidden(true);
|
||||
m_curveVariable.uiCapability()->setUiChildrenHidden(true);
|
||||
m_curveVariable.uiCapability()->setUiTreeChildrenHidden(true);
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_plotAxis, "PlotAxis", "Axis", "", "", "");
|
||||
|
||||
m_curveVariable = new RimSummaryAddress;
|
||||
|
||||
@ -233,6 +241,35 @@ std::string RimSummaryCurve::unitName()
|
||||
return "";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<double> RimSummaryCurve::yPlotValues() const
|
||||
{
|
||||
std::vector<QDateTime> dateTimes;
|
||||
std::vector<double> values;
|
||||
|
||||
this->curveData(&dateTimes, &values);
|
||||
|
||||
return values;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryCurve::setPlotAxis(RimDefines::PlotAxis plotAxis)
|
||||
{
|
||||
m_plotAxis = plotAxis;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimDefines::PlotAxis RimSummaryCurve::associatedPlotAxis() const
|
||||
{
|
||||
return m_plotAxis();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -340,19 +377,25 @@ void RimSummaryCurve::onLoadDataAndUpdate()
|
||||
std::vector<QDateTime> dateTimes;
|
||||
std::vector<double> values;
|
||||
|
||||
RimSummaryPlot* plot = nullptr;
|
||||
firstAncestorOrThisOfType(plot);
|
||||
bool isLogCurve = plot->isLogarithmicScaleEnabled(this->associatedPlotAxis());
|
||||
|
||||
if(this->curveData(&dateTimes, &values))
|
||||
{
|
||||
m_qwtPlotCurve->setSamplesFromDateAndValues(dateTimes, values);
|
||||
m_qwtPlotCurve->setSamplesFromDateAndValues(dateTimes, values, isLogCurve);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_qwtPlotCurve->setSamplesFromDateAndValues(std::vector<QDateTime>(), std::vector<double>());
|
||||
m_qwtPlotCurve->setSamplesFromDateAndValues(std::vector<QDateTime>(), std::vector<double>(), isLogCurve);
|
||||
}
|
||||
|
||||
updateZoomInParentPlot();
|
||||
|
||||
if (m_parentQwtPlot) m_parentQwtPlot->replot();
|
||||
}
|
||||
|
||||
updateQwtPlotAxis();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -382,9 +425,28 @@ void RimSummaryCurve::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering&
|
||||
appearanceGroup->add(&m_addCaseNameToCurveName);
|
||||
}
|
||||
|
||||
uiOrdering.add(&m_plotAxis);
|
||||
|
||||
uiOrdering.setForgetRemainingFields(true); // For now.
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryCurve::updateQwtPlotAxis()
|
||||
{
|
||||
if (m_qwtPlotCurve)
|
||||
{
|
||||
if (this->associatedPlotAxis() == RimDefines::PLOT_AXIS_LEFT)
|
||||
{
|
||||
m_qwtPlotCurve->setYAxis(QwtPlot::yLeft);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_qwtPlotCurve->setYAxis(QwtPlot::yRight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@ -393,6 +455,10 @@ void RimSummaryCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedField,
|
||||
{
|
||||
this->RimPlotCurve::fieldChangedByUi(changedField,oldValue,newValue);
|
||||
|
||||
RimSummaryPlot* plot = nullptr;
|
||||
firstAncestorOrThisOfType(plot);
|
||||
CVF_ASSERT(plot);
|
||||
|
||||
if(changedField == &m_uiFilterResultSelection)
|
||||
{
|
||||
if (0 <= m_uiFilterResultSelection() && static_cast<size_t>(m_uiFilterResultSelection()) < summaryReader()->allResultAddresses().size())
|
||||
@ -406,27 +472,29 @@ void RimSummaryCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedField,
|
||||
|
||||
this->loadDataAndUpdate();
|
||||
|
||||
RimSummaryPlot* plot = nullptr;
|
||||
firstAncestorOrThisOfType(plot);
|
||||
plot->updateYAxisUnit();
|
||||
plot->updateAxes();
|
||||
}
|
||||
else if (&m_showCurve == changedField)
|
||||
{
|
||||
RimSummaryPlot* plot = nullptr;
|
||||
firstAncestorOrThisOfType(plot);
|
||||
plot->updateYAxisUnit();
|
||||
plot->updateAxes();
|
||||
}
|
||||
else if (changedField == &m_addCaseNameToCurveName)
|
||||
{
|
||||
this->uiCapability()->updateConnectedEditors();
|
||||
updateCurveName();
|
||||
}
|
||||
else if (changedField == &m_plotAxis)
|
||||
{
|
||||
updateQwtPlotAxis();
|
||||
|
||||
plot->updateAxes();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RifReaderEclipseSummary* RimSummaryCurve::summaryReader()
|
||||
RifReaderEclipseSummary* RimSummaryCurve::summaryReader() const
|
||||
{
|
||||
if (!m_summaryCase()) return nullptr;
|
||||
|
||||
@ -446,7 +514,7 @@ void RimSummaryCurve::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrderin
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimSummaryCurve::curveData(std::vector<QDateTime>* timeSteps, std::vector<double>* values)
|
||||
bool RimSummaryCurve::curveData(std::vector<QDateTime>* timeSteps, std::vector<double>* values) const
|
||||
{
|
||||
CVF_ASSERT(timeSteps && values);
|
||||
|
||||
|
@ -25,14 +25,16 @@
|
||||
#include "cafPdmPtrField.h"
|
||||
#include "cafPdmChildField.h"
|
||||
|
||||
#include "RimPlotCurve.h"
|
||||
#include "RifEclipseSummaryAddress.h"
|
||||
#include "RimDefines.h"
|
||||
#include "RimPlotCurve.h"
|
||||
|
||||
#include "cafAppEnum.h"
|
||||
|
||||
class RimSummaryCase;
|
||||
class RifReaderEclipseSummary;
|
||||
class RiuLineSegmentQwtPlotCurve;
|
||||
class RimSummaryCase;
|
||||
class RimSummaryFilter;
|
||||
class RiuLineSegmentQwtPlotCurve;
|
||||
|
||||
class RimSummaryAddress: public caf::PdmObject
|
||||
{
|
||||
@ -68,6 +70,7 @@ private:
|
||||
class RimSummaryCurve : public RimPlotCurve
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimSummaryCurve();
|
||||
virtual ~RimSummaryCurve();
|
||||
@ -79,6 +82,13 @@ public:
|
||||
RifEclipseSummaryAddress summaryAddress();
|
||||
void setSummaryAddress(const RifEclipseSummaryAddress& address);
|
||||
std::string unitName();
|
||||
|
||||
std::vector<double> yPlotValues() const;
|
||||
|
||||
void setPlotAxis(RimDefines::PlotAxis plotAxis);
|
||||
RimDefines::PlotAxis associatedPlotAxis() const;
|
||||
void updateQwtPlotAxis();
|
||||
|
||||
protected:
|
||||
// RimPlotCurve overrides
|
||||
|
||||
@ -87,8 +97,8 @@ protected:
|
||||
virtual void onLoadDataAndUpdate() override;
|
||||
|
||||
private:
|
||||
RifReaderEclipseSummary* summaryReader();
|
||||
bool curveData(std::vector<QDateTime>* timeSteps, std::vector<double>* values);
|
||||
RifReaderEclipseSummary* summaryReader() const;
|
||||
bool curveData(std::vector<QDateTime>* timeSteps, std::vector<double>* values) const;
|
||||
|
||||
// Overridden PDM methods
|
||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
|
||||
@ -96,15 +106,16 @@ private:
|
||||
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly);
|
||||
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
|
||||
|
||||
private:
|
||||
// Fields
|
||||
caf::PdmPtrField<RimSummaryCase*> m_summaryCase;
|
||||
caf::PdmChildField<RimSummaryAddress*> m_curveVariable;
|
||||
caf::PdmField<QString> m_selectedVariableDisplayField;
|
||||
caf::PdmField<bool> m_addCaseNameToCurveName;
|
||||
|
||||
caf::PdmField< caf::AppEnum< RimDefines::PlotAxis > > m_plotAxis;
|
||||
|
||||
// Filter fields
|
||||
caf::PdmChildField<RimSummaryFilter*> m_summaryFilter;
|
||||
caf::PdmField<int> m_uiFilterResultSelection;
|
||||
|
||||
};
|
||||
|
@ -29,6 +29,8 @@
|
||||
#include "RimProject.h"
|
||||
#include "RimSummaryCase.h"
|
||||
#include "RimSummaryCurve.h"
|
||||
#include "RimSummaryCurveAppearanceCalculator.h"
|
||||
#include "RimSummaryFilter.h"
|
||||
#include "RimSummaryPlot.h"
|
||||
#include "RimSummaryPlotCollection.h"
|
||||
|
||||
@ -37,11 +39,8 @@
|
||||
|
||||
#include "WellLogCommands/RicWellLogPlotCurveFeatureImpl.h"
|
||||
|
||||
#include "cafPdmUiComboBoxEditor.h"
|
||||
#include "cafPdmUiListEditor.h"
|
||||
#include "cafPdmUiPushButtonEditor.h"
|
||||
#include "cafPdmUiTreeOrdering.h"
|
||||
#include "RimSummaryCurveAppearanceCalculator.h"
|
||||
|
||||
|
||||
QTextStream& operator << (QTextStream& str, const std::vector<RifEclipseSummaryAddress>& sobj)
|
||||
@ -67,7 +66,7 @@ RimSummaryCurveFilter::RimSummaryCurveFilter()
|
||||
CAF_PDM_InitObject("Curve Filter", ":/SummaryCurveFilter16x16.png", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_selectedSummaryCases, "SummaryCases", "Cases", "", "", "");
|
||||
m_selectedSummaryCases.uiCapability()->setUiChildrenHidden(true);
|
||||
m_selectedSummaryCases.uiCapability()->setUiTreeChildrenHidden(true);
|
||||
m_selectedSummaryCases.uiCapability()->setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName());
|
||||
m_selectedSummaryCases.uiCapability()->setAutoAddingOptionFromValue(false);
|
||||
m_selectedSummaryCases.xmlCapability()->setIOWritable(false);
|
||||
@ -81,7 +80,7 @@ RimSummaryCurveFilter::RimSummaryCurveFilter()
|
||||
m_selectedVariableDisplayField.uiCapability()->setUiHidden(true);
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_summaryFilter, "VarListFilter", "Filter", "", "", "");
|
||||
m_summaryFilter.uiCapability()->setUiChildrenHidden(true);
|
||||
m_summaryFilter.uiCapability()->setUiTreeChildrenHidden(true);
|
||||
m_summaryFilter.uiCapability()->setUiHidden(true);
|
||||
m_summaryFilter = new RimSummaryFilter();
|
||||
|
||||
@ -94,7 +93,7 @@ RimSummaryCurveFilter::RimSummaryCurveFilter()
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_curves, "FilteredCurves", "Filtered Curves", "", "", "");
|
||||
m_curves.uiCapability()->setUiHidden(true);
|
||||
m_curves.uiCapability()->setUiChildrenHidden(false);
|
||||
m_curves.uiCapability()->setUiTreeChildrenHidden(false);
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_applyButtonField, "ApplySelection", "Apply", "", "", "");
|
||||
m_applyButtonField.xmlCapability()->setIOWritable(false);
|
||||
@ -114,6 +113,7 @@ RimSummaryCurveFilter::RimSummaryCurveFilter()
|
||||
CAF_PDM_InitFieldNoDefault(&m_groupAppearanceType, "GroupAppearanceType", "Group", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&m_regionAppearanceType, "RegionAppearanceType", "Region", "", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_plotAxis, "PlotAxis", "Axis", "", "", "");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -218,7 +218,9 @@ void RimSummaryCurveFilter::defineUiOrdering(QString uiConfigName, caf::PdmUiOrd
|
||||
m_regionAppearanceType.uiCapability()->setUiReadOnly(m_useAutoAppearanceAssignment);
|
||||
}
|
||||
|
||||
uiOrdering.add(&m_plotAxis);
|
||||
uiOrdering.add(&m_applyButtonField);
|
||||
|
||||
uiOrdering.setForgetRemainingFields(true);
|
||||
}
|
||||
|
||||
@ -239,7 +241,7 @@ void RimSummaryCurveFilter::fieldChangedByUi(const caf::PdmFieldHandle* changedF
|
||||
|
||||
RimSummaryPlot* plot = nullptr;
|
||||
firstAncestorOrThisOfType(plot);
|
||||
plot->updateYAxisUnit();
|
||||
plot->updateAxes();
|
||||
}
|
||||
else if (changedField == &m_showCurves)
|
||||
{
|
||||
@ -249,6 +251,10 @@ void RimSummaryCurveFilter::fieldChangedByUi(const caf::PdmFieldHandle* changedF
|
||||
}
|
||||
if (m_parentQwtPlot) m_parentQwtPlot->replot();
|
||||
}
|
||||
else if (changedField == &m_plotAxis)
|
||||
{
|
||||
updatePlotAxisForCurves();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -371,6 +377,22 @@ void RimSummaryCurveFilter::defineEditorAttribute(const caf::PdmFieldHandle* fie
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryCurveFilter::updatePlotAxisForCurves()
|
||||
{
|
||||
for (RimSummaryCurve* curve : m_curves)
|
||||
{
|
||||
curve->setPlotAxis(m_plotAxis());
|
||||
curve->updateQwtPlotAxis();
|
||||
}
|
||||
|
||||
RimSummaryPlot* plot = nullptr;
|
||||
firstAncestorOrThisOfType(plot);
|
||||
plot->updateAxes();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -493,6 +515,25 @@ void RimSummaryCurveFilter::updateCaseNameHasChanged()
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimDefines::PlotAxis RimSummaryCurveFilter::associatedPlotAxis() const
|
||||
{
|
||||
return m_plotAxis();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryCurveFilter::setPlotAxis(RimDefines::PlotAxis plotAxis)
|
||||
{
|
||||
m_plotAxis = plotAxis;
|
||||
updateConnectedEditors();
|
||||
|
||||
updatePlotAxisForCurves();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -25,20 +25,26 @@
|
||||
#include "cafPdmPtrField.h"
|
||||
#include "cafPdmChildField.h"
|
||||
#include "cafPdmChildArrayField.h"
|
||||
|
||||
#include "RimPlotCurve.h"
|
||||
#include "RifEclipseSummaryAddress.h"
|
||||
#include "cafAppEnum.h"
|
||||
|
||||
#include "RimSummaryCurve.h"
|
||||
#include "RimSummaryFilter.h"
|
||||
#include "cafPdmPtrArrayField.h"
|
||||
|
||||
#include "RifEclipseSummaryAddress.h"
|
||||
#include "RimDefines.h"
|
||||
#include "RimSummaryCurveAppearanceCalculator.h"
|
||||
|
||||
class RimSummaryCase;
|
||||
#include "qwt_plot.h"
|
||||
|
||||
class QwtPlot;
|
||||
class QwtPlotCurve;
|
||||
class RifReaderEclipseSummary;
|
||||
class RimSummaryCase;
|
||||
class RimSummaryCurve;
|
||||
class RimSummaryFilter;
|
||||
class RiuLineSegmentQwtPlotCurve;
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
|
||||
Q_DECLARE_METATYPE(RifEclipseSummaryAddress);
|
||||
|
||||
//==================================================================================================
|
||||
@ -48,6 +54,7 @@ Q_DECLARE_METATYPE(RifEclipseSummaryAddress);
|
||||
class RimSummaryCurveFilter : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimSummaryCurveFilter();
|
||||
virtual ~RimSummaryCurveFilter();
|
||||
@ -64,6 +71,9 @@ public:
|
||||
|
||||
void updateCaseNameHasChanged();
|
||||
|
||||
RimDefines::PlotAxis associatedPlotAxis() const;
|
||||
void setPlotAxis(RimDefines::PlotAxis plotAxis);
|
||||
|
||||
private:
|
||||
void syncCurvesFromUiSelection();
|
||||
void createCurvesFromCurveDefinitions(const std::set<std::pair<RimSummaryCase*, RifEclipseSummaryAddress> >& curveDefinitions);
|
||||
@ -81,7 +91,9 @@ private:
|
||||
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly);
|
||||
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
|
||||
void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute * attribute) override;
|
||||
void updatePlotAxisForCurves();
|
||||
|
||||
private:
|
||||
QPointer<QwtPlot> m_parentQwtPlot;
|
||||
|
||||
// Fields
|
||||
@ -90,6 +102,9 @@ private:
|
||||
caf::PdmChildArrayField<RimSummaryCurve*> m_curves;
|
||||
|
||||
caf::PdmField<QString> m_selectedVariableDisplayField;
|
||||
|
||||
caf::PdmField< caf::AppEnum< RimDefines::PlotAxis > > m_plotAxis;
|
||||
|
||||
|
||||
// Filter fields
|
||||
caf::PdmChildField<RimSummaryFilter*> m_summaryFilter;
|
||||
@ -105,6 +120,5 @@ private:
|
||||
caf::PdmField< AppearanceTypeAppEnum > m_wellAppearanceType;
|
||||
caf::PdmField< AppearanceTypeAppEnum > m_groupAppearanceType;
|
||||
caf::PdmField< AppearanceTypeAppEnum > m_regionAppearanceType;
|
||||
|
||||
};
|
||||
|
||||
|
290
ApplicationCode/ProjectDataModel/RimSummaryCurvesCalculator.cpp
Normal file
290
ApplicationCode/ProjectDataModel/RimSummaryCurvesCalculator.cpp
Normal file
@ -0,0 +1,290 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2016 Statoil ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RimSummaryCurvesCalculator.h"
|
||||
|
||||
#include "RigStatisticsCalculator.h"
|
||||
|
||||
#include "RimDefines.h"
|
||||
#include "RimSummaryCurve.h"
|
||||
#include "RimSummaryCurveFilter.h"
|
||||
#include "RimSummaryYAxisProperties.h"
|
||||
|
||||
#include "RiuSummaryQwtPlot.h"
|
||||
|
||||
#include "qwt_plot_curve.h"
|
||||
#include "qwt_scale_draw.h"
|
||||
#include "qwt_scale_engine.h"
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <cmath>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// e format as [-]9.9e[+|-]999
|
||||
// E format as[-]9.9E[+| -]999
|
||||
// f format as[-]9.9
|
||||
// g use e or f format, whichever is the most concise
|
||||
// G use E or f format, whichever is the most concise
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class DecimalScaleDraw : public QwtScaleDraw
|
||||
{
|
||||
public:
|
||||
virtual QwtText label(double value) const override
|
||||
{
|
||||
if (qFuzzyCompare(value + 1.0, 1.0))
|
||||
value = 0.0;
|
||||
|
||||
int precision = DecimalScaleDraw::calculatePrecision(value);
|
||||
|
||||
return QString::number(value, 'f', precision);
|
||||
}
|
||||
|
||||
private:
|
||||
static int calculatePrecision(double value)
|
||||
{
|
||||
double absVal = fabs(value);
|
||||
|
||||
const int numberOfDigits = 2;
|
||||
|
||||
if (1e-16 < absVal && absVal < 1.0e3)
|
||||
{
|
||||
int logVal = static_cast<int>(log10(absVal));
|
||||
int numDigitsAfterPoint = abs(logVal - numberOfDigits);
|
||||
return numDigitsAfterPoint;
|
||||
}
|
||||
else
|
||||
{
|
||||
return numberOfDigits;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class ScientificScaleDraw : public QwtScaleDraw
|
||||
{
|
||||
|
||||
public:
|
||||
virtual QwtText label(double value) const override
|
||||
{
|
||||
if (qFuzzyCompare(value + 1.0, 1.0))
|
||||
value = 0.0;
|
||||
|
||||
return QString::number(value, 'e', 2);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryCurvesCalculator::RimSummaryCurvesCalculator(RimSummaryYAxisProperties* axisProperties,
|
||||
const std::vector<RimSummaryCurve*>& curves,
|
||||
const std::vector<RimSummaryCurveFilter*>& curveFilters)
|
||||
: m_axisProperties(axisProperties),
|
||||
m_singleCurves(curves),
|
||||
m_curveFilters(curveFilters)
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryCurvesCalculator::RimSummaryCurvesCalculator(RimSummaryYAxisProperties* axisProperties, const std::vector<RimSummaryCurve*>& curves)
|
||||
: m_axisProperties(axisProperties),
|
||||
m_singleCurves(curves)
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryCurvesCalculator::applyPropertiesToPlot(RiuSummaryQwtPlot* m_qwtPlot)
|
||||
{
|
||||
if (!m_qwtPlot) return;
|
||||
|
||||
{
|
||||
QString axisTitle = m_axisProperties->customTitle;
|
||||
if (m_axisProperties->isAutoTitle) axisTitle = autoAxisTitle();
|
||||
|
||||
QwtText axisTitleY = m_qwtPlot->axisTitle(m_axisProperties->axis());
|
||||
|
||||
QFont axisTitleYFont = axisTitleY.font();
|
||||
axisTitleYFont.setBold(true);
|
||||
axisTitleYFont.setPixelSize(m_axisProperties->fontSize);
|
||||
axisTitleY.setFont(axisTitleYFont);
|
||||
|
||||
axisTitleY.setText(axisTitle);
|
||||
m_qwtPlot->setAxisTitle(m_axisProperties->axis(), axisTitleY);
|
||||
}
|
||||
|
||||
{
|
||||
QFont yAxisFont = m_qwtPlot->axisFont(m_axisProperties->axis());
|
||||
yAxisFont.setBold(false);
|
||||
yAxisFont.setPixelSize(m_axisProperties->fontSize);
|
||||
m_qwtPlot->setAxisFont(m_axisProperties->axis(), yAxisFont);
|
||||
}
|
||||
|
||||
{
|
||||
if (m_axisProperties->numberFormat == RimSummaryYAxisProperties::NUMBER_FORMAT_AUTO)
|
||||
{
|
||||
m_qwtPlot->setAxisScaleDraw(m_axisProperties->axis(), new QwtScaleDraw);
|
||||
}
|
||||
else if (m_axisProperties->numberFormat == RimSummaryYAxisProperties::NUMBER_FORMAT_DECIMAL)
|
||||
{
|
||||
m_qwtPlot->setAxisScaleDraw(m_axisProperties->axis(), new DecimalScaleDraw);
|
||||
}
|
||||
else if (m_axisProperties->numberFormat == RimSummaryYAxisProperties::NUMBER_FORMAT_SCIENTIFIC)
|
||||
{
|
||||
m_qwtPlot->setAxisScaleDraw(m_axisProperties->axis(), new ScientificScaleDraw());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
{
|
||||
if (m_axisProperties->isLogarithmicScaleEnabled)
|
||||
{
|
||||
QwtLogScaleEngine* currentScaleEngine = dynamic_cast<QwtLogScaleEngine*>(m_qwtPlot->axisScaleEngine(m_axisProperties->axis()));
|
||||
if (!currentScaleEngine)
|
||||
{
|
||||
m_qwtPlot->setAxisScaleEngine(m_axisProperties->axis(), new QwtLogScaleEngine);
|
||||
m_qwtPlot->setAxisMaxMinor(m_axisProperties->axis(), 5);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
QwtLinearScaleEngine* currentScaleEngine = dynamic_cast<QwtLinearScaleEngine*>(m_qwtPlot->axisScaleEngine(m_axisProperties->axis()));
|
||||
if (!currentScaleEngine)
|
||||
{
|
||||
m_qwtPlot->setAxisScaleEngine(m_axisProperties->axis(), new QwtLinearScaleEngine);
|
||||
m_qwtPlot->setAxisMaxMinor(m_axisProperties->axis(), 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimSummaryCurvesCalculator::autoAxisTitle() const
|
||||
{
|
||||
std::set<std::string> unitNames;
|
||||
|
||||
for (RimSummaryCurve* rimCurve : m_singleCurves)
|
||||
{
|
||||
if (rimCurve->isCurveVisible()) unitNames.insert(rimCurve->unitName());
|
||||
}
|
||||
|
||||
for (RimSummaryCurveFilter* curveFilter : m_curveFilters)
|
||||
{
|
||||
std::set<std::string> filterUnitNames = curveFilter->unitNames();
|
||||
unitNames.insert(filterUnitNames.begin(), filterUnitNames.end());
|
||||
}
|
||||
|
||||
QString assembledYAxisText;
|
||||
|
||||
for (const std::string& unitName : unitNames)
|
||||
{
|
||||
assembledYAxisText += "[" + QString::fromStdString(unitName) + "] ";
|
||||
}
|
||||
|
||||
return assembledYAxisText;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryCurvesCalculator::computeYRange(double* min, double* max) const
|
||||
{
|
||||
double minValue = HUGE_VAL;
|
||||
double maxValue = -HUGE_VAL;
|
||||
|
||||
for (RimSummaryCurve* curve : m_singleCurves)
|
||||
{
|
||||
double minCurveValue = HUGE_VAL;
|
||||
double maxCurveValue = -HUGE_VAL;
|
||||
|
||||
if (curve->isCurveVisible() && curveValueRangeY(curve->qwtPlotCurve(), &minCurveValue, &maxCurveValue))
|
||||
{
|
||||
if (minCurveValue < minValue)
|
||||
{
|
||||
minValue = minCurveValue;
|
||||
}
|
||||
|
||||
if (maxCurveValue > maxValue)
|
||||
{
|
||||
maxValue = maxCurveValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (minValue == HUGE_VAL)
|
||||
{
|
||||
minValue = RimDefines::minimumDefaultValuePlot();
|
||||
maxValue = RimDefines::maximumDefaultValuePlot();
|
||||
}
|
||||
|
||||
if (m_axisProperties->isLogarithmicScaleEnabled)
|
||||
{
|
||||
// For logarithmic auto scaling, compute positive curve value closest to zero and use
|
||||
// this value as the plot visible minimum
|
||||
|
||||
double pos = HUGE_VAL;
|
||||
double neg = -HUGE_VAL;
|
||||
|
||||
for (RimSummaryCurve* curve : m_singleCurves)
|
||||
{
|
||||
if (curve->isCurveVisible())
|
||||
{
|
||||
RigStatisticsCalculator::posNegClosestToZero(curve->yPlotValues(), pos, neg);
|
||||
}
|
||||
}
|
||||
|
||||
if (pos != HUGE_VAL)
|
||||
{
|
||||
minValue = pos;
|
||||
}
|
||||
}
|
||||
|
||||
*min = minValue;
|
||||
*max = maxValue;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimSummaryCurvesCalculator::curveValueRangeY(const QwtPlotCurve* qwtCurve, double* min, double* max) const
|
||||
{
|
||||
if (!qwtCurve) return false;
|
||||
|
||||
if (qwtCurve->data()->size() < 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
*min = qwtCurve->minYValue();
|
||||
*max = qwtCurve->maxYValue();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -0,0 +1,54 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2016 Statoil ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <QString>
|
||||
|
||||
class RimSummaryCurve;
|
||||
class RimSummaryCurveFilter;
|
||||
class RimSummaryYAxisProperties;
|
||||
|
||||
class RiuSummaryQwtPlot;
|
||||
|
||||
class QwtPlotCurve;
|
||||
|
||||
class RimSummaryCurvesCalculator
|
||||
{
|
||||
public:
|
||||
RimSummaryCurvesCalculator(RimSummaryYAxisProperties* axisProperties,
|
||||
const std::vector<RimSummaryCurve*>& curves,
|
||||
const std::vector<RimSummaryCurveFilter*>& curveFilters);
|
||||
|
||||
RimSummaryCurvesCalculator(RimSummaryYAxisProperties* axisProperties,
|
||||
const std::vector<RimSummaryCurve*>& curves);
|
||||
|
||||
void applyPropertiesToPlot(RiuSummaryQwtPlot* qwtPlot);
|
||||
void computeYRange(double* min, double* max) const;
|
||||
|
||||
private:
|
||||
QString autoAxisTitle() const;
|
||||
bool curveValueRangeY(const QwtPlotCurve* qwtCurve, double* min, double* max) const;
|
||||
|
||||
private:
|
||||
RimSummaryYAxisProperties* m_axisProperties;
|
||||
std::vector<RimSummaryCurve*> m_singleCurves;
|
||||
std::vector<RimSummaryCurveFilter*> m_curveFilters;
|
||||
};
|
||||
|
@ -22,7 +22,10 @@
|
||||
|
||||
#include "RimSummaryCurve.h"
|
||||
#include "RimSummaryCurveFilter.h"
|
||||
#include "RimSummaryCurvesCalculator.h"
|
||||
#include "RimSummaryPlotCollection.h"
|
||||
#include "RimSummaryTimeAxisProperties.h"
|
||||
#include "RimSummaryYAxisProperties.h"
|
||||
|
||||
#include "RiuMainPlotWindow.h"
|
||||
#include "RiuSelectionColors.h"
|
||||
@ -31,9 +34,12 @@
|
||||
#include "cvfBase.h"
|
||||
#include "cvfColor3.h"
|
||||
|
||||
#include "cafPdmUiTreeOrdering.h"
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QRectF>
|
||||
|
||||
#include "qwt_plot_curve.h"
|
||||
#include "qwt_plot_renderer.h"
|
||||
|
||||
|
||||
@ -51,13 +57,33 @@ RimSummaryPlot::RimSummaryPlot()
|
||||
CAF_PDM_InitField(&m_userName, "PlotDescription", QString("Summary Plot"), "Name", "", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_curveFilters, "SummaryCurveFilters", "", "", "", "");
|
||||
m_curveFilters.uiCapability()->setUiHidden(true);
|
||||
m_curveFilters.uiCapability()->setUiTreeHidden(true);
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_curves, "SummaryCurves", "", "", "", "");
|
||||
m_curves.uiCapability()->setUiHidden(true);
|
||||
m_curves.uiCapability()->setUiTreeHidden(true);
|
||||
|
||||
CAF_PDM_InitField(&m_visibleWindow, "VisibleWindow", std::vector<float>(), "Visible Display Window", "", "", "");
|
||||
m_visibleWindow.uiCapability()->setUiHidden(true);
|
||||
CAF_PDM_InitFieldNoDefault(&m_leftYAxisProperties, "LeftYAxisProperties", "Left Y Axis", "", "", "");
|
||||
m_leftYAxisProperties.uiCapability()->setUiTreeHidden(true);
|
||||
|
||||
m_leftYAxisPropertiesObject = std::unique_ptr<RimSummaryYAxisProperties>(new RimSummaryYAxisProperties);
|
||||
m_leftYAxisPropertiesObject->setNameAndAxis("Left Y-Axis", QwtPlot::yLeft);
|
||||
m_leftYAxisProperties = m_leftYAxisPropertiesObject.get();
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_rightYAxisProperties, "RightYAxisProperties", "Right Y Axis", "", "", "");
|
||||
m_rightYAxisProperties.uiCapability()->setUiTreeHidden(true);
|
||||
|
||||
m_rightYAxisPropertiesObject = std::unique_ptr<RimSummaryYAxisProperties>(new RimSummaryYAxisProperties);
|
||||
m_rightYAxisPropertiesObject->setNameAndAxis("Right Y-Axis", QwtPlot::yRight);
|
||||
m_rightYAxisProperties = m_rightYAxisPropertiesObject.get();
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_timeAxisProperties, "TimeAxisProperties", "Time Axis", "", "", "");
|
||||
m_timeAxisProperties.uiCapability()->setUiTreeHidden(true);
|
||||
|
||||
m_timeAxisPropertiesObject = std::unique_ptr<RimSummaryTimeAxisProperties>(new RimSummaryTimeAxisProperties);
|
||||
m_timeAxisProperties = m_timeAxisPropertiesObject.get();
|
||||
|
||||
CAF_PDM_InitField(&m_isAutoZoom, "AutoZoom", true, "Auto Zoom", "", "", "");
|
||||
m_isAutoZoom.uiCapability()->setUiHidden(true);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -88,6 +114,111 @@ void RimSummaryPlot::deletePlotWidget()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::updateAxes()
|
||||
{
|
||||
updateAxis(RimDefines::PLOT_AXIS_LEFT);
|
||||
updateAxis(RimDefines::PLOT_AXIS_RIGHT);
|
||||
|
||||
updateZoomInQwt();
|
||||
|
||||
updateTimeAxis();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimSummaryPlot::isLogarithmicScaleEnabled(RimDefines::PlotAxis plotAxis) const
|
||||
{
|
||||
if (plotAxis == RimDefines::PLOT_AXIS_LEFT)
|
||||
{
|
||||
return m_leftYAxisProperties->isLogarithmicScaleEnabled();
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_rightYAxisProperties->isLogarithmicScaleEnabled();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::updateAxis(RimDefines::PlotAxis plotAxis)
|
||||
{
|
||||
if (!m_qwtPlot) return;
|
||||
|
||||
std::vector<RimSummaryCurve*> curves = curvesForAxis(plotAxis);
|
||||
|
||||
std::vector<RimSummaryCurveFilter*> curveFiltersForAxis;
|
||||
for (RimSummaryCurveFilter* cs : m_curveFilters)
|
||||
{
|
||||
if (cs->associatedPlotAxis() == plotAxis)
|
||||
{
|
||||
curveFiltersForAxis.push_back(cs);
|
||||
}
|
||||
}
|
||||
|
||||
QwtPlot::Axis qwtAxis = QwtPlot::yLeft;
|
||||
RimSummaryYAxisProperties* yAxisProperties = nullptr;
|
||||
if (plotAxis == RimDefines::PLOT_AXIS_LEFT)
|
||||
{
|
||||
qwtAxis = QwtPlot::yLeft;
|
||||
yAxisProperties = m_leftYAxisProperties();
|
||||
}
|
||||
else
|
||||
{
|
||||
qwtAxis = QwtPlot::yRight;
|
||||
yAxisProperties = m_rightYAxisProperties();
|
||||
}
|
||||
|
||||
if (curves.size() > 0)
|
||||
{
|
||||
m_qwtPlot->enableAxis(qwtAxis, true);
|
||||
|
||||
RimSummaryCurvesCalculator calc(yAxisProperties, curves, curveFiltersForAxis);
|
||||
calc.applyPropertiesToPlot(m_qwtPlot);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_qwtPlot->enableAxis(qwtAxis, false);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimSummaryCurve*> RimSummaryPlot::curvesForAxis(RimDefines::PlotAxis plotAxis) const
|
||||
{
|
||||
std::vector<RimSummaryCurve*> curves;
|
||||
|
||||
std::vector<RimSummaryCurve*> childCurves;
|
||||
this->descendantsIncludingThisOfType(childCurves);
|
||||
|
||||
for (RimSummaryCurve* curve : childCurves)
|
||||
{
|
||||
if (curve->associatedPlotAxis() == plotAxis)
|
||||
{
|
||||
curves.push_back(curve);
|
||||
}
|
||||
}
|
||||
|
||||
return curves;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::updateTimeAxis()
|
||||
{
|
||||
if (!m_qwtPlot) return;
|
||||
|
||||
QFont timeAxisFont = m_qwtPlot->axisFont(QwtPlot::xBottom);
|
||||
timeAxisFont.setBold(false);
|
||||
timeAxisFont.setPixelSize(m_timeAxisProperties->fontSize);
|
||||
m_qwtPlot->setAxisFont(QwtPlot::xBottom, timeAxisFont);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@ -105,36 +236,6 @@ void RimSummaryPlot::handleViewerDeletion()
|
||||
updateConnectedEditors();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::updateYAxisUnit()
|
||||
{
|
||||
if (!m_qwtPlot) return;
|
||||
|
||||
std::set<std::string> unitNames;
|
||||
|
||||
for(RimSummaryCurve* rimCurve: m_curves)
|
||||
{
|
||||
if (rimCurve->isCurveVisible()) unitNames.insert(rimCurve->unitName());
|
||||
}
|
||||
|
||||
for(RimSummaryCurveFilter* curveFilter: m_curveFilters)
|
||||
{
|
||||
std::set<std::string> filterUnitNames = curveFilter->unitNames();
|
||||
unitNames.insert(filterUnitNames.begin(), filterUnitNames.end());
|
||||
}
|
||||
|
||||
QString assembledYAxisText;
|
||||
|
||||
for (const std::string& unitName : unitNames)
|
||||
{
|
||||
assembledYAxisText += "[" + QString::fromStdString(unitName) + "] ";
|
||||
}
|
||||
|
||||
m_qwtPlot->setYAxisTitle(assembledYAxisText);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -160,22 +261,24 @@ QWidget* RimSummaryPlot::viewer()
|
||||
return m_qwtPlot;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::setZoomWindow(const QRectF& zoomWindow)
|
||||
void RimSummaryPlot::setZoomWindow(const QwtInterval& leftAxis, const QwtInterval& rightAxis, const QwtInterval& timeAxis)
|
||||
{
|
||||
if(!zoomWindow.isEmpty())
|
||||
{
|
||||
std::vector<float> window;
|
||||
window.push_back(zoomWindow.left());
|
||||
window.push_back(zoomWindow.top());
|
||||
window.push_back(zoomWindow.width());
|
||||
window.push_back(zoomWindow.height());
|
||||
m_leftYAxisProperties->visibleRangeMax = leftAxis.maxValue();
|
||||
m_leftYAxisProperties->visibleRangeMin = leftAxis.minValue();
|
||||
m_leftYAxisProperties->updateConnectedEditors();
|
||||
|
||||
m_visibleWindow = window;
|
||||
}
|
||||
m_rightYAxisProperties->visibleRangeMax = rightAxis.maxValue();
|
||||
m_rightYAxisProperties->visibleRangeMin = rightAxis.minValue();
|
||||
m_rightYAxisProperties->updateConnectedEditors();
|
||||
|
||||
m_timeAxisProperties->setVisibleRangeMin(timeAxis.minValue());
|
||||
m_timeAxisProperties->setVisibleRangeMax(timeAxis.maxValue());
|
||||
m_timeAxisProperties->updateConnectedEditors();
|
||||
|
||||
disableAutoZoom();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -185,9 +288,44 @@ void RimSummaryPlot::zoomAll()
|
||||
{
|
||||
if (m_qwtPlot)
|
||||
{
|
||||
m_qwtPlot->zoomAll();
|
||||
this->setZoomWindow(m_qwtPlot->currentVisibleWindow());
|
||||
m_qwtPlot->setAxisAutoScale(QwtPlot::xBottom, true);
|
||||
|
||||
if (m_leftYAxisProperties->isLogarithmicScaleEnabled)
|
||||
{
|
||||
std::vector<RimSummaryCurve*> curves = curvesForAxis(RimDefines::PLOT_AXIS_LEFT);
|
||||
|
||||
double min, max;
|
||||
RimSummaryCurvesCalculator calc(m_leftYAxisProperties, curves);
|
||||
calc.computeYRange(&min, &max);
|
||||
|
||||
m_qwtPlot->setAxisScale(m_leftYAxisProperties->axis(), min, max);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_qwtPlot->setAxisAutoScale(QwtPlot::yLeft, true);
|
||||
}
|
||||
|
||||
if (m_rightYAxisProperties->isLogarithmicScaleEnabled)
|
||||
{
|
||||
std::vector<RimSummaryCurve*> curves = curvesForAxis(RimDefines::PLOT_AXIS_RIGHT);
|
||||
|
||||
double min, max;
|
||||
RimSummaryCurvesCalculator calc(m_rightYAxisProperties, curves);
|
||||
calc.computeYRange(&min, &max);
|
||||
|
||||
m_qwtPlot->setAxisScale(m_rightYAxisProperties->axis(), min, max);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_qwtPlot->setAxisAutoScale(QwtPlot::yRight, true);
|
||||
}
|
||||
|
||||
m_qwtPlot->replot();
|
||||
}
|
||||
|
||||
updateZoomFromQwt();
|
||||
|
||||
m_isAutoZoom = true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -201,7 +339,7 @@ void RimSummaryPlot::addCurve(RimSummaryCurve* curve)
|
||||
if (m_qwtPlot)
|
||||
{
|
||||
curve->setParentQwtPlot(m_qwtPlot);
|
||||
this->updateYAxisUnit();
|
||||
this->updateAxes();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -217,7 +355,7 @@ void RimSummaryPlot::addCurveFilter(RimSummaryCurveFilter* curveFilter)
|
||||
if(m_qwtPlot)
|
||||
{
|
||||
curveFilter->setParentQwtPlot(m_qwtPlot);
|
||||
this->updateYAxisUnit();
|
||||
this->updateAxes();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -251,14 +389,9 @@ void RimSummaryPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::setupBeforeSave()
|
||||
{
|
||||
if (m_qwtPlot)
|
||||
if (m_qwtPlot && RiaApplication::instance()->mainPlotWindow())
|
||||
{
|
||||
if (RiaApplication::instance()->mainPlotWindow())
|
||||
{
|
||||
this->setMdiWindowGeometry(RiaApplication::instance()->mainPlotWindow()->windowGeometryForViewer(m_qwtPlot));
|
||||
}
|
||||
|
||||
this->setZoomWindow(m_qwtPlot->currentVisibleWindow());
|
||||
this->setMdiWindowGeometry(RiaApplication::instance()->mainPlotWindow()->windowGeometryForViewer(m_qwtPlot));
|
||||
}
|
||||
}
|
||||
|
||||
@ -284,6 +417,18 @@ QImage RimSummaryPlot::snapshotWindowContent()
|
||||
return image;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/)
|
||||
{
|
||||
uiTreeOrdering.add(&m_timeAxisProperties);
|
||||
uiTreeOrdering.add(&m_leftYAxisProperties);
|
||||
uiTreeOrdering.add(&m_rightYAxisProperties);
|
||||
uiTreeOrdering.add(&m_curveFilters);
|
||||
uiTreeOrdering.add(&m_curves);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -301,7 +446,7 @@ void RimSummaryPlot::loadDataAndUpdate()
|
||||
curve->loadDataAndUpdate();
|
||||
}
|
||||
|
||||
this->updateYAxisUnit();
|
||||
this->updateAxes();
|
||||
|
||||
updateZoomInQwt();
|
||||
}
|
||||
@ -312,15 +457,53 @@ void RimSummaryPlot::loadDataAndUpdate()
|
||||
void RimSummaryPlot::updateZoomInQwt()
|
||||
{
|
||||
if (!m_qwtPlot) return;
|
||||
|
||||
// Todo: introduce autoscale
|
||||
|
||||
if(m_visibleWindow().size() == 4)
|
||||
|
||||
if (m_isAutoZoom)
|
||||
{
|
||||
QRectF visibleWindow(m_visibleWindow()[0], m_visibleWindow()[1], m_visibleWindow()[2], m_visibleWindow()[3]);
|
||||
|
||||
m_qwtPlot->setZoomWindow(visibleWindow);
|
||||
zoomAll();
|
||||
}
|
||||
else
|
||||
{
|
||||
setZoomIntervalsInQwtPlot();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::setZoomIntervalsInQwtPlot()
|
||||
{
|
||||
QwtInterval left, right, time;
|
||||
|
||||
left.setMinValue(m_leftYAxisProperties->visibleRangeMin());
|
||||
left.setMaxValue(m_leftYAxisProperties->visibleRangeMax());
|
||||
right.setMinValue(m_rightYAxisProperties->visibleRangeMin());
|
||||
right.setMaxValue(m_rightYAxisProperties->visibleRangeMax());
|
||||
time.setMinValue(m_timeAxisProperties->visibleRangeMin());
|
||||
time.setMaxValue(m_timeAxisProperties->visibleRangeMax());
|
||||
|
||||
m_qwtPlot->setZoomWindow(left, right, time);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::updateZoomFromQwt()
|
||||
{
|
||||
if (!m_qwtPlot) return;
|
||||
|
||||
QwtInterval left, right, time;
|
||||
m_qwtPlot->currentVisibleWindow(&left, &right, &time);
|
||||
|
||||
setZoomWindow(left, right, time);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::disableAutoZoom()
|
||||
{
|
||||
m_isAutoZoom = false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -23,15 +23,24 @@
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmChildArrayField.h"
|
||||
#include "cafAppEnum.h"
|
||||
#include "cafPdmChildField.h"
|
||||
|
||||
#include "RimDefines.h"
|
||||
#include "RimViewWindow.h"
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
#include "RimViewWindow.h"
|
||||
#include <memory>
|
||||
|
||||
class RiuSummaryQwtPlot;
|
||||
class RimSummaryCurve;
|
||||
class RimSummaryCurveFilter;
|
||||
class RimSummaryYAxisProperties;
|
||||
class RimSummaryTimeAxisProperties;
|
||||
class PdmUiTreeOrdering;
|
||||
|
||||
class QwtPlotCurve;
|
||||
class QwtInterval;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@ -53,16 +62,22 @@ public:
|
||||
|
||||
void loadDataAndUpdate();
|
||||
|
||||
|
||||
void handleViewerDeletion();
|
||||
void updateYAxisUnit();
|
||||
void updateCaseNameHasChanged();
|
||||
|
||||
QWidget* viewer();
|
||||
|
||||
void setZoomWindow(const QRectF& zoomWindow);
|
||||
void updateAxes();
|
||||
virtual void zoomAll() override;
|
||||
void setZoomWindow(const QwtInterval& leftAxis,
|
||||
const QwtInterval& rightAxis,
|
||||
const QwtInterval& timeAxis);
|
||||
|
||||
void updateZoomInQwt();
|
||||
void updateZoomFromQwt();
|
||||
void disableAutoZoom();
|
||||
|
||||
bool isLogarithmicScaleEnabled(RimDefines::PlotAxis plotAxis) const;
|
||||
|
||||
protected:
|
||||
// Overridden PDM methods
|
||||
@ -70,6 +85,7 @@ protected:
|
||||
virtual caf::PdmFieldHandle* userDescriptionField() { return &m_userName; }
|
||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||
virtual void setupBeforeSave() override;
|
||||
virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "") override;
|
||||
|
||||
virtual QImage snapshotWindowContent() override;
|
||||
|
||||
@ -78,12 +94,29 @@ private:
|
||||
void updateViewerWidgetWindowTitle();
|
||||
void detachAllCurves();
|
||||
void deletePlotWidget();
|
||||
|
||||
void updateAxis(RimDefines::PlotAxis plotAxis);
|
||||
std::vector<RimSummaryCurve*> curvesForAxis(RimDefines::PlotAxis plotAxis) const;
|
||||
|
||||
void updateTimeAxis();
|
||||
void setZoomIntervalsInQwtPlot();
|
||||
|
||||
|
||||
private:
|
||||
caf::PdmField<bool> m_showWindow;
|
||||
caf::PdmField<QString> m_userName;
|
||||
caf::PdmChildArrayField<RimSummaryCurve*> m_curves;
|
||||
caf::PdmChildArrayField<RimSummaryCurveFilter*> m_curveFilters;
|
||||
caf::PdmField<std::vector<float> > m_visibleWindow;
|
||||
|
||||
caf::PdmField<bool> m_isAutoZoom;
|
||||
caf::PdmChildField<RimSummaryYAxisProperties*> m_leftYAxisProperties;
|
||||
caf::PdmChildField<RimSummaryYAxisProperties*> m_rightYAxisProperties;
|
||||
caf::PdmChildField<RimSummaryTimeAxisProperties*> m_timeAxisProperties;
|
||||
|
||||
QPointer<RiuSummaryQwtPlot> m_qwtPlot;
|
||||
|
||||
// Internal objects managed by unique_ptr
|
||||
std::unique_ptr<RimSummaryYAxisProperties> m_leftYAxisPropertiesObject;
|
||||
std::unique_ptr<RimSummaryYAxisProperties> m_rightYAxisPropertiesObject;
|
||||
std::unique_ptr<RimSummaryTimeAxisProperties> m_timeAxisPropertiesObject;
|
||||
};
|
||||
|
@ -0,0 +1,137 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2016 Statoil ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RimSummaryTimeAxisProperties.h"
|
||||
|
||||
#include "RimSummaryPlot.h"
|
||||
|
||||
#include "cafPdmUiLineEditor.h"
|
||||
|
||||
#include "qwt_date.h"
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimSummaryTimeAxisProperties, "SummaryTimeAxisProperties");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryTimeAxisProperties::RimSummaryTimeAxisProperties()
|
||||
{
|
||||
CAF_PDM_InitObject("Time Axis", ":/SummaryPlot16x16.png", "", "");
|
||||
|
||||
CAF_PDM_InitField(&fontSize, "FontSize", 11, "Font Size", "", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_visibleRangeMax, "VisibleRangeMax", "Max", "", "", "");
|
||||
m_visibleRangeMax.uiCapability()->setUiEditorTypeName(caf::PdmUiLineEditor::uiEditorTypeName());
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_visibleRangeMin, "VisibleRangeMin", "Min", "", "", "");
|
||||
m_visibleRangeMin.uiCapability()->setUiEditorTypeName(caf::PdmUiLineEditor::uiEditorTypeName());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RimSummaryTimeAxisProperties::visibleRangeMin() const
|
||||
{
|
||||
return QwtDate::toDouble(m_visibleRangeMin());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RimSummaryTimeAxisProperties::visibleRangeMax() const
|
||||
{
|
||||
return QwtDate::toDouble(m_visibleRangeMax());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryTimeAxisProperties::setVisibleRangeMin(double value)
|
||||
{
|
||||
m_visibleRangeMin = QwtDate::toDateTime(value);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryTimeAxisProperties::setVisibleRangeMax(double value)
|
||||
{
|
||||
m_visibleRangeMax = QwtDate::toDateTime(value);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QList<caf::PdmOptionItemInfo> RimSummaryTimeAxisProperties::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly)
|
||||
{
|
||||
QList<caf::PdmOptionItemInfo> options;
|
||||
*useOptionsOnly = true;
|
||||
|
||||
if (&fontSize == fieldNeedingOptions)
|
||||
{
|
||||
std::vector<int> fontSizes;
|
||||
fontSizes.push_back(8);
|
||||
fontSizes.push_back(10);
|
||||
fontSizes.push_back(11);
|
||||
fontSizes.push_back(12);
|
||||
fontSizes.push_back(16);
|
||||
fontSizes.push_back(24);
|
||||
|
||||
for (int value : fontSizes)
|
||||
{
|
||||
QString text = QString("%1").arg(value);
|
||||
options.push_back(caf::PdmOptionItemInfo(text, value));
|
||||
}
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryTimeAxisProperties::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
||||
{
|
||||
RimSummaryPlot* rimSummaryPlot = nullptr;
|
||||
this->firstAncestorOrThisOfType(rimSummaryPlot);
|
||||
|
||||
if (changedField == &m_visibleRangeMax)
|
||||
{
|
||||
QDateTime test = newValue.toDateTime();
|
||||
if (!test.isValid())
|
||||
{
|
||||
m_visibleRangeMax = oldValue.toDateTime();
|
||||
}
|
||||
|
||||
rimSummaryPlot->disableAutoZoom();
|
||||
}
|
||||
else if (changedField == &m_visibleRangeMin)
|
||||
{
|
||||
QDateTime test = newValue.toDateTime();
|
||||
if (!test.isValid())
|
||||
{
|
||||
m_visibleRangeMin = oldValue.toDateTime();
|
||||
}
|
||||
|
||||
rimSummaryPlot->disableAutoZoom();
|
||||
}
|
||||
|
||||
rimSummaryPlot->updateAxes();
|
||||
}
|
||||
|
@ -0,0 +1,56 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2016 Statoil ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmChildArrayField.h"
|
||||
#include "cafAppEnum.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QDateTime>
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimSummaryTimeAxisProperties : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimSummaryTimeAxisProperties();
|
||||
|
||||
caf::PdmField<int> fontSize;
|
||||
|
||||
double visibleRangeMin() const;
|
||||
double visibleRangeMax() const;
|
||||
|
||||
void setVisibleRangeMin(double value);
|
||||
void setVisibleRangeMax(double value);
|
||||
|
||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||
//virtual caf::PdmFieldHandle* userDescriptionField() override;
|
||||
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override;
|
||||
|
||||
private:
|
||||
caf::PdmField<QDateTime> m_visibleRangeMin;
|
||||
caf::PdmField<QDateTime> m_visibleRangeMax;
|
||||
};
|
166
ApplicationCode/ProjectDataModel/RimSummaryYAxisProperties.cpp
Normal file
166
ApplicationCode/ProjectDataModel/RimSummaryYAxisProperties.cpp
Normal file
@ -0,0 +1,166 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2016 Statoil ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RimSummaryYAxisProperties.h"
|
||||
|
||||
#include "RimSummaryPlot.h"
|
||||
#include "RimDefines.h"
|
||||
|
||||
|
||||
namespace caf
|
||||
{
|
||||
template<>
|
||||
void caf::AppEnum< RimSummaryYAxisProperties::NumberFormatType >::setUp()
|
||||
{
|
||||
addItem(RimSummaryYAxisProperties::NUMBER_FORMAT_AUTO, "NUMBER_FORMAT_AUTO", "Auto");
|
||||
addItem(RimSummaryYAxisProperties::NUMBER_FORMAT_DECIMAL, "NUMBER_FORMAT_DECIMAL", "Decimal");
|
||||
addItem(RimSummaryYAxisProperties::NUMBER_FORMAT_SCIENTIFIC,"NUMBER_FORMAT_SCIENTIFIC", "Scientific");
|
||||
|
||||
setDefault(RimSummaryYAxisProperties::NUMBER_FORMAT_AUTO);
|
||||
}
|
||||
}
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimSummaryYAxisProperties, "SummaryYAxisProperties");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryYAxisProperties::RimSummaryYAxisProperties()
|
||||
{
|
||||
CAF_PDM_InitObject("Y-Axis Properties", ":/SummaryPlot16x16.png", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_name, "Name", "Name", "", "", "");
|
||||
m_name.uiCapability()->setUiHidden(true);
|
||||
|
||||
CAF_PDM_InitField(&isAutoTitle, "AutoTitle", true, "Auto Title", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&customTitle, "CustomTitle", "Title", "", "", "");
|
||||
CAF_PDM_InitField(&fontSize, "FontSize", 11, "Font Size", "", "", "");
|
||||
|
||||
CAF_PDM_InitField(&visibleRangeMax, "VisibleRangeMax", RimDefines::maximumDefaultValuePlot(), "Max", "", "", "");
|
||||
CAF_PDM_InitField(&visibleRangeMin, "VisibleRangeMin", RimDefines::minimumDefaultValuePlot(), "Min", "", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&numberFormat, "NumberFormat", "Number Format", "", "", "");
|
||||
|
||||
CAF_PDM_InitField(&isLogarithmicScaleEnabled, "LogarithmicScale", false, "Logarithmic Scale", "", "", "");
|
||||
|
||||
updateOptionSensitivity();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmFieldHandle* RimSummaryYAxisProperties::userDescriptionField()
|
||||
{
|
||||
return &m_name;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QList<caf::PdmOptionItemInfo> RimSummaryYAxisProperties::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly)
|
||||
{
|
||||
QList<caf::PdmOptionItemInfo> options;
|
||||
*useOptionsOnly = true;
|
||||
|
||||
if (&fontSize == fieldNeedingOptions)
|
||||
{
|
||||
std::vector<int> fontSizes;
|
||||
fontSizes.push_back(8);
|
||||
fontSizes.push_back(10);
|
||||
fontSizes.push_back(12);
|
||||
fontSizes.push_back(16);
|
||||
fontSizes.push_back(24);
|
||||
|
||||
for (int value : fontSizes)
|
||||
{
|
||||
QString text = QString("%1").arg(value);
|
||||
options.push_back(caf::PdmOptionItemInfo(text, value));
|
||||
}
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryYAxisProperties::setNameAndAxis(const QString& name, QwtPlot::Axis axis)
|
||||
{
|
||||
m_name = name;
|
||||
m_axis = axis;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QwtPlot::Axis RimSummaryYAxisProperties::axis() const
|
||||
{
|
||||
return m_axis;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryYAxisProperties::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
||||
{
|
||||
RimSummaryPlot* rimSummaryPlot = nullptr;
|
||||
this->firstAncestorOrThisOfType(rimSummaryPlot);
|
||||
|
||||
if (changedField == &isAutoTitle)
|
||||
{
|
||||
updateOptionSensitivity();
|
||||
}
|
||||
else if (changedField == &visibleRangeMax)
|
||||
{
|
||||
if (visibleRangeMin > visibleRangeMax) visibleRangeMax = oldValue.toDouble();
|
||||
|
||||
rimSummaryPlot->disableAutoZoom();
|
||||
}
|
||||
else if (changedField == &visibleRangeMin)
|
||||
{
|
||||
if (visibleRangeMin > visibleRangeMax) visibleRangeMin = oldValue.toDouble();
|
||||
|
||||
rimSummaryPlot->disableAutoZoom();
|
||||
}
|
||||
|
||||
if (changedField == &isLogarithmicScaleEnabled)
|
||||
{
|
||||
rimSummaryPlot->loadDataAndUpdate();
|
||||
}
|
||||
else
|
||||
{
|
||||
rimSummaryPlot->updateAxes();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryYAxisProperties::updateOptionSensitivity()
|
||||
{
|
||||
customTitle.uiCapability()->setUiReadOnly(isAutoTitle);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryYAxisProperties::initAfterRead()
|
||||
{
|
||||
updateOptionSensitivity();
|
||||
}
|
||||
|
77
ApplicationCode/ProjectDataModel/RimSummaryYAxisProperties.h
Normal file
77
ApplicationCode/ProjectDataModel/RimSummaryYAxisProperties.h
Normal file
@ -0,0 +1,77 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2016 Statoil ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmChildArrayField.h"
|
||||
#include "cafAppEnum.h"
|
||||
|
||||
#include "qwt_plot.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimSummaryYAxisProperties : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
enum NumberFormatType
|
||||
{
|
||||
NUMBER_FORMAT_AUTO,
|
||||
NUMBER_FORMAT_DECIMAL,
|
||||
NUMBER_FORMAT_SCIENTIFIC
|
||||
};
|
||||
|
||||
public:
|
||||
RimSummaryYAxisProperties();
|
||||
|
||||
void setNameAndAxis(const QString& name, QwtPlot::Axis axis);
|
||||
QwtPlot::Axis axis() const;
|
||||
|
||||
caf::PdmField<bool> isAutoTitle;
|
||||
caf::PdmField<QString> customTitle;
|
||||
caf::PdmField<int> fontSize;
|
||||
|
||||
caf::PdmField<double> visibleRangeMin;
|
||||
caf::PdmField<double> visibleRangeMax;
|
||||
|
||||
caf::PdmField< caf::AppEnum< NumberFormatType > > numberFormat;
|
||||
|
||||
caf::PdmField<bool> isLogarithmicScaleEnabled;
|
||||
|
||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||
virtual caf::PdmFieldHandle* userDescriptionField() override;
|
||||
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override;
|
||||
|
||||
protected:
|
||||
virtual void initAfterRead() override;
|
||||
|
||||
private:
|
||||
void updateOptionSensitivity();
|
||||
|
||||
private:
|
||||
caf::PdmField<QString> m_name;
|
||||
QwtPlot::Axis m_axis;
|
||||
};
|
@ -64,7 +64,7 @@ RimViewController::RimViewController(void)
|
||||
m_name.uiCapability()->setUiHidden(true);
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_managedView, "ManagedView", "Linked View", "", "", "");
|
||||
m_managedView.uiCapability()->setUiChildrenHidden(true);
|
||||
m_managedView.uiCapability()->setUiTreeChildrenHidden(true);
|
||||
|
||||
CAF_PDM_InitField(&m_syncCamera, "SyncCamera", true, "Camera", "", "", "");
|
||||
CAF_PDM_InitField(&m_syncTimeStep, "SyncTimeStep", true, "Time Step", "", "", "");
|
||||
|
@ -61,12 +61,12 @@ RimViewLinker::RimViewLinker(void)
|
||||
m_name.uiCapability()->setUiHidden(true);
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_masterView, "MainView", "Main View", "", "", "");
|
||||
m_masterView.uiCapability()->setUiChildrenHidden(true);
|
||||
m_masterView.uiCapability()->setUiTreeChildrenHidden(true);
|
||||
m_masterView.uiCapability()->setUiHidden(true);
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_viewControllers, "ManagedViews", "Managed Views", "", "", "");
|
||||
m_viewControllers.uiCapability()->setUiHidden(true);
|
||||
m_viewControllers.uiCapability()->setUiChildrenHidden(true);
|
||||
m_viewControllers.uiCapability()->setUiTreeChildrenHidden(true);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -66,20 +66,20 @@ RimWellLogExtractionCurve::RimWellLogExtractionCurve()
|
||||
CAF_PDM_InitObject("Well Log Curve", "", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_wellPath, "CurveWellPath", "Well Path", "", "", "");
|
||||
m_wellPath.uiCapability()->setUiChildrenHidden(true);
|
||||
m_wellPath.uiCapability()->setUiTreeChildrenHidden(true);
|
||||
//m_wellPath.uiCapability()->setUiHidden(true);
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_case, "CurveCase", "Case", "", "", "");
|
||||
m_case.uiCapability()->setUiChildrenHidden(true);
|
||||
m_case.uiCapability()->setUiTreeChildrenHidden(true);
|
||||
//m_case.uiCapability()->setUiHidden(true);
|
||||
CAF_PDM_InitFieldNoDefault(&m_eclipseResultDefinition, "CurveEclipseResult", "", "", "", "");
|
||||
m_eclipseResultDefinition.uiCapability()->setUiHidden(true);
|
||||
m_eclipseResultDefinition.uiCapability()->setUiChildrenHidden(true);
|
||||
m_eclipseResultDefinition.uiCapability()->setUiTreeChildrenHidden(true);
|
||||
m_eclipseResultDefinition = new RimEclipseResultDefinition;
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_geomResultDefinition, "CurveGeomechResult", "", "", "", "");
|
||||
m_geomResultDefinition.uiCapability()->setUiHidden(true);
|
||||
m_geomResultDefinition.uiCapability()->setUiChildrenHidden(true);
|
||||
m_geomResultDefinition.uiCapability()->setUiTreeChildrenHidden(true);
|
||||
m_geomResultDefinition = new RimGeoMechResultDefinition;
|
||||
|
||||
CAF_PDM_InitField(&m_timeStep, "CurveTimeStep", 0,"Time Step", "", "", "");
|
||||
|
@ -49,7 +49,7 @@ RimWellLogFileCurve::RimWellLogFileCurve()
|
||||
CAF_PDM_InitObject("Well Log File Curve", "", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_wellPath, "CurveWellPath", "Well Path", "", "", "");
|
||||
m_wellPath.uiCapability()->setUiChildrenHidden(true);
|
||||
m_wellPath.uiCapability()->setUiTreeChildrenHidden(true);
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_wellLogChannnelName, "CurveWellLogChannel", "Well Log Channel", "", "", "");
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigCurveDataTools::calculateIntervalsOfValidValues(const std::vector<double>& values, std::vector< std::pair<size_t, size_t> >* intervals)
|
||||
void RigCurveDataTools::calculateIntervalsOfValidValues(const std::vector<double>& values, std::vector< std::pair<size_t, size_t> >* intervals, bool removeNegativeValues)
|
||||
{
|
||||
CVF_ASSERT(intervals);
|
||||
|
||||
@ -36,7 +36,19 @@ void RigCurveDataTools::calculateIntervalsOfValidValues(const std::vector<double
|
||||
while (vIdx < valueCount)
|
||||
{
|
||||
double value = values[vIdx];
|
||||
|
||||
bool isInvalidValueDetected = false;
|
||||
if (value == HUGE_VAL || value == -HUGE_VAL || value != value)
|
||||
{
|
||||
isInvalidValueDetected = true;
|
||||
}
|
||||
|
||||
if (removeNegativeValues && value <= 0.0)
|
||||
{
|
||||
isInvalidValueDetected = true;
|
||||
}
|
||||
|
||||
if (isInvalidValueDetected)
|
||||
{
|
||||
if (startIdx >= 0)
|
||||
{
|
||||
|
@ -32,7 +32,8 @@ class RigCurveDataTools
|
||||
{
|
||||
public:
|
||||
static void calculateIntervalsOfValidValues(const std::vector<double>& values,
|
||||
std::vector< std::pair<size_t, size_t> >* intervals);
|
||||
std::vector< std::pair<size_t, size_t> >* intervals,
|
||||
bool removeNegativeValues);
|
||||
|
||||
template <typename T>
|
||||
static void getValuesByIntervals(const std::vector<T>& values,
|
||||
|
@ -250,7 +250,7 @@ cvf::ref<RigWellLogCurveData> RigWellLogCurveData::calculateResampledCurveData(d
|
||||
void RigWellLogCurveData::calculateIntervalsOfContinousValidValues()
|
||||
{
|
||||
std::vector< std::pair<size_t, size_t> > intervalsOfValidValues;
|
||||
RigCurveDataTools::calculateIntervalsOfValidValues(m_xValues, &intervalsOfValidValues);
|
||||
RigCurveDataTools::calculateIntervalsOfValidValues(m_xValues, &intervalsOfValidValues, false);
|
||||
|
||||
m_intervalsOfContinousValidValues.clear();
|
||||
|
||||
|
@ -19,7 +19,7 @@ TEST(RimWellLogExtractionCurveImplTest, StripOffInvalidValAtEndsOfVector)
|
||||
values.push_back(HUGE_VAL);
|
||||
|
||||
std::vector< std::pair<size_t, size_t> > valuesIntervals;
|
||||
RigCurveDataTools::calculateIntervalsOfValidValues(values, &valuesIntervals);
|
||||
RigCurveDataTools::calculateIntervalsOfValidValues(values, &valuesIntervals, false);
|
||||
|
||||
EXPECT_EQ(1, static_cast<int>(valuesIntervals.size()));
|
||||
EXPECT_EQ(2, static_cast<int>(valuesIntervals[0].first));
|
||||
@ -43,7 +43,7 @@ TEST(RimWellLogExtractionCurveImplTest, StripOffHugeValAtEndsAndInteriorOfVector
|
||||
values.push_back(HUGE_VAL);
|
||||
|
||||
std::vector< std::pair<size_t, size_t> > valuesIntervals;
|
||||
RigCurveDataTools::calculateIntervalsOfValidValues(values, &valuesIntervals);
|
||||
RigCurveDataTools::calculateIntervalsOfValidValues(values, &valuesIntervals, false);
|
||||
|
||||
EXPECT_EQ(2, static_cast<int>(valuesIntervals.size()));
|
||||
EXPECT_EQ(2, static_cast<int>(valuesIntervals[0].first));
|
||||
|
@ -51,7 +51,7 @@ RiuLineSegmentQwtPlotCurve::~RiuLineSegmentQwtPlotCurve()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuLineSegmentQwtPlotCurve::setSamplesFromDateAndValues(const std::vector<QDateTime>& dateTimes, const std::vector<double>& timeHistoryValues)
|
||||
void RiuLineSegmentQwtPlotCurve::setSamplesFromDateAndValues(const std::vector<QDateTime>& dateTimes, const std::vector<double>& timeHistoryValues, bool removeNegativeValues)
|
||||
{
|
||||
CVF_ASSERT(dateTimes.size() == timeHistoryValues.size());
|
||||
|
||||
@ -63,7 +63,7 @@ void RiuLineSegmentQwtPlotCurve::setSamplesFromDateAndValues(const std::vector<Q
|
||||
|
||||
{
|
||||
std::vector< std::pair<size_t, size_t> > intervalsOfValidValues;
|
||||
RigCurveDataTools::calculateIntervalsOfValidValues(timeHistoryValues, &intervalsOfValidValues);
|
||||
RigCurveDataTools::calculateIntervalsOfValidValues(timeHistoryValues, &intervalsOfValidValues, removeNegativeValues);
|
||||
|
||||
RigCurveDataTools::getValuesByIntervals(timeHistoryValues, intervalsOfValidValues, &filteredTimeHistoryValues);
|
||||
RigCurveDataTools::getValuesByIntervals(dateTimes, intervalsOfValidValues, &filteredDateTimes);
|
||||
@ -79,11 +79,8 @@ void RiuLineSegmentQwtPlotCurve::setSamplesFromDateAndValues(const std::vector<Q
|
||||
}
|
||||
}
|
||||
|
||||
RiuLineSegmentQwtPlotCurve* plotCurve = new RiuLineSegmentQwtPlotCurve("Curve 1");
|
||||
|
||||
this->setSamples(points);
|
||||
this->setLineSegmentStartStopIndices(filteredIntervals);
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -47,7 +47,7 @@ public:
|
||||
explicit RiuLineSegmentQwtPlotCurve(const QString &title = QString::null);
|
||||
virtual ~RiuLineSegmentQwtPlotCurve();
|
||||
|
||||
void setSamplesFromDateAndValues(const std::vector<QDateTime>& dateTimes, const std::vector<double>& timeHistoryValues);
|
||||
void setSamplesFromDateAndValues(const std::vector<QDateTime>& dateTimes, const std::vector<double>& timeHistoryValues, bool removeNegativeValues);
|
||||
|
||||
void setLineSegmentStartStopIndices(const std::vector< std::pair<size_t, size_t> >& lineSegmentStartStopIndices);
|
||||
|
||||
|
@ -66,7 +66,7 @@ void RiuResultQwtPlot::addCurve(const QString& curveName, const cvf::Color3f& cu
|
||||
{
|
||||
RiuLineSegmentQwtPlotCurve* plotCurve = new RiuLineSegmentQwtPlotCurve("Curve 1");
|
||||
|
||||
plotCurve->setSamplesFromDateAndValues(dateTimes, timeHistoryValues);
|
||||
plotCurve->setSamplesFromDateAndValues(dateTimes, timeHistoryValues, false);
|
||||
plotCurve->setTitle(curveName);
|
||||
|
||||
plotCurve->setPen(QPen(QColor(curveColor.rByte(), curveColor.gByte(), curveColor.bByte())));
|
||||
|
@ -52,18 +52,23 @@ RiuSummaryQwtPlot::RiuSummaryQwtPlot(RimSummaryPlot* plotDefinition, QWidget* pa
|
||||
setDefaults();
|
||||
|
||||
// LeftButton for the zooming
|
||||
m_zoomer = new QwtPlotZoomer(canvas());
|
||||
m_zoomer->setRubberBandPen(QColor(Qt::black));
|
||||
m_zoomer->setTrackerMode(QwtPicker::AlwaysOff);
|
||||
m_zoomer->setTrackerPen(QColor(Qt::black));
|
||||
m_zoomer->initMousePattern(1);
|
||||
m_zoomerLeft = new QwtPlotZoomer(canvas());
|
||||
m_zoomerLeft->setRubberBandPen(QColor(Qt::black));
|
||||
m_zoomerLeft->setTrackerMode(QwtPicker::AlwaysOff);
|
||||
m_zoomerLeft->setTrackerPen(QColor(Qt::black));
|
||||
m_zoomerLeft->initMousePattern(1);
|
||||
|
||||
// MidButton for the panning
|
||||
QwtPlotPanner* panner = new QwtPlotPanner(canvas());
|
||||
panner->setMouseButton(Qt::MidButton);
|
||||
|
||||
connect(m_zoomer, SIGNAL(zoomed( const QRectF & )), SLOT(onZoomedSlot()));
|
||||
connect(m_zoomerLeft, SIGNAL(zoomed( const QRectF & )), SLOT(onZoomedSlot()));
|
||||
connect(panner, SIGNAL(panned( int , int )), SLOT(onZoomedSlot()));
|
||||
|
||||
// Attach a zoomer for the right axis
|
||||
m_zoomerRight = new QwtPlotZoomer(canvas());
|
||||
m_zoomerRight->setAxis(xTop, yRight);
|
||||
m_zoomerRight->setTrackerMode(QwtPicker::AlwaysOff);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -91,45 +96,37 @@ RimSummaryPlot* RiuSummaryQwtPlot::ownerPlotDefinition()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuSummaryQwtPlot::setYAxisTitle(const QString& title)
|
||||
void RiuSummaryQwtPlot::currentVisibleWindow(QwtInterval* leftAxis, QwtInterval* rightAxis, QwtInterval* timeAxis) const
|
||||
{
|
||||
QwtText axisTitleY = axisTitle(QwtPlot::yLeft);
|
||||
axisTitleY.setText(title);
|
||||
setAxisTitle(QwtPlot::yLeft, axisTitleY);
|
||||
*leftAxis = axisScaleDiv(yLeft).interval();
|
||||
*rightAxis = axisScaleDiv(yRight).interval();
|
||||
*timeAxis = axisScaleDiv(xBottom).interval();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuSummaryQwtPlot::zoomAll()
|
||||
void RiuSummaryQwtPlot::setZoomWindow(const QwtInterval& leftAxis, const QwtInterval& rightAxis, const QwtInterval& timeAxis)
|
||||
{
|
||||
setAxisAutoScale(yLeft, true);
|
||||
setAxisAutoScale(xBottom, true);
|
||||
{
|
||||
QRectF zoomWindow;
|
||||
zoomWindow.setLeft(timeAxis.minValue());
|
||||
zoomWindow.setRight(timeAxis.maxValue());
|
||||
zoomWindow.setTop(leftAxis.maxValue());
|
||||
zoomWindow.setBottom(leftAxis.minValue());
|
||||
|
||||
m_zoomer->setZoomBase(true);
|
||||
}
|
||||
m_zoomerLeft->zoom(zoomWindow);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QRectF RiuSummaryQwtPlot::currentVisibleWindow() const
|
||||
{
|
||||
QRectF scaleRect;
|
||||
scaleRect.setLeft(axisScaleDiv(xBottom).lowerBound());
|
||||
scaleRect.setRight(axisScaleDiv(xBottom).upperBound());
|
||||
{
|
||||
QRectF zoomWindow;
|
||||
zoomWindow.setLeft(timeAxis.minValue());
|
||||
zoomWindow.setRight(timeAxis.maxValue());
|
||||
zoomWindow.setTop(rightAxis.maxValue());
|
||||
zoomWindow.setBottom(rightAxis.minValue());
|
||||
|
||||
scaleRect.setBottom(axisScaleDiv(yLeft).upperBound());
|
||||
scaleRect.setTop(axisScaleDiv(yLeft).lowerBound());
|
||||
|
||||
return scaleRect;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuSummaryQwtPlot::setZoomWindow(const QRectF& zoomWindow)
|
||||
{
|
||||
m_zoomer->zoom(zoomWindow);
|
||||
m_zoomerRight->zoom(zoomWindow);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -292,5 +289,10 @@ void RiuSummaryQwtPlot::selectClosestCurve(const QPoint& pos)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuSummaryQwtPlot::onZoomedSlot()
|
||||
{
|
||||
m_plotDefinition->setZoomWindow(currentVisibleWindow());
|
||||
QwtInterval left, right, time;
|
||||
currentVisibleWindow(&left, &right, &time);
|
||||
|
||||
this->setZoomWindow(left, right, time);
|
||||
|
||||
m_plotDefinition->updateZoomFromQwt();
|
||||
}
|
||||
|
@ -26,6 +26,7 @@
|
||||
class QwtPlotCurve;
|
||||
class QwtPlotGrid;
|
||||
class QwtPlotZoomer;
|
||||
class QwtInterval;
|
||||
|
||||
class RimSummaryPlot;
|
||||
|
||||
@ -42,11 +43,14 @@ public:
|
||||
virtual ~RiuSummaryQwtPlot();
|
||||
|
||||
RimSummaryPlot* ownerPlotDefinition();
|
||||
void setYAxisTitle(const QString& title);
|
||||
void zoomAll();
|
||||
|
||||
QRectF currentVisibleWindow() const;
|
||||
void setZoomWindow(const QRectF& zoomWindow);
|
||||
void currentVisibleWindow(QwtInterval* leftAxis,
|
||||
QwtInterval* rightAxis,
|
||||
QwtInterval* timeAxis) const;
|
||||
|
||||
void setZoomWindow(const QwtInterval& leftAxis,
|
||||
const QwtInterval& rightAxis,
|
||||
const QwtInterval& timeAxis);
|
||||
|
||||
protected:
|
||||
virtual bool eventFilter(QObject* watched, QEvent* event);
|
||||
@ -61,8 +65,8 @@ private slots:
|
||||
private:
|
||||
QwtPlotGrid* m_grid;
|
||||
caf::PdmPointer<RimSummaryPlot> m_plotDefinition;
|
||||
QPointer<QwtPlotZoomer> m_zoomer;
|
||||
|
||||
QPointer<QwtPlotZoomer> m_zoomerLeft;
|
||||
QPointer<QwtPlotZoomer> m_zoomerRight;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
@ -49,7 +49,7 @@ RimOilFieldEntry::RimOilFieldEntry()
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&wells, "Wells", "", "", "", "");
|
||||
wells.uiCapability()->setUiHidden(true);
|
||||
wells.uiCapability()->setUiChildrenHidden(true);
|
||||
wells.uiCapability()->setUiTreeChildrenHidden(true);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -140,15 +140,25 @@ bool PdmUiItem::isUiHidden(QString uiConfigName) const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool PdmUiItem::isUiChildrenHidden(QString uiConfigName) const
|
||||
bool PdmUiItem::isUiTreeHidden(QString uiConfigName) const
|
||||
{
|
||||
// TODO: Must be separated from uiHidden when childField object embedding is implemented
|
||||
|
||||
return isUiHidden(uiConfigName);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool PdmUiItem::isUiTreeChildrenHidden(QString uiConfigName) const
|
||||
{
|
||||
const PdmUiItemInfo* conInfo = configInfo(uiConfigName);
|
||||
const PdmUiItemInfo* defInfo = defaultInfo();
|
||||
const PdmUiItemInfo* sttInfo = m_staticItemInfo;
|
||||
|
||||
if (conInfo && !(conInfo->m_isChildrenHidden == -1)) return conInfo->m_isChildrenHidden;
|
||||
if (defInfo && !(defInfo->m_isChildrenHidden == -1)) return defInfo->m_isChildrenHidden;
|
||||
if (sttInfo && !(sttInfo->m_isChildrenHidden == -1)) return sttInfo->m_isChildrenHidden;
|
||||
if (conInfo && !(conInfo->m_isTreeChildrenHidden == -1)) return conInfo->m_isTreeChildrenHidden;
|
||||
if (defInfo && !(defInfo->m_isTreeChildrenHidden == -1)) return defInfo->m_isTreeChildrenHidden;
|
||||
if (sttInfo && !(sttInfo->m_isTreeChildrenHidden == -1)) return sttInfo->m_isTreeChildrenHidden;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -56,27 +56,27 @@ class PdmUiItemInfo
|
||||
{
|
||||
public:
|
||||
PdmUiItemInfo()
|
||||
: m_editorTypeName(""), m_isHidden(-1), m_isChildrenHidden(-1), m_isReadOnly(-1), m_labelAlignment(LEFT)
|
||||
: m_editorTypeName(""), m_isHidden(-1), m_isTreeChildrenHidden(-1), m_isReadOnly(-1), m_labelAlignment(LEFT)
|
||||
{}
|
||||
|
||||
PdmUiItemInfo( QString uiName, QIcon icon = QIcon(), QString toolTip = "", QString whatsThis = "")
|
||||
: m_uiName(uiName), m_icon(icon), m_toolTip(toolTip), m_whatsThis(whatsThis),
|
||||
m_editorTypeName(""), m_isHidden(false), m_isChildrenHidden(false), m_isReadOnly(false), m_labelAlignment(LEFT)
|
||||
m_editorTypeName(""), m_isHidden(false), m_isTreeChildrenHidden(false), m_isReadOnly(false), m_labelAlignment(LEFT)
|
||||
{ }
|
||||
|
||||
enum LabelPosType { LEFT, TOP, HIDDEN };
|
||||
|
||||
private:
|
||||
friend class PdmUiItem;
|
||||
QString m_uiName;
|
||||
QString m_toolTip;
|
||||
QString m_whatsThis;
|
||||
QIcon m_icon;
|
||||
QString m_editorTypeName; ///< Use this exact type of editor to edit this UiItem
|
||||
int m_isHidden; ///< UiItem should be hidden. -1 means not set
|
||||
int m_isChildrenHidden; ///< Children of UiItem should be hidden. -1 means not set
|
||||
int m_isReadOnly; ///< UiItem should be insensitive, or read only. -1 means not set.
|
||||
LabelPosType m_labelAlignment;
|
||||
QString m_uiName;
|
||||
QString m_toolTip;
|
||||
QString m_whatsThis;
|
||||
QIcon m_icon;
|
||||
QString m_editorTypeName; ///< Use this exact type of editor to edit this UiItem
|
||||
int m_isHidden; ///< UiItem should be hidden. -1 means not set
|
||||
int m_isTreeChildrenHidden; ///< Children of UiItem should be hidden. -1 means not set
|
||||
int m_isReadOnly; ///< UiItem should be insensitive, or read only. -1 means not set.
|
||||
LabelPosType m_labelAlignment;
|
||||
};
|
||||
|
||||
//==================================================================================================
|
||||
@ -184,8 +184,11 @@ public:
|
||||
bool isUiHidden(QString uiConfigName = "") const;
|
||||
void setUiHidden(bool isHidden, QString uiConfigName = "") { m_configItemInfos[uiConfigName].m_isHidden = isHidden; }
|
||||
|
||||
bool isUiChildrenHidden(QString uiConfigName = "") const;
|
||||
void setUiChildrenHidden(bool isChildrenHidden, QString uiConfigName = "") { m_configItemInfos[uiConfigName].m_isChildrenHidden = isChildrenHidden; }
|
||||
bool isUiTreeHidden(QString uiConfigName = "") const;
|
||||
void setUiTreeHidden(bool isHidden, QString uiConfigName = "") { m_configItemInfos[uiConfigName].m_isHidden = isHidden; }
|
||||
|
||||
bool isUiTreeChildrenHidden(QString uiConfigName = "") const;
|
||||
void setUiTreeChildrenHidden(bool isTreeChildrenHidden, QString uiConfigName = "") { m_configItemInfos[uiConfigName].m_isTreeChildrenHidden = isTreeChildrenHidden; }
|
||||
|
||||
bool isUiReadOnly(QString uiConfigName = "");
|
||||
void setUiReadOnly(bool isReadOnly, QString uiConfigName = "") { m_configItemInfos[uiConfigName].m_isReadOnly = isReadOnly; }
|
||||
|
@ -114,7 +114,7 @@ void PdmUiObjectHandle::addDefaultUiTreeChildren(PdmUiTreeOrdering* uiTreeOrderi
|
||||
{
|
||||
if (fields[fIdx]->hasChildObjects() && !uiTreeOrdering->containsField(fields[fIdx]))
|
||||
{
|
||||
if (fields[fIdx]->uiCapability()->isUiHidden() && !fields[fIdx]->uiCapability()->isUiChildrenHidden())
|
||||
if (fields[fIdx]->uiCapability()->isUiHidden() && !fields[fIdx]->uiCapability()->isUiTreeChildrenHidden())
|
||||
{
|
||||
std::vector<PdmObjectHandle*> children;
|
||||
fields[fIdx]->childObjects(&children);
|
||||
@ -182,7 +182,7 @@ void PdmUiObjectHandle::expandUiTree(PdmUiTreeOrdering* root, QString uiConfigNa
|
||||
{
|
||||
if (!root->ignoreSubTree())
|
||||
{
|
||||
if (root->isRepresentingField() && !root->field()->uiCapability()->isUiChildrenHidden(uiConfigName))
|
||||
if (root->isRepresentingField() && !root->field()->uiCapability()->isUiTreeChildrenHidden(uiConfigName))
|
||||
{
|
||||
std::vector<PdmObjectHandle*> fieldsChildObjects;
|
||||
root->field()->childObjects(&fieldsChildObjects);
|
||||
@ -195,7 +195,7 @@ void PdmUiObjectHandle::expandUiTree(PdmUiTreeOrdering* root, QString uiConfigNa
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (root->isRepresentingObject() && !root->object()->uiCapability()->isUiChildrenHidden(uiConfigName))
|
||||
else if (root->isRepresentingObject() && !root->object()->uiCapability()->isUiTreeChildrenHidden(uiConfigName))
|
||||
{
|
||||
uiObj(root->object())->defineUiTreeOrdering(*root, uiConfigName);
|
||||
uiObj(root->object())->addDefaultUiTreeChildren(root);
|
||||
|
@ -52,11 +52,27 @@ namespace caf
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void PdmUiTreeOrdering::add(PdmFieldHandle * field)
|
||||
void PdmUiTreeOrdering::add(PdmFieldHandle* field, QString uiConfigName)
|
||||
{
|
||||
assert(field);
|
||||
|
||||
PdmUiTreeOrdering* child = new PdmUiTreeOrdering(this, field);
|
||||
if (field->uiCapability()->isUiTreeHidden(uiConfigName))
|
||||
{
|
||||
if (!field->uiCapability()->isUiTreeChildrenHidden(uiConfigName))
|
||||
{
|
||||
std::vector<PdmObjectHandle*> children;
|
||||
field->childObjects(&children);
|
||||
|
||||
for (PdmObjectHandle* objHandle : children)
|
||||
{
|
||||
this->add(objHandle);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PdmUiTreeOrdering* child = new PdmUiTreeOrdering(this, field);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -69,7 +69,7 @@ public:
|
||||
|
||||
~PdmUiTreeOrdering();
|
||||
|
||||
void add(PdmFieldHandle * field);
|
||||
void add(PdmFieldHandle * field, QString uiConfigName = "");
|
||||
void add(PdmObjectHandle* object);
|
||||
PdmUiTreeOrdering* add(const QString & title, const QString& iconResourceName );
|
||||
|
||||
|
@ -171,6 +171,30 @@ void PdmUiDefaultObjectEditor::configureAndUpdateUi(const QString& uiConfigName)
|
||||
m_groupBoxes = m_newGroupBoxes;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void PdmUiDefaultObjectEditor::cleanupBeforeSettingPdmObject()
|
||||
{
|
||||
std::map<QString, PdmUiFieldEditorHandle*>::iterator it;
|
||||
for (it = m_fieldViews.begin(); it != m_fieldViews.end(); ++it)
|
||||
{
|
||||
PdmUiFieldEditorHandle* fvh = it->second;
|
||||
delete fvh;
|
||||
}
|
||||
m_fieldViews.clear();
|
||||
|
||||
m_newGroupBoxes.clear();
|
||||
|
||||
std::map<QString, QPointer<QGroupBox> >::iterator groupIt;
|
||||
for (groupIt = m_groupBoxes.begin(); groupIt != m_groupBoxes.end(); ++groupIt)
|
||||
{
|
||||
if (!groupIt->second.isNull()) groupIt->second->deleteLater();
|
||||
}
|
||||
|
||||
m_groupBoxes.clear();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -61,8 +61,9 @@ public:
|
||||
~PdmUiDefaultObjectEditor();
|
||||
|
||||
protected:
|
||||
virtual QWidget* createWidget(QWidget* parent);
|
||||
virtual void configureAndUpdateUi(const QString& uiConfigName);
|
||||
virtual QWidget* createWidget(QWidget* parent) override;
|
||||
virtual void configureAndUpdateUi(const QString& uiConfigName) override;
|
||||
virtual void cleanupBeforeSettingPdmObject() override;
|
||||
|
||||
private:
|
||||
void recursiveSetupFieldsAndGroups(const std::vector<PdmUiItem*>& uiItems, QWidget* parent, QGridLayout* parentLayout, const QString& uiConfigName);
|
||||
|
Loading…
Reference in New Issue
Block a user