mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Merge pull request #4693 from OPM/feature-plot-color-fill
#4666 Add colour fill for formations in Well Log Plots
This commit is contained in:
commit
b8eeb2cc2b
@ -144,7 +144,8 @@ public:
|
||||
const caf::TitledOverlayFrame* titledOverlayFrame() const override;
|
||||
caf::TitledOverlayFrame* titledOverlayFrame() override;
|
||||
|
||||
RangeModeType rangeMode() const;
|
||||
RangeModeType rangeMode() const;
|
||||
static cvf::Color3ubArray colorArrayFromColorType( ColorRangesType colorType );
|
||||
|
||||
private:
|
||||
void setNamedCategories( const std::vector<QString>& categoryNames, bool inverse );
|
||||
@ -164,8 +165,6 @@ private:
|
||||
|
||||
friend class RimViewLinker;
|
||||
|
||||
static cvf::Color3ubArray colorArrayFromColorType( ColorRangesType colorType );
|
||||
|
||||
caf::OverlayScalarMapperLegend* getOrCreateScalarMapperLegend();
|
||||
caf::CategoryLegend* getOrCreateCategoryLegend();
|
||||
|
||||
|
@ -71,6 +71,8 @@
|
||||
#include "RiuWellPathComponentPlotItem.h"
|
||||
|
||||
#include "RiuQwtLinearScaleEngine.h"
|
||||
|
||||
#include "cafPdmUiSliderEditor.h"
|
||||
#include "cvfAssert.h"
|
||||
|
||||
#define RI_LOGPLOTTRACK_MINX_DEFAULT -10.0
|
||||
@ -127,6 +129,18 @@ void AppEnum<RimWellLogTrack::WidthScaleFactor>::setUp()
|
||||
addItem( RimWellLogTrack::EXTRA_WIDE_TRACK, "EXTRA_WIDE_TRACK", "Extra wide" );
|
||||
setDefault( RimWellLogTrack::NORMAL_TRACK );
|
||||
}
|
||||
|
||||
template <>
|
||||
void AppEnum<RiuPlotAnnotationTool::FormationDisplay>::setUp()
|
||||
{
|
||||
addItem( RiuPlotAnnotationTool::NONE, "NONE", "None" );
|
||||
addItem( RiuPlotAnnotationTool::DARK_LINES, "DARK_LINES", "Dark Lines" );
|
||||
addItem( RiuPlotAnnotationTool::COLORED_LINES, "COLORED_LINES", "Colored Lines" );
|
||||
addItem( RiuPlotAnnotationTool::COLOR_SHADING, "COLOR_SHADING", "Color Shading" );
|
||||
addItem( RiuPlotAnnotationTool::COLOR_SHADING_AND_LINES, "SHADING_AND_LINES", "Color Shading and Lines" );
|
||||
setDefault( RiuPlotAnnotationTool::NONE );
|
||||
}
|
||||
|
||||
} // namespace caf
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -161,7 +175,16 @@ RimWellLogTrack::RimWellLogTrack()
|
||||
m_majorTickInterval.uiCapability()->setUiHidden( true );
|
||||
m_minorTickInterval.uiCapability()->setUiHidden( true );
|
||||
|
||||
CAF_PDM_InitField( &m_showFormations, "ShowFormations", false, "Show Lines", "", "", "" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_formationDisplay, "FormationDisplay", "Show Formations", "", "", "" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_colorShadingPalette, "ColorShadingPalette", "Colors", "", "", "" );
|
||||
m_colorShadingPalette = RimRegularLegendConfig::CATEGORY;
|
||||
|
||||
CAF_PDM_InitField( &m_colorShadingTransparency, "ColorShadingTransparency", 50, "Color Transparency", "", "", "" );
|
||||
m_colorShadingTransparency.uiCapability()->setUiEditorTypeName( caf::PdmUiSliderEditor::uiEditorTypeName() );
|
||||
|
||||
CAF_PDM_InitField( &m_showFormations_OBSOLETE, "ShowFormations", false, "Show Lines", "", "", "" );
|
||||
m_showFormations_OBSOLETE.xmlCapability()->setIOWritable( false );
|
||||
CAF_PDM_InitField( &m_showFormationLabels, "ShowFormationLabels", true, "Show Labels", "", "", "" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_formationSource, "FormationSource", "Source", "", "", "" );
|
||||
@ -354,7 +377,8 @@ void RimWellLogTrack::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
||||
|
||||
m_wellLogTrackPlotWidget->replot();
|
||||
}
|
||||
else if ( changedField == &m_showFormations || changedField == &m_formationSource )
|
||||
else if ( changedField == &m_formationDisplay || changedField == &m_formationSource ||
|
||||
changedField == &m_colorShadingTransparency || changedField == &m_colorShadingPalette )
|
||||
{
|
||||
if ( changedField == &m_formationSource && m_formationSource == WELL_PICK_FILTER )
|
||||
{
|
||||
@ -636,6 +660,27 @@ QList<caf::PdmOptionItemInfo> RimWellLogTrack::calculateValueOptions( const caf:
|
||||
RimTools::wellPathOptionItems( &options );
|
||||
options.push_front( caf::PdmOptionItemInfo( "None", nullptr ) );
|
||||
}
|
||||
else if ( fieldNeedingOptions == &m_colorShadingPalette )
|
||||
{
|
||||
std::vector<RimRegularLegendConfig::ColorRangesType> rangeTypes;
|
||||
rangeTypes.push_back( RimRegularLegendConfig::NORMAL );
|
||||
rangeTypes.push_back( RimRegularLegendConfig::OPPOSITE_NORMAL );
|
||||
rangeTypes.push_back( RimRegularLegendConfig::WHITE_PINK );
|
||||
rangeTypes.push_back( RimRegularLegendConfig::PINK_WHITE );
|
||||
rangeTypes.push_back( RimRegularLegendConfig::BLUE_WHITE_RED );
|
||||
rangeTypes.push_back( RimRegularLegendConfig::RED_WHITE_BLUE );
|
||||
rangeTypes.push_back( RimRegularLegendConfig::WHITE_BLACK );
|
||||
rangeTypes.push_back( RimRegularLegendConfig::BLACK_WHITE );
|
||||
rangeTypes.push_back( RimRegularLegendConfig::ANGULAR );
|
||||
rangeTypes.push_back( RimRegularLegendConfig::CATEGORY );
|
||||
|
||||
for ( RimRegularLegendConfig::ColorRangesType colType : rangeTypes )
|
||||
{
|
||||
options.push_back(
|
||||
caf::PdmOptionItemInfo( RimRegularLegendConfig::ColorRangeEnum::uiText( colType ), colType ) );
|
||||
}
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
@ -785,13 +830,13 @@ void RimWellLogTrack::loadDataAndUpdate( bool updateParentPlotAndToolbars )
|
||||
curves[cIdx]->loadDataAndUpdate( false );
|
||||
}
|
||||
|
||||
if ( m_showFormations )
|
||||
if ( m_formationDisplay == RiuPlotAnnotationTool::NONE )
|
||||
{
|
||||
setFormationFieldsUiReadOnly( false );
|
||||
setFormationFieldsUiReadOnly( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
setFormationFieldsUiReadOnly( true );
|
||||
setFormationFieldsUiReadOnly( false );
|
||||
}
|
||||
|
||||
if ( m_wellLogTrackPlotWidget )
|
||||
@ -836,7 +881,7 @@ void RimWellLogTrack::setAndUpdateWellPathFormationNamesData( RimCase* rimCase,
|
||||
|
||||
updateConnectedEditors();
|
||||
|
||||
if ( m_showFormations )
|
||||
if ( m_formationDisplay != RiuPlotAnnotationTool::NONE )
|
||||
{
|
||||
updateFormationNamesOnPlot();
|
||||
}
|
||||
@ -868,7 +913,7 @@ void RimWellLogTrack::setAndUpdateSimWellFormationNamesData( RimCase* rimCase, c
|
||||
|
||||
updateConnectedEditors();
|
||||
|
||||
if ( m_showFormations )
|
||||
if ( m_formationDisplay != RiuPlotAnnotationTool::NONE )
|
||||
{
|
||||
updateFormationNamesOnPlot();
|
||||
}
|
||||
@ -1205,7 +1250,7 @@ void RimWellLogTrack::setXAxisGridVisibility( RimWellLogPlot::AxisGridVisibility
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellLogTrack::setShowFormations( bool on )
|
||||
{
|
||||
m_showFormations = on;
|
||||
m_showFormations_OBSOLETE = on;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -1213,7 +1258,7 @@ void RimWellLogTrack::setShowFormations( bool on )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimWellLogTrack::showFormations() const
|
||||
{
|
||||
return m_showFormations;
|
||||
return m_showFormations_OBSOLETE;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -1281,7 +1326,16 @@ void RimWellLogTrack::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering
|
||||
uiOrdering.add( &m_userName );
|
||||
caf::PdmUiGroup* formationGroup = uiOrdering.addNewGroup( "Zonation/Formation Names" );
|
||||
|
||||
formationGroup->add( &m_showFormations );
|
||||
formationGroup->add( &m_formationDisplay );
|
||||
if ( m_formationDisplay() & RiuPlotAnnotationTool::COLOR_SHADING ||
|
||||
m_formationDisplay() & RiuPlotAnnotationTool::COLORED_LINES )
|
||||
{
|
||||
formationGroup->add( &m_colorShadingPalette );
|
||||
if ( m_formationDisplay() & RiuPlotAnnotationTool::COLOR_SHADING )
|
||||
{
|
||||
formationGroup->add( &m_colorShadingTransparency );
|
||||
}
|
||||
}
|
||||
formationGroup->add( &m_showFormationLabels );
|
||||
|
||||
if ( !m_formationsForCaseWithSimWellOnly )
|
||||
@ -1345,6 +1399,35 @@ void RimWellLogTrack::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering
|
||||
uiOrdering.skipRemainingFields( true );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellLogTrack::initAfterRead()
|
||||
{
|
||||
if ( m_showFormations_OBSOLETE() && m_formationDisplay() == RiuPlotAnnotationTool::NONE )
|
||||
{
|
||||
m_formationDisplay = RiuPlotAnnotationTool::COLORED_LINES;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellLogTrack::defineEditorAttribute( const caf::PdmFieldHandle* field,
|
||||
QString uiConfigName,
|
||||
caf::PdmUiEditorAttribute* attribute )
|
||||
{
|
||||
if ( field == &m_colorShadingTransparency )
|
||||
{
|
||||
auto sliderAttrib = dynamic_cast<caf::PdmUiSliderEditorAttribute*>( attribute );
|
||||
if ( sliderAttrib )
|
||||
{
|
||||
sliderAttrib->m_minimum = 0;
|
||||
sliderAttrib->m_maximum = 100;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -1509,7 +1592,7 @@ void RimWellLogTrack::uiOrderingForRftPltFormations( caf::PdmUiOrdering& uiOrder
|
||||
{
|
||||
caf::PdmUiGroup* formationGroup = uiOrdering.addNewGroup( "Zonation/Formation Names" );
|
||||
formationGroup->setCollapsedByDefault( true );
|
||||
formationGroup->add( &m_showFormations );
|
||||
formationGroup->add( &m_formationDisplay );
|
||||
formationGroup->add( &m_formationSource );
|
||||
if ( m_formationSource == CASE )
|
||||
{
|
||||
@ -1728,7 +1811,7 @@ void RimWellLogTrack::updateFormationNamesOnPlot()
|
||||
{
|
||||
removeFormationNames();
|
||||
|
||||
if ( m_showFormations == false ) return;
|
||||
if ( m_formationDisplay == RiuPlotAnnotationTool::NONE ) return;
|
||||
|
||||
if ( m_annotationTool == nullptr )
|
||||
{
|
||||
@ -1807,7 +1890,18 @@ void RimWellLogTrack::updateFormationNamesOnPlot()
|
||||
&formationNamesToPlot,
|
||||
&yValues );
|
||||
|
||||
m_annotationTool->attachFormationNames( this->viewer(), formationNamesToPlot, yValues, m_showFormationLabels() );
|
||||
std::pair<double, double> xRange = std::make_pair( m_visibleXRangeMin(), m_visibleXRangeMax() );
|
||||
|
||||
caf::ColorTable colorTable( RimRegularLegendConfig::colorArrayFromColorType( m_colorShadingPalette() ) );
|
||||
|
||||
m_annotationTool->attachFormationNames( this->viewer(),
|
||||
formationNamesToPlot,
|
||||
xRange,
|
||||
yValues,
|
||||
m_formationDisplay(),
|
||||
colorTable,
|
||||
( ( 100 - m_colorShadingTransparency ) * 255 ) / 100,
|
||||
m_showFormationLabels() );
|
||||
}
|
||||
else if ( m_formationSource() == WELL_PICK_FILTER )
|
||||
{
|
||||
|
@ -22,6 +22,9 @@
|
||||
#include "RimWellLogPlot.h"
|
||||
|
||||
#include "RigWellPathFormations.h"
|
||||
#include "RiuPlotAnnotationTool.h"
|
||||
|
||||
#include "RimRegularLegendConfig.h"
|
||||
|
||||
#include "cafPdmChildArrayField.h"
|
||||
#include "cafPdmField.h"
|
||||
@ -40,7 +43,6 @@ class RimWellPathAttributeCollection;
|
||||
class RimWellFlowRateCurve;
|
||||
class RimWellLogCurve;
|
||||
class RimWellPath;
|
||||
class RiuPlotAnnotationTool;
|
||||
class RiuWellPathComponentPlotItem;
|
||||
class RiuWellLogTrack;
|
||||
class RigEclipseWellLogExtractor;
|
||||
@ -177,6 +179,10 @@ private:
|
||||
caf::PdmFieldHandle* objectToggleField() override;
|
||||
caf::PdmFieldHandle* userDescriptionField() override;
|
||||
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
||||
void initAfterRead() override;
|
||||
void defineEditorAttribute( const caf::PdmFieldHandle* field,
|
||||
QString uiConfigName,
|
||||
caf::PdmUiEditorAttribute* attribute ) override;
|
||||
|
||||
void computeAndSetXRangeMinForLogarithmicScale();
|
||||
|
||||
@ -228,27 +234,31 @@ private:
|
||||
caf::PdmField<double> m_majorTickInterval;
|
||||
caf::PdmField<double> m_minorTickInterval;
|
||||
|
||||
caf::PdmField<bool> m_showFormations;
|
||||
caf::PdmField<bool> m_showFormationLabels;
|
||||
caf::PdmField<caf::AppEnum<FormationSource>> m_formationSource;
|
||||
caf::PdmPtrField<RimCase*> m_formationCase;
|
||||
caf::PdmField<caf::AppEnum<TrajectoryType>> m_formationTrajectoryType;
|
||||
caf::PdmPtrField<RimWellPath*> m_formationWellPathForSourceCase;
|
||||
caf::PdmPtrField<RimWellPath*> m_formationWellPathForSourceWellPath;
|
||||
caf::PdmField<QString> m_formationSimWellName;
|
||||
caf::PdmField<int> m_formationBranchIndex;
|
||||
caf::PdmField<caf::AppEnum<RigWellPathFormations::FormationLevel>> m_formationLevel;
|
||||
caf::PdmField<bool> m_showformationFluids;
|
||||
caf::PdmField<caf::AppEnum<WidthScaleFactor>> m_widthScaleFactor;
|
||||
caf::PdmField<bool> m_formationBranchDetection;
|
||||
caf::PdmField<bool> m_showWellPathAttributes;
|
||||
caf::PdmField<bool> m_showWellPathCompletions;
|
||||
caf::PdmField<bool> m_showWellPathComponentsBothSides;
|
||||
caf::PdmField<bool> m_showWellPathComponentLabels;
|
||||
caf::PdmField<bool> m_wellPathAttributesInLegend;
|
||||
caf::PdmField<bool> m_wellPathCompletionsInLegend;
|
||||
caf::PdmPtrField<RimWellPath*> m_wellPathComponentSource;
|
||||
caf::PdmPtrField<RimWellPathAttributeCollection*> m_wellPathAttributeCollection;
|
||||
caf::PdmField<caf::AppEnum<RiuPlotAnnotationTool::FormationDisplay>> m_formationDisplay;
|
||||
caf::PdmField<RimRegularLegendConfig::ColorRangeEnum> m_colorShadingPalette;
|
||||
caf::PdmField<int> m_colorShadingTransparency;
|
||||
caf::PdmField<bool> m_showFormationLabels;
|
||||
caf::PdmField<caf::AppEnum<FormationSource>> m_formationSource;
|
||||
caf::PdmPtrField<RimCase*> m_formationCase;
|
||||
caf::PdmField<caf::AppEnum<TrajectoryType>> m_formationTrajectoryType;
|
||||
caf::PdmPtrField<RimWellPath*> m_formationWellPathForSourceCase;
|
||||
caf::PdmPtrField<RimWellPath*> m_formationWellPathForSourceWellPath;
|
||||
caf::PdmField<QString> m_formationSimWellName;
|
||||
caf::PdmField<int> m_formationBranchIndex;
|
||||
caf::PdmField<caf::AppEnum<RigWellPathFormations::FormationLevel>> m_formationLevel;
|
||||
caf::PdmField<bool> m_showformationFluids;
|
||||
caf::PdmField<caf::AppEnum<WidthScaleFactor>> m_widthScaleFactor;
|
||||
caf::PdmField<bool> m_formationBranchDetection;
|
||||
caf::PdmField<bool> m_showWellPathAttributes;
|
||||
caf::PdmField<bool> m_showWellPathCompletions;
|
||||
caf::PdmField<bool> m_showWellPathComponentsBothSides;
|
||||
caf::PdmField<bool> m_showWellPathComponentLabels;
|
||||
caf::PdmField<bool> m_wellPathAttributesInLegend;
|
||||
caf::PdmField<bool> m_wellPathCompletionsInLegend;
|
||||
caf::PdmPtrField<RimWellPath*> m_wellPathComponentSource;
|
||||
caf::PdmPtrField<RimWellPathAttributeCollection*> m_wellPathAttributeCollection;
|
||||
|
||||
caf::PdmField<bool> m_showFormations_OBSOLETE;
|
||||
|
||||
std::vector<std::unique_ptr<RiuWellPathComponentPlotItem>> m_wellPathAttributePlotObjects;
|
||||
|
||||
|
@ -18,10 +18,18 @@
|
||||
|
||||
#include "RiuPlotAnnotationTool.h"
|
||||
|
||||
#include "RiaColorTables.h"
|
||||
#include "RiaColorTools.h"
|
||||
|
||||
#include "cafCategoryMapper.h"
|
||||
#include "cvfMath.h"
|
||||
|
||||
#include "qwt_plot.h"
|
||||
#include "qwt_plot_shapeitem.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "cvfMath.h"
|
||||
#include "qwt_plot.h"
|
||||
#include <algorithm>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@ -36,8 +44,12 @@ RiuPlotAnnotationTool::~RiuPlotAnnotationTool()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuPlotAnnotationTool::attachFormationNames( QwtPlot* plot,
|
||||
const std::vector<QString>& names,
|
||||
const std::pair<double, double> xRange,
|
||||
const std::vector<std::pair<double, double>> yPositions,
|
||||
bool showNames )
|
||||
FormationDisplay formationDisplay,
|
||||
const caf::ColorTable& colorTable,
|
||||
int shadingAlphaByte,
|
||||
bool showNames /*= true */ )
|
||||
{
|
||||
detachAllAnnotations();
|
||||
|
||||
@ -46,6 +58,13 @@ void RiuPlotAnnotationTool::attachFormationNames( QwtPlot*
|
||||
|
||||
double delta = 0.5;
|
||||
|
||||
std::vector<int> categoryIndices( names.size() );
|
||||
std::iota( categoryIndices.begin(), categoryIndices.end(), 0 );
|
||||
|
||||
caf::CategoryMapper catMapper;
|
||||
catMapper.setCategories( categoryIndices );
|
||||
catMapper.setInterpolateColors( colorTable.color3ubArray() );
|
||||
|
||||
for ( size_t i = 0; i < names.size(); i++ )
|
||||
{
|
||||
QwtPlotMarker* line( new QwtPlotMarker() );
|
||||
@ -54,21 +73,56 @@ void RiuPlotAnnotationTool::attachFormationNames( QwtPlot*
|
||||
if ( showNames )
|
||||
{
|
||||
name = names[i];
|
||||
if ( names[i].toLower().indexOf( "top" ) == -1 )
|
||||
if ( ( formationDisplay & COLOR_SHADING ) == 0 && names[i].toLower().indexOf( "top" ) == -1 )
|
||||
{
|
||||
name += " Top";
|
||||
}
|
||||
}
|
||||
if ( formationDisplay & COLOR_SHADING )
|
||||
{
|
||||
cvf::Color3ub cvfColor = catMapper.mapToColor( static_cast<double>( i ) );
|
||||
QColor shadingColor( cvfColor.r(), cvfColor.g(), cvfColor.b(), shadingAlphaByte );
|
||||
|
||||
RiuPlotAnnotationTool::horizontalDashedLine( line, name, yPositions[i].first );
|
||||
QwtPlotShapeItem* shading = new QwtPlotShapeItem( name );
|
||||
|
||||
QwtInterval axisInterval = m_plot->axisInterval( QwtPlot::xBottom );
|
||||
|
||||
QRectF shadingRect( axisInterval.minValue(),
|
||||
yPositions[i].first,
|
||||
axisInterval.width(),
|
||||
yPositions[i].second - yPositions[i].first );
|
||||
|
||||
shading->setRect( shadingRect );
|
||||
shading->setPen( shadingColor, 0.0, Qt::NoPen );
|
||||
shading->setBrush( QBrush( shadingColor ) );
|
||||
shading->attach( m_plot );
|
||||
shading->setZ( -100.0 );
|
||||
shading->setXAxis( QwtPlot::xBottom );
|
||||
m_markers.push_back( std::move( shading ) );
|
||||
}
|
||||
|
||||
QColor lineColor( 0, 0, 0, 0 );
|
||||
QColor textColor( 0, 0, 0, 255 );
|
||||
if ( formationDisplay & DARK_LINES || formationDisplay & COLORED_LINES )
|
||||
{
|
||||
cvf::Color3ub cvfColor = catMapper.mapToColor( static_cast<double>( i ) );
|
||||
QColor cycledColor( cvfColor.r(), cvfColor.g(), cvfColor.b() );
|
||||
|
||||
lineColor = formationDisplay & DARK_LINES ? QColor( 0, 0, 100 ) : cycledColor;
|
||||
textColor = lineColor;
|
||||
}
|
||||
RiuPlotAnnotationTool::horizontalDashedLineWithColor( line, lineColor, textColor, name, yPositions[i].first );
|
||||
line->attach( m_plot );
|
||||
m_markers.push_back( std::move( line ) );
|
||||
|
||||
if ( ( i != names.size() - 1 ) && cvf::Math::abs( yPositions[i].second - yPositions[i + 1].first ) > delta )
|
||||
{
|
||||
QwtPlotMarker* bottomLine( new QwtPlotMarker() );
|
||||
RiuPlotAnnotationTool::horizontalDashedLine( bottomLine, QString(), yPositions[i].second );
|
||||
RiuPlotAnnotationTool::horizontalDashedLineWithColor( bottomLine,
|
||||
lineColor,
|
||||
textColor,
|
||||
QString(),
|
||||
yPositions[i].second );
|
||||
|
||||
bottomLine->attach( m_plot );
|
||||
m_markers.push_back( std::move( bottomLine ) );
|
||||
@ -108,7 +162,7 @@ void RiuPlotAnnotationTool::attachAnnotationLine( QwtPlot* plot,
|
||||
m_plot = plot;
|
||||
|
||||
QwtPlotMarker* line( new QwtPlotMarker() );
|
||||
RiuPlotAnnotationTool::horizontalDashedLineWithColor( line, color, annotationText, yPosition );
|
||||
RiuPlotAnnotationTool::horizontalDashedLineWithColor( line, color, color, annotationText, yPosition );
|
||||
line->attach( m_plot );
|
||||
m_markers.push_back( std::move( line ) );
|
||||
}
|
||||
@ -134,16 +188,14 @@ void RiuPlotAnnotationTool::detachAllAnnotations()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuPlotAnnotationTool::horizontalDashedLine( QwtPlotMarker* line, const QString& name, double yValue )
|
||||
{
|
||||
horizontalDashedLineWithColor( line, QColor( 0, 0, 100 ), name, yValue );
|
||||
horizontalDashedLineWithColor( line, QColor( 0, 0, 100 ), QColor( 0, 0, 100 ), name, yValue );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuPlotAnnotationTool::horizontalDashedLineWithColor( QwtPlotMarker* line,
|
||||
const QColor& color,
|
||||
const QString& name,
|
||||
double yValue )
|
||||
void RiuPlotAnnotationTool::horizontalDashedLineWithColor(
|
||||
QwtPlotMarker* line, const QColor& color, const QColor& textColor, const QString& name, double yValue )
|
||||
{
|
||||
QPen curvePen;
|
||||
curvePen.setStyle( Qt::DashLine );
|
||||
@ -153,6 +205,8 @@ void RiuPlotAnnotationTool::horizontalDashedLineWithColor( QwtPlotMarker* line,
|
||||
line->setLineStyle( QwtPlotMarker::HLine );
|
||||
line->setLinePen( curvePen );
|
||||
line->setYValue( yValue );
|
||||
line->setLabel( name );
|
||||
QwtText label( name );
|
||||
label.setColor( textColor );
|
||||
line->setLabel( label );
|
||||
line->setLabelAlignment( Qt::AlignRight | Qt::AlignBottom );
|
||||
}
|
||||
|
@ -18,6 +18,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafColorTable.h"
|
||||
|
||||
#include "qwt_plot_marker.h"
|
||||
|
||||
#include <memory>
|
||||
@ -30,13 +32,27 @@ class QwtPlot;
|
||||
|
||||
class RiuPlotAnnotationTool
|
||||
{
|
||||
public:
|
||||
enum FormationDisplay
|
||||
{
|
||||
NONE = 0x00,
|
||||
DARK_LINES = 0x01,
|
||||
COLORED_LINES = 0x02,
|
||||
COLOR_SHADING = 0x04,
|
||||
COLOR_SHADING_AND_LINES = 0x05
|
||||
};
|
||||
|
||||
public:
|
||||
RiuPlotAnnotationTool(){};
|
||||
~RiuPlotAnnotationTool();
|
||||
|
||||
void attachFormationNames( QwtPlot* plot,
|
||||
const std::vector<QString>& names,
|
||||
const std::pair<double, double> xRange,
|
||||
const std::vector<std::pair<double, double>> yPositions,
|
||||
FormationDisplay formationDisplay,
|
||||
const caf::ColorTable& colorTable,
|
||||
int shadingAlphaByte,
|
||||
bool showNames = true );
|
||||
void attachWellPicks( QwtPlot* plot, const std::vector<QString>& names, const std::vector<double> yPositions );
|
||||
|
||||
@ -46,10 +62,10 @@ public:
|
||||
|
||||
private:
|
||||
static void horizontalDashedLine( QwtPlotMarker* line, const QString& name, double yValue );
|
||||
static void
|
||||
horizontalDashedLineWithColor( QwtPlotMarker* line, const QColor& color, const QString& name, double yValue );
|
||||
static void horizontalDashedLineWithColor(
|
||||
QwtPlotMarker* line, const QColor& color, const QColor& textColor, const QString& name, double yValue );
|
||||
|
||||
private:
|
||||
QPointer<QwtPlot> m_plot;
|
||||
std::vector<QwtPlotMarker*> m_markers;
|
||||
QPointer<QwtPlot> m_plot;
|
||||
std::vector<QwtPlotItem*> m_markers;
|
||||
};
|
||||
|
@ -142,15 +142,6 @@ void RiuWellLogPlot::insertTrackPlot( RiuWellLogTrack* trackPlot, size_t index )
|
||||
legend->contentsWidget()->layout()->setAlignment( Qt::AlignBottom | Qt::AlignHCenter );
|
||||
m_legends.insert( static_cast<int>( index ), legend );
|
||||
|
||||
m_trackLayout->addWidget( legend, 0, static_cast<int>( index ) );
|
||||
m_trackLayout->addWidget( trackPlot, 1, static_cast<int>( index ) );
|
||||
m_trackLayout->setRowStretch( 1, 1 );
|
||||
|
||||
if ( !m_plotDefinition->areTrackLegendsVisible() )
|
||||
{
|
||||
legend->hide();
|
||||
}
|
||||
|
||||
trackPlot->updateLegend();
|
||||
|
||||
if ( trackPlot->isRimTrackVisible() )
|
||||
@ -161,6 +152,8 @@ void RiuWellLogPlot::insertTrackPlot( RiuWellLogTrack* trackPlot, size_t index )
|
||||
{
|
||||
trackPlot->hide();
|
||||
}
|
||||
|
||||
updateChildrenLayout();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -179,6 +172,8 @@ void RiuWellLogPlot::removeTrackPlot( RiuWellLogTrack* trackPlot )
|
||||
QwtLegend* legend = m_legends[trackIdx];
|
||||
m_legends.removeAt( trackIdx );
|
||||
delete legend;
|
||||
|
||||
updateChildrenLayout();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -241,6 +236,8 @@ void RiuWellLogPlot::setTitleVisible( bool visible )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogPlot::updateChildrenLayout()
|
||||
{
|
||||
reinsertTracks();
|
||||
|
||||
int trackCount = m_trackPlots.size();
|
||||
int numTracksAlreadyShown = 0;
|
||||
for ( int tIdx = 0; tIdx < trackCount; ++tIdx )
|
||||
@ -265,9 +262,9 @@ void RiuWellLogPlot::updateChildrenLayout()
|
||||
RiuWellLogTrack* riuTrack = m_trackPlots[tIdx];
|
||||
m_trackLayout->setColumnStretch( tIdx, riuTrack->widthScaleFactor() );
|
||||
}
|
||||
|
||||
alignCanvasTops();
|
||||
this->update();
|
||||
this->repaint();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -408,6 +405,29 @@ void RiuWellLogPlot::alignCanvasTops()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogPlot::reinsertTracks()
|
||||
{
|
||||
int visibleIndex = 0;
|
||||
for ( int tIdx = 0; tIdx < m_trackPlots.size(); ++tIdx )
|
||||
{
|
||||
if ( m_trackPlots[tIdx]->isVisible() )
|
||||
{
|
||||
m_trackLayout->addWidget( m_legends[tIdx], 0, static_cast<int>( visibleIndex ) );
|
||||
m_trackLayout->addWidget( m_trackPlots[tIdx], 1, static_cast<int>( visibleIndex ) );
|
||||
m_trackLayout->setRowStretch( 1, 1 );
|
||||
|
||||
if ( !m_plotDefinition->areTrackLegendsVisible() )
|
||||
{
|
||||
m_legends[tIdx]->hide();
|
||||
}
|
||||
visibleIndex++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -83,7 +83,7 @@ protected:
|
||||
private:
|
||||
void updateScrollBar( double minDepth, double maxDepth );
|
||||
void alignCanvasTops();
|
||||
|
||||
void reinsertTracks();
|
||||
private slots:
|
||||
void slotSetMinDepth( int value );
|
||||
|
||||
|
@ -34,18 +34,16 @@
|
||||
//
|
||||
//##################################################################################################
|
||||
|
||||
|
||||
#include "cafColorTable.h"
|
||||
|
||||
#include <QColor>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace caf {
|
||||
|
||||
|
||||
|
||||
namespace caf
|
||||
{
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
ColorTable::ColorTable(const std::vector<cvf::Color3ub>& colors)
|
||||
: m_colors(colors)
|
||||
@ -54,7 +52,16 @@ ColorTable::ColorTable(const std::vector<cvf::Color3ub>& colors)
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
ColorTable::ColorTable(const cvf::Color3ubArray& colors)
|
||||
: m_colors(colors.begin(), colors.end())
|
||||
{
|
||||
CVF_ASSERT(m_colors.size() > 0);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Color3f ColorTable::cycledColor3f(size_t itemIndex) const
|
||||
{
|
||||
@ -62,7 +69,7 @@ cvf::Color3f ColorTable::cycledColor3f(size_t itemIndex) const
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Color3ub ColorTable::cycledColor3ub(size_t itemIndex) const
|
||||
{
|
||||
@ -72,7 +79,7 @@ cvf::Color3ub ColorTable::cycledColor3ub(size_t itemIndex) const
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QColor ColorTable::cycledQColor(size_t itemIndex) const
|
||||
{
|
||||
@ -81,7 +88,7 @@ QColor ColorTable::cycledQColor(size_t itemIndex) const
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Color3ubArray ColorTable::color3ubArray() const
|
||||
{
|
||||
@ -89,7 +96,7 @@ cvf::Color3ubArray ColorTable::color3ubArray() const
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Color3fArray ColorTable::color3fArray() const
|
||||
{
|
||||
@ -105,7 +112,7 @@ cvf::Color3fArray ColorTable::color3fArray() const
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
size_t ColorTable::size() const
|
||||
{
|
||||
@ -113,7 +120,17 @@ size_t ColorTable::size() const
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::ColorTable ColorTable::inverted() const
|
||||
{
|
||||
std::vector<cvf::Color3ub> invertedColors = m_colors;
|
||||
std::reverse(invertedColors.begin(), invertedColors.end());
|
||||
return ColorTable(invertedColors);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Color3ub ColorTable::fromQColor(const QColor& color)
|
||||
{
|
||||
@ -121,7 +138,7 @@ cvf::Color3ub ColorTable::fromQColor(const QColor& color)
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Color3ubArray ColorTable::interpolateColorArray(const cvf::Color3ubArray& colorArray, size_t targetColorCount)
|
||||
{
|
||||
@ -132,7 +149,7 @@ cvf::Color3ubArray ColorTable::interpolateColorArray(const cvf::Color3ubArray& c
|
||||
cvf::Color3ubArray colors;
|
||||
colors.reserve(targetColorCount);
|
||||
|
||||
const size_t inputColorsMaxIdx = inputColorCount - 1;
|
||||
const size_t inputColorsMaxIdx = inputColorCount - 1;
|
||||
const size_t outputColorsMaxIdx = targetColorCount - 1;
|
||||
|
||||
for (size_t outputLevelIdx = 0; outputLevelIdx < outputColorsMaxIdx; outputLevelIdx++)
|
||||
@ -148,9 +165,9 @@ cvf::Color3ubArray ColorTable::interpolateColorArray(const cvf::Color3ubArray& c
|
||||
cvf::Color3ub c1 = colorArray[inputLevelIndex];
|
||||
cvf::Color3ub c2 = colorArray[inputLevelIndex + 1];
|
||||
|
||||
int r = static_cast<int>(c1.r() + t*(c2.r() - c1.r()) + 0.5);
|
||||
int g = static_cast<int>(c1.g() + t*(c2.g() - c1.g()) + 0.5);
|
||||
int b = static_cast<int>(c1.b() + t*(c2.b() - c1.b()) + 0.5);
|
||||
int r = static_cast<int>(c1.r() + t * (c2.r() - c1.r()) + 0.5);
|
||||
int g = static_cast<int>(c1.g() + t * (c2.g() - c1.g()) + 0.5);
|
||||
int b = static_cast<int>(c1.b() + t * (c2.b() - c1.b()) + 0.5);
|
||||
|
||||
r = cvf::Math::clamp(r, 0, 255);
|
||||
g = cvf::Math::clamp(g, 0, 255);
|
||||
@ -163,7 +180,6 @@ cvf::Color3ubArray ColorTable::interpolateColorArray(const cvf::Color3ubArray& c
|
||||
colors.add(colorArray[colorArray.size() - 1]);
|
||||
|
||||
return colors;
|
||||
|
||||
}
|
||||
|
||||
} // namespace caf
|
||||
|
@ -34,43 +34,44 @@
|
||||
//
|
||||
//##################################################################################################
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cvfBase.h"
|
||||
#include "cvfArray.h"
|
||||
#include "cvfBase.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
||||
class QColor;
|
||||
|
||||
|
||||
namespace caf {
|
||||
|
||||
namespace caf
|
||||
{
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//==================================================================================================
|
||||
class ColorTable
|
||||
{
|
||||
public:
|
||||
explicit ColorTable(const std::vector<cvf::Color3ub>& colors);
|
||||
explicit ColorTable(const cvf::Color3ubArray& colors);
|
||||
|
||||
cvf::Color3f cycledColor3f(size_t itemIndex) const;
|
||||
cvf::Color3ub cycledColor3ub(size_t itemIndex) const;
|
||||
QColor cycledQColor(size_t itemIndex) const;
|
||||
cvf::Color3f cycledColor3f(size_t itemIndex) const;
|
||||
cvf::Color3ub cycledColor3ub(size_t itemIndex) const;
|
||||
QColor cycledQColor(size_t itemIndex) const;
|
||||
|
||||
cvf::Color3ubArray color3ubArray() const;
|
||||
cvf::Color3fArray color3fArray() const;
|
||||
cvf::Color3ubArray color3ubArray() const;
|
||||
cvf::Color3fArray color3fArray() const;
|
||||
|
||||
size_t size() const;
|
||||
size_t size() const;
|
||||
|
||||
ColorTable inverted() const;
|
||||
|
||||
static cvf::Color3ub fromQColor(const QColor& color);
|
||||
static cvf::Color3ubArray interpolateColorArray(const cvf::Color3ubArray& colorArray, size_t targetColorCount);
|
||||
|
||||
static cvf::Color3ub fromQColor(const QColor& color);
|
||||
static cvf::Color3ubArray interpolateColorArray(const cvf::Color3ubArray& colorArray, size_t targetColorCount);
|
||||
private:
|
||||
const std::vector<cvf::Color3ub> m_colors;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace caf
|
||||
|
Loading…
Reference in New Issue
Block a user