Create a simpler task system for handling sub tasks in progress dialog.

* Remove incrementProgressAndUpdateNextStep() method
This commit is contained in:
Gaute Lindkvist 2019-03-12 11:01:49 +01:00
parent 674758fbf6
commit 749e19a879
3 changed files with 68 additions and 40 deletions

View File

@ -102,29 +102,42 @@ void RicNewWellBoreStabilityPlotFeature::onActionTriggered(bool isChecked)
if (!geoMechView) return;
caf::ProgressInfo progInfo(100, "Creating Well Bore Stability Plot");
progInfo.setProgressDescription("Creating plot and formation track");
progInfo.setNextProgressIncrement(2);
RimGeoMechCase* geoMechCase = geoMechView->geoMechCase();
RimWellLogPlot* plot = RicNewWellLogPlotFeatureImpl::createWellLogPlot(false, "Well Bore Stability");
QString plotName("Well Bore Stability");
RimWellLogPlot* plot = RicNewWellLogPlotFeatureImpl::createWellLogPlot(false, plotName);
createFormationTrack(plot, wellPath, geoMechCase);
progInfo.incrementProgressAndUpdateNextStep(3, "Creating well design track");
createCasingShoeTrack(plot, wellPath, geoMechCase);
progInfo.incrementProgressAndUpdateNextStep(75, "Creating stability curves track");
createStabilityCurvesTrack(plot, wellPath, geoMechView);
progInfo.incrementProgressAndUpdateNextStep(15, "Creating angles track");
createAnglesTrack(plot, wellPath, geoMechView);
progInfo.incrementProgressAndUpdateNextStep(5, "Updating all tracks");
plot->enableAllAutoNameTags(true);
plot->setPlotTitleVisible(true);
plot->setTrackLegendsVisible(true);
plot->setTrackLegendsHorizontal(true);
plot->setDepthType(RimWellLogPlot::TRUE_VERTICAL_DEPTH);
plot->setDepthAutoZoom(true);
{
auto task = progInfo.task("Creating formation track", 2);
createFormationTrack(plot, wellPath, geoMechCase);
}
{
auto task = progInfo.task("Creating well design track", 3);
createCasingShoeTrack(plot, wellPath, geoMechCase);
}
RicNewWellLogPlotFeatureImpl::updateAfterCreation(plot);
progInfo.incrementProgress();
{
auto task = progInfo.task("Creating stability curves track", 75);
createStabilityCurvesTrack(plot, wellPath, geoMechView);
}
{
auto task = progInfo.task("Creating angles track", 15);
createAnglesTrack(plot, wellPath, geoMechView);
}
{
auto task = progInfo.task("Updating all tracks", 5);
plot->enableAllAutoNameTags(true);
plot->setPlotTitleVisible(true);
plot->setTrackLegendsVisible(true);
plot->setTrackLegendsHorizontal(true);
plot->setDepthType(RimWellLogPlot::TRUE_VERTICAL_DEPTH);
plot->setDepthAutoZoom(true);
RicNewWellLogPlotFeatureImpl::updateAfterCreation(plot);
}
RiuPlotMainWindowTools::selectAsCurrentItem(plot);

View File

@ -50,6 +50,18 @@
namespace caf {
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
ProgressTask::ProgressTask(ProgressInfo& parentTask)
: m_parentTask(parentTask)
{
}
ProgressTask::~ProgressTask()
{
m_parentTask.incrementProgress();
}
//==================================================================================================
///
/// \class caf::ProgressInfo
@ -152,16 +164,6 @@ namespace caf {
ProgressInfoStatic::incrementProgress();
}
//--------------------------------------------------------------------------------------------------
/// Convenience method for incrementing progress and setting step size and description for next step
//--------------------------------------------------------------------------------------------------
void ProgressInfo::incrementProgressAndUpdateNextStep(size_t nextStepSize, const QString& nextDescription)
{
incrementProgress();
setNextProgressIncrement(nextStepSize);
setProgressDescription(nextDescription);
}
//--------------------------------------------------------------------------------------------------
/// To make a certain operation span more of the progress bar than one tick,
/// set the number of progress ticks that you want it to use before calling it.
@ -176,15 +178,18 @@ namespace caf {
//--------------------------------------------------------------------------------------------------
void ProgressInfo::setNextProgressIncrement(size_t nextStepSize)
{
ProgressInfoStatic::setNextProgressIncrement(nextStepSize);
ProgressInfoStatic::setNextProgressIncrement(nextStepSize);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::ProgressTask ProgressInfo::task(const QString& description, int stepSize)
{
setProgressDescription(description);
setNextProgressIncrement(stepSize);
return caf::ProgressTask(*this);
}
//==================================================================================================
///
@ -631,6 +636,4 @@ namespace caf {
//if (progressDialog()) progressDialog()->repaint();
}
}
} // namespace caf

View File

@ -43,6 +43,17 @@ class QString;
namespace caf {
class ProgressInfo;
class ProgressTask
{
public:
ProgressTask(ProgressInfo& parentTask);
~ProgressTask();
private:
ProgressInfo& m_parentTask;
};
class ProgressInfo
{
public:
@ -52,9 +63,10 @@ public:
void setProgressDescription(const QString& description);
void setProgress(size_t progressValue);
void incrementProgress();
void incrementProgressAndUpdateNextStep(size_t nextStepSize, const QString& nextDescription);
void setNextProgressIncrement(size_t nextStepSize);
ProgressTask task(const QString& description, int stepSize);
};