Skip to content

Commit

Permalink
QskScaleRenderer -> QskGraduationRenderer
Browse files Browse the repository at this point in the history
  • Loading branch information
uwerat committed Nov 28, 2023
1 parent 717a1c2 commit d0472bc
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 62 deletions.
4 changes: 2 additions & 2 deletions playground/plots/PlotSkin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <QskBoxShapeMetrics.h>
#include <QskStippleMetrics.h>

#include <QskScaleRenderer.h>
#include <QskGraduationRenderer.h>

#include <qbrush.h>

Expand Down Expand Up @@ -98,7 +98,7 @@ void SkinEditor::setupPlotHints()

setColor( Q::AxisScale, qRgb( 20, 20, 20 ) );
setFontRole( Q::AxisScale, QskSkin::MediumFont );
setFlag( Q::AxisScale | A::Style, QskScaleRenderer::Backbone );
setFlag( Q::AxisScale | A::Style, QskGraduationRenderer::Backbone );

// thickness/length of the major ticks
setStrutSize( Q::AxisScale, 1.0, 8.0 );
Expand Down
18 changes: 9 additions & 9 deletions playground/plots/QskPlotViewSkinlet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "QskPlotViewSkinlet.h"
#include "QskPlotView.h"

#include <QskScaleRenderer.h>
#include <QskGraduationRenderer.h>
#include <QskTickmarks.h>
#include <QskTextColors.h>
#include <QskFunctions.h>
Expand Down Expand Up @@ -50,12 +50,12 @@ static inline QskAspect qskAxisAspect( QskPlot::Axis axis )

namespace
{
class ScaleRenderer : public QskScaleRenderer
class Renderer : public QskGraduationRenderer
{
using Inherited = QskScaleRenderer;
using Inherited = QskGraduationRenderer;

public:
ScaleRenderer( const QskPlotView* view, QskPlot::Axis axis )
Renderer( const QskPlotView* view, QskPlot::Axis axis )
: m_view( view )
, m_axis( axis )
{
Expand All @@ -70,8 +70,8 @@ namespace
const auto aspect = Q::AxisScale
| ( ( axis == QskPlot::XBottom ) ? A::Bottom : A::Left );

const auto flags = view->flagHint< QskScaleRenderer::Flags >(
aspect | QskAspect::Style, QskScaleRenderer::Backbone );
const auto flags = view->flagHint< QskGraduationRenderer::Flags >(
aspect | QskAspect::Style, QskGraduationRenderer::Backbone );

setFlags( flags );

Expand Down Expand Up @@ -223,14 +223,14 @@ QRectF QskPlotViewSkinlet::axisRect(

qreal x0, y0;
{
const ScaleRenderer renderer( view, QskPlot::XBottom );
const Renderer renderer( view, QskPlot::XBottom );
const auto sz = renderer.boundingLabelSize();

y0 = rect.bottom() - sz.height()
- renderer.labelOffset() - paddingBottom.height();
}
{
const ScaleRenderer renderer( view, QskPlot::YLeft );
const Renderer renderer( view, QskPlot::YLeft );
const auto sz = renderer.boundingLabelSize();

x0 = rect.left() + sz.width()
Expand Down Expand Up @@ -265,7 +265,7 @@ QSGNode* QskPlotViewSkinlet::updateAxisNode(
const auto axisRect = sampleRect( view, view->contentsRect(), Q::AxisScale, axis );
const auto padding = view->paddingHint( qskAxisAspect( axis ) );

ScaleRenderer renderer( view, axis );
Renderer renderer( view, axis );
if ( axis == QskPlot::XBottom )
{
renderer.setPosition( axisRect.top() + padding.top() );
Expand Down
4 changes: 2 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@ list(APPEND HEADERS
nodes/QskBoxShadowNode.h
nodes/QskColorRamp.h
nodes/QskFillNode.h
nodes/QskGraduationRenderer.h
nodes/QskGraphicNode.h
nodes/QskLinesNode.h
nodes/QskPaintedNode.h
nodes/QskPlainTextRenderer.h
nodes/QskRichTextRenderer.h
nodes/QskScaleRenderer.h
nodes/QskSGNode.h
nodes/QskStrokeNode.h
nodes/QskStippledLineRenderer.h
Expand Down Expand Up @@ -149,13 +149,13 @@ list(APPEND SOURCES
nodes/QskBoxShadowNode.cpp
nodes/QskColorRamp.cpp
nodes/QskFillNode.cpp
nodes/QskGraduationRenderer.cpp
nodes/QskGraphicNode.cpp
nodes/QskLinesNode.cpp
nodes/QskPaintedNode.cpp
nodes/QskPlainTextRenderer.cpp
nodes/QskRectangleNode.cpp
nodes/QskRichTextRenderer.cpp
nodes/QskScaleRenderer.cpp
nodes/QskSGNode.cpp
nodes/QskStrokeNode.cpp
nodes/QskStippledLineRenderer.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*****************************************************************************/

#include "QskScaleRenderer.h"
#include "QskGraduationRenderer.h"
#include "QskTickmarks.h"
#include "QskSkinlet.h"
#include "QskSGNode.h"
Expand Down Expand Up @@ -87,7 +87,7 @@ static inline quint8 qskLabelNodeRole( const QVariant& label )
return QskSGNode::NoRole;
}

class QskScaleRenderer::PrivateData
class QskGraduationRenderer::PrivateData
{
public:

Expand Down Expand Up @@ -117,167 +117,167 @@ class QskScaleRenderer::PrivateData
QskColorFilter colorFilter;

Qt::Edge edge = Qt::BottomEdge;
QskScaleRenderer::Flags flags = ClampedLabels;
QskGraduationRenderer::Flags flags = ClampedLabels;
};

QskScaleRenderer::QskScaleRenderer()
QskGraduationRenderer::QskGraduationRenderer()
: m_data( new PrivateData() )
{
}

QskScaleRenderer::~QskScaleRenderer()
QskGraduationRenderer::~QskGraduationRenderer()
{
}

void QskScaleRenderer::setEdge( Qt::Edge edge )
void QskGraduationRenderer::setEdge( Qt::Edge edge )
{
m_data->edge = edge;
}

Qt::Edge QskScaleRenderer::edge() const
Qt::Edge QskGraduationRenderer::edge() const
{
return m_data->edge;
}

void QskScaleRenderer::setFlag( Flag flag, bool on )
void QskGraduationRenderer::setFlag( Flag flag, bool on )
{
if ( on )
m_data->flags |= flag;
else
m_data->flags &= ~flag;
}

void QskScaleRenderer::setFlags( Flags flags )
void QskGraduationRenderer::setFlags( Flags flags )
{
m_data->flags = flags;
}

QskScaleRenderer::Flags QskScaleRenderer::flags() const
QskGraduationRenderer::Flags QskGraduationRenderer::flags() const
{
return m_data->flags;
}

void QskScaleRenderer::setBoundaries( qreal lowerBound, qreal upperBound )
void QskGraduationRenderer::setBoundaries( qreal lowerBound, qreal upperBound )
{
setBoundaries( QskIntervalF( lowerBound, upperBound ) );
}

void QskScaleRenderer::setBoundaries( const QskIntervalF& boundaries )
void QskGraduationRenderer::setBoundaries( const QskIntervalF& boundaries )
{
m_data->boundaries = boundaries;
}

QskIntervalF QskScaleRenderer::boundaries() const
QskIntervalF QskGraduationRenderer::boundaries() const
{
return m_data->boundaries;
}

qreal QskScaleRenderer::position() const
qreal QskGraduationRenderer::position() const
{
return m_data->position;
}

void QskScaleRenderer::setPosition( qreal pos )
void QskGraduationRenderer::setPosition( qreal pos )
{
m_data->position = pos;
}

void QskScaleRenderer::setRange( qreal from, qreal to )
void QskGraduationRenderer::setRange( qreal from, qreal to )
{
setRange( QskIntervalF( from, to ) );
}

void QskScaleRenderer::setRange( const QskIntervalF& range )
void QskGraduationRenderer::setRange( const QskIntervalF& range )
{
m_data->range = range;
}

QskIntervalF QskScaleRenderer::range() const
QskIntervalF QskGraduationRenderer::range() const
{
return m_data->range;
}

void QskScaleRenderer::setTickmarks( const QskTickmarks& tickmarks )
void QskGraduationRenderer::setTickmarks( const QskTickmarks& tickmarks )
{
m_data->tickmarks = tickmarks;
}

const QskTickmarks& QskScaleRenderer::tickmarks() const
const QskTickmarks& QskGraduationRenderer::tickmarks() const
{
return m_data->tickmarks;
}

void QskScaleRenderer::setSpacing( qreal spacing )
void QskGraduationRenderer::setSpacing( qreal spacing )
{
m_data->spacing = qMax( spacing, 0.0 );
}

qreal QskScaleRenderer::spacing() const
qreal QskGraduationRenderer::spacing() const
{
return m_data->spacing;
}

void QskScaleRenderer::setTickColor( const QColor& color )
void QskGraduationRenderer::setTickColor( const QColor& color )
{
m_data->tickColor = color;
}

QColor QskScaleRenderer::tickColor() const
QColor QskGraduationRenderer::tickColor() const
{
return m_data->tickColor;
}

void QskScaleRenderer::setTickLength( qreal length )
void QskGraduationRenderer::setTickLength( qreal length )
{
m_data->tickLength = qMax( length, 0.0 );
}

qreal QskScaleRenderer::tickLength() const
qreal QskGraduationRenderer::tickLength() const
{
return m_data->tickLength;
}

void QskScaleRenderer::setTickWidth( qreal width )
void QskGraduationRenderer::setTickWidth( qreal width )
{
m_data->tickWidth = qMax( width, 0.0 );
}

qreal QskScaleRenderer::tickWidth() const
qreal QskGraduationRenderer::tickWidth() const
{
return m_data->tickWidth;
}

void QskScaleRenderer::setFont( const QFont& font )
void QskGraduationRenderer::setFont( const QFont& font )
{
m_data->font = font;
}

QFont QskScaleRenderer::font() const
QFont QskGraduationRenderer::font() const
{
return m_data->font;
}

void QskScaleRenderer::setTextColors( const QskTextColors& textColors )
void QskGraduationRenderer::setTextColors( const QskTextColors& textColors )
{
m_data->textColors = textColors;
}

QskTextColors QskScaleRenderer::textColors() const
QskTextColors QskGraduationRenderer::textColors() const
{
return m_data->textColors;
}

void QskScaleRenderer::setColorFilter( const QskColorFilter& colorFilter )
void QskGraduationRenderer::setColorFilter( const QskColorFilter& colorFilter )
{
m_data->colorFilter = colorFilter;
}

const QskColorFilter& QskScaleRenderer::colorFilter() const
const QskColorFilter& QskGraduationRenderer::colorFilter() const
{
return m_data->colorFilter;
}

QSGNode* QskScaleRenderer::updateNode(
QSGNode* QskGraduationRenderer::updateNode(
const QskSkinnable* skinnable, QSGNode* node )
{
enum Role : quint8 { Ticks = 1, Labels = 2 };
Expand All @@ -303,7 +303,7 @@ QSGNode* QskScaleRenderer::updateNode(
return node;
}

QSGNode* QskScaleRenderer::updateTicksNode(
QSGNode* QskGraduationRenderer::updateTicksNode(
const QTransform& transform, QSGNode* node ) const
{
QskIntervalF backbone;
Expand Down Expand Up @@ -342,7 +342,7 @@ QSGNode* QskScaleRenderer::updateTicksNode(
return axisNode;
}

QSGNode* QskScaleRenderer::updateLabelsNode( const QskSkinnable* skinnable,
QSGNode* QskGraduationRenderer::updateLabelsNode( const QskSkinnable* skinnable,
const QTransform& transform, QSGNode* node ) const
{
const auto ticks = m_data->tickmarks.majorTicks();
Expand Down Expand Up @@ -428,13 +428,13 @@ QSGNode* QskScaleRenderer::updateLabelsNode( const QskSkinnable* skinnable,
return node;
}

QVariant QskScaleRenderer::labelAt( qreal pos ) const
QVariant QskGraduationRenderer::labelAt( qreal pos ) const
{
return QString::number( pos, 'g' );
}

// should be cached
QSizeF QskScaleRenderer::boundingLabelSize() const
QSizeF QskGraduationRenderer::boundingLabelSize() const
{
QSizeF boundingSize( 0.0, 0.0 );

Expand Down Expand Up @@ -471,7 +471,7 @@ QSizeF QskScaleRenderer::boundingLabelSize() const
return boundingSize;
}

QRectF QskScaleRenderer::labelRect(
QRectF QskGraduationRenderer::labelRect(
const QTransform& transform, qreal tick, const QSizeF& labelSize ) const
{
const auto isHorizontal = qskIsHorizontal( m_data->edge );
Expand Down Expand Up @@ -521,7 +521,7 @@ QRectF QskScaleRenderer::labelRect(
return QRectF( x, y, w, h );
}

QSGNode* QskScaleRenderer::updateTickLabelNode( const QskSkinnable* skinnable,
QSGNode* QskGraduationRenderer::updateTickLabelNode( const QskSkinnable* skinnable,
QSGNode* node, const QVariant& label, const QRectF& rect ) const
{
if ( label.canConvert< QString >() )
Expand All @@ -545,4 +545,4 @@ QSGNode* QskScaleRenderer::updateTickLabelNode( const QskSkinnable* skinnable,
return nullptr;
}

#include "moc_QskScaleRenderer.cpp"
#include "moc_QskGraduationRenderer.cpp"
Loading

0 comments on commit d0472bc

Please sign in to comment.