2019-02-21 05:52:23 -06:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2019- Equinor 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 "RimGridCrossPlot.h"
|
|
|
|
|
2019-04-10 09:13:40 -05:00
|
|
|
#include "RiaApplication.h"
|
|
|
|
#include "RiaFontCache.h"
|
|
|
|
#include "RiaPreferences.h"
|
|
|
|
|
2019-10-15 04:30:06 -05:00
|
|
|
#include "RifTextDataTableFormatter.h"
|
2019-03-04 08:35:48 -06:00
|
|
|
#include "RiuGridCrossQwtPlot.h"
|
2019-02-25 07:54:36 -06:00
|
|
|
#include "RiuPlotMainWindowTools.h"
|
2019-02-21 05:52:23 -06:00
|
|
|
#include "RiuQwtPlotTools.h"
|
|
|
|
|
2019-02-25 07:54:36 -06:00
|
|
|
#include "RimGridCrossPlotCurve.h"
|
2019-03-29 07:17:39 -05:00
|
|
|
#include "RimGridCrossPlotDataSet.h"
|
2019-02-25 07:54:36 -06:00
|
|
|
#include "RimPlotAxisProperties.h"
|
2019-02-21 05:52:23 -06:00
|
|
|
|
|
|
|
#include "cafPdmUiCheckBoxEditor.h"
|
2019-02-25 07:54:36 -06:00
|
|
|
#include "cafPdmUiTreeOrdering.h"
|
|
|
|
|
2019-03-11 05:39:23 -05:00
|
|
|
#include "cafProgressInfo.h"
|
2019-02-21 05:52:23 -06:00
|
|
|
#include "cvfAssert.h"
|
|
|
|
|
|
|
|
#include "qwt_legend.h"
|
|
|
|
#include "qwt_plot.h"
|
|
|
|
#include "qwt_plot_curve.h"
|
2019-03-26 09:36:10 -05:00
|
|
|
#include "qwt_scale_engine.h"
|
2019-02-21 05:52:23 -06:00
|
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
CAF_PDM_SOURCE_INIT( RimGridCrossPlot, "RimGridCrossPlot" );
|
2019-02-21 05:52:23 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimGridCrossPlot::RimGridCrossPlot()
|
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
CAF_PDM_InitObject( "Grid Cross Plot", ":/SummaryXPlotLight16x16.png", "", "" );
|
2019-02-21 05:52:23 -06:00
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
CAF_PDM_InitField( &m_showInfoBox, "ShowInfoBox", true, "Show Info Box", "", "", "" );
|
|
|
|
CAF_PDM_InitField( &m_showLegend, "ShowLegend", true, "Show Legend", "", "", "" );
|
|
|
|
CAF_PDM_InitField( &m_legendFontSize, "LegendFontSize", 10, "Legend and Info Font Size", "", "", "" );
|
|
|
|
m_legendFontSize = RiaFontCache::pointSizeFromFontSizeEnum(
|
|
|
|
RiaApplication::instance()->preferences()->defaultPlotFontSize() );
|
2019-04-10 09:13:40 -05:00
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
CAF_PDM_InitFieldNoDefault( &m_nameConfig, "NameConfig", "Name Config", "", "", "" );
|
|
|
|
m_nameConfig.uiCapability()->setUiTreeHidden( true );
|
|
|
|
m_nameConfig.uiCapability()->setUiTreeChildrenHidden( true );
|
2019-09-06 03:59:04 -05:00
|
|
|
m_nameConfig = new RimGridCrossPlotNameConfig();
|
2019-02-21 05:52:23 -06:00
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
CAF_PDM_InitFieldNoDefault( &m_xAxisProperties, "xAxisProperties", "X Axis", "", "", "" );
|
|
|
|
m_xAxisProperties.uiCapability()->setUiTreeHidden( true );
|
2019-02-25 07:54:36 -06:00
|
|
|
m_xAxisProperties = new RimPlotAxisProperties;
|
2019-09-06 06:17:36 -05:00
|
|
|
m_xAxisProperties->setNameAndAxis( "X-Axis", QwtPlot::xBottom );
|
|
|
|
m_xAxisProperties->setEnableTitleTextSettings( false );
|
2019-02-25 07:54:36 -06:00
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
CAF_PDM_InitFieldNoDefault( &m_yAxisProperties, "yAxisProperties", "Y Axis", "", "", "" );
|
|
|
|
m_yAxisProperties.uiCapability()->setUiTreeHidden( true );
|
2019-02-25 07:54:36 -06:00
|
|
|
m_yAxisProperties = new RimPlotAxisProperties;
|
2019-09-06 06:17:36 -05:00
|
|
|
m_yAxisProperties->setNameAndAxis( "Y-Axis", QwtPlot::yLeft );
|
|
|
|
m_yAxisProperties->setEnableTitleTextSettings( false );
|
2019-09-06 03:59:04 -05:00
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
CAF_PDM_InitFieldNoDefault( &m_crossPlotDataSets, "CrossPlotCurve", "Cross Plot Data Set", "", "", "" );
|
|
|
|
m_crossPlotDataSets.uiCapability()->setUiHidden( true );
|
2019-02-21 05:52:23 -06:00
|
|
|
}
|
|
|
|
|
2019-02-21 08:42:28 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimGridCrossPlot::~RimGridCrossPlot()
|
|
|
|
{
|
|
|
|
removeMdiWindowFromMdiArea();
|
|
|
|
deleteViewWidget();
|
|
|
|
}
|
|
|
|
|
2019-02-21 05:52:23 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-29 07:17:39 -05:00
|
|
|
RimGridCrossPlotDataSet* RimGridCrossPlot::createDataSet()
|
2019-02-21 05:52:23 -06:00
|
|
|
{
|
2019-03-29 07:17:39 -05:00
|
|
|
RimGridCrossPlotDataSet* dataSet = new RimGridCrossPlotDataSet();
|
2019-09-06 06:17:36 -05:00
|
|
|
m_crossPlotDataSets.push_back( dataSet );
|
2019-03-29 07:17:39 -05:00
|
|
|
return dataSet;
|
2019-02-21 05:52:23 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 06:17:36 -05:00
|
|
|
int RimGridCrossPlot::indexOfDataSet( const RimGridCrossPlotDataSet* dataSetToCheck ) const
|
2019-02-21 05:52:23 -06:00
|
|
|
{
|
2019-03-25 08:47:55 -05:00
|
|
|
int index = 0;
|
2019-09-06 06:17:36 -05:00
|
|
|
for ( auto dataSet : m_crossPlotDataSets() )
|
2019-02-21 05:52:23 -06:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( dataSet == dataSetToCheck )
|
2019-03-25 08:47:55 -05:00
|
|
|
{
|
|
|
|
return index;
|
|
|
|
}
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( dataSet->isChecked() && dataSet->visibleCurveCount() > 0u )
|
2019-02-21 05:52:23 -06:00
|
|
|
{
|
2019-03-25 08:47:55 -05:00
|
|
|
index++;
|
2019-02-21 05:52:23 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2019-03-12 08:46:51 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-26 09:36:10 -05:00
|
|
|
///
|
2019-03-12 08:46:51 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 06:17:36 -05:00
|
|
|
void RimGridCrossPlot::addDataSet( RimGridCrossPlotDataSet* dataSet )
|
2019-03-12 08:46:51 -05:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
m_crossPlotDataSets.push_back( dataSet );
|
2019-03-12 08:46:51 -05:00
|
|
|
}
|
|
|
|
|
2019-03-04 08:35:48 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-29 07:17:39 -05:00
|
|
|
std::vector<RimGridCrossPlotDataSet*> RimGridCrossPlot::dataSets() const
|
2019-03-04 08:35:48 -06:00
|
|
|
{
|
2019-03-29 07:17:39 -05:00
|
|
|
return m_crossPlotDataSets.childObjects();
|
2019-03-04 08:35:48 -06:00
|
|
|
}
|
|
|
|
|
2019-02-21 05:52:23 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QWidget* RimGridCrossPlot::viewWidget()
|
|
|
|
{
|
|
|
|
return m_qwtPlot;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QImage RimGridCrossPlot::snapshotWindowContent()
|
|
|
|
{
|
|
|
|
QImage image;
|
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( m_qwtPlot )
|
2019-02-21 05:52:23 -06:00
|
|
|
{
|
2019-09-13 08:13:49 -05:00
|
|
|
QPixmap pix = m_qwtPlot->grab();
|
2019-02-21 05:52:23 -06:00
|
|
|
image = pix.toImage();
|
|
|
|
}
|
|
|
|
|
|
|
|
return image;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimGridCrossPlot::zoomAll()
|
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( !m_qwtPlot ) return;
|
2019-03-18 06:41:44 -05:00
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
setAutoZoomForAllAxes( true );
|
|
|
|
updateAxisInQwt( RiaDefines::PLOT_AXIS_LEFT );
|
|
|
|
updateAxisInQwt( RiaDefines::PLOT_AXIS_BOTTOM );
|
2019-03-26 09:36:10 -05:00
|
|
|
|
2019-02-25 07:54:36 -06:00
|
|
|
m_qwtPlot->replot();
|
2019-03-26 09:36:10 -05:00
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
updateAxisFromQwt( RiaDefines::PLOT_AXIS_LEFT );
|
|
|
|
updateAxisFromQwt( RiaDefines::PLOT_AXIS_BOTTOM );
|
2019-02-21 05:52:23 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimGridCrossPlot::calculateZoomRangeAndUpdateQwt()
|
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( m_qwtPlot )
|
2019-03-07 07:17:12 -06:00
|
|
|
{
|
|
|
|
m_qwtPlot->replot();
|
|
|
|
}
|
2019-02-21 05:52:23 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimGridCrossPlot::reattachCurvesToQwtAndReplot()
|
2019-03-26 09:36:10 -05:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( m_qwtPlot )
|
2019-02-21 05:52:23 -06:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
for ( auto dataSet : m_crossPlotDataSets )
|
2019-02-22 03:15:07 -06:00
|
|
|
{
|
2019-03-29 07:17:39 -05:00
|
|
|
dataSet->detachAllCurves();
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( dataSet->isChecked() )
|
2019-02-28 11:30:07 -06:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
dataSet->setParentQwtPlotNoReplot( m_qwtPlot );
|
2019-02-28 11:30:07 -06:00
|
|
|
}
|
2019-02-22 03:15:07 -06:00
|
|
|
}
|
2019-03-04 08:35:48 -06:00
|
|
|
updateAxisDisplay();
|
2019-02-21 05:52:23 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QString RimGridCrossPlot::createAutoName() const
|
|
|
|
{
|
|
|
|
QStringList autoName;
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( !m_nameConfig->customName().isEmpty() )
|
2019-02-21 05:52:23 -06:00
|
|
|
{
|
|
|
|
autoName += m_nameConfig->customName();
|
|
|
|
}
|
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( m_nameConfig->addDataSetNames() )
|
2019-02-21 05:52:23 -06:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
QStringList dataSetStrings;
|
2019-03-29 07:17:39 -05:00
|
|
|
std::map<RimGridCrossPlotDataSet::NameComponents, std::set<QString>> allNameComponents;
|
2019-09-06 06:17:36 -05:00
|
|
|
for ( auto dataSet : m_crossPlotDataSets )
|
2019-02-21 05:52:23 -06:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( dataSet->isChecked() )
|
2019-03-04 08:35:48 -06:00
|
|
|
{
|
2019-03-07 07:17:12 -06:00
|
|
|
QStringList componentList;
|
2019-09-06 06:17:36 -05:00
|
|
|
auto dataSetNameComponents = dataSet->nameComponents();
|
2019-03-07 07:17:12 -06:00
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
for ( auto dataSetNameComponent : dataSetNameComponents )
|
2019-03-07 07:17:12 -06:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( !dataSetNameComponent.second.isEmpty() )
|
2019-03-07 07:17:12 -06:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( allNameComponents[dataSetNameComponent.first].count( dataSetNameComponent.second ) == 0u )
|
2019-03-07 07:17:12 -06:00
|
|
|
{
|
2019-03-29 07:17:39 -05:00
|
|
|
componentList += dataSetNameComponent.second;
|
2019-09-06 06:17:36 -05:00
|
|
|
allNameComponents[dataSetNameComponent.first].insert( dataSetNameComponent.second );
|
2019-03-07 07:17:12 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( !componentList.isEmpty() )
|
2019-03-07 07:17:12 -06:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
dataSetStrings += componentList.join( ", " );
|
2019-03-07 07:17:12 -06:00
|
|
|
}
|
2019-03-04 08:35:48 -06:00
|
|
|
}
|
2019-02-21 05:52:23 -06:00
|
|
|
}
|
2019-03-26 09:36:10 -05:00
|
|
|
|
2019-03-07 07:17:12 -06:00
|
|
|
dataSetStrings.removeDuplicates();
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( dataSetStrings.size() > 2 )
|
2019-03-07 07:17:12 -06:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
autoName += QString( "(%1 Data Sets)" ).arg( dataSetStrings.size() );
|
2019-03-07 07:17:12 -06:00
|
|
|
}
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( !dataSetStrings.isEmpty() )
|
2019-02-21 05:52:23 -06:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
autoName += QString( "(%1)" ).arg( dataSetStrings.join( "; " ) );
|
2019-02-21 05:52:23 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
return autoName.join( " " );
|
2019-02-21 05:52:23 -06:00
|
|
|
}
|
|
|
|
|
2019-03-25 08:47:55 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RimGridCrossPlot::showInfoBox() const
|
|
|
|
{
|
|
|
|
return m_showInfoBox();
|
|
|
|
}
|
|
|
|
|
2019-02-21 05:52:23 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
caf::PdmFieldHandle* RimGridCrossPlot::userDescriptionField()
|
|
|
|
{
|
|
|
|
return m_nameConfig->nameField();
|
|
|
|
}
|
|
|
|
|
2019-02-25 07:54:36 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimGridCrossPlot::detachAllCurves()
|
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
for ( auto dataSet : m_crossPlotDataSets() )
|
2019-02-25 07:54:36 -06:00
|
|
|
{
|
2019-03-29 07:17:39 -05:00
|
|
|
dataSet->detachAllCurves();
|
2019-02-25 07:54:36 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimGridCrossPlot::updateAxisScaling()
|
|
|
|
{
|
2019-03-13 04:16:46 -05:00
|
|
|
loadDataAndUpdate();
|
2019-02-25 07:54:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimGridCrossPlot::updateAxisDisplay()
|
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( !m_qwtPlot ) return;
|
2019-03-18 06:41:44 -05:00
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
updateAxisInQwt( RiaDefines::PLOT_AXIS_BOTTOM );
|
|
|
|
updateAxisInQwt( RiaDefines::PLOT_AXIS_LEFT );
|
2019-03-26 09:36:10 -05:00
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
m_qwtPlot->updateAnnotationObjects( m_xAxisProperties );
|
|
|
|
m_qwtPlot->updateAnnotationObjects( m_yAxisProperties );
|
2019-03-12 10:05:58 -05:00
|
|
|
|
2019-02-25 07:54:36 -06:00
|
|
|
m_qwtPlot->replot();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimGridCrossPlot::updateZoomWindowFromQwt()
|
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( !m_qwtPlot ) return;
|
2019-03-26 09:36:10 -05:00
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
updateAxisFromQwt( RiaDefines::PLOT_AXIS_LEFT );
|
|
|
|
updateAxisFromQwt( RiaDefines::PLOT_AXIS_BOTTOM );
|
|
|
|
setAutoZoomForAllAxes( false );
|
2019-02-25 07:54:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 06:17:36 -05:00
|
|
|
void RimGridCrossPlot::selectAxisInPropertyEditor( int axis )
|
2019-02-25 07:54:36 -06:00
|
|
|
{
|
|
|
|
RiuPlotMainWindowTools::showPlotMainWindow();
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( axis == QwtPlot::yLeft )
|
2019-02-25 07:54:36 -06:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
RiuPlotMainWindowTools::selectAsCurrentItem( m_yAxisProperties );
|
2019-02-25 07:54:36 -06:00
|
|
|
}
|
2019-09-06 06:17:36 -05:00
|
|
|
else if ( axis == QwtPlot::xBottom )
|
2019-02-25 07:54:36 -06:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
RiuPlotMainWindowTools::selectAsCurrentItem( m_xAxisProperties );
|
2019-02-25 07:54:36 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 06:17:36 -05:00
|
|
|
void RimGridCrossPlot::setAutoZoomForAllAxes( bool enableAutoZoom )
|
2019-02-25 07:54:36 -06:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
m_xAxisProperties->setAutoZoom( enableAutoZoom );
|
|
|
|
m_yAxisProperties->setAutoZoom( enableAutoZoom );
|
2019-02-25 07:54:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 06:17:36 -05:00
|
|
|
caf::PdmObject* RimGridCrossPlot::findRimPlotObjectFromQwtCurve( const QwtPlotCurve* qwtCurve ) const
|
2019-02-25 07:54:36 -06:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
for ( auto dataSet : m_crossPlotDataSets )
|
2019-02-25 07:54:36 -06:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
for ( auto curve : dataSet->curves() )
|
2019-02-25 07:54:36 -06:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( curve->qwtPlotCurve() == qwtCurve )
|
2019-02-25 07:54:36 -06:00
|
|
|
{
|
|
|
|
return curve;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2019-02-21 05:52:23 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 06:17:36 -05:00
|
|
|
QWidget* RimGridCrossPlot::createViewWidget( QWidget* mainWindowParent )
|
2019-02-21 05:52:23 -06:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( !m_qwtPlot )
|
2019-02-21 05:52:23 -06:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
m_qwtPlot = new RiuGridCrossQwtPlot( this, mainWindowParent );
|
2019-02-21 08:42:28 -06:00
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
for ( auto dataSet : m_crossPlotDataSets )
|
2019-02-21 08:42:28 -06:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
dataSet->setParentQwtPlotNoReplot( m_qwtPlot );
|
2019-02-21 08:42:28 -06:00
|
|
|
}
|
|
|
|
m_qwtPlot->replot();
|
2019-02-21 05:52:23 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
return m_qwtPlot;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimGridCrossPlot::deleteViewWidget()
|
|
|
|
{
|
2019-02-21 08:42:28 -06:00
|
|
|
detachAllCurves();
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( m_qwtPlot )
|
2019-02-21 05:52:23 -06:00
|
|
|
{
|
|
|
|
m_qwtPlot->deleteLater();
|
|
|
|
m_qwtPlot = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimGridCrossPlot::onLoadDataAndUpdate()
|
|
|
|
{
|
|
|
|
updateMdiWindowVisibility();
|
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
for ( auto dataSet : m_crossPlotDataSets )
|
2019-02-21 05:52:23 -06:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
dataSet->loadDataAndUpdate( false );
|
2019-03-29 07:17:39 -05:00
|
|
|
dataSet->updateConnectedEditors();
|
2019-02-21 05:52:23 -06:00
|
|
|
}
|
|
|
|
|
2019-03-04 03:19:02 -06:00
|
|
|
updateCurveNamesAndPlotTitle();
|
2019-03-26 09:36:10 -05:00
|
|
|
updatePlot();
|
2019-02-21 05:52:23 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 06:17:36 -05:00
|
|
|
void RimGridCrossPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
|
2019-02-21 05:52:23 -06:00
|
|
|
{
|
2019-10-09 02:21:28 -05:00
|
|
|
RimViewWindow::defineUiOrdering( uiConfigName, uiOrdering );
|
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
uiOrdering.add( &m_showInfoBox );
|
|
|
|
uiOrdering.add( &m_showLegend );
|
2019-02-21 05:52:23 -06:00
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( m_showLegend() )
|
2019-02-21 05:52:23 -06:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
uiOrdering.add( &m_legendFontSize );
|
2019-02-21 05:52:23 -06:00
|
|
|
}
|
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
caf::PdmUiGroup* nameGroup = uiOrdering.addNewGroup( "Name Configuration" );
|
|
|
|
m_nameConfig->uiOrdering( uiConfigName, *nameGroup );
|
2019-02-21 05:52:23 -06:00
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
uiOrdering.skipRemainingFields( true );
|
2019-02-21 05:52:23 -06:00
|
|
|
}
|
|
|
|
|
2019-02-25 07:54:36 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 06:17:36 -05:00
|
|
|
void RimGridCrossPlot::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/ )
|
2019-02-25 07:54:36 -06:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
caf::PdmUiTreeOrdering* axisFolder = uiTreeOrdering.add( "Axes", ":/Axes16x16.png" );
|
2019-02-25 07:54:36 -06:00
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
axisFolder->add( &m_xAxisProperties );
|
|
|
|
axisFolder->add( &m_yAxisProperties );
|
2019-02-25 07:54:36 -06:00
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
uiTreeOrdering.add( &m_crossPlotDataSets );
|
2019-02-25 07:54:36 -06:00
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
uiTreeOrdering.skipRemainingChildren( true );
|
2019-02-25 07:54:36 -06:00
|
|
|
}
|
|
|
|
|
2019-02-21 05:52:23 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 06:17:36 -05:00
|
|
|
void RimGridCrossPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
|
|
|
const QVariant& oldValue,
|
|
|
|
const QVariant& newValue )
|
2019-02-21 05:52:23 -06:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( changedField == &m_legendFontSize )
|
2019-03-28 14:09:25 -05:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
for ( auto dataSet : m_crossPlotDataSets )
|
2019-03-28 14:09:25 -05:00
|
|
|
{
|
2019-03-29 07:17:39 -05:00
|
|
|
dataSet->updateLegendIcons();
|
2019-03-28 14:09:25 -05:00
|
|
|
}
|
|
|
|
}
|
2019-02-21 05:52:23 -06:00
|
|
|
onLoadDataAndUpdate();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 06:17:36 -05:00
|
|
|
QList<caf::PdmOptionItemInfo> RimGridCrossPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
|
|
|
|
bool* useOptionsOnly )
|
2019-02-21 05:52:23 -06:00
|
|
|
{
|
|
|
|
QList<caf::PdmOptionItemInfo> options;
|
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( fieldNeedingOptions == &m_legendFontSize )
|
2019-02-21 05:52:23 -06:00
|
|
|
{
|
|
|
|
std::vector<int> fontSizes;
|
2019-09-06 06:17:36 -05:00
|
|
|
fontSizes.push_back( 8 );
|
|
|
|
fontSizes.push_back( 10 );
|
|
|
|
fontSizes.push_back( 12 );
|
|
|
|
fontSizes.push_back( 14 );
|
|
|
|
fontSizes.push_back( 16 );
|
2019-02-21 05:52:23 -06:00
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
for ( int value : fontSizes )
|
2019-02-21 05:52:23 -06:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
QString text = QString( "%1" ).arg( value );
|
|
|
|
options.push_back( caf::PdmOptionItemInfo( text, value ) );
|
2019-02-21 05:52:23 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return options;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimGridCrossPlot::performAutoNameUpdate()
|
|
|
|
{
|
2019-03-04 03:19:02 -06:00
|
|
|
updateCurveNamesAndPlotTitle();
|
2019-02-21 05:52:23 -06:00
|
|
|
}
|
|
|
|
|
2019-02-21 08:42:28 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimGridCrossPlot::updatePlot()
|
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( m_qwtPlot )
|
2019-02-21 08:42:28 -06:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
RiuQwtPlotTools::setCommonPlotBehaviour( m_qwtPlot );
|
|
|
|
RiuQwtPlotTools::setDefaultAxes( m_qwtPlot );
|
2019-02-21 08:42:28 -06:00
|
|
|
|
2019-02-25 07:54:36 -06:00
|
|
|
updateAxisDisplay();
|
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
for ( auto dataSet : m_crossPlotDataSets )
|
2019-02-21 08:42:28 -06:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
dataSet->setParentQwtPlotNoReplot( m_qwtPlot );
|
2019-02-21 08:42:28 -06:00
|
|
|
}
|
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( m_showLegend() )
|
2019-02-21 08:42:28 -06:00
|
|
|
{
|
|
|
|
// Will be released in plot destructor or when a new legend is set
|
2019-09-06 06:17:36 -05:00
|
|
|
QwtLegend* legend = new QwtLegend( m_qwtPlot );
|
2019-02-21 08:42:28 -06:00
|
|
|
|
|
|
|
auto font = legend->font();
|
2019-09-06 06:17:36 -05:00
|
|
|
font.setPointSize( m_legendFontSize() );
|
|
|
|
legend->setFont( font );
|
|
|
|
m_qwtPlot->insertLegend( legend, QwtPlot::BottomLegend );
|
2019-02-21 08:42:28 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
m_qwtPlot->insertLegend( nullptr );
|
2019-02-21 08:42:28 -06:00
|
|
|
}
|
2019-03-08 02:59:29 -06:00
|
|
|
m_qwtPlot->updateLegendSizesToMatchPlot();
|
2019-02-21 08:42:28 -06:00
|
|
|
m_qwtPlot->replot();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-04 03:19:02 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimGridCrossPlot::updateCurveNamesAndPlotTitle()
|
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
for ( size_t i = 0; i < m_crossPlotDataSets.size(); ++i )
|
2019-03-07 07:17:12 -06:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
m_crossPlotDataSets[i]->updateCurveNames( i, m_crossPlotDataSets.size() );
|
2019-03-07 07:17:12 -06:00
|
|
|
}
|
2019-03-04 03:19:02 -06:00
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( m_qwtPlot )
|
2019-03-04 03:19:02 -06:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
m_qwtPlot->setTitle( this->createAutoName() );
|
2019-03-04 03:19:02 -06:00
|
|
|
}
|
2019-03-20 12:54:02 -05:00
|
|
|
updateMdiWindowTitle();
|
2019-03-04 03:19:02 -06:00
|
|
|
}
|
|
|
|
|
2019-03-08 02:59:29 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-13 02:38:18 -05:00
|
|
|
void RimGridCrossPlot::swapAxes()
|
2019-03-08 02:59:29 -06:00
|
|
|
{
|
2019-03-13 02:38:18 -05:00
|
|
|
RimPlotAxisProperties* xAxisProperties = m_xAxisProperties();
|
|
|
|
RimPlotAxisProperties* yAxisProperties = m_yAxisProperties();
|
|
|
|
|
2019-03-26 09:36:10 -05:00
|
|
|
QString tmpName = xAxisProperties->name();
|
2019-03-13 02:38:18 -05:00
|
|
|
QwtPlot::Axis tmpAxis = xAxisProperties->qwtPlotAxisType();
|
2019-09-06 06:17:36 -05:00
|
|
|
xAxisProperties->setNameAndAxis( yAxisProperties->name(), yAxisProperties->qwtPlotAxisType() );
|
|
|
|
yAxisProperties->setNameAndAxis( tmpName, tmpAxis );
|
2019-03-13 02:38:18 -05:00
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
m_xAxisProperties.removeChildObject( xAxisProperties );
|
|
|
|
m_yAxisProperties.removeChildObject( yAxisProperties );
|
2019-03-13 02:38:18 -05:00
|
|
|
m_yAxisProperties = xAxisProperties;
|
|
|
|
m_xAxisProperties = yAxisProperties;
|
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
for ( auto dataSet : m_crossPlotDataSets )
|
2019-03-08 02:59:29 -06:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
dataSet->swapAxisProperties( false );
|
2019-03-08 02:59:29 -06:00
|
|
|
}
|
2019-03-13 02:38:18 -05:00
|
|
|
|
2019-03-08 02:59:29 -06:00
|
|
|
loadDataAndUpdate();
|
2019-03-26 09:36:10 -05:00
|
|
|
|
2019-03-13 02:38:18 -05:00
|
|
|
updateAxisDisplay();
|
2019-03-08 02:59:29 -06:00
|
|
|
}
|
|
|
|
|
2019-03-11 05:39:23 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 06:17:36 -05:00
|
|
|
QString RimGridCrossPlot::asciiTitleForPlotExport( int dataSetIndex ) const
|
2019-03-11 05:39:23 -05:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( (size_t)dataSetIndex < m_crossPlotDataSets.size() )
|
2019-03-11 05:39:23 -05:00
|
|
|
{
|
2019-03-29 07:17:39 -05:00
|
|
|
return m_crossPlotDataSets[dataSetIndex]->createAutoName();
|
2019-03-11 05:39:23 -05:00
|
|
|
}
|
|
|
|
return "Data invalid";
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 06:17:36 -05:00
|
|
|
QString RimGridCrossPlot::asciiDataForPlotExport( int dataSetIndex ) const
|
2019-03-11 05:39:23 -05:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( (size_t)dataSetIndex < m_crossPlotDataSets.size() )
|
2019-03-11 05:39:23 -05:00
|
|
|
{
|
|
|
|
QString asciiData;
|
2019-09-06 06:17:36 -05:00
|
|
|
QTextStream stringStream( &asciiData );
|
2019-03-11 05:39:23 -05:00
|
|
|
|
2019-10-15 04:30:06 -05:00
|
|
|
RifTextDataTableFormatter formatter( stringStream );
|
2019-09-06 06:17:36 -05:00
|
|
|
formatter.setCommentPrefix( "" );
|
|
|
|
formatter.setTableRowPrependText( "" );
|
|
|
|
formatter.setTableRowLineAppendText( "" );
|
|
|
|
formatter.setColumnSpacing( 3 );
|
2019-03-11 05:39:23 -05:00
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
m_crossPlotDataSets[dataSetIndex]->exportFormattedData( formatter );
|
2019-03-11 05:39:23 -05:00
|
|
|
formatter.tableCompleted();
|
|
|
|
return asciiData;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return "Data invalid and may have been deleted.";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-04 08:35:48 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RiuGridCrossQwtPlot* RimGridCrossPlot::qwtPlot() const
|
|
|
|
{
|
|
|
|
return m_qwtPlot;
|
|
|
|
}
|
|
|
|
|
2019-03-13 04:16:46 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RimGridCrossPlot::isXAxisLogarithmic() const
|
|
|
|
{
|
|
|
|
return m_xAxisProperties->isLogarithmicScaleEnabled();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RimGridCrossPlot::isYAxisLogarithmic() const
|
|
|
|
{
|
|
|
|
return m_yAxisProperties->isLogarithmicScaleEnabled();
|
|
|
|
}
|
|
|
|
|
2019-03-19 03:07:04 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 06:17:36 -05:00
|
|
|
void RimGridCrossPlot::setYAxisInverted( bool inverted )
|
2019-03-19 03:07:04 -05:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
m_yAxisProperties->setAxisInverted( inverted );
|
2019-03-19 03:07:04 -05:00
|
|
|
}
|
|
|
|
|
2019-03-28 14:09:25 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
int RimGridCrossPlot::legendFontSize() const
|
|
|
|
{
|
|
|
|
return m_legendFontSize;
|
|
|
|
}
|
|
|
|
|
2019-04-10 09:13:40 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 06:17:36 -05:00
|
|
|
bool RimGridCrossPlot::hasCustomFontSizes( RiaDefines::FontSettingType fontSettingType, int defaultFontSize ) const
|
2019-04-10 09:13:40 -05:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( fontSettingType != RiaDefines::PLOT_FONT ) return false;
|
2019-04-10 09:13:40 -05:00
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
for ( auto plotAxis : allPlotAxes() )
|
2019-04-10 09:13:40 -05:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( plotAxis->titleFontSize() != defaultFontSize || plotAxis->valuesFontSize() != defaultFontSize )
|
2019-04-10 09:13:40 -05:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( legendFontSize() != defaultFontSize )
|
2019-04-10 09:13:40 -05:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 06:17:36 -05:00
|
|
|
bool RimGridCrossPlot::applyFontSize( RiaDefines::FontSettingType fontSettingType,
|
|
|
|
int oldFontSize,
|
|
|
|
int fontSize,
|
|
|
|
bool forceChange /*= false*/ )
|
2019-04-10 09:13:40 -05:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( fontSettingType != RiaDefines::PLOT_FONT ) return false;
|
2019-04-10 09:13:40 -05:00
|
|
|
|
|
|
|
bool anyChange = false;
|
2019-09-06 06:17:36 -05:00
|
|
|
for ( auto plotAxis : allPlotAxes() )
|
2019-04-10 09:13:40 -05:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( forceChange || plotAxis->titleFontSize() == oldFontSize )
|
2019-04-10 09:13:40 -05:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
plotAxis->setTitleFontSize( fontSize );
|
2019-04-10 09:13:40 -05:00
|
|
|
anyChange = true;
|
|
|
|
}
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( forceChange || plotAxis->valuesFontSize() == oldFontSize )
|
2019-04-10 09:13:40 -05:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
plotAxis->setValuesFontSize( fontSize );
|
2019-04-10 09:13:40 -05:00
|
|
|
anyChange = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( forceChange || legendFontSize() == oldFontSize )
|
2019-04-10 09:13:40 -05:00
|
|
|
{
|
|
|
|
m_legendFontSize = fontSize;
|
2019-09-06 06:17:36 -05:00
|
|
|
anyChange = true;
|
2019-04-10 09:13:40 -05:00
|
|
|
}
|
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( anyChange ) loadDataAndUpdate();
|
2019-04-10 09:13:40 -05:00
|
|
|
|
|
|
|
return anyChange;
|
|
|
|
}
|
|
|
|
|
2019-02-21 05:52:23 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QString RimGridCrossPlot::xAxisParameterString() const
|
|
|
|
{
|
|
|
|
QStringList xAxisParams;
|
2019-09-06 06:17:36 -05:00
|
|
|
for ( auto dataSet : m_crossPlotDataSets )
|
2019-02-21 05:52:23 -06:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( dataSet->isChecked() && dataSet->sampleCount() > 0u )
|
2019-03-04 08:35:48 -06:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
xAxisParams.push_back( dataSet->xAxisName() );
|
2019-03-04 08:35:48 -06:00
|
|
|
}
|
2019-02-21 05:52:23 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
xAxisParams.removeDuplicates();
|
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( xAxisParams.size() > 4 )
|
2019-02-21 05:52:23 -06:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
return QString( "%1 parameters" ).arg( xAxisParams.size() );
|
2019-02-21 05:52:23 -06:00
|
|
|
}
|
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
return xAxisParams.join( ", " );
|
2019-02-21 05:52:23 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QString RimGridCrossPlot::yAxisParameterString() const
|
|
|
|
{
|
|
|
|
QStringList yAxisParams;
|
2019-09-06 06:17:36 -05:00
|
|
|
for ( auto dataSet : m_crossPlotDataSets )
|
2019-02-21 05:52:23 -06:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( dataSet->isChecked() && dataSet->sampleCount() > 0u )
|
2019-03-04 08:35:48 -06:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
yAxisParams.push_back( dataSet->yAxisName() );
|
2019-03-04 08:35:48 -06:00
|
|
|
}
|
2019-02-21 05:52:23 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
yAxisParams.removeDuplicates();
|
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( yAxisParams.size() > 4 )
|
2019-02-21 05:52:23 -06:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
return QString( "%1 parameters" ).arg( yAxisParams.size() );
|
2019-02-21 05:52:23 -06:00
|
|
|
}
|
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
return yAxisParams.join( ", " );
|
2019-02-21 05:52:23 -06:00
|
|
|
}
|
|
|
|
|
2019-02-21 08:42:28 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 06:17:36 -05:00
|
|
|
void RimGridCrossPlot::updateAxisInQwt( RiaDefines::PlotAxis axisType )
|
2019-02-21 08:42:28 -06:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( !m_qwtPlot ) return;
|
2019-03-18 06:41:44 -05:00
|
|
|
|
2019-02-25 07:54:36 -06:00
|
|
|
RimPlotAxisProperties* axisProperties = m_xAxisProperties();
|
|
|
|
QString axisParameterString = xAxisParameterString();
|
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( axisType == RiaDefines::PLOT_AXIS_LEFT )
|
2019-02-21 08:42:28 -06:00
|
|
|
{
|
2019-02-25 07:54:36 -06:00
|
|
|
axisProperties = m_yAxisProperties();
|
|
|
|
axisParameterString = yAxisParameterString();
|
|
|
|
}
|
|
|
|
|
|
|
|
QwtPlot::Axis qwtAxisId = axisProperties->qwtPlotAxisType();
|
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( axisProperties->isActive() )
|
2019-02-25 07:54:36 -06:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
m_qwtPlot->enableAxis( qwtAxisId, true );
|
2019-03-26 09:36:10 -05:00
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
QwtText axisTitle( axisParameterString );
|
|
|
|
QFont titleFont = m_qwtPlot->axisTitle( qwtAxisId ).font();
|
|
|
|
titleFont.setBold( true );
|
|
|
|
titleFont.setPointSize( axisProperties->titleFontSize() );
|
|
|
|
axisTitle.setFont( titleFont );
|
2019-02-25 07:54:36 -06:00
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
QFont valuesFont = m_qwtPlot->axisFont( qwtAxisId );
|
|
|
|
valuesFont.setPointSize( axisProperties->valuesFontSize() );
|
|
|
|
m_qwtPlot->setAxisFont( qwtAxisId, valuesFont );
|
2019-04-10 09:13:40 -05:00
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
switch ( axisProperties->titlePosition() )
|
2019-02-25 07:54:36 -06:00
|
|
|
{
|
|
|
|
case RimPlotAxisProperties::AXIS_TITLE_CENTER:
|
2019-09-06 06:17:36 -05:00
|
|
|
axisTitle.setRenderFlags( Qt::AlignCenter );
|
2019-02-25 07:54:36 -06:00
|
|
|
break;
|
|
|
|
case RimPlotAxisProperties::AXIS_TITLE_END:
|
2019-09-06 06:17:36 -05:00
|
|
|
axisTitle.setRenderFlags( Qt::AlignRight );
|
2019-02-25 07:54:36 -06:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
m_qwtPlot->setAxisTitle( qwtAxisId, axisTitle );
|
2019-02-25 07:54:36 -06:00
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( axisProperties->isLogarithmicScaleEnabled )
|
2019-02-25 07:54:36 -06:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
QwtLogScaleEngine* currentScaleEngine = dynamic_cast<QwtLogScaleEngine*>(
|
|
|
|
m_qwtPlot->axisScaleEngine( axisProperties->qwtPlotAxisType() ) );
|
|
|
|
if ( !currentScaleEngine )
|
2019-02-25 07:54:36 -06:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
m_qwtPlot->setAxisScaleEngine( axisProperties->qwtPlotAxisType(), new QwtLogScaleEngine );
|
|
|
|
m_qwtPlot->setAxisMaxMinor( axisProperties->qwtPlotAxisType(), 5 );
|
2019-02-25 07:54:36 -06:00
|
|
|
}
|
2019-03-13 02:38:18 -05:00
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( axisProperties->isAutoZoom() )
|
2019-03-13 02:38:18 -05:00
|
|
|
{
|
2019-03-13 04:16:46 -05:00
|
|
|
std::vector<const QwtPlotCurve*> plotCurves = visibleQwtCurves();
|
|
|
|
|
2019-03-26 09:36:10 -05:00
|
|
|
double min, max;
|
2019-09-06 06:17:36 -05:00
|
|
|
RimPlotAxisLogRangeCalculator logRangeCalculator( qwtAxisId, plotCurves );
|
|
|
|
logRangeCalculator.computeAxisRange( &min, &max );
|
|
|
|
if ( axisProperties->isAxisInverted() )
|
2019-03-13 04:16:46 -05:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
std::swap( min, max );
|
2019-03-13 04:16:46 -05:00
|
|
|
}
|
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
m_qwtPlot->setAxisScale( qwtAxisId, min, max );
|
2019-03-13 02:38:18 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
m_qwtPlot->setAxisScale( qwtAxisId, axisProperties->visibleRangeMin, axisProperties->visibleRangeMax );
|
2019-03-13 02:38:18 -05:00
|
|
|
}
|
2019-02-25 07:54:36 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
QwtLinearScaleEngine* currentScaleEngine = dynamic_cast<QwtLinearScaleEngine*>(
|
|
|
|
m_qwtPlot->axisScaleEngine( axisProperties->qwtPlotAxisType() ) );
|
|
|
|
if ( !currentScaleEngine )
|
2019-02-25 07:54:36 -06:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
m_qwtPlot->setAxisScaleEngine( axisProperties->qwtPlotAxisType(), new QwtLinearScaleEngine );
|
|
|
|
m_qwtPlot->setAxisMaxMinor( axisProperties->qwtPlotAxisType(), 3 );
|
2019-02-25 07:54:36 -06:00
|
|
|
}
|
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( axisProperties->isAutoZoom() )
|
2019-03-13 02:38:18 -05:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
m_qwtPlot->setAxisAutoScale( qwtAxisId );
|
2019-03-13 02:38:18 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
m_qwtPlot->setAxisScale( qwtAxisId, axisProperties->visibleRangeMin, axisProperties->visibleRangeMax );
|
2019-03-13 02:38:18 -05:00
|
|
|
}
|
2019-02-26 08:42:58 -06:00
|
|
|
}
|
2019-09-06 06:17:36 -05:00
|
|
|
m_qwtPlot->axisScaleEngine( axisProperties->qwtPlotAxisType() )
|
|
|
|
->setAttribute( QwtScaleEngine::Inverted, axisProperties->isAxisInverted() );
|
2019-02-21 08:42:28 -06:00
|
|
|
}
|
2019-02-25 07:54:36 -06:00
|
|
|
else
|
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
m_qwtPlot->enableAxis( qwtAxisId, false );
|
2019-02-25 07:54:36 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 06:17:36 -05:00
|
|
|
void RimGridCrossPlot::updateAxisFromQwt( RiaDefines::PlotAxis axisType )
|
2019-02-25 07:54:36 -06:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
CVF_ASSERT( m_qwtPlot );
|
2019-03-26 09:36:10 -05:00
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
QwtInterval xAxisRange = m_qwtPlot->currentAxisRange( QwtPlot::xBottom );
|
|
|
|
QwtInterval yAxisRange = m_qwtPlot->currentAxisRange( QwtPlot::yLeft );
|
2019-02-25 07:54:36 -06:00
|
|
|
|
|
|
|
RimPlotAxisProperties* axisProperties = m_xAxisProperties();
|
|
|
|
QwtInterval axisRange = xAxisRange;
|
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( axisType == RiaDefines::PLOT_AXIS_LEFT )
|
2019-02-25 07:54:36 -06:00
|
|
|
{
|
|
|
|
axisProperties = m_yAxisProperties();
|
|
|
|
axisRange = yAxisRange;
|
|
|
|
}
|
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
axisProperties->visibleRangeMin = std::min( axisRange.minValue(), axisRange.maxValue() );
|
|
|
|
axisProperties->visibleRangeMax = std::max( axisRange.minValue(), axisRange.maxValue() );
|
2019-02-25 07:54:36 -06:00
|
|
|
|
|
|
|
axisProperties->updateConnectedEditors();
|
2019-02-21 08:42:28 -06:00
|
|
|
}
|
|
|
|
|
2019-03-13 04:16:46 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
std::vector<const QwtPlotCurve*> RimGridCrossPlot::visibleQwtCurves() const
|
|
|
|
{
|
|
|
|
std::vector<const QwtPlotCurve*> plotCurves;
|
2019-09-06 06:17:36 -05:00
|
|
|
for ( auto dataSet : m_crossPlotDataSets )
|
2019-03-13 04:16:46 -05:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( dataSet->isChecked() )
|
2019-03-13 04:16:46 -05:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
for ( auto curve : dataSet->curves() )
|
2019-03-13 04:16:46 -05:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( curve->isCurveVisible() )
|
2019-03-13 04:16:46 -05:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
plotCurves.push_back( curve->qwtPlotCurve() );
|
2019-03-13 04:16:46 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return plotCurves;
|
|
|
|
}
|
|
|
|
|
2019-03-18 06:41:44 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-26 09:36:10 -05:00
|
|
|
///
|
2019-03-18 06:41:44 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimPlotAxisProperties* RimGridCrossPlot::xAxisProperties()
|
|
|
|
{
|
|
|
|
return m_xAxisProperties();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-26 09:36:10 -05:00
|
|
|
///
|
2019-03-18 06:41:44 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimPlotAxisProperties* RimGridCrossPlot::yAxisProperties()
|
|
|
|
{
|
|
|
|
return m_yAxisProperties();
|
|
|
|
}
|
|
|
|
|
2019-03-18 08:31:06 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-26 09:36:10 -05:00
|
|
|
///
|
2019-03-18 08:31:06 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimGridCrossPlotNameConfig* RimGridCrossPlot::nameConfig()
|
|
|
|
{
|
|
|
|
return m_nameConfig();
|
|
|
|
}
|
|
|
|
|
2019-03-26 09:36:10 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 06:17:36 -05:00
|
|
|
void RimGridCrossPlot::setShowInfoBox( bool enable )
|
2019-03-26 09:36:10 -05:00
|
|
|
{
|
|
|
|
m_showInfoBox = enable;
|
|
|
|
}
|
|
|
|
|
2019-04-10 09:13:40 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
std::set<RimPlotAxisPropertiesInterface*> RimGridCrossPlot::allPlotAxes() const
|
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
return {m_xAxisProperties, m_yAxisProperties};
|
2019-04-10 09:13:40 -05:00
|
|
|
}
|
|
|
|
|
2019-02-21 05:52:23 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
/// Name Configuration
|
2019-03-26 09:36:10 -05:00
|
|
|
///
|
2019-02-21 05:52:23 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
CAF_PDM_SOURCE_INIT( RimGridCrossPlotNameConfig, "RimGridCrossPlotNameConfig" );
|
2019-02-21 05:52:23 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:59:04 -05:00
|
|
|
RimGridCrossPlotNameConfig::RimGridCrossPlotNameConfig()
|
|
|
|
: RimNameConfig()
|
2019-02-21 05:52:23 -06:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
CAF_PDM_InitObject( "Cross Plot Name Generator", "", "", "" );
|
2019-02-21 05:52:23 -06:00
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
CAF_PDM_InitField( &addDataSetNames, "AddDataSetNames", true, "Add Data Set Names", "", "", "" );
|
2019-02-21 05:52:23 -06:00
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
setCustomName( "Cross Plot" );
|
2019-02-21 05:52:23 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 06:17:36 -05:00
|
|
|
void RimGridCrossPlotNameConfig::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
|
2019-02-21 05:52:23 -06:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
RimNameConfig::defineUiOrdering( uiConfigName, uiOrdering );
|
|
|
|
uiOrdering.add( &addDataSetNames );
|
2019-02-21 05:52:23 -06:00
|
|
|
}
|