//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- 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(); } } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- 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); } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RicPasteWellLogCurveFeature::onActionTriggered(bool isChecked) { caf::PdmObjectHandle* destinationObject = dynamic_cast<caf::PdmObjectHandle*>(caf::SelectionManager::instance()->selectedItem()); RimWellLogTrack* wellLogTrack = nullptr; destinationObject->firstAncestorOrThisOfType(wellLogTrack); if (!wellLogTrack) { return; } std::vector<caf::PdmPointer<RimWellLogCurve> > sourceObjects = RicPasteWellLogCurveFeature::curves(); for (size_t i = 0; i < sourceObjects.size(); i++) { RimWellLogFileCurve* fileCurve = dynamic_cast<RimWellLogFileCurve*>(sourceObjects[i].p()); if (fileCurve) { RimWellLogFileCurve* newObject = dynamic_cast<RimWellLogFileCurve*>(sourceObjects[i]->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); CVF_ASSERT(newObject); wellLogTrack->addCurve(newObject); // Resolve references after object has been inserted into the project data model newObject->resolveReferencesRecursively(); newObject->initAfterReadRecursively(); newObject->loadDataAndUpdate(); wellLogTrack->updateConnectedEditors(); } RimWellLogExtractionCurve* extractionCurve = dynamic_cast<RimWellLogExtractionCurve*>(sourceObjects[i].p()); if (extractionCurve) { RimWellLogExtractionCurve* newObject = dynamic_cast<RimWellLogExtractionCurve*>(sourceObjects[i]->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); CVF_ASSERT(newObject); wellLogTrack->addCurve(newObject); // Resolve references after object has been inserted into the project data model newObject->resolveReferencesRecursively(); newObject->initAfterReadRecursively(); newObject->loadDataAndUpdate(); wellLogTrack->updateConnectedEditors(); } } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RicWellLogPlotTrackFeatureImpl::moveCurvesToWellLogPlotTrack(RimWellLogTrack* destTrack, const std::vector<RimWellLogCurve*>& curves, RimWellLogCurve* curveToInsertAfter) { CVF_ASSERT(destTrack ); std::set<RimWellLogTrack*> srcTracks; std::set<RimWellLogPlot*> srcPlots; for (size_t cIdx = 0; cIdx < curves.size(); cIdx++) { RimWellLogCurve* curve = curves[cIdx]; RimWellLogTrack* wellLogPlotTrack; curve->firstAncestorOrThisOfType(wellLogPlotTrack); if (wellLogPlotTrack) { wellLogPlotTrack->removeCurve(curve); wellLogPlotTrack->updateConnectedEditors(); srcTracks.insert(wellLogPlotTrack); RimWellLogPlot* plot; wellLogPlotTrack->firstAncestorOrThisOfType(plot); if (plot) srcPlots.insert(plot); } } size_t insertionStartIndex = 0; if (curveToInsertAfter) insertionStartIndex = destTrack->curveIndex(curveToInsertAfter) + 1; for (size_t cIdx = 0; cIdx < curves.size(); cIdx++) { destTrack->insertCurve(curves[cIdx], insertionStartIndex + cIdx); } for (std::set<RimWellLogPlot*>::iterator pIt = srcPlots.begin(); pIt != srcPlots.end(); ++pIt) { (*pIt)->calculateAvailableDepthRange(); } for (std::set<RimWellLogTrack*>::iterator tIt = srcTracks.begin(); tIt != srcTracks.end(); ++tIt) { (*tIt)->updateXZoomAndParentPlotDepthZoom(); } destTrack->loadDataAndUpdate(); destTrack->updateXZoomAndParentPlotDepthZoom(); destTrack->updateConnectedEditors(); }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimWellLogExtractionCurve::setLogScaleFromSelectedResult() { QString resVar = m_eclipseResultDefinition->resultVariable(); if (resVar.toUpper().contains("PERM")) { RimWellLogTrack* track = nullptr; this->firstAncestorOrThisOfType(track); if (track) { if (track->curveCount() == 1) { track->setLogarithmicScale(true); } } } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimWellLogCurve::updateZoomInParentPlot() { RimWellLogPlot* wellLogPlot; firstAncestorOrThisOfType(wellLogPlot); if (wellLogPlot) { wellLogPlot->calculateAvailableDepthRange(); wellLogPlot->updateDepthZoom(); } RimWellLogTrack* plotTrack; firstAncestorOrThisOfType(plotTrack); if (plotTrack) { plotTrack->updateXZoomAndParentPlotDepthZoom(); } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RicNewPltPlotFeature::onActionTriggered(bool isChecked) { RimProject* proj = RiaApplication::instance()->project(); RimPltPlotCollection* pltPlotColl = proj->mainPlotCollection()->pltPlotCollection(); if (pltPlotColl) { QString wellPathName; RimWellPath* wellPath = nullptr; RimSimWellInView* eclipseWell = nullptr; if ((wellPath = caf::firstAncestorOfTypeFromSelectedObject<RimWellPath*>()) != nullptr) { wellPathName = wellPath->name(); } else if ((eclipseWell = caf::firstAncestorOfTypeFromSelectedObject<RimSimWellInView*>()) != nullptr) { RimWellPath* wellPath = proj->wellPathFromSimWellName(eclipseWell->name()); if (!wellPath ) return; wellPathName = wellPath->name(); } QString plotName = QString(RimWellPltPlot::plotNameFormatString()).arg(wellPathName); RimWellPltPlot* pltPlot = new RimWellPltPlot(); pltPlot->setCurrentWellName(wellPathName); RimWellLogTrack* plotTrack = new RimWellLogTrack(); pltPlot->wellLogPlot()->addTrack(plotTrack); plotTrack->setDescription(QString("Track %1").arg(pltPlot->wellLogPlot()->trackCount())); pltPlotColl->addPlot(pltPlot); pltPlot->setDescription(plotName); //pltPlot->applyInitialSelections(); pltPlot->loadDataAndUpdate(); pltPlotColl->updateConnectedEditors(); RiuPlotMainWindowTools::showPlotMainWindow(); RiuPlotMainWindowTools::setExpanded(plotTrack); RiuPlotMainWindowTools::selectAsCurrentItem(pltPlot); } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- 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(); }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- 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(); } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- 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(); } } }