#1495 Move features from well path to sub objects

This commit is contained in:
Magne Sjaastad 2017-05-20 14:31:25 +02:00
parent 5ec2764c16
commit ecddaffeb4
7 changed files with 53 additions and 33 deletions

View File

@ -41,7 +41,11 @@ CAF_CMD_SOURCE_INIT(RicExportFishbonesLateralsFeature, "RicExportFishbonesLatera
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RicExportFishbonesLateralsFeature::onActionTriggered(bool isChecked) void RicExportFishbonesLateralsFeature::onActionTriggered(bool isChecked)
{ {
RimWellPath* wellPath = selectedWellPath(); RimFishbonesCollection* fishbonesCollection = selectedFishbonesCollection();
CVF_ASSERT(fishbonesCollection);
RimWellPath* wellPath = nullptr;
fishbonesCollection->firstAncestorOrThisOfType(wellPath);
CVF_ASSERT(wellPath); CVF_ASSERT(wellPath);
RiaApplication* app = RiaApplication::instance(); RiaApplication* app = RiaApplication::instance();
@ -78,7 +82,7 @@ void RicExportFishbonesLateralsFeature::onActionTriggered(bool isChecked)
size_t fishboneSubIndex = 0; size_t fishboneSubIndex = 0;
QTextStream stream(&exportFile); QTextStream stream(&exportFile);
for (RimFishbonesMultipleSubs* fishbone : wellPath->fishbonesCollection()->fishbonesSubs()) for (RimFishbonesMultipleSubs* fishbone : fishbonesCollection->fishbonesSubs())
{ {
if (!fishbone->isChecked()) continue; if (!fishbone->isChecked()) continue;
@ -126,19 +130,19 @@ QString RicExportFishbonesLateralsFeature::formatNumber(double val, int numberOf
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimWellPath* RicExportFishbonesLateralsFeature::selectedWellPath() RimFishbonesCollection* RicExportFishbonesLateralsFeature::selectedFishbonesCollection()
{ {
RimWellPath* wellPath = nullptr; RimFishbonesCollection* objToFind = nullptr;
caf::PdmUiItem* pdmUiItem = caf::SelectionManager::instance()->selectedItem(); caf::PdmUiItem* pdmUiItem = caf::SelectionManager::instance()->selectedItem();
caf::PdmObjectHandle* objHandle = dynamic_cast<caf::PdmObjectHandle*>(pdmUiItem); caf::PdmObjectHandle* objHandle = dynamic_cast<caf::PdmObjectHandle*>(pdmUiItem);
if (objHandle) if (objHandle)
{ {
objHandle->firstAncestorOrThisOfType(wellPath); objHandle->firstAncestorOrThisOfType(objToFind);
} }
return wellPath; return objToFind;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -155,7 +159,7 @@ void RicExportFishbonesLateralsFeature::setupActionLook(QAction* actionToSetup)
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RicExportFishbonesLateralsFeature::isCommandEnabled() bool RicExportFishbonesLateralsFeature::isCommandEnabled()
{ {
if (selectedWellPath()) if (selectedFishbonesCollection())
{ {
return true; return true;
} }

View File

@ -20,7 +20,7 @@
#include "cafCmdFeature.h" #include "cafCmdFeature.h"
class RimWellPath; class RimFishbonesCollection;
//================================================================================================== //==================================================================================================
/// ///
@ -36,5 +36,5 @@ protected:
private: private:
static QString formatNumber(double val, int numberOfDecimals); static QString formatNumber(double val, int numberOfDecimals);
static RimWellPath* selectedWellPath(); static RimFishbonesCollection* selectedFishbonesCollection();
}; };

View File

@ -1,7 +1,6 @@
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2015- Statoil ASA // Copyright (C) 2017 Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
// //
// ResInsight is free software: you can redistribute it and/or modify // ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
@ -21,10 +20,11 @@
#include "RiaApplication.h" #include "RiaApplication.h"
#include "RimProject.h"
#include "RimWellPath.h"
#include "RimFishboneWellPathCollection.h" #include "RimFishboneWellPathCollection.h"
#include "RimFishbonesCollection.h" #include "RimFishbonesCollection.h"
#include "RimProject.h"
#include "RimWellPath.h"
#include "RimWellPathCompletions.h"
#include "RiuMainWindow.h" #include "RiuMainWindow.h"
@ -40,10 +40,8 @@ CAF_CMD_SOURCE_INIT(RicWellPathImportCompletionsFileFeature, "RicWellPathImportC
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RicWellPathImportCompletionsFileFeature::isCommandEnabled() bool RicWellPathImportCompletionsFileFeature::isCommandEnabled()
{ {
std::vector<RimWellPath*> objects; if (RicWellPathImportCompletionsFileFeature::selectedWellPathCompletions() != nullptr)
caf::SelectionManager::instance()->objectsByType(&objects); {
if (objects.size() == 1) {
return true; return true;
} }
@ -55,10 +53,8 @@ bool RicWellPathImportCompletionsFileFeature::isCommandEnabled()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RicWellPathImportCompletionsFileFeature::onActionTriggered(bool isChecked) void RicWellPathImportCompletionsFileFeature::onActionTriggered(bool isChecked)
{ {
std::vector<RimWellPath*> objects; RimWellPathCompletions* wellPathCompletions = RicWellPathImportCompletionsFileFeature::selectedWellPathCompletions();
caf::SelectionManager::instance()->objectsByType(&objects); CVF_ASSERT(wellPathCompletions);
CVF_ASSERT(objects.size() == 1);
// Open dialog box to select well path files // Open dialog box to select well path files
RiaApplication* app = RiaApplication::instance(); RiaApplication* app = RiaApplication::instance();
@ -70,7 +66,7 @@ void RicWellPathImportCompletionsFileFeature::onActionTriggered(bool isChecked)
// Remember the path to next time // Remember the path to next time
app->setLastUsedDialogDirectory("WELLPATH_DIR", QFileInfo(wellPathFilePaths.last()).absolutePath()); app->setLastUsedDialogDirectory("WELLPATH_DIR", QFileInfo(wellPathFilePaths.last()).absolutePath());
objects[0]->fishbonesCollection()->wellPathCollection()->importCompletionsFromFile(wellPathFilePaths); wellPathCompletions->fishbonesCollection()->wellPathCollection()->importCompletionsFromFile(wellPathFilePaths);
if (app->project()) if (app->project())
{ {
@ -86,3 +82,19 @@ void RicWellPathImportCompletionsFileFeature::setupActionLook(QAction* actionToS
actionToSetup->setText("Import Completions from File"); actionToSetup->setText("Import Completions from File");
actionToSetup->setIcon(QIcon(":/Well.png")); actionToSetup->setIcon(QIcon(":/Well.png"));
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellPathCompletions* RicWellPathImportCompletionsFileFeature::selectedWellPathCompletions()
{
std::vector<RimWellPathCompletions*> objects;
caf::SelectionManager::instance()->objectsByType(&objects);
if (objects.size() > 0)
{
return objects[0];
}
return nullptr;
}

View File

@ -1,7 +1,6 @@
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2015- Statoil ASA // Copyright (C) 2017 Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
// //
// ResInsight is free software: you can redistribute it and/or modify // ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
@ -21,6 +20,8 @@
#include "cafCmdFeature.h" #include "cafCmdFeature.h"
class RimWellPathCompletions;
//================================================================================================== //==================================================================================================
/// ///
//================================================================================================== //==================================================================================================
@ -33,5 +34,8 @@ protected:
virtual bool isCommandEnabled() override; virtual bool isCommandEnabled() override;
virtual void onActionTriggered( bool isChecked ) override; virtual void onActionTriggered( bool isChecked ) override;
virtual void setupActionLook( QAction* actionToSetup ) override; virtual void setupActionLook( QAction* actionToSetup ) override;
private:
static RimWellPathCompletions* selectedWellPathCompletions();
}; };

View File

@ -18,16 +18,10 @@
#include "RimFishbonesCollection.h" #include "RimFishbonesCollection.h"
#include "RimEclipseWell.h" #include "RifWellPathImporter.h"
#include "RimPerforationInterval.h"
#include "RimView.h"
#include "RimProject.h"
#include "RigWellPath.h" #include "RigWellPath.h"
#include "RifWellPathImporter.h"
#include "RiuMainWindow.h"
#include "RimFishboneWellPathCollection.h" #include "RimFishboneWellPathCollection.h"
#include "RimFishbonesMultipleSubs.h" #include "RimFishbonesMultipleSubs.h"
@ -58,6 +52,8 @@ RimFishbonesCollection::RimFishbonesCollection()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimFishboneWellPathCollection* RimFishbonesCollection::wellPathCollection() const RimFishboneWellPathCollection* RimFishbonesCollection::wellPathCollection() const
{ {
CVF_ASSERT(m_wellPathCollection);
return m_wellPathCollection(); return m_wellPathCollection();
} }

View File

@ -20,9 +20,7 @@
#include "RimCheckableNamedObject.h" #include "RimCheckableNamedObject.h"
#include "cafPdmObject.h"
#include "cafPdmChildArrayField.h" #include "cafPdmChildArrayField.h"
#include "cafPdmField.h"
#include "cafPdmChildField.h" #include "cafPdmChildField.h"
class RimFishbonesMultipleSubs; class RimFishbonesMultipleSubs;

View File

@ -21,6 +21,8 @@
#include "RimFishbonesCollection.h" #include "RimFishbonesCollection.h"
#include "RimPerforationCollection.h" #include "RimPerforationCollection.h"
#include "cvfAssert.h"
CAF_PDM_SOURCE_INIT(RimWellPathCompletions, "WellPathCompletions"); CAF_PDM_SOURCE_INIT(RimWellPathCompletions, "WellPathCompletions");
@ -45,6 +47,8 @@ RimWellPathCompletions::RimWellPathCompletions()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimFishbonesCollection* RimWellPathCompletions::fishbonesCollection() const RimFishbonesCollection* RimWellPathCompletions::fishbonesCollection() const
{ {
CVF_ASSERT(m_fishbonesCollection);
return m_fishbonesCollection; return m_fishbonesCollection;
} }
@ -53,6 +57,8 @@ RimFishbonesCollection* RimWellPathCompletions::fishbonesCollection() const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimPerforationCollection* RimWellPathCompletions::perforationCollection() const RimPerforationCollection* RimWellPathCompletions::perforationCollection() const
{ {
CVF_ASSERT(m_perforationCollection);
return m_perforationCollection; return m_perforationCollection;
} }