ResInsight/ApplicationCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.cpp

139 lines
4.7 KiB
C++
Raw Normal View History

/////////////////////////////////////////////////////////////////////////////////
//
// 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"
#include "RicWellLogPlotCurveFeatureImpl.h"
#include "RicNewWellLogPlotFeatureImpl.h"
#include "RimMainPlotCollection.h"
#include "RimProject.h"
#include "RimWellLogFile.h"
2015-09-18 02:16:59 -05:00
#include "RimWellLogFileChannel.h"
#include "RimWellLogFileCurve.h"
#include "RimWellLogPlot.h"
#include "RimWellLogPlotCollection.h"
#include "RimWellLogTrack.h"
#include "RimWellPath.h"
#include "RimWellPathCollection.h"
#include "RiuMainPlotWindow.h"
#include "RigWellLogFile.h"
#include "RiaApplication.h"
#include "RiuWellLogTrack.h"
#include "cafSelectionManager.h"
#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();
return selection.size() > 0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicAddWellLogToPlotFeature::onActionTriggered(bool isChecked)
{
2015-09-18 02:16:59 -05:00
std::vector<RimWellLogFileChannel*> selection = selectedWellLogs();
if (selection.size() < 1) return;
RimWellLogPlot* plot = RicNewWellLogPlotFeatureImpl::createWellLogPlot();
RimWellLogTrack* plotTrack = new RimWellLogTrack();
2015-09-18 05:29:23 -05:00
plot->addTrack(plotTrack);
plotTrack->setDescription(QString("Track %1").arg(plot->trackCount()));
plot->loadDataAndUpdate();
for (size_t wlIdx = 0; wlIdx < selection.size(); wlIdx++)
{
2015-09-18 02:16:59 -05:00
RimWellLogFileChannel* wellLog = selection[wlIdx];
RimWellPath* wellPath = NULL;
wellLog->firstAncestorOrThisOfType(wellPath);
RimWellLogFile* wellLogFile = NULL;
wellLog->firstAncestorOrThisOfType(wellLogFile);
if (wellLogFile)
{
RimWellLogFileCurve* curve = new RimWellLogFileCurve;
2015-09-18 05:29:23 -05:00
plotTrack->addCurve(curve);
RigWellLogFile* wellLogDataFile = wellLogFile->wellLogFile();
CVF_ASSERT(wellLogDataFile);
if (wlIdx == 0)
{
// Initialize plot with depth unit from the first log file
plot->setDepthUnit(wellLogDataFile->depthUnit());
}
cvf::Color3f curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromTable();
curve->setColor(curveColor);
curve->setWellPath(wellPath);
curve->setWellLogChannelName(wellLog->name());
curve->loadDataAndUpdate();
}
}
plot->calculateAvailableDepthRange();
plot->updateDepthZoom();
2015-09-18 05:29:23 -05:00
plotTrack->viewer()->replot();
// Make sure the summary plot window is created and visible
RiuMainPlotWindow* plotwindow = RiaApplication::instance()->getOrCreateAndShowMainPlotWindow();
RiaApplication::instance()->project()->updateConnectedEditors();
plotwindow->selectAsCurrentItem(selection.back());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicAddWellLogToPlotFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Add To New Plot");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2015-09-18 02:16:59 -05:00
std::vector<RimWellLogFileChannel*> RicAddWellLogToPlotFeature::selectedWellLogs()
{
2015-09-18 02:16:59 -05:00
std::vector<RimWellLogFileChannel*> selection;
caf::SelectionManager::instance()->objectsByType(&selection);
return selection;
}
} // end namespace caf