(#632) Improved colors used for selection and time history curves

This commit is contained in:
Magne Sjaastad
2015-11-10 09:43:56 +01:00
parent 2f70abb90d
commit 17493070ac
7 changed files with 115 additions and 9 deletions

View File

@@ -94,6 +94,8 @@ set( USER_INTERFACE_FILES
UserInterface/RiuTimeHistoryQwtPlot.cpp
UserInterface/RiuSelectionManager.h
UserInterface/RiuSelectionManager.cpp
UserInterface/RiuSelectionColors.h
UserInterface/RiuSelectionColors.cpp
)
set( SOCKET_INTERFACE_FILES

View File

@@ -0,0 +1,57 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RiuSelectionColors.h"
#include <QColor>
static const int RI_SELECTION_COLOR_COUNT = 7;
static const int RI_SELECTION_COLOR[] =
{
Qt::magenta,
Qt::cyan,
Qt::blue,
Qt::red,
Qt::green,
Qt::yellow,
Qt::gray
};
static int riuSelectionColorIndex = 0;
//--------------------------------------------------------------------------------------------------
/// Pick default curve color from an index based palette
//--------------------------------------------------------------------------------------------------
cvf::Color3f RiuSelectionColors::curveColorFromTable()
{
QColor color = QColor(Qt::GlobalColor(RI_SELECTION_COLOR[riuSelectionColorIndex % RI_SELECTION_COLOR_COUNT]));
++riuSelectionColorIndex;
cvf::Color3f cvfColor(color.redF(), color.greenF(), color.blueF());
return cvfColor;
}
//--------------------------------------------------------------------------------------------------
/// Color rarely present in result value colors
//--------------------------------------------------------------------------------------------------
cvf::Color3f RiuSelectionColors::singleCurveColor()
{
riuSelectionColorIndex = 0;
return curveColorFromTable();
}

View File

@@ -0,0 +1,33 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "cvfBase.h"
#include "cvfColor3.h"
//==================================================================================================
///
//==================================================================================================
class RiuSelectionColors
{
public:
static cvf::Color3f curveColorFromTable();
static cvf::Color3f singleCurveColor();
};

View File

@@ -69,6 +69,14 @@ void RiuSelectionManager::deleteAllItems()
m_selection.clear();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuSelectionManager::isEmpty() const
{
return m_selection.size() == 0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -54,6 +54,8 @@ public:
// Deletes all items in the SelectionManager
void deleteAllItems();
bool isEmpty() const;
private:
std::vector < RiuSelectionItem* > m_selection;
};

View File

@@ -21,10 +21,9 @@
#include "RigCurveDataTools.h"
#include "WellLogCommands/RicWellLogPlotCurveFeatureImpl.h"
#include "RiuLineSegmentQwtPlotCurve.h"
#include "cvfBase.h"
#include "cvfAssert.h"
#include "cvfColor3.h"

View File

@@ -25,13 +25,14 @@
#include "Commands/WellLogCommands/RicNewWellLogFileCurveFeature.h"
#include "Commands/WellLogCommands/RicNewWellLogCurveExtractionFeature.h"
#include "RigCaseData.h"
#include "RigCaseCellResultsData.h"
#include "RigCaseData.h"
#include "RigFemPartCollection.h"
#include "RigFemPartGrid.h"
#include "RigGeoMechCaseData.h"
#include "RigTimeHistoryResultAccessor.h"
#include "RigFemTimeHistoryResultAccessor.h"
#include "RimCellRangeFilter.h"
#include "RimCellRangeFilterCollection.h"
#include "RimEclipseCase.h"
@@ -50,13 +51,15 @@
#include "RimProject.h"
#include "RimView.h"
#include "RimViewController.h"
#include "RimWellLogFile.h"
#include "RimWellPath.h"
#include "RimWellPathCollection.h"
#include "RimWellLogFile.h"
#include "RiuFemResultTextBuilder.h"
#include "RiuMainWindow.h"
#include "RiuResultTextBuilder.h"
#include "RiuSelectionColors.h"
#include "RiuSelectionManager.h"
#include "RiuTimeHistoryQwtPlot.h"
#include "RiuViewer.h"
@@ -77,9 +80,6 @@
#include <QMenu>
#include <QMouseEvent>
#include <QStatusBar>
#include "RigFemTimeHistoryResultAccessor.h"
#include "RiuSelectionManager.h"
#include "WellLogCommands/RicWellLogPlotCurveFeatureImpl.h"
//==================================================================================================
//
@@ -570,7 +570,6 @@ void RiuViewerCommands::addTimeHistoryCurve(RimEclipseView* eclipseView, size_t
std::vector<double> timeHistoryValues = timeHistResultAccessor.timeHistoryValues();
CVF_ASSERT(timeStepDates.size() == timeHistoryValues.size());
cvf::Color3f curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromTable();
std::vector<RiuSelectionItem*> items;
RiuSelectionManager::instance()->selectedItems(items);
@@ -596,6 +595,12 @@ void RiuViewerCommands::addTimeHistoryCurve(RimEclipseView* eclipseView, size_t
RiuSelectionManager::instance()->deleteAllItems();
}
cvf::Color3f curveColor = RiuSelectionColors::curveColorFromTable();
if (RiuSelectionManager::instance()->isEmpty())
{
curveColor = RiuSelectionColors::singleCurveColor();
}
RiuSelectionManager::instance()->appendItemToSelection(new RiuEclipseSelectionItem(eclipseView, gridIndex, cellIndex, curveColor));
mainWnd->timeHistoryPlot()->addCurve(curveName, curveColor, timeStepDates, timeHistoryValues);
@@ -639,7 +644,7 @@ void RiuViewerCommands::addTimeHistoryCurve(RimGeoMechView* geoMechView, size_t
CVF_ASSERT(frameTimes.size() == timeHistoryValues.size());
cvf::Color3f curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromTable();
cvf::Color3f curveColor = RiuSelectionColors::curveColorFromTable();
RiuMainWindow* mainWnd = RiuMainWindow::instance();