(#436) Refactored curve creation features

Moved common code to new base class.
This commit is contained in:
Pål Hagen 2015-09-15 15:58:22 +02:00
parent e4212a1135
commit e81a1c69c0
7 changed files with 99 additions and 35 deletions

View File

@ -47,6 +47,8 @@ ${CEE_CURRENT_LIST_DIR}RicNewWellLogPlotFeature.h
${CEE_CURRENT_LIST_DIR}RicNewWellLogPlotTraceFeature.h
${CEE_CURRENT_LIST_DIR}RicNewWellLogPlotCurveFeature.h
${CEE_CURRENT_LIST_DIR}RicAddWellLogToPlotFeature.h
${CEE_CURRENT_LIST_DIR}RicWellLogPlotCurveFeatureImpl.h
${CEE_CURRENT_LIST_DIR}RicWellPathsImportSsihubFeature.h
${CEE_CURRENT_LIST_DIR}RicWellPathsImportFileFeature.h
@ -106,6 +108,7 @@ ${CEE_CURRENT_LIST_DIR}RicNewWellLogPlotFeature.cpp
${CEE_CURRENT_LIST_DIR}RicNewWellLogPlotTraceFeature.cpp
${CEE_CURRENT_LIST_DIR}RicNewWellLogPlotCurveFeature.cpp
${CEE_CURRENT_LIST_DIR}RicAddWellLogToPlotFeature.cpp
${CEE_CURRENT_LIST_DIR}RicWellLogPlotCurveFeatureImpl.cpp
${CEE_CURRENT_LIST_DIR}RicWellPathsImportSsihubFeature.cpp
${CEE_CURRENT_LIST_DIR}RicWellPathsImportFileFeature.cpp

View File

@ -73,11 +73,16 @@ void RicAddWellLogToPlotFeature::onActionTriggered(bool isChecked)
wellLog->firstAnchestorOrThisOfType(lasFileInfo);
if (lasFileInfo)
{
size_t curveIdx = plotTrace->curveCount();
RimWellLogFileCurve* curve = new RimWellLogFileCurve;
plotTrace->addCurve(curve);
curve->setCurveData(lasFileInfo->logValues(wellLog->name()), lasFileInfo->depthValues());
cvf::Color3f curveColor = curveColorFromIndex(curveIdx);
curve->setColor(curveColor);
curve->setDescription(wellLog->name());
curve->setCurveData(lasFileInfo->logValues(wellLog->name()), lasFileInfo->depthValues());
curve->updatePlotData();
}
}

View File

@ -20,6 +20,7 @@
#pragma once
#include "cafCmdFeature.h"
#include "RicWellLogPlotCurveFeatureImpl.h"
#include <vector>
@ -34,7 +35,7 @@ namespace caf
//==================================================================================================
///
//==================================================================================================
class RicAddWellLogToPlotFeature : public CmdFeature
class RicAddWellLogToPlotFeature : public CmdFeature, RicWellLogPlotCurveFeatureImpl
{
CAF_CMD_HEADER_INIT;
protected:

View File

@ -25,41 +25,11 @@
#include "RiuMainWindow.h"
#include "cafSelectionManager.h"
#include "cafPdmFieldCvfColor.h"
#include <QAction>
#include <QColor>
#include <vector>
static const int RI_LOGPLOT_CURVECOLORSCOUNT = 15;
static const int RI_LOGPLOT_CURVECOLORS[] =
{
Qt::blue,
Qt::red,
Qt::green,
Qt::yellow,
Qt::magenta,
Qt::cyan,
Qt::gray,
Qt::darkBlue,
Qt::darkRed,
Qt::darkGreen,
Qt::darkYellow,
Qt::darkMagenta,
Qt::darkCyan,
Qt::darkGray,
Qt::black
};
//--------------------------------------------------------------------------------------------------
/// Pick default curve color from an index based palette
//--------------------------------------------------------------------------------------------------
static QColor sg_curveColorFromIndex(size_t curveIndex)
{
return QColor(Qt::GlobalColor(RI_LOGPLOT_CURVECOLORS[curveIndex % RI_LOGPLOT_CURVECOLORSCOUNT]));
}
CAF_CMD_SOURCE_INIT(RicNewWellLogPlotCurveFeature, "RicNewWellLogPlotCurveFeature");
@ -113,8 +83,7 @@ void RicNewWellLogPlotCurveFeature::addCurve(RimWellLogPlotTrace* plotTrace)
RimWellLogPlotCurve* curve = new RimWellLogExtractionCurve();
plotTrace->addCurve(curve);
QColor curveColorQt = sg_curveColorFromIndex(curveIndex);
cvf::Color3f curveColor(curveColorQt.redF(), curveColorQt.greenF(), curveColorQt.blueF());
cvf::Color3f curveColor = curveColorFromIndex(curveIndex);
curve->setColor(curveColor);
curve->setDescription(QString("Curve %1").arg(plotTrace->curveCount()));

View File

@ -20,13 +20,14 @@
#pragma once
#include "cafCmdFeature.h"
#include "RicWellLogPlotCurveFeatureImpl.h"
class RimWellLogPlotTrace;
//==================================================================================================
///
//==================================================================================================
class RicNewWellLogPlotCurveFeature : public caf::CmdFeature
class RicNewWellLogPlotCurveFeature : public caf::CmdFeature, RicWellLogPlotCurveFeatureImpl
{
CAF_CMD_HEADER_INIT;

View File

@ -0,0 +1,53 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicWellLogPlotCurveFeatureImpl.h"
#include <QColor>
static const int RI_LOGPLOT_CURVECOLORSCOUNT = 15;
static const int RI_LOGPLOT_CURVECOLORS[] =
{
Qt::blue,
Qt::red,
Qt::green,
Qt::yellow,
Qt::magenta,
Qt::cyan,
Qt::gray,
Qt::darkBlue,
Qt::darkRed,
Qt::darkGreen,
Qt::darkYellow,
Qt::darkMagenta,
Qt::darkCyan,
Qt::darkGray,
Qt::black
};
//--------------------------------------------------------------------------------------------------
/// Pick default curve color from an index based palette
//--------------------------------------------------------------------------------------------------
cvf::Color3f RicWellLogPlotCurveFeatureImpl::curveColorFromIndex(size_t curveIndex)
{
QColor color = QColor(Qt::GlobalColor(RI_LOGPLOT_CURVECOLORS[curveIndex % RI_LOGPLOT_CURVECOLORSCOUNT]));
cvf::Color3f cvfColor(color.redF(), color.greenF(), color.blueF());
return cvfColor;
}

View File

@ -0,0 +1,32 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafPdmFieldCvfColor.h"
//==================================================================================================
///
//==================================================================================================
class RicWellLogPlotCurveFeatureImpl
{
protected:
static cvf::Color3f curveColorFromIndex(size_t curveIndex);
};