//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RicNewSummaryCurveFeature::onActionTriggered(bool isChecked) { RimProject* project = RiaApplication::instance()->project(); CVF_ASSERT(project); RimSummaryPlot* plot = selectedSummaryPlot(); if (plot) { RimSummaryCurve* newCurve = new RimSummaryCurve(); cvf::Color3f curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromTable(plot->curveCount()); newCurve->setColor(curveColor); plot->addCurveAndUpdate(newCurve); RimSummaryCase* defaultCase = nullptr; if (project->activeOilField()->summaryCaseMainCollection()->summaryCaseCount() > 0) { defaultCase = project->activeOilField()->summaryCaseMainCollection()->summaryCase(0); newCurve->setSummaryCaseY(defaultCase); newCurve->setSummaryAddressY(RifEclipseSummaryAddress::fieldVarAddress("FOPT")); newCurve->loadDataAndUpdate(true); } plot->updateConnectedEditors(); RiaApplication::instance()->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem(newCurve); RiuPlotMainWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); mainPlotWindow->updateSummaryPlotToolBar(); } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RicSummaryCurveCreator::copyCurveAndAddToPlot(const RimSummaryCurve* curve, RimSummaryPlot* plot, bool forceVisible) { RimSummaryCurve* curveCopy = dynamic_cast<RimSummaryCurve*>(curve->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); CVF_ASSERT(curveCopy); if (forceVisible) { curveCopy->setCurveVisiblity(true); } plot->addCurveNoUpdate(curveCopy); // The curve creator is not a descendant of the project, and need to be set manually curveCopy->setSummaryCaseY(curve->summaryCaseY()); curveCopy->initAfterReadRecursively(); curveCopy->loadDataAndUpdate(false); }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimSummaryCurveAutoName::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { // NOTE: The curve filter is parent object of a summary curve, and the update is supposed to update // the first parent, not the grandparent. This is the reason for not using firstAncestorOrThisOfType() RimSummaryCurve* summaryCurve = dynamic_cast<RimSummaryCurve*>(this->parentField()->ownerObject()); if (summaryCurve) { summaryCurve->updateCurveName(); summaryCurve->updateConnectedEditors(); } RimSummaryCurveFilter* summaryCurveFilter = dynamic_cast<RimSummaryCurveFilter*>(this->parentField()->ownerObject()); if (summaryCurveFilter) { summaryCurveFilter->updateCurveNames(); summaryCurveFilter->updateConnectedEditors(); } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RicSummaryCurveCreator::updatePreviewCurvesFromCurveDefinitions( const std::set<RiaSummaryCurveDefinition>& allCurveDefsToDisplay, const std::set<RiaSummaryCurveDefinition>& curveDefsToAdd, const std::set<RimSummaryCurve*>& curvesToDelete) { static bool warningDisplayed = false; RimSummaryCase* prevCase = nullptr; std::set<RiaSummaryCurveDefinition> summaryCurveDefsToDisplay; // Ignore curve sets when assigning colors to singe summary curves for (const auto& def : allCurveDefsToDisplay) { if (!def.isEnsembleCurve()) summaryCurveDefsToDisplay.insert(def); } RimSummaryCurveAppearanceCalculator curveLookCalc( summaryCurveDefsToDisplay, getAllSummaryCaseNames(), getAllSummaryWellNames()); initCurveAppearanceCalculator(curveLookCalc); // Delete curves for (const auto& curve : curvesToDelete) { m_previewPlot->deleteCurve(curve); } size_t ensembleCurveCnt = ensembleCurveCount(allCurveDefsToDisplay); // Add new curves for (const auto& curveDef : curveDefsToAdd) { RimSummaryCase* currentCase = curveDef.summaryCase(); RimSummaryCurve* curve = new RimSummaryCurve(); curve->setSummaryCaseY(currentCase); curve->setSummaryAddressY(curveDef.summaryAddress()); curve->applyCurveAutoNameSettings(*m_curveNameConfig()); if (curveDef.isEnsembleCurve()) { // Find curveSet RimEnsembleCurveSet* curveSet = nullptr; for (const auto& cs : m_previewPlot->ensembleCurveSetCollection()->curveSets()) { if (cs->summaryCaseCollection() == curveDef.ensemble() && cs->summaryAddress() == curveDef.summaryAddress()) { curveSet = cs; break; } } if (!curveSet) { curveSet = new RimEnsembleCurveSet(); curveSet->setSummaryCaseCollection(curveDef.ensemble()); curveSet->setSummaryAddress(curveDef.summaryAddress()); m_previewPlot->ensembleCurveSetCollection()->addCurveSet(curveSet); // Set single curve set color size_t colorIndex = m_previewPlot->ensembleCurveSetCollection()->curveSetCount(); curveSet->setColor(RiaColorTables::summaryCurveDefaultPaletteColors().cycledColor3f(colorIndex)); if (m_previewPlot->ensembleCurveSetCollection()->curveSets().size() > 1 && ensembleCurveCnt > ENSEMBLE_CURVE_COUNT_THRESHOLD) { // Toggle off new curve set and display warning curveSet->showCurves(false); if (!warningDisplayed) { QMessageBox mbox; mbox.setIcon(QMessageBox::Icon::Warning); mbox.setInformativeText( "The new curve set is hidden. Too many visible curve sets may lead to poor performance"); mbox.exec(); warningDisplayed = true; } } } curveSet->addCurve(curve); } else { m_previewPlot->addCurveNoUpdate(curve); curveLookCalc.setupCurveLook(curve); } } m_previewPlot->loadDataAndUpdate(); m_previewPlot->zoomAll(); m_previewPlot->updateConnectedEditors(); m_previewPlot->summaryCurveCollection()->updateConnectedEditors(); }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- QString RimSummaryCurveAutoName::curveName(const RifEclipseSummaryAddress& summaryAddress) const { std::string text; RimSummaryCurve* summaryCurve = nullptr; this->firstAncestorOrThisOfType(summaryCurve); if (m_vectorName) { text += summaryAddress.quantityName(); if (m_unit && summaryCurve) { text += "[" + summaryCurve->unitName() + "]"; } } switch (summaryAddress.category()) { case RifEclipseSummaryAddress::SUMMARY_REGION: { if (m_regionNumber) { if (text.size() > 0) text +=":"; text += std::to_string(summaryAddress.regionNumber()); } } break; case RifEclipseSummaryAddress::SUMMARY_REGION_2_REGION: { if (m_regionNumber) { if (text.size() > 0) text += ":"; text += std::to_string(summaryAddress.regionNumber()); text += "-" + std::to_string(summaryAddress.regionNumber2()); } } break; case RifEclipseSummaryAddress::SUMMARY_WELL_GROUP: { if (m_wellGroupName) { if (text.size() > 0) text += ":"; text += summaryAddress.wellGroupName(); } } break; case RifEclipseSummaryAddress::SUMMARY_WELL: { appendWellName(text, summaryAddress); } break; case RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION: { appendWellName(text, summaryAddress); if (m_completion) { if (text.size() > 0) text += ":"; text += std::to_string(summaryAddress.cellI()) + ", " + std::to_string(summaryAddress.cellJ()) + ", " + std::to_string(summaryAddress.cellK()); } } break; case RifEclipseSummaryAddress::SUMMARY_WELL_LGR: { appendLgrName(text, summaryAddress); appendWellName(text, summaryAddress); } break; case RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION_LGR: { appendLgrName(text, summaryAddress); appendWellName(text, summaryAddress); if (m_completion) { if (text.size() > 0) text += ":"; text += std::to_string(summaryAddress.cellI()) + ", " + std::to_string(summaryAddress.cellJ()) + ", " + std::to_string(summaryAddress.cellK()); } } break; case RifEclipseSummaryAddress::SUMMARY_WELL_SEGMENT: { appendWellName(text, summaryAddress); if (m_wellSegmentNumber) { if (text.size() > 0) text += ":"; text += ":" + summaryAddress.wellSegmentNumber(); } } break; case RifEclipseSummaryAddress::SUMMARY_BLOCK: { if (m_completion) { if (text.size() > 0) text += ":"; text += std::to_string(summaryAddress.cellI()) + ", " + std::to_string(summaryAddress.cellJ()) + ", " + std::to_string(summaryAddress.cellK()); } } break; case RifEclipseSummaryAddress::SUMMARY_BLOCK_LGR: { appendLgrName(text, summaryAddress); if (m_completion) { if (text.size() > 0) text += ":"; text += std::to_string(summaryAddress.cellI()) + ", " + std::to_string(summaryAddress.cellJ()) + ", " + std::to_string(summaryAddress.cellK()); } } break; } if (summaryCurve) { if (m_caseName) { if (summaryCurve && summaryCurve->summaryCase()) { if (text.size() > 0) text += ", "; text += summaryCurve->summaryCase()->caseName().toStdString(); } } } return QString::fromStdString(text); }