Skip to content

Commit

Permalink
#1474 Ask user to automatically set scale to 1 for fishbones
Browse files Browse the repository at this point in the history
  • Loading branch information
magnesj committed May 20, 2017
1 parent 6e78c0b commit 1acc54d
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

#include "RicNewFishbonesSubsAtMeasuredDepthFeature.h"

#include "RicNewFishbonesSubsFeature.h"

#include "RimFishbonesCollection.h"
#include "RimFishbonesMultipleSubs.h"
#include "RimProject.h"
Expand Down Expand Up @@ -51,6 +53,8 @@ void RicNewFishbonesSubsAtMeasuredDepthFeature::onActionTriggered(bool isChecked
int integerValue = wellPathSelItem->m_measuredDepth;
obj->setMeasuredDepthAndCount(integerValue, 24, 1);

RicNewFishbonesSubsFeature::askUserToSetUsefulScaling(wellPath->fishbonesCollection());

wellPath->updateConnectedEditors();
RiuMainWindow::instance()->selectAsCurrentItem(obj);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,20 @@

#include "RicNewFishbonesSubsFeature.h"

#include "RimFishbonesMultipleSubs.h"
#include "RiaApplication.h"

#include "RimFishboneWellPathCollection.h"
#include "RimFishbonesCollection.h"
#include "RimFishbonesMultipleSubs.h"
#include "RimView.h"
#include "RimWellPathCollection.h"

#include "RiuMainWindow.h"

#include "cafSelectionManager.h"

#include <QAction>
#include <QMessageBox>


CAF_CMD_SOURCE_INIT(RicNewFishbonesSubsFeature, "RicNewFishbonesSubsFeature");
Expand All @@ -42,6 +48,8 @@ void RicNewFishbonesSubsFeature::onActionTriggered(bool isChecked)
obj->setName(QString("Fishbones Subs (%1)").arg(fishbonesCollection->fishbonesSubs.size()));
fishbonesCollection->fishbonesSubs.push_back(obj);

RicNewFishbonesSubsFeature::askUserToSetUsefulScaling(fishbonesCollection);

fishbonesCollection->updateConnectedEditors();
RiuMainWindow::instance()->selectAsCurrentItem(obj);
}
Expand Down Expand Up @@ -85,3 +93,59 @@ bool RicNewFishbonesSubsFeature::isCommandEnabled()

return false;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewFishbonesSubsFeature::askUserToSetUsefulScaling(RimFishbonesCollection* fishboneCollection)
{
// Always reset well path collection scale factor
CVF_ASSERT(fishboneCollection);
RimWellPathCollection* wellPathColl = nullptr;
fishboneCollection->firstAncestorOrThisOfTypeAsserted(wellPathColl);
wellPathColl->wellPathRadiusScaleFactor = 0.01;

RimView* activeView = RiaApplication::instance()->activeReservoirView();
if (!activeView) return;

RiaApplication* app = RiaApplication::instance();
QString sessionKey = "AutoAdjustSettingsForFishbones";

bool autoAdjustSettings = false;
QVariant v = app->cacheDataObject(sessionKey);
if (!v.isValid())
{
double currentScaleFactor = activeView->scaleZ();
if (fabs(currentScaleFactor - 1.0) < 0.1) return;

QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Question);

QString questionText;
questionText = QString("When displaying Fishbones structures, the view scaling should be set to 1.\n\nDo you want ResInsight to automatically set view scaling to 1?");

msgBox.setText(questionText);
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);

int ret = msgBox.exec();
if (ret == QMessageBox::Yes)
{
autoAdjustSettings = true;
}

app->setCacheDataObject(sessionKey, autoAdjustSettings);
}
else
{
autoAdjustSettings = v.toBool();
}

if (autoAdjustSettings)
{
activeView->setScaleZAndUpdate(1.0);

wellPathColl->scheduleGeometryRegenAndRedrawViews();

RiuMainWindow::instance()->updateScaleValue();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ class RimFishbonesCollection;
class RicNewFishbonesSubsFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:

public:
static void askUserToSetUsefulScaling(RimFishbonesCollection* fishboneCollection);

protected:
virtual void onActionTriggered(bool isChecked) override;
virtual void setupActionLook(QAction* actionToSetup) override;
virtual bool isCommandEnabled() override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ CAF_PDM_SOURCE_INIT(RimWellPathCompletions, "WellPathCompletions");
//--------------------------------------------------------------------------------------------------
RimWellPathCompletions::RimWellPathCompletions()
{
CAF_PDM_InitObject("WellPathCompletions", ":/WellCollection.png", "", "");
CAF_PDM_InitObject("Completions", ":/WellCollection.png", "", "");

CAF_PDM_InitFieldNoDefault(&m_perforationCollection, "Perforations", "Perforations", "", "", "");
m_perforationCollection = new RimPerforationCollection;
Expand Down

0 comments on commit 1acc54d

Please sign in to comment.