mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4683 clang-format on all files in ApplicationCode
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -22,12 +22,12 @@
|
||||
|
||||
#include "ExportCommands/RicAdvancedSnapshotExportFeature.h"
|
||||
|
||||
#include "Rim3dView.h"
|
||||
#include "RimAdvancedSnapshotExportDefinition.h"
|
||||
#include "RimCase.h"
|
||||
#include "RimEclipseCellColors.h"
|
||||
#include "RimEclipseView.h"
|
||||
#include "RimAdvancedSnapshotExportDefinition.h"
|
||||
#include "RimProject.h"
|
||||
#include "Rim3dView.h"
|
||||
|
||||
#include "RiuTools.h"
|
||||
|
||||
@@ -35,10 +35,11 @@
|
||||
#include "cafPdmUiTableView.h"
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QAbstractItemView>
|
||||
#include <QBoxLayout>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QFileDialog>
|
||||
#include <QHeaderView>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QMenu>
|
||||
@@ -46,139 +47,137 @@
|
||||
#include <QTableView>
|
||||
#include <QToolButton>
|
||||
#include <QWidget>
|
||||
#include <QHeaderView>
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuAdvancedSnapshotExportWidget::RiuAdvancedSnapshotExportWidget(QWidget* parent, RimProject* project)
|
||||
: QDialog(parent, RiuTools::defaultDialogFlags()),
|
||||
m_rimProject(project)
|
||||
RiuAdvancedSnapshotExportWidget::RiuAdvancedSnapshotExportWidget( QWidget* parent, RimProject* project )
|
||||
: QDialog( parent, RiuTools::defaultDialogFlags() )
|
||||
, m_rimProject( project )
|
||||
{
|
||||
setWindowTitle("Advanced Snapshot Export");
|
||||
setWindowTitle( "Advanced Snapshot Export" );
|
||||
|
||||
int nWidth = 1000;
|
||||
int nWidth = 1000;
|
||||
int nHeight = 300;
|
||||
resize(nWidth, nHeight);
|
||||
resize( nWidth, nHeight );
|
||||
|
||||
QVBoxLayout* dialogLayout = new QVBoxLayout;
|
||||
setLayout(dialogLayout);
|
||||
setLayout( dialogLayout );
|
||||
|
||||
m_pdmTableView = new caf::PdmUiTableView(this);
|
||||
m_pdmTableView->tableView()->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
m_pdmTableView->tableView()->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
m_pdmTableView->enableHeaderText(false);
|
||||
m_pdmTableView = new caf::PdmUiTableView( this );
|
||||
m_pdmTableView->tableView()->setSelectionMode( QAbstractItemView::ExtendedSelection );
|
||||
m_pdmTableView->tableView()->setContextMenuPolicy( Qt::CustomContextMenu );
|
||||
m_pdmTableView->enableHeaderText( false );
|
||||
|
||||
connect(m_pdmTableView->tableView(), SIGNAL(customContextMenuRequested(QPoint)), SLOT(customMenuRequested(QPoint)));
|
||||
connect( m_pdmTableView->tableView(),
|
||||
SIGNAL( customContextMenuRequested( QPoint ) ),
|
||||
SLOT( customMenuRequested( QPoint ) ) );
|
||||
|
||||
m_pdmTableView->setChildArrayField(&(project->multiSnapshotDefinitions()));
|
||||
m_pdmTableView->setChildArrayField( &( project->multiSnapshotDefinitions() ) );
|
||||
|
||||
QHeaderView* verticalHeader = m_pdmTableView->tableView()->verticalHeader();
|
||||
#if QT_VERSION >= 0x050000
|
||||
verticalHeader->setSectionResizeMode(QHeaderView::Interactive);
|
||||
verticalHeader->setSectionResizeMode( QHeaderView::Interactive );
|
||||
#else
|
||||
verticalHeader->setResizeMode(QHeaderView::Interactive);
|
||||
verticalHeader->setResizeMode( QHeaderView::Interactive );
|
||||
#endif
|
||||
m_pdmTableView->tableView()->resizeColumnsToContents();
|
||||
|
||||
// Set active child array to be able to use generic delete
|
||||
caf::SelectionManager::instance()->setActiveChildArrayFieldHandle(&(project->multiSnapshotDefinitions()));
|
||||
caf::SelectionManager::instance()->setActiveChildArrayFieldHandle( &( project->multiSnapshotDefinitions() ) );
|
||||
|
||||
dialogLayout->addWidget(m_pdmTableView);
|
||||
dialogLayout->addWidget( m_pdmTableView );
|
||||
|
||||
// Export folder
|
||||
{
|
||||
QHBoxLayout* layout = new QHBoxLayout;
|
||||
|
||||
layout->addWidget(new QLabel("Export folder"));
|
||||
layout->addWidget( new QLabel( "Export folder" ) );
|
||||
|
||||
m_exportFolderLineEdit = new QLineEdit;
|
||||
|
||||
QToolButton* button = new QToolButton;
|
||||
button->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred));
|
||||
button->setText(QLatin1String("..."));
|
||||
button->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Preferred ) );
|
||||
button->setText( QLatin1String( "..." ) );
|
||||
|
||||
layout->addWidget(m_exportFolderLineEdit);
|
||||
layout->addWidget(button);
|
||||
layout->addWidget( m_exportFolderLineEdit );
|
||||
layout->addWidget( button );
|
||||
|
||||
connect(button, SIGNAL(clicked()), this, SLOT(folderSelectionClicked()));
|
||||
connect( button, SIGNAL( clicked() ), this, SLOT( folderSelectionClicked() ) );
|
||||
|
||||
dialogLayout->addLayout(layout);
|
||||
dialogLayout->addLayout( layout );
|
||||
}
|
||||
|
||||
|
||||
// Buttons
|
||||
QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Close);
|
||||
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
|
||||
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
||||
QDialogButtonBox* buttonBox = new QDialogButtonBox( QDialogButtonBox::Close );
|
||||
connect( buttonBox, SIGNAL( accepted() ), this, SLOT( accept() ) );
|
||||
connect( buttonBox, SIGNAL( rejected() ), this, SLOT( reject() ) );
|
||||
|
||||
QPushButton* exportButton = new QPushButton(tr("Export"));
|
||||
exportButton->setDefault(true);
|
||||
buttonBox->addButton(exportButton, QDialogButtonBox::ActionRole);
|
||||
connect(exportButton, SIGNAL(clicked()), this, SLOT(exportSnapshots()));
|
||||
QPushButton* exportButton = new QPushButton( tr( "Export" ) );
|
||||
exportButton->setDefault( true );
|
||||
buttonBox->addButton( exportButton, QDialogButtonBox::ActionRole );
|
||||
connect( exportButton, SIGNAL( clicked() ), this, SLOT( exportSnapshots() ) );
|
||||
|
||||
dialogLayout->addWidget(buttonBox);
|
||||
dialogLayout->addWidget( buttonBox );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuAdvancedSnapshotExportWidget::~RiuAdvancedSnapshotExportWidget()
|
||||
{
|
||||
m_pdmTableView->setChildArrayField(nullptr);
|
||||
m_pdmTableView->setChildArrayField( nullptr );
|
||||
|
||||
caf::SelectionManager::instance()->setActiveChildArrayFieldHandle(nullptr);
|
||||
caf::SelectionManager::instance()->setActiveChildArrayFieldHandle( nullptr );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuAdvancedSnapshotExportWidget::addSnapshotItemFromActiveView()
|
||||
{
|
||||
if (!m_rimProject) return;
|
||||
if ( !m_rimProject ) return;
|
||||
|
||||
Rim3dView* activeView = RiaApplication::instance()->activeReservoirView();
|
||||
if (activeView)
|
||||
if ( activeView )
|
||||
{
|
||||
RimAdvancedSnapshotExportDefinition* multiSnapshot = new RimAdvancedSnapshotExportDefinition();
|
||||
multiSnapshot->view = activeView;
|
||||
multiSnapshot->view = activeView;
|
||||
|
||||
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(activeView);
|
||||
if (eclipseView)
|
||||
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>( activeView );
|
||||
if ( eclipseView )
|
||||
{
|
||||
multiSnapshot->eclipseResultType = eclipseView->cellResult()->resultType();
|
||||
multiSnapshot->selectedEclipseResults.v().push_back(eclipseView->cellResult()->resultVariable());
|
||||
|
||||
multiSnapshot->selectedEclipseResults.v().push_back( eclipseView->cellResult()->resultVariable() );
|
||||
}
|
||||
multiSnapshot->timeStepStart = activeView->currentTimeStep();
|
||||
multiSnapshot->timeStepEnd = activeView->currentTimeStep();
|
||||
multiSnapshot->timeStepEnd = activeView->currentTimeStep();
|
||||
|
||||
RimCase* sourceCase = nullptr;
|
||||
activeView->firstAncestorOrThisOfType(sourceCase);
|
||||
if (sourceCase)
|
||||
activeView->firstAncestorOrThisOfType( sourceCase );
|
||||
if ( sourceCase )
|
||||
{
|
||||
multiSnapshot->additionalCases().push_back(sourceCase);
|
||||
multiSnapshot->additionalCases().push_back( sourceCase );
|
||||
}
|
||||
|
||||
m_rimProject->multiSnapshotDefinitions.push_back(multiSnapshot);
|
||||
m_rimProject->multiSnapshotDefinitions.push_back( multiSnapshot );
|
||||
m_rimProject->multiSnapshotDefinitions.uiCapability()->updateConnectedEditors();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuAdvancedSnapshotExportWidget::addEmptySnapshotItems(size_t itemCount)
|
||||
void RiuAdvancedSnapshotExportWidget::addEmptySnapshotItems( size_t itemCount )
|
||||
{
|
||||
if (!m_rimProject) return;
|
||||
if ( !m_rimProject ) return;
|
||||
|
||||
for (size_t i = 0; i < itemCount; i++)
|
||||
for ( size_t i = 0; i < itemCount; i++ )
|
||||
{
|
||||
RimAdvancedSnapshotExportDefinition* multiSnapshot = new RimAdvancedSnapshotExportDefinition();
|
||||
multiSnapshot->isActive = false;
|
||||
multiSnapshot->isActive = false;
|
||||
|
||||
m_rimProject->multiSnapshotDefinitions.push_back(multiSnapshot);
|
||||
m_rimProject->multiSnapshotDefinitions.push_back( multiSnapshot );
|
||||
}
|
||||
|
||||
m_rimProject->multiSnapshotDefinitions.uiCapability()->updateConnectedEditors();
|
||||
@@ -187,50 +186,49 @@ void RiuAdvancedSnapshotExportWidget::addEmptySnapshotItems(size_t itemCount)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuAdvancedSnapshotExportWidget::setExportFolder(const QString& folder)
|
||||
void RiuAdvancedSnapshotExportWidget::setExportFolder( const QString& folder )
|
||||
{
|
||||
m_exportFolderLineEdit->setText(folder);
|
||||
m_exportFolderLineEdit->setText( folder );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RiuAdvancedSnapshotExportWidget::exportFolder() const
|
||||
QString RiuAdvancedSnapshotExportWidget::exportFolder() const
|
||||
{
|
||||
return m_exportFolderLineEdit->text();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuAdvancedSnapshotExportWidget::customMenuRequested(QPoint pos)
|
||||
void RiuAdvancedSnapshotExportWidget::customMenuRequested( QPoint pos )
|
||||
{
|
||||
caf::CmdFeatureManager* commandManager = caf::CmdFeatureManager::instance();
|
||||
|
||||
QMenu menu;
|
||||
menu.addAction(commandManager->action("PdmListField_DeleteItem","Delete row"));
|
||||
menu.addAction( commandManager->action( "PdmListField_DeleteItem", "Delete row" ) );
|
||||
|
||||
QAction* newRowAction = new QAction("New row", this);
|
||||
connect(newRowAction, SIGNAL(triggered()), SLOT(addSnapshotItem()));
|
||||
menu.addAction(newRowAction);
|
||||
QAction* newRowAction = new QAction( "New row", this );
|
||||
connect( newRowAction, SIGNAL( triggered() ), SLOT( addSnapshotItem() ) );
|
||||
menu.addAction( newRowAction );
|
||||
|
||||
QAction* clearAllRows = new QAction( "Clear", this );
|
||||
connect( clearAllRows, SIGNAL( triggered() ), SLOT( deleteAllSnapshotItems() ) );
|
||||
menu.addAction( clearAllRows );
|
||||
|
||||
QAction* clearAllRows = new QAction("Clear", this);
|
||||
connect(clearAllRows, SIGNAL(triggered()), SLOT(deleteAllSnapshotItems()));
|
||||
menu.addAction(clearAllRows);
|
||||
|
||||
|
||||
// Qt doc: QAbstractScrollArea and its subclasses that map the context menu event to coordinates of the viewport().
|
||||
QPoint globalPos = m_pdmTableView->tableView()->viewport()->mapToGlobal(pos);
|
||||
QPoint globalPos = m_pdmTableView->tableView()->viewport()->mapToGlobal( pos );
|
||||
|
||||
menu.exec(globalPos);
|
||||
menu.exec( globalPos );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuAdvancedSnapshotExportWidget::deleteAllSnapshotItems()
|
||||
{
|
||||
if (!m_rimProject) return;
|
||||
if ( !m_rimProject ) return;
|
||||
|
||||
m_rimProject->multiSnapshotDefinitions.deleteAllChildObjects();
|
||||
|
||||
@@ -238,33 +236,34 @@ void RiuAdvancedSnapshotExportWidget::deleteAllSnapshotItems()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuAdvancedSnapshotExportWidget::exportSnapshots()
|
||||
{
|
||||
RicAdvancedSnapshotExportFeature::exportMultipleSnapshots(m_exportFolderLineEdit->text(), m_rimProject);
|
||||
RicAdvancedSnapshotExportFeature::exportMultipleSnapshots( m_exportFolderLineEdit->text(), m_rimProject );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuAdvancedSnapshotExportWidget::folderSelectionClicked()
|
||||
{
|
||||
QString defaultPath = m_exportFolderLineEdit->text();
|
||||
|
||||
QString directoryPath = QFileDialog::getExistingDirectory(m_exportFolderLineEdit,
|
||||
tr("Get existing directory"),
|
||||
defaultPath,
|
||||
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
|
||||
QString directoryPath = QFileDialog::getExistingDirectory( m_exportFolderLineEdit,
|
||||
tr( "Get existing directory" ),
|
||||
defaultPath,
|
||||
QFileDialog::ShowDirsOnly |
|
||||
QFileDialog::DontResolveSymlinks );
|
||||
|
||||
if (!directoryPath.isEmpty())
|
||||
if ( !directoryPath.isEmpty() )
|
||||
{
|
||||
m_exportFolderLineEdit->setText(directoryPath);
|
||||
m_exportFolderLineEdit->setText( directoryPath );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuAdvancedSnapshotExportWidget::addSnapshotItem()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user