Merge remote-tracking branch 'origin/dev' into pre-proto

This commit is contained in:
Bjørnar Grip Fjær 2017-08-08 14:24:42 +02:00
commit eee4a65497
16 changed files with 493 additions and 112 deletions

View File

@ -92,6 +92,7 @@
#include "RicImportSummaryCaseFeature.h"
#include "ExportCommands/RicSnapshotViewToFileFeature.h"
#include "ExportCommands/RicSnapshotAllPlotsToFileFeature.h"
#include "ExportCommands/RicSnapshotAllViewsToFileFeature.h"
#include "SummaryPlotCommands/RicNewSummaryPlotFeature.h"
#include "RicfCommandFileExecutor.h"
@ -1590,7 +1591,7 @@ bool RiaApplication::parseArguments()
// 2016-11-09 : Location of snapshot folder was previously located in 'snapshot' folder
// relative to current working folder. Now harmonized to behave as RiuMainWindow::slotSnapshotAllViewsToFile()
QString absolutePathToSnapshotDir = createAbsolutePathFromProjectRelativePath("snapshots");
saveSnapshotForAllViews(absolutePathToSnapshotDir);
RicSnapshotAllViewsToFileFeature::exportSnapshotOfAllViewsIntoFolder(absolutePathToSnapshotDir);
mainWnd->loadWinGeoAndDockToolBarLayout();
}
@ -2285,62 +2286,6 @@ bool RiaApplication::openFile(const QString& fileName)
return loadingSucceded;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication::saveSnapshotForAllViews(const QString& snapshotFolderName)
{
RiuMainWindow* mainWnd = RiuMainWindow::instance();
if (!mainWnd) return;
if (m_project.isNull()) return;
QDir snapshotPath(snapshotFolderName);
if (!snapshotPath.exists())
{
if (!snapshotPath.mkpath(".")) return;
}
const QString absSnapshotPath = snapshotPath.absolutePath();
std::vector<RimCase*> projectCases;
m_project->allCases(projectCases);
for (size_t i = 0; i < projectCases.size(); i++)
{
RimCase* cas = projectCases[i];
if (!cas) continue;
std::vector<RimView*> views = cas->views();
for (size_t j = 0; j < views.size(); j++)
{
RimView* riv = views[j];
if (riv && riv->viewer())
{
setActiveReservoirView(riv);
RiuViewer* viewer = riv->viewer();
mainWnd->setActiveViewer(viewer->layoutWidget());
clearViewsScheduledForUpdate();
//riv->updateCurrentTimeStepAndRedraw();
riv->createDisplayModelAndRedraw();
viewer->repaint();
QString fileName = cas->caseUserDescription() + "-" + riv->name();
fileName = caf::Utils::makeValidFileBasename(fileName);
QString absoluteFileName = caf::Utils::constructFullFileName(absSnapshotPath, fileName, ".png");
RicSnapshotViewToFileFeature::saveSnapshotAs(absoluteFileName, riv);
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -2362,7 +2307,7 @@ void RiaApplication::runMultiCaseSnapshots(const QString& templateProjectFileNam
bool loadOk = loadProject(templateProjectFileName, PLA_NONE, &modifier);
if (loadOk)
{
saveSnapshotForAllViews(snapshotFolderName);
RicSnapshotAllViewsToFileFeature::exportSnapshotOfAllViewsIntoFolder(snapshotFolderName);
}
}
@ -2507,7 +2452,7 @@ void RiaApplication::runRegressionTest(const QString& testRootPath)
resizeMaximizedPlotWindows();
QString fullPathGeneratedFolder = testCaseFolder.absoluteFilePath(generatedFolderName);
saveSnapshotForAllViews(fullPathGeneratedFolder);
RicSnapshotAllViewsToFileFeature::exportSnapshotOfAllViewsIntoFolder(fullPathGeneratedFolder);
RicSnapshotAllPlotsToFileFeature::exportSnapshotOfAllPlotsIntoFolder(fullPathGeneratedFolder);

View File

@ -143,7 +143,6 @@ public:
void addWellPathsToModel(QList<QString> wellPathFilePaths);
void addWellLogsToModel(const QList<QString>& wellLogFilePaths);
void saveSnapshotForAllViews(const QString& snapshotFolderName);
void runMultiCaseSnapshots(const QString& templateProjectFileName, std::vector<QString> gridFileNames, const QString& snapshotFolderName);
void runRegressionTest(const QString& testRootPath);
@ -208,12 +207,12 @@ public:
static std::vector<QString> readFileListFromTextFile(QString listFileName);
void clearViewsScheduledForUpdate();
private:
void onProjectOpenedOrClosed();
void setWindowCaptionFromAppState();
void clearViewsScheduledForUpdate();
void createMainPlotWindow();
void deleteMainPlotWindow();

View File

@ -55,45 +55,55 @@ void RicfObjectCapability::readFields(QTextStream& inputStream,
while ( !inputStream.atEnd() && !isLastArgumentRead )
{
// Read field keyword
bool fieldDataFound = true;
bool fieldDataFound = false;
bool isEndOfArgumentFound = false;
QString keyword;
{
errorMessageContainer->skipWhiteSpaceWithLineNumberCount(inputStream);
while ( !inputStream.atEnd() )
{
QChar currentChar;
currentChar = errorMessageContainer->readCharWithLineNumberCount(inputStream);
if ( currentChar.isSpace() )
while (!inputStream.atEnd())
{
// Must skip to, and read "="
errorMessageContainer->skipWhiteSpaceWithLineNumberCount(inputStream);
currentChar = errorMessageContainer->readCharWithLineNumberCount(inputStream);
if ( currentChar != QChar('=') )
if (currentChar == QChar('=') || currentChar == QChar(')') || currentChar == QChar(',') || currentChar.isSpace())
{
// Error message: Missing "=" after argument name
errorMessageContainer->addError("Can't find the '=' after the argument named: \"" + keyword + "\" in the command: \"" + errorMessageContainer->currentCommand + "\"" );
fieldDataFound = false;
if (currentChar == QChar(')') )
{
isLastArgumentRead = true;
}
else if (currentChar == QChar(',') )
{
isEndOfArgumentFound = true;
}
break;
}
break;
else
{
keyword += currentChar;
}
}
if ( currentChar == QChar('=') )
if (currentChar.isSpace())
{
break;
errorMessageContainer->skipWhiteSpaceWithLineNumberCount(inputStream);
currentChar = errorMessageContainer->readCharWithLineNumberCount(inputStream);
}
keyword += currentChar;
if (currentChar == QChar('='))
{
fieldDataFound = true;
}
else if (currentChar == QChar(')'))
{
if (!keyword.isNull())
{
errorMessageContainer->addError(QString("Can't find the '=' after the argument named '%1' in the command '%2'").arg(keyword).arg(errorMessageContainer->currentCommand));
}
isLastArgumentRead = true;
}
else if (currentChar == QChar(','))
{
errorMessageContainer->addError(QString("Can't find the '=' after the argument named '%1' in the command '%2'").arg(keyword).arg(errorMessageContainer->currentCommand));
isEndOfArgumentFound = true;
}
else
{
errorMessageContainer->addError(QString("Can't find the '=' after the argument named '%1' in the command '%2'").arg(keyword).arg(errorMessageContainer->currentCommand));
}
}
if ( readFields.count(keyword) )

View File

@ -21,6 +21,7 @@
#include "RicfCommandFileExecutor.h"
#include "ExportCommands/RicSnapshotAllPlotsToFileFeature.h"
#include "ExportCommands/RicSnapshotAllViewsToFileFeature.h"
#include "RiaApplication.h"
@ -65,7 +66,7 @@ void RicfExportSnapshots::execute()
}
if (m_type == RicfExportSnapshots::VIEWS || m_type == RicfExportSnapshots::ALL)
{
RiaApplication::instance()->saveSnapshotForAllViews(absolutePathToSnapshotDir);
RicSnapshotAllViewsToFileFeature::exportSnapshotOfAllViewsIntoFolder(absolutePathToSnapshotDir);
}
if (m_type == RicfExportSnapshots::PLOTS || m_type == RicfExportSnapshots::ALL)
{

View File

@ -320,20 +320,16 @@ void RicWellPathExportCompletionDataFeature::exportCompletions(const std::vector
appendCompletionData(&completionsPerEclipseCell, fractureCompletionData);
}
std::vector<RigCompletionData> completions;
//std::map < IJKCellIndex, std::map<QString, RigCompletionData >> combinedCompletionDataPerEclipseCell;
//Should be moved to map instead of vector
for (auto& data : completionsPerEclipseCell)
{
completions.push_back(combineEclipseCellCompletions(data.second, exportSettings));
}
const QString eclipseCaseName = exportSettings.caseToApply->caseUserDescription();
if (exportSettings.fileSplit == RicExportCompletionDataSettingsUi::UNIFIED_FILE)
{
std::vector<RigCompletionData> completions;
for (auto& data : completionsPerEclipseCell)
{
completions.push_back(combineEclipseCellCompletions(data.second, exportSettings));
}
const QString fileName = QString("UnifiedCompletions_%1").arg(eclipseCaseName);
printCompletionsToFile(exportSettings.folder, fileName, completions, exportSettings.compdatExport);
}
@ -341,6 +337,12 @@ void RicWellPathExportCompletionDataFeature::exportCompletions(const std::vector
{
for (auto wellPath : usedWellPaths)
{
std::map<IJKCellIndex, std::vector<RigCompletionData> > filteredWellCompletions = getCompletionsForWell(completionsPerEclipseCell, wellPath->completions()->wellNameForExport());
std::vector<RigCompletionData> completions;
for (auto& data : filteredWellCompletions)
{
completions.push_back(combineEclipseCellCompletions(data.second, exportSettings));
}
std::vector<RigCompletionData> wellCompletions;
for (auto completion : completions)
{
@ -360,6 +362,12 @@ void RicWellPathExportCompletionDataFeature::exportCompletions(const std::vector
{
for (auto wellPath : usedWellPaths)
{
std::map<IJKCellIndex, std::vector<RigCompletionData> > filteredWellCompletions = getCompletionsForWell(completionsPerEclipseCell, wellPath->completions()->wellNameForExport());
std::vector<RigCompletionData> completions;
for (auto& data : filteredWellCompletions)
{
completions.push_back(combineEclipseCellCompletions(data.second, exportSettings));
}
{
std::vector<RigCompletionData> fishbonesCompletions = getCompletionsForWellAndCompletionType(completions, wellPath->completions()->wellNameForExport(), RigCompletionData::FISHBONES);
if (!fishbonesCompletions.empty())
@ -548,6 +556,27 @@ std::vector<RigCompletionData> RicWellPathExportCompletionDataFeature::getComple
return filteredCompletions;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::map<IJKCellIndex, std::vector<RigCompletionData> > RicWellPathExportCompletionDataFeature::getCompletionsForWell(const std::map<IJKCellIndex, std::vector<RigCompletionData>>& cellToCompletionMap, const QString& wellName)
{
std::map<IJKCellIndex, std::vector<RigCompletionData> > wellCompletions;
for (const auto& it : cellToCompletionMap)
{
for (auto& completion : it.second)
{
if (completion.wellName() == wellName)
{
wellCompletions[it.first].push_back(completion);
}
}
}
return wellCompletions;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -160,6 +160,7 @@ private:
const RicExportCompletionDataSettingsUi& settings);
static void printCompletionsToFile(const QString& exportFolder, const QString& fileName, std::vector<RigCompletionData>& completions, RicExportCompletionDataSettingsUi::CompdatExportType exportType);
static std::vector<RigCompletionData> getCompletionsForWellAndCompletionType(const std::vector<RigCompletionData>& completions, const QString& wellName, RigCompletionData::CompletionType completionType);
static std::map<IJKCellIndex, std::vector<RigCompletionData> > getCompletionsForWell(const std::map<IJKCellIndex, std::vector<RigCompletionData>>& cellToCompletionMap, const QString& wellName);
static void generateCompdatTable(RifEclipseDataTableFormatter& formatter, const std::vector<RigCompletionData>& completionData);
static void generateWpimultTable(RifEclipseDataTableFormatter& formatter, const std::vector<RigCompletionData>& completionData);

View File

@ -16,6 +16,8 @@ ${CEE_CURRENT_LIST_DIR}RicSaveEclipseInputPropertyFeature.h
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyExec.h
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyFeature.h
${CEE_CURRENT_LIST_DIR}RicSnapshotAllPlotsToFileFeature.h
${CEE_CURRENT_LIST_DIR}RicSnapshotAllViewsToFileFeature.h
${CEE_CURRENT_LIST_DIR}RicSnapshotFilenameGenerator.h
${CEE_CURRENT_LIST_DIR}RicSnapshotViewToClipboardFeature.h
${CEE_CURRENT_LIST_DIR}RicSnapshotViewToFileFeature.h
)
@ -32,6 +34,8 @@ ${CEE_CURRENT_LIST_DIR}RicSaveEclipseInputPropertyFeature.cpp
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyExec.cpp
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyFeature.cpp
${CEE_CURRENT_LIST_DIR}RicSnapshotAllPlotsToFileFeature.cpp
${CEE_CURRENT_LIST_DIR}RicSnapshotAllViewsToFileFeature.cpp
${CEE_CURRENT_LIST_DIR}RicSnapshotFilenameGenerator.cpp
${CEE_CURRENT_LIST_DIR}RicSnapshotViewToClipboardFeature.cpp
${CEE_CURRENT_LIST_DIR}RicSnapshotViewToFileFeature.cpp
)

View File

@ -26,6 +26,7 @@
#include "RimViewWindow.h"
#include "RicSnapshotViewToFileFeature.h"
#include "RicSnapshotFilenameGenerator.h"
#include "RiuMainPlotWindow.h"
@ -90,17 +91,7 @@ void RicSnapshotAllPlotsToFileFeature::exportSnapshotOfAllPlotsIntoFolder(QStrin
{
if (viewWindow->isMdiWindow() && viewWindow->viewWidget())
{
QString fileName;
if ( viewWindow->userDescriptionField())
{
fileName = viewWindow->userDescriptionField()->uiCapability()->uiValue().toString();
}
else
{
fileName = viewWindow->uiCapability()->uiName();
}
fileName = caf::Utils::makeValidFileBasename(fileName);
QString fileName = RicSnapshotFilenameGenerator::generateSnapshotFileName(viewWindow);
QString absoluteFileName = caf::Utils::constructFullFileName(absSnapshotPath, fileName, ".png");
absoluteFileName.replace(" ", "_");

View File

@ -0,0 +1,167 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicSnapshotAllViewsToFileFeature.h"
#include "RiaApplication.h"
#include "RiaLogging.h"
#include "RimMainPlotCollection.h"
#include "RimProject.h"
#include "RimViewWindow.h"
#include "RimView.h"
#include "RimCase.h"
#include "RicSnapshotViewToFileFeature.h"
#include "RicSnapshotFilenameGenerator.h"
#include "RiuMainWindow.h"
#include "RiuViewer.h"
#include "RigFemResultPosEnum.h"
#include "cafUtils.h"
#include <QAction>
#include <QClipboard>
#include <QDebug>
#include <QFileDialog>
#include <QFileInfo>
#include <QMdiSubWindow>
#include <QMessageBox>
CAF_CMD_SOURCE_INIT(RicSnapshotAllViewsToFileFeature, "RicSnapshotAllViewsToFileFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSnapshotAllViewsToFileFeature::saveAllViews()
{
RiaApplication* app = RiaApplication::instance();
RimProject* proj = app->project();
if (!proj) return;
// Save images in snapshot catalog relative to project directory
QString snapshotFolderName = app->createAbsolutePathFromProjectRelativePath("snapshots");
exportSnapshotOfAllViewsIntoFolder(snapshotFolderName);
QString text = QString("Exported snapshots to folder : \n%1").arg(snapshotFolderName);
QMessageBox::information(nullptr, "Export Snapshots To Folder", text);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSnapshotAllViewsToFileFeature::exportSnapshotOfAllViewsIntoFolder(QString snapshotFolderName)
{
RiuMainWindow* mainWnd = RiuMainWindow::instance();
if (!mainWnd) return;
RimProject* project = RiaApplication::instance()->project();
if (project == nullptr) return;
QDir snapshotPath(snapshotFolderName);
if (!snapshotPath.exists())
{
if (!snapshotPath.mkpath(".")) return;
}
const QString absSnapshotPath = snapshotPath.absolutePath();
RiaLogging::info(QString("Exporting snapshot of all views to %1").arg(snapshotFolderName));
std::vector<RimCase*> projectCases;
project->allCases(projectCases);
for (size_t i = 0; i < projectCases.size(); i++)
{
RimCase* cas = projectCases[i];
if (!cas) continue;
std::vector<RimView*> views = cas->views();
for (size_t j = 0; j < views.size(); j++)
{
RimView* riv = views[j];
if (riv && riv->viewer())
{
RiaApplication::instance()->setActiveReservoirView(riv);
RiuViewer* viewer = riv->viewer();
mainWnd->setActiveViewer(viewer->layoutWidget());
RiaApplication::instance()->clearViewsScheduledForUpdate();
//riv->updateCurrentTimeStepAndRedraw();
riv->createDisplayModelAndRedraw();
viewer->repaint();
QString fileName = RicSnapshotFilenameGenerator::generateSnapshotFileName(riv);
QString absoluteFileName = caf::Utils::constructFullFileName(absSnapshotPath, fileName, ".png");
RicSnapshotViewToFileFeature::saveSnapshotAs(absoluteFileName, riv);
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicSnapshotAllViewsToFileFeature::isCommandEnabled()
{
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSnapshotAllViewsToFileFeature::onActionTriggered(bool isChecked)
{
QWidget* currentActiveWidget = nullptr;
if (RiaApplication::activeViewWindow())
{
currentActiveWidget = RiaApplication::activeViewWindow()->viewWidget();
}
RicSnapshotAllViewsToFileFeature::saveAllViews();
if (currentActiveWidget)
{
RiuMainWindow* mainWindow = RiuMainWindow::instance();
if (mainWindow)
{
mainWindow->setActiveViewer(currentActiveWidget);
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSnapshotAllViewsToFileFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Snapshot All Views To File");
actionToSetup->setIcon(QIcon(":/SnapShotSaveViews.png"));
}

View File

@ -0,0 +1,40 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 RicSnapshotAllViewsToFileFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
public:
static void saveAllViews();
static void exportSnapshotOfAllViewsIntoFolder(QString snapshotFolderName);
protected:
// Overrides
virtual bool isCommandEnabled() override;
virtual void onActionTriggered(bool isChecked) override;
virtual void setupActionLook(QAction* actionToSetup) override;
};

View File

@ -0,0 +1,109 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 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 "RicSnapshotFilenameGenerator.h"
#include "RimViewWindow.h"
#include "RimView.h"
#include "RimCase.h"
#include "RimEclipseView.h"
#include "RimEclipseCellColors.h"
#include "RimGeoMechView.h"
#include "RimGeoMechCellColors.h"
#include "cafUtils.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RicSnapshotFilenameGenerator::generateSnapshotFileName(RimViewWindow* viewWindow)
{
{
RimView* view = dynamic_cast<RimView*>(viewWindow);
if (view != nullptr)
{
return generateSnapshotFilenameForRimView(view);
}
}
QString fileName;
if (viewWindow->userDescriptionField())
{
fileName = viewWindow->userDescriptionField()->uiCapability()->uiValue().toString();
}
else
{
fileName = viewWindow->uiCapability()->uiName();
}
fileName = caf::Utils::makeValidFileBasename(fileName);
return fileName;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RicSnapshotFilenameGenerator::generateSnapshotFilenameForRimView(RimView* rimView)
{
QStringList timeSteps = rimView->ownerCase()->timeStepStrings();
int timeStep = rimView->currentTimeStep();
QString fileName = QString("%1_%2_%3_%4_%5").arg(rimView->ownerCase()->caseUserDescription())
.arg(rimView->name())
.arg(resultName(rimView))
.arg(timeStep, 2, 10, QChar('0'))
.arg(timeSteps[timeStep].replace(".", "-"));
fileName = caf::Utils::makeValidFileBasename(fileName);
return fileName;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RicSnapshotFilenameGenerator::resultName(RimView * rimView)
{
if (dynamic_cast<RimEclipseView*>(rimView))
{
RimEclipseView* eclView = dynamic_cast<RimEclipseView*>(rimView);
return caf::Utils::makeValidFileBasename(eclView->cellResult()->resultVariableUiShortName());
}
else if (dynamic_cast<RimGeoMechView*>(rimView))
{
RimGeoMechView* geoMechView = dynamic_cast<RimGeoMechView*>(rimView);
RimGeoMechCellColors* cellResult = geoMechView->cellResult();
if (cellResult)
{
QString title = QString("%1_%2").arg(caf::AppEnum<RigFemResultPosEnum>(cellResult->resultPositionType()).uiText())
.arg(cellResult->resultFieldUiName());
if (!cellResult->resultComponentUiName().isEmpty())
{
title += "_" + cellResult->resultComponentUiName();
}
return title;
}
}
return "";
}

View File

@ -0,0 +1,37 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 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 <QString>
class RimViewWindow;
class RimView;
//==================================================================================================
///
//==================================================================================================
class RicSnapshotFilenameGenerator
{
public:
static QString generateSnapshotFileName(RimViewWindow* viewWindow);
private:
static QString generateSnapshotFilenameForRimView(RimView* rimView);
static QString resultName(RimView* rimView);
};

View File

@ -26,6 +26,8 @@
#include "RimViewWindow.h"
#include "RiuMainPlotWindow.h"
#include "RicSnapshotFilenameGenerator.h"
#include "cafUtils.h"
#include <QAction>
@ -51,11 +53,11 @@ void RicSnapshotViewToFileFeature::saveSnapshotAs(const QString& fileName, RimVi
{
if (image.save(fileName))
{
qDebug() << "Exported snapshot image to " << fileName;
RiaLogging::info(QString("Exported snapshot image to %1").arg(fileName));
}
else
{
qDebug() << "Error when trying to export snapshot image to " << fileName;
RiaLogging::error(QString("Error when trying to export snapshot image to %1").arg(fileName));
}
}
}
@ -99,7 +101,7 @@ void RicSnapshotViewToFileFeature::onActionTriggered(bool isChecked)
startPath = app->lastUsedDialogDirectory("IMAGE_SNAPSHOT");
}
startPath += "/image.png";
startPath = caf::Utils::constructFullFileName(startPath, RicSnapshotFilenameGenerator::generateSnapshotFileName(viewWindow), ".png");
QString fileName = QFileDialog::getSaveFileName(NULL, tr("Export to File"), startPath);
if (fileName.isEmpty())

View File

@ -272,12 +272,28 @@ void RivWellPathPartMgr::buildWellPathParts(const caf::DisplayCoordTransform* di
if (firstVisibleSegmentIndex != cvf::UNDEFINED_SIZE_T)
{
if (firstVisibleSegmentIndex > 0)
{
double wellPathStartPoint = wellPathClipBoundingBox.max().z() + wellPathCollection->wellPathClipZDistance;
double stepsize = (wellPathStartPoint - wellPathGeometry->m_wellPathPoints[firstVisibleSegmentIndex - 1].z()) /
(wellPathGeometry->m_wellPathPoints[firstVisibleSegmentIndex].z() - wellPathGeometry->m_wellPathPoints[firstVisibleSegmentIndex - 1].z());
cvf::Vec3d newPoint = wellPathGeometry->m_wellPathPoints[firstVisibleSegmentIndex - 1] +
stepsize * (wellPathGeometry->m_wellPathPoints[firstVisibleSegmentIndex] - wellPathGeometry->m_wellPathPoints[firstVisibleSegmentIndex - 1]);
clippedPoints.push_back(newPoint);
pbd.m_pipeGeomGenerator->setFirstVisibleSegmentIndex(firstVisibleSegmentIndex - 1);
}
else
{
pbd.m_pipeGeomGenerator->setFirstVisibleSegmentIndex(firstVisibleSegmentIndex);
}
for (size_t idx = firstVisibleSegmentIndex; idx < wellPathGeometry->m_wellPathPoints.size(); idx++)
{
clippedPoints.push_back(wellPathGeometry->m_wellPathPoints[idx]);
}
pbd.m_pipeGeomGenerator->setFirstVisibleSegmentIndex(firstVisibleSegmentIndex);
}
if (clippedPoints.size() < 2) return;

View File

@ -117,6 +117,12 @@ TEST(RicfCommands, ErrorMessages)
EXPECT_EQ((size_t)2, objects.size());
EXPECT_EQ((size_t)5, errors.m_messages.size());
// Errors should be:
// Line 1 : TesCommand1 does not exist
// Line 2 : Unreadable value for argument IntArgument
// Line 3 : Can't find = after argument named TextA (space withing argument name)
// Line 4 : Can't find = after argument named DoubleArgument
// Line 5 : Missing quotes around TextArgument value
for (const auto& msg: errors.m_messages)
{
@ -137,3 +143,25 @@ TEST(RicfCommands, ErrorMessages)
delete(obj);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
TEST(RicfCommands, EmptyArgumentList)
{
// Ensure no error messages when command with no arguments is read
QString commandString("TestCommand1()");
QTextStream inputStream(&commandString);
RicfMessages errors;
auto objects = RicfCommandFileReader::readCommands(inputStream, caf::PdmDefaultObjectFactory::instance(), &errors);
EXPECT_EQ((size_t)1, objects.size());
EXPECT_EQ((size_t)0, errors.m_messages.size());
for (auto obj : objects)
{
delete(obj);
}
}

View File

@ -58,6 +58,8 @@
#include "cafSelectionManager.h"
#include "cafUtils.h"
#include "ExportCommands/RicSnapshotAllViewsToFileFeature.h"
#include "cvfTimer.h"
#include <QAction>
@ -1271,7 +1273,7 @@ void RiuMainWindow::slotSnapshotAllViewsToFile()
// Save images in snapshot catalog relative to project directory
QString absolutePathToSnapshotDir = app->createAbsolutePathFromProjectRelativePath("snapshots");
app->saveSnapshotForAllViews(absolutePathToSnapshotDir);
RicSnapshotAllViewsToFileFeature::exportSnapshotOfAllViewsIntoFolder(absolutePathToSnapshotDir);
}
//--------------------------------------------------------------------------------------------------