2013-12-03 13:30:32 -06:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2013-12-04 02:39:50 -06:00
|
|
|
// Copyright (C) Statoil ASA, Ceetron Solutions AS
|
2013-12-03 13:30:32 -06:00
|
|
|
//
|
|
|
|
// 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 "RimFaultCollection.h"
|
|
|
|
|
|
|
|
#include "cafAppEnum.h"
|
|
|
|
#include "cafPdmFieldCvfColor.h"
|
|
|
|
#include "cafPdmFieldCvfMat4d.h"
|
|
|
|
#include "RimReservoirView.h"
|
|
|
|
|
|
|
|
#include "RimResultSlot.h"
|
|
|
|
#include "RimCellRangeFilterCollection.h"
|
|
|
|
#include "RimCellPropertyFilterCollection.h"
|
|
|
|
#include "RimWellCollection.h"
|
|
|
|
|
|
|
|
#include "Rim3dOverlayInfoConfig.h"
|
|
|
|
#include "RimCellEdgeResultSlot.h"
|
|
|
|
#include "RiaApplication.h"
|
|
|
|
#include "RiaPreferences.h"
|
|
|
|
|
2013-12-04 05:13:01 -06:00
|
|
|
#include "RimCase.h"
|
|
|
|
#include "RimReservoirCellResultsCacher.h"
|
|
|
|
#include "RigCaseData.h"
|
|
|
|
#include "RivColorTableArray.h"
|
|
|
|
|
2013-12-03 13:30:32 -06:00
|
|
|
|
2013-12-18 01:57:22 -06:00
|
|
|
namespace caf
|
|
|
|
{
|
|
|
|
template<>
|
|
|
|
void AppEnum< RimFaultCollection::FaultFaceCullingMode >::setUp()
|
|
|
|
{
|
2013-12-18 08:49:03 -06:00
|
|
|
addItem(RimFaultCollection::FAULT_BACK_FACE_CULLING, "FAULT_BACK_FACE_CULLING", "Show outside face only");
|
|
|
|
addItem(RimFaultCollection::FAULT_FRONT_FACE_CULLING, "FAULT_FRONT_FACE_CULLING", "Show inside face only");
|
|
|
|
addItem(RimFaultCollection::FAULT_NO_FACE_CULLING, "FAULT_NO_FACE_CULLING", "Show Both");
|
2013-12-18 01:57:22 -06:00
|
|
|
setDefault(RimFaultCollection::FAULT_NO_FACE_CULLING);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-03 13:30:32 -06:00
|
|
|
|
|
|
|
CAF_PDM_SOURCE_INIT(RimFaultCollection, "Faults");
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimFaultCollection::RimFaultCollection()
|
|
|
|
{
|
|
|
|
CAF_PDM_InitObject("Faults", ":/draw_style_faults_24x24.png", "", "");
|
|
|
|
|
2013-12-20 01:48:54 -06:00
|
|
|
RiaPreferences* prefs = RiaApplication::instance()->preferences();
|
|
|
|
CAF_PDM_InitField(&showFaultCollection, "Active", prefs->defaultShowFaults(), "Active", "", "", "");
|
2013-12-03 13:30:32 -06:00
|
|
|
showFaultCollection.setUiHidden(true);
|
|
|
|
|
2013-12-18 12:02:07 -06:00
|
|
|
CAF_PDM_InitField(&showGeometryDetectedFaults, "ShowGeometryDetectedFaults", false, "Show geometry detected faults", "", "", "");
|
2013-12-19 03:13:55 -06:00
|
|
|
showGeometryDetectedFaults.setUiHidden(true);
|
2013-12-03 13:30:32 -06:00
|
|
|
|
2013-12-18 12:02:07 -06:00
|
|
|
CAF_PDM_InitField(&showFaultFaces, "ShowFaultFaces", true, "Show faults faces", "", "", "");
|
|
|
|
CAF_PDM_InitField(&showOppositeFaultFaces, "ShowOppositeFaultFaces", true, "Show opposite fault faces", "", "", "");
|
|
|
|
CAF_PDM_InitField(&showNNCs, "ShowNNCs", false, "Show NNCs", "", "", "");
|
|
|
|
CAF_PDM_InitField(&limitFaultsToFilter, "LimitFaultsToFilter", true, "Hide fault outside filters", "", "", "");
|
2013-12-06 02:08:45 -06:00
|
|
|
|
2013-12-18 12:02:07 -06:00
|
|
|
CAF_PDM_InitField(&faultFaceCulling, "FaultFaceCulling", caf::AppEnum<RimFaultCollection::FaultFaceCullingMode>(RimFaultCollection::FAULT_FRONT_FACE_CULLING), "Face culling", "", "", "");
|
2013-12-18 01:57:22 -06:00
|
|
|
|
2013-12-18 12:02:07 -06:00
|
|
|
CAF_PDM_InitField(&showFaultLabel, "ShowFaultLabel", true, "Show fault labels", "", "", "");
|
2013-12-03 13:30:32 -06:00
|
|
|
cvf::Color3f defWellLabelColor = RiaApplication::instance()->preferences()->defaultWellLabelColor();
|
2013-12-18 12:02:07 -06:00
|
|
|
CAF_PDM_InitField(&faultLabelColor, "FaultLabelColor", defWellLabelColor, "Fault label color", "", "", "");
|
2013-12-03 13:30:32 -06:00
|
|
|
|
|
|
|
CAF_PDM_InitFieldNoDefault(&faults, "Faults", "Faults", "", "", "");
|
|
|
|
|
|
|
|
m_reservoirView = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimFaultCollection::~RimFaultCollection()
|
|
|
|
{
|
|
|
|
faults.deleteAllChildObjects();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimFaultCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
|
|
|
{
|
|
|
|
if (&showFaultCollection == changedField)
|
|
|
|
{
|
|
|
|
this->updateUiIconFromState(showFaultCollection);
|
|
|
|
}
|
|
|
|
|
2013-12-10 00:43:17 -06:00
|
|
|
if (&faultLabelColor == changedField)
|
|
|
|
{
|
|
|
|
m_reservoirView->scheduleReservoirGridGeometryRegen();
|
|
|
|
}
|
|
|
|
|
2013-12-18 01:57:22 -06:00
|
|
|
if (&faultFaceCulling == changedField)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
2013-12-10 00:43:17 -06:00
|
|
|
|
2013-12-06 02:08:45 -06:00
|
|
|
if (&showGeometryDetectedFaults == changedField ||
|
|
|
|
&showFaultFaces == changedField ||
|
2013-12-06 12:39:55 -06:00
|
|
|
&showOppositeFaultFaces == changedField ||
|
2013-12-16 04:29:48 -06:00
|
|
|
&showNNCs == changedField ||
|
2013-12-06 12:39:55 -06:00
|
|
|
&showFaultCollection == changedField ||
|
|
|
|
&showFaultLabel == changedField ||
|
2013-12-10 00:43:17 -06:00
|
|
|
&limitFaultsToFilter == changedField ||
|
2013-12-18 01:57:22 -06:00
|
|
|
&faultLabelColor == changedField ||
|
|
|
|
&faultFaceCulling == changedField
|
|
|
|
)
|
2013-12-03 13:30:32 -06:00
|
|
|
{
|
|
|
|
if (m_reservoirView)
|
|
|
|
{
|
|
|
|
m_reservoirView->scheduleCreateDisplayModelAndRedraw();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimFaultCollection::setReservoirView(RimReservoirView* ownerReservoirView)
|
|
|
|
{
|
|
|
|
m_reservoirView = ownerReservoirView;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
caf::PdmFieldHandle* RimFaultCollection::objectToggleField()
|
|
|
|
{
|
|
|
|
return &showFaultCollection;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimFault* RimFaultCollection::findFaultByName(QString name)
|
|
|
|
{
|
|
|
|
for (size_t i = 0; i < this->faults().size(); ++i)
|
|
|
|
{
|
|
|
|
if (this->faults()[i]->name() == name)
|
|
|
|
{
|
|
|
|
return this->faults()[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-12-05 02:59:05 -06:00
|
|
|
|
2013-12-05 03:48:57 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
/// A comparing function used to sort Faults in the RimFaultCollection::syncronizeFaults() method
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
bool faultComparator(const cvf::ref<RigFault>& a, const cvf::ref<RigFault>& b)
|
|
|
|
{
|
|
|
|
CVF_TIGHT_ASSERT(a.notNull() && b.notNull());
|
|
|
|
|
|
|
|
int compareValue = a->name().compare(b->name(), Qt::CaseInsensitive);
|
|
|
|
|
|
|
|
return (compareValue < 0);
|
|
|
|
}
|
2013-12-05 02:59:05 -06:00
|
|
|
|
2013-12-04 05:13:01 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimFaultCollection::syncronizeFaults()
|
|
|
|
{
|
|
|
|
if (!(m_reservoirView && m_reservoirView->eclipseCase() && m_reservoirView->eclipseCase()->reservoirData()) ) return;
|
|
|
|
|
|
|
|
cvf::ref<cvf::Color3fArray> partColors = RivColorTableArray::colorTableArray();
|
|
|
|
|
2013-12-05 02:59:05 -06:00
|
|
|
const cvf::Collection<RigFault> constRigFaults = m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->faults();
|
|
|
|
|
|
|
|
cvf::Collection<RigFault> rigFaults(constRigFaults);
|
|
|
|
|
2013-12-05 03:48:57 -06:00
|
|
|
std::sort(rigFaults.begin(), rigFaults.end(), faultComparator);
|
2013-12-04 05:13:01 -06:00
|
|
|
|
|
|
|
std::vector<caf::PdmPointer<RimFault> > newFaults;
|
|
|
|
|
|
|
|
// Find corresponding fault from data model, or create a new
|
|
|
|
for (size_t fIdx = 0; fIdx < rigFaults.size(); ++fIdx)
|
|
|
|
{
|
|
|
|
RimFault* rimFault = this->findFaultByName(rigFaults[fIdx]->name());
|
|
|
|
|
|
|
|
if (!rimFault)
|
|
|
|
{
|
|
|
|
rimFault = new RimFault();
|
|
|
|
rimFault->faultColor = partColors->get(fIdx % partColors->size());
|
|
|
|
}
|
|
|
|
|
|
|
|
rimFault->setFaultGeometry(rigFaults[fIdx].p());
|
|
|
|
|
|
|
|
newFaults.push_back(rimFault);
|
|
|
|
}
|
|
|
|
|
|
|
|
this->faults().clear();
|
|
|
|
this->faults().insert(0, newFaults);
|
|
|
|
}
|
|
|
|
|
2013-12-18 02:26:06 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RimFaultCollection::isGridVisualizationMode() const
|
|
|
|
{
|
|
|
|
CVF_ASSERT(m_reservoirView);
|
|
|
|
|
2013-12-18 16:37:30 -06:00
|
|
|
return m_reservoirView->isGridVisualizationMode();
|
2013-12-18 02:26:06 -06:00
|
|
|
}
|