Skip to content

Commit

Permalink
Merge branch '2018.11.02-patch'
Browse files Browse the repository at this point in the history
  • Loading branch information
magnesj committed Feb 4, 2019
2 parents 329d2f7 + ffb4f74 commit 45138cb
Show file tree
Hide file tree
Showing 18 changed files with 367 additions and 201 deletions.
2 changes: 0 additions & 2 deletions ApplicationCode/Application/RiaApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1984,8 +1984,6 @@ bool RiaApplication::openFile(const QString& fileName)
if (loadingSucceded)
{
getOrCreateAndShowMainPlotWindow();

m_project->updateConnectedEditors();
}
}

Expand Down
4 changes: 4 additions & 0 deletions ApplicationCode/Application/RiaMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ int main(int argc, char *argv[])
window.loadWinGeoAndDockToolBarLayout();
window.showWindow();

// Create plot main window to be able to set expanded state on created objects
// The plot window is hidden by default
RiaApplication::instance()->getOrCreateMainPlotWindow();

if (app.parseArguments())
{
RiaLogging::setLoggerInstance(new RiuMessagePanelLogger(window.messagePanel()));
Expand Down
43 changes: 30 additions & 13 deletions ApplicationCode/Application/RiaSummaryCurveDefinition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,28 +142,45 @@ QString RiaSummaryCurveDefinition::curveDefinitionText(const QString& caseName,
//--------------------------------------------------------------------------------------------------
bool RiaSummaryCurveDefinition::operator<(const RiaSummaryCurveDefinition& other) const
{
if (m_summaryCase != other.summaryCase())
{
// Try comparing the dereferenced objects first. They have a predictable sorting operator.
if (m_summaryCase && other.summaryCase())
QString ensembleName;
QString otherEnsembleName;

if (m_ensemble)
{
ensembleName = m_ensemble->name();
}

if (other.ensemble())
{
return *m_summaryCase < *other.summaryCase();
otherEnsembleName = other.ensemble()->name();
}

if (ensembleName != otherEnsembleName)
{
return ensembleName < otherEnsembleName;
}
// Sorting by pointer address, which may appear random to the user.
return m_summaryCase < other.summaryCase();
}

if (m_ensemble != other.ensemble())
{
// Try comparing the dereferenced objects first. They have a predictable sorting operator.
if (m_ensemble && other.ensemble())
QString summaryCaseName;
QString otherSummaryCaseName;

if (m_summaryCase)
{
return *m_ensemble < *other.ensemble();
summaryCaseName = m_summaryCase->caseName();
}
if (other.summaryCase())
{
otherSummaryCaseName = other.summaryCase()->caseName();
}

if (summaryCaseName != otherSummaryCaseName)
{
return summaryCaseName < otherSummaryCaseName;
}
// Sorting by pointer address, which may appear random to the user.
return (m_ensemble < other.ensemble());
}

return (m_summaryAddress < other.summaryAddress());
}

2 changes: 1 addition & 1 deletion ApplicationCode/Application/Tools/RiaArgumentParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ bool RiaArgumentParser::parseArguments()
progOpt.setOptionPrefix(cvf::ProgramOptions::DOUBLE_DASH);

QString helpText = QString("\n%1 v. %2\n").arg(RI_APPLICATION_NAME).arg(RiaApplication::getVersionStringApp(false));
helpText += "Copyright Statoil ASA, Ceetron Solution AS, Ceetron AS\n\n";
helpText += "Copyright Equinor ASA, Ceetron Solution AS, Ceetron AS\n\n";

const cvf::String usageText = progOpt.usageText(110, 30);
helpText += cvfqt::Utils::toQString(usageText);
Expand Down
15 changes: 13 additions & 2 deletions ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@

#include "RiaImportEclipseCaseTools.h"

#include "../SummaryPlotCommands/RicNewSummaryPlotFeature.h"
#include "SummaryPlotCommands/RicNewSummaryPlotFeature.h"
#include "SummaryPlotCommands/RicNewSummaryCurveFeature.h"

#include "RiaApplication.h"
#include "RiaLogging.h"
Expand Down Expand Up @@ -47,6 +48,7 @@
#include "RimSummaryCurve.h"
#include "RimSummaryCurveCollection.h"
#include "RimSummaryCurveFilter.h"
#include "RimSummaryPlot.h"
#include "RimSummaryPlotCollection.h"

#include "RiuMainWindow.h"
Expand Down Expand Up @@ -90,9 +92,9 @@ bool RiaImportEclipseCaseTools::openEclipseCasesFromFile(const QStringList& file
if (sumCaseColl)
{
std::vector<RimSummaryCase*> newSumCases = sumCaseColl->createSummaryCasesFromFileInfos(summaryFileInfos);

for (RimSummaryCase* newSumCase : newSumCases)
{

RimSummaryCaseCollection* existingCollection = nullptr;
QString gridCaseFile = RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(newSumCase->summaryHeaderFilename());
RimEclipseCase* gridCase = project->eclipseCaseFromGridFileName(gridCaseFile);
Expand Down Expand Up @@ -150,6 +152,15 @@ bool RiaImportEclipseCaseTools::openEclipseCasesFromFile(const QStringList& file
}
sumCaseColl->updateAllRequiredEditors();
}

if (!newSumCases.empty())
{
RimSummaryPlotCollection* summaryPlotColl = project->mainPlotCollection()->summaryPlotCollection();

RicNewSummaryCurveFeature::ensureAtLeastOnePlot(summaryPlotColl, newSumCases.front());

RiuPlotMainWindowTools::setExpanded(newSumCases.front());
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void RicHelpAboutFeature::onActionTriggered(bool isChecked)

dlg.setApplicationName(RI_APPLICATION_NAME);
dlg.setApplicationVersion(RiaApplication::getVersionStringApp(true));
dlg.setCopyright("Copyright Statoil ASA, Ceetron Solutions AS, Ceetron AS");
dlg.setCopyright("Copyright Equinor ASA, Ceetron Solutions AS, Ceetron AS");
dlg.showQtVersion(false);
#ifdef _DEBUG
dlg.setIsDebugBuild(true);
Expand Down
8 changes: 8 additions & 0 deletions ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

#include "RicImportSummaryCasesFeature.h"

#include "SummaryPlotCommands/RicNewSummaryCurveFeature.h"

#include "RiaApplication.h"
#include "RiaLogging.h"
#include "RiaPreferences.h"
Expand Down Expand Up @@ -187,6 +189,12 @@ void RicImportSummaryCasesFeature::addSummaryCases(const std::vector<RimSummaryC
RimProject* proj = app->project();
RimSummaryCaseMainCollection* sumCaseColl = proj->activeOilField() ? proj->activeOilField()->summaryCaseMainCollection() : nullptr;
sumCaseColl->addCases(cases);

if (!cases.empty())
{
RicNewSummaryCurveFeature::createNewPlot(proj->mainPlotCollection->summaryPlotCollection(), cases.front());
}

sumCaseColl->updateAllRequiredEditors();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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.
//
/////////////////////////////////////////////////////////////////////////////////
Expand All @@ -21,10 +21,10 @@
#include "RiaApplication.h"
#include "RiaColorTables.h"

#include "RiaSummaryTools.h"
#include "RimMainPlotCollection.h"
#include "RimOilField.h"
#include "RimProject.h"
#include "RiaSummaryTools.h"
#include "RimSummaryCaseMainCollection.h"
#include "RimSummaryCurve.h"
#include "RimSummaryPlot.h"
Expand All @@ -37,20 +37,83 @@
#include "cvfAssert.h"

#include <QAction>

#include "RiuPlotMainWindowTools.h"

CAF_CMD_SOURCE_INIT(RicNewSummaryCurveFeature, "RicNewSummaryCurveFeature");

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSummaryCurve* RicNewSummaryCurveFeature::addCurveToPlot(RimSummaryPlot* plot, RimSummaryCase* summaryCase)
{
if (plot)
{
RimSummaryCurve* newCurve = new RimSummaryCurve();

// Use same counting as RicNewSummaryEnsembleCurveSetFeature::onActionTriggered
cvf::Color3f curveColor = RiaColorTables::summaryCurveDefaultPaletteColors().cycledColor3f(plot->singleColorCurveCount());
newCurve->setColor(curveColor);

plot->addCurveAndUpdate(newCurve);

if (summaryCase)
{
newCurve->setSummaryCaseY(summaryCase);
}

newCurve->setSummaryAddressY(RifEclipseSummaryAddress::fieldAddress("FOPT"));

newCurve->loadDataAndUpdate(true);

return newCurve;
}

return nullptr;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewSummaryCurveFeature::ensureAtLeastOnePlot(RimSummaryPlotCollection* summaryPlotCollection, RimSummaryCase* summaryCase)
{
if (summaryPlotCollection && summaryCase)
{
if (summaryPlotCollection->summaryPlots.empty())
{
createNewPlot(summaryPlotCollection, summaryCase);
}
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewSummaryCurveFeature::createNewPlot(RimSummaryPlotCollection* summaryPlotCollection, RimSummaryCase* summaryCase)
{
if (summaryPlotCollection && summaryCase)
{
auto plot = summaryPlotCollection->createSummaryPlotWithAutoTitle();

auto curve = RicNewSummaryCurveFeature::addCurveToPlot(plot, summaryCase);
plot->loadDataAndUpdate();

summaryPlotCollection->updateConnectedEditors();

RiuPlotMainWindowTools::setExpanded(curve);
RiuPlotMainWindowTools::selectAsCurrentItem(curve);
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicNewSummaryCurveFeature::isCommandEnabled()
{
return (selectedSummaryPlot());
}

//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RicNewSummaryCurveFeature::onActionTriggered(bool isChecked)
{
Expand All @@ -60,25 +123,14 @@ void RicNewSummaryCurveFeature::onActionTriggered(bool isChecked)
RimSummaryPlot* plot = selectedSummaryPlot();
if (plot)
{
RimSummaryCurve* newCurve = new RimSummaryCurve();

// Use same counting as RicNewSummaryEnsembleCurveSetFeature::onActionTriggered
cvf::Color3f curveColor = RiaColorTables::summaryCurveDefaultPaletteColors().cycledColor3f(plot->singleColorCurveCount());
newCurve->setColor(curveColor);

plot->addCurveAndUpdate(newCurve);

RimSummaryCase* defaultCase = nullptr;
RimSummaryCase* defaultCase = nullptr;
if (project->activeOilField()->summaryCaseMainCollection()->summaryCaseCount() > 0)
{
defaultCase = project->activeOilField()->summaryCaseMainCollection()->summaryCase(0);
newCurve->setSummaryCaseY(defaultCase);
}

newCurve->setSummaryAddressY(RifEclipseSummaryAddress::fieldAddress("FOPT"));
RimSummaryCurve* newCurve = addCurveToPlot(plot, defaultCase);

newCurve->loadDataAndUpdate(true);
}

plot->updateConnectedEditors();

RiaApplication::instance()->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem(newCurve);
Expand All @@ -89,7 +141,7 @@ void RicNewSummaryCurveFeature::onActionTriggered(bool isChecked)
}

//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RicNewSummaryCurveFeature::setupActionLook(QAction* actionToSetup)
{
Expand All @@ -98,13 +150,13 @@ void RicNewSummaryCurveFeature::setupActionLook(QAction* actionToSetup)
}

//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RimSummaryPlot* RicNewSummaryCurveFeature::selectedSummaryPlot() const
{
RimSummaryPlot* sumPlot = nullptr;

caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>(caf::SelectionManager::instance()->selectedItem());
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>(caf::SelectionManager::instance()->selectedItem());
if (selObj)
{
sumPlot = RiaSummaryTools::parentSummaryPlot(selObj);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,22 @@
#include <vector>

class RimSummaryPlot;
class RimSummaryCase;
class RimSummaryCurve;
class RimSummaryPlotCollection;

//==================================================================================================
///
//==================================================================================================
class RicNewSummaryCurveFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;

public:
static RimSummaryCurve* addCurveToPlot(RimSummaryPlot* plot, RimSummaryCase* summaryCase);
static void ensureAtLeastOnePlot(RimSummaryPlotCollection* summaryPlotCollection, RimSummaryCase* summaryCase);
static void createNewPlot(RimSummaryPlotCollection* summaryPlotCollection, RimSummaryCase* summaryCase);

protected:
// Overrides
bool isCommandEnabled() override;
Expand Down
Loading

0 comments on commit 45138cb

Please sign in to comment.