///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2011- Statoil ASA // Copyright (C) 2013- Ceetron Solutions AS // Copyright (C) 2011-2012 Ceetron AS // // 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 // for more details. // ///////////////////////////////////////////////////////////////////////////////// #pragma once #include #include #include #include "cafPdmObject.h" #include "cafPdmField.h" #include "cvfBase.h" #include "cvfObject.h" #include "cvfFont.h" #include #include class QAction; class Drawable; class RIProcess; class RiaPreferences; class RiaProjectModifier; class RiaSocketServer; 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; namespace caf { class UiProcess; } //================================================================================================== // // // //================================================================================================== class RiaApplication : public QApplication { Q_OBJECT public: enum RINavigationPolicy { NAVIGATION_POLICY_CEETRON, NAVIGATION_POLICY_CAD, NAVIGATION_POLICY_GEOQUEST, NAVIGATION_POLICY_RMS }; enum ProjectLoadAction { PLA_NONE = 0, PLA_CALCULATE_STATISTICS = 1 }; public: RiaApplication(int& argc, char** argv); ~RiaApplication(); static RiaApplication* instance(); int parseArgumentsAndRunUnitTestsIfRequested(); bool parseArguments(); void executeRegressionTests(const QString& regressionTestPath); void setActiveReservoirView(RimView*); RimView* activeReservoirView(); const RimView* activeReservoirView() const; RimViewWindow* activePlotWindow() const; void scheduleDisplayModelUpdateAndRedraw(RimView* resViewToUpdate); void scheduleRecalculateCompletionTypeAndRedrawAllViews(); void scheduleRecalculateCompletionTypeAndRedrawEclipseCase(RimEclipseCase* eclipseCase); RimProject* project(); void createMockModel(); void createResultsMockModel(); void createLargeResultsMockModel(); void createMockModelCustomized(); void createInputMockModel(); QString lastUsedDialogDirectory(const QString& dialogName); QString lastUsedDialogDirectoryWithFallback(const QString& dialogName, const QString& fallbackDirectory); void setLastUsedDialogDirectory(const QString& dialogName, const QString& directory); bool openFile(const QString& fileName); 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); bool saveProject(); bool saveProjectAs(const QString& fileName); bool saveProjectPromptForFileName(); static bool hasValidProjectFileExtension(const QString& fileName); bool askUserToSaveModifiedProject(); void closeProject(); void addWellPathsToModel(QList wellPathFilePaths); void addWellLogsToModel(const QList& wellLogFilePaths); void runMultiCaseSnapshots(const QString& templateProjectFileName, std::vector gridFileNames, const QString& snapshotFolderName); void runRegressionTest(const QString& testRootPath); void processNonGuiEvents(); static const char* getVersionStringApp(bool includeCrtInfo); void setUseShaders(bool enable); bool useShaders() const; void setShowPerformanceInfo(bool enable); bool showPerformanceInfo() const; RINavigationPolicy navigationPolicy() const; QString scriptDirectories() const; QString scriptEditorPath() const; QString octavePath() const; QStringList octaveArguments() const; bool launchProcess(const QString& program, const QStringList& arguments); bool launchProcessForMultipleCases(const QString& program, const QStringList& arguments, const std::vector& caseIds); void terminateProcess(); void waitForProcess() const; RiaPreferences* preferences(); void applyPreferences(); cvf::Font* standardFont(); cvf::Font* customFont(); QString commandLineParameterHelp() const; void showFormattedTextInMessageBox(const QString& text); 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(); 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 recentFileActions() const; void setStartDir(const QString& startDir); static std::vector readFileListFromTextFile(QString listFileName); void clearViewsScheduledForUpdate(); private: void onProjectOpenedOrClosed(); void setWindowCaptionFromAppState(); void createMainPlotWindow(); void deleteMainPlotWindow(); void loadAndUpdatePlotData(); void storeTreeViewState(); void resizeMaximizedPlotWindows(); void updateRegressionTest(const QString& testRootPath); void regressionTestConfigureProject(); static QSize regressionDefaultImageSize(); private slots: void slotWorkerProcessFinished(int exitCode, QProcess::ExitStatus exitStatus); void slotUpdateScheduledDisplayModels(); void slotRecaulculateCompletionType(); // 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; private: caf::PdmPointer m_activeReservoirView; caf::PdmPointer m_project; std::vector > m_resViewsToUpdate; QTimer* m_resViewUpdateTimer; std::vector > m_eclipseCasesToRecalculate; QTimer* m_recalculateCompletionTypeTimer; RiaSocketServer* m_socketServer; caf::UiProcess* m_workerProcess; // Execute for all settings std::list m_currentCaseIds; QString m_currentProgram; QStringList m_currentArguments; RiaPreferences* m_preferences; std::map m_fileDialogDefaultDirectories; QString m_startupDefaultDirectory; cvf::ref m_standardFont; cvf::ref m_customFont; QMap m_sessionCache; // Session cache used to store username/passwords per session std::list m_commandQueue; QMutex m_commandQueueLock; QString m_helpText; bool m_runningRegressionTests; bool m_runningWorkerProcess; RiuMainPlotWindow* m_mainPlotWindow; std::unique_ptr m_recentFileActionProvider; };