diff --git a/playground/levelingsensor/main.cpp b/playground/levelingsensor/main.cpp index ab93ceb3..587365f5 100644 --- a/playground/levelingsensor/main.cpp +++ b/playground/levelingsensor/main.cpp @@ -72,41 +72,44 @@ namespace sensor->setTickmarksLabels( axis, labels ); } - Q_REQUIRED_RESULT QskSlider* makeTickmarksSlider( const Qt::Axis axis, QskLevelingSensor* const sensor, int min, int max, std::function intervalA, std::function intervalB, QQuickItem* const parent = nullptr ) + Q_REQUIRED_RESULT QskSlider* makeTickmarksSlider( const Qt::Axis axis, + QskLevelingSensor* const sensor, int min, int max, + std::function< QskIntervalF( qreal ) > intervalA, + std::function< QskIntervalF( qreal ) > intervalB, QQuickItem* const parent = nullptr ) { auto* const slider = new QskSlider( Qt::Horizontal, parent ); slider->setMinimum( min ); slider->setMaximum( max ); - QObject::connect(slider, &QskSlider::valueChanged, sensor, [ = ]( const qreal degree ) { - updateTickmarks( axis, intervalA(degree), intervalB(degree), sensor ); + QObject::connect( slider, &QskSlider::valueChanged, sensor, [ = ]( const qreal degree ) { + updateTickmarks( axis, intervalA( degree ), intervalB( degree ), sensor ); updateTickmarksLabels( axis, intervalA( degree ), intervalB( degree ), 10, sensor ); } ); return slider; } - Q_REQUIRED_RESULT QskSlider* makeRotationSlider( - const Qt::Axis axis, QskLevelingSensor* const sensor, const QskAspect::Subcontrol subControl, QQuickItem* const parent = nullptr ) + Q_REQUIRED_RESULT QskSlider* makeRotationSlider( const Qt::Axis axis, + QskLevelingSensor* const sensor, const QskAspect::Subcontrol subControl, + QQuickItem* const parent = nullptr ) { auto* const slider = new QskSlider( Qt::Horizontal, parent ); slider->setMinimum( -360 ); slider->setMaximum( +360 ); QObject::connect( sensor, &QskLevelingSensor::subControlRotationChanged, slider, - [ = ]( const QskAspect::Subcontrol control, const QVector3D& degree ) { - if(control == subControl) + [ = ]( const QskAspect::Subcontrol control, const QVector3D& degree ) { + if ( control == subControl ) { slider->setValue( degree[ axis ] ); } } ); - QObject::connect( slider, &QskSlider::valueChanged, sensor, - [ = ]( const qreal degree ) { - auto d = sensor->subControlRotation( subControl ); - d[ axis ] = degree; - sensor->setSubControlRotation( subControl, d ); - } ); + QObject::connect( slider, &QskSlider::valueChanged, sensor, [ = ]( const qreal degree ) { + auto d = sensor->subControlRotation( subControl ); + d[ axis ] = degree; + sensor->setSubControlRotation( subControl, d ); + } ); return slider; } @@ -117,24 +120,33 @@ namespace Window() { auto* const root = new QskLinearBox( Qt::Horizontal, contentItem() ); - root->setSpacing(8); - root->setMargins(8); + root->setSpacing( 8 ); + root->setMargins( 8 ); auto* const left = new QskLinearBox( Qt::Vertical, root ); auto* const right = new QskLinearBox( Qt::Vertical, root ); auto* const sensor = new QskLevelingSensor( left ); - auto linearIntervalA = [](const qreal degree)->QskIntervalF{ return {-degree, +degree};}; - auto linearIntervalB = [](const qreal degree)->QskIntervalF{ return {}; }; - - auto radialIntervalA = [](const qreal degree)->QskIntervalF{ return {-degree, +degree};}; - auto radialIntervalB = [](const qreal degree)->QskIntervalF{ return {180-degree, 180+degree};}; + auto linearIntervalA = []( const qreal degree ) -> QskIntervalF { + return { -degree, +degree }; + }; + auto linearIntervalB = []( const qreal degree ) -> QskIntervalF { return {}; }; + + auto radialIntervalA = []( const qreal degree ) -> QskIntervalF { + return { -degree, +degree }; + }; + auto radialIntervalB = []( const qreal degree ) -> QskIntervalF { + return { 180 - degree, 180 + degree }; + }; ( void ) new QskTextLabel( "Tickmarks X", right ); - auto* const sliderTickmarksX = makeTickmarksSlider( Qt::XAxis, sensor, 0, 90, linearIntervalA, linearIntervalB, right ); + auto* const sliderTickmarksX = makeTickmarksSlider( + Qt::XAxis, sensor, 0, 90, linearIntervalA, linearIntervalB, right ); ( void ) new QskTextLabel( "Tickmarks Y", right ); - auto* const sliderTickmarksY = makeTickmarksSlider( Qt::YAxis, sensor, 0, 90, linearIntervalA, linearIntervalB, right ); + auto* const sliderTickmarksY = makeTickmarksSlider( + Qt::YAxis, sensor, 0, 90, linearIntervalA, linearIntervalB, right ); ( void ) new QskTextLabel( "Tickmarks Z", right ); - auto* const sliderTickmarksZ = makeTickmarksSlider( Qt::ZAxis, sensor, 0, 90, radialIntervalA, radialIntervalB, right ); + auto* const sliderTickmarksZ = makeTickmarksSlider( + Qt::ZAxis, sensor, 0, 90, radialIntervalA, radialIntervalB, right ); ( void ) new QskTextLabel( "Rotation X Plane", right ); ( void ) makeRotationSlider( Qt::XAxis, sensor, QskLevelingSensor::TickmarksX, right ); @@ -149,9 +161,9 @@ namespace ( void ) makeRotationSlider( Qt::YAxis, sensor, QskLevelingSensor::TickmarksZ, right ); ( void ) makeRotationSlider( Qt::ZAxis, sensor, QskLevelingSensor::TickmarksZ, right ); - sliderTickmarksX->setValue(15); - sliderTickmarksY->setValue(15); - sliderTickmarksZ->setValue(30); + sliderTickmarksX->setValue( 15 ); + sliderTickmarksY->setValue( 15 ); + sliderTickmarksZ->setValue( 30 ); } }; } diff --git a/src/controls/LevelingSensor/QskLevelingSensorNodes.cpp b/src/controls/LevelingSensor/QskLevelingSensorNodes.cpp deleted file mode 100644 index e69de29b..00000000 diff --git a/src/controls/LevelingSensor/QskLevelingSensorNodes.h b/src/controls/LevelingSensor/QskLevelingSensorNodes.h index 82b5ad77..6bf2a8c4 100644 --- a/src/controls/LevelingSensor/QskLevelingSensorNodes.h +++ b/src/controls/LevelingSensor/QskLevelingSensorNodes.h @@ -175,10 +175,10 @@ private: QVector3D m_tickmarkSize = { 1.0, 2.0, 4.0 }; }; -class PolygonClipNode final : public QSGClipNode +class RadialClipNode final : public QSGClipNode { public: - PolygonClipNode() : m_geometry(QSGGeometry::defaultAttributes_Point2D(), 0) + RadialClipNode() : m_geometry(QSGGeometry::defaultAttributes_Point2D(), 0) { m_geometry.setVertexDataPattern(QSGGeometry::DynamicPattern); m_geometry.setDrawingMode(QSGGeometry::DrawTriangleFan); diff --git a/src/controls/LevelingSensor/QskLevelingSensorSkinlet.cpp b/src/controls/LevelingSensor/QskLevelingSensorSkinlet.cpp index b26a1e1d..0ecd312e 100644 --- a/src/controls/LevelingSensor/QskLevelingSensorSkinlet.cpp +++ b/src/controls/LevelingSensor/QskLevelingSensorSkinlet.cpp @@ -252,7 +252,7 @@ QSGNode* QskLevelingSensorSkinlet::updateSubNode< R::TickmarksX >( const auto r3 = state.r1 * scale.height(); auto* const clipping = - ensureNode< PolygonClipNode, QSGTransformNode, LinearTickmarksNode >( + ensureNode< RadialClipNode, QSGTransformNode, LinearTickmarksNode >( node ); auto* const transform = static_cast< QSGTransformNode* >( clipping->firstChild() ); auto* const tickmarks = static_cast< LinearTickmarksNode* >( transform->firstChild() ); @@ -285,7 +285,7 @@ QSGNode* QskLevelingSensorSkinlet::updateSubNode< R::TickmarksY >( const auto rotation = sensor->subControlRotation( subControl ); auto* const cNode = - ensureNode< PolygonClipNode,QSGTransformNode, LinearTickmarksNode>( + ensureNode< RadialClipNode,QSGTransformNode, LinearTickmarksNode>( node ); auto* const tNode = static_cast< QSGTransformNode* >( cNode->firstChild() ); auto* const lNode = static_cast< LinearTickmarksNode* >( tNode->firstChild() ); @@ -336,7 +336,7 @@ QSGNode* QskLevelingSensorSkinlet::updateSubNode< R::TickmarksXLabels >( const auto translation = state.translation().toVector2D() + QVector2D{0, r3}; auto* const cNode = - ensureNode< PolygonClipNode, QSGTransformNode, LinearTickmarksLabelsNode >( node ); + ensureNode< 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 ); @@ -359,7 +359,7 @@ QSGNode* QskLevelingSensorSkinlet::updateSubNode< R::TickmarksYLabels >( const auto rotation = sensor->subControlRotation( subControl ); const auto translation = state.translation().toVector2D() + QVector2D( r3, 0 ); - auto* const cNode = ensureNode< PolygonClipNode, QSGTransformNode, LinearTickmarksLabelsNode >( node ); + auto* const cNode = ensureNode< 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 ); @@ -391,7 +391,7 @@ QSGNode* QskLevelingSensorSkinlet::updateSubNode< R::HorizonClip >( const auto cY = center( sensor ).y(); const auto r1 = innerRadius( sensor ); - auto* const clipNode = ensureNode< PolygonClipNode >( node ); + auto* const clipNode = ensureNode< RadialClipNode >( node ); clipNode->setGeometryProperties( r1, cX, cY ); return clipNode; } diff --git a/src/controls/LevelingSensor/QskLevelingSensorUtility.cpp b/src/controls/LevelingSensor/QskLevelingSensorUtility.cpp deleted file mode 100644 index e28b1e35..00000000 --- a/src/controls/LevelingSensor/QskLevelingSensorUtility.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "QskLevelingSensorUtility.h" \ No newline at end of file