|
44 | 44 |
|
45 | 45 | QgsConstWkbPtr QgsFeatureRendererV2::_getPoint( QPointF& pt, QgsRenderContext& context, QgsConstWkbPtr wkbPtr )
|
46 | 46 | {
|
47 |
| - QgsDebugCall; |
48 |
| - QgsWKBTypes::Type type = wkbPtr.readHeader(); |
49 |
| - wkbPtr >> pt.rx() >> pt.ry(); |
50 |
| - wkbPtr += ( QgsWKBTypes::coordDimensions( type ) - 2 ) * sizeof( double ); |
51 |
| - |
52 |
| - if ( context.coordinateTransform() ) |
53 |
| - { |
54 |
| - double z = 0; // dummy variable for coordiante transform |
55 |
| - context.coordinateTransform()->transformInPlace( pt.rx(), pt.ry(), z ); |
56 |
| - } |
57 |
| - |
58 |
| - context.mapToPixel().transformInPlace( pt.rx(), pt.ry() ); |
59 |
| - |
60 |
| - return wkbPtr; |
| 47 | + return QgsSymbolV2::_getPoint( pt, context, wkbPtr ); |
61 | 48 | }
|
62 | 49 |
|
63 | 50 | QgsConstWkbPtr QgsFeatureRendererV2::_getLineString( QPolygonF& pts, QgsRenderContext& context, QgsConstWkbPtr wkbPtr, bool clipToExtent )
|
64 | 51 | {
|
65 |
| - QgsDebugCall; |
66 |
| - QgsWKBTypes::Type wkbType = wkbPtr.readHeader(); |
67 |
| - unsigned int nPoints; |
68 |
| - wkbPtr >> nPoints; |
69 |
| - |
70 |
| - const QgsCoordinateTransform* ct = context.coordinateTransform(); |
71 |
| - const QgsMapToPixel& mtp = context.mapToPixel(); |
72 |
| - |
73 |
| - //apply clipping for large lines to achieve a better rendering performance |
74 |
| - if ( clipToExtent && nPoints > 1 ) |
75 |
| - { |
76 |
| - const QgsRectangle& e = context.extent(); |
77 |
| - double cw = e.width() / 10; |
78 |
| - double ch = e.height() / 10; |
79 |
| - QgsRectangle clipRect( e.xMinimum() - cw, e.yMinimum() - ch, e.xMaximum() + cw, e.yMaximum() + ch ); |
80 |
| - wkbPtr -= 1 + 2 * sizeof( int ); |
81 |
| - wkbPtr = QgsClipper::clippedLineWKB( wkbPtr, clipRect, pts ); |
82 |
| - } |
83 |
| - else |
84 |
| - { |
85 |
| - int skipZM = ( QgsWKBTypes::coordDimensions( wkbType ) - 2 ) * sizeof( double ); |
86 |
| - |
87 |
| - if ( static_cast<int>( nPoints * ( 2 * sizeof( double ) + skipZM ) ) > wkbPtr.remaining() ) |
88 |
| - { |
89 |
| - QgsDebugMsg( QString( "%1 points exceed wkb length (%2>%3)" ).arg( nPoints ).arg( nPoints * ( 2 * sizeof( double ) + skipZM ) ).arg( wkbPtr.remaining() ) ); |
90 |
| - return QgsConstWkbPtr( nullptr, 0 ); |
91 |
| - } |
92 |
| - |
93 |
| - pts.resize( nPoints ); |
94 |
| - |
95 |
| - QPointF* ptr = pts.data(); |
96 |
| - for ( unsigned int i = 0; i < nPoints; ++i, ++ptr ) |
97 |
| - { |
98 |
| - wkbPtr >> ptr->rx() >> ptr->ry(); |
99 |
| - wkbPtr += skipZM; |
100 |
| - } |
101 |
| - } |
102 |
| - |
103 |
| - //transform the QPolygonF to screen coordinates |
104 |
| - if ( ct ) |
105 |
| - { |
106 |
| - ct->transformPolygon( pts ); |
107 |
| - } |
108 |
| - |
109 |
| - QPointF* ptr = pts.data(); |
110 |
| - for ( int i = 0; i < pts.size(); ++i, ++ptr ) |
111 |
| - { |
112 |
| - mtp.transformInPlace( ptr->rx(), ptr->ry() ); |
113 |
| - } |
114 |
| - |
115 |
| - return wkbPtr; |
| 52 | + return QgsSymbolV2::_getLineString( pts, context, wkbPtr, clipToExtent ); |
116 | 53 | }
|
117 | 54 |
|
118 | 55 | QgsConstWkbPtr QgsFeatureRendererV2::_getPolygon( QPolygonF& pts, QList<QPolygonF>& holes, QgsRenderContext& context, QgsConstWkbPtr wkbPtr, bool clipToExtent )
|
119 | 56 | {
|
120 |
| - QgsDebugCall; |
121 |
| - QgsWKBTypes::Type wkbType = wkbPtr.readHeader(); |
122 |
| - unsigned int numRings; |
123 |
| - wkbPtr >> numRings; |
124 |
| - |
125 |
| - if ( numRings == 0 ) // sanity check for zero rings in polygon |
126 |
| - return wkbPtr; |
127 |
| - |
128 |
| - holes.clear(); |
129 |
| - |
130 |
| - const QgsCoordinateTransform* ct = context.coordinateTransform(); |
131 |
| - const QgsMapToPixel& mtp = context.mapToPixel(); |
132 |
| - const QgsRectangle& e = context.extent(); |
133 |
| - double cw = e.width() / 10; |
134 |
| - double ch = e.height() / 10; |
135 |
| - QgsRectangle clipRect( e.xMinimum() - cw, e.yMinimum() - ch, e.xMaximum() + cw, e.yMaximum() + ch ); |
136 |
| - |
137 |
| - int skipZM = ( QgsWKBTypes::coordDimensions( wkbType ) - 2 ) * sizeof( double ); |
138 |
| - |
139 |
| - for ( unsigned int idx = 0; idx < numRings; idx++ ) |
140 |
| - { |
141 |
| - unsigned int nPoints; |
142 |
| - wkbPtr >> nPoints; |
143 |
| - |
144 |
| - if ( static_cast<int>( nPoints * ( 2 * sizeof( double ) + skipZM ) ) > wkbPtr.remaining() ) |
145 |
| - { |
146 |
| - QgsDebugMsg( QString( "%1 points exceed wkb length (%2>%3)" ).arg( nPoints ).arg( nPoints * ( 2 * sizeof( double ) + skipZM ) ).arg( wkbPtr.remaining() ) ); |
147 |
| - return QgsConstWkbPtr( nullptr, 0 ); |
148 |
| - } |
149 |
| - |
150 |
| - QPolygonF poly( nPoints ); |
151 |
| - |
152 |
| - // Extract the points from the WKB and store in a pair of vectors. |
153 |
| - QPointF* ptr = poly.data(); |
154 |
| - for ( unsigned int jdx = 0; jdx < nPoints; ++jdx, ++ptr ) |
155 |
| - { |
156 |
| - wkbPtr >> ptr->rx() >> ptr->ry(); |
157 |
| - wkbPtr += skipZM; |
158 |
| - } |
159 |
| - |
160 |
| - if ( nPoints < 1 ) |
161 |
| - continue; |
162 |
| - |
163 |
| - //clip close to view extent, if needed |
164 |
| - QRectF ptsRect = poly.boundingRect(); |
165 |
| - if ( clipToExtent && !context.extent().contains( ptsRect ) ) QgsClipper::trimPolygon( poly, clipRect ); |
166 |
| - |
167 |
| - //transform the QPolygonF to screen coordinates |
168 |
| - if ( ct ) |
169 |
| - { |
170 |
| - ct->transformPolygon( poly ); |
171 |
| - } |
172 |
| - |
173 |
| - ptr = poly.data(); |
174 |
| - for ( int i = 0; i < poly.size(); ++i, ++ptr ) |
175 |
| - { |
176 |
| - mtp.transformInPlace( ptr->rx(), ptr->ry() ); |
177 |
| - } |
178 |
| - |
179 |
| - if ( idx == 0 ) |
180 |
| - pts = poly; |
181 |
| - else |
182 |
| - holes.append( poly ); |
183 |
| - } |
184 |
| - |
185 |
| - return wkbPtr; |
| 57 | + return QgsSymbolV2::_getPolygon( pts, holes, context, wkbPtr, clipToExtent ); |
186 | 58 | }
|
187 | 59 |
|
188 | 60 | void QgsFeatureRendererV2::setScaleMethodToSymbol( QgsSymbolV2* symbol, int scaleMethod )
|
|
0 commit comments