///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2016 Statoil ASA // // 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 // for more details. // ///////////////////////////////////////////////////////////////////////////////// #include "RicChangeDataSourceFeature.h" #include "RicChangeDataSourceFeatureUi.h" #include "RicWellLogPlotCurveFeatureImpl.h" #include "RimCase.h" #include "RimWellLogCurve.h" #include "RimWellLogExtractionCurve.h" #include "RimWellPath.h" #include "cafPdmUiPropertyViewDialog.h" #include CAF_CMD_SOURCE_INIT(RicChangeDataSourceFeature, "RicChangeDataSourceFeature"); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- bool RicChangeDataSourceFeature::isCommandEnabled() { if (RicWellLogPlotCurveFeatureImpl::parentWellAllocationPlot()) return false; std::vector extrCurves = extractionCurves(); return extrCurves.size() > 0; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RicChangeDataSourceFeature::onActionTriggered(bool isChecked) { if (RicWellLogPlotCurveFeatureImpl::parentWellAllocationPlot()) return; std::vector extrCurves = extractionCurves(); if (extrCurves.size() == 0) return; RicChangeDataSourceFeatureUi featureUi; featureUi.wellPathToApply = extrCurves[0]->wellPath(); featureUi.caseToApply = extrCurves[0]->rimCase(); caf::PdmUiPropertyViewDialog propertyDialog(nullptr, &featureUi, "Change Data Source for Selected Curves", ""); propertyDialog.resize(QSize(500, 200)); if (propertyDialog.exec() == QDialog::Accepted) { for (RimWellLogExtractionCurve* extractionCurve : extrCurves) { extractionCurve->setWellPath(featureUi.wellPathToApply); extractionCurve->setCase(featureUi.caseToApply); extractionCurve->loadDataAndUpdate(); } } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RicChangeDataSourceFeature::setupActionLook(QAction* actionToSetup) { actionToSetup->setText("Change Data Source"); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- std::vector RicChangeDataSourceFeature::extractionCurves() { std::vector extrCurves; std::vector curves = RicWellLogPlotCurveFeatureImpl::selectedWellLogCurves(); for (RimWellLogCurve* c : curves) { if (dynamic_cast(c)) { extrCurves.push_back(dynamic_cast(c)); } } return extrCurves; }