2015-11-18 09:15:13 +01:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// Copyright (C) 2015- Statoil ASA
|
|
|
|
|
// Copyright (C) 2015- Ceetron Solutions AS
|
|
|
|
|
//
|
|
|
|
|
// 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.
|
|
|
|
|
//
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2016-09-21 10:52:16 +02:00
|
|
|
#include "RimIntersectionCollection.h"
|
2015-11-18 09:15:13 +01:00
|
|
|
|
2018-02-01 17:45:22 +01:00
|
|
|
#include "Rim2dIntersectionView.h"
|
2018-03-02 11:25:47 +01:00
|
|
|
#include "Rim2dIntersectionViewCollection.h"
|
2018-01-23 14:23:28 +01:00
|
|
|
#include "Rim3dView.h"
|
|
|
|
|
#include "RimCase.h"
|
2016-10-25 10:03:55 +02:00
|
|
|
#include "RimIntersection.h"
|
|
|
|
|
#include "RimIntersectionBox.h"
|
2017-10-13 09:29:42 +02:00
|
|
|
#include "RimSimWellInView.h"
|
2015-11-18 09:15:13 +01:00
|
|
|
|
2018-02-27 15:53:33 +01:00
|
|
|
#include "Riu3DMainWindowTools.h"
|
2016-07-27 08:05:44 +02:00
|
|
|
|
2016-09-30 08:40:46 +02:00
|
|
|
#include "RivIntersectionBoxPartMgr.h"
|
2016-10-25 10:03:55 +02:00
|
|
|
#include "RivIntersectionPartMgr.h"
|
2016-07-27 08:05:44 +02:00
|
|
|
|
2015-11-18 09:15:13 +01:00
|
|
|
|
2016-09-21 10:52:16 +02:00
|
|
|
CAF_PDM_SOURCE_INIT(RimIntersectionCollection, "CrossSectionCollection");
|
2015-11-18 09:15:13 +01:00
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2016-09-21 10:52:16 +02:00
|
|
|
RimIntersectionCollection::RimIntersectionCollection()
|
2015-11-18 09:15:13 +01:00
|
|
|
{
|
2015-11-24 13:26:45 +01:00
|
|
|
CAF_PDM_InitObject("Intersections", ":/CrossSections16x16.png", "", "");
|
2015-11-18 09:15:13 +01:00
|
|
|
|
2016-10-25 10:03:55 +02:00
|
|
|
CAF_PDM_InitFieldNoDefault(&m_intersections, "CrossSections", "Intersections", "", "", "");
|
|
|
|
|
m_intersections.uiCapability()->setUiHidden(true);
|
2015-11-18 09:15:13 +01:00
|
|
|
|
2016-09-30 08:40:46 +02:00
|
|
|
CAF_PDM_InitFieldNoDefault(&m_intersectionBoxes, "IntersectionBoxes", "IntersectionBoxes", "", "", "");
|
|
|
|
|
m_intersectionBoxes.uiCapability()->setUiHidden(true);
|
|
|
|
|
|
2015-11-18 09:15:13 +01:00
|
|
|
CAF_PDM_InitField(&isActive, "Active", true, "Active", "", "", "");
|
|
|
|
|
isActive.uiCapability()->setUiHidden(true);
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-03 08:26:38 +01:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2016-09-21 10:52:16 +02:00
|
|
|
RimIntersectionCollection::~RimIntersectionCollection()
|
2015-12-03 08:26:38 +01:00
|
|
|
{
|
2016-10-25 10:03:55 +02:00
|
|
|
m_intersections.deleteAllChildObjects();
|
2016-09-30 08:40:46 +02:00
|
|
|
m_intersectionBoxes.deleteAllChildObjects();
|
2015-12-03 08:26:38 +01:00
|
|
|
}
|
|
|
|
|
|
2015-11-18 09:15:13 +01:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2016-09-21 10:52:16 +02:00
|
|
|
caf::PdmFieldHandle* RimIntersectionCollection::objectToggleField()
|
2015-11-18 09:15:13 +01:00
|
|
|
{
|
|
|
|
|
return &isActive;
|
|
|
|
|
}
|
2015-11-19 11:41:16 +01:00
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2016-09-21 10:52:16 +02:00
|
|
|
void RimIntersectionCollection::applySingleColorEffect()
|
2015-11-19 11:41:16 +01:00
|
|
|
{
|
2016-09-28 09:04:21 +02:00
|
|
|
if(!this->isActive()) return;
|
|
|
|
|
|
2016-10-25 10:03:55 +02:00
|
|
|
for (RimIntersection* cs : m_intersections)
|
2015-11-19 11:41:16 +01:00
|
|
|
{
|
2015-11-22 15:07:34 +01:00
|
|
|
if (cs->isActive)
|
|
|
|
|
{
|
2016-10-25 10:03:55 +02:00
|
|
|
cs->intersectionPartMgr()->applySingleColorEffect();
|
2015-11-22 15:07:34 +01:00
|
|
|
}
|
2015-11-19 11:41:16 +01:00
|
|
|
}
|
2016-09-30 08:40:46 +02:00
|
|
|
|
2016-10-25 10:03:55 +02:00
|
|
|
for (RimIntersectionBox* cs : m_intersectionBoxes)
|
2016-09-30 08:40:46 +02:00
|
|
|
{
|
|
|
|
|
if(cs->isActive)
|
|
|
|
|
{
|
|
|
|
|
cs->intersectionBoxPartMgr()->applySingleColorEffect();
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-11-19 11:41:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-02-01 17:45:22 +01:00
|
|
|
void RimIntersectionCollection::updateCellResultColor(size_t timeStepIndex,
|
|
|
|
|
const cvf::ScalarMapper* scalarColorMapper,
|
|
|
|
|
const RivTernaryScalarMapper* ternaryColorMapper)
|
2015-11-19 11:41:16 +01:00
|
|
|
{
|
2016-09-28 09:04:21 +02:00
|
|
|
if(!this->isActive()) return;
|
|
|
|
|
|
2016-10-25 10:03:55 +02:00
|
|
|
for (RimIntersection* cs : m_intersections)
|
2015-11-19 11:41:16 +01:00
|
|
|
{
|
2016-09-28 09:04:21 +02:00
|
|
|
if(cs->isActive)
|
2015-11-22 15:07:34 +01:00
|
|
|
{
|
2018-02-01 17:45:22 +01:00
|
|
|
cs->intersectionPartMgr()->updateCellResultColor(timeStepIndex, scalarColorMapper, ternaryColorMapper);
|
2015-11-22 15:07:34 +01:00
|
|
|
}
|
2015-11-19 11:41:16 +01:00
|
|
|
}
|
2016-09-30 08:40:46 +02:00
|
|
|
|
2016-10-25 10:03:55 +02:00
|
|
|
for (RimIntersectionBox* cs : m_intersectionBoxes)
|
2016-09-30 08:40:46 +02:00
|
|
|
{
|
|
|
|
|
if(cs->isActive)
|
|
|
|
|
{
|
|
|
|
|
cs->intersectionBoxPartMgr()->updateCellResultColor(timeStepIndex);
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-11-19 11:41:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-03-12 09:21:27 +01:00
|
|
|
void RimIntersectionCollection::appendPartsToModel(Rim3dView& view, cvf::ModelBasicList* model, cvf::Transform* scaleTransform)
|
2015-11-19 11:41:16 +01:00
|
|
|
{
|
2015-11-19 18:56:23 +01:00
|
|
|
if (!isActive) return;
|
|
|
|
|
|
2016-10-25 10:03:55 +02:00
|
|
|
for (RimIntersection* cs : m_intersections)
|
2015-11-19 11:41:16 +01:00
|
|
|
{
|
|
|
|
|
if (cs->isActive)
|
|
|
|
|
{
|
2016-10-25 10:03:55 +02:00
|
|
|
cs->intersectionPartMgr()->appendNativeCrossSectionFacesToModel(model, scaleTransform);
|
|
|
|
|
cs->intersectionPartMgr()->appendMeshLinePartsToModel(model, scaleTransform);
|
2018-03-12 09:21:27 +01:00
|
|
|
cs->intersectionPartMgr()->appendPolylinePartsToModel(view, model, scaleTransform);
|
2015-11-19 11:41:16 +01:00
|
|
|
}
|
|
|
|
|
}
|
2016-09-30 08:40:46 +02:00
|
|
|
|
2016-10-25 10:03:55 +02:00
|
|
|
for (RimIntersectionBox* cs : m_intersectionBoxes)
|
2016-09-30 08:40:46 +02:00
|
|
|
{
|
|
|
|
|
if(cs->isActive)
|
|
|
|
|
{
|
|
|
|
|
cs->intersectionBoxPartMgr()->appendNativeCrossSectionFacesToModel(model, scaleTransform);
|
|
|
|
|
cs->intersectionBoxPartMgr()->appendMeshLinePartsToModel(model, scaleTransform);
|
2016-10-03 14:26:46 +02:00
|
|
|
|
|
|
|
|
if (cs->show3dManipulator())
|
|
|
|
|
{
|
|
|
|
|
cs->appendManipulatorPartsToModel(model);
|
|
|
|
|
}
|
2016-09-30 08:40:46 +02:00
|
|
|
}
|
|
|
|
|
}
|
2015-11-19 11:41:16 +01:00
|
|
|
}
|
2015-11-19 13:40:45 +01:00
|
|
|
|
2018-11-06 10:09:30 +01:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimIntersectionCollection::rebuildGeometry()
|
|
|
|
|
{
|
|
|
|
|
for (RimIntersection* intersection : m_intersections)
|
|
|
|
|
{
|
|
|
|
|
intersection->rebuildGeometry();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (RimIntersectionBox* intersectionBox : m_intersectionBoxes)
|
|
|
|
|
{
|
|
|
|
|
intersectionBox->rebuildGeometry();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-05 13:23:44 +01:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
std::vector<RimIntersection*> RimIntersectionCollection::intersections() const
|
|
|
|
|
{
|
|
|
|
|
return m_intersections.childObjects();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
std::vector<RimIntersectionBox*> RimIntersectionCollection::intersectionBoxes() const
|
|
|
|
|
{
|
|
|
|
|
return m_intersectionBoxes.childObjects();
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-02 11:25:47 +01:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimIntersectionCollection::recomputeSimWellBranchData()
|
|
|
|
|
{
|
|
|
|
|
for (const auto& intersection : intersections())
|
|
|
|
|
{
|
|
|
|
|
intersection->recomputeSimulationWellBranchData();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-19 13:40:45 +01:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-01-24 10:48:23 +01:00
|
|
|
void RimIntersectionCollection::appendIntersectionAndUpdate(RimIntersection* intersection)
|
2015-11-19 13:40:45 +01:00
|
|
|
{
|
2016-10-25 10:03:55 +02:00
|
|
|
m_intersections.push_back(intersection);
|
2015-11-19 13:40:45 +01:00
|
|
|
|
2018-01-23 14:23:28 +01:00
|
|
|
syncronize2dIntersectionViews();
|
|
|
|
|
|
2015-11-19 13:40:45 +01:00
|
|
|
updateConnectedEditors();
|
2018-02-27 15:53:33 +01:00
|
|
|
Riu3DMainWindowTools::selectAsCurrentItem(intersection);
|
2015-11-19 13:40:45 +01:00
|
|
|
|
2018-01-24 11:30:39 +01:00
|
|
|
Rim3dView* rimView = nullptr;
|
2016-09-21 13:59:41 +02:00
|
|
|
firstAncestorOrThisOfType(rimView);
|
2015-11-19 13:40:45 +01:00
|
|
|
if (rimView)
|
|
|
|
|
{
|
|
|
|
|
rimView->scheduleCreateDisplayModelAndRedraw();
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-11-19 18:56:23 +01:00
|
|
|
|
2018-01-24 11:30:39 +01:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimIntersectionCollection::appendIntersectionNoUpdate(RimIntersection* intersection)
|
|
|
|
|
{
|
|
|
|
|
m_intersections.push_back(intersection);
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-23 14:23:28 +01:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimIntersectionCollection::syncronize2dIntersectionViews()
|
|
|
|
|
{
|
|
|
|
|
RimCase* ownerCase = nullptr;
|
|
|
|
|
this->firstAncestorOrThisOfTypeAsserted(ownerCase);
|
|
|
|
|
ownerCase->intersectionViewCollection()->syncFromExistingIntersections(true);
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-01 17:45:22 +01:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimIntersectionCollection::scheduleCreateDisplayModelAndRedraw2dIntersectionViews()
|
|
|
|
|
{
|
|
|
|
|
for (RimIntersection* isection: m_intersections)
|
|
|
|
|
{
|
2018-10-23 16:32:40 +02:00
|
|
|
if (isection->correspondingIntersectionView())
|
|
|
|
|
{
|
|
|
|
|
isection->correspondingIntersectionView()->scheduleCreateDisplayModelAndRedraw();
|
|
|
|
|
}
|
2018-02-01 17:45:22 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-30 08:40:46 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-01-24 10:48:23 +01:00
|
|
|
void RimIntersectionCollection::appendIntersectionBoxAndUpdate(RimIntersectionBox* intersectionBox)
|
2016-09-30 08:40:46 +02:00
|
|
|
{
|
|
|
|
|
m_intersectionBoxes.push_back(intersectionBox);
|
2018-01-24 10:48:23 +01:00
|
|
|
|
|
|
|
|
updateConnectedEditors();
|
2018-02-27 15:53:33 +01:00
|
|
|
Riu3DMainWindowTools::selectAsCurrentItem(intersectionBox);
|
2018-01-24 10:48:23 +01:00
|
|
|
|
2018-01-24 11:30:39 +01:00
|
|
|
Rim3dView* rimView = nullptr;
|
2018-01-24 10:48:23 +01:00
|
|
|
firstAncestorOrThisOfType(rimView);
|
|
|
|
|
if (rimView)
|
|
|
|
|
{
|
|
|
|
|
rimView->scheduleCreateDisplayModelAndRedraw();
|
|
|
|
|
}
|
2016-09-30 08:40:46 +02:00
|
|
|
}
|
|
|
|
|
|
2018-01-24 11:30:39 +01:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimIntersectionCollection::appendIntersectionBoxNoUpdate(RimIntersectionBox* intersectionBox)
|
|
|
|
|
{
|
|
|
|
|
m_intersectionBoxes.push_back(intersectionBox);
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-19 18:56:23 +01:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2016-09-21 10:52:16 +02:00
|
|
|
void RimIntersectionCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
2015-11-19 18:56:23 +01:00
|
|
|
{
|
|
|
|
|
if (changedField == &isActive)
|
|
|
|
|
{
|
2018-01-24 11:30:39 +01:00
|
|
|
Rim3dView* rimView = nullptr;
|
2016-09-21 13:59:41 +02:00
|
|
|
firstAncestorOrThisOfType(rimView);
|
2015-11-19 18:56:23 +01:00
|
|
|
if (rimView)
|
|
|
|
|
{
|
|
|
|
|
rimView->scheduleCreateDisplayModelAndRedraw();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-07-27 08:05:44 +02:00
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-10-13 10:16:01 +02:00
|
|
|
bool RimIntersectionCollection::hasActiveIntersectionForSimulationWell(const RimSimWellInView* simWell) const
|
2016-07-27 08:05:44 +02:00
|
|
|
{
|
|
|
|
|
if (!isActive) return false;
|
|
|
|
|
|
2016-10-25 10:03:55 +02:00
|
|
|
for (RimIntersection* cs : m_intersections)
|
2016-07-27 08:05:44 +02:00
|
|
|
{
|
|
|
|
|
if (cs->isActive &&
|
2016-09-21 10:48:25 +02:00
|
|
|
cs->type() == RimIntersection::CS_SIMULATION_WELL &&
|
2017-10-13 10:16:01 +02:00
|
|
|
cs->simulationWell() == simWell)
|
2016-07-27 08:05:44 +02:00
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2016-10-25 09:50:33 +02:00
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimIntersectionCollection::updateIntersectionBoxGeometry()
|
|
|
|
|
{
|
2016-10-25 10:03:55 +02:00
|
|
|
for (RimIntersectionBox* intersectionBox : m_intersectionBoxes)
|
2016-10-25 09:50:33 +02:00
|
|
|
{
|
|
|
|
|
intersectionBox->updateBoxManipulatorGeometry();
|
|
|
|
|
}
|
|
|
|
|
}
|