clang-format
This commit is contained in:
parent
f3727a79e1
commit
7a74014257
|
|
@ -11,12 +11,12 @@
|
|||
#include <QskSkinManager.h>
|
||||
#include <QskWindow.h>
|
||||
|
||||
#include <QskLevelingSensor.h>
|
||||
#include <QskIntervalF.h>
|
||||
#include <QskLevelingSensor.h>
|
||||
#include <QskLinearBox.h>
|
||||
#include <QskScaleTickmarks.h>
|
||||
#include <QskSlider.h>
|
||||
#include <QskTextLabel.h>
|
||||
#include <QskScaleTickmarks.h>
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include <QQuickWindow>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <QskSkinlet.h>
|
||||
#include <QSGNode>
|
||||
#include <QskSkinlet.h>
|
||||
|
||||
class QskLevelingSensor;
|
||||
|
||||
|
|
@ -36,18 +36,17 @@ public:
|
|||
static Q_REQUIRED_RESULT QPointF center( const QskSkinnable* const skinnable );
|
||||
|
||||
protected:
|
||||
|
||||
Q_REQUIRED_RESULT QRectF subControlRect( const QskSkinnable* skinnable,
|
||||
const QRectF& contentsRect, QskAspect::Subcontrol subControl ) const override;
|
||||
|
||||
Q_REQUIRED_RESULT QSGNode* updateSubNode(const QskSkinnable* skinnable,
|
||||
quint8 nodeRole, QSGNode* node) const override;
|
||||
Q_REQUIRED_RESULT QSGNode* updateSubNode(
|
||||
const QskSkinnable* skinnable, quint8 nodeRole, QSGNode* node ) const override;
|
||||
|
||||
template< NodeRole >
|
||||
Q_REQUIRED_RESULT QRectF subControlRect(const QskLevelingSensor* sensor,
|
||||
const QRectF& contentsRect) const;
|
||||
Q_REQUIRED_RESULT QRectF subControlRect(
|
||||
const QskLevelingSensor* sensor, const QRectF& contentsRect ) const;
|
||||
|
||||
template< NodeRole >
|
||||
Q_REQUIRED_RESULT QSGNode* updateSubNode(const QskLevelingSensor* sensor,
|
||||
quint8 nodeRole, QSGNode* node) const;
|
||||
Q_REQUIRED_RESULT QSGNode* updateSubNode(
|
||||
const QskLevelingSensor* sensor, quint8 nodeRole, QSGNode* node ) const;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
#include "QskLevelingSensorUtility.h"
|
||||
|
||||
#include <QSGFlatColorMaterial>
|
||||
#include <QSGGeometry>
|
||||
#include <QSGGeometryNode>
|
||||
#include <QSGFlatColorMaterial>
|
||||
|
||||
#include <QFontMetricsF>
|
||||
#include <qmath.h>
|
||||
|
|
@ -12,7 +12,8 @@
|
|||
class RadialTickmarksNode final : public QSGGeometryNode
|
||||
{
|
||||
public:
|
||||
RadialTickmarksNode() : m_geometry(QSGGeometry::defaultAttributes_Point2D(), 0)
|
||||
RadialTickmarksNode()
|
||||
: m_geometry( QSGGeometry::defaultAttributes_Point2D(), 0 )
|
||||
{
|
||||
m_geometry.setDrawingMode( QSGGeometry::DrawLines );
|
||||
m_geometry.setVertexDataPattern( QSGGeometry::StaticPattern );
|
||||
|
|
@ -30,7 +31,8 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
void setGeometryProperties(const QskScaleTickmarks& tickmarks, const qreal r1 = 0.0, const QVector3D& r2 = { 0.5, 0.75, 1.0 }, float lineWidth = 1.0)
|
||||
void setGeometryProperties( const QskScaleTickmarks& tickmarks, const qreal r1 = 0.0,
|
||||
const QVector3D& r2 = { 0.5, 0.75, 1.0 }, float lineWidth = 1.0 )
|
||||
{
|
||||
auto dirty = false;
|
||||
|
||||
|
|
@ -91,7 +93,8 @@ private:
|
|||
class LinearTickmarksNode final : public QSGGeometryNode
|
||||
{
|
||||
public:
|
||||
LinearTickmarksNode() : m_geometry(QSGGeometry::defaultAttributes_Point2D(), 0)
|
||||
LinearTickmarksNode()
|
||||
: m_geometry( QSGGeometry::defaultAttributes_Point2D(), 0 )
|
||||
{
|
||||
m_geometry.setDrawingMode( QSGGeometry::DrawLines );
|
||||
m_geometry.setVertexDataPattern( QSGGeometry::StaticPattern );
|
||||
|
|
@ -115,7 +118,9 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
void setGeometryProperties(const QskScaleTickmarks& tickmarks, const QVector3D& tickmarkSize, const QVector2D& scale = { 1.0,0.0f }, const QVector2D& offset = {}, const float lineWidth = 1.0f, const bool forceDirty = false)
|
||||
void setGeometryProperties( const QskScaleTickmarks& tickmarks, const QVector3D& tickmarkSize,
|
||||
const QVector2D& scale = { 1.0, 0.0f }, const QVector2D& offset = {},
|
||||
const float lineWidth = 1.0f, const bool forceDirty = false )
|
||||
{
|
||||
auto dirty = forceDirty;
|
||||
|
||||
|
|
@ -178,7 +183,8 @@ private:
|
|||
class RadialClipNode final : public QSGClipNode
|
||||
{
|
||||
public:
|
||||
RadialClipNode() : m_geometry(QSGGeometry::defaultAttributes_Point2D(), 0)
|
||||
RadialClipNode()
|
||||
: m_geometry( QSGGeometry::defaultAttributes_Point2D(), 0 )
|
||||
{
|
||||
m_geometry.setVertexDataPattern( QSGGeometry::DynamicPattern );
|
||||
m_geometry.setDrawingMode( QSGGeometry::DrawTriangleFan );
|
||||
|
|
@ -186,7 +192,8 @@ public:
|
|||
setIsRectangular( false );
|
||||
}
|
||||
|
||||
void setGeometryProperties(const qreal radius = 1.0, const qreal cx = 0.0, const qreal cy = 0.0, const int count = 360)
|
||||
void setGeometryProperties( const qreal radius = 1.0, const qreal cx = 0.0,
|
||||
const qreal cy = 0.0, const int count = 360 )
|
||||
{
|
||||
auto dirty = false;
|
||||
dirty |= compareExchange( m_radius, radius );
|
||||
|
|
@ -222,8 +229,8 @@ private:
|
|||
markDirty( QSGNode::DirtyGeometry );
|
||||
}
|
||||
|
||||
using QSGClipNode::setIsRectangular;
|
||||
using QSGClipNode::setClipRect;
|
||||
using QSGClipNode::setIsRectangular;
|
||||
|
||||
QSGGeometry m_geometry;
|
||||
qreal m_radius = 1.0;
|
||||
|
|
@ -241,7 +248,9 @@ public:
|
|||
return static_cast< const CRTP* >( this )->value( v, s, o );
|
||||
}
|
||||
|
||||
void update(const QskSkinnable* const skinnable, const QskAspect::Subcontrol subControl, const QVector<QPair<double, QString>>& labels, const QVector2D& scale = { 1.0, 0.0 }, const QVector2D& offset = {})
|
||||
void update( const QskSkinnable* const skinnable, const QskAspect::Subcontrol subControl,
|
||||
const QVector< QPair< double, QString > >& labels, const QVector2D& scale = { 1.0, 0.0 },
|
||||
const QVector2D& offset = {} )
|
||||
{
|
||||
const auto count = labels.count();
|
||||
|
||||
|
|
@ -274,7 +283,8 @@ public:
|
|||
y -= a.testFlag( Qt::AlignBottom ) ? h : 0;
|
||||
y -= a.testFlag( Qt::AlignVCenter ) ? h / 2 : 0;
|
||||
|
||||
QskSkinlet::updateTextNode(skinnable, textNode, { x,y,w,h }, a, label.second, subControl);
|
||||
QskSkinlet::updateTextNode(
|
||||
skinnable, textNode, { x, y, w, h }, a, label.second, subControl );
|
||||
|
||||
textNode = static_cast< QskTextNode* >( textNode->nextSibling() );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
#include <QskLevelingSensorSkinlet.h>
|
||||
#include <QskLevelingSensor.h>
|
||||
#include "QskLevelingSensorUtility.h"
|
||||
#include "QskLevelingSensorNodes.h"
|
||||
#include "QskLevelingSensorUtility.h"
|
||||
#include "QskSGNodeUtility.h"
|
||||
#include <QskLevelingSensor.h>
|
||||
#include <QskLevelingSensorSkinlet.h>
|
||||
|
||||
#include <QskArcMetrics.h>
|
||||
#include <QskBoxBorderColors.h>
|
||||
|
|
@ -238,7 +238,8 @@ QSGNode* QskLevelingSensorSkinlet::updateSubNode< R::Horizon >(
|
|||
|
||||
auto* const tNode = ensureNodes< QSGTransformNode, QskBoxNode >( node );
|
||||
auto* const boxNode = static_cast< QskBoxNode* >( tNode->firstChild() );
|
||||
updateBoxNode( sensor, boxNode, { 0, 0, 2 * state.r1, 2 * state.r1 }, shape, metrics, colors, gradient );
|
||||
updateBoxNode(
|
||||
sensor, boxNode, { 0, 0, 2 * state.r1, 2 * state.r1 }, shape, metrics, colors, gradient );
|
||||
|
||||
const auto matrix = matrix_deg( 0, 0, 0, state.cX, state.cY, 0 ) *
|
||||
matrix_deg( 0, 0, 0, -state.r1, -state.r1, 0 );
|
||||
|
|
@ -258,8 +259,7 @@ QSGNode* QskLevelingSensorSkinlet::updateSubNode< R::TickmarksX >(
|
|||
const auto r3 = state.r1 * scale.height();
|
||||
|
||||
auto* const clipping =
|
||||
ensureNodes< RadialClipNode, QSGTransformNode, LinearTickmarksNode >(
|
||||
node );
|
||||
ensureNodes< RadialClipNode, QSGTransformNode, LinearTickmarksNode >( node );
|
||||
auto* const transform = static_cast< QSGTransformNode* >( clipping->firstChild() );
|
||||
auto* const tickmarks = static_cast< LinearTickmarksNode* >( transform->firstChild() );
|
||||
|
||||
|
|
@ -291,8 +291,7 @@ QSGNode* QskLevelingSensorSkinlet::updateSubNode< R::TickmarksY >(
|
|||
const auto rotation = sensor->subControlRotation( subControl );
|
||||
|
||||
auto* const cNode =
|
||||
ensureNodes< RadialClipNode,QSGTransformNode, LinearTickmarksNode>(
|
||||
node );
|
||||
ensureNodes< RadialClipNode, QSGTransformNode, LinearTickmarksNode >( node );
|
||||
auto* const tNode = static_cast< QSGTransformNode* >( cNode->firstChild() );
|
||||
auto* const lNode = static_cast< LinearTickmarksNode* >( tNode->firstChild() );
|
||||
|
||||
|
|
@ -318,8 +317,8 @@ QSGNode* QskLevelingSensorSkinlet::updateSubNode< R::TickmarksZ >(
|
|||
const auto color = sensor->color( subControl );
|
||||
const auto scale = sensor->strutSizeHint( subControl );
|
||||
|
||||
const auto r3 =
|
||||
qvariant_cast< QVector3D >( sensor->effectiveSkinHint( subControl ) ) * ( state.r2 - state.r1 ) +
|
||||
const auto r3 = qvariant_cast< QVector3D >( sensor->effectiveSkinHint( subControl ) ) *
|
||||
( state.r2 - state.r1 ) +
|
||||
QVector3D{ ( float ) state.r1, ( float ) state.r1, ( float ) state.r1 };
|
||||
|
||||
auto* const transform = ensureNodes< QSGTransformNode, RadialTickmarksNode >( node );
|
||||
|
|
@ -338,7 +337,8 @@ QSGNode* QskLevelingSensorSkinlet::updateSubNode< R::TickmarksXLabels >(
|
|||
{
|
||||
const auto subControl = Q::TickmarksXLabels;
|
||||
const State< QskAspect::Subcontrol > state( sensor, subControl );
|
||||
const auto r3 = static_cast< float >( state.r1 * sensor->strutSizeHint( Q::TickmarksX ).height() );
|
||||
const auto r3 =
|
||||
static_cast< float >( state.r1 * sensor->strutSizeHint( Q::TickmarksX ).height() );
|
||||
const auto translation = state.translation().toVector2D() + QVector2D{ 0, r3 };
|
||||
|
||||
auto* const cNode =
|
||||
|
|
@ -347,8 +347,8 @@ QSGNode* QskLevelingSensorSkinlet::updateSubNode< R::TickmarksXLabels >(
|
|||
auto* const lNode = static_cast< LinearTickmarksLabelsNode* >( tNode->firstChild() );
|
||||
cNode->setGeometryProperties( state.r1, state.cX, state.cY );
|
||||
tNode->setMatrix( state.matrix() );
|
||||
lNode->update(
|
||||
sensor, subControl, sensor->tickmarkLabels( Qt::XAxis ), { state.scale().x(), 0.0 }, translation );
|
||||
lNode->update( sensor, subControl, sensor->tickmarkLabels( Qt::XAxis ),
|
||||
{ state.scale().x(), 0.0 }, translation );
|
||||
return cNode;
|
||||
}
|
||||
|
||||
|
|
@ -358,14 +358,16 @@ QSGNode* QskLevelingSensorSkinlet::updateSubNode< R::TickmarksYLabels >(
|
|||
{
|
||||
const auto subControl = Q::TickmarksYLabels;
|
||||
const State< QskAspect::Subcontrol > state( sensor, subControl );
|
||||
const auto r3 = static_cast< float >( state.r1 * sensor->strutSizeHint( Q::TickmarksY ).width() );
|
||||
const auto r3 =
|
||||
static_cast< float >( state.r1 * sensor->strutSizeHint( Q::TickmarksY ).width() );
|
||||
|
||||
const auto scale = sensor->strutSizeHint( subControl );
|
||||
const auto angles = sensor->angle();
|
||||
const auto rotation = sensor->subControlRotation( subControl );
|
||||
const auto translation = state.translation().toVector2D() + QVector2D( r3, 0 );
|
||||
|
||||
auto* const cNode = ensureNodes< RadialClipNode, QSGTransformNode, LinearTickmarksLabelsNode >( node );
|
||||
auto* const cNode =
|
||||
ensureNodes< RadialClipNode, QSGTransformNode, LinearTickmarksLabelsNode >( node );
|
||||
auto* const tNode = static_cast< QSGTransformNode* >( cNode->firstChild() );
|
||||
auto* const lNode = static_cast< LinearTickmarksLabelsNode* >( tNode->firstChild() );
|
||||
cNode->setGeometryProperties( state.r1, state.cX, state.cY );
|
||||
|
|
|
|||
|
|
@ -3,18 +3,12 @@
|
|||
#include <qmath.h>
|
||||
#include <qmatrix4x4.h>
|
||||
|
||||
#include <QskScaleTickmarks.h>
|
||||
#include <QskFunctions.h>
|
||||
#include <QskScaleTickmarks.h>
|
||||
|
||||
// create a homogenous transformation matrix
|
||||
inline Q_REQUIRED_RESULT QMatrix4x4 matrix_deg(
|
||||
float rX = 0.0f,
|
||||
float rY = 0.0f,
|
||||
float rZ = 0.0f,
|
||||
float tX = 0.0f,
|
||||
float tY = 0.0f,
|
||||
float tZ = 0.0f
|
||||
)
|
||||
inline Q_REQUIRED_RESULT QMatrix4x4 matrix_deg( float rX = 0.0f, float rY = 0.0f, float rZ = 0.0f,
|
||||
float tX = 0.0f, float tY = 0.0f, float tZ = 0.0f )
|
||||
{
|
||||
// Convert rotation angles to radians
|
||||
float rotationX = qDegreesToRadians( rX );
|
||||
|
|
@ -30,12 +24,9 @@ inline Q_REQUIRED_RESULT QMatrix4x4 matrix_deg(
|
|||
float sinZ = qSin( rotationZ );
|
||||
|
||||
// Create the transform matrix
|
||||
return QMatrix4x4(
|
||||
cosY * cosZ, sinX * sinY * cosZ - cosX * sinZ, cosX * sinY * cosZ + sinX * sinZ, tX,
|
||||
cosY * sinZ, sinX * sinY * sinZ + cosX * cosZ, cosX * sinY * sinZ - sinX * cosZ, tY,
|
||||
-sinY, sinX * cosY, cosX * cosY, tZ,
|
||||
0, 0, 0, 1
|
||||
);
|
||||
return QMatrix4x4( cosY * cosZ, sinX * sinY * cosZ - cosX * sinZ,
|
||||
cosX * sinY * cosZ + sinX * sinZ, tX, cosY * sinZ, sinX * sinY * sinZ + cosX * cosZ,
|
||||
cosX * sinY * sinZ - sinX * cosZ, tY, -sinY, sinX * cosY, cosX * cosY, tZ, 0, 0, 0, 1 );
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
|
|
@ -71,7 +62,8 @@ inline Q_REQUIRED_RESULT bool compareExchange<qreal>(qreal& dst, const qreal& sr
|
|||
return false;
|
||||
}
|
||||
|
||||
inline QskScaleTickmarks filtered(const QskScaleTickmarks& tickmarks, const std::function<bool(QskScaleTickmarks::TickType, qreal)>& predicate)
|
||||
inline QskScaleTickmarks filtered( const QskScaleTickmarks& tickmarks,
|
||||
const std::function< bool( QskScaleTickmarks::TickType, qreal ) >& predicate )
|
||||
{
|
||||
QskScaleTickmarks result;
|
||||
QVector< qreal > ticks[ 3 ];
|
||||
|
|
|
|||
Loading…
Reference in New Issue