Files
ResInsight/ApplicationCode/Application/RiaApplication.h
T

276 lines
9.6 KiB
C++
Raw Normal View History

2012-05-18 09:45:23 +02:00
/////////////////////////////////////////////////////////////////////////////////
//
2014-09-23 15:04:57 +02:00
// Copyright (C) 2011- Statoil ASA
// Copyright (C) 2013- Ceetron Solutions AS
// Copyright (C) 2011-2012 Ceetron AS
2012-05-18 09:45:23 +02: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.
//
// 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 <QApplication>
2012-05-18 09:45:23 +02:00
#include <QProcess>
#include <QMutex>
#include "cafPdmObject.h"
#include "cafPdmField.h"
2012-05-18 09:45:23 +02:00
#include "cvfBase.h"
#include "cvfObject.h"
#include "cvfFont.h"
2012-05-18 09:45:23 +02:00
#include <iostream>
#include <memory>
class QAction;
2012-05-18 09:45:23 +02:00
class Drawable;
2012-05-18 09:45:23 +02:00
class RIProcess;
class RiaPreferences;
class RiaProjectModifier;
class RiaSocketServer;
2017-01-10 09:51:39 +01:00
class RigEclipseCaseData;
class RimCommandObject;
class RimEclipseCase;
class RimEclipseView;
class RimProject;
class RimSummaryPlot;
class RimView;
class RimViewWindow;
class RimWellLogPlot;
class RimWellAllocationPlot;
class RiuMainWindowBase;
class RiuMainPlotWindow;
class RiuRecentFileActionProvider;
2012-05-18 09:45:23 +02:00
namespace caf
{
class UiProcess;
}
//==================================================================================================
//
//
//
//==================================================================================================
class RiaApplication : public QApplication
2012-05-18 09:45:23 +02:00
{
Q_OBJECT
public:
enum RINavigationPolicy
{
NAVIGATION_POLICY_CEETRON,
2015-07-02 12:31:35 +02:00
NAVIGATION_POLICY_CAD,
NAVIGATION_POLICY_GEOQUEST,
NAVIGATION_POLICY_RMS
2012-05-18 09:45:23 +02:00
};
enum ProjectLoadAction
{
PLA_NONE = 0,
PLA_CALCULATE_STATISTICS = 1
};
2012-05-18 09:45:23 +02:00
public:
RiaApplication(int& argc, char** argv);
~RiaApplication();
static RiaApplication* instance();
2012-05-18 09:45:23 +02:00
int parseArgumentsAndRunUnitTestsIfRequested();
2012-05-18 09:45:23 +02:00
bool parseArguments();
void executeRegressionTests(const QString& regressionTestPath);
2015-05-08 14:13:26 +02:00
void setActiveReservoirView(RimView*);
RimView* activeReservoirView();
const RimView* activeReservoirView() const;
2012-05-18 09:45:23 +02:00
RimViewWindow* activePlotWindow() const;
2015-04-30 10:34:15 +02:00
void scheduleDisplayModelUpdateAndRedraw(RimView* resViewToUpdate);
RimProject* project();
2012-05-18 09:45:23 +02:00
void createMockModel();
void createResultsMockModel();
void createLargeResultsMockModel();
void createMockModelCustomized();
2012-06-26 16:10:41 +02:00
void createInputMockModel();
2012-05-18 09:45:23 +02:00
QString lastUsedDialogDirectory(const QString& dialogName);
QString lastUsedDialogDirectoryWithFallback(const QString& dialogName, const QString& fallbackDirectory);
void setLastUsedDialogDirectory(const QString& dialogName, const QString& directory);
2016-10-05 10:42:08 +02:00
bool openFile(const QString& fileName);
2012-05-18 09:45:23 +02:00
bool openEclipseCaseFromFile(const QString& fileName);
2012-06-26 16:10:41 +02:00
bool openEclipseCase(const QString& caseName, const QString& caseFileName);
2013-02-27 15:27:33 +01:00
bool addEclipseCases(const QStringList& fileNames);
bool openInputEclipseCaseFromFileNames(const QStringList& fileNames);
2012-06-26 16:10:41 +02:00
2015-04-20 09:02:33 +02:00
bool openOdbCaseFromFile(const QString& fileName);
QString currentProjectPath() const;
QString createAbsolutePathFromProjectRelativePath(QString projectRelativePath);
bool loadProject(const QString& projectFileName);
bool loadProject(const QString& projectFileName, ProjectLoadAction loadAction, RiaProjectModifier* projectModifier);
2012-05-18 09:45:23 +02:00
bool saveProject();
bool saveProjectAs(const QString& fileName);
bool saveProjectPromptForFileName();
static bool hasValidProjectFileExtension(const QString& fileName);
bool askUserToSaveModifiedProject();
void closeProject();
void addWellPathsToModel(QList<QString> wellPathFilePaths);
void addWellLogsToModel(const QList<QString>& wellLogFilePaths);
void runMultiCaseSnapshots(const QString& templateProjectFileName, std::vector<QString> gridFileNames, const QString& snapshotFolderName);
void runRegressionTest(const QString& testRootPath);
2012-05-18 09:45:23 +02:00
void processNonGuiEvents();
static const char* getVersionStringApp(bool includeCrtInfo);
2012-05-18 09:45:23 +02:00
void setUseShaders(bool enable);
bool useShaders() const;
void setShowPerformanceInfo(bool enable);
bool showPerformanceInfo() const;
RINavigationPolicy navigationPolicy() const;
QString scriptDirectories() const;
2012-05-18 09:45:23 +02:00
QString scriptEditorPath() const;
2014-07-22 12:11:48 +02:00
2012-05-18 09:45:23 +02:00
QString octavePath() const;
2014-07-22 12:11:48 +02:00
QStringList octaveArguments() const;
2012-05-18 09:45:23 +02:00
bool launchProcess(const QString& program, const QStringList& arguments);
bool launchProcessForMultipleCases(const QString& program, const QStringList& arguments, const std::vector<int>& caseIds);
2012-08-31 19:12:47 +02:00
void terminateProcess();
void waitForProcess() const;
2012-05-18 09:45:23 +02:00
RiaPreferences* preferences();
2012-05-18 09:45:23 +02:00
void applyPreferences();
cvf::Font* standardFont();
cvf::Font* customFont();
2013-08-08 11:09:18 +02:00
QString commandLineParameterHelp() const;
void showFormattedTextInMessageBox(const QString& text);
2013-09-08 10:53:25 +02:00
void setCacheDataObject(const QString& key, const QVariant& dataObject);
QVariant cacheDataObject(const QString& key) const;
void addCommandObject(RimCommandObject* commandObject);
void executeCommandObjects();
bool isRunningRegressionTests() const;
int launchUnitTests();
int launchUnitTestsWithConsole();
2015-10-05 16:09:51 +02:00
RiuMainPlotWindow* getOrCreateAndShowMainPlotWindow();
RiuMainPlotWindow* mainPlotWindow();
RiuMainWindowBase* mainWindowByID(int mainWindowID);
static RimViewWindow* activeViewWindow();
bool isMain3dWindowVisible() const;
bool isMainPlotWindowVisible() const;
bool tryCloseMainWindow();
bool tryClosePlotWindow();
void addToRecentFiles(const QString& fileName);
std::vector<QAction*> recentFileActions() const;
void setStartDir(const QString& startDir);
static std::vector<QString> readFileListFromTextFile(QString listFileName);
void clearViewsScheduledForUpdate();
private:
void onProjectOpenedOrClosed();
void setWindowCaptionFromAppState();
2012-05-18 09:45:23 +02:00
void createMainPlotWindow();
void deleteMainPlotWindow();
void loadAndUpdatePlotData();
void storeTreeViewState();
void resizeMaximizedPlotWindows();
void updateRegressionTest(const QString& testRootPath);
void regressionTestConfigureProject();
static QSize regressionDefaultImageSize();
2012-05-18 09:45:23 +02:00
private slots:
void slotWorkerProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
void slotUpdateScheduledDisplayModels();
2012-05-18 09:45:23 +02:00
// Friend classes required to have access to slotUpdateScheduledDisplayModels
// As snapshots are produced fast in sequence, the feature must have access to force redraw
// of scheduled redraws
friend class RimView;
friend class RicExportMultipleSnapshotsFeature;
2012-05-18 09:45:23 +02:00
private:
2015-05-08 14:13:26 +02:00
caf::PdmPointer<RimView> m_activeReservoirView;
caf::PdmPointer<RimProject> m_project;
2015-04-30 10:34:15 +02:00
std::vector<caf::PdmPointer<RimView> > m_resViewsToUpdate;
QTimer* m_resViewUpdateTimer;
RiaSocketServer* m_socketServer;
2012-05-18 09:45:23 +02:00
caf::UiProcess* m_workerProcess;
2012-05-18 09:45:23 +02:00
// Execute for all settings
std::list<int> m_currentCaseIds;
QString m_currentProgram;
QStringList m_currentArguments;
RiaPreferences* m_preferences;
2012-05-18 09:45:23 +02:00
std::map<QString, QString> m_fileDialogDefaultDirectories;
QString m_startupDefaultDirectory;
cvf::ref<cvf::Font> m_standardFont;
cvf::ref<cvf::Font> m_customFont;
2013-09-08 10:53:25 +02:00
QMap<QString, QVariant> m_sessionCache; // Session cache used to store username/passwords per session
std::list<RimCommandObject*> m_commandQueue;
QMutex m_commandQueueLock;
QString m_helpText;
bool m_runningRegressionTests;
bool m_runningWorkerProcess;
RiuMainPlotWindow* m_mainPlotWindow;
std::unique_ptr<RiuRecentFileActionProvider> m_recentFileActionProvider;
2012-05-18 09:45:23 +02:00
};