mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Merged intersection-box into dev
This commit is contained in:
174
ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp
Normal file
174
ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp
Normal file
@@ -0,0 +1,174 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RimIntersectionCollection.h"
|
||||
|
||||
#include "RimIntersection.h"
|
||||
#include "RimEclipseWell.h"
|
||||
#include "RimView.h"
|
||||
|
||||
#include "RiuMainWindow.h"
|
||||
|
||||
#include "RivIntersectionPartMgr.h"
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimIntersectionCollection, "CrossSectionCollection");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimIntersectionCollection::RimIntersectionCollection()
|
||||
{
|
||||
CAF_PDM_InitObject("Intersections", ":/CrossSections16x16.png", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_crossSections, "CrossSections", "Intersections", "", "", "");
|
||||
m_crossSections.uiCapability()->setUiHidden(true);
|
||||
|
||||
CAF_PDM_InitField(&isActive, "Active", true, "Active", "", "", "");
|
||||
isActive.uiCapability()->setUiHidden(true);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimIntersectionCollection::~RimIntersectionCollection()
|
||||
{
|
||||
m_crossSections.deleteAllChildObjects();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmFieldHandle* RimIntersectionCollection::objectToggleField()
|
||||
{
|
||||
return &isActive;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimIntersectionCollection::applySingleColorEffect()
|
||||
{
|
||||
if(!this->isActive()) return;
|
||||
|
||||
for (size_t csIdx = 0; csIdx < m_crossSections.size(); ++csIdx)
|
||||
{
|
||||
RimIntersection* cs = m_crossSections[csIdx];
|
||||
if (cs->isActive)
|
||||
{
|
||||
cs->crossSectionPartMgr()->applySingleColorEffect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimIntersectionCollection::updateCellResultColor(size_t timeStepIndex)
|
||||
{
|
||||
if(!this->isActive()) return;
|
||||
|
||||
for(size_t csIdx = 0; csIdx < m_crossSections.size(); ++csIdx)
|
||||
{
|
||||
RimIntersection* cs = m_crossSections[csIdx];
|
||||
if(cs->isActive)
|
||||
{
|
||||
cs->crossSectionPartMgr()->updateCellResultColor(timeStepIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimIntersectionCollection::appendPartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform)
|
||||
{
|
||||
if (!isActive) return;
|
||||
|
||||
for (size_t csIdx = 0; csIdx < m_crossSections.size(); ++csIdx)
|
||||
{
|
||||
RimIntersection* cs = m_crossSections[csIdx];
|
||||
if (cs->isActive)
|
||||
{
|
||||
cs->crossSectionPartMgr()->appendNativeCrossSectionFacesToModel(model, scaleTransform);
|
||||
cs->crossSectionPartMgr()->appendMeshLinePartsToModel(model, scaleTransform);
|
||||
|
||||
if (cs->inputFromViewerEnabled)
|
||||
{
|
||||
cs->crossSectionPartMgr()->appendPolylinePartsToModel(model, scaleTransform);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimIntersectionCollection::appendCrossSection(RimIntersection* crossSection)
|
||||
{
|
||||
m_crossSections.push_back(crossSection);
|
||||
|
||||
updateConnectedEditors();
|
||||
RiuMainWindow::instance()->selectAsCurrentItem(crossSection);
|
||||
|
||||
RimView* rimView = NULL;
|
||||
firstAncestorOrThisOfType(rimView);
|
||||
if (rimView)
|
||||
{
|
||||
rimView->scheduleCreateDisplayModelAndRedraw();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimIntersectionCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
||||
{
|
||||
if (changedField == &isActive)
|
||||
{
|
||||
RimView* rimView = NULL;
|
||||
firstAncestorOrThisOfType(rimView);
|
||||
if (rimView)
|
||||
{
|
||||
rimView->scheduleCreateDisplayModelAndRedraw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimIntersectionCollection::hasActiveCrossSectionForSimulationWell(RimEclipseWell* eclipseWell) const
|
||||
{
|
||||
if (!isActive) return false;
|
||||
|
||||
for (size_t csIdx = 0; csIdx < m_crossSections.size(); ++csIdx)
|
||||
{
|
||||
RimIntersection* cs = m_crossSections[csIdx];
|
||||
|
||||
if (cs->isActive &&
|
||||
cs->type() == RimIntersection::CS_SIMULATION_WELL &&
|
||||
cs->simulationWell() == eclipseWell)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
Reference in New Issue
Block a user