2018-10-10 04:10:56 -05:00
|
|
|
#include "RicNewValveFeature.h"
|
|
|
|
#include "Riu3DMainWindowTools.h"
|
|
|
|
|
2018-11-20 08:38:43 -06:00
|
|
|
#include "RiaApplication.h"
|
2018-10-10 04:10:56 -05:00
|
|
|
#include "RimPerforationInterval.h"
|
2018-12-13 12:49:37 -06:00
|
|
|
#include "RimProject.h"
|
2018-10-10 04:10:56 -05:00
|
|
|
#include "RimWellPathValve.h"
|
|
|
|
#include "RimWellPathCollection.h"
|
|
|
|
|
|
|
|
#include "cafSelectionManager.h"
|
|
|
|
|
|
|
|
#include <QAction>
|
|
|
|
|
|
|
|
CAF_CMD_SOURCE_INIT(RicNewValveFeature, "RicNewValveFeature");
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RicNewValveFeature::isCommandEnabled()
|
|
|
|
{
|
2019-04-12 02:08:38 -05:00
|
|
|
std::vector<caf::PdmUiItem*> allSelectedItems;
|
|
|
|
caf::SelectionManager::instance()->selectedItems(allSelectedItems);
|
|
|
|
if (allSelectedItems.size() != 1u) return false;
|
|
|
|
|
|
|
|
const RimPerforationInterval* perfInterval = dynamic_cast<RimPerforationInterval*>(allSelectedItems.front());
|
2018-12-13 12:49:37 -06:00
|
|
|
return perfInterval != nullptr;
|
2018-10-10 04:10:56 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RicNewValveFeature::onActionTriggered(bool isChecked)
|
|
|
|
{
|
|
|
|
RimPerforationInterval* perfInterval = caf::SelectionManager::instance()->selectedItemOfType<RimPerforationInterval>();
|
|
|
|
if (perfInterval)
|
|
|
|
{
|
|
|
|
RimWellPathValve* valve = new RimWellPathValve;
|
2018-12-13 12:49:37 -06:00
|
|
|
|
|
|
|
RimProject* project = nullptr;
|
|
|
|
perfInterval->firstAncestorOrThisOfTypeAsserted(project);
|
|
|
|
|
|
|
|
std::vector<RimWellPathValve*> existingValves = perfInterval->valves();
|
|
|
|
valve->setName(QString("Valve #%1").arg(existingValves.size() + 1));
|
|
|
|
|
|
|
|
std::vector<RimValveTemplate*> allValveTemplates = project->allValveTemplates();
|
|
|
|
if (!allValveTemplates.empty())
|
|
|
|
{
|
|
|
|
valve->setValveTemplate(allValveTemplates.front());
|
|
|
|
}
|
|
|
|
|
2018-10-10 04:10:56 -05:00
|
|
|
perfInterval->addValve(valve);
|
2018-10-19 07:44:17 -05:00
|
|
|
valve->setMeasuredDepthAndCount(perfInterval->startMD(), perfInterval->endMD() - perfInterval->startMD(), 1);
|
2018-10-10 04:10:56 -05:00
|
|
|
|
|
|
|
RimWellPathCollection* wellPathCollection = nullptr;
|
|
|
|
perfInterval->firstAncestorOrThisOfType(wellPathCollection);
|
|
|
|
if (!wellPathCollection) return;
|
|
|
|
|
|
|
|
wellPathCollection->uiCapability()->updateConnectedEditors();
|
|
|
|
wellPathCollection->scheduleRedrawAffectedViews();
|
|
|
|
|
|
|
|
Riu3DMainWindowTools::selectAsCurrentItem(valve);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RicNewValveFeature::setupActionLook(QAction* actionToSetup)
|
|
|
|
{
|
2018-10-31 03:37:47 -05:00
|
|
|
actionToSetup->setIcon(QIcon(":/ICDValve16x16.png"));
|
2019-04-08 04:04:21 -05:00
|
|
|
actionToSetup->setText("Create Valve");
|
2018-10-10 04:10:56 -05:00
|
|
|
}
|