2020-11-13 15:34:02 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
|
|
|
* This file may be used under the terms of the QSkinny License, Version 1.0
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#include "QskScaleTickmarks.h"
|
|
|
|
#include <algorithm>
|
|
|
|
|
2021-02-14 12:36:15 +01:00
|
|
|
static void qskRegisterTickmarks()
|
2020-11-13 15:34:02 +01:00
|
|
|
{
|
2021-02-14 12:36:15 +01:00
|
|
|
qRegisterMetaType< QskScaleTickmarks >();
|
2022-03-31 18:29:39 +02:00
|
|
|
|
|
|
|
#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
|
|
|
|
QMetaType::registerEqualsComparator< QskScaleTickmarks >();
|
|
|
|
#endif
|
2020-11-13 15:34:02 +01:00
|
|
|
}
|
|
|
|
|
2021-02-14 12:36:15 +01:00
|
|
|
Q_CONSTRUCTOR_FUNCTION( qskRegisterTickmarks )
|
|
|
|
|
2020-11-13 15:34:02 +01:00
|
|
|
QskScaleTickmarks::QskScaleTickmarks()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
QskScaleTickmarks::~QskScaleTickmarks()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-02-14 12:36:15 +01:00
|
|
|
int QskScaleTickmarks::tickCount() const noexcept
|
|
|
|
{
|
|
|
|
return m_ticks[ MajorTick ].count()
|
|
|
|
+ m_ticks[ MediumTick ].count()
|
|
|
|
+ m_ticks[ MinorTick ].count();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-13 15:34:02 +01:00
|
|
|
int QskScaleTickmarks::tickCount( TickType type ) const noexcept
|
|
|
|
{
|
|
|
|
return m_ticks[ type ].count();
|
|
|
|
}
|
|
|
|
|
2020-12-05 15:09:31 +01:00
|
|
|
QVector< qreal > QskScaleTickmarks::ticks( TickType type ) const noexcept
|
2020-11-13 15:34:02 +01:00
|
|
|
{
|
|
|
|
return m_ticks[ type ];
|
|
|
|
}
|
|
|
|
|
2020-12-05 15:09:31 +01:00
|
|
|
void QskScaleTickmarks::setTicks(TickType type, const QVector< qreal >& ticks )
|
2020-11-13 15:34:02 +01:00
|
|
|
{
|
|
|
|
m_ticks[ type ] = ticks;
|
|
|
|
}
|
|
|
|
|
2021-02-19 12:43:11 +01:00
|
|
|
qreal QskScaleTickmarks::tickAt( TickType type, int index ) const
|
|
|
|
{
|
|
|
|
return m_ticks[ type ].at( index );
|
|
|
|
}
|
|
|
|
|
2020-11-13 15:34:02 +01:00
|
|
|
void QskScaleTickmarks::reset()
|
|
|
|
{
|
|
|
|
m_ticks[ 0 ].clear();
|
|
|
|
m_ticks[ 1 ].clear();
|
|
|
|
m_ticks[ 2 ].clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void QskScaleTickmarks::invert()
|
2020-12-05 15:09:31 +01:00
|
|
|
{
|
2020-11-13 15:34:02 +01:00
|
|
|
std::reverse( m_ticks[ 0 ].begin(), m_ticks[ 0 ].end() );
|
|
|
|
std::reverse( m_ticks[ 1 ].begin(), m_ticks[ 1 ].end() );
|
|
|
|
std::reverse( m_ticks[ 2 ].begin(), m_ticks[ 2 ].end() );
|
|
|
|
}
|
|
|
|
|
2022-03-25 11:21:32 +01:00
|
|
|
QskHashValue QskScaleTickmarks::hash( QskHashValue seed ) const noexcept
|
2020-11-13 15:34:02 +01:00
|
|
|
{
|
|
|
|
seed = qHash( m_ticks[0], seed );
|
|
|
|
seed = qHash( m_ticks[1], seed );
|
|
|
|
seed = qHash( m_ticks[2], seed );
|
|
|
|
|
|
|
|
return seed;
|
|
|
|
}
|
|
|
|
|
2020-12-05 15:09:31 +01:00
|
|
|
bool QskScaleTickmarks::operator==( const QskScaleTickmarks& other ) const noexcept
|
2020-11-13 15:34:02 +01:00
|
|
|
{
|
|
|
|
return ( m_ticks[ 0 ] == other.m_ticks[ 0 ] )
|
|
|
|
&& ( m_ticks[ 1 ] == other.m_ticks[ 1 ] )
|
|
|
|
&& ( m_ticks[ 2 ] == other.m_ticks[ 2 ] );
|
|
|
|
}
|
|
|
|
|
2021-02-14 12:36:15 +01:00
|
|
|
#ifndef QT_NO_DEBUG_STREAM
|
|
|
|
|
|
|
|
#include <qdebug.h>
|
|
|
|
|
|
|
|
QDebug operator<<( QDebug debug, const QskScaleTickmarks& tickmarks )
|
|
|
|
{
|
|
|
|
debug << tickmarks.majorTicks()
|
|
|
|
<< tickmarks.mediumTicks() << tickmarks.minorTicks();
|
|
|
|
|
|
|
|
return debug;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2020-11-13 15:34:02 +01:00
|
|
|
#include "moc_QskScaleTickmarks.cpp"
|