|
|
|
|
@@ -80,6 +80,7 @@
|
|
|
|
|
#include "Riu3dSelectionManager.h"
|
|
|
|
|
#include "RiuDockWidgetTools.h"
|
|
|
|
|
#include "RiuMainWindow.h"
|
|
|
|
|
#include "RiuMessagePanel.h"
|
|
|
|
|
#include "RiuPlotMainWindow.h"
|
|
|
|
|
#include "RiuProcessMonitor.h"
|
|
|
|
|
#include "RiuRecentFileActionProvider.h"
|
|
|
|
|
@@ -224,9 +225,18 @@ RiaApplication::RiaApplication(int& argc, char** argv)
|
|
|
|
|
|
|
|
|
|
m_runningWorkerProcess = false;
|
|
|
|
|
|
|
|
|
|
m_mainWindow = nullptr;
|
|
|
|
|
m_mainPlotWindow = nullptr;
|
|
|
|
|
|
|
|
|
|
m_recentFileActionProvider = std::unique_ptr<RiuRecentFileActionProvider>(new RiuRecentFileActionProvider);
|
|
|
|
|
|
|
|
|
|
// Create main windows
|
|
|
|
|
// The plot window is created to be able to set expanded state on created objects, but hidden by default
|
|
|
|
|
getOrCreateAndShowMainWindow();
|
|
|
|
|
getOrCreateMainPlotWindow();
|
|
|
|
|
|
|
|
|
|
RiaLogging::setLoggerInstance(new RiuMessagePanelLogger(m_mainWindow->messagePanel()));
|
|
|
|
|
RiaLogging::loggerInstance()->setLevel(RI_LL_DEBUG);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
@@ -237,8 +247,11 @@ RiaApplication::~RiaApplication()
|
|
|
|
|
RiuDockWidgetTools::instance()->saveDockWidgetsState();
|
|
|
|
|
|
|
|
|
|
deleteMainPlotWindow();
|
|
|
|
|
deleteMainWindow();
|
|
|
|
|
|
|
|
|
|
delete m_preferences;
|
|
|
|
|
|
|
|
|
|
RiaLogging::deleteLoggerInstance();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
@@ -283,8 +296,7 @@ int RiaApplication::parseArgumentsAndRunUnitTestsIfRequested()
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RiaApplication::setWindowCaptionFromAppState()
|
|
|
|
|
{
|
|
|
|
|
RiuMainWindow* mainWnd = RiuMainWindow::instance();
|
|
|
|
|
if (!mainWnd) return;
|
|
|
|
|
if (!m_mainWindow) return;
|
|
|
|
|
|
|
|
|
|
// The stuff being done here should really be handled by Qt automatically as a result of
|
|
|
|
|
// setting applicationName and windowFilePath
|
|
|
|
|
@@ -302,7 +314,7 @@ void RiaApplication::setWindowCaptionFromAppState()
|
|
|
|
|
capt = projFileName + QString("[*]") + QString(" - ") + capt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mainWnd->setWindowTitle(capt);
|
|
|
|
|
m_mainWindow->setWindowTitle(capt);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
@@ -382,8 +394,7 @@ bool RiaApplication::loadProject(const QString& projectFileName,
|
|
|
|
|
QString("Unknown project file version detected in file \n%1\n\nCould not open project.").arg(fullPathProjectFileName);
|
|
|
|
|
QMessageBox::warning(nullptr, "Error when opening project file", tmp);
|
|
|
|
|
|
|
|
|
|
RiuMainWindow* mainWnd = RiuMainWindow::instance();
|
|
|
|
|
mainWnd->setPdmRoot(nullptr);
|
|
|
|
|
m_mainWindow->setPdmRoot(nullptr);
|
|
|
|
|
|
|
|
|
|
// Delete all object possibly generated by readFile()
|
|
|
|
|
delete m_project;
|
|
|
|
|
@@ -396,11 +407,11 @@ bool RiaApplication::loadProject(const QString& projectFileName,
|
|
|
|
|
|
|
|
|
|
if (m_project->show3DWindow())
|
|
|
|
|
{
|
|
|
|
|
RiuMainWindow::instance()->show();
|
|
|
|
|
m_mainWindow->show();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
RiuMainWindow::instance()->hide();
|
|
|
|
|
m_mainWindow->hide();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_project->showPlotWindow())
|
|
|
|
|
@@ -785,7 +796,7 @@ void RiaApplication::storeTreeViewState()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
caf::PdmUiTreeView* projectTreeView = RiuMainWindow::instance()->projectTreeView();
|
|
|
|
|
caf::PdmUiTreeView* projectTreeView = m_mainWindow->projectTreeView();
|
|
|
|
|
if (projectTreeView)
|
|
|
|
|
{
|
|
|
|
|
QString treeViewState;
|
|
|
|
|
@@ -871,7 +882,7 @@ void RiaApplication::addWellLogsToModel(const QList<QString>& wellLogFilePaths)
|
|
|
|
|
|
|
|
|
|
oilField->wellPathCollection->updateConnectedEditors();
|
|
|
|
|
|
|
|
|
|
RiuMainWindow::instance()->selectAsCurrentItem(wellLogFile);
|
|
|
|
|
m_mainWindow->selectAsCurrentItem(wellLogFile);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
@@ -1018,15 +1029,13 @@ void RiaApplication::closeProject()
|
|
|
|
|
RicHoloLensSessionManager::instance()->terminateSession();
|
|
|
|
|
RicHoloLensSessionManager::refreshToolbarState();
|
|
|
|
|
|
|
|
|
|
RiuMainWindow* mainWnd = RiuMainWindow::instance();
|
|
|
|
|
|
|
|
|
|
RiaViewRedrawScheduler::instance()->clearViewsScheduledForUpdate();
|
|
|
|
|
|
|
|
|
|
terminateProcess();
|
|
|
|
|
|
|
|
|
|
RiaApplication::clearAllSelections();
|
|
|
|
|
|
|
|
|
|
mainWnd->cleanupGuiBeforeProjectClose();
|
|
|
|
|
m_mainWindow->cleanupGuiBeforeProjectClose();
|
|
|
|
|
|
|
|
|
|
if (m_mainPlotWindow)
|
|
|
|
|
{
|
|
|
|
|
@@ -1049,10 +1058,9 @@ void RiaApplication::closeProject()
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RiaApplication::onProjectOpenedOrClosed()
|
|
|
|
|
{
|
|
|
|
|
RiuMainWindow* mainWnd = RiuMainWindow::instance();
|
|
|
|
|
if (mainWnd)
|
|
|
|
|
if (m_mainWindow)
|
|
|
|
|
{
|
|
|
|
|
mainWnd->initializeGuiNewProjectLoaded();
|
|
|
|
|
m_mainWindow->initializeGuiNewProjectLoaded();
|
|
|
|
|
}
|
|
|
|
|
if (m_mainPlotWindow)
|
|
|
|
|
{
|
|
|
|
|
@@ -1157,7 +1165,7 @@ bool RiaApplication::openOdbCaseFromFile(const QString& fileName, bool applyTime
|
|
|
|
|
|
|
|
|
|
m_project->updateConnectedEditors();
|
|
|
|
|
|
|
|
|
|
RiuMainWindow::instance()->selectAsCurrentItem(riv->cellResult());
|
|
|
|
|
m_mainWindow->selectAsCurrentItem(riv->cellResult());
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
@@ -1366,6 +1374,26 @@ int RiaApplication::launchUnitTestsWithConsole()
|
|
|
|
|
return launchUnitTests();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
RiuMainWindow* RiaApplication::getOrCreateAndShowMainWindow()
|
|
|
|
|
{
|
|
|
|
|
if (!m_mainWindow)
|
|
|
|
|
{
|
|
|
|
|
createMainWindow();
|
|
|
|
|
}
|
|
|
|
|
return m_mainWindow;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
RiuMainWindow* RiaApplication::mainWindow()
|
|
|
|
|
{
|
|
|
|
|
return m_mainWindow;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
@@ -1380,6 +1408,33 @@ RiuPlotMainWindow* RiaApplication::getOrCreateMainPlotWindow()
|
|
|
|
|
return m_mainPlotWindow;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RiaApplication::createMainWindow()
|
|
|
|
|
{
|
|
|
|
|
CVF_ASSERT(m_mainWindow == nullptr);
|
|
|
|
|
m_mainWindow = new RiuMainWindow;
|
|
|
|
|
QString platform = cvf::System::is64Bit() ? "(64bit)" : "(32bit)";
|
|
|
|
|
m_mainWindow->setWindowTitle("ResInsight " + platform);
|
|
|
|
|
m_mainWindow->setDefaultWindowSize();
|
|
|
|
|
m_mainWindow->setDefaultToolbarVisibility();
|
|
|
|
|
m_mainWindow->loadWinGeoAndDockToolBarLayout();
|
|
|
|
|
m_mainWindow->showWindow();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RiaApplication::deleteMainWindow()
|
|
|
|
|
{
|
|
|
|
|
if (m_mainWindow)
|
|
|
|
|
{
|
|
|
|
|
delete m_mainWindow;
|
|
|
|
|
m_mainWindow = nullptr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
@@ -1447,7 +1502,7 @@ RiuPlotMainWindow* RiaApplication::mainPlotWindow()
|
|
|
|
|
RiuMainWindowBase* RiaApplication::mainWindowByID(int mainWindowID)
|
|
|
|
|
{
|
|
|
|
|
if (mainWindowID == 0)
|
|
|
|
|
return RiuMainWindow::instance();
|
|
|
|
|
return m_mainWindow;
|
|
|
|
|
else if (mainWindowID == 1)
|
|
|
|
|
return m_mainPlotWindow;
|
|
|
|
|
else
|
|
|
|
|
@@ -1486,7 +1541,7 @@ RimViewWindow* RiaApplication::activeViewWindow()
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
bool RiaApplication::isMain3dWindowVisible() const
|
|
|
|
|
{
|
|
|
|
|
return RiuMainWindow::instance()->isVisible();
|
|
|
|
|
return m_mainWindow && m_mainWindow->isVisible();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
@@ -1494,45 +1549,29 @@ bool RiaApplication::isMain3dWindowVisible() const
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
bool RiaApplication::isMainPlotWindowVisible() const
|
|
|
|
|
{
|
|
|
|
|
if (!m_mainPlotWindow) return false;
|
|
|
|
|
|
|
|
|
|
return m_mainPlotWindow->isVisible();
|
|
|
|
|
return m_mainPlotWindow && m_mainPlotWindow->isVisible();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
bool RiaApplication::tryCloseMainWindow()
|
|
|
|
|
void RiaApplication::closeMainWindowIfOpenButHidden()
|
|
|
|
|
{
|
|
|
|
|
RiuMainWindow* mainWindow = RiuMainWindow::instance();
|
|
|
|
|
if (mainWindow && !mainWindow->isVisible())
|
|
|
|
|
if (m_mainWindow && !m_mainWindow->isVisible())
|
|
|
|
|
{
|
|
|
|
|
mainWindow->close();
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
m_mainWindow->close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
bool RiaApplication::tryClosePlotWindow()
|
|
|
|
|
void RiaApplication::closeMainPlotWindowIfOpenButHidden()
|
|
|
|
|
{
|
|
|
|
|
if (!m_mainPlotWindow)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_mainPlotWindow && !m_mainPlotWindow->isVisible())
|
|
|
|
|
{
|
|
|
|
|
m_mainPlotWindow->close();
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
@@ -1540,6 +1579,7 @@ bool RiaApplication::tryClosePlotWindow()
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RiaApplication::addToRecentFiles(const QString& fileName)
|
|
|
|
|
{
|
|
|
|
|
CVF_ASSERT(m_recentFileActionProvider && "The provider needs to be created before any attempts to use the recent file actions");
|
|
|
|
|
m_recentFileActionProvider->addFileName(fileName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -1548,6 +1588,7 @@ void RiaApplication::addToRecentFiles(const QString& fileName)
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
std::vector<QAction*> RiaApplication::recentFileActions() const
|
|
|
|
|
{
|
|
|
|
|
CVF_ASSERT(m_recentFileActionProvider && "The provider needs to be created before any attempts to use the recent file actions");
|
|
|
|
|
return m_recentFileActionProvider->actions();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -1608,19 +1649,24 @@ void RiaApplication::waitUntilCommandObjectsHasBeenProcessed()
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RiaApplication::saveWinGeoAndDockToolBarLayout()
|
|
|
|
|
void RiaApplication::saveMainWinGeoAndDockToolBarLayout()
|
|
|
|
|
{
|
|
|
|
|
if (m_mainPlotWindow)
|
|
|
|
|
if (isMain3dWindowVisible())
|
|
|
|
|
{
|
|
|
|
|
m_mainPlotWindow->saveWinGeoAndDockToolBarLayout();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (RiuMainWindow::instance())
|
|
|
|
|
{
|
|
|
|
|
RiuMainWindow::instance()->saveWinGeoAndDockToolBarLayout();
|
|
|
|
|
m_mainWindow->saveWinGeoAndDockToolBarLayout();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RiaApplication::savePlotWinGeoAndDockToolBarLayout()
|
|
|
|
|
{
|
|
|
|
|
if (isMainPlotWindowVisible())
|
|
|
|
|
{
|
|
|
|
|
m_mainPlotWindow->saveWinGeoAndDockToolBarLayout();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
@@ -1696,7 +1742,7 @@ QStringList RiaApplication::octaveArguments() const
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RiaApplication::slotWorkerProcessFinished(int exitCode, QProcess::ExitStatus exitStatus)
|
|
|
|
|
{
|
|
|
|
|
RiuMainWindow::instance()->processMonitor()->stopMonitorWorkProcess();
|
|
|
|
|
m_mainWindow->processMonitor()->stopMonitorWorkProcess();
|
|
|
|
|
|
|
|
|
|
// Execute delete later so that other slots that are hooked up
|
|
|
|
|
// get a chance to run before we delete the object
|
|
|
|
|
@@ -1794,7 +1840,7 @@ bool RiaApplication::launchProcess(const QString& program, const QStringList& ar
|
|
|
|
|
SIGNAL(finished(int, QProcess::ExitStatus)),
|
|
|
|
|
SLOT(slotWorkerProcessFinished(int, QProcess::ExitStatus)));
|
|
|
|
|
|
|
|
|
|
RiuMainWindow::instance()->processMonitor()->startMonitorWorkProcess(m_workerProcess);
|
|
|
|
|
m_mainWindow->processMonitor()->startMonitorWorkProcess(m_workerProcess);
|
|
|
|
|
|
|
|
|
|
m_workerProcess->start(program, arguments);
|
|
|
|
|
if (!m_workerProcess->waitForStarted(1000))
|
|
|
|
|
@@ -1803,10 +1849,10 @@ bool RiaApplication::launchProcess(const QString& program, const QStringList& ar
|
|
|
|
|
m_workerProcess = nullptr;
|
|
|
|
|
m_runningWorkerProcess = false;
|
|
|
|
|
|
|
|
|
|
RiuMainWindow::instance()->processMonitor()->stopMonitorWorkProcess();
|
|
|
|
|
m_mainWindow->processMonitor()->stopMonitorWorkProcess();
|
|
|
|
|
|
|
|
|
|
QMessageBox::warning(
|
|
|
|
|
RiuMainWindow::instance(), "Script execution", "Failed to start script executable located at\n" + program);
|
|
|
|
|
m_mainWindow, "Script execution", "Failed to start script executable located at\n" + program);
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
@@ -1866,9 +1912,9 @@ void RiaApplication::applyPreferences()
|
|
|
|
|
caf::EffectGenerator::setRenderingMode(caf::EffectGenerator::FIXED_FUNCTION);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (RiuMainWindow::instance() && RiuMainWindow::instance()->projectTreeView())
|
|
|
|
|
if (m_mainWindow && m_mainWindow->projectTreeView())
|
|
|
|
|
{
|
|
|
|
|
RiuMainWindow::instance()->projectTreeView()->enableAppendOfClassNameToUiItemText(
|
|
|
|
|
m_mainWindow->projectTreeView()->enableAppendOfClassNameToUiItemText(
|
|
|
|
|
m_preferences->appendClassNameToUiText());
|
|
|
|
|
if (mainPlotWindow())
|
|
|
|
|
mainPlotWindow()->projectTreeView()->enableAppendOfClassNameToUiItemText(m_preferences->appendClassNameToUiText());
|
|
|
|
|
@@ -2030,10 +2076,9 @@ void RiaApplication::runMultiCaseSnapshots(const QString& templateProjectF
|
|
|
|
|
std::vector<QString> gridFileNames,
|
|
|
|
|
const QString& snapshotFolderName)
|
|
|
|
|
{
|
|
|
|
|
RiuMainWindow* mainWnd = RiuMainWindow::instance();
|
|
|
|
|
if (!mainWnd) return;
|
|
|
|
|
if (!m_mainWindow) return;
|
|
|
|
|
|
|
|
|
|
mainWnd->hideAllDockWindows();
|
|
|
|
|
m_mainWindow->hideAllDockWindows();
|
|
|
|
|
|
|
|
|
|
const size_t numGridFiles = gridFileNames.size();
|
|
|
|
|
for (size_t i = 0; i < numGridFiles; i++)
|
|
|
|
|
@@ -2050,7 +2095,7 @@ void RiaApplication::runMultiCaseSnapshots(const QString& templateProjectF
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mainWnd->loadWinGeoAndDockToolBarLayout();
|
|
|
|
|
m_mainWindow->loadWinGeoAndDockToolBarLayout();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
|