25 : mTickPosition( position )
32 switch ( mTickPosition )
35 return QStringLiteral(
"Line Ticks Up" );
37 return QStringLiteral(
"Line Ticks Down" );
39 return QStringLiteral(
"Line Ticks Middle" );
46 switch ( mTickPosition )
49 return QObject::tr(
"Line Ticks Up" );
51 return QObject::tr(
"Line Ticks Down" );
53 return QObject::tr(
"Line Ticks Middle" );
61 switch ( mTickPosition )
99 QPainter *painter = context.
painter();
107 const double scaledMaxHeight = ( ( settings.
numberOfSubdivisions() > 1 ) && ( scaledSubdivisionsHeight > scaledHeight ) ) ? scaledSubdivisionsHeight : scaledHeight;
108 const double middlePosition = barTopPosition + scaledMaxHeight / 2.0;
109 const double bottomPosition = barTopPosition + scaledMaxHeight;
115 painter->setRenderHint( QPainter::Antialiasing,
true );
117 std::unique_ptr< QgsLineSymbol > symbol( settings.
lineSymbol()->
clone() );
118 symbol->startRender( context );
121 divisionSymbol->startRender( context );
124 subdivisionSymbol->startRender( context );
126 const QList<double> positions =
segmentPositions( context, scaleContext, settings );
129 double verticalPos = 0.0;
130 QList<double> subTickPositionsY;
131 QList<double> tickPositionsY;
132 switch ( mTickPosition )
135 verticalPos = barTopPosition;
136 subTickPositionsY << verticalPos;
137 subTickPositionsY << verticalPos + scaledSubdivisionsHeight;
138 tickPositionsY << verticalPos;
139 tickPositionsY << verticalPos + scaledHeight;
142 verticalPos = middlePosition;
143 subTickPositionsY << verticalPos + scaledSubdivisionsHeight / 2.0;
144 subTickPositionsY << verticalPos - scaledSubdivisionsHeight / 2.0;
145 tickPositionsY << verticalPos + scaledHeight / 2.0;
146 tickPositionsY << verticalPos - scaledHeight / 2.0;
149 verticalPos = bottomPosition;
150 subTickPositionsY << verticalPos;
151 subTickPositionsY << verticalPos - scaledSubdivisionsHeight;
152 tickPositionsY << verticalPos;
153 tickPositionsY << verticalPos - scaledHeight;
157 int symbolLayerCount = symbol->symbolLayerCount();
158 symbolLayerCount = std::max( symbolLayerCount, divisionSymbol->symbolLayerCount() );
159 symbolLayerCount = std::max( symbolLayerCount, subdivisionSymbol->symbolLayerCount() );
162 for (
int layer = 0; layer < symbolLayerCount; ++ layer )
164 const bool drawDivisionsForThisSymbolLayer = layer < divisionSymbol->symbolLayerCount();
165 const bool drawSubdivisionsForThisSymbolLayer = layer < subdivisionSymbol->symbolLayerCount();
166 const bool drawLineForThisSymbolLayer = layer < symbol->symbolLayerCount();
168 if ( drawDivisionsForThisSymbolLayer )
171 for (
int i = 0; i < positions.size(); ++i )
174 divisionSymbol->renderPolyline( QPolygonF() << QPointF( thisX, tickPositionsY.at( 0 ) )
175 << QPointF( thisX, tickPositionsY.at( 1 ) ),
nullptr, context, layer );
180 if ( drawSubdivisionsForThisSymbolLayer )
187 subdivisionSymbol->renderPolyline( QPolygonF() << QPointF( thisSubX, subTickPositionsY.at( 0 ) )
188 << QPointF( thisSubX, subTickPositionsY.at( 1 ) ),
nullptr, context, layer );
194 if ( !positions.isEmpty() )
199 if ( drawDivisionsForThisSymbolLayer )
201 divisionSymbol->renderPolyline( QPolygonF() << QPointF( lastTickPositionX, tickPositionsY.at( 0 ) )
202 << QPointF( lastTickPositionX, tickPositionsY.at( 1 ) ),
203 nullptr, context, layer );
207 if ( drawLineForThisSymbolLayer )
210 << QPointF( lastTickPositionX, verticalPos ),
nullptr, context, layer );
215 symbol->stopRender( context );
216 divisionSymbol->stopRender( context );
217 subdivisionSymbol->stopRender( context );