mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-25 06:38:13 -05:00
Curve Appearance: add transparency slider.
This commit is contained in:
1 parent
26e8282546
commit
a878d947e8
8 files changed
+76
-6
No files matched your search
@@ -44,10 +44,10 @@ void RicHistogramPlotTools::createHistogramCurve( RimHistogramPlot* plot, RimHis
|
||||
RimHistogramCurve* newCurve = new RimHistogramCurve();
|
||||
|
||||
newCurve->setDataSource( dataSource );
|
||||
newCurve->setAppearanceFromGraphType( plot->graphType() );
|
||||
|
||||
cvf::Color3f curveColor = RiaColorTables::summaryCurveDefaultPaletteColors().cycledColor3f( plot->curveCount() );
|
||||
newCurve->setColor( curveColor );
|
||||
newCurve->setIsStacked( true );
|
||||
newCurve->setFillColor( curveColor );
|
||||
|
||||
plot->addCurveNoUpdate( newCurve );
|
||||
|
||||
@@ -405,3 +405,14 @@ void RimHistogramCurve::onDataSourceChanged( const caf::SignalEmitter* emitter )
|
||||
{
|
||||
loadAndUpdateDataAndPlot();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimHistogramCurve::setAppearanceFromGraphType( RimHistogramPlot::GraphType graphType )
|
||||
{
|
||||
auto fillType = graphType == RimHistogramPlot::GraphType::BAR_GRAPH ? Qt::SolidPattern : Qt::NoBrush;
|
||||
setFillStyle( fillType );
|
||||
float transparency = graphType == RimHistogramPlot::GraphType::BAR_GRAPH ? 0.2 : 1.0;
|
||||
setFillColorTransparency( transparency );
|
||||
}
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmPtrField.h"
|
||||
|
||||
#include "RimHistogramPlot.h"
|
||||
#include "RimStackablePlotCurve.h"
|
||||
|
||||
class RimPlotAxisPropertiesInterface;
|
||||
@@ -56,6 +57,7 @@ public:
|
||||
void updateLegendEntryVisibilityNoPlotUpdate() override;
|
||||
|
||||
void setDataSource( RimHistogramDataSource* dataSource );
|
||||
void setAppearanceFromGraphType( RimHistogramPlot::GraphType graphType );
|
||||
|
||||
protected:
|
||||
// RimPlotCurve overrides
|
||||
|
||||
@@ -545,6 +545,14 @@ void RimHistogramPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField
|
||||
|
||||
if ( changedField == &m_showPlotLegends ) updateLegend();
|
||||
|
||||
if ( changedField == &m_graphType )
|
||||
{
|
||||
for ( auto c : histogramCurves() )
|
||||
{
|
||||
c->setAppearanceFromGraphType( m_graphType() );
|
||||
}
|
||||
}
|
||||
|
||||
if ( changedField == &m_normalizeCurveYValues || changedField == &m_histogramFrequencyType || changedField == &m_graphType )
|
||||
{
|
||||
loadDataAndUpdate();
|
||||
|
||||
@@ -724,6 +724,14 @@ void RimPlotCurve::setFillColor( const cvf::Color3f& fillColor )
|
||||
m_curveAppearance->setFillColor( fillColor );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimPlotCurve::setFillColorTransparency( float fillColorTransparency )
|
||||
{
|
||||
m_curveAppearance->setFillColorTransparency( fillColorTransparency );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -1007,9 +1015,8 @@ void RimPlotCurve::updateCurveAppearance()
|
||||
QColor fillColor = RiaColorTools::toQColor( m_curveAppearance->fillColor() );
|
||||
|
||||
fillColor = RiaColorTools::blendQColors( fillColor, QColor( Qt::white ), 3, 1 );
|
||||
fillColor.setAlphaF( m_curveAppearance->fillColorTransparency() );
|
||||
|
||||
// TODO: this is a workaround. Create proper api for setting fill color transparency.
|
||||
fillColor.setAlphaF( 0.5 );
|
||||
QBrush fillBrush( fillColor, fillStyle() );
|
||||
m_plotCurve->setAppearance( m_curveAppearance->lineStyle(),
|
||||
m_curveAppearance->interpolation(),
|
||||
|
||||
@@ -77,6 +77,7 @@ public:
|
||||
virtual Qt::BrushStyle fillStyle() const;
|
||||
void setFillStyle( Qt::BrushStyle brushStyle );
|
||||
void setFillColor( const cvf::Color3f& fillColor );
|
||||
void setFillColorTransparency( float fillColorTransparency );
|
||||
|
||||
bool isChecked() const;
|
||||
void setCheckState( bool isChecked );
|
||||
|
||||
@@ -22,8 +22,7 @@
|
||||
|
||||
#include "cafPdmUiComboBoxEditor.h"
|
||||
#include "cafPdmUiCommandSystemProxy.h"
|
||||
|
||||
#include "cvfAssert.h"
|
||||
#include "cafPdmUiDoubleSliderEditor.h"
|
||||
|
||||
CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimPlotCurveAppearance, "PlotCurveAppearance" );
|
||||
|
||||
@@ -89,6 +88,8 @@ RimPlotCurveAppearance::RimPlotCurveAppearance()
|
||||
|
||||
CAF_PDM_InitField( &m_curveColor, "Color", RiaColorTools::textColor3f(), "Color" );
|
||||
CAF_PDM_InitField( &m_fillColor, "FillColor", cvf::Color3f( -1.0, -1.0, -1.0 ), "Fill Color" );
|
||||
CAF_PDM_InitField( &m_fillColorTransparency, "FillColorTransparency", 1.0f, "Fill Color Transparency" );
|
||||
m_fillColorTransparency.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() );
|
||||
|
||||
CAF_PDM_InitField( &m_curveThickness, "Thickness", 1, "Line Thickness" );
|
||||
m_curveThickness.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() );
|
||||
@@ -144,6 +145,22 @@ void RimPlotCurveAppearance::fieldChangedByUi( const caf::PdmFieldHandle* change
|
||||
appearanceChanged.send();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimPlotCurveAppearance ::defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute )
|
||||
{
|
||||
if ( field == &m_fillColorTransparency )
|
||||
{
|
||||
caf::PdmUiDoubleSliderEditorAttribute* myAttr = dynamic_cast<caf::PdmUiDoubleSliderEditorAttribute*>( attribute );
|
||||
if ( myAttr )
|
||||
{
|
||||
myAttr->m_minimum = 0.0;
|
||||
myAttr->m_maximum = 1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -207,8 +224,10 @@ void RimPlotCurveAppearance::defineUiOrdering( QString uiConfigName, caf::PdmUiO
|
||||
if ( m_fillStyle != Qt::BrushStyle::NoBrush )
|
||||
{
|
||||
uiOrdering.add( &m_fillColor );
|
||||
uiOrdering.add( &m_fillColorTransparency );
|
||||
}
|
||||
m_fillColor.uiCapability()->setUiHidden( !m_fillOptionsVisible );
|
||||
m_fillColorTransparency.uiCapability()->setUiHidden( !m_fillOptionsVisible );
|
||||
|
||||
uiOrdering.add( &m_curveInterpolation );
|
||||
m_curveInterpolation.uiCapability()->setUiHidden( !m_interpolationVisible );
|
||||
@@ -416,6 +435,22 @@ void RimPlotCurveAppearance::setFillColor( const cvf::Color3f& fillColor )
|
||||
m_fillColor = fillColor;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimPlotCurveAppearance::setFillColorTransparency( float fillColorTransparency )
|
||||
{
|
||||
m_fillColorTransparency = fillColorTransparency;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
float RimPlotCurveAppearance::fillColorTransparency() const
|
||||
{
|
||||
return m_fillColorTransparency;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -86,6 +86,9 @@ public:
|
||||
void setFillColor( const cvf::Color3f& fillColor );
|
||||
cvf::Color3f fillColor() const;
|
||||
|
||||
void setFillColorTransparency( float fillColorTransparency );
|
||||
float fillColorTransparency() const;
|
||||
|
||||
float curveFittingTolerance() const;
|
||||
|
||||
void setInterpolation( RiuQwtPlotCurveDefines::CurveInterpolationEnum );
|
||||
@@ -101,7 +104,9 @@ protected:
|
||||
// Overridden PDM methods
|
||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
||||
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override;
|
||||
void initAfterRead() override;
|
||||
void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;
|
||||
|
||||
void initAfterRead() override;
|
||||
|
||||
protected:
|
||||
caf::PdmField<QString> m_symbolLabel;
|
||||
@@ -117,6 +122,7 @@ protected:
|
||||
caf::PdmField<LineStyle> m_lineStyle;
|
||||
caf::PdmField<FillStyle> m_fillStyle;
|
||||
caf::PdmField<cvf::Color3f> m_fillColor;
|
||||
caf::PdmField<float> m_fillColorTransparency;
|
||||
caf::PdmField<CurveInterpolation> m_curveInterpolation;
|
||||
caf::PdmField<LabelPosition> m_symbolLabelPosition;
|
||||
caf::PdmField<cvf::Color3f> m_symbolEdgeColor;
|
||||
|
||||
Reference in new issue
Block a user