27 return QStringLiteral(
"Double Box" );
32 return QObject::tr(
"Double Box" );
65 QPainter *painter = context.
painter();
75 painter->setRenderHint( QPainter::Antialiasing,
true );
77 std::unique_ptr< QgsLineSymbol > lineSymbol( settings.
lineSymbol()->
clone() );
78 lineSymbol->startRender( context );
80 std::unique_ptr< QgsFillSymbol > fillSymbol1( settings.
fillSymbol()->
clone() );
81 fillSymbol1->startRender( context );
84 fillSymbol2->startRender( context );
86 painter->setPen( Qt::NoPen );
87 painter->setBrush( Qt::NoBrush );
93 const QList<double> positions =
segmentPositions( context, scaleContext, settings );
94 const QList<double> widths =
segmentWidths( scaleContext, settings );
99 for (
int i = 0; i < positions.size(); ++i )
104 currentSymbol = fillSymbol1.get();
108 currentSymbol = fillSymbol2.get();
116 if ( i == positions.size() - 1 )
117 maxX = thisX + thisWidth;
119 const QRectF segmentRectTop( thisX, barTopPosition, thisWidth, segmentHeight );
121 << segmentRectTop.topLeft()
122 << segmentRectTop.topRight()
123 << segmentRectTop.bottomRight()
124 << segmentRectTop.bottomLeft()
125 << segmentRectTop.topLeft(),
126 nullptr,
nullptr, context );
127 painter->drawRect( segmentRectTop );
133 currentSymbol = fillSymbol2.get();
137 currentSymbol = fillSymbol1.get(); ;
140 const QRectF segmentRectBottom( thisX, barTopPosition + segmentHeight, thisWidth, segmentHeight );
143 << segmentRectBottom.topLeft()
144 << segmentRectBottom.topRight()
145 << segmentRectBottom.bottomRight()
146 << segmentRectBottom.bottomLeft()
147 << segmentRectBottom.topLeft(),
148 nullptr,
nullptr, context );
149 useColor = !useColor;
155 for (
int layer = 0; layer < lineSymbol->symbolLayerCount(); ++layer )
158 for (
int i = 1; i < positions.size(); ++i )
161 lineSymbol->renderPolyline( QPolygonF()
162 << QPointF( lineX, barTopPosition )
163 << QPointF( lineX, barTopPosition + segmentHeight * 2 ),
164 nullptr, context, layer );
168 lineSymbol->renderPolyline( QPolygonF()
169 << QPointF( minX, barTopPosition + segmentHeight )
170 << QPointF( maxX, barTopPosition + segmentHeight ),
171 nullptr, context, layer );
175 lineSymbol->renderPolyline( QPolygonF()
176 << QPointF( minX, barTopPosition )
177 << QPointF( maxX, barTopPosition )
178 << QPointF( maxX, barTopPosition + segmentHeight * 2 )
179 << QPointF( minX, barTopPosition + segmentHeight * 2 )
180 << QPointF( minX, barTopPosition ),
181 nullptr, context, layer );
184 lineSymbol->stopRender( context );
185 fillSymbol1->stopRender( context );
186 fillSymbol2->stopRender( context );