2015-09-15 08:23:25 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2015- Statoil ASA
|
|
|
|
// Copyright (C) 2015- Ceetron Solutions AS
|
|
|
|
//
|
|
|
|
// 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 "RicAddWellLogToPlotFeature.h"
|
|
|
|
|
2015-09-15 11:21:38 -05:00
|
|
|
#include "RicWellLogPlotCurveFeatureImpl.h"
|
|
|
|
#include "RicNewWellLogPlotFeatureImpl.h"
|
|
|
|
|
2015-09-16 09:06:06 -05:00
|
|
|
#include "RimWellLogFile.h"
|
2015-09-18 02:16:59 -05:00
|
|
|
#include "RimWellLogFileChannel.h"
|
2015-09-15 08:23:25 -05:00
|
|
|
#include "RimWellLogPlot.h"
|
2015-09-18 05:29:23 -05:00
|
|
|
#include "RimWellLogPlotTrack.h"
|
2015-09-15 08:23:25 -05:00
|
|
|
#include "RimWellLogFileCurve.h"
|
|
|
|
#include "RimProject.h"
|
|
|
|
#include "RimMainPlotCollection.h"
|
|
|
|
#include "RimWellLogPlotCollection.h"
|
2015-09-16 08:31:04 -05:00
|
|
|
#include "RimWellPath.h"
|
|
|
|
#include "RimWellPathCollection.h"
|
|
|
|
|
2015-09-15 11:07:53 -05:00
|
|
|
#include "RigWellLogFile.h"
|
2015-09-15 08:23:25 -05:00
|
|
|
|
|
|
|
#include "RiaApplication.h"
|
|
|
|
#include "RiuMainWindow.h"
|
2015-09-18 05:29:23 -05:00
|
|
|
#include "RiuWellLogTrackPlot.h"
|
2015-09-15 08:23:25 -05:00
|
|
|
|
|
|
|
#include "cafSelectionManager.h"
|
2015-09-16 08:31:04 -05:00
|
|
|
#include "cafPdmUiTreeView.h"
|
2015-09-15 08:23:25 -05:00
|
|
|
|
|
|
|
#include <QAction>
|
|
|
|
|
|
|
|
namespace caf
|
|
|
|
{
|
|
|
|
CAF_CMD_SOURCE_INIT(RicAddWellLogToPlotFeature, "RicAddWellLogToPlotFeature");
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RicAddWellLogToPlotFeature::isCommandEnabled()
|
|
|
|
{
|
2015-09-18 02:16:59 -05:00
|
|
|
std::vector<RimWellLogFileChannel*> selection = selectedWellLogs();
|
2015-09-15 08:23:25 -05:00
|
|
|
return selection.size() > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RicAddWellLogToPlotFeature::onActionTriggered(bool isChecked)
|
|
|
|
{
|
2015-09-18 02:16:59 -05:00
|
|
|
std::vector<RimWellLogFileChannel*> selection = selectedWellLogs();
|
2015-09-15 08:23:25 -05:00
|
|
|
if (selection.size() < 1) return;
|
2015-09-16 08:31:04 -05:00
|
|
|
|
2015-09-15 11:21:38 -05:00
|
|
|
RimWellLogPlot* plot = RicNewWellLogPlotFeatureImpl::createWellLogPlot();
|
2015-09-15 08:23:25 -05:00
|
|
|
|
2015-09-18 05:29:23 -05:00
|
|
|
RimWellLogPlotTrack* plotTrack = new RimWellLogPlotTrack();
|
|
|
|
plot->addTrack(plotTrack);
|
2015-09-15 08:23:25 -05:00
|
|
|
|
|
|
|
plot->loadDataAndUpdate();
|
|
|
|
|
2015-09-16 08:31:04 -05:00
|
|
|
caf::PdmUiItem* uiItem = NULL;
|
|
|
|
|
2015-09-15 08:23:25 -05:00
|
|
|
for (size_t wlIdx = 0; wlIdx < selection.size(); wlIdx++)
|
|
|
|
{
|
2015-09-18 02:16:59 -05:00
|
|
|
RimWellLogFileChannel* wellLog = selection[wlIdx];
|
2015-09-15 08:23:25 -05:00
|
|
|
|
2015-09-16 08:31:04 -05:00
|
|
|
RimWellPath* wellPath;
|
|
|
|
wellLog->firstAnchestorOrThisOfType(wellPath);
|
|
|
|
|
2015-09-16 09:06:06 -05:00
|
|
|
RimWellLogFile* wellLogFile;
|
|
|
|
wellLog->firstAnchestorOrThisOfType(wellLogFile);
|
|
|
|
if (wellLogFile)
|
2015-09-15 08:23:25 -05:00
|
|
|
{
|
2015-09-18 05:29:23 -05:00
|
|
|
size_t curveIdx = plotTrack->curveCount();
|
2015-09-15 08:58:22 -05:00
|
|
|
|
2015-09-15 08:23:25 -05:00
|
|
|
RimWellLogFileCurve* curve = new RimWellLogFileCurve;
|
2015-09-18 05:29:23 -05:00
|
|
|
plotTrack->addCurve(curve);
|
2015-09-15 08:23:25 -05:00
|
|
|
|
2015-09-15 11:21:38 -05:00
|
|
|
cvf::Color3f curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromIndex(curveIdx);
|
2015-09-15 08:58:22 -05:00
|
|
|
curve->setColor(curveColor);
|
2015-09-16 08:31:04 -05:00
|
|
|
curve->setWellPath(wellPath);
|
|
|
|
curve->setWellLogChannelName(wellLog->name());
|
2015-09-15 08:58:22 -05:00
|
|
|
|
2015-09-15 08:23:25 -05:00
|
|
|
curve->updatePlotData();
|
2015-09-16 08:31:04 -05:00
|
|
|
|
|
|
|
if (wlIdx == selection.size() - 1)
|
|
|
|
{
|
|
|
|
uiItem = curve;
|
|
|
|
}
|
2015-09-15 08:23:25 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-16 08:31:04 -05:00
|
|
|
plot->updateAvailableDepthRange();
|
2015-09-15 11:07:53 -05:00
|
|
|
plot->setVisibleDepthRangeFromContents();
|
2015-09-18 05:29:23 -05:00
|
|
|
plotTrack->updateXAxisRangeFromCurves();
|
|
|
|
plotTrack->viewer()->replot();
|
2015-09-15 11:07:53 -05:00
|
|
|
|
2015-09-15 08:23:25 -05:00
|
|
|
RiaApplication::instance()->project()->updateConnectedEditors();
|
2015-09-16 08:31:04 -05:00
|
|
|
|
|
|
|
if (uiItem)
|
|
|
|
{
|
|
|
|
RiuMainWindow::instance()->projectTreeView()->selectAsCurrentItem(uiItem);
|
|
|
|
}
|
2015-09-15 08:23:25 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RicAddWellLogToPlotFeature::setupActionLook(QAction* actionToSetup)
|
|
|
|
{
|
|
|
|
actionToSetup->setText("Add To Plot");
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-09-18 02:16:59 -05:00
|
|
|
std::vector<RimWellLogFileChannel*> RicAddWellLogToPlotFeature::selectedWellLogs()
|
2015-09-15 08:23:25 -05:00
|
|
|
{
|
2015-09-18 02:16:59 -05:00
|
|
|
std::vector<RimWellLogFileChannel*> selection;
|
2015-09-15 08:23:25 -05:00
|
|
|
caf::SelectionManager::instance()->objectsByType(&selection);
|
|
|
|
return selection;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // end namespace caf
|