Exemplo n.º 1
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RimWellLogPlot::moveTracks(RimWellLogTrack* insertAfterTrack, const std::vector<RimWellLogTrack*>& tracksToMove)
{
    for (size_t tIdx = 0; tIdx < tracksToMove.size(); tIdx++)
    {
        RimWellLogTrack* track = tracksToMove[tIdx];

        RimWellLogPlot* wellLogPlot;
        track->firstAncestorOrThisOfType(wellLogPlot);
        if (wellLogPlot)
        {
            wellLogPlot->removeTrack(track);
            wellLogPlot->updateTrackNames();
            wellLogPlot->updateConnectedEditors();
        }
    }

    size_t index = m_tracks.index(insertAfterTrack) + 1;

    for (size_t tIdx = 0; tIdx < tracksToMove.size(); tIdx++)
    {
        insertTrack(tracksToMove[tIdx], index + tIdx);
    }

    updateTrackNames();
}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RicNewWellLogCurveExtractionFeature::onActionTriggered(bool isChecked)
{
    RimWellLogTrack* wellLogPlotTrack = selectedWellLogPlotTrack();
    if (wellLogPlotTrack)
    {
        addCurve(wellLogPlotTrack, NULL, NULL);
    }
    else
    {
        RimWellPath* wellPath = selectedWellPath();
        if (wellPath)
        {
            RimWellLogTrack* wellLogPlotTrack = RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack();
            RimWellLogExtractionCurve* plotCurve = addCurve(wellLogPlotTrack, RiaApplication::instance()->activeReservoirView(), wellPath);

            plotCurve->updatePlotData();

            RimWellLogPlot* plot = NULL;
            wellLogPlotTrack->firstAnchestorOrThisOfType(plot);
            if (plot && plotCurve->curveData())
            {
                plot->setDepthUnit(plotCurve->curveData()->depthUnit());
            }

            plotCurve->updateConnectedEditors();
        }
    }
}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RicNewWellLogPlotTrackFeature::onActionTriggered(bool isChecked)
{
    RimWellLogPlot* wellLogPlot = selectedWellLogPlot();
    if (wellLogPlot)
    {
         RimWellLogTrack* plotTrack = new RimWellLogTrack;
         wellLogPlot->addTrack(plotTrack);
         plotTrack->setDescription(QString("Track %1").arg(wellLogPlot->trackCount()));

         wellLogPlot->updateConnectedEditors();
         RicNewWellLogCurveExtractionFeature::addCurve(plotTrack, NULL, NULL);
    }
}
Exemplo n.º 4
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::loadDataAndUpdate()
{
    CVF_ASSERT(m_wellLogTrackPlotWidget);

    RimWellLogPlot* wellLogPlot;
    firstAnchestorOrThisOfType(wellLogPlot);
    if (wellLogPlot)
    {
        m_wellLogTrackPlotWidget->setDepthTitle(wellLogPlot->depthPlotTitle());
    }

    for (size_t cIdx = 0; cIdx < curves.size(); ++cIdx)
    {
        curves[cIdx]->updatePlotData();
    }
}
Exemplo n.º 5
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::zoomAllXAndZoomAllDepthOnOwnerPlot()
{
    if (m_wellLogTrackPlotWidget)
    {
        RimWellLogPlot* wellLogPlot;
        firstAnchestorOrThisOfType(wellLogPlot);
        if (wellLogPlot)
        {
           wellLogPlot->updateDepthZoom();
        }

        zoomAllXAxisIfAutoScale();

        m_wellLogTrackPlotWidget->replot();
    }
}
Exemplo n.º 6
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
{
    if (changedField == &m_show)
    {
        if (m_wellLogTrackPlotWidget)
        {
            m_wellLogTrackPlotWidget->setVisible(m_show());
        }

        RimWellLogPlot* wellLogPlot;
        this->firstAnchestorOrThisOfType(wellLogPlot);
        if (wellLogPlot)
        {
            wellLogPlot->calculateAvailableDepthRange();
            wellLogPlot->updateDepthZoom();
            if (wellLogPlot->viewer()) wellLogPlot->viewer()->updateChildrenLayout();
        }
    }
    else if (changedField == &m_visibleXRangeMin || changedField == &m_visibleXRangeMax)
    {
        m_wellLogTrackPlotWidget->setXRange(m_visibleXRangeMin, m_visibleXRangeMax);
        m_wellLogTrackPlotWidget->replot();
        m_isAutoScaleXEnabled = false;
    }
    else if (changedField == &m_isAutoScaleXEnabled)
    {
        if (m_isAutoScaleXEnabled())
        { 
            this->zoomAllXAxisIfAutoScale();
            computeAndSetXRangeMinForLogarithmicScale();

            if (m_wellLogTrackPlotWidget) m_wellLogTrackPlotWidget->replot();
        }
    }
    else if (changedField == &m_isLogarithmicScaleEnabled)
    {
        updateAxisScaleEngine();

        this->zoomAllXAxisIfAutoScale();
        computeAndSetXRangeMinForLogarithmicScale();

        m_wellLogTrackPlotWidget->setXRange(m_visibleXRangeMin, m_visibleXRangeMax);

        m_wellLogTrackPlotWidget->replot();
    }
}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
bool RicDeleteWellLogPlotTrackFeature::isCommandEnabled()
{
    std::vector<RimWellLogTrack*> selection;
    caf::SelectionManager::instance()->objectsByType(&selection);

    if (selection.size() > 0)
    {
        RimWellLogPlot* wellLogPlot = NULL;
        selection[0]->firstAncestorOrThisOfType(wellLogPlot);
        if (wellLogPlot->trackCount() > 1)
        {
            return true;
        }
    }

    return false;
}
Exemplo n.º 8
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RimWellLogCurve::updateZoomInParentPlot()
{
    RimWellLogPlot* wellLogPlot;
    firstAncestorOrThisOfType(wellLogPlot);
    if (wellLogPlot)
    {
        wellLogPlot->calculateAvailableDepthRange();
        wellLogPlot->updateDepthZoom();
    }

    RimWellLogTrack* plotTrack;
    firstAncestorOrThisOfType(plotTrack);
    if (plotTrack)
    {
        plotTrack->updateXZoomAndParentPlotDepthZoom();
    }
}
Exemplo n.º 9
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
bool RicDeleteWellLogPlotTrackFeature::isCommandEnabled()
{
    if (RicWellLogPlotCurveFeatureImpl::parentWellAllocationPlot()) return false;

    std::vector<RimWellLogTrack*> selection;
    caf::SelectionManager::instance()->objectsByType(&selection);

    if (selection.size() > 0)
    {
        RimWellLogPlot* wellLogPlot = nullptr;
        selection[0]->firstAncestorOrThisOfType(wellLogPlot);
        if (wellLogPlot && wellLogPlot->trackCount() > 1)
        {
            return true;
        }
    }

    return false;
}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RicWellLogPlotTrackFeatureImpl::moveTracksToWellLogPlot(RimWellLogPlot* dstWellLogPlot, 
                                                             const std::vector<RimWellLogTrack*>& tracksToMove, 
                                                             RimWellLogTrack* trackToInsertAfter)
{
    CVF_ASSERT(dstWellLogPlot);

    std::set<RimWellLogPlot*> srcPlots;

    for (size_t tIdx = 0; tIdx < tracksToMove.size(); tIdx++)
    {
        RimWellLogTrack* track = tracksToMove[tIdx];

        RimWellLogPlot* srcPlot;
        track->firstAncestorOrThisOfType(srcPlot);
        if (srcPlot)
        {
            srcPlot->removeTrack(track);
          
            srcPlots.insert(srcPlot);
        }
    }

    for (std::set<RimWellLogPlot*>::iterator pIt = srcPlots.begin(); pIt != srcPlots.end(); ++pIt)
    {
        (*pIt)->calculateAvailableDepthRange();
        (*pIt)->updateTrackNames();
        (*pIt)->updateDepthZoom();
        (*pIt)->updateConnectedEditors();
    }


    size_t insertionStartIndex = 0;
    if (trackToInsertAfter) insertionStartIndex = dstWellLogPlot->trackIndex(trackToInsertAfter) + 1;

    for (size_t tIdx = 0; tIdx < tracksToMove.size(); tIdx++)
    {
        dstWellLogPlot->insertTrack(tracksToMove[tIdx], insertionStartIndex + tIdx);
    }

    dstWellLogPlot->updateTrackNames();
    dstWellLogPlot->updateTracks();
    dstWellLogPlot->updateConnectedEditors();
}
Exemplo n.º 11
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RicDeleteWellLogPlotTrackFeature::onActionTriggered(bool isChecked)
{
    if (RicWellLogPlotCurveFeatureImpl::parentWellAllocationPlot()) return;

    std::vector<RimWellLogTrack*> selection;
    caf::SelectionManager::instance()->objectsByType(&selection);

    for (size_t i = 0; i < selection.size(); i++)
    {
        RimWellLogTrack* track = selection[i];

        RimWellLogPlot* wellLogPlot = nullptr;
        track->firstAncestorOrThisOfType(wellLogPlot);
        if (wellLogPlot && wellLogPlot->trackCount() > 1)
        {
            wellLogPlot->removeTrack(track);
            caf::SelectionManager::instance()->removeObjectFromAllSelections(track);
            delete track;

            wellLogPlot->calculateAvailableDepthRange();
            wellLogPlot->updateDepthZoom();
            wellLogPlot->uiCapability()->updateConnectedEditors();
        }
    }
}
Exemplo n.º 12
0
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindow::updateWellLogPlotToolBar()
{
    RimWellLogPlot* wellLogPlot = dynamic_cast<RimWellLogPlot*>(m_activePlotViewWindow.p());
    if (wellLogPlot)
    {
        std::vector<caf::PdmFieldHandle*> toolBarFields;
        toolBarFields = wellLogPlot->commonDataSource()->fieldsToShowInToolbar();

        m_wellLogPlotToolBarEditor->setFields(toolBarFields);
        m_wellLogPlotToolBarEditor->updateUi();

        m_wellLogPlotToolBarEditor->show();
    }
    else
    {
        m_wellLogPlotToolBarEditor->clear();

        m_wellLogPlotToolBarEditor->hide();
    }

    refreshToolbars();
}
Exemplo n.º 13
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
QString RimWellLogFileCurve::createCurveAutoName()
{
    QStringList name;
    QString unit;
    bool channelNameAvailable = false;

    if (m_wellPath)
    {
        name.push_back(wellName());
        name.push_back("LAS");

        if (!m_wellLogChannnelName().isEmpty())
        {
            name.push_back(m_wellLogChannnelName);
            channelNameAvailable = true;
        }

        RigWellLogFile* wellLogFile = m_wellLogFile ? m_wellLogFile->wellLogFileData() : nullptr;

        if (wellLogFile)
        {
            if (channelNameAvailable)
            {
                RimWellLogPlot* wellLogPlot;
                firstAncestorOrThisOfType(wellLogPlot);
                CVF_ASSERT(wellLogPlot);
                QString unitName = wellLogFile->wellLogChannelUnitString(m_wellLogChannnelName, wellLogPlot->depthUnit());

                if (!unitName.isEmpty())
                {
                    name.back() += QString(" [%1]").arg(unitName);
                }
            }

            QString date = wellLogFile->date();
            if (!date.isEmpty())
            {
                name.push_back(wellLogFile->date());
            }

        }

        return name.join(", ");
    }

    return "Empty curve";
}
Exemplo n.º 14
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RicPasteWellLogPlotFeature::onActionTriggered(bool isChecked)
{
    caf::PdmObjectHandle* destinationObject = dynamic_cast<caf::PdmObjectHandle*>(caf::SelectionManager::instance()->selectedItem());

    RimWellLogPlotCollection* wellLogPlotCollection = nullptr;
    destinationObject->firstAncestorOrThisOfType(wellLogPlotCollection);
    if (!wellLogPlotCollection)
    {
        return;
    }

    std::vector<caf::PdmPointer<RimWellLogPlot> > sourceObjects = RicPasteWellLogPlotFeature::plots();

    for (size_t i = 0; i < sourceObjects.size(); i++)
    {
        RimWellLogPlot* fileCurve = sourceObjects[i];
        if (fileCurve)
        {
            RimWellLogPlot* newObject = dynamic_cast<RimWellLogPlot*>(fileCurve->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance()));
            CVF_ASSERT(newObject);

            wellLogPlotCollection->wellLogPlots.push_back(newObject);

            // Resolve references after object has been inserted into the project data model
            newObject->resolveReferencesRecursively();
            newObject->initAfterReadRecursively();

            QString description = "Copy of " + newObject->description();
            newObject->setDescription(description);

            newObject->loadDataAndUpdate();

            wellLogPlotCollection->updateConnectedEditors();
        }
    }
}
Exemplo n.º 15
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RimWellLogExtractionCurve::onLoadDataAndUpdate(bool updateParentPlot)
{
    this->RimPlotCurve::updateCurvePresentation(updateParentPlot);

    if (isCurveVisible())
    {
        // Make sure we have set correct case data into the result definitions.
        bool isUsingPseudoLength = false;

        RimGeoMechCase* geomCase = dynamic_cast<RimGeoMechCase*>(m_case.value());
        RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>(m_case.value());
        m_eclipseResultDefinition->setEclipseCase(eclipseCase);
        m_geomResultDefinition->setGeoMechCase(geomCase);

        clampBranchIndex();

        RimMainPlotCollection* mainPlotCollection;
        this->firstAncestorOrThisOfTypeAsserted(mainPlotCollection);

        RimWellLogPlotCollection* wellLogCollection = mainPlotCollection->wellLogPlotCollection();

        cvf::ref<RigEclipseWellLogExtractor> eclExtractor;

        if (eclipseCase)
        {
            if (m_trajectoryType == WELL_PATH)
            {
                eclExtractor = wellLogCollection->findOrCreateExtractor(m_wellPath, eclipseCase);
            }
            else
            {
                std::vector<const RigWellPath*> simWellBranches = simulationWellBranches();
                if (m_branchIndex >= 0 && m_branchIndex < static_cast<int>(simWellBranches.size()))
                {
                    auto wellBranch = simWellBranches[m_branchIndex];
                    eclExtractor = wellLogCollection->findOrCreateSimWellExtractor(m_simWellName,
                                                                                   eclipseCase->caseUserDescription(),
                                                                                   wellBranch,
                                                                                   eclipseCase->eclipseCaseData());
                    if (eclExtractor.notNull())
                    {
                        m_wellPathsWithExtractors.push_back(wellBranch);
                    }

                    isUsingPseudoLength = true;
                }
            }
        }
        cvf::ref<RigGeoMechWellLogExtractor> geomExtractor = wellLogCollection->findOrCreateExtractor(m_wellPath, geomCase);

        std::vector<double> values;
        std::vector<double> measuredDepthValues;
        std::vector<double> tvDepthValues;

        RiaDefines::DepthUnitType depthUnit = RiaDefines::UNIT_METER;

        if (eclExtractor.notNull() && eclipseCase)
        {
            measuredDepthValues = eclExtractor->measuredDepth();
            tvDepthValues = eclExtractor->trueVerticalDepth();

            m_eclipseResultDefinition->loadResult();

            cvf::ref<RigResultAccessor> resAcc = RigResultAccessorFactory::createFromResultDefinition(eclipseCase->eclipseCaseData(),
                                                                                                      0,
                                                                                                      m_timeStep,
                                                                                                      m_eclipseResultDefinition);

            if (resAcc.notNull())
            {
                eclExtractor->curveData(resAcc.p(), &values);
            }

            RiaEclipseUnitTools::UnitSystem eclipseUnitsType = eclipseCase->eclipseCaseData()->unitsType();
            if (eclipseUnitsType == RiaEclipseUnitTools::UNITS_FIELD)
            {
                // See https://github.com/OPM/ResInsight/issues/538
                
                depthUnit = RiaDefines::UNIT_FEET;
            }
        }
        else if (geomExtractor.notNull()) // geomExtractor
        {

            measuredDepthValues =  geomExtractor->measuredDepth();
            tvDepthValues = geomExtractor->trueVerticalDepth();

            m_geomResultDefinition->loadResult();

            geomExtractor->curveData(m_geomResultDefinition->resultAddress(), m_timeStep, &values);
        }

        m_curveData = new RigWellLogCurveData;
        if (values.size() && measuredDepthValues.size())
        {
            if (!tvDepthValues.size())
            {
                m_curveData->setValuesAndMD(values, measuredDepthValues, depthUnit, true);
            }
            else
            {
                m_curveData->setValuesWithTVD(values, measuredDepthValues, tvDepthValues, depthUnit, true);
            }
        }

        RiaDefines::DepthUnitType displayUnit = RiaDefines::UNIT_METER;

        RimWellLogPlot* wellLogPlot;
        firstAncestorOrThisOfType(wellLogPlot);
        CVF_ASSERT(wellLogPlot);
        if (!wellLogPlot) return;

        displayUnit = wellLogPlot->depthUnit();

        if(wellLogPlot->depthType() == RimWellLogPlot::TRUE_VERTICAL_DEPTH)
        {
            m_qwtPlotCurve->setSamples(m_curveData->xPlotValues().data(), m_curveData->trueDepthPlotValues(displayUnit).data(), static_cast<int>(m_curveData->xPlotValues().size()));
            isUsingPseudoLength = false;
        }
        else if (wellLogPlot->depthType() == RimWellLogPlot::MEASURED_DEPTH)
        {
            m_qwtPlotCurve->setSamples(m_curveData->xPlotValues().data(), m_curveData->measuredDepthPlotValues(displayUnit).data(), static_cast<int>(m_curveData->xPlotValues().size()));
        }

        m_qwtPlotCurve->setLineSegmentStartStopIndices(m_curveData->polylineStartStopIndices());

        if (isUsingPseudoLength)
        {
            RimWellLogTrack* wellLogTrack;
            firstAncestorOrThisOfType(wellLogTrack);
            CVF_ASSERT(wellLogTrack);

            RiuWellLogTrack* viewer = wellLogTrack->viewer();
            if (viewer)
            {
                viewer->setDepthTitle("PL/" + wellLogPlot->depthPlotTitle());
            }
        }

        updateZoomInParentPlot();

        setLogScaleFromSelectedResult();

        if (m_parentQwtPlot) m_parentQwtPlot->replot();
    }
}
Exemplo n.º 16
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RimWellLogFileCurve::onLoadDataAndUpdate(bool updateParentPlot)
{
    this->RimPlotCurve::updateCurvePresentation(updateParentPlot);

    if (isCurveVisible())
    {
        m_curveData = new RigWellLogCurveData;

        RimWellLogPlot* wellLogPlot;
        firstAncestorOrThisOfType(wellLogPlot);
        CVF_ASSERT(wellLogPlot);

        if (m_wellPath && m_wellLogFile)
        {
            RigWellLogFile* wellLogFile = m_wellLogFile->wellLogFileData();
            if (wellLogFile)
            {
                std::vector<double> values = wellLogFile->values(m_wellLogChannnelName);
                std::vector<double> measuredDepthValues = wellLogFile->depthValues();

                if (wellLogPlot && wellLogPlot->depthType() == RimWellLogPlot::TRUE_VERTICAL_DEPTH)
                {
                    bool canUseTvd = false;
                    if (wellLogFile->hasTvdChannel())
                    {
                        std::vector<double> tvdMslValues = wellLogFile->tvdMslValues();

                        if (values.size() == measuredDepthValues.size() && values.size() == tvdMslValues.size())
                        {
                            m_curveData->setValuesWithTVD(values, measuredDepthValues, tvdMslValues, wellLogFile->depthUnit(), false);
                            canUseTvd = true;
                        }
                    }

                    if (!canUseTvd)
                    {
                        RigWellPath* rigWellPath = m_wellPath->wellPathGeometry();
                        if (rigWellPath)
                        {
                            std::vector<double> trueVerticeldepthValues;

                            for (double measuredDepthValue : measuredDepthValues)
                            {
                                trueVerticeldepthValues.push_back(-rigWellPath->interpolatedPointAlongWellPath(measuredDepthValue).z());
                            }
                            if (values.size() == trueVerticeldepthValues.size() && values.size() == measuredDepthValues.size())
                            {
                                m_curveData->setValuesWithTVD(values, measuredDepthValues, trueVerticeldepthValues, wellLogFile->depthUnit(), false);
                                canUseTvd = true;
                            }
                        }
                    }

                    if (!canUseTvd)
                    {
                        if (RiaApplication::instance()->preferences()->showLasCurveWithoutTvdWarning())
                        {
                            QString tmp = QString("Display of True Vertical Depth (TVD) for LAS curves is not possible without a well log path, and the LAS curve will be hidden in this mode.\n\n");
                            tmp += "Control display of this warning from \"Preferences->Show LAS curve without TVD warning\"";

                            QMessageBox::warning(nullptr, "LAS curve without TVD", tmp);
                        }
                    }
                }
                else
                {
                    if (values.size() == measuredDepthValues.size())
                    {
                        m_curveData->setValuesAndMD(values, measuredDepthValues, wellLogFile->depthUnit(), false);
                    }
                }
            }

            if (m_isUsingAutoName)
            {
                m_qwtPlotCurve->setTitle(createCurveAutoName());
            }
        }

        RiaDefines::DepthUnitType displayUnit = RiaDefines::UNIT_METER;
        if (wellLogPlot)
        {
            displayUnit = wellLogPlot->depthUnit();
        }
        if (wellLogPlot && wellLogPlot->depthType() == RimWellLogPlot::TRUE_VERTICAL_DEPTH)
        {
            m_qwtPlotCurve->setSamples(m_curveData->xPlotValues().data(), m_curveData->trueDepthPlotValues(displayUnit).data(), static_cast<int>(m_curveData->xPlotValues().size()));
        }
        else
        {
            m_qwtPlotCurve->setSamples(m_curveData->xPlotValues().data(), m_curveData->measuredDepthPlotValues(displayUnit).data(), static_cast<int>(m_curveData->xPlotValues().size()));
        }
        m_qwtPlotCurve->setLineSegmentStartStopIndices(m_curveData->polylineStartStopIndices());

        updateZoomInParentPlot();

        if (m_parentQwtPlot) m_parentQwtPlot->replot();
    }
}
Exemplo n.º 17
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RicDeleteItemExec::redo()
{
    caf::PdmFieldHandle* field = caf::PdmReferenceHelper::fieldFromReference(m_commandData->m_rootObject, m_commandData->m_pathToField);

    caf::PdmChildArrayFieldHandle* listField = dynamic_cast<caf::PdmChildArrayFieldHandle*>(field);
    if (listField)
    {
        std::vector<caf::PdmObjectHandle*> children;
        listField->childObjects(&children);

        caf::PdmObjectHandle* obj = children[m_commandData->m_indexToObject];
        caf::SelectionManager::instance()->removeObjectFromAllSelections(obj);

        std::vector<caf::PdmObjectHandle*> referringObjects;
        obj->objectsWithReferringPtrFields(referringObjects);

        if (m_commandData->m_deletedObjectAsXml().isEmpty())
        {
            m_commandData->m_deletedObjectAsXml = xmlObj(obj)->writeObjectToXmlString();
        }

        delete obj;

        listField->erase(m_commandData->m_indexToObject);

        caf::PdmObjectHandle* parentObj = listField->ownerObject();
        parentObj->uiCapability()->updateConnectedEditors();
        
        Rim3dView* view = nullptr;
        parentObj->firstAncestorOrThisOfType(view);

        // Range Filters

        RimCellRangeFilterCollection* rangeFilterColl;
        parentObj->firstAncestorOrThisOfType(rangeFilterColl);

        if (rangeFilterColl)
        {
            rangeFilterColl->updateDisplayModeNotifyManagedViews(nullptr);
        }

        // Prop Filter

        RimEclipsePropertyFilterCollection* eclipsePropColl;
        parentObj->firstAncestorOrThisOfType(eclipsePropColl);
        
        RimGeoMechPropertyFilterCollection* geoMechPropColl;
        parentObj->firstAncestorOrThisOfType(geoMechPropColl);

        if (view && (eclipsePropColl || geoMechPropColl))
        {
            view->scheduleGeometryRegen(PROPERTY_FILTERED);
            view->scheduleCreateDisplayModelAndRedraw();
        }

        // Intersections

        RimIntersectionCollection* crossSectionColl;
        parentObj->firstAncestorOrThisOfType(crossSectionColl);
        if (view && crossSectionColl)
        {
            crossSectionColl->syncronize2dIntersectionViews();
            view->scheduleCreateDisplayModelAndRedraw();
        }
        else
        {
            RimCase* parentCase = dynamic_cast<RimCase*>(parentObj);
            if ( parentCase ) // A view was deleted. Need to update the list of intersection views
            {
                parentCase->intersectionViewCollection()->syncFromExistingIntersections(true);
            }
        }

        // SimWell Fractures
        RimSimWellInView* simWell;
        parentObj->firstAncestorOrThisOfType(simWell);
        if (view && simWell)
        {
            view->scheduleCreateDisplayModelAndRedraw();
        }

        RimFractureTemplateCollection* fracTemplateColl;
        parentObj->firstAncestorOrThisOfType(fracTemplateColl);
        if (fracTemplateColl)
        {
            RimProject* proj = nullptr;
            parentObj->firstAncestorOrThisOfType(proj);
            if (proj)
            {
                proj->createDisplayModelAndRedrawAllViews();
            }

            std::vector<Rim3dView*> views;
            proj->allVisibleViews(views);
            for (Rim3dView* view : views)
            {
                if (dynamic_cast<RimEclipseView*>(view))
                {
                    view->updateConnectedEditors();
                }
            }
        }


        // Well paths

        RimWellPath* wellPath;
        parentObj->firstAncestorOrThisOfType(wellPath);

        if (wellPath)
        {
            wellPath->updateConnectedEditors();
        }

        RimWellPathCollection* wellPathColl;
        parentObj->firstAncestorOrThisOfType(wellPathColl);

        if (wellPathColl)
        {
            wellPathColl->scheduleRedrawAffectedViews();
            wellPathColl->uiCapability()->updateConnectedEditors();
        }

        // Update due to deletion of curves (not tracks, handled separatly)

        RimWellLogPlot* wellLogPlot;
        parentObj->firstAncestorOrThisOfType(wellLogPlot);
        if (wellLogPlot)
        {
            wellLogPlot->calculateAvailableDepthRange();
            wellLogPlot->updateDepthZoom();
        }

        RimWellLogTrack* wellLogPlotTrack;
        parentObj->firstAncestorOrThisOfType(wellLogPlotTrack);
        if (wellLogPlotTrack)
        {
            wellLogPlotTrack->updateXZoom();
        }
        
        // Update due to delete plots
        // Make sure the plot collection disappears with the last plot

        RimWellLogPlotCollection* wellLogPlotCollection = dynamic_cast<RimWellLogPlotCollection*>(parentObj);
        if (wellLogPlotCollection)
        {
            if (wellLogPlotCollection->wellLogPlots.empty())
            {
                RimProject* project = nullptr;
                parentObj->firstAncestorOrThisOfType(project);
                if (project)
                {
                    project->updateConnectedEditors();
                }
            }
        }
        
        // Linked views

        RimViewLinkerCollection* viewLinkerCollection = nullptr;
        parentObj->firstAncestorOrThisOfType(viewLinkerCollection);
        if (viewLinkerCollection)
        {
            viewLinkerCollection->uiCapability()->updateConnectedEditors();

            RimProject* project = nullptr;
            parentObj->firstAncestorOrThisOfType(project);
            if (project)
            {
                // Update visibility of top level Linked Views item in the project tree
                // Not visible if no views are linked
                project->uiCapability()->updateConnectedEditors();
            }
        }

        // Formation names

        RimFormationNamesCollection* formationNamesCollection;
        parentObj->firstAncestorOrThisOfType(formationNamesCollection);
        if (formationNamesCollection)
        {
            for(caf::PdmObjectHandle* reffingObj :referringObjects)
            {
                RimCase* aCase = dynamic_cast<RimCase*>(reffingObj);
                if (aCase) aCase->updateFormationNamesData();
            }
        }


        RimSummaryPlotCollection* summaryPlotCollection = nullptr;
        parentObj->firstAncestorOrThisOfType(summaryPlotCollection);
        if (summaryPlotCollection)
        {
            summaryPlotCollection->updateSummaryNameHasChanged();
            RiuPlotMainWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow();
            mainPlotWindow->updateSummaryPlotToolBar();
        }

        RimSummaryCrossPlotCollection* summaryCrossPlotCollection = nullptr;
        parentObj->firstAncestorOrThisOfType(summaryCrossPlotCollection);
        if (summaryCrossPlotCollection)
        {
            RiuPlotMainWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow();
            mainPlotWindow->updateSummaryPlotToolBar();
        }

        RimEnsembleCurveSetCollection* ensembleCurveSetColl = nullptr;
        parentObj->firstAncestorOrThisOfType(ensembleCurveSetColl);
        if (ensembleCurveSetColl)
        {
            RimSummaryPlot* plot = nullptr;
            ensembleCurveSetColl->firstAncestorOrThisOfType(plot);
            if (plot) plot->updateConnectedEditors();
        }
    }
}