2015-11-18 02:15:13 -06: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.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RimCrossSectionCollection.h"
|
|
|
|
|
|
|
|
#include "RimCrossSection.h"
|
2015-11-19 04:41:16 -06:00
|
|
|
#include "RivCrossSectionPartMgr.h"
|
2015-11-19 06:40:45 -06:00
|
|
|
#include "RiuMainWindow.h"
|
|
|
|
#include "RimView.h"
|
2015-11-18 02:15:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
CAF_PDM_SOURCE_INIT(RimCrossSectionCollection, "CrossSectionCollection");
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimCrossSectionCollection::RimCrossSectionCollection()
|
|
|
|
{
|
2015-11-23 02:07:35 -06:00
|
|
|
CAF_PDM_InitObject("Intersections", ":/undefined_image.png", "", "");
|
2015-11-18 02:15:13 -06:00
|
|
|
|
2015-11-23 02:07:35 -06:00
|
|
|
CAF_PDM_InitFieldNoDefault(&m_crossSections, "CrossSections", "Intersections", "", "", "");
|
2015-11-19 06:40:45 -06:00
|
|
|
m_crossSections.uiCapability()->setUiHidden(true);
|
2015-11-18 02:15:13 -06:00
|
|
|
|
|
|
|
CAF_PDM_InitField(&isActive, "Active", true, "Active", "", "", "");
|
|
|
|
isActive.uiCapability()->setUiHidden(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
caf::PdmFieldHandle* RimCrossSectionCollection::objectToggleField()
|
|
|
|
{
|
|
|
|
return &isActive;
|
|
|
|
}
|
2015-11-19 04:41:16 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimCrossSectionCollection::applySingleColorEffect()
|
|
|
|
{
|
2015-11-19 06:40:45 -06:00
|
|
|
for (size_t csIdx = 0; csIdx < m_crossSections.size(); ++csIdx)
|
2015-11-19 04:41:16 -06:00
|
|
|
{
|
2015-11-19 06:40:45 -06:00
|
|
|
RimCrossSection* cs = m_crossSections[csIdx];
|
2015-11-22 08:07:34 -06:00
|
|
|
if (cs->isActive)
|
|
|
|
{
|
|
|
|
cs->crossSectionPartMgr()->applySingleColorEffect();
|
|
|
|
}
|
2015-11-19 04:41:16 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-11-20 08:54:22 -06:00
|
|
|
void RimCrossSectionCollection::updateCellResultColor(size_t timeStepIndex)
|
2015-11-19 04:41:16 -06:00
|
|
|
{
|
2015-11-19 06:40:45 -06:00
|
|
|
for (size_t csIdx = 0; csIdx < m_crossSections.size(); ++csIdx)
|
2015-11-19 04:41:16 -06:00
|
|
|
{
|
2015-11-19 06:40:45 -06:00
|
|
|
RimCrossSection* cs = m_crossSections[csIdx];
|
2015-11-22 08:07:34 -06:00
|
|
|
if (cs->isActive)
|
|
|
|
{
|
|
|
|
cs->crossSectionPartMgr()->updateCellResultColor(timeStepIndex);
|
|
|
|
}
|
2015-11-19 04:41:16 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimCrossSectionCollection::appendPartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform)
|
|
|
|
{
|
2015-11-19 11:56:23 -06:00
|
|
|
if (!isActive) return;
|
|
|
|
|
2015-11-19 06:40:45 -06:00
|
|
|
for (size_t csIdx = 0; csIdx < m_crossSections.size(); ++csIdx)
|
2015-11-19 04:41:16 -06:00
|
|
|
{
|
2015-11-19 06:40:45 -06:00
|
|
|
RimCrossSection* cs = m_crossSections[csIdx];
|
2015-11-19 04:41:16 -06:00
|
|
|
if (cs->isActive)
|
|
|
|
{
|
|
|
|
cs->crossSectionPartMgr()->appendNativeCrossSectionFacesToModel(model, scaleTransform);
|
|
|
|
cs->crossSectionPartMgr()->appendMeshLinePartsToModel(model, scaleTransform);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-11-19 06:40:45 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimCrossSectionCollection::appendCrossSection(RimCrossSection* crossSection)
|
|
|
|
{
|
|
|
|
m_crossSections.push_back(crossSection);
|
|
|
|
|
|
|
|
updateConnectedEditors();
|
|
|
|
RiuMainWindow::instance()->setCurrentObjectInTreeView(crossSection);
|
|
|
|
|
|
|
|
RimView* rimView = NULL;
|
|
|
|
firstAnchestorOrThisOfType(rimView);
|
|
|
|
if (rimView)
|
|
|
|
{
|
|
|
|
rimView->scheduleCreateDisplayModelAndRedraw();
|
|
|
|
}
|
|
|
|
}
|
2015-11-19 11:56:23 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimCrossSectionCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
|
|
|
{
|
|
|
|
if (changedField == &isActive)
|
|
|
|
{
|
|
|
|
RimView* rimView = NULL;
|
|
|
|
firstAnchestorOrThisOfType(rimView);
|
|
|
|
if (rimView)
|
|
|
|
{
|
|
|
|
rimView->scheduleCreateDisplayModelAndRedraw();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|