2017-10-11 12:48:35 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2017- Statoil ASA
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2017-10-11 12:48:35 -05:00
|
|
|
// 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.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2017-10-11 12:48:35 -05:00
|
|
|
// 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.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2017-10-11 12:48:35 -05:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2020-02-18 07:00:11 -06:00
|
|
|
#include "RiuSummaryVectorSelectionDialog.h"
|
2017-10-11 12:48:35 -05:00
|
|
|
|
2017-10-24 02:44:50 -05:00
|
|
|
#include "RiaSummaryCurveDefinition.h"
|
|
|
|
|
2018-05-11 06:24:46 -05:00
|
|
|
#include "RimSummaryCaseCollection.h"
|
|
|
|
|
2020-02-18 07:10:10 -06:00
|
|
|
#include "RiuSummaryVectorSelectionUi.h"
|
2020-02-18 07:06:16 -06:00
|
|
|
#include "RiuSummaryVectorSelectionWidgetCreator.h"
|
2017-11-29 01:50:48 -06:00
|
|
|
#include "RiuTools.h"
|
2017-10-11 12:48:35 -05:00
|
|
|
|
2017-10-24 02:44:50 -05:00
|
|
|
#include <QBoxLayout>
|
2017-10-12 02:28:34 -05:00
|
|
|
#include <QDialogButtonBox>
|
2017-10-24 02:44:50 -05:00
|
|
|
#include <QLabel>
|
|
|
|
#include <QVBoxLayout>
|
2017-10-11 12:48:35 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-10-11 12:48:35 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-02-18 07:00:11 -06:00
|
|
|
RiuSummaryVectorSelectionDialog::RiuSummaryVectorSelectionDialog( QWidget* parent )
|
2019-09-06 03:40:57 -05:00
|
|
|
: QDialog( parent, RiuTools::defaultDialogFlags() )
|
2017-10-11 12:48:35 -05:00
|
|
|
{
|
2020-02-18 07:06:16 -06:00
|
|
|
m_addrSelWidget =
|
|
|
|
std::unique_ptr<RiuSummaryVectorSelectionWidgetCreator>( new RiuSummaryVectorSelectionWidgetCreator() );
|
2019-09-06 03:40:57 -05:00
|
|
|
QWidget* addrWidget = m_addrSelWidget->getOrCreateWidget( this );
|
2017-10-11 12:48:35 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
QVBoxLayout* mainLayout = new QVBoxLayout( this );
|
|
|
|
mainLayout->setContentsMargins( 0, 0, 0, 0 );
|
|
|
|
mainLayout->addWidget( addrWidget );
|
2017-10-11 12:48:35 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
setWindowTitle( "Summary Address Selection" );
|
|
|
|
resize( 1200, 800 );
|
2017-10-12 02:28:34 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
m_label = new QLabel( "", this );
|
2017-10-24 02:44:50 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
QDialogButtonBox* buttonBox = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel );
|
|
|
|
connect( buttonBox, SIGNAL( accepted() ), this, SLOT( accept() ) );
|
|
|
|
connect( buttonBox, SIGNAL( rejected() ), this, SLOT( reject() ) );
|
2017-10-12 02:28:34 -05:00
|
|
|
|
2017-11-27 00:56:21 -06:00
|
|
|
QHBoxLayout* labelLayout = new QHBoxLayout;
|
2019-09-06 03:40:57 -05:00
|
|
|
labelLayout->addStretch( 1 );
|
|
|
|
labelLayout->addWidget( m_label );
|
|
|
|
labelLayout->addWidget( buttonBox );
|
2017-10-24 02:44:50 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
mainLayout->addLayout( labelLayout );
|
2017-10-24 02:44:50 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
m_addrSelWidget->summaryAddressSelection()->setFieldChangedHandler( [this]() { this->updateLabel(); } );
|
2017-10-24 02:44:50 -05:00
|
|
|
|
|
|
|
updateLabel();
|
2017-10-11 12:48:35 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-10-11 12:48:35 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-02-18 07:00:11 -06:00
|
|
|
RiuSummaryVectorSelectionDialog::~RiuSummaryVectorSelectionDialog()
|
2020-02-12 04:13:38 -06:00
|
|
|
{
|
|
|
|
}
|
2017-10-11 12:48:35 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-11-15 08:20:47 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-02-18 07:00:11 -06:00
|
|
|
void RiuSummaryVectorSelectionDialog::setCaseAndAddress( RimSummaryCase* summaryCase,
|
|
|
|
const RifEclipseSummaryAddress& address )
|
2017-11-15 08:20:47 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( summaryCase )
|
2017-11-21 02:43:34 -06:00
|
|
|
{
|
2018-05-11 06:24:46 -05:00
|
|
|
std::vector<RiaSummaryCurveDefinition> curveDefs;
|
2020-09-15 05:53:46 -05:00
|
|
|
curveDefs.push_back( RiaSummaryCurveDefinition( summaryCase, address, false ) );
|
2020-09-29 02:38:26 -05:00
|
|
|
setCurveSelection( curveDefs );
|
2018-05-11 06:24:46 -05:00
|
|
|
}
|
2020-09-25 01:42:41 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// Still need to update the editors
|
|
|
|
summaryAddressSelection()->updateConnectedEditors();
|
|
|
|
updateLabel();
|
|
|
|
}
|
2018-05-11 06:24:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2018-05-11 06:24:46 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-02-18 07:00:11 -06:00
|
|
|
void RiuSummaryVectorSelectionDialog::setEnsembleAndAddress( RimSummaryCaseCollection* ensemble,
|
|
|
|
const RifEclipseSummaryAddress& address )
|
2018-05-11 06:24:46 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( ensemble )
|
2018-05-11 06:24:46 -05:00
|
|
|
{
|
|
|
|
std::vector<RiaSummaryCurveDefinition> curveDefs;
|
2020-09-15 05:53:46 -05:00
|
|
|
curveDefs.push_back( RiaSummaryCurveDefinition( ensemble, address ) );
|
2020-06-08 09:12:32 -05:00
|
|
|
setCurveSelection( curveDefs );
|
2017-11-21 02:43:34 -06:00
|
|
|
}
|
2020-09-25 01:42:41 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// Still need to update the editors
|
|
|
|
summaryAddressSelection()->updateConnectedEditors();
|
|
|
|
updateLabel();
|
|
|
|
}
|
2017-11-15 08:20:47 -06:00
|
|
|
}
|
|
|
|
|
2020-12-07 09:49:58 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiuSummaryVectorSelectionDialog::setEnsembleAndAddresses( RimSummaryCaseCollection* ensemble,
|
|
|
|
std::vector<RifEclipseSummaryAddress> addresses )
|
|
|
|
{
|
|
|
|
if ( ensemble )
|
|
|
|
{
|
|
|
|
std::vector<RiaSummaryCurveDefinition> curveDefs;
|
|
|
|
for ( auto address : addresses )
|
|
|
|
{
|
|
|
|
curveDefs.push_back( RiaSummaryCurveDefinition( ensemble, address ) );
|
|
|
|
}
|
|
|
|
setCurveSelection( curveDefs );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Still need to update the editors
|
|
|
|
summaryAddressSelection()->updateConnectedEditors();
|
|
|
|
updateLabel();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-24 03:44:51 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiuSummaryVectorSelectionDialog::setCurveSelection( const std::vector<RiaSummaryCurveDefinition>& selection )
|
|
|
|
{
|
|
|
|
summaryAddressSelection()->setSelectedCurveDefinitions( selection );
|
2020-09-25 01:42:41 -05:00
|
|
|
summaryAddressSelection()->updateConnectedEditors();
|
|
|
|
updateLabel();
|
2020-02-24 03:44:51 -06:00
|
|
|
}
|
|
|
|
|
2017-11-15 08:20:47 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-11-15 08:20:47 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-02-18 07:00:11 -06:00
|
|
|
std::vector<RiaSummaryCurveDefinition> RiuSummaryVectorSelectionDialog::curveSelection() const
|
2017-11-15 08:20:47 -06:00
|
|
|
{
|
2018-05-15 07:25:53 -05:00
|
|
|
return summaryAddressSelection()->selection();
|
2017-11-15 08:20:47 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2018-05-11 06:24:46 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-02-18 07:00:11 -06:00
|
|
|
void RiuSummaryVectorSelectionDialog::hideEnsembles()
|
2018-05-11 06:24:46 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
summaryAddressSelection()->hideEnsembles( true );
|
2018-05-11 06:24:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2018-05-11 06:24:46 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-02-18 07:00:11 -06:00
|
|
|
void RiuSummaryVectorSelectionDialog::hideSummaryCases()
|
2018-05-11 06:24:46 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
summaryAddressSelection()->hideSummaryCases( true );
|
2018-05-11 06:24:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-02-24 03:44:51 -06:00
|
|
|
///
|
2020-02-18 04:48:04 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiuSummaryVectorSelectionDialog::enableMultiSelect( bool enable )
|
|
|
|
{
|
2020-02-24 03:44:51 -06:00
|
|
|
summaryAddressSelection()->setMultiSelectionMode( enable );
|
2020-02-18 04:48:04 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-06-08 04:09:11 -05:00
|
|
|
///
|
2020-03-03 02:49:54 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiuSummaryVectorSelectionDialog::enableIndividualEnsembleCaseSelection( bool enable )
|
|
|
|
{
|
|
|
|
summaryAddressSelection()->enableIndividualEnsembleCaseSelection( enable );
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-10-11 12:48:35 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-02-18 07:10:10 -06:00
|
|
|
RiuSummaryVectorSelectionUi* RiuSummaryVectorSelectionDialog::summaryAddressSelection() const
|
2017-10-11 12:48:35 -05:00
|
|
|
{
|
|
|
|
return m_addrSelWidget->summaryAddressSelection();
|
|
|
|
}
|
|
|
|
|
2017-10-24 02:44:50 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-10-24 02:44:50 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-02-18 07:00:11 -06:00
|
|
|
void RiuSummaryVectorSelectionDialog::updateLabel()
|
2017-10-24 02:44:50 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
QString curveAddressText;
|
2018-05-15 07:25:53 -05:00
|
|
|
std::vector<RiaSummaryCurveDefinition> sumCasePairs = this->summaryAddressSelection()->selection();
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( sumCasePairs.size() == 1 )
|
2017-10-24 02:44:50 -05:00
|
|
|
{
|
|
|
|
curveAddressText = sumCasePairs.front().curveDefinitionText();
|
|
|
|
}
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( curveAddressText.isEmpty() )
|
2017-10-24 02:44:50 -05:00
|
|
|
{
|
|
|
|
curveAddressText = "<None>";
|
|
|
|
}
|
|
|
|
|
|
|
|
QString txt = "Selected Address : ";
|
|
|
|
txt += curveAddressText;
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
m_label->setText( txt );
|
2017-10-24 02:44:50 -05:00
|
|
|
}
|