2013-10-08 07:28:01 -05:00
/////////////////////////////////////////////////////////////////////////////////
//
2014-09-23 08:04:57 -05:00
// Copyright (C) 2011- Statoil ASA
// Copyright (C) 2013- Ceetron Solutions AS
// Copyright (C) 2011-2012 Ceetron AS
2013-10-08 07:28:01 -05: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.
//
/////////////////////////////////////////////////////////////////////////////////
# include "RiaApplication.h"
2018-01-12 04:31:01 -06:00
# include "RiaArgumentParser.h"
2013-10-08 07:28:01 -05:00
# include "RiaBaseDefs.h"
2018-04-20 03:03:07 -05:00
# include "RiaFilePathTools.h"
2017-08-24 23:51:56 -05:00
# include "RiaImportEclipseCaseTools.h"
2017-02-23 07:24:18 -06:00
# include "RiaLogging.h"
2015-09-25 08:57:43 -05:00
# include "RiaPreferences.h"
2013-12-04 05:04:42 -06:00
# include "RiaProjectModifier.h"
2015-09-25 08:57:43 -05:00
# include "RiaSocketServer.h"
# include "RiaVersionInfo.h"
2018-01-12 04:31:01 -06:00
# include "RiaViewRedrawScheduler.h"
2013-10-08 07:28:01 -05:00
2018-03-08 03:10:15 -06:00
# include "RicImportInputEclipseCaseFeature.h"
2018-03-19 05:02:22 -05:00
# include "RicImportSummaryCasesFeature.h"
2018-03-08 03:10:15 -06:00
# include "ExportCommands/RicSnapshotAllViewsToFileFeature.h"
2018-10-25 08:34:21 -05:00
# include "HoloLensCommands/RicHoloLensSessionManager.h"
2017-10-03 08:31:45 -05:00
2018-01-23 07:23:28 -06:00
# include "Rim2dIntersectionViewCollection.h"
2018-11-27 10:53:56 -06:00
# include "RimAnnotationCollection.h"
2013-10-08 07:28:01 -05:00
# include "RimCellRangeFilterCollection.h"
2015-09-25 08:57:43 -05:00
# include "RimCommandObject.h"
# include "RimEclipseCaseCollection.h"
# include "RimEclipseView.h"
2017-02-17 02:29:46 -06:00
# include "RimFlowPlotCollection.h"
2016-10-06 03:33:57 -05:00
# include "RimFormationNamesCollection.h"
2018-03-08 03:10:15 -06:00
# include "RimFractureTemplateCollection.h"
2015-04-20 02:02:33 -05:00
# include "RimGeoMechCase.h"
2015-09-25 08:57:43 -05:00
# include "RimGeoMechCellColors.h"
2015-04-20 02:02:33 -05:00
# include "RimGeoMechModels.h"
# include "RimGeoMechView.h"
2015-09-25 08:57:43 -05:00
# include "RimIdenticalGridCaseGroup.h"
2015-09-03 01:09:06 -05:00
# include "RimMainPlotCollection.h"
2017-10-03 08:31:45 -05:00
# include "RimObservedData.h"
2017-09-14 08:44:01 -05:00
# include "RimObservedDataCollection.h"
2015-09-25 08:57:43 -05:00
# include "RimOilField.h"
2018-03-08 03:10:15 -06:00
# include "RimPltPlotCollection.h"
2015-09-25 08:57:43 -05:00
# include "RimProject.h"
2018-03-08 03:10:15 -06:00
# include "RimRftPlotCollection.h"
# include "RimStimPlanColors.h"
2016-06-24 08:10:18 -05:00
# include "RimSummaryCase.h"
2018-06-25 08:14:47 -05:00
# include "RimSummaryCaseCollection.h"
2017-09-06 09:32:46 -05:00
# include "RimSummaryCaseMainCollection.h"
2017-11-07 13:40:45 -06:00
# include "RimSummaryCrossPlotCollection.h"
2016-06-24 08:10:18 -05:00
# include "RimSummaryPlot.h"
# include "RimSummaryPlotCollection.h"
2015-10-23 07:13:14 -05:00
# include "RimViewLinker.h"
# include "RimViewLinkerCollection.h"
2017-10-20 07:05:42 -05:00
# include "RimWellLogFile.h"
2015-09-03 01:09:06 -05:00
# include "RimWellLogPlot.h"
2015-09-25 08:57:43 -05:00
# include "RimWellLogPlotCollection.h"
# include "RimWellPathCollection.h"
2018-03-08 03:10:15 -06:00
# include "RimWellPathFracture.h"
2017-10-23 06:57:01 -05:00
# include "RimWellPltPlot.h"
2018-03-08 03:10:15 -06:00
# include "RimWellRftPlot.h"
2015-09-25 08:57:43 -05:00
2018-04-26 13:05:42 -05:00
# include "RiuDockWidgetTools.h"
2018-04-26 23:28:08 -05:00
# include "RiuPlotMainWindow.h"
2015-09-25 08:57:43 -05:00
# include "RiuMainWindow.h"
# include "RiuProcessMonitor.h"
2016-10-05 01:23:07 -05:00
# include "RiuRecentFileActionProvider.h"
2015-11-09 12:05:00 -06:00
# include "RiuSelectionManager.h"
2015-09-25 08:57:43 -05:00
# include "RiuViewer.h"
2016-08-09 06:09:08 -05:00
2015-09-25 08:57:43 -05:00
# include "cafAppEnum.h"
2018-03-08 03:10:15 -06:00
# include "cafEffectGenerator.h"
# include "cafFixedAtlasFont.h"
2015-09-25 08:57:43 -05:00
# include "cafPdmSettings.h"
2017-04-20 01:07:47 -05:00
# include "cafPdmUiModelChangeDetector.h"
2015-09-18 12:24:02 -05:00
# include "cafPdmUiTreeView.h"
2015-09-25 08:57:43 -05:00
# include "cafProgressInfo.h"
2017-10-03 07:50:06 -05:00
# include "cafQTreeViewStateSerializer.h"
2018-06-06 05:36:20 -05:00
# include "cafSelectionManager.h"
2015-09-25 08:57:43 -05:00
# include "cafUiProcess.h"
# include "cafUtils.h"
2017-04-20 01:07:47 -05:00
2015-09-25 08:57:43 -05:00
# include "cvfProgramOptions.h"
# include "cvfqtUtils.h"
# include <QDir>
# include <QFileDialog>
2015-10-23 07:13:14 -05:00
# include <QMdiSubWindow>
2015-09-25 08:57:43 -05:00
# include <QMessageBox>
2018-09-19 07:43:06 -05:00
# include <QProcessEnvironment>
2017-04-20 04:02:05 -05:00
# include <QTreeView>
2015-09-25 08:57:43 -05:00
2018-03-08 03:31:21 -06:00
# ifndef WIN32
2018-03-12 05:12:39 -05:00
# include <unistd.h> // for usleep
2018-03-08 03:31:21 -06:00
# endif //WIN32
2018-03-08 03:10:15 -06:00
# ifdef USE_UNIT_TESTS
2015-10-05 09:09:51 -05:00
# include "gtest/gtest.h"
2018-03-08 03:10:15 -06:00
# endif // USE_UNIT_TESTS
2017-02-23 07:24:18 -06:00
2013-10-08 07:28:01 -05:00
namespace caf
{
template < >
void AppEnum < RiaApplication : : RINavigationPolicy > : : setUp ( )
{
addItem ( RiaApplication : : NAVIGATION_POLICY_CEETRON , " NAVIGATION_POLICY_CEETRON " , " Ceetron " ) ;
addItem ( RiaApplication : : NAVIGATION_POLICY_CAD , " NAVIGATION_POLICY_CAD " , " CAD " ) ;
2015-07-02 05:31:35 -05:00
addItem ( RiaApplication : : NAVIGATION_POLICY_GEOQUEST , " NAVIGATION_POLICY_GEOQUEST " , " GEOQUEST " ) ;
addItem ( RiaApplication : : NAVIGATION_POLICY_RMS , " NAVIGATION_POLICY_RMS " , " RMS " ) ;
2015-07-02 06:33:07 -05:00
setDefault ( RiaApplication : : NAVIGATION_POLICY_RMS ) ;
2013-10-08 07:28:01 -05:00
}
}
2013-12-04 05:04:42 -06:00
2013-10-08 07:28:01 -05:00
//==================================================================================================
///
/// \class RiaApplication
///
/// Application class
///
//==================================================================================================
2018-05-03 02:53:54 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaApplication : : notify ( QObject * receiver , QEvent * event )
{
// Pre-allocating a memory exhaustion message
// Doing som e trickery to avoid deadlock, as creating a messagebox actually triggers a call to this notify method.
static QMessageBox * memoryExhaustedBox = nullptr ;
static bool allocatingMessageBox = false ;
if ( ! memoryExhaustedBox & & ! allocatingMessageBox )
{
allocatingMessageBox = true ;
memoryExhaustedBox = new QMessageBox ( QMessageBox : : Critical ,
" ResInsight Exhausted Memory " ,
" Memory is Exhausted! \n ResInsight could not allocate the memory needed, and is now unstable and will probably crash soon. " ) ;
}
bool done = true ;
try
{
done = QApplication : : notify ( receiver , event ) ;
}
catch ( const std : : bad_alloc & )
{
if ( memoryExhaustedBox ) memoryExhaustedBox - > exec ( ) ;
std : : cout < < " ResInsight: Memory is Exhausted! \n ResInsight could not allocate the memory needed, and is now unstable and will probably crash soon. " < < std : : endl ;
// If we really want to crash instead of limping forward:
// throw;
}
return done ;
}
2013-10-08 07:28:01 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaApplication : : RiaApplication ( int & argc , char * * argv )
: QApplication ( argc , argv )
{
// USed to get registry settings in the right place
QCoreApplication : : setOrganizationName ( RI_COMPANY_NAME ) ;
QCoreApplication : : setApplicationName ( RI_APPLICATION_NAME ) ;
// For idle processing
// m_idleTimerStarted = false;
installEventFilter ( this ) ;
//cvf::Trace::enable(false);
m_preferences = new RiaPreferences ;
2015-10-23 08:46:25 -05:00
caf : : PdmSettings : : readFieldsFromApplicationStore ( m_preferences ) ;
2013-10-08 07:28:01 -05:00
applyPreferences ( ) ;
if ( useShaders ( ) )
{
caf : : EffectGenerator : : setRenderingMode ( caf : : EffectGenerator : : SHADER_BASED ) ;
}
else
{
caf : : EffectGenerator : : setRenderingMode ( caf : : EffectGenerator : : FIXED_FUNCTION ) ;
}
// Start with a project
m_project = new RimProject ;
setWindowIcon ( QIcon ( " :/AppLogo48x48.png " ) ) ;
m_socketServer = new RiaSocketServer ( this ) ;
2018-02-18 11:56:43 -06:00
m_workerProcess = nullptr ;
2013-10-08 07:28:01 -05:00
# ifdef WIN32
m_startupDefaultDirectory = QDir : : homePath ( ) ;
# else
m_startupDefaultDirectory = QDir : : currentPath ( ) ;
# endif
2016-09-21 02:46:17 -05:00
setLastUsedDialogDirectory ( " MULTICASEIMPORT " , " / " ) ;
2013-10-08 07:28:01 -05:00
// The creation of a font is time consuming, so make sure you really need your own font
// instead of using the application font
2016-08-09 06:09:08 -05:00
m_standardFont = new caf : : FixedAtlasFont ( caf : : FixedAtlasFont : : POINT_SIZE_8 ) ;
2017-07-31 04:10:22 -05:00
m_runningWorkerProcess = false ;
2017-06-20 09:15:47 -05:00
m_mainPlotWindow = nullptr ;
2016-10-05 01:23:07 -05:00
m_recentFileActionProvider = std : : unique_ptr < RiuRecentFileActionProvider > ( new RiuRecentFileActionProvider ) ;
2013-10-08 07:28:01 -05:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaApplication : : ~ RiaApplication ( )
{
2018-04-26 13:05:42 -05:00
RiuDockWidgetTools : : instance ( ) - > saveDockWidgetsState ( ) ;
2016-06-27 08:27:18 -05:00
deleteMainPlotWindow ( ) ;
2013-10-08 07:28:01 -05:00
delete m_preferences ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaApplication * RiaApplication : : instance ( )
{
return static_cast < RiaApplication * > qApp ;
}
2015-12-03 03:33:38 -06:00
//--------------------------------------------------------------------------------------------------
/// Return -1 if unit test is not executed, returns 0 if test passed, returns 1 if tests failed
//--------------------------------------------------------------------------------------------------
int RiaApplication : : parseArgumentsAndRunUnitTestsIfRequested ( )
{
cvf : : ProgramOptions progOpt ;
progOpt . registerOption ( " unittest " , " " , " Execute unit tests " ) ;
progOpt . setOptionPrefix ( cvf : : ProgramOptions : : DOUBLE_DASH ) ;
QStringList arguments = QCoreApplication : : arguments ( ) ;
bool parseOk = progOpt . parse ( cvfqt : : Utils : : toStringVector ( arguments ) ) ;
if ( ! parseOk )
{
return - 1 ;
}
// Unit testing
// --------------------------------------------------------
if ( cvf : : Option o = progOpt . option ( " unittest " ) )
{
int testReturnValue = launchUnitTestsWithConsole ( ) ;
return testReturnValue ;
}
return - 1 ;
}
2013-10-08 07:28:01 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication : : setWindowCaptionFromAppState ( )
{
RiuMainWindow * mainWnd = RiuMainWindow : : instance ( ) ;
if ( ! mainWnd ) return ;
// The stuff being done here should really be handled by Qt automatically as a result of
// setting applicationName and windowFilePath
// Was unable to make this work in Qt4.4.0!
QString capt = RI_APPLICATION_NAME ;
# ifdef _DEBUG
capt + = " ##DEBUG## " ;
# endif
{
QString projFileName = m_project - > fileName ( ) ;
if ( projFileName . isEmpty ( ) ) projFileName = " Untitled project " ;
capt = projFileName + QString ( " [*] " ) + QString ( " - " ) + capt ;
}
mainWnd - > setWindowTitle ( capt ) ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication : : processNonGuiEvents ( )
{
processEvents ( QEventLoop : : ExcludeUserInputEvents ) ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const char * RiaApplication : : getVersionStringApp ( bool includeCrtInfo )
{
// Use static buf so we can return ptr
static char szBuf [ 1024 ] ;
cvf : : String crtInfo ;
if ( includeCrtInfo )
{
# ifdef _MT
# ifdef _DLL
crtInfo = " (DLL CRT) " ;
# else
crtInfo = " (static CRT) " ;
# endif
# endif //_MT
}
cvf : : System : : sprintf ( szBuf , 1024 , " %s%s " , STRPRODUCTVER , crtInfo . toAscii ( ) . ptr ( ) ) ;
return szBuf ;
}
2013-12-04 05:04:42 -06:00
2013-10-08 07:28:01 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2013-12-04 05:04:42 -06:00
bool RiaApplication : : loadProject ( const QString & projectFileName , ProjectLoadAction loadAction , RiaProjectModifier * projectModifier )
2013-10-08 07:28:01 -05:00
{
// First Close the current project
2016-10-04 04:02:56 -05:00
closeProject ( ) ;
2013-10-08 07:28:01 -05:00
2017-02-27 06:17:32 -06:00
RiaLogging : : info ( QString ( " Starting to open project file : '%1' " ) . arg ( projectFileName ) ) ;
2017-02-23 07:24:18 -06:00
2018-03-06 04:27:08 -06:00
// Create a absolute path file name, as this is required for update of file references in the project modifier object
QString fullPathProjectFileName = caf : : Utils : : absoluteFileName ( projectFileName ) ;
if ( ! caf : : Utils : : fileExists ( fullPathProjectFileName ) )
2017-02-23 07:24:18 -06:00
{
2018-03-06 04:27:08 -06:00
RiaLogging : : info ( QString ( " File does not exist : '%1' " ) . arg ( fullPathProjectFileName ) ) ;
2017-02-23 07:24:18 -06:00
return false ;
}
2013-10-08 07:28:01 -05:00
2018-03-06 04:27:08 -06:00
m_project - > fileName = fullPathProjectFileName ;
2013-10-08 07:28:01 -05:00
m_project - > readFile ( ) ;
2016-10-04 07:23:34 -05:00
// Apply any modifications to the loaded project before we go ahead and load actual data
2013-12-04 05:04:42 -06:00
if ( projectModifier )
{
projectModifier - > applyModificationsToProject ( m_project ) ;
}
2013-10-08 07:28:01 -05:00
// Propagate possible new location of project
2018-03-06 04:27:08 -06:00
m_project - > setProjectFileNameAndUpdateDependencies ( fullPathProjectFileName ) ;
2013-10-08 07:28:01 -05:00
// On error, delete everything, and bail out.
if ( m_project - > projectFileVersionString ( ) . isEmpty ( ) )
{
2016-10-04 04:02:56 -05:00
closeProject ( ) ;
2013-10-08 07:28:01 -05:00
2018-03-06 04:27:08 -06:00
QString tmp = QString ( " Unknown project file version detected in file \n %1 \n \n Could not open project. " ) . arg ( fullPathProjectFileName ) ;
2018-02-18 11:56:43 -06:00
QMessageBox : : warning ( nullptr , " Error when opening project file " , tmp ) ;
2013-10-08 07:28:01 -05:00
RiuMainWindow * mainWnd = RiuMainWindow : : instance ( ) ;
2018-02-18 11:56:43 -06:00
mainWnd - > setPdmRoot ( nullptr ) ;
2013-10-08 07:28:01 -05:00
// Delete all object possibly generated by readFile()
delete m_project ;
m_project = new RimProject ;
onProjectOpenedOrClosed ( ) ;
return true ;
}
2016-10-04 07:23:34 -05:00
if ( m_project - > show3DWindow ( ) )
{
RiuMainWindow : : instance ( ) - > show ( ) ;
}
else
{
2016-10-06 08:01:27 -05:00
RiuMainWindow : : instance ( ) - > hide ( ) ;
2016-10-04 07:23:34 -05:00
}
if ( m_project - > showPlotWindow ( ) )
{
2016-11-10 02:26:53 -06:00
if ( ! m_mainPlotWindow )
{
createMainPlotWindow ( ) ;
2018-06-29 04:36:50 -05:00
m_mainPlotWindow - > show ( ) ;
2016-11-10 02:26:53 -06:00
}
else
{
m_mainPlotWindow - > show ( ) ;
m_mainPlotWindow - > raise ( ) ;
}
2016-10-04 07:23:34 -05:00
}
else if ( mainPlotWindow ( ) )
{
2016-10-06 08:01:27 -05:00
mainPlotWindow ( ) - > hide ( ) ;
2016-10-04 07:23:34 -05:00
}
2013-10-08 07:28:01 -05:00
///////
// Load the external data, and initialize stuff that needs specific ordering
// VL check regarding specific order mentioned in comment above...
2018-03-06 04:27:08 -06:00
m_preferences - > lastUsedProjectFileName = fullPathProjectFileName ;
2015-08-04 04:47:06 -05:00
caf : : PdmSettings : : writeFieldsToApplicationStore ( m_preferences ) ;
2013-10-08 07:28:01 -05:00
for ( size_t oilFieldIdx = 0 ; oilFieldIdx < m_project - > oilFields ( ) . size ( ) ; oilFieldIdx + + )
{
RimOilField * oilField = m_project - > oilFields [ oilFieldIdx ] ;
2018-02-18 11:56:43 -06:00
RimEclipseCaseCollection * analysisModels = oilField ? oilField - > analysisModels ( ) : nullptr ;
if ( analysisModels = = nullptr ) continue ;
2013-10-08 07:28:01 -05:00
for ( size_t cgIdx = 0 ; cgIdx < analysisModels - > caseGroups . size ( ) ; + + cgIdx )
{
// Load the Main case of each IdenticalGridCaseGroup
RimIdenticalGridCaseGroup * igcg = analysisModels - > caseGroups [ cgIdx ] ;
igcg - > loadMainCaseAndActiveCellInfo ( ) ; // VL is this supposed to be done for each RimOilField?
}
}
2016-08-24 01:30:12 -05:00
// Load the formation names
for ( RimOilField * oilField : m_project - > oilFields )
{
2018-02-18 11:56:43 -06:00
if ( oilField = = nullptr ) continue ;
if ( oilField - > formationNamesCollection ( ) ! = nullptr )
2016-08-24 01:30:12 -05:00
{
oilField - > formationNamesCollection ( ) - > readAllFormationNames ( ) ;
}
}
2013-10-08 07:28:01 -05:00
// Add well paths for each oil field
for ( size_t oilFieldIdx = 0 ; oilFieldIdx < m_project - > oilFields ( ) . size ( ) ; oilFieldIdx + + )
{
RimOilField * oilField = m_project - > oilFields [ oilFieldIdx ] ;
2018-02-18 11:56:43 -06:00
if ( oilField = = nullptr ) continue ;
if ( oilField - > wellPathCollection = = nullptr )
2013-10-08 07:28:01 -05:00
{
//printf("Create well path collection for oil field %i in loadProject.\n", oilFieldIdx);
oilField - > wellPathCollection = new RimWellPathCollection ( ) ;
}
2017-11-24 03:01:05 -06:00
if ( oilField - > wellPathCollection )
{
2018-07-02 09:55:32 -05:00
oilField - > wellPathCollection - > loadDataAndUpdate ( ) ;
2017-11-24 03:01:05 -06:00
oilField - > wellPathCollection - > readWellPathFormationFiles ( ) ;
}
2013-10-08 07:28:01 -05:00
}
2016-05-31 06:42:27 -05:00
for ( RimOilField * oilField : m_project - > oilFields )
{
2018-02-18 11:56:43 -06:00
if ( oilField = = nullptr ) continue ;
2016-05-31 06:42:27 -05:00
// Temporary
2017-09-06 09:32:46 -05:00
if ( ! oilField - > summaryCaseMainCollection ( ) )
2016-05-31 06:42:27 -05:00
{
2017-09-06 09:32:46 -05:00
oilField - > summaryCaseMainCollection = new RimSummaryCaseMainCollection ( ) ;
2016-05-31 06:42:27 -05:00
}
2017-09-06 09:32:46 -05:00
oilField - > summaryCaseMainCollection ( ) - > loadAllSummaryCaseData ( ) ;
2017-02-17 02:29:46 -06:00
2017-09-14 08:44:01 -05:00
if ( ! oilField - > observedDataCollection ( ) )
{
oilField - > observedDataCollection = new RimObservedDataCollection ( ) ;
}
2017-09-22 07:26:54 -05:00
for ( auto observedCases : oilField - > observedDataCollection ( ) - > allObservedData ( ) )
{
observedCases - > createSummaryReaderInterface ( ) ;
2017-10-03 08:31:45 -05:00
RimObservedData * rimObservedData = dynamic_cast < RimObservedData * > ( observedCases ) ;
if ( rimObservedData )
{
rimObservedData - > updateMetaData ( ) ;
}
2017-09-22 07:26:54 -05:00
}
2018-02-01 08:37:05 -06:00
2017-02-17 02:29:46 -06:00
oilField - > fractureDefinitionCollection ( ) - > loadAndUpdateData ( ) ;
2018-02-27 05:05:37 -06:00
oilField - > fractureDefinitionCollection ( ) - > createAndAssignTemplateCopyForNonMatchingUnit ( ) ;
2017-08-14 15:16:03 -05:00
{
std : : vector < RimWellPathFracture * > wellPathFractures ;
oilField - > wellPathCollection - > descendantsIncludingThisOfType ( wellPathFractures ) ;
for ( auto fracture : wellPathFractures )
{
fracture - > loadDataAndUpdate ( ) ;
}
}
2016-05-31 06:42:27 -05:00
}
2013-12-04 05:04:42 -06:00
// If load action is specified to recalculate statistics, do it now.
// Apparently this needs to be done before the views are loaded, lest the number of time steps for statistics will be clamped
if ( loadAction & PLA_CALCULATE_STATISTICS )
{
for ( size_t oilFieldIdx = 0 ; oilFieldIdx < m_project - > oilFields ( ) . size ( ) ; oilFieldIdx + + )
{
RimOilField * oilField = m_project - > oilFields [ oilFieldIdx ] ;
2018-02-18 11:56:43 -06:00
RimEclipseCaseCollection * analysisModels = oilField ? oilField - > analysisModels ( ) : nullptr ;
2013-12-04 05:04:42 -06:00
if ( analysisModels )
{
analysisModels - > recomputeStatisticsForAllCaseGroups ( ) ;
}
}
}
2018-02-01 08:37:05 -06:00
2013-10-08 07:28:01 -05:00
// Now load the ReservoirViews for the cases
// Add all "native" cases in the project
2015-05-15 11:51:49 -05:00
std : : vector < RimCase * > casesToLoad ;
2013-10-08 07:28:01 -05:00
m_project - > allCases ( casesToLoad ) ;
{
2015-09-28 01:21:51 -05:00
caf : : ProgressInfo caseProgress ( casesToLoad . size ( ) , " Reading Cases " ) ;
2013-10-08 07:28:01 -05:00
2015-09-28 01:21:51 -05:00
for ( size_t cIdx = 0 ; cIdx < casesToLoad . size ( ) ; + + cIdx )
2013-10-08 07:28:01 -05:00
{
2015-09-28 01:21:51 -05:00
RimCase * cas = casesToLoad [ cIdx ] ;
CVF_ASSERT ( cas ) ;
2013-10-08 07:28:01 -05:00
2015-09-28 01:21:51 -05:00
caseProgress . setProgressDescription ( cas - > caseUserDescription ( ) ) ;
2018-01-09 03:11:28 -06:00
std : : vector < Rim3dView * > views = cas - > views ( ) ;
2017-12-08 09:38:58 -06:00
{ // To delete the view progress before incrementing the caseProgress
caf : : ProgressInfo viewProgress ( views . size ( ) , " Creating Views " ) ;
2013-10-08 07:28:01 -05:00
2017-12-08 09:38:58 -06:00
size_t j ;
for ( j = 0 ; j < views . size ( ) ; j + + )
{
2018-01-09 03:11:28 -06:00
Rim3dView * riv = views [ j ] ;
2017-12-08 09:38:58 -06:00
CVF_ASSERT ( riv ) ;
2013-10-08 07:28:01 -05:00
2017-12-08 09:38:58 -06:00
viewProgress . setProgressDescription ( riv - > name ( ) ) ;
2015-09-28 01:21:51 -05:00
2018-02-01 08:37:05 -06:00
if ( m_project - > isProjectFileVersionEqualOrOlderThan ( " 2018.1.0.103 " ) )
{
std : : vector < RimStimPlanColors * > stimPlanColors ;
riv - > descendantsIncludingThisOfType ( stimPlanColors ) ;
if ( stimPlanColors . size ( ) = = 1 )
{
stimPlanColors [ 0 ] - > updateConductivityResultName ( ) ;
}
}
2018-05-18 14:38:49 -05:00
riv - > loadDataAndUpdate ( ) ;
2018-02-01 08:37:05 -06:00
2018-05-18 14:38:49 -05:00
if ( m_project - > isProjectFileVersionEqualOrOlderThan ( " 2018.1.1.110 " ) )
2018-05-18 12:23:36 -05:00
{
2018-05-18 14:38:49 -05:00
auto * geoView = dynamic_cast < RimGeoMechView * > ( riv ) ;
if ( geoView )
{
geoView - > convertCameraPositionFromOldProjectFiles ( ) ;
}
2018-05-18 12:23:36 -05:00
}
2017-12-08 09:38:58 -06:00
this - > setActiveReservoirView ( riv ) ;
2015-10-28 06:23:24 -05:00
2018-01-15 07:52:22 -06:00
RimGridView * rigv = dynamic_cast < RimGridView * > ( riv ) ;
if ( rigv ) rigv - > rangeFilterCollection ( ) - > updateIconState ( ) ;
2015-10-28 06:23:24 -05:00
2017-12-08 09:38:58 -06:00
viewProgress . incrementProgress ( ) ;
}
2015-09-28 01:21:51 -05:00
}
caseProgress . incrementProgress ( ) ;
}
2013-10-08 07:28:01 -05:00
}
2015-10-22 09:02:28 -05:00
2015-10-22 09:46:58 -05:00
if ( m_project - > viewLinkerCollection ( ) & & m_project - > viewLinkerCollection ( ) - > viewLinker ( ) )
2015-10-22 09:02:28 -05:00
{
m_project - > viewLinkerCollection ( ) - > viewLinker ( ) - > updateOverrides ( ) ;
}
2018-01-23 07:23:28 -06:00
// Intersection Views: Sync from intersections in the case.
for ( RimCase * cas : casesToLoad )
{
cas - > intersectionViewCollection ( ) - > syncFromExistingIntersections ( false ) ;
}
2018-06-25 08:14:47 -05:00
// Init summary case groups
for ( RimOilField * oilField : m_project - > oilFields )
{
auto sumMainCollection = oilField - > summaryCaseMainCollection ( ) ;
if ( ! sumMainCollection ) continue ;
for ( auto sumCaseGroup : sumMainCollection - > summaryCaseCollections ( ) )
{
sumCaseGroup - > loadDataAndUpdate ( ) ;
}
2018-11-27 10:53:56 -06:00
oilField - > annotationCollection ( ) - > loadDataAndUpdate ( ) ;
2018-06-25 08:14:47 -05:00
}
2015-10-22 09:02:28 -05:00
2016-10-05 03:04:41 -05:00
loadAndUpdatePlotData ( ) ;
2013-10-08 07:28:01 -05:00
// NB! This function must be called before executing command objects,
// because the tree view state is restored from project file and sets
// current active view ( see restoreTreeViewState() )
// Default behavior for scripts is to use current active view for data read/write
onProjectOpenedOrClosed ( ) ;
processEvents ( ) ;
// Loop over command objects and execute them
for ( size_t i = 0 ; i < m_project - > commandObjects . size ( ) ; i + + )
{
m_commandQueue . push_back ( m_project - > commandObjects [ i ] ) ;
}
// Lock the command queue
m_commandQueueLock . lock ( ) ;
// Execute command objects, and release the mutex when the queue is empty
executeCommandObjects ( ) ;
2017-02-27 06:17:32 -06:00
RiaLogging : : info ( QString ( " Completed open of project file : '%1' " ) . arg ( projectFileName ) ) ;
2017-02-23 07:24:18 -06:00
2013-10-08 07:28:01 -05:00
return true ;
}
2013-12-04 05:04:42 -06:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaApplication : : loadProject ( const QString & projectFileName )
{
2018-02-18 11:56:43 -06:00
return loadProject ( projectFileName , PLA_NONE , nullptr ) ;
2013-12-04 05:04:42 -06:00
}
2016-10-05 03:04:41 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication : : loadAndUpdatePlotData ( )
{
RimWellLogPlotCollection * wlpColl = nullptr ;
RimSummaryPlotCollection * spColl = nullptr ;
2017-11-07 13:40:45 -06:00
RimSummaryCrossPlotCollection * scpColl = nullptr ;
2017-01-13 06:32:02 -06:00
RimFlowPlotCollection * flowColl = nullptr ;
2017-10-03 01:19:38 -05:00
RimRftPlotCollection * rftColl = nullptr ;
2017-10-23 06:57:01 -05:00
RimPltPlotCollection * pltColl = nullptr ;
2016-10-05 03:04:41 -05:00
if ( m_project - > mainPlotCollection ( ) & & m_project - > mainPlotCollection ( ) - > wellLogPlotCollection ( ) )
{
wlpColl = m_project - > mainPlotCollection ( ) - > wellLogPlotCollection ( ) ;
}
if ( m_project - > mainPlotCollection ( ) & & m_project - > mainPlotCollection ( ) - > summaryPlotCollection ( ) )
{
spColl = m_project - > mainPlotCollection ( ) - > summaryPlotCollection ( ) ;
}
2017-11-07 13:40:45 -06:00
if ( m_project - > mainPlotCollection ( ) & & m_project - > mainPlotCollection ( ) - > summaryCrossPlotCollection ( ) )
{
scpColl = m_project - > mainPlotCollection ( ) - > summaryCrossPlotCollection ( ) ;
}
2017-01-13 06:32:02 -06:00
if ( m_project - > mainPlotCollection ( ) & & m_project - > mainPlotCollection ( ) - > flowPlotCollection ( ) )
{
flowColl = m_project - > mainPlotCollection ( ) - > flowPlotCollection ( ) ;
}
2017-10-03 01:19:38 -05:00
if ( m_project - > mainPlotCollection ( ) & & m_project - > mainPlotCollection ( ) - > rftPlotCollection ( ) )
{
rftColl = m_project - > mainPlotCollection ( ) - > rftPlotCollection ( ) ;
}
2017-10-23 06:57:01 -05:00
if ( m_project - > mainPlotCollection ( ) & & m_project - > mainPlotCollection ( ) - > pltPlotCollection ( ) )
{
pltColl = m_project - > mainPlotCollection ( ) - > pltPlotCollection ( ) ;
}
2017-01-13 06:32:02 -06:00
2016-10-05 03:04:41 -05:00
size_t plotCount = 0 ;
plotCount + = wlpColl ? wlpColl - > wellLogPlots ( ) . size ( ) : 0 ;
2017-01-13 02:51:37 -06:00
plotCount + = spColl ? spColl - > summaryPlots ( ) . size ( ) : 0 ;
2017-11-07 13:40:45 -06:00
plotCount + = scpColl ? scpColl - > summaryPlots ( ) . size ( ) : 0 ;
2017-02-13 07:49:52 -06:00
plotCount + = flowColl ? flowColl - > plotCount ( ) : 0 ;
2017-10-03 01:19:38 -05:00
plotCount + = rftColl ? rftColl - > rftPlots ( ) . size ( ) : 0 ;
2017-10-23 06:57:01 -05:00
plotCount + = pltColl ? pltColl - > pltPlots ( ) . size ( ) : 0 ;
2016-10-05 03:04:41 -05:00
caf : : ProgressInfo plotProgress ( plotCount , " Loading Plot Data " ) ;
if ( wlpColl )
{
for ( size_t wlpIdx = 0 ; wlpIdx < wlpColl - > wellLogPlots ( ) . size ( ) ; + + wlpIdx )
{
wlpColl - > wellLogPlots [ wlpIdx ] - > loadDataAndUpdate ( ) ;
plotProgress . incrementProgress ( ) ;
}
}
if ( spColl )
{
2017-01-13 02:51:37 -06:00
for ( size_t wlpIdx = 0 ; wlpIdx < spColl - > summaryPlots ( ) . size ( ) ; + + wlpIdx )
2016-10-05 03:04:41 -05:00
{
2017-01-13 02:51:37 -06:00
spColl - > summaryPlots [ wlpIdx ] - > loadDataAndUpdate ( ) ;
2016-10-05 03:04:41 -05:00
plotProgress . incrementProgress ( ) ;
}
}
2017-02-13 07:49:52 -06:00
2017-11-14 07:01:19 -06:00
if ( scpColl )
{
for ( auto plot : scpColl - > summaryPlots ( ) )
{
plot - > loadDataAndUpdate ( ) ;
plotProgress . incrementProgress ( ) ;
}
}
2017-01-13 06:32:02 -06:00
if ( flowColl )
{
2017-02-24 09:00:56 -06:00
plotProgress . setNextProgressIncrement ( flowColl - > plotCount ( ) ) ;
2017-03-07 05:19:54 -06:00
flowColl - > loadDataAndUpdate ( ) ;
plotProgress . incrementProgress ( ) ;
2017-01-13 06:32:02 -06:00
}
2017-10-03 01:19:38 -05:00
if ( rftColl )
{
for ( const auto & rftPlot : rftColl - > rftPlots ( ) )
{
rftPlot - > loadDataAndUpdate ( ) ;
plotProgress . incrementProgress ( ) ;
2017-10-23 06:57:01 -05:00
}
}
if ( pltColl )
{
for ( const auto & pltPlot : pltColl - > pltPlots ( ) )
{
pltPlot - > loadDataAndUpdate ( ) ;
plotProgress . incrementProgress ( ) ;
2017-10-03 01:19:38 -05:00
}
}
2016-10-05 03:04:41 -05:00
}
2013-12-04 05:04:42 -06:00
2017-04-20 04:02:05 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication : : storeTreeViewState ( )
{
{
if ( mainPlotWindow ( ) & & mainPlotWindow ( ) - > projectTreeView ( ) )
{
caf : : PdmUiTreeView * projectTreeView = mainPlotWindow ( ) - > projectTreeView ( ) ;
QString treeViewState ;
2017-09-06 06:06:37 -05:00
caf : : QTreeViewStateSerializer : : storeTreeViewStateToString ( projectTreeView - > treeView ( ) , treeViewState ) ;
2017-04-20 04:02:05 -05:00
QModelIndex mi = projectTreeView - > treeView ( ) - > currentIndex ( ) ;
QString encodedModelIndexString ;
2017-09-06 06:06:37 -05:00
caf : : QTreeViewStateSerializer : : encodeStringFromModelIndex ( mi , encodedModelIndexString ) ;
2017-04-20 04:02:05 -05:00
project ( ) - > plotWindowTreeViewState = treeViewState ;
project ( ) - > plotWindowCurrentModelIndexPath = encodedModelIndexString ;
}
}
{
caf : : PdmUiTreeView * projectTreeView = RiuMainWindow : : instance ( ) - > projectTreeView ( ) ;
if ( projectTreeView )
{
QString treeViewState ;
2017-09-06 06:06:37 -05:00
caf : : QTreeViewStateSerializer : : storeTreeViewStateToString ( projectTreeView - > treeView ( ) , treeViewState ) ;
2017-04-20 04:02:05 -05:00
QModelIndex mi = projectTreeView - > treeView ( ) - > currentIndex ( ) ;
QString encodedModelIndexString ;
2017-09-06 06:06:37 -05:00
caf : : QTreeViewStateSerializer : : encodeStringFromModelIndex ( mi , encodedModelIndexString ) ;
2017-04-20 04:02:05 -05:00
project ( ) - > mainWindowTreeViewState = treeViewState ;
project ( ) - > mainWindowCurrentModelIndexPath = encodedModelIndexString ;
}
}
}
2013-10-08 07:28:01 -05:00
//--------------------------------------------------------------------------------------------------
/// Add a list of well path file paths (JSON files) to the well path collection
//--------------------------------------------------------------------------------------------------
void RiaApplication : : addWellPathsToModel ( QList < QString > wellPathFilePaths )
{
2018-02-18 11:56:43 -06:00
if ( m_project = = nullptr | | m_project - > oilFields . size ( ) < 1 ) return ;
2013-10-08 07:28:01 -05:00
RimOilField * oilField = m_project - > activeOilField ( ) ;
2018-02-18 11:56:43 -06:00
if ( oilField = = nullptr ) return ;
2013-10-08 07:28:01 -05:00
2018-02-18 11:56:43 -06:00
if ( oilField - > wellPathCollection = = nullptr )
2013-10-08 07:28:01 -05:00
{
//printf("Create well path collection.\n");
oilField - > wellPathCollection = new RimWellPathCollection ( ) ;
2015-08-12 10:46:22 -05:00
m_project - > updateConnectedEditors ( ) ;
2013-10-08 07:28:01 -05:00
}
if ( oilField - > wellPathCollection ) oilField - > wellPathCollection - > addWellPaths ( wellPathFilePaths ) ;
2015-08-12 10:46:22 -05:00
oilField - > wellPathCollection - > updateConnectedEditors ( ) ;
2013-10-08 07:28:01 -05:00
}
2017-11-24 03:01:05 -06:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication : : addWellPathFormationsToModel ( QList < QString > wellPathFormationsFilePaths )
{
if ( m_project = = nullptr | | m_project - > oilFields . size ( ) < 1 ) return ;
RimOilField * oilField = m_project - > activeOilField ( ) ;
if ( oilField = = nullptr ) return ;
if ( oilField - > wellPathCollection = = nullptr )
{
oilField - > wellPathCollection = new RimWellPathCollection ( ) ;
m_project - > updateConnectedEditors ( ) ;
}
2017-11-27 03:33:41 -06:00
if ( oilField - > wellPathCollection )
{
oilField - > wellPathCollection - > addWellPathFormations ( wellPathFormationsFilePaths ) ;
}
2017-11-24 03:01:05 -06:00
oilField - > wellPathCollection - > updateConnectedEditors ( ) ;
}
2015-09-14 09:33:28 -05:00
//--------------------------------------------------------------------------------------------------
/// Add a list of well log file paths (LAS files) to the well path collection
//--------------------------------------------------------------------------------------------------
void RiaApplication : : addWellLogsToModel ( const QList < QString > & wellLogFilePaths )
{
2017-10-20 07:05:42 -05:00
if ( m_project = = nullptr | | m_project - > oilFields . size ( ) < 1 ) return ;
2015-09-14 09:33:28 -05:00
RimOilField * oilField = m_project - > activeOilField ( ) ;
2017-10-20 07:05:42 -05:00
if ( oilField = = nullptr ) return ;
2015-09-14 09:33:28 -05:00
2017-10-20 07:05:42 -05:00
if ( oilField - > wellPathCollection = = nullptr )
2015-09-14 09:33:28 -05:00
{
oilField - > wellPathCollection = new RimWellPathCollection ( ) ;
m_project - > updateConnectedEditors ( ) ;
}
2017-10-20 07:05:42 -05:00
RimWellLogFile * wellLogFile = oilField - > wellPathCollection - > addWellLogs ( wellLogFilePaths ) ;
2015-09-14 09:33:28 -05:00
oilField - > wellPathCollection - > updateConnectedEditors ( ) ;
2017-10-20 07:05:42 -05:00
RiuMainWindow : : instance ( ) - > selectAsCurrentItem ( wellLogFile ) ;
2015-09-14 09:33:28 -05:00
}
2013-10-08 07:28:01 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaApplication : : saveProject ( )
{
CVF_ASSERT ( m_project . notNull ( ) ) ;
2017-05-11 02:23:13 -05:00
if ( ! caf : : Utils : : fileExists ( m_project - > fileName ( ) ) )
2013-10-08 07:28:01 -05:00
{
return saveProjectPromptForFileName ( ) ;
}
else
{
return saveProjectAs ( m_project - > fileName ( ) ) ;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaApplication : : saveProjectPromptForFileName ( )
{
//if (m_project.isNull()) return true;
RiaApplication * app = RiaApplication : : instance ( ) ;
QString startPath ;
if ( ! m_project - > fileName ( ) . isEmpty ( ) )
{
2015-09-18 11:48:29 -05:00
startPath = m_project - > fileName ( ) ;
2013-10-08 07:28:01 -05:00
}
else
{
2016-09-21 02:46:17 -05:00
startPath = app - > lastUsedDialogDirectory ( " BINARY_GRID " ) ;
2015-09-18 11:48:29 -05:00
startPath + = " /ResInsightProject.rsp " ;
2013-10-08 07:28:01 -05:00
}
2018-02-18 11:56:43 -06:00
QString fileName = QFileDialog : : getSaveFileName ( nullptr , tr ( " Save File " ) , startPath , tr ( " Project Files (*.rsp);;All files(*.*) " ) ) ;
2013-10-08 07:28:01 -05:00
if ( fileName . isEmpty ( ) )
{
return false ;
}
// Remember the directory to next time
2016-09-21 02:46:17 -05:00
app - > setLastUsedDialogDirectory ( " BINARY_GRID " , QFileInfo ( fileName ) . absolutePath ( ) ) ;
2013-10-08 07:28:01 -05:00
bool bSaveOk = saveProjectAs ( fileName ) ;
setWindowCaptionFromAppState ( ) ;
return bSaveOk ;
}
2017-04-20 01:07:47 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaApplication : : hasValidProjectFileExtension ( const QString & fileName )
{
if ( fileName . contains ( " .rsp " , Qt : : CaseInsensitive ) | | fileName . contains ( " .rip " , Qt : : CaseInsensitive ) )
{
return true ;
}
return false ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaApplication : : askUserToSaveModifiedProject ( )
{
if ( caf : : PdmUiModelChangeDetector : : instance ( ) - > isModelChanged ( ) )
{
QMessageBox msgBox ;
msgBox . setIcon ( QMessageBox : : Question ) ;
QString questionText ;
questionText = QString ( " The current project is modified. \n \n Do you want to save the changes? " ) ;
msgBox . setText ( questionText ) ;
msgBox . setStandardButtons ( QMessageBox : : Yes | QMessageBox : : No | QMessageBox : : Cancel ) ;
int ret = msgBox . exec ( ) ;
if ( ret = = QMessageBox : : Cancel )
{
return false ;
}
else if ( ret = = QMessageBox : : Yes )
{
if ( ! saveProject ( ) )
{
return false ;
}
}
else
{
caf : : PdmUiModelChangeDetector : : instance ( ) - > reset ( ) ;
}
}
return true ;
}
2013-10-08 07:28:01 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaApplication : : saveProjectAs ( const QString & fileName )
{
2018-04-20 03:03:07 -05:00
// Make sure we always store path with forward slash to avoid issues when opening the project file on Linux
m_project - > fileName = RiaFilePathTools : : toInternalSeparator ( fileName ) ;
2015-11-20 03:50:23 -06:00
2017-04-20 04:02:05 -05:00
storeTreeViewState ( ) ;
2015-11-20 03:50:23 -06:00
if ( ! m_project - > writeFile ( ) )
{
2018-02-18 11:56:43 -06:00
QMessageBox : : warning ( nullptr , " Error when saving project file " , QString ( " Not possible to save project file. Make sure you have sufficient access rights. \n \n Project file location : %1 " ) . arg ( fileName ) ) ;
2015-11-20 03:50:23 -06:00
return false ;
}
2013-10-08 07:28:01 -05:00
m_preferences - > lastUsedProjectFileName = fileName ;
2015-10-23 08:46:25 -05:00
caf : : PdmSettings : : writeFieldsToApplicationStore ( m_preferences ) ;
2013-10-08 07:28:01 -05:00
2016-10-05 01:23:07 -05:00
m_recentFileActionProvider - > addFileName ( fileName ) ;
2015-11-20 03:50:23 -06:00
2017-04-20 01:07:47 -05:00
caf : : PdmUiModelChangeDetector : : instance ( ) - > reset ( ) ;
2013-10-08 07:28:01 -05:00
return true ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2016-10-04 04:02:56 -05:00
void RiaApplication : : closeProject ( )
2013-10-08 07:28:01 -05:00
{
2018-10-25 08:34:21 -05:00
RicHoloLensSessionManager : : instance ( ) - > terminateSession ( ) ;
RicHoloLensSessionManager : : refreshToolbarState ( ) ;
2018-10-22 04:09:52 -05:00
2013-10-08 07:28:01 -05:00
RiuMainWindow * mainWnd = RiuMainWindow : : instance ( ) ;
2018-01-12 04:31:01 -06:00
RiaViewRedrawScheduler : : instance ( ) - > clearViewsScheduledForUpdate ( ) ;
2015-10-23 07:13:14 -05:00
2013-10-08 07:28:01 -05:00
terminateProcess ( ) ;
2018-10-30 08:02:22 -05:00
RiaApplication : : clearAllSelections ( ) ;
2015-11-09 12:05:00 -06:00
2013-10-08 07:28:01 -05:00
mainWnd - > cleanupGuiBeforeProjectClose ( ) ;
2016-06-27 04:07:01 -05:00
if ( m_mainPlotWindow )
{
m_mainPlotWindow - > cleanupGuiBeforeProjectClose ( ) ;
}
2016-06-24 08:10:18 -05:00
2013-10-08 07:28:01 -05:00
caf : : EffectGenerator : : clearEffectCache ( ) ;
m_project - > close ( ) ;
m_commandQueue . clear ( ) ;
onProjectOpenedOrClosed ( ) ;
2015-10-28 09:30:20 -05:00
// Make sure all project windows are closed down properly before returning
processEvents ( ) ;
2013-10-08 07:28:01 -05:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication : : onProjectOpenedOrClosed ( )
{
RiuMainWindow * mainWnd = RiuMainWindow : : instance ( ) ;
2016-06-24 08:53:04 -05:00
if ( mainWnd )
{
mainWnd - > initializeGuiNewProjectLoaded ( ) ;
}
2016-06-27 04:07:01 -05:00
if ( m_mainPlotWindow )
2016-06-24 08:53:04 -05:00
{
2016-06-27 04:07:01 -05:00
m_mainPlotWindow - > initializeGuiNewProjectLoaded ( ) ;
2016-06-24 08:53:04 -05:00
}
2013-10-08 07:28:01 -05:00
setWindowCaptionFromAppState ( ) ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2016-09-21 02:46:17 -05:00
QString RiaApplication : : currentProjectPath ( ) const
2013-10-08 07:28:01 -05:00
{
2016-09-21 02:46:17 -05:00
QString projectFolder ;
if ( m_project )
{
QString projectFileName = m_project - > fileName ( ) ;
2013-10-08 07:28:01 -05:00
2016-09-21 02:46:17 -05:00
if ( ! projectFileName . isEmpty ( ) )
{
QFileInfo fi ( projectFileName ) ;
projectFolder = fi . absolutePath ( ) ;
}
}
2013-10-08 07:28:01 -05:00
2016-09-21 02:46:17 -05:00
return projectFolder ;
}
2013-12-04 05:04:42 -06:00
//--------------------------------------------------------------------------------------------------
/// Create an absolute path from a path that is specified relative to the project directory
///
/// If the path specified in \a projectRelativePath is already absolute, no changes will be made
//--------------------------------------------------------------------------------------------------
QString RiaApplication : : createAbsolutePathFromProjectRelativePath ( QString projectRelativePath )
{
// Check if path is already absolute
if ( QDir : : isAbsolutePath ( projectRelativePath ) )
{
return projectRelativePath ;
}
2017-02-14 07:59:08 -06:00
QString absolutePath ;
2013-12-04 05:04:42 -06:00
if ( m_project & & ! m_project - > fileName ( ) . isEmpty ( ) )
{
2017-02-14 07:59:08 -06:00
absolutePath = QFileInfo ( m_project - > fileName ( ) ) . absolutePath ( ) ;
2013-12-04 05:04:42 -06:00
}
else
{
2017-02-14 07:59:08 -06:00
absolutePath = this - > lastUsedDialogDirectory ( " BINARY_GRID " ) ;
2013-12-04 05:04:42 -06:00
}
2017-02-14 07:59:08 -06:00
QDir projectDir ( absolutePath ) ;
return projectDir . absoluteFilePath ( projectRelativePath ) ;
2013-12-04 05:04:42 -06:00
}
2015-04-20 02:02:33 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2018-06-11 06:47:21 -05:00
bool RiaApplication : : openOdbCaseFromFile ( const QString & fileName , bool applyTimeStepFilter )
2015-04-20 02:02:33 -05:00
{
2017-05-11 02:23:13 -05:00
if ( ! caf : : Utils : : fileExists ( fileName ) ) return false ;
2015-04-20 02:02:33 -05:00
QFileInfo gridFileName ( fileName ) ;
QString caseName = gridFileName . completeBaseName ( ) ;
RimGeoMechCase * geoMechCase = new RimGeoMechCase ( ) ;
2015-04-25 01:57:34 -05:00
geoMechCase - > setFileName ( fileName ) ;
2015-04-20 02:02:33 -05:00
geoMechCase - > caseUserDescription = caseName ;
2018-06-11 06:47:21 -05:00
geoMechCase - > setApplyTimeFilter ( applyTimeStepFilter ) ;
2018-02-18 11:56:43 -06:00
RimGeoMechModels * geoMechModelCollection = m_project - > activeOilField ( ) ? m_project - > activeOilField ( ) - > geoMechModels ( ) : nullptr ;
2015-04-20 02:02:33 -05:00
// Create the geoMech model container if it is not there already
2018-02-18 11:56:43 -06:00
if ( geoMechModelCollection = = nullptr )
2015-04-20 02:02:33 -05:00
{
geoMechModelCollection = new RimGeoMechModels ( ) ;
m_project - > activeOilField ( ) - > geoMechModels = geoMechModelCollection ;
}
RimGeoMechView * riv = geoMechCase - > createAndAddReservoirView ( ) ;
2015-05-29 05:14:40 -05:00
caf : : ProgressInfo progress ( 11 , " Loading Case " ) ;
progress . setNextProgressIncrement ( 10 ) ;
2015-04-20 02:02:33 -05:00
2015-04-20 09:56:26 -05:00
riv - > loadDataAndUpdate ( ) ;
2015-04-20 02:02:33 -05:00
2018-06-11 06:47:21 -05:00
if ( ! riv - > geoMechCase ( ) )
{
delete geoMechCase ;
return false ;
}
geoMechModelCollection - > cases . push_back ( geoMechCase ) ;
2015-04-20 02:02:33 -05:00
//if (!riv->cellResult()->hasResult())
//{
2017-08-14 03:47:44 -05:00
// riv->cellResult()->setResultVariable(RiaDefines::undefinedResultName());
2015-04-20 02:02:33 -05:00
//}
2015-05-29 05:14:40 -05:00
progress . incrementProgress ( ) ;
progress . setProgressDescription ( " Loading results information " ) ;
2015-04-20 02:02:33 -05:00
2015-08-13 14:28:09 -05:00
m_project - > updateConnectedEditors ( ) ;
2015-04-20 02:02:33 -05:00
2015-12-07 03:07:51 -06:00
RiuMainWindow : : instance ( ) - > selectAsCurrentItem ( riv - > cellResult ( ) ) ;
2015-05-29 05:14:40 -05:00
2015-04-20 02:02:33 -05:00
return true ;
}
2013-10-08 07:28:01 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication : : createMockModel ( )
{
2017-08-24 23:51:56 -05:00
RiaImportEclipseCaseTools : : openMockModel ( RiaDefines : : mockModelBasic ( ) ) ;
2013-10-08 07:28:01 -05:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication : : createResultsMockModel ( )
{
2017-08-24 23:51:56 -05:00
RiaImportEclipseCaseTools : : openMockModel ( RiaDefines : : mockModelBasicWithResults ( ) ) ;
2013-10-08 07:28:01 -05:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication : : createLargeResultsMockModel ( )
{
2017-08-24 23:51:56 -05:00
RiaImportEclipseCaseTools : : openMockModel ( RiaDefines : : mockModelLargeWithResults ( ) ) ;
2013-10-08 07:28:01 -05:00
}
2013-10-28 04:32:24 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication : : createMockModelCustomized ( )
{
2017-08-24 23:51:56 -05:00
RiaImportEclipseCaseTools : : openMockModel ( RiaDefines : : mockModelCustomized ( ) ) ;
2013-10-28 04:32:24 -05:00
}
2013-10-08 07:28:01 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication : : createInputMockModel ( )
{
2017-08-24 23:51:56 -05:00
RicImportInputEclipseCaseFeature : : openInputEclipseCaseFromFileNames ( QStringList ( RiaDefines : : mockModelBasicInputCase ( ) ) ) ;
2013-10-08 07:28:01 -05:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2018-01-09 03:11:28 -06:00
const Rim3dView * RiaApplication : : activeReservoirView ( ) const
2013-10-08 07:28:01 -05:00
{
return m_activeReservoirView ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2018-01-09 03:11:28 -06:00
Rim3dView * RiaApplication : : activeReservoirView ( )
2013-10-08 07:28:01 -05:00
{
return m_activeReservoirView ;
}
2018-01-15 07:52:22 -06:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimGridView * RiaApplication : : activeGridView ( )
{
return dynamic_cast < RimGridView * > ( m_activeReservoirView . p ( ) ) ;
}
2013-10-08 07:28:01 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2017-03-31 08:10:39 -05:00
RimViewWindow * RiaApplication : : activePlotWindow ( ) const
2016-06-28 03:58:22 -05:00
{
2017-03-31 08:10:39 -05:00
RimViewWindow * viewWindow = nullptr ;
2016-06-28 03:58:22 -05:00
2017-03-31 08:10:39 -05:00
if ( m_mainPlotWindow )
{
QList < QMdiSubWindow * > subwindows = m_mainPlotWindow - > subWindowList ( QMdiArea : : StackingOrder ) ;
if ( subwindows . size ( ) > 0 )
{
viewWindow = RiuInterfaceToViewWindow : : viewWindowFromWidget ( subwindows . back ( ) - > widget ( ) ) ;
}
}
2016-06-28 03:58:22 -05:00
2017-03-31 08:10:39 -05:00
return viewWindow ;
2017-01-13 06:32:02 -06:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2018-01-09 03:11:28 -06:00
void RiaApplication : : setActiveReservoirView ( Rim3dView * rv )
2017-01-13 06:32:02 -06:00
{
2017-03-31 08:10:39 -05:00
m_activeReservoirView = rv ;
2018-04-26 13:05:42 -05:00
RiuDockWidgetTools : : instance ( ) - > changeDockWidgetVisibilityBasedOnView ( rv ) ;
2017-01-13 06:32:02 -06:00
}
2013-10-08 07:28:01 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaApplication : : useShaders ( ) const
{
if ( ! m_preferences - > useShaders ) return false ;
bool isShadersSupported = caf : : Viewer : : isShadersSupported ( ) ;
if ( ! isShadersSupported ) return false ;
return true ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaApplication : : RINavigationPolicy RiaApplication : : navigationPolicy ( ) const
{
return m_preferences - > navigationPolicy ( ) ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaApplication : : showPerformanceInfo ( ) const
{
return m_preferences - > showHud ;
}
2013-12-04 05:04:42 -06:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaApplication : : parseArguments ( )
{
2017-08-29 02:38:41 -05:00
bool result = RiaArgumentParser : : parseArguments ( ) ;
if ( ! result )
2013-12-04 05:04:42 -06:00
{
2017-07-26 09:41:17 -05:00
closeAllWindows ( ) ;
processEvents ( ) ;
}
2017-08-29 02:38:41 -05:00
return result ;
2013-12-04 05:04:42 -06:00
}
2015-10-05 09:09:51 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2015-12-03 03:33:38 -06:00
int RiaApplication : : launchUnitTests ( )
2015-10-05 09:09:51 -05:00
{
2015-12-03 04:38:59 -06:00
# ifdef USE_UNIT_TESTS
2015-10-05 09:09:51 -05:00
cvf : : Assert : : setReportMode ( cvf : : Assert : : CONSOLE ) ;
int argc = QCoreApplication : : argc ( ) ;
testing : : InitGoogleTest ( & argc , QCoreApplication : : argv ( ) ) ;
2015-12-03 03:33:38 -06:00
// Use this macro in main() to run all tests. It returns 0 if all
// tests are successful, or 1 otherwise.
//
// RUN_ALL_TESTS() should be invoked after the command line has been
// parsed by InitGoogleTest().
return RUN_ALL_TESTS ( ) ;
2015-12-03 04:38:59 -06:00
# else
return - 1 ;
# endif
2015-10-05 09:09:51 -05:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2015-12-03 03:33:38 -06:00
int RiaApplication : : launchUnitTestsWithConsole ( )
2015-10-05 09:09:51 -05:00
{
// Following code is taken from cvfAssert.cpp
# ifdef WIN32
{
// Allocate a new console for this app
// Only one console can be associated with an app, so should fail if a console is already present.
AllocConsole ( ) ;
2016-05-04 08:11:42 -05:00
FILE * consoleFilePointer ;
2015-10-05 09:09:51 -05:00
2016-05-04 08:11:42 -05:00
freopen_s ( & consoleFilePointer , " CONOUT$ " , " w " , stdout ) ;
freopen_s ( & consoleFilePointer , " CONOUT$ " , " w " , stderr ) ;
2015-10-05 09:09:51 -05:00
// Make cout, wcout, cin, wcin, wcerr, cerr, wclog and clog point to console as well
std : : ios : : sync_with_stdio ( ) ;
}
# endif
2015-12-03 03:33:38 -06:00
return launchUnitTests ( ) ;
2015-10-05 09:09:51 -05:00
}
2013-12-04 05:04:42 -06:00
2018-06-29 04:36:50 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuPlotMainWindow * RiaApplication : : getOrCreateMainPlotWindow ( )
{
if ( ! m_mainPlotWindow )
{
createMainPlotWindow ( ) ;
2018-08-17 03:54:30 -05:00
m_mainPlotWindow - > initializeGuiNewProjectLoaded ( ) ;
loadAndUpdatePlotData ( ) ;
2018-06-29 04:36:50 -05:00
}
return m_mainPlotWindow ;
}
2016-06-27 04:07:01 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication : : createMainPlotWindow ( )
{
2018-02-18 11:56:43 -06:00
CVF_ASSERT ( m_mainPlotWindow = = nullptr ) ;
2016-06-27 04:07:01 -05:00
2018-04-26 23:28:08 -05:00
m_mainPlotWindow = new RiuPlotMainWindow ;
2016-06-27 04:07:01 -05:00
2016-06-29 07:15:39 -05:00
m_mainPlotWindow - > setWindowTitle ( " Plots - ResInsight " ) ;
2016-06-27 04:07:01 -05:00
m_mainPlotWindow - > setDefaultWindowSize ( ) ;
m_mainPlotWindow - > loadWinGeoAndDockToolBarLayout ( ) ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication : : deleteMainPlotWindow ( )
{
2016-06-29 07:15:39 -05:00
if ( m_mainPlotWindow )
{
m_mainPlotWindow - > deleteLater ( ) ;
2018-02-18 11:56:43 -06:00
m_mainPlotWindow = nullptr ;
2016-06-29 07:15:39 -05:00
}
2016-06-27 04:07:01 -05:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2018-04-26 23:28:08 -05:00
RiuPlotMainWindow * RiaApplication : : getOrCreateAndShowMainPlotWindow ( )
2016-06-27 04:07:01 -05:00
{
if ( ! m_mainPlotWindow )
{
createMainPlotWindow ( ) ;
2017-08-21 06:09:06 -05:00
m_mainPlotWindow - > initializeGuiNewProjectLoaded ( ) ;
2016-10-05 03:04:41 -05:00
loadAndUpdatePlotData ( ) ;
2016-06-27 04:07:01 -05:00
}
2016-11-24 07:47:20 -06:00
if ( m_mainPlotWindow - > isMinimized ( ) )
{
m_mainPlotWindow - > showNormal ( ) ;
m_mainPlotWindow - > update ( ) ;
}
else
{
m_mainPlotWindow - > show ( ) ;
}
2016-10-04 02:29:45 -05:00
m_mainPlotWindow - > raise ( ) ;
2018-07-02 02:49:45 -05:00
m_mainPlotWindow - > activateWindow ( ) ;
2016-06-27 04:07:01 -05:00
return m_mainPlotWindow ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2018-04-26 23:28:08 -05:00
RiuPlotMainWindow * RiaApplication : : mainPlotWindow ( )
2016-06-27 04:07:01 -05:00
{
return m_mainPlotWindow ;
}
2016-08-31 10:34:31 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2017-01-17 06:06:57 -06:00
RiuMainWindowBase * RiaApplication : : mainWindowByID ( int mainWindowID )
{
if ( mainWindowID = = 0 ) return RiuMainWindow : : instance ( ) ;
else if ( mainWindowID = = 1 ) return m_mainPlotWindow ;
else return nullptr ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2016-08-31 10:34:31 -05:00
RimViewWindow * RiaApplication : : activeViewWindow ( )
{
2018-02-18 11:56:43 -06:00
RimViewWindow * viewWindow = nullptr ;
2016-08-31 10:34:31 -05:00
2017-03-31 08:10:39 -05:00
QWidget * mainWindowWidget = RiaApplication : : activeWindow ( ) ;
2016-08-31 10:34:31 -05:00
2017-03-31 08:10:39 -05:00
if ( dynamic_cast < RiuMainWindow * > ( mainWindowWidget ) )
2016-08-31 10:34:31 -05:00
{
viewWindow = RiaApplication : : instance ( ) - > activeReservoirView ( ) ;
}
2018-04-26 23:28:08 -05:00
else if ( dynamic_cast < RiuPlotMainWindow * > ( mainWindowWidget ) )
2016-08-31 10:34:31 -05:00
{
2018-04-26 23:28:08 -05:00
RiuPlotMainWindow * mainPlotWindow = dynamic_cast < RiuPlotMainWindow * > ( mainWindowWidget ) ;
2017-03-31 08:10:39 -05:00
2016-08-31 10:34:31 -05:00
QList < QMdiSubWindow * > subwindows = mainPlotWindow - > subWindowList ( QMdiArea : : StackingOrder ) ;
if ( subwindows . size ( ) > 0 )
{
2017-03-31 08:10:39 -05:00
viewWindow = RiuInterfaceToViewWindow : : viewWindowFromWidget ( subwindows . back ( ) - > widget ( ) ) ;
2016-08-31 10:34:31 -05:00
}
}
return viewWindow ;
}
2017-04-25 08:01:31 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaApplication : : isMain3dWindowVisible ( ) const
{
return RiuMainWindow : : instance ( ) - > isVisible ( ) ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaApplication : : isMainPlotWindowVisible ( ) const
{
if ( ! m_mainPlotWindow ) return false ;
return m_mainPlotWindow - > isVisible ( ) ;
}
2016-10-04 02:29:45 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaApplication : : tryCloseMainWindow ( )
{
RiuMainWindow * mainWindow = RiuMainWindow : : instance ( ) ;
if ( mainWindow & & ! mainWindow - > isVisible ( ) )
{
mainWindow - > close ( ) ;
return true ;
}
return false ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaApplication : : tryClosePlotWindow ( )
{
2016-10-04 06:14:39 -05:00
if ( ! m_mainPlotWindow )
{
return true ;
}
2016-10-04 02:29:45 -05:00
if ( m_mainPlotWindow & & ! m_mainPlotWindow - > isVisible ( ) )
{
m_mainPlotWindow - > close ( ) ;
return true ;
}
return false ;
}
2016-10-05 01:23:07 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication : : addToRecentFiles ( const QString & fileName )
{
m_recentFileActionProvider - > addFileName ( fileName ) ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std : : vector < QAction * > RiaApplication : : recentFileActions ( ) const
{
return m_recentFileActionProvider - > actions ( ) ;
}
2017-07-26 09:57:43 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication : : setStartDir ( const QString & startDir )
{
m_startupDefaultDirectory = startDir ;
}
2013-12-04 05:04:42 -06:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std : : vector < QString > RiaApplication : : readFileListFromTextFile ( QString listFileName )
{
std : : vector < QString > fileList ;
QFile file ( listFileName ) ;
if ( ! file . open ( QIODevice : : ReadOnly | QIODevice : : Text ) )
{
return fileList ;
}
QTextStream in ( & file ) ;
QString line = in . readLine ( ) ;
while ( ! line . isNull ( ) )
{
line = line . trimmed ( ) ;
if ( ! line . isEmpty ( ) )
{
fileList . push_back ( line ) ;
}
line = in . readLine ( ) ;
}
return fileList ;
}
2018-03-08 03:10:15 -06:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication : : waitUntilCommandObjectsHasBeenProcessed ( )
{
2018-03-12 05:12:39 -05:00
// Wait until all command objects have completed
while ( ! m_commandQueueLock . tryLock ( ) )
{
processEvents ( ) ;
}
m_commandQueueLock . unlock ( ) ;
2018-03-08 03:10:15 -06:00
}
2013-10-08 07:28:01 -05:00
//--------------------------------------------------------------------------------------------------
2018-05-16 01:35:11 -05:00
///
//--------------------------------------------------------------------------------------------------
void RiaApplication : : saveWinGeoAndDockToolBarLayout ( )
{
if ( m_mainPlotWindow )
{
m_mainPlotWindow - > saveWinGeoAndDockToolBarLayout ( ) ;
}
if ( RiuMainWindow : : instance ( ) )
{
RiuMainWindow : : instance ( ) - > saveWinGeoAndDockToolBarLayout ( ) ;
}
}
//--------------------------------------------------------------------------------------------------
2018-09-19 07:43:06 -05:00
///
//--------------------------------------------------------------------------------------------------
bool RiaApplication : : enableDevelopmentFeatures ( )
{
QString environmentVar = QProcessEnvironment : : systemEnvironment ( ) . value ( " RESINSIGHT_DEVEL " , QString ( " 0 " ) ) ;
return environmentVar . toInt ( ) = = 1 ;
}
2018-10-30 08:02:22 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication : : clearAllSelections ( )
{
RiuSelectionManager : : instance ( ) - > deleteAllItems ( RiuSelectionManager : : RUI_APPLICATION_GLOBAL ) ;
RiuSelectionManager : : instance ( ) - > deleteAllItems ( RiuSelectionManager : : RUI_TEMPORARY ) ;
caf : : SelectionManager : : instance ( ) - > clearAll ( ) ;
}
2018-09-19 07:43:06 -05:00
//--------------------------------------------------------------------------------------------------
2013-10-08 07:28:01 -05:00
///
//--------------------------------------------------------------------------------------------------
QString RiaApplication : : scriptDirectories ( ) const
{
return m_preferences - > scriptDirectories ( ) ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaApplication : : scriptEditorPath ( ) const
{
return m_preferences - > scriptEditorExecutable ( ) ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaApplication : : octavePath ( ) const
{
return m_preferences - > octaveExecutable ( ) ;
}
2014-07-22 05:11:48 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QStringList RiaApplication : : octaveArguments ( ) const
{
// http://www.gnu.org/software/octave/doc/interpreter/Command-Line-Options.html#Command-Line-Options
// -p path
// Add path to the head of the search path for function files. The value of path specified on the command line
// will override any value of OCTAVE_PATH found in the environment, but not any commands in the system or
// user startup files that set the internal load path through one of the path functions.
QStringList arguments ;
arguments . append ( " --path " ) ;
arguments < < QApplication : : applicationDirPath ( ) ;
if ( ! m_preferences - > octaveShowHeaderInfoWhenExecutingScripts )
{
// -q
// Don't print the usual greeting and version message at startup.
arguments . append ( " -q " ) ;
}
return arguments ;
}
2013-10-08 07:28:01 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication : : slotWorkerProcessFinished ( int exitCode , QProcess : : ExitStatus exitStatus )
{
RiuMainWindow : : instance ( ) - > processMonitor ( ) - > stopMonitorWorkProcess ( ) ;
// Execute delete later so that other slots that are hooked up
// get a chance to run before we delete the object
if ( m_workerProcess )
{
m_workerProcess - > close ( ) ;
}
2018-02-18 11:56:43 -06:00
m_workerProcess = nullptr ;
2013-10-08 07:28:01 -05:00
// Either the work process crashed or was aborted by the user
if ( exitStatus = = QProcess : : CrashExit )
{
// MFLog::error("Simulation execution crashed or was aborted.");
2017-07-31 04:10:22 -05:00
m_runningWorkerProcess = false ;
2013-10-08 07:28:01 -05:00
return ;
}
executeCommandObjects ( ) ;
// Exit code != 0 means we have an error
if ( exitCode ! = 0 )
{
// MFLog::error(QString("Simulation execution failed (exit code %1).").arg(exitCode));
2017-07-31 04:10:22 -05:00
m_runningWorkerProcess = false ;
2013-10-08 07:28:01 -05:00
return ;
}
// If multiple cases are present, invoke launchProcess() which will set next current case, and run script on this case
2015-11-27 09:37:26 -06:00
if ( ! m_currentCaseIds . empty ( ) )
2013-10-08 07:28:01 -05:00
{
launchProcess ( m_currentProgram , m_currentArguments ) ;
}
else
{
// Disable concept of current case
m_socketServer - > setCurrentCaseId ( - 1 ) ;
2017-07-31 04:10:22 -05:00
m_runningWorkerProcess = false ;
2013-10-08 07:28:01 -05:00
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaApplication : : launchProcess ( const QString & program , const QStringList & arguments )
{
2018-02-18 11:56:43 -06:00
if ( m_workerProcess = = nullptr )
2013-10-08 07:28:01 -05:00
{
// If multiple cases are present, pop the first case ID from the list and set as current case
2015-11-27 09:37:26 -06:00
if ( ! m_currentCaseIds . empty ( ) )
2013-10-08 07:28:01 -05:00
{
int nextCaseId = m_currentCaseIds . front ( ) ;
m_currentCaseIds . pop_front ( ) ;
m_socketServer - > setCurrentCaseId ( nextCaseId ) ;
}
else
{
// Disable current case concept
m_socketServer - > setCurrentCaseId ( - 1 ) ;
}
2017-07-31 04:10:22 -05:00
m_runningWorkerProcess = true ;
2013-10-08 07:28:01 -05:00
m_workerProcess = new caf : : UiProcess ( this ) ;
QProcessEnvironment penv = QProcessEnvironment : : systemEnvironment ( ) ;
2014-01-02 07:31:10 -06:00
# ifdef WIN32
// Octave plugins compiled by ResInsight are dependent on Qt (currently Qt 32-bit only)
// Some Octave installations for Windows have included Qt, and some don't. To make sure these plugins always can be executed,
// the path to octave_plugin_dependencies is added to global path
QString pathString = penv . value ( " PATH " , " " ) ;
if ( pathString = = " " ) pathString = QApplication : : applicationDirPath ( ) + " \\ octave_plugin_dependencies " ;
else pathString = QApplication : : applicationDirPath ( ) + " \\ octave_plugin_dependencies " + " ; " + pathString ;
penv . insert ( " PATH " , pathString ) ;
# else
// Set the LD_LIBRARY_PATH to make the octave plugins find the embedded Qt
QString ldPath = penv . value ( " LD_LIBRARY_PATH " , " " ) ;
if ( ldPath = = " " ) ldPath = QApplication : : applicationDirPath ( ) ;
else ldPath = QApplication : : applicationDirPath ( ) + " : " + ldPath ;
penv . insert ( " LD_LIBRARY_PATH " , ldPath ) ;
# endif
2013-10-08 07:28:01 -05:00
m_workerProcess - > setProcessEnvironment ( penv ) ;
connect ( m_workerProcess , SIGNAL ( finished ( int , QProcess : : ExitStatus ) ) , SLOT ( slotWorkerProcessFinished ( int , QProcess : : ExitStatus ) ) ) ;
RiuMainWindow : : instance ( ) - > processMonitor ( ) - > startMonitorWorkProcess ( m_workerProcess ) ;
m_workerProcess - > start ( program , arguments ) ;
if ( ! m_workerProcess - > waitForStarted ( 1000 ) )
{
m_workerProcess - > close ( ) ;
2018-02-18 11:56:43 -06:00
m_workerProcess = nullptr ;
2017-07-31 04:10:22 -05:00
m_runningWorkerProcess = false ;
2013-10-08 07:28:01 -05:00
RiuMainWindow : : instance ( ) - > processMonitor ( ) - > stopMonitorWorkProcess ( ) ;
QMessageBox : : warning ( RiuMainWindow : : instance ( ) , " Script execution " , " Failed to start script executable located at \n " + program ) ;
return false ;
}
return true ;
}
else
{
2018-02-18 11:56:43 -06:00
QMessageBox : : warning ( nullptr , " Script execution " , " An Octave process is still running. Please stop this process before executing a new script. " ) ;
2013-10-08 07:28:01 -05:00
return false ;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaApplication : : launchProcessForMultipleCases ( const QString & program , const QStringList & arguments , const std : : vector < int > & caseIds )
{
m_currentCaseIds . clear ( ) ;
std : : copy ( caseIds . begin ( ) , caseIds . end ( ) , std : : back_inserter ( m_currentCaseIds ) ) ;
m_currentProgram = program ;
m_currentArguments = arguments ;
return launchProcess ( m_currentProgram , m_currentArguments ) ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaPreferences * RiaApplication : : preferences ( )
{
return m_preferences ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication : : applyPreferences ( )
{
if ( m_activeReservoirView & & m_activeReservoirView - > viewer ( ) )
{
2015-07-02 05:44:57 -05:00
m_activeReservoirView - > viewer ( ) - > updateNavigationPolicy ( ) ;
2013-10-08 07:28:01 -05:00
m_activeReservoirView - > viewer ( ) - > enablePerfInfoHud ( m_preferences - > showHud ( ) ) ;
}
if ( useShaders ( ) )
{
caf : : EffectGenerator : : setRenderingMode ( caf : : EffectGenerator : : SHADER_BASED ) ;
}
else
{
caf : : EffectGenerator : : setRenderingMode ( caf : : EffectGenerator : : FIXED_FUNCTION ) ;
}
2015-09-18 12:24:02 -05:00
if ( RiuMainWindow : : instance ( ) & & RiuMainWindow : : instance ( ) - > projectTreeView ( ) )
{
RiuMainWindow : : instance ( ) - > projectTreeView ( ) - > enableAppendOfClassNameToUiItemText ( m_preferences - > appendClassNameToUiText ( ) ) ;
2017-01-19 10:35:47 -06:00
if ( mainPlotWindow ( ) ) mainPlotWindow ( ) - > projectTreeView ( ) - > enableAppendOfClassNameToUiItemText ( m_preferences - > appendClassNameToUiText ( ) ) ;
2015-09-18 12:24:02 -05:00
}
2016-08-09 06:09:08 -05:00
caf : : FixedAtlasFont : : FontSize fontSizeType = caf : : FixedAtlasFont : : POINT_SIZE_16 ;
if ( m_preferences - > fontSizeInScene ( ) = = " 8 " )
{
fontSizeType = caf : : FixedAtlasFont : : POINT_SIZE_8 ;
}
else if ( m_preferences - > fontSizeInScene ( ) = = " 12 " )
{
fontSizeType = caf : : FixedAtlasFont : : POINT_SIZE_12 ;
}
else if ( m_preferences - > fontSizeInScene ( ) = = " 16 " )
{
fontSizeType = caf : : FixedAtlasFont : : POINT_SIZE_16 ;
}
else if ( m_preferences - > fontSizeInScene ( ) = = " 24 " )
{
fontSizeType = caf : : FixedAtlasFont : : POINT_SIZE_24 ;
}
else if ( m_preferences - > fontSizeInScene ( ) = = " 32 " )
{
fontSizeType = caf : : FixedAtlasFont : : POINT_SIZE_32 ;
}
m_customFont = new caf : : FixedAtlasFont ( fontSizeType ) ;
2013-10-08 07:28:01 -05:00
if ( this - > project ( ) )
{
this - > project ( ) - > setScriptDirectories ( m_preferences - > scriptDirectories ( ) ) ;
2015-09-18 12:24:02 -05:00
this - > project ( ) - > updateConnectedEditors ( ) ;
2016-08-09 06:09:08 -05:00
2018-01-09 03:11:28 -06:00
std : : vector < Rim3dView * > visibleViews ;
2016-08-09 06:09:08 -05:00
this - > project ( ) - > allVisibleViews ( visibleViews ) ;
for ( auto view : visibleViews )
{
RimEclipseView * eclipseView = dynamic_cast < RimEclipseView * > ( view ) ;
if ( eclipseView )
{
eclipseView - > scheduleReservoirGridGeometryRegen ( ) ;
}
view - > scheduleCreateDisplayModelAndRedraw ( ) ;
}
2013-10-08 07:28:01 -05:00
}
2017-11-08 04:29:35 -06:00
caf : : PdmUiItem : : enableExtraDebugText ( m_preferences - > appendFieldKeywordToToolTipText ( ) ) ;
2013-10-08 07:28:01 -05:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication : : terminateProcess ( )
{
if ( m_workerProcess )
{
m_workerProcess - > close ( ) ;
}
2017-07-31 04:10:22 -05:00
m_runningWorkerProcess = false ;
2018-02-18 11:56:43 -06:00
m_workerProcess = nullptr ;
2013-10-08 07:28:01 -05:00
}
2017-07-31 04:10:22 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication : : waitForProcess ( ) const
{
while ( m_runningWorkerProcess )
{
2017-07-31 04:26:21 -05:00
# ifdef WIN32
2017-07-31 04:10:22 -05:00
Sleep ( 100 ) ;
2017-07-31 04:26:21 -05:00
# else
usleep ( 100000 ) ;
# endif
2017-08-03 04:31:12 -05:00
processEvents ( ) ;
2017-07-31 04:10:22 -05:00
}
}
2013-10-08 07:28:01 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2016-09-21 02:46:17 -05:00
QString RiaApplication : : lastUsedDialogDirectory ( const QString & dialogName )
2013-10-08 07:28:01 -05:00
{
2016-09-21 02:46:17 -05:00
QString lastUsedDirectory = m_startupDefaultDirectory ;
auto it = m_fileDialogDefaultDirectories . find ( dialogName ) ;
if ( it ! = m_fileDialogDefaultDirectories . end ( ) )
{
lastUsedDirectory = it - > second ;
}
return lastUsedDirectory ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaApplication : : lastUsedDialogDirectoryWithFallback ( const QString & dialogName , const QString & fallbackDirectory )
{
QString lastUsedDirectory = m_startupDefaultDirectory ;
if ( ! fallbackDirectory . isEmpty ( ) )
{
lastUsedDirectory = fallbackDirectory ;
}
auto it = m_fileDialogDefaultDirectories . find ( dialogName ) ;
if ( it ! = m_fileDialogDefaultDirectories . end ( ) )
2013-10-08 07:28:01 -05:00
{
2016-09-21 02:46:17 -05:00
lastUsedDirectory = it - > second ;
2013-10-08 07:28:01 -05:00
}
2016-09-21 02:46:17 -05:00
return lastUsedDirectory ;
2013-10-08 07:28:01 -05:00
}
2018-10-09 08:54:07 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaApplication : : lastUsedDialogDirectoryWithFallbackToProjectFolder ( const QString & dialogName )
{
2018-10-09 09:05:15 -05:00
return lastUsedDialogDirectoryWithFallback ( dialogName , currentProjectPath ( ) ) ;
2018-10-09 08:54:07 -05:00
}
2013-10-08 07:28:01 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2016-09-21 02:46:17 -05:00
void RiaApplication : : setLastUsedDialogDirectory ( const QString & dialogName , const QString & directory )
2013-10-08 07:28:01 -05:00
{
2016-09-21 02:46:17 -05:00
m_fileDialogDefaultDirectories [ dialogName ] = directory ;
2013-10-08 07:28:01 -05:00
}
2013-12-04 05:04:42 -06:00
2016-10-05 03:42:08 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaApplication : : openFile ( const QString & fileName )
{
2017-05-11 02:23:13 -05:00
if ( ! caf : : Utils : : fileExists ( fileName ) ) return false ;
2016-11-24 03:51:20 -06:00
2016-10-05 03:42:08 -05:00
bool loadingSucceded = false ;
2017-04-20 01:07:47 -05:00
if ( RiaApplication : : hasValidProjectFileExtension ( fileName ) )
2016-10-05 03:42:08 -05:00
{
loadingSucceded = loadProject ( fileName ) ;
}
else if ( fileName . contains ( " .egrid " , Qt : : CaseInsensitive ) | | fileName . contains ( " .grid " , Qt : : CaseInsensitive ) )
{
2018-04-13 06:17:44 -05:00
loadingSucceded = RiaImportEclipseCaseTools : : openEclipseCasesFromFile ( QStringList ( { fileName } ) ) ;
2016-10-05 03:42:08 -05:00
}
2016-11-28 00:25:04 -06:00
else if ( fileName . contains ( " .grdecl " , Qt : : CaseInsensitive ) )
{
2017-08-24 23:51:56 -05:00
loadingSucceded = RicImportInputEclipseCaseFeature : : openInputEclipseCaseFromFileNames ( QStringList ( fileName ) ) ;
2016-11-28 00:25:04 -06:00
}
2016-10-05 03:42:08 -05:00
else if ( fileName . contains ( " .odb " , Qt : : CaseInsensitive ) )
{
loadingSucceded = openOdbCaseFromFile ( fileName ) ;
}
2016-10-06 03:33:57 -05:00
else if ( fileName . contains ( " .smspec " , Qt : : CaseInsensitive ) )
{
2018-03-20 05:25:54 -05:00
loadingSucceded = RicImportSummaryCasesFeature : : createAndAddSummaryCasesFromFiles ( QStringList ( { fileName } ) ) ;
2016-10-06 03:33:57 -05:00
if ( loadingSucceded )
{
getOrCreateAndShowMainPlotWindow ( ) ;
2016-10-24 09:01:19 -05:00
2016-10-06 03:33:57 -05:00
m_project - > updateConnectedEditors ( ) ;
}
}
2016-10-05 03:42:08 -05:00
2017-04-20 01:07:47 -05:00
if ( loadingSucceded & & ! RiaApplication : : hasValidProjectFileExtension ( fileName ) )
{
caf : : PdmUiModelChangeDetector : : instance ( ) - > setModelChanged ( ) ;
}
2016-10-05 03:42:08 -05:00
return loadingSucceded ;
}
2013-12-04 05:04:42 -06:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication : : runMultiCaseSnapshots ( const QString & templateProjectFileName , std : : vector < QString > gridFileNames , const QString & snapshotFolderName )
{
RiuMainWindow * mainWnd = RiuMainWindow : : instance ( ) ;
if ( ! mainWnd ) return ;
mainWnd - > hideAllDockWindows ( ) ;
const size_t numGridFiles = gridFileNames . size ( ) ;
for ( size_t i = 0 ; i < numGridFiles ; i + + )
{
QString gridFn = gridFileNames [ i ] ;
RiaProjectModifier modifier ;
2016-11-25 07:21:40 -06:00
modifier . setReplaceCaseFirstOccurrence ( gridFn ) ;
2013-12-04 05:04:42 -06:00
bool loadOk = loadProject ( templateProjectFileName , PLA_NONE , & modifier ) ;
if ( loadOk )
{
2017-08-04 04:25:17 -05:00
RicSnapshotAllViewsToFileFeature : : exportSnapshotOfAllViewsIntoFolder ( snapshotFolderName ) ;
2013-12-04 05:04:42 -06:00
}
}
mainWnd - > loadWinGeoAndDockToolBarLayout ( ) ;
}
2013-10-08 07:28:01 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf : : Font * RiaApplication : : standardFont ( )
{
CVF_ASSERT ( m_standardFont . notNull ( ) ) ;
// The creation of a font is time consuming, so make sure you really need your own font
// instead of using the application font
return m_standardFont . p ( ) ;
}
2016-08-09 06:09:08 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf : : Font * RiaApplication : : customFont ( )
{
CVF_ASSERT ( m_customFont . notNull ( ) ) ;
return m_customFont . p ( ) ;
}
2013-10-08 07:28:01 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimProject * RiaApplication : : project ( )
{
return m_project ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication : : showFormattedTextInMessageBox ( const QString & text )
{
QString helpText = text ;
QMessageBox msgBox ;
msgBox . setIcon ( QMessageBox : : Information ) ;
msgBox . setWindowTitle ( " ResInsight " ) ;
helpText . replace ( " & " , " & " ) ;
helpText . replace ( " < " , " < " ) ;
helpText . replace ( " > " , " > " ) ;
helpText = QString ( " <pre>%1</pre> " ) . arg ( helpText ) ;
msgBox . setText ( helpText ) ;
msgBox . exec ( ) ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaApplication : : commandLineParameterHelp ( ) const
{
2013-12-19 03:45:15 -06:00
return m_helpText ;
/*
2013-10-08 07:28:01 -05:00
QString text = QString ( " \n %1 v. %2 \n " ) . arg ( RI_APPLICATION_NAME ) . arg ( getVersionStringApp ( false ) ) ;
text + = " Copyright Statoil ASA, Ceetron AS 2011, 2012 \n \n " ;
text + =
" \n Parameter Description \n "
" ----------------------------------------------------------------- \n "
" -last Open last used project \n "
" \n "
" -project <filename> Open project file <filename> \n "
" \n "
2013-10-18 09:23:31 -05:00
" -case <casename> Import Eclipse case <casename> \n "
2013-10-08 07:28:01 -05:00
" (do not include .GRID/.EGRID) \n "
" \n "
" -savesnapshots Save snapshot of all views to 'snapshots' folder in project file folder \n "
" Application closes after snapshots are written to file \n "
" \n "
" -regressiontest <folder> Run a regression test on all sub-folders starting with \" " + RegTestNames : : testFolderFilter + " \" of the given folder: \n "
" " + RegTestNames : : testProjectName + " files in the sub-folders will be opened and \n "
" snapshots of all the views is written to the sub-sub-folder " + RegTestNames : : generatedFolderName + " . \n "
" Then difference images is generated in the sub-sub-folder " + RegTestNames : : diffFolderName + " based \n "
" on the images in sub-sub-folder " + RegTestNames : : baseFolderName + " . \n "
" The results are presented in " + RegTestNames : : reportFileName + " that is \n "
" written in the given folder. \n "
" \n "
" -updateregressiontestbase <folder> For all sub-folders starting with \" " + RegTestNames : : testFolderFilter + " \" of the given folder: \n "
" Copy the images in the sub-sub-folder " + RegTestNames : : generatedFolderName + " to the sub-sub-folder \n "
" " + RegTestNames : : baseFolderName + " after deleting " + RegTestNames : : baseFolderName + " completely. \n "
" \n "
" -help, -? Displays help text \n "
" ----------------------------------------------------------------- " ;
return text ;
2013-12-19 03:45:15 -06:00
*/
2013-10-08 07:28:01 -05:00
}
2017-06-20 09:15:47 -05:00
2013-10-08 07:28:01 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication : : setCacheDataObject ( const QString & key , const QVariant & dataObject )
{
m_sessionCache [ key ] = dataObject ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QVariant RiaApplication : : cacheDataObject ( const QString & key ) const
{
QMap < QString , QVariant > : : const_iterator it = m_sessionCache . find ( key ) ;
if ( it ! = m_sessionCache . end ( ) )
{
return it . value ( ) ;
}
return QVariant ( ) ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication : : addCommandObject ( RimCommandObject * commandObject )
{
m_commandQueue . push_back ( commandObject ) ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication : : executeCommandObjects ( )
{
{
2018-09-25 00:37:40 -05:00
std : : list < RimCommandObject * > : : iterator it = m_commandQueue . begin ( ) ;
while ( it ! = m_commandQueue . end ( ) )
2013-10-08 07:28:01 -05:00
{
2018-09-25 00:37:40 -05:00
RimCommandObject * toBeRemoved = * it ;
if ( ! toBeRemoved - > isAsyncronous ( ) )
{
toBeRemoved - > redo ( ) ;
2013-10-08 07:28:01 -05:00
2018-09-25 00:37:40 -05:00
+ + it ;
m_commandQueue . remove ( toBeRemoved ) ;
}
else
{
+ + it ;
}
2013-10-08 07:28:01 -05:00
}
}
2015-11-27 09:37:26 -06:00
if ( ! m_commandQueue . empty ( ) )
2013-10-08 07:28:01 -05:00
{
std : : list < RimCommandObject * > : : iterator it = m_commandQueue . begin ( ) ;
RimCommandObject * first = * it ;
first - > redo ( ) ;
m_commandQueue . pop_front ( ) ;
}
else
{
// Unlock the command queue lock when the command queue is empty
m_commandQueueLock . unlock ( ) ;
}
}
2017-08-29 02:38:41 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication : : setHelpText ( const QString & helpText )
{
m_helpText = helpText ;
}