Added a GUI theme selector in preferences and a new class for handling GUI changes.

Added a new feature for editing style sheets and variable colors and see immediately the result.
Made Qwt plots (and items) stylable.
Added icons, improved styling possibilities of QMinimizePanel, fixed minor bugs in RicThemeColorEditorFeature.
This commit is contained in:
Ruben Manuel Thoms
2020-09-04 17:10:55 +02:00
committed by Gaute Lindkvist
parent 66ec3212c0
commit 87bc6acd65
50 changed files with 3178 additions and 308 deletions

View File

@@ -93,6 +93,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiuAbstractLegendFrame.h
${CMAKE_CURRENT_LIST_DIR}/RiuCategoryLegendFrame.h
${CMAKE_CURRENT_LIST_DIR}/RiuScalarMapperLegendFrame.h
${CMAKE_CURRENT_LIST_DIR}/RiuFileDialogTools.h
${CMAKE_CURRENT_LIST_DIR}/RiuGuiTheme.h
)
set (SOURCE_GROUP_SOURCE_FILES
@@ -185,6 +186,9 @@ ${CMAKE_CURRENT_LIST_DIR}/RiuAbstractLegendFrame.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuCategoryLegendFrame.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuScalarMapperLegendFrame.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuFileDialogTools.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuGuiTheme.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuQssSyntaxHighlighter.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuTextEditWithCompletion.cpp
)
list(APPEND CODE_HEADER_FILES
@@ -240,6 +244,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RiuAbstractOverlayContentFrame.h
${CMAKE_CURRENT_LIST_DIR}/RiuAbstractLegendFrame.h
${CMAKE_CURRENT_LIST_DIR}/RiuCategoryLegendFrame.h
${CMAKE_CURRENT_LIST_DIR}/RiuScalarMapperLegendFrame.h
${CMAKE_CURRENT_LIST_DIR}/RiuQssSyntaxHighlighter.h
${CMAKE_CURRENT_LIST_DIR}/RiuTextEditWithCompletion.h
)
list(APPEND QT_UI_FILES

View File

@@ -140,9 +140,9 @@ RiuFlowCharacteristicsPlot::RiuFlowCharacteristicsPlot( RimFlowCharacteristicsPl
void RiuFlowCharacteristicsPlot::addWindowZoom( QwtPlot* plot )
{
auto zoomer = new RiuQwtPlotZoomer( plot->canvas() );
zoomer->setRubberBandPen( QColor( Qt::black ) );
// zoomer->setRubberBandPen( QColor( Qt::black ) );
zoomer->setTrackerMode( QwtPicker::AlwaysOff );
zoomer->setTrackerPen( QColor( Qt::black ) );
// zoomer->setTrackerPen( QColor( Qt::black ) );
zoomer->initMousePattern( 1 );
}
//--------------------------------------------------------------------------------------------------

View File

@@ -0,0 +1,916 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2020 Equinor 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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RiuGuiTheme.h"
#include "RiuThemesDirectory.h"
#include "RiaGuiApplication.h"
#include "RiaPreferences.h"
#include "cafAppEnum.h"
#include <QAbstractItemModel>
#include <QColor>
#include <QCompleter>
#include <QFile>
#include <QFileInfo>
#include <QIODevice>
#include <QRegExp>
#include <QRegularExpression>
#include <QString>
#include <QStringListModel>
#include <QStyle>
#include <QWidget>
#include "qwt_legend_label.h"
#include "qwt_picker.h"
#include "qwt_plot.h"
#include "qwt_plot_curve.h"
#include "qwt_plot_grid.h"
#include "qwt_plot_marker.h"
#include "qwt_symbol.h"
namespace caf
{
template <>
void caf::AppEnum<RiuGuiTheme::ThemeEnum>::setUp()
{
addItem( RiuGuiTheme::ThemeEnum::DEFAULT, "DEFAULT", "Default theme" );
addItem( RiuGuiTheme::ThemeEnum::DARK, "DARK", "Dark theme" );
addItem( RiuGuiTheme::ThemeEnum::LIGHT, "LIGHT", "Light theme" );
setDefault( RiuGuiTheme::ThemeEnum::DEFAULT );
}
} // End namespace caf
QMap<RiuGuiTheme::ThemeEnum, QMap<QString, QString>> RiuGuiTheme::s_variableValueMap = {};
QMap<RiuGuiTheme::ThemeEnum, QMap<QString, QString>> RiuGuiTheme::s_variableGuiTextMap = {};
QMap<QString, QMap<QString, QMap<QString, QMap<QString, QString>>>> RiuGuiTheme::s_qwtPlotItemPropertiesMap = {};
QMap<QString, CustomStyleSheetApplicator> RiuGuiTheme::s_customStyleSheetApplicators =
{ { QString(
"QwtPlot\\[\"(?<plotName>[a-zA-Z0-9-_\\*]+)\"\\]::curve\\[\"(?<itemName>[a-zA-Z0-9-_\\*]+)\"\\]\\s*\\{("
"?<properties>([\\n\\r]*\\s*((line-color|symbol-color):"
"\\s*([a-zA-Z0-9#]+)\\s*;))*)[\\n\\r]*\\s*\\}" ),
[]( QRegularExpressionMatch& match ) {
QRegExp plotNameRegExp( match.captured( "plotName" ) );
QRegExp itemNameRegExp( match.captured( "itemName" ) );
QRegularExpression lineColorRegExp( "line-color:\\s*([#0-9a-zA-Z]+)" );
QString lineColor = lineColorRegExp.match( match.captured( "properties" ) ).captured( 1 );
QRegularExpression symbolColorRegExp( "symbol-color:\\s*([#0-9a-zA-Z]+)" );
QString symbolColor = symbolColorRegExp.match( match.captured( "properties" ) ).captured( 1 );
if ( !lineColor.isEmpty() )
{
storeQwtStyleSheetProperty( match.captured( "plotName" ),
QString( "curve" ),
match.captured( "itemName" ),
"line-color",
lineColor );
}
if ( !symbolColor.isEmpty() )
{
// Symbols get the same color assigned as curves.
storeQwtStyleSheetProperty( match.captured( "plotName" ),
QString( "curve" ),
match.captured( "itemName" ),
"symbol-color",
symbolColor );
}
if ( lineColor.isEmpty() && symbolColor.isEmpty() ) return;
const QWidgetList topLevelWidgets = RiaGuiApplication::instance()->topLevelWidgets();
for ( QWidget* widget : topLevelWidgets )
{
for ( QwtPlot* plotWidget : widget->findChildren<QwtPlot*>() )
{
if ( plotNameRegExp.exactMatch( plotWidget->property( "qss-class" ).toString() ) )
{
for ( QwtPlotItem* item : plotWidget->itemList() )
{
if ( QwtPlotCurve* curve = dynamic_cast<QwtPlotCurve*>( item ) )
{
if ( itemNameRegExp.exactMatch( item->title().text() ) ||
match.captured( "itemName" ) == "*" )
{
QPen pen = curve->pen();
pen.setColor( QColor( lineColor ) );
curve->setPen( pen );
if ( curve->symbol() && curve->symbol()->style() != QwtSymbol::NoSymbol )
{
QPen pen = curve->symbol()->pen();
pen.setColor( QColor( symbolColor ) );
QwtSymbol* symbol = cloneCurveSymbol( curve );
symbol->setPen( pen );
curve->setSymbol( symbol );
}
}
}
}
}
plotWidget->replot();
}
}
} },
{ QString( "QwtPlot\\[\"(?<plotName>[a-zA-Z0-9-_\\*]+)\"\\]::grid\\[\"(?<itemName>[a-zA-Z0-9-_\\*]+)\"\\]\\s*\\{("
"?<properties>([\\n\\r]*\\s*((color):"
"\\s*([a-zA-Z0-9#]+)\\s*;))*)[\\n\\r]*\\s*\\}" ),
[]( QRegularExpressionMatch& match ) {
QRegExp plotNameRegExp( match.captured( "plotName" ) );
QRegExp itemNameRegExp( match.captured( "itemName" ) );
QRegularExpression colorRegExp( "color:\\s*([#0-9a-zA-Z]+)" );
QString color = colorRegExp.match( match.captured( "properties" ) ).captured( 1 );
const QWidgetList topLevelWidgets = RiaGuiApplication::instance()->topLevelWidgets();
if ( !color.isEmpty() )
{
storeQwtStyleSheetProperty( match.captured( "plotName" ),
QString( "grid" ),
match.captured( "itemName" ),
"color",
color );
}
for ( QWidget* widget : topLevelWidgets )
{
for ( QwtPlot* plotWidget : widget->findChildren<QwtPlot*>() )
{
if ( plotNameRegExp.exactMatch( plotWidget->property( "qss-class" ).toString() ) ||
match.captured( "plotName" ) == "*" )
{
for ( QwtPlotItem* item : plotWidget->itemList() )
{
if ( QwtPlotGrid* grid = dynamic_cast<QwtPlotGrid*>( item ) )
{
if ( itemNameRegExp.exactMatch( item->title().text() ) ||
match.captured( "itemName" ) == "*" )
{
QPen pen = grid->majorPen();
pen.setColor( QColor( color ) );
grid->setPen( pen );
}
}
}
}
plotWidget->replot();
}
}
} },
{ QString( "QwtPlot\\[\"(?<plotName>[a-zA-Z0-9-_\\*]+)\"\\]::legend\\s*\\{("
"?<properties>([\\n\\r]*\\s*((text-color):"
"\\s*([a-zA-Z0-9#]+)\\s*;))*)[\\n\\r]*\\s*\\}" ),
[]( QRegularExpressionMatch& match ) {
QRegExp plotNameRegExp( match.captured( "plotName" ) );
QRegExp itemNameRegExp( match.captured( "itemName" ) );
QRegularExpression colorRegExp( "text-color:\\s*([#0-9a-zA-Z]+)" );
QString color = colorRegExp.match( match.captured( "properties" ) ).captured( 1 );
const QWidgetList topLevelWidgets = RiaGuiApplication::instance()->topLevelWidgets();
if ( !color.isEmpty() )
{
storeQwtStyleSheetProperty( match.captured( "plotName" ),
QString( "legend" ),
match.captured( "itemName" ),
"text-color",
color );
}
for ( QWidget* widget : topLevelWidgets )
{
for ( QwtPlot* plotWidget : widget->findChildren<QwtPlot*>() )
{
if ( plotNameRegExp.exactMatch( plotWidget->property( "qss-class" ).toString() ) ||
match.captured( "plotName" ) == "*" )
{
for ( QwtLegendLabel* label : plotWidget->findChildren<QwtLegendLabel*>() )
{
QwtText text = label->text();
text.setColor( QColor( color ) );
label->setText( text );
label->repaint();
}
}
plotWidget->replot();
}
}
} },
{ QString( "QwtPlot\\[\"(?<plotName>[a-zA-Z0-9-_\\*]+)\"\\]::lineMarker\\[\"(?<itemName>[a-zA-Z0-9-_\\*]+)\"\\]"
"\\s*\\{("
"?<properties>([\\n\\r]*\\s*((color|text-color):"
"\\s*([a-zA-Z0-9#]+)\\s*;))*)[\\n\\r]*\\s*\\}" ),
[]( QRegularExpressionMatch& match ) {
QRegExp plotNameRegExp( match.captured( "plotName" ) );
QRegExp itemNameRegExp( match.captured( "itemName" ) );
QRegularExpression colorRegExp( "color:\\s*([#0-9a-zA-Z]+)" );
QString color = colorRegExp.match( match.captured( "properties" ) ).captured( 1 );
QRegularExpression textColorRegExp( "text-color:\\s*([#0-9a-zA-Z]+)" );
QString textColor = textColorRegExp.match( match.captured( "properties" ) ).captured( 1 );
const QWidgetList topLevelWidgets = RiaGuiApplication::instance()->topLevelWidgets();
if ( !color.isEmpty() )
{
storeQwtStyleSheetProperty( match.captured( "plotName" ),
QString( "lineMarker" ),
match.captured( "itemName" ),
"color",
color );
}
if ( !textColor.isEmpty() )
{
storeQwtStyleSheetProperty( match.captured( "plotName" ),
QString( "lineMarker" ),
match.captured( "itemName" ),
"text-color",
textColor );
}
for ( QWidget* widget : topLevelWidgets )
{
for ( QwtPlot* plotWidget : widget->findChildren<QwtPlot*>() )
{
if ( plotNameRegExp.exactMatch( plotWidget->property( "qss-class" ).toString() ) ||
match.captured( "plotName" ) == "*" )
{
for ( QwtPlotItem* item : plotWidget->itemList() )
{
if ( QwtPlotMarker* marker = dynamic_cast<QwtPlotMarker*>( item ) )
{
if ( marker->symbol() == nullptr || marker->symbol()->style() == QwtSymbol::NoSymbol )
{
if ( itemNameRegExp.exactMatch( item->title().text() ) ||
match.captured( "itemName" ) == "*" )
{
QPen pen = marker->linePen();
pen.setColor( QColor( color ) );
marker->setLinePen( pen );
marker->label().setColor( QColor( textColor ) );
}
}
}
}
}
plotWidget->replot();
}
}
} },
{ QString( "QwtPlot\\[\"(?<plotName>[a-zA-Z0-9-_\\*]+)\"\\]::pointMarker\\[\"(?<itemName>[a-zA-Z0-9-_\\*]+)\"\\]"
"\\s*\\{("
"?<properties>([\\n\\r]*\\s*((color|text-color):"
"\\s*([a-zA-Z0-9#]+)\\s*;))*)[\\n\\r]*\\s*\\}" ),
[]( QRegularExpressionMatch& match ) {
QRegExp plotNameRegExp( match.captured( "plotName" ) );
QRegExp itemNameRegExp( match.captured( "itemName" ) );
QRegularExpression colorRegExp( "color:\\s*([#0-9a-zA-Z]+)" );
QString color = colorRegExp.match( match.captured( "properties" ) ).captured( 1 );
QRegularExpression textColorRegExp( "text-color:\\s*([#0-9a-zA-Z]+)" );
QString textColor = textColorRegExp.match( match.captured( "properties" ) ).captured( 1 );
const QWidgetList topLevelWidgets = RiaGuiApplication::instance()->topLevelWidgets();
if ( !color.isEmpty() )
{
storeQwtStyleSheetProperty( match.captured( "plotName" ),
QString( "pointMarker" ),
match.captured( "itemName" ),
"color",
color );
}
if ( !textColor.isEmpty() )
{
storeQwtStyleSheetProperty( match.captured( "plotName" ),
QString( "pointMarker" ),
match.captured( "itemName" ),
"text-color",
textColor );
}
for ( QWidget* widget : topLevelWidgets )
{
for ( QwtPlot* plotWidget : widget->findChildren<QwtPlot*>() )
{
if ( plotNameRegExp.exactMatch( plotWidget->property( "qss-class" ).toString() ) ||
match.captured( "plotName" ) == "*" )
{
for ( QwtPlotItem* item : plotWidget->itemList() )
{
if ( QwtPlotMarker* marker = dynamic_cast<QwtPlotMarker*>( item ) )
{
if ( marker->symbol() && marker->symbol()->style() != QwtSymbol::NoSymbol )
{
if ( itemNameRegExp.exactMatch( item->title().text() ) ||
match.captured( "itemName" ) == "*" )
{
QPen pen = marker->symbol()->pen();
pen.setColor( QColor( color ) );
QwtSymbol* symbol = cloneMarkerSymbol( marker );
symbol->setPen( pen );
marker->setSymbol( symbol );
marker->label().setColor( QColor( textColor ) );
}
}
}
}
}
plotWidget->replot();
}
}
} },
{ QString( "QwtPlot\\[\"(?<plotName>[a-zA-Z0-9-_\\*]+)\"\\]::picker"
"\\s*\\{("
"?<properties>([\\n\\r]*\\s*((text-color):"
"\\s*([a-zA-Z0-9#]+)\\s*;))*)[\\n\\r]*\\s*\\}" ),
[]( QRegularExpressionMatch& match ) {
QRegExp plotNameRegExp( match.captured( "plotName" ) );
QRegExp itemNameRegExp( match.captured( "itemName" ) );
QRegularExpression textColorRegExp( "text-color:\\s*([#a-zA-Z0-9]+)" );
QString textColor = textColorRegExp.match( match.captured( "properties" ) ).captured( 1 );
const QWidgetList topLevelWidgets = RiaGuiApplication::instance()->topLevelWidgets();
if ( !textColor.isEmpty() )
{
storeQwtStyleSheetProperty( match.captured( "plotName" ), QString( "picker" ), "*", "text-color", textColor );
}
for ( QWidget* widget : topLevelWidgets )
{
for ( QwtPlot* plotWidget : widget->findChildren<QwtPlot*>() )
{
if ( plotNameRegExp.exactMatch( plotWidget->property( "qss-class" ).toString() ) ||
match.captured( "plotName" ) == "*" )
{
QWidget* canvas = plotWidget->canvas();
if ( canvas )
{
for ( QwtPicker* picker : canvas->findChildren<QwtPicker*>() )
{
QPen pen = picker->trackerPen();
pen.setColor( QColor( textColor ) );
picker->setTrackerPen( pen );
}
}
}
plotWidget->replot();
}
}
} } };
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuGuiTheme::updateGuiTheme( ThemeEnum theme )
{
s_qwtPlotItemPropertiesMap.clear();
applyStyleSheet( theme );
const QWidgetList allWidgets = RiaGuiApplication::instance()->allWidgets();
for ( QWidget* widget : allWidgets )
{
widget->style()->unpolish( widget );
widget->style()->polish( widget );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuGuiTheme::applyStyleSheet( ThemeEnum theme )
{
QString styleSheetPath = getStyleSheetPath( theme );
QFile styleSheetFile( styleSheetPath );
if ( styleSheetFile.exists() )
{
if ( styleSheetFile.open( QIODevice::ReadOnly ) )
{
RiaGuiApplication* app = RiaGuiApplication::instance();
QString styleSheet = styleSheetFile.readAll();
preparseStyleSheet( theme, styleSheet );
app->setStyleSheet( styleSheet );
styleSheetFile.close();
}
return true;
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuGuiTheme::changeVariableValue( RiuGuiTheme::ThemeEnum theme, const QString& variableName, const QString& newValue )
{
if ( !s_variableValueMap.keys().contains( theme ) )
{
s_variableValueMap.insert( theme, {} );
}
if ( !s_variableValueMap[theme].keys().contains( variableName ) )
{
s_variableValueMap[theme].insert( variableName, newValue );
}
else
{
s_variableValueMap[theme][variableName] = newValue;
}
}
QMap<QString, QString> RiuGuiTheme::getVariableValueMap( RiuGuiTheme::ThemeEnum theme )
{
if ( !s_variableValueMap.keys().contains( theme ) )
{
QFile styleSheetFile( getStyleSheetPath( theme ) );
if ( styleSheetFile.exists() )
{
if ( styleSheetFile.open( QIODevice::ReadOnly ) )
{
QString styleSheet = styleSheetFile.readAll();
preparseStyleSheet( theme, styleSheet );
styleSheetFile.close();
return s_variableValueMap[theme];
}
}
return QMap<QString, QString>();
}
else
{
return s_variableValueMap[theme];
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QMap<QString, QString> RiuGuiTheme::getVariableGuiTextMap( RiuGuiTheme::ThemeEnum theme )
{
if ( !s_variableGuiTextMap.keys().contains( theme ) )
{
QFile styleSheetFile( getStyleSheetPath( theme ) );
if ( styleSheetFile.exists() )
{
if ( styleSheetFile.open( QIODevice::ReadOnly ) )
{
QString styleSheet = styleSheetFile.readAll();
preparseStyleSheet( theme, styleSheet );
styleSheetFile.close();
return s_variableGuiTextMap[theme];
}
}
return QMap<QString, QString>();
}
else
{
return s_variableGuiTextMap[theme];
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiuGuiTheme::applyVariableValueMapToStyleSheet( RiuGuiTheme::ThemeEnum theme )
{
QFileInfo info( getStyleSheetPath( theme ) );
QString absoluteStyleSheetPath = QString( "%0/%1" ).arg( GUI_THEMES_DIR ).arg( info.fileName() );
QFile styleSheetFile( absoluteStyleSheetPath );
if ( styleSheetFile.exists() )
{
QString styleSheet;
if ( styleSheetFile.open( QIODevice::ReadOnly | QIODevice::Truncate | QIODevice::Text ) )
{
styleSheet = styleSheetFile.readAll();
QRegularExpression variableRegExp( "(?<prefix>[ \\t]*(?<name>\\$[a-zA-z0-9_]+)[ \\t]*:[ "
"\\t]*)(?<value>[a-zA-Z-_0-9#]+)(?<suffix>;[ \\t]*(\\/\\/[ "
"\\t]*(?<descriptor>(.*)))?)" );
QRegularExpressionMatchIterator matchIterator = variableRegExp.globalMatch( styleSheet );
while ( matchIterator.hasNext() )
{
QRegularExpressionMatch match = matchIterator.next();
styleSheet.replace( match.captured( 0 ),
QString( "%0%1%2" )
.arg( match.captured( "prefix" ) )
.arg( s_variableValueMap[theme].value( match.captured( "name" ) ) )
.arg( match.captured( "suffix" ) ) );
}
styleSheetFile.close();
}
if ( styleSheetFile.open( QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text ) )
{
styleSheetFile.write( styleSheet.toLatin1() );
return styleSheet;
}
}
return QString();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuGuiTheme::writeStyleSheetToFile( RiuGuiTheme::ThemeEnum theme, const QString& styleSheet )
{
QFileInfo info( getStyleSheetPath( theme ) );
QString absoluteStyleSheetPath = QString( "%0/%1" ).arg( GUI_THEMES_DIR ).arg( info.fileName() );
QFile styleSheetFile( absoluteStyleSheetPath );
if ( styleSheetFile.exists() )
{
if ( styleSheetFile.open( QIODevice::ReadWrite | QIODevice::Truncate | QIODevice::Text ) )
{
styleSheetFile.write( styleSheet.toLatin1() );
styleSheetFile.close();
QString modifiedStyleSheet = styleSheet;
preparseStyleSheet( theme, modifiedStyleSheet );
RiaGuiApplication* app = RiaGuiApplication::instance();
app->setStyleSheet( modifiedStyleSheet );
const QWidgetList topLevelWidgets = RiaGuiApplication::instance()->allWidgets();
for ( QWidget* widget : topLevelWidgets )
{
widget->style()->unpolish( widget );
widget->style()->polish( widget );
}
return true;
}
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiuGuiTheme::loadStyleSheet( RiuGuiTheme::ThemeEnum theme )
{
QFile styleSheetFile( getStyleSheetPath( theme ) );
QString styleSheet;
if ( styleSheetFile.exists() )
{
if ( styleSheetFile.open( QIODevice::ReadOnly ) )
{
styleSheet = styleSheetFile.readAll();
}
}
return styleSheet;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QAbstractItemModel* RiuGuiTheme::getQssCompletionModel( QCompleter* completer )
{
QFile file( ":utility/qss-keywords.txt" );
if ( !file.open( QFile::ReadOnly ) ) return new QStringListModel( completer );
QStringList words;
while ( !file.atEnd() )
{
QByteArray line = file.readLine();
if ( !line.isEmpty() ) words << QString::fromUtf8( line.trimmed() );
}
return new QStringListModel( words, completer );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QColor RiuGuiTheme::getColorByVariableName( const QString& variable, int theme /*= -1 */ )
{
RiuGuiTheme::ThemeEnum eTheme = RiaGuiApplication::instance()->preferences()->guiTheme();
if ( theme >= 0 && theme < static_cast<int>( caf::AppEnum<RiuGuiTheme::ThemeEnum>().size() ) )
{
eTheme = static_cast<RiuGuiTheme::ThemeEnum>( theme );
}
if ( s_variableValueMap.keys().contains( eTheme ) && s_variableValueMap[eTheme].keys().contains( "$" + variable ) )
{
return QColor( s_variableValueMap[eTheme]["$" + variable] );
}
return Qt::black;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiuGuiTheme::getQwtStyleSheetProperty( QString plotName,
const QString& itemType,
QString itemName,
const QString& propertyName )
{
if ( !s_qwtPlotItemPropertiesMap.keys().contains( plotName ) )
{
if ( !s_qwtPlotItemPropertiesMap.keys().contains( "*" ) )
{
return QString();
}
else
{
plotName = "*";
}
}
if ( !s_qwtPlotItemPropertiesMap[plotName].keys().contains( itemType ) )
{
if ( s_qwtPlotItemPropertiesMap.keys().contains( "*" ) &&
s_qwtPlotItemPropertiesMap["*"].keys().contains( itemType ) )
{
plotName = "*";
}
else
{
return QString();
}
}
if ( !s_qwtPlotItemPropertiesMap[plotName][itemType].keys().contains( itemName ) )
{
if ( !s_qwtPlotItemPropertiesMap[plotName][itemType].keys().contains( "*" ) )
{
if ( s_qwtPlotItemPropertiesMap.keys().contains( "*" ) &&
s_qwtPlotItemPropertiesMap["*"].keys().contains( itemType ) &&
s_qwtPlotItemPropertiesMap["*"][itemType].keys().contains( "*" ) )
{
plotName = "*";
itemName = "*";
}
else
{
return QString();
}
}
else
{
itemName = "*";
}
}
return s_qwtPlotItemPropertiesMap[plotName][itemType][itemName].value( propertyName );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuGuiTheme::styleQwtItem( QwtPlotItem* item )
{
QwtPlot* plot = item->plot();
QString plotName;
if ( plot && plot->property( "qss-class" ).isValid() )
{
plotName = plot->property( "qss-class" ).toString();
}
if ( QwtPlotCurve* curve = dynamic_cast<QwtPlotCurve*>( item ) )
{
QPen pen = curve->pen();
QString color = getQwtStyleSheetProperty( plotName, "curve", curve->title().text(), "line-color" );
if ( !color.isEmpty() ) pen.setColor( QColor( color ) );
curve->setPen( pen );
if ( curve->symbol() && curve->symbol()->style() != QwtSymbol::NoSymbol )
{
pen = curve->symbol()->pen();
QString symbolColor = getQwtStyleSheetProperty( plotName, "curve", curve->title().text(), "symbol-color" );
if ( !color.isEmpty() ) pen.setColor( QColor( symbolColor ) );
QwtSymbol* symbol = cloneCurveSymbol( curve );
symbol->setPen( pen );
curve->setSymbol( symbol );
}
}
else if ( QwtPlotGrid* grid = dynamic_cast<QwtPlotGrid*>( item ) )
{
QPen pen = grid->majorPen();
QString color = getQwtStyleSheetProperty( plotName, "grid", grid->title().text(), "color" );
if ( !color.isEmpty() ) pen.setColor( QColor( color ) );
grid->setPen( pen );
}
else if ( QwtPlotMarker* marker = dynamic_cast<QwtPlotMarker*>( item ) )
{
if ( marker->symbol() == nullptr || marker->symbol()->style() == QwtSymbol::NoSymbol )
{
QPen pen = marker->linePen();
QString color = getQwtStyleSheetProperty( plotName, "lineMarker", marker->title().text(), "color" );
if ( !color.isEmpty() ) pen.setColor( QColor( color ) );
marker->setLinePen( pen );
QString textColor = getQwtStyleSheetProperty( plotName, "lineMarker", marker->title().text(), "text-color" );
if ( !textColor.isEmpty() ) marker->label().setColor( QColor( textColor ) );
}
else
{
QwtSymbol* symbol = cloneMarkerSymbol( marker );
QPen pen = symbol->pen();
QString color = getQwtStyleSheetProperty( plotName, "pointMarker", marker->title().text(), "color" );
if ( !color.isEmpty() ) pen.setColor( QColor( color ) );
symbol->setPen( pen );
marker->setSymbol( symbol );
QString textColor = getQwtStyleSheetProperty( plotName, "pointMarker", marker->title().text(), "text-color" );
if ( !textColor.isEmpty() ) marker->label().setColor( QColor( textColor ) );
}
}
else if ( QwtPlotMarker* marker = dynamic_cast<QwtPlotMarker*>( item ) )
{
if ( marker->symbol() == nullptr || marker->symbol()->style() == QwtSymbol::NoSymbol )
{
QPen pen = marker->linePen();
QString color = getQwtStyleSheetProperty( plotName, "lineMarker", marker->title().text(), "color" );
if ( !color.isEmpty() ) pen.setColor( QColor( color ) );
marker->setLinePen( pen );
QString textColor = getQwtStyleSheetProperty( plotName, "lineMarker", marker->title().text(), "text-color" );
if ( !textColor.isEmpty() ) marker->label().setColor( QColor( textColor ) );
}
else
{
QwtSymbol* symbol = cloneMarkerSymbol( marker );
QPen pen = symbol->pen();
QString color = getQwtStyleSheetProperty( plotName, "pointMarker", marker->title().text(), "color" );
if ( !color.isEmpty() ) pen.setColor( QColor( color ) );
symbol->setPen( pen );
marker->setSymbol( symbol );
QString textColor = getQwtStyleSheetProperty( plotName, "pointMarker", marker->title().text(), "text-color" );
if ( !textColor.isEmpty() ) marker->label().setColor( QColor( textColor ) );
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuGuiTheme::styleQwtItem( QwtPicker* item )
{
QWidget* canvas = item->parentWidget();
if ( canvas )
{
QwtPlot* plot = dynamic_cast<QwtPlot*>( canvas->parentWidget() );
if ( plot )
{
QString plotName;
if ( plot && plot->property( "qss-class" ).isValid() )
{
plotName = plot->property( "qss-class" ).toString();
}
QPen pen = item->trackerPen();
QString textColor = getQwtStyleSheetProperty( plotName, "picker", "*", "text-color" );
if ( !textColor.isEmpty() ) pen.setColor( QColor( textColor ) );
item->setTrackerPen( pen );
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuGuiTheme::preparseStyleSheet( RiuGuiTheme::ThemeEnum theme, QString& styleSheet )
{
QRegularExpression variableRegExp(
"[ \\t]*(?<name>\\$[a-zA-z0-9_]+)[ \\t]*:[ \\t]*(?<value>[a-zA-Z-_0-9#]+);[ \\t]*(\\/\\/[ "
"\\t]*(?<descriptor>(.*)))?" );
QRegularExpressionMatchIterator matchIterator = variableRegExp.globalMatch( styleSheet );
if ( !s_variableValueMap.keys().contains( theme ) )
{
s_variableValueMap.insert( theme, {} );
}
else
{
s_variableValueMap[theme].clear();
}
while ( matchIterator.hasNext() )
{
QRegularExpressionMatch match = matchIterator.next();
styleSheet.replace( match.captured( 0 ), "" );
if ( s_variableValueMap[theme].keys().contains( match.captured( "name" ) ) )
{
styleSheet.replace( match.captured( "name" ), s_variableValueMap[theme].value( match.captured( "name" ) ) );
}
else
{
styleSheet.replace( match.captured( "name" ), match.captured( "value" ) );
s_variableValueMap[theme].insert( match.captured( "name" ), match.captured( "value" ) );
s_variableGuiTextMap[theme].insert( match.captured( "name" ), match.captured( "descriptor" ) );
}
}
QMap<QString, CustomStyleSheetApplicator>::iterator applicatorIterator;
for ( applicatorIterator = s_customStyleSheetApplicators.begin();
applicatorIterator != s_customStyleSheetApplicators.end();
applicatorIterator++ )
{
matchIterator = QRegularExpression( applicatorIterator.key() ).globalMatch( styleSheet );
while ( matchIterator.hasNext() )
{
QRegularExpressionMatch match = matchIterator.next();
applicatorIterator.value()( match );
styleSheet.replace( match.captured( 0 ), "" );
}
}
styleSheet = styleSheet.simplified();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiuGuiTheme::getStyleSheetPath( ThemeEnum theme )
{
return QString( ":/themes/%0.qss" ).arg( caf::AppEnum<RiuGuiTheme::ThemeEnum>( theme ).text().toLower() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuGuiTheme::storeQwtStyleSheetProperty( const QString& plotName,
const QString& itemType,
const QString& itemName,
const QString& propertyName,
const QString& value )
{
if ( !s_qwtPlotItemPropertiesMap.keys().contains( plotName ) )
{
s_qwtPlotItemPropertiesMap.insert( plotName, QMap<QString, QMap<QString, QMap<QString, QString>>>{} );
}
if ( !s_qwtPlotItemPropertiesMap[plotName].keys().contains( itemType ) )
{
s_qwtPlotItemPropertiesMap[plotName].insert( itemType, QMap<QString, QMap<QString, QString>>{} );
}
if ( !s_qwtPlotItemPropertiesMap[plotName][itemType].keys().contains( itemName ) )
{
s_qwtPlotItemPropertiesMap[plotName][itemType].insert( itemName, QMap<QString, QString>{} );
}
s_qwtPlotItemPropertiesMap[plotName][itemType][itemName].insert( propertyName, value );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Qt::PenStyle RiuGuiTheme::getPenStyleFromString( const QString& style )
{
if ( style == "solid" )
{
return Qt::PenStyle::SolidLine;
}
else if ( style == "dash" )
{
return Qt::PenStyle::DashLine;
}
else if ( style == "dot" )
{
return Qt::PenStyle::DotLine;
}
else if ( style == "dash-dot" )
{
return Qt::PenStyle::DashDotLine;
}
else if ( style == "dash-dot-dot" )
{
return Qt::PenStyle::DashDotDotLine;
}
else
{
return Qt::PenStyle::NoPen;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QwtSymbol* RiuGuiTheme::cloneMarkerSymbol( QwtPlotMarker* marker )
{
QwtSymbol* symbol = new QwtSymbol();
symbol->setBrush( marker->symbol()->brush() );
symbol->setPen( marker->symbol()->pen() );
symbol->setStyle( marker->symbol()->style() );
if ( marker->symbol()->style() == QwtSymbol::Style::Pixmap )
{
symbol->setPixmap( marker->symbol()->pixmap() );
}
else if ( marker->symbol()->style() == QwtSymbol::Style::Graphic )
{
symbol->setGraphic( marker->symbol()->graphic() );
}
symbol->setSize( marker->symbol()->size() );
symbol->setPinPoint( marker->symbol()->pinPoint() );
return symbol;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QwtSymbol* RiuGuiTheme::cloneCurveSymbol( QwtPlotCurve* curve )
{
QwtSymbol* symbol = new QwtSymbol();
symbol->setBrush( curve->symbol()->brush() );
symbol->setPen( curve->symbol()->pen() );
symbol->setStyle( curve->symbol()->style() );
if ( curve->symbol()->style() == QwtSymbol::Style::Pixmap )
{
symbol->setPixmap( curve->symbol()->pixmap() );
}
else if ( curve->symbol()->style() == QwtSymbol::Style::Graphic )
{
symbol->setGraphic( curve->symbol()->graphic() );
}
symbol->setSize( curve->symbol()->size() );
symbol->setPinPoint( curve->symbol()->pinPoint() );
return symbol;
}

View File

@@ -0,0 +1,82 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2020 Equinor 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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <functional>
#include <QMap>
#include <QPen>
class QWidget;
class QAbstractItemModel;
class QCompleter;
class QColor;
class QRegularExpressionMatch;
class QString;
class QwtPlotItem;
class QwtSymbol;
class QwtPlotMarker;
class QwtPlotCurve;
class QwtPicker;
typedef std::function<void( QRegularExpressionMatch& )> CustomStyleSheetApplicator;
class RiuGuiTheme
{
public:
enum class ThemeEnum
{
DEFAULT,
DARK,
LIGHT
};
static void updateGuiTheme( ThemeEnum theme );
static bool applyStyleSheet( ThemeEnum theme );
static void changeVariableValue( RiuGuiTheme::ThemeEnum theme, const QString& variableName, const QString& newValue );
static QMap<QString, QString> getVariableValueMap( RiuGuiTheme::ThemeEnum theme );
static QMap<QString, QString> getVariableGuiTextMap( RiuGuiTheme::ThemeEnum theme );
static QString applyVariableValueMapToStyleSheet( RiuGuiTheme::ThemeEnum theme );
static bool writeStyleSheetToFile( RiuGuiTheme::ThemeEnum theme, const QString& styleSheet );
static QString loadStyleSheet( RiuGuiTheme::ThemeEnum theme );
static QAbstractItemModel* getQssCompletionModel( QCompleter* completer );
static QColor getColorByVariableName( const QString& variable, int theme = -1 );
static QString
getQwtStyleSheetProperty( QString plotName, const QString& itemType, QString itemName, const QString& propertyName );
static void styleQwtItem( QwtPlotItem* item );
static void styleQwtItem( QwtPicker* item );
private:
static void preparseStyleSheet( RiuGuiTheme::ThemeEnum theme, QString& styleSheet );
static QString getStyleSheetPath( RiuGuiTheme::ThemeEnum theme );
static void storeQwtStyleSheetProperty( const QString& plotName,
const QString& itemType,
const QString& itemName,
const QString& propertyName,
const QString& value );
static Qt::PenStyle getPenStyleFromString( const QString& style );
static QwtSymbol* cloneMarkerSymbol( QwtPlotMarker* marker );
static QwtSymbol* cloneCurveSymbol( QwtPlotCurve* curve );
private:
static QMap<RiuGuiTheme::ThemeEnum, QMap<QString, QString>> s_variableValueMap;
static QMap<RiuGuiTheme::ThemeEnum, QMap<QString, QString>> s_variableGuiTextMap;
static QMap<QString, QMap<QString, QMap<QString, QMap<QString, QString>>>> s_qwtPlotItemPropertiesMap;
static QMap<QString, CustomStyleSheetApplicator> s_customStyleSheetApplicators;
};

View File

@@ -530,6 +530,10 @@ void RiuMainWindow::createMenus()
testMenu->addAction( cmdFeatureMgr->action( "RicHoloLensExportToFolderFeature" ) );
testMenu->addAction( cmdFeatureMgr->action( "RicHoloLensCreateDummyFiledBackedSessionFeature" ) );
testMenu->addSeparator();
testMenu->addAction( cmdFeatureMgr->action( "RicThemeColorEditorFeature" ) );
// Windows menu
m_windowMenu = menuBar()->addMenu( "&Windows" );
connect( m_windowMenu, SIGNAL( aboutToShow() ), SLOT( slotBuildWindowActions() ) );
@@ -1730,8 +1734,7 @@ void RiuMainWindow::updateMemoryUsage()
if ( availVirtualFraction < caf::MemoryInspector::getRemainingMemoryCriticalThresholdFraction() )
{
m_memoryCriticalWarning->setText( QString( "Available System Memory Critically Low!" ) );
m_memoryCriticalWarning->setStyleSheet(
QString( "QLabel {color: %1; padding: 0px 5px 0px 0px;}" ).arg( criticalColor.name() ) );
m_memoryCriticalWarning->setProperty( "styleRole", "memoryCriticalWarning" );
}
else
{
@@ -1739,10 +1742,11 @@ void RiuMainWindow::updateMemoryUsage()
}
m_memoryUsedButton->setText( QString( "Memory Used: %1 MiB" ).arg( currentUsage ) );
m_memoryUsedButton->setProperty( "styleRole", "memoryUsedButton" );
m_memoryTotalStatus->setText( QString( "Total Physical Memory: %1 MiB" ).arg( totalPhysicalMemory ) );
m_memoryTotalStatus->setProperty( "styleRole", "memoryTotalStatus" );
m_memoryUsedButton->setStyleSheet( QString( "QLabel {color: %1; padding: 0px 5px 0px 0px;}" ).arg( usageColor.name() ) );
m_memoryTotalStatus->setStyleSheet( QString( "QLabel {padding: 0px 5px 0px 0px; }" ) );
m_memoryUsedButton->setStyleSheet( QString( "QLabel {color: %1;}" ).arg( usageColor.name() ) );
}
//--------------------------------------------------------------------------------------------------

View File

@@ -55,7 +55,7 @@ RiuMessagePanel::RiuMessagePanel( QDockWidget* parent )
//--------------------------------------------------------------------------------------------------
void RiuMessagePanel::addMessage( RILogLevel messageLevel, const QString& msg )
{
QColor clr( Qt::black );
QColor clr = palette().color( QPalette::ColorRole::Text );
if ( messageLevel == RILogLevel::RI_LL_ERROR )
clr = Qt::red;
else if ( messageLevel == RILogLevel::RI_LL_WARNING )

View File

@@ -70,7 +70,7 @@ RiuProjectAndPropertyView::RiuProjectAndPropertyView( QWidget* parent, Qt::Windo
{
QLabel* propertyHeader = new QLabel;
propertyHeader->setText( "Property Editor" );
propertyHeader->setStyleSheet( "QLabel { background-color: #CCCCCC }" );
// propertyHeader->setStyleSheet( "QLabel { background-color: #CCCCCC }" );
propertyHeader->setFixedHeight( 20 );
QVBoxLayout* layout = new QVBoxLayout;

View File

@@ -19,6 +19,7 @@
#include "RiuPvtPlotPanel.h"
#include "RiuDockedQwtPlot.h"
#include "RiuGuiTheme.h"
#include "RiuPvtPlotUpdater.h"
#include "RigFlowDiagSolverInterface.h"
@@ -101,6 +102,7 @@ RiuPvtPlotWidget::RiuPvtPlotWidget( RiuPvtPlotPanel* parent )
, m_trackerPlotMarker( nullptr )
{
m_qwtPlot = new PvtQwtPlot( this );
m_qwtPlot->setProperty( "qss-class", "PvtPlot" );
setPlotDefaults( m_qwtPlot );
applyFontSizes( false );
@@ -112,6 +114,7 @@ RiuPvtPlotWidget::RiuPvtPlotWidget( RiuPvtPlotPanel* parent )
setLayout( layout );
m_qwtPicker = new RiuPvtQwtPicker( m_qwtPlot, this );
RiuGuiTheme::styleQwtItem( m_qwtPicker );
connect( m_qwtPicker, SIGNAL( activated( bool ) ), this, SLOT( slotPickerActivated( bool ) ) );
connect( m_qwtPicker, SIGNAL( moved( const QPoint& ) ), this, SLOT( slotPickerPointChanged( const QPoint& ) ) );
}
@@ -121,13 +124,7 @@ RiuPvtPlotWidget::RiuPvtPlotWidget( RiuPvtPlotPanel* parent )
//--------------------------------------------------------------------------------------------------
void RiuPvtPlotWidget::setPlotDefaults( QwtPlot* plot )
{
// Plot background and frame look
QPalette newPalette( plot->palette() );
newPalette.setColor( QPalette::Window, Qt::white );
plot->setPalette( newPalette );
plot->setAutoFillBackground( true );
plot->setCanvasBackground( Qt::white );
QFrame* canvasFrame = dynamic_cast<QFrame*>( plot->canvas() );
if ( canvasFrame )
@@ -139,9 +136,7 @@ void RiuPvtPlotWidget::setPlotDefaults( QwtPlot* plot )
{
QwtPlotGrid* grid = new QwtPlotGrid;
grid->attach( plot );
QPen gridPen( Qt::SolidLine );
gridPen.setColor( Qt::lightGray );
grid->setPen( gridPen );
RiuGuiTheme::styleQwtItem( grid );
}
// Axis number font
@@ -215,48 +210,50 @@ void RiuPvtPlotWidget::plotCurves( RiaEclipseUnitTools::UnitSystem
if ( xVals.size() > 1 )
{
QwtPlotCurve* qwtCurve = new QwtPlotCurve();
QwtPlotCurve* qwtCurve = new QwtPlotCurve( "Auxiliary" );
qwtCurve->setSamples( xVals.data(), yVals.data(), static_cast<int>( xVals.size() ) );
qwtCurve->setStyle( QwtPlotCurve::Lines );
qwtCurve->setRenderHint( QwtPlotItem::RenderAntialiased, true );
QColor curveClr = Qt::darkGreen;
const QPen curvePen( curveClr );
qwtCurve->setPen( curvePen );
qwtCurve->attach( m_qwtPlot );
RiuGuiTheme::styleQwtItem( qwtCurve );
}
}
// Add the primary curves
for ( size_t i = 0; i < curveArr.size(); i++ )
{
const RigFlowDiagSolverInterface::PvtCurve& curve = curveArr[i];
QwtPlotCurve* qwtCurve = new QwtPlotCurve();
const RigFlowDiagSolverInterface::PvtCurve& curve = curveArr[i];
QwtPlotCurve* qwtCurve = new QwtPlotCurve();
QwtSymbol* curveSymbol = new QwtSymbol( QwtSymbol::Ellipse );
CVF_ASSERT( curve.pressureVals.size() == curve.yVals.size() );
qwtCurve->setSamples( curve.pressureVals.data(), curve.yVals.data(), static_cast<int>( curve.pressureVals.size() ) );
qwtCurve->setStyle( QwtPlotCurve::Lines );
QColor curveClr = Qt::magenta;
if ( curve.phase == RigFlowDiagSolverInterface::PvtCurve::GAS )
curveClr = QColor( Qt::red );
{
qwtCurve->setTitle( "Gas" );
}
else if ( curve.phase == RigFlowDiagSolverInterface::PvtCurve::OIL )
curveClr = QColor( Qt::green );
const QPen curvePen( curveClr );
qwtCurve->setPen( curvePen );
{
qwtCurve->setTitle( "Oil" );
}
else
{
qwtCurve->setTitle( "Undefined" );
}
qwtCurve->setRenderHint( QwtPlotItem::RenderAntialiased, true );
QwtSymbol* curveSymbol = new QwtSymbol( QwtSymbol::Ellipse );
curveSymbol->setSize( 6, 6 );
curveSymbol->setPen( curvePen );
curveSymbol->setBrush( Qt::NoBrush );
qwtCurve->setSymbol( curveSymbol );
qwtCurve->attach( m_qwtPlot );
RiuGuiTheme::styleQwtItem( qwtCurve );
m_qwtCurveArr.push_back( qwtCurve );
}
@@ -268,13 +265,18 @@ void RiuPvtPlotWidget::plotCurves( RiaEclipseUnitTools::UnitSystem
if ( pressure != HUGE_VAL )
{
QwtPlotMarker* lineMarker = new QwtPlotMarker;
QPen pen;
pen.setStyle( Qt::DashLine );
lineMarker->setLinePen( pen );
lineMarker->setXValue( pressure );
lineMarker->setLineStyle( QwtPlotMarker::VLine );
lineMarker->setLinePen( QPen( QColor( 128, 128, 255 ), 1, Qt::DashLine ) );
lineMarker->setLabel( QString( "PRESSURE" ) );
lineMarker->setLabelAlignment( Qt::AlignTop | Qt::AlignRight );
lineMarker->setLabelOrientation( Qt::Vertical );
lineMarker->attach( m_qwtPlot );
RiuGuiTheme::styleQwtItem( lineMarker );
}
// Then point marker
@@ -283,10 +285,11 @@ void RiuPvtPlotWidget::plotCurves( RiaEclipseUnitTools::UnitSystem
QwtPlotMarker* pointMarker = new QwtPlotMarker;
pointMarker->setValue( pressure, pointMarkerYValue );
QColor markerClr( 128, 0, 255 );
QwtSymbol* symbol = new QwtSymbol( QwtSymbol::Ellipse );
symbol->setSize( 13, 13 );
symbol->setPen( QPen( markerClr, 2 ) );
QPen pen;
pen.setWidth( 2 );
symbol->setPen( pen );
symbol->setBrush( Qt::NoBrush );
pointMarker->setSymbol( symbol );
@@ -294,12 +297,13 @@ void RiuPvtPlotWidget::plotCurves( RiaEclipseUnitTools::UnitSystem
{
QwtText text( pointMarkerLabel );
text.setRenderFlags( Qt::AlignLeft );
text.setColor( markerClr );
text.setColor( RiuGuiTheme::getColorByVariableName( "textColor" ) );
pointMarker->setLabel( text );
pointMarker->setLabelAlignment( Qt::AlignTop | Qt::AlignRight );
}
pointMarker->attach( m_qwtPlot );
RiuGuiTheme::styleQwtItem( pointMarker );
}
m_qwtPlot->setTitle( plotTitle );
@@ -366,13 +370,14 @@ void RiuPvtPlotWidget::updateTrackerPlotMarkerAndLabelFromPicker()
if ( !m_trackerPlotMarker )
{
m_trackerPlotMarker = new QwtPlotMarker;
m_trackerPlotMarker->setTitle( QString( "TrackedPoint" ) );
QwtSymbol* symbol = new QwtSymbol( QwtSymbol::Ellipse );
symbol->setSize( 13, 13 );
symbol->setPen( QPen( QColor( 0, 0, 0 ), 2 ) );
symbol->setBrush( Qt::NoBrush );
m_trackerPlotMarker->setSymbol( symbol );
m_trackerPlotMarker->attach( m_qwtPlot );
RiuGuiTheme::styleQwtItem( m_trackerPlotMarker );
needsReplot = true;
}

View File

@@ -0,0 +1,185 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2020 Equinor 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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RiuQssSyntaxHighlighter.h"
#include <QRegularExpression>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QssSyntaxHighligter::QssSyntaxHighligter( QTextDocument* parent )
: QSyntaxHighlighter( parent )
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void QssSyntaxHighligter::highlightBlock( const QString& text )
{
QTextCharFormat variableFormat;
variableFormat.setFontWeight( QFont::Bold );
variableFormat.setForeground( QColor( "#e20a48" ) );
QTextCharFormat commentFormat;
commentFormat.setFontWeight( QFont::Normal );
commentFormat.setForeground( QColor( "#4e9041" ) );
QTextCharFormat classFormat;
classFormat.setFontWeight( QFont::Bold );
classFormat.setForeground( QColor( "#fc8f00" ) );
QTextCharFormat handleFormat;
handleFormat.setFontWeight( QFont::Bold );
handleFormat.setForeground( QColor( "#e20a48" ) );
QTextCharFormat modifierFormat;
modifierFormat.setFontWeight( QFont::Normal );
modifierFormat.setForeground( QColor( "#e20a48" ) );
// Block states:
// -1 - none
// 1 - inside class
// 2 - inside function
// 3 - inside multiline comment
QRegularExpression classStartExpression = QRegularExpression( QString( "\\{" ) );
QRegularExpression classEndExpression = QRegularExpression( QString( "\\}" ) );
QRegularExpression functionStartExpression = QRegularExpression( QString( "\\(" ) );
QRegularExpression functionEndExpression = QRegularExpression( QString( "\\)" ) );
QRegularExpression commentStartExpression = QRegularExpression( QString( "/\\*" ) );
QRegularExpression commentEndExpression = QRegularExpression( QString( "\\*/" ) );
setCurrentBlockState( -1 );
auto parseClass = [this, text]( int startIndex, int length ) {
QTextCharFormat propertyFormat;
propertyFormat.setFontWeight( QFont::Bold );
QTextCharFormat valueFormat;
valueFormat.setFontWeight( QFont::Normal );
valueFormat.setForeground( QColor( "#0d98ce" ) );
QTextCharFormat functionFormat;
functionFormat.setFontWeight( QFont::Bold );
functionFormat.setForeground( QColor( "#dd1bc1" ) );
QRegularExpression expression =
QRegularExpression( "\\s*([a-zA-Z0-9_-]+)[ \\t]*:\\s*([a-zA-Z0-9_-]+\\()?([\\$#\\[\\]:\\.,a-zA-Z0-9-_ "
"]+)(\\))?[ \\t]*;" );
QRegularExpressionMatchIterator j = expression.globalMatch( text );
while ( j.hasNext() )
{
QRegularExpressionMatch matchClass = j.next();
setFormat( startIndex + matchClass.capturedStart( 1 ), matchClass.capturedLength( 1 ), propertyFormat );
setFormat( startIndex + matchClass.capturedStart( 2 ), matchClass.capturedLength( 2 ), functionFormat );
setFormat( startIndex + matchClass.capturedStart( 3 ), matchClass.capturedLength( 3 ), valueFormat );
setFormat( startIndex + matchClass.capturedStart( 4 ), matchClass.capturedLength( 4 ), functionFormat );
}
};
if ( previousBlockState() == -1 )
{
QRegularExpression expression = QRegularExpression( "([a-zA-z0-9_-]+)(::[a-zA-Z0-9_-]+)?(:[a-zA-Z0-9_-]+)?" );
QRegularExpressionMatchIterator i = expression.globalMatch( text );
while ( i.hasNext() )
{
QRegularExpressionMatch matchClass = i.next();
setFormat( matchClass.capturedStart( 1 ), matchClass.capturedLength( 1 ), classFormat );
setFormat( matchClass.capturedStart( 2 ), matchClass.capturedLength( 2 ), handleFormat );
setFormat( matchClass.capturedStart( 3 ), matchClass.capturedLength( 3 ), modifierFormat );
}
int startIndex = text.indexOf( classStartExpression );
while ( startIndex >= 0 )
{
QRegularExpressionMatch match = classEndExpression.match( text, startIndex );
int endIndex = match.capturedStart();
int classLength = 0;
if ( endIndex == -1 )
{
setCurrentBlockState( 1 );
classLength = text.length() - startIndex;
}
else
{
classLength = endIndex - startIndex + match.capturedLength();
}
parseClass( startIndex, classLength );
startIndex = text.indexOf( classStartExpression, startIndex + classLength );
}
}
if ( previousBlockState() == 1 )
{
int startIndex = 0;
while ( startIndex >= 0 )
{
QRegularExpressionMatch match = classEndExpression.match( text, startIndex );
int endIndex = match.capturedStart();
int classLength = 0;
if ( endIndex == -1 )
{
setCurrentBlockState( 1 );
classLength = text.length() - startIndex;
}
else
{
classLength = endIndex - startIndex + match.capturedLength();
}
parseClass( startIndex, classLength );
startIndex = text.indexOf( classStartExpression, startIndex + classLength );
}
}
QRegularExpression expression( "\\$[a-zA-z0-9_]+" );
QRegularExpressionMatchIterator i = expression.globalMatch( text );
while ( i.hasNext() )
{
QRegularExpressionMatch match = i.next();
setFormat( match.capturedStart(), match.capturedLength(), variableFormat );
}
expression = QRegularExpression( "\\/\\/(.*)" );
i = expression.globalMatch( text );
while ( i.hasNext() )
{
QRegularExpressionMatch match = i.next();
setFormat( match.capturedStart(), match.capturedLength(), commentFormat );
}
int startIndex = 0;
if ( previousBlockState() != 2 ) startIndex = text.indexOf( commentStartExpression );
while ( startIndex >= 0 )
{
QRegularExpressionMatch match = commentEndExpression.match( text, startIndex );
int endIndex = match.capturedStart();
int commentLength = 0;
if ( endIndex == -1 )
{
setCurrentBlockState( 2 );
commentLength = text.length() - startIndex;
}
else
{
commentLength = endIndex - startIndex + match.capturedLength();
}
setFormat( startIndex, commentLength, commentFormat );
startIndex = text.indexOf( commentStartExpression, startIndex + commentLength );
}
}

View File

@@ -0,0 +1,31 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2020 Equinor 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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <QSyntaxHighlighter>
#include <QTextDocument>
class QssSyntaxHighligter : public QSyntaxHighlighter
{
public:
QssSyntaxHighligter( QTextDocument* parent );
protected:
virtual void highlightBlock( const QString& text );
};

View File

@@ -44,8 +44,11 @@ RiuQwtCurvePointTracker::RiuQwtCurvePointTracker( QwtPlot* pl
this->setTrackerMode( QwtPicker::AlwaysOn );
m_plotMarker = new QwtPlotMarker;
// Get text color from palette
QColor color = plot->palette().color( QPalette::Text );
// QwtPlotMarker takes ownership of the symbol, it is deleted in destructor of QwtPlotMarker
QwtSymbol* mySymbol = new QwtSymbol( QwtSymbol::Ellipse, Qt::NoBrush, QPen( Qt::black, 2.0 ), QSize( 12, 12 ) );
QwtSymbol* mySymbol = new QwtSymbol( QwtSymbol::Ellipse, Qt::NoBrush, QPen( color, 2.0 ), QSize( 12, 12 ) );
m_plotMarker->setSymbol( mySymbol );
}

View File

@@ -17,6 +17,8 @@
/////////////////////////////////////////////////////////////////////////////////
#include "RiuQwtPlotTools.h"
#include "RiuGuiTheme.h"
#include "RiaApplication.h"
#include "RiaPreferences.h"
@@ -53,8 +55,8 @@ void RiuQwtPlotTools::setCommonPlotBehaviour( QwtPlot* plot )
QwtPlotGrid* grid = new QwtPlotGrid;
grid->attach( plot );
QPen gridPen( Qt::SolidLine );
gridPen.setColor( Qt::lightGray );
grid->setPen( gridPen );
RiuGuiTheme::styleQwtItem( grid );
// Axis number font
int axisFontSize = caf::FontTools::absolutePointSize( RiaPreferences::current()->defaultPlotFontSize(),

View File

@@ -19,6 +19,7 @@
#include "RiuQwtSymbol.h"
#include "RiaColorTools.h"
#include "RiaFontCache.h"
#include "cvfAssert.h"
@@ -157,6 +158,7 @@ void RiuQwtSymbol::renderSymbolLabel( QPainter* painter, const QPointF& position
QFont font = painter->font();
font.setPixelSize( m_labelFontSizePx );
painter->setFont( font );
painter->setPen( RiaColorTools::systemPaletteTextColor() );
QSize symbolSize = QwtSymbol::size();
QRect symbolRect( position.x(), position.y(), symbolSize.width(), symbolSize.height() );

View File

@@ -18,6 +18,7 @@
#include "RiuRelativePermeabilityPlotPanel.h"
#include "RiuDockedQwtPlot.h"
#include "RiuGuiTheme.h"
#include "RiuQwtPlotCurve.h"
#include "RiuQwtPlotTools.h"
#include "RiuRelativePermeabilityPlotUpdater.h"
@@ -85,6 +86,8 @@ RiuRelativePermeabilityPlotPanel::RiuRelativePermeabilityPlotPanel( QDockWidget*
, m_plotUpdater( new RiuRelativePermeabilityPlotUpdater( this ) )
{
m_qwtPlot = new RelPermQwtPlot( this );
m_qwtPlot->setProperty( "qss-class", "RelPermPlot" );
setPlotDefaults( m_qwtPlot );
applyFontSizes( false );
@@ -366,37 +369,36 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt( RiaEclipseUnitTools::Uni
qwtCurve->setStyle( QwtPlotCurve::Lines );
Qt::PenStyle penStyle = Qt::SolidLine;
QColor clr = Qt::magenta;
switch ( curve.ident )
{
case RigFlowDiagSolverInterface::RelPermCurve::KRW:
clr = QColor( 0, 0, 200 );
qwtCurve->setTitle( "KRW" );
break;
case RigFlowDiagSolverInterface::RelPermCurve::KROW:
clr = QColor( 0, 0, 200 );
qwtCurve->setTitle( "KROW" );
break;
case RigFlowDiagSolverInterface::RelPermCurve::PCOW:
clr = QColor( 0, 130, 175 );
qwtCurve->setTitle( "PCOW" );
penStyle = Qt::DashLine;
break;
case RigFlowDiagSolverInterface::RelPermCurve::KRG:
clr = QColor( 200, 0, 0 );
qwtCurve->setTitle( "KRG" );
break;
case RigFlowDiagSolverInterface::RelPermCurve::KROG:
clr = QColor( 200, 0, 0 );
qwtCurve->setTitle( "KROG" );
break;
case RigFlowDiagSolverInterface::RelPermCurve::PCOG:
clr = QColor( 225, 110, 0 );
qwtCurve->setTitle( "PCOG" );
penStyle = Qt::DashLine;
break;
}
const QPen curvePen( clr, 1, penStyle );
const QPen curvePen( Qt::black, 1, penStyle );
qwtCurve->setPen( curvePen );
QwtSymbol* curveSymbol = new QwtSymbol( QwtSymbol::Ellipse );
curveSymbol->setSize( 6, 6 );
curveSymbol->setPen( clr );
curveSymbol->setPen( Qt::black );
curveSymbol->setBrush( Qt::NoBrush );
qwtCurve->setSymbol( curveSymbol );
@@ -414,6 +416,8 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt( RiaEclipseUnitTools::Uni
qwtCurve->attach( plot );
RiuGuiTheme::styleQwtItem( qwtCurve );
// Add markers to indicate where SWAT and/or SGAS saturation intersects the respective curves
// Note that if we're using log scale we must guard against non-positive values
if ( swat != HUGE_VAL )
@@ -424,7 +428,7 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt( RiaEclipseUnitTools::Uni
{
addCurveConstSaturationIntersectionMarker( curve,
swat,
Qt::blue,
RiuGuiTheme::getColorByVariableName( "markerColor" ),
plotOnWhichYAxis,
plot,
myPlotMarkers,
@@ -440,7 +444,7 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt( RiaEclipseUnitTools::Uni
{
addCurveConstSaturationIntersectionMarker( curve,
sgas,
Qt::red,
RiuGuiTheme::getColorByVariableName( "markerColor" ),
plotOnWhichYAxis,
plot,
myPlotMarkers,
@@ -457,11 +461,11 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt( RiaEclipseUnitTools::Uni
// Add vertical marker lines to indicate cell SWAT and/or SGAS saturations
if ( swat != HUGE_VAL )
{
addVerticalSaturationMarkerLine( swat, "SWAT", Qt::blue, plot, myPlotMarkers );
addVerticalSaturationMarkerLine( swat, "SWAT", RiuGuiTheme::getColorByVariableName( "markerColor" ), plot, myPlotMarkers );
}
if ( sgas != HUGE_VAL )
{
addVerticalSaturationMarkerLine( sgas, "SGAS", Qt::red, plot, myPlotMarkers );
addVerticalSaturationMarkerLine( sgas, "SGAS", RiuGuiTheme::getColorByVariableName( "markerColor" ), plot, myPlotMarkers );
}
if ( logScaleLeftAxis )

View File

@@ -52,6 +52,7 @@
RiuResultQwtPlot::RiuResultQwtPlot( QWidget* parent )
: RiuDockedQwtPlot( parent )
{
setAutoFillBackground( true );
setDefaults();
}

View File

@@ -0,0 +1,157 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2020 Equinor 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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RiuTextEditWithCompletion.h"
#include <QAbstractItemModel>
#include <QAbstractItemView>
#include <QApplication>
#include <QCompleter>
#include <QKeyEvent>
#include <QModelIndex>
#include <QScrollBar>
#include <QtDebug>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
TextEditWithCompletion::TextEditWithCompletion( QWidget* parent /*= nullptr */ )
: QTextEdit( parent )
{
m_completer = nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
TextEditWithCompletion::~TextEditWithCompletion()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void TextEditWithCompletion::setCompleter( QCompleter* completer )
{
if ( m_completer ) m_completer->disconnect( this );
m_completer = completer;
if ( !m_completer ) return;
m_completer->setWidget( this );
m_completer->setCompletionMode( QCompleter::PopupCompletion );
m_completer->setCaseSensitivity( Qt::CaseInsensitive );
QObject::connect( m_completer,
QOverload<const QString&>::of( &QCompleter::activated ),
this,
&TextEditWithCompletion::insertCompletion );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QCompleter* TextEditWithCompletion::completer()
{
return m_completer;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void TextEditWithCompletion::keyPressEvent( QKeyEvent* e )
{
if ( m_completer && m_completer->popup()->isVisible() )
{
// The following keys are forwarded by the completer to the widget
switch ( e->key() )
{
case Qt::Key_Enter:
case Qt::Key_Return:
case Qt::Key_Escape:
case Qt::Key_Tab:
case Qt::Key_Backtab:
e->ignore();
return; // let the completer do default behavior
default:
break;
}
}
const bool isShortcut = ( e->modifiers().testFlag( Qt::ControlModifier ) && e->key() == Qt::Key_E ); // CTRL+E
if ( !m_completer || !isShortcut ) // do not process the shortcut when we have a completer
QTextEdit::keyPressEvent( e );
const bool ctrlOrShift = e->modifiers().testFlag( Qt::ControlModifier ) ||
e->modifiers().testFlag( Qt::ShiftModifier );
if ( !m_completer || ( ctrlOrShift && e->text().isEmpty() ) ) return;
static QString eow( "~!@#$%^&*()_+{}|:\"<>?,./;'[]\\-=" ); // end of word
const bool hasModifier = ( e->modifiers() != Qt::NoModifier ) && !ctrlOrShift;
QString completionPrefix = textUnderCursor();
if ( !isShortcut &&
( hasModifier || e->text().isEmpty() || completionPrefix.length() < 3 || eow.contains( e->text().right( 1 ) ) ) )
{
m_completer->popup()->hide();
return;
}
if ( completionPrefix != m_completer->completionPrefix() )
{
m_completer->setCompletionPrefix( completionPrefix );
m_completer->popup()->setCurrentIndex( m_completer->completionModel()->index( 0, 0 ) );
}
QRect cr = cursorRect();
cr.setWidth( m_completer->popup()->sizeHintForColumn( 0 ) +
m_completer->popup()->verticalScrollBar()->sizeHint().width() );
m_completer->complete( cr ); // popup it up!
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void TextEditWithCompletion::focusInEvent( QFocusEvent* e )
{
if ( m_completer ) m_completer->setWidget( this );
QTextEdit::focusInEvent( e );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void TextEditWithCompletion::insertCompletion( const QString& completion )
{
if ( m_completer->widget() != this ) return;
QTextCursor tc = textCursor();
int extra = completion.length() - m_completer->completionPrefix().length();
tc.movePosition( QTextCursor::Left );
tc.movePosition( QTextCursor::EndOfWord );
tc.insertText( completion.right( extra ) );
setTextCursor( tc );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString TextEditWithCompletion::textUnderCursor() const
{
QTextCursor tc = textCursor();
tc.select( QTextCursor::WordUnderCursor );
return tc.selectedText();
}

View File

@@ -0,0 +1,46 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2020 Equinor 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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <QTextEdit>
class QCompleter;
class TextEditWithCompletion : public QTextEdit
{
Q_OBJECT
public:
TextEditWithCompletion( QWidget* parent = nullptr );
~TextEditWithCompletion();
void setCompleter( QCompleter* completer );
QCompleter* completer();
protected:
void keyPressEvent( QKeyEvent* e ) override;
void focusInEvent( QFocusEvent* e ) override;
private slots:
void insertCompletion( const QString& completion );
private:
QString textUnderCursor() const;
private:
QCompleter* m_completer;
};

View File

@@ -25,6 +25,8 @@
#include "RiuMainWindow.h"
#include "RiuQwtCurvePointTracker.h"
#include "RiuGuiTheme.h"
#include "cafSelectionManager.h"
#include "cvfAssert.h"
@@ -67,19 +69,19 @@ RiuTofAccumulatedPhaseFractionsPlot::RiuTofAccumulatedPhaseFractionsPlot( RimTof
setTitle( title );
m_watCurve = new QwtPlotCurve;
setCurveColor( m_watCurve, QColor( 62, 122, 167 ) ); // Blue
setCurveColor( m_watCurve, RiuGuiTheme::getColorByVariableName( "waterCurveColor" ) );
m_watCurve->setZ( 0.9 );
m_watCurve->setTitle( "Water" );
m_watCurve->setRenderHint( QwtPlotItem::RenderAntialiased, true );
m_oilCurve = new QwtPlotCurve;
setCurveColor( m_oilCurve, QColor( 123, 167, 0 ) ); // Green
setCurveColor( m_oilCurve, RiuGuiTheme::getColorByVariableName( "oilCurveColor" ) );
m_oilCurve->setZ( 0.8 );
m_oilCurve->setTitle( "Oil" );
m_oilCurve->setRenderHint( QwtPlotItem::RenderAntialiased, true );
m_gasCurve = new QwtPlotCurve;
setCurveColor( m_gasCurve, QColor( 169, 18, 16 ) ); // Red
setCurveColor( m_gasCurve, RiuGuiTheme::getColorByVariableName( "gasCurveColor" ) );
m_gasCurve->setZ( 0.7 );
m_gasCurve->setTitle( "Gas" );
m_gasCurve->setRenderHint( QwtPlotItem::RenderAntialiased, true );

View File

@@ -23,4 +23,5 @@
namespace RiuTools
{
Qt::WindowFlags defaultDialogFlags();
void applyGuiTheme();
} // end namespace RiuTools