/src/libreoffice/svx/source/sdr/overlay/overlaytools.cxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
5 | | * This Source Code Form is subject to the terms of the Mozilla Public |
6 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
7 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
11 | | * Licensed to the Apache Software Foundation (ASF) under one or more |
12 | | * contributor license agreements. See the NOTICE file distributed |
13 | | * with this work for additional information regarding copyright |
14 | | * ownership. The ASF licenses this file to you under the Apache |
15 | | * License, Version 2.0 (the "License"); you may not use this file |
16 | | * except in compliance with the License. You may obtain a copy of |
17 | | * the License at http://www.apache.org/licenses/LICENSE-2.0 . |
18 | | */ |
19 | | |
20 | | |
21 | | #include <sdr/overlay/overlaytools.hxx> |
22 | | #include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx> |
23 | | #include <basegfx/matrix/b2dhommatrix.hxx> |
24 | | #include <drawinglayer/primitive2d/bitmapprimitive2d.hxx> |
25 | | #include <basegfx/polygon/b2dpolygon.hxx> |
26 | | #include <basegfx/polygon/b2dpolygontools.hxx> |
27 | | #include <drawinglayer/primitive2d/PolygonMarkerPrimitive2D.hxx> |
28 | | #include <drawinglayer/primitive2d/PolyPolygonColorPrimitive2D.hxx> |
29 | | #include <drawinglayer/primitive2d/PolyPolygonStrokePrimitive2D.hxx> |
30 | | #include <drawinglayer/primitive2d/PolygonStrokePrimitive2D.hxx> |
31 | | #include <drawinglayer/geometry/viewinformation2d.hxx> |
32 | | #include <basegfx/matrix/b2dhommatrixtools.hxx> |
33 | | #include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx> |
34 | | #include <drawinglayer/primitive2d/PolyPolygonRGBAPrimitive2D.hxx> |
35 | | #include <tools/color.hxx> |
36 | | #include <vcl/svapp.hxx> |
37 | | #include <vcl/settings.hxx> |
38 | | |
39 | | |
40 | | namespace drawinglayer::primitive2d |
41 | | { |
42 | | |
43 | | OverlayStaticRectanglePrimitive::OverlayStaticRectanglePrimitive( |
44 | | const basegfx::B2DPoint& rPosition, |
45 | | const basegfx::B2DSize& rSize, |
46 | | const basegfx::BColor& rStrokeColor, |
47 | | const basegfx::BColor& rFillColor, |
48 | | double fTransparence, |
49 | | double fRotation) |
50 | 0 | : maPosition(rPosition) |
51 | 0 | , maSize(rSize) |
52 | 0 | , maStrokeColor(rStrokeColor) |
53 | 0 | , maFillColor(rFillColor) |
54 | 0 | , mfTransparence(fTransparence) |
55 | 0 | , mfRotation(fRotation) |
56 | 0 | {} |
57 | | |
58 | | Primitive2DReference OverlayStaticRectanglePrimitive::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const |
59 | 0 | { |
60 | 0 | const double fHalfWidth = maSize.getWidth() * getDiscreteUnit() / 2.0; |
61 | 0 | const double fHalfHeight = maSize.getHeight() * getDiscreteUnit() / 2.0; |
62 | |
|
63 | 0 | basegfx::B2DRange aRange( |
64 | 0 | maPosition.getX() - fHalfWidth, maPosition.getY() - fHalfHeight, |
65 | 0 | maPosition.getX() + fHalfWidth, maPosition.getY() + fHalfHeight); |
66 | |
|
67 | 0 | if (getDiscreteUnit() <= 0.0 || mfTransparence > 1.0) |
68 | 0 | return nullptr; |
69 | | |
70 | 0 | basegfx::B2DPolygon aPolygon( |
71 | 0 | basegfx::utils::createPolygonFromRect(aRange)); |
72 | | |
73 | | // create filled primitive |
74 | 0 | basegfx::B2DPolyPolygon aPolyPolygon; |
75 | 0 | aPolyPolygon.append(aPolygon); |
76 | |
|
77 | 0 | const attribute::LineAttribute aLineAttribute(maStrokeColor, 1.0); |
78 | | |
79 | | // create data |
80 | 0 | const Primitive2DReference aStroke( |
81 | 0 | new PolyPolygonStrokePrimitive2D(aPolyPolygon, aLineAttribute)); |
82 | | |
83 | | // create fill primitive |
84 | 0 | const Primitive2DReference aFill( |
85 | 0 | new PolyPolygonColorPrimitive2D(std::move(aPolyPolygon), maFillColor)); |
86 | |
|
87 | 0 | Primitive2DContainer aPrimitive2DSequence { aFill, aStroke }; |
88 | | |
89 | | // embed filled to transparency (if used) |
90 | 0 | if (mfTransparence > 0.0) |
91 | 0 | { |
92 | 0 | return new UnifiedTransparencePrimitive2D( |
93 | 0 | std::move(aPrimitive2DSequence), |
94 | 0 | mfTransparence); |
95 | 0 | } |
96 | | |
97 | 0 | return new GroupPrimitive2D(std::move(aPrimitive2DSequence)); |
98 | 0 | } |
99 | | |
100 | | bool OverlayStaticRectanglePrimitive::operator==(const BasePrimitive2D& rPrimitive) const |
101 | 0 | { |
102 | 0 | if (DiscreteMetricDependentPrimitive2D::operator==(rPrimitive)) |
103 | 0 | { |
104 | 0 | const OverlayStaticRectanglePrimitive& rCompare = static_cast<const OverlayStaticRectanglePrimitive&>(rPrimitive); |
105 | |
|
106 | 0 | return (maPosition == rCompare.maPosition |
107 | 0 | && maSize == rCompare.maSize |
108 | 0 | && maStrokeColor == rCompare.maStrokeColor |
109 | 0 | && maFillColor == rCompare.maFillColor |
110 | 0 | && mfTransparence == rCompare.mfTransparence |
111 | 0 | && mfRotation == rCompare.mfRotation); |
112 | 0 | } |
113 | | |
114 | 0 | return false; |
115 | 0 | } |
116 | | |
117 | | sal_uInt32 OverlayStaticRectanglePrimitive::getPrimitive2DID() const |
118 | 0 | { |
119 | 0 | return PRIMITIVE2D_ID_OVERLAYRECTANGLEPRIMITIVE; |
120 | 0 | } |
121 | | |
122 | | |
123 | | |
124 | | OverlayBitmapPrimitive::OverlayBitmapPrimitive( |
125 | | const Bitmap& rBitmap, |
126 | | const basegfx::B2DPoint& rBasePosition, |
127 | | sal_uInt16 nCenterX, |
128 | | sal_uInt16 nCenterY, |
129 | | double fShearX, |
130 | | double fRotation) |
131 | 0 | : maBitmap(rBitmap), |
132 | 0 | maBasePosition(rBasePosition), |
133 | 0 | mnCenterX(nCenterX), |
134 | 0 | mnCenterY(nCenterY), |
135 | 0 | mfShearX(fShearX), |
136 | 0 | mfRotation(fRotation) |
137 | 0 | {} |
138 | | |
139 | | Primitive2DReference OverlayBitmapPrimitive::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const |
140 | 0 | { |
141 | 0 | const Size aBitmapSize(getBitmap().GetSizePixel()); |
142 | |
|
143 | 0 | if(!aBitmapSize.Width() || !aBitmapSize.Height() || getDiscreteUnit() <= 0.0) |
144 | 0 | return nullptr; |
145 | | |
146 | | // calculate back from internal bitmap's extreme coordinates (the edges) |
147 | | // to logical coordinates. Only use a unified scaling value (getDiscreteUnit(), |
148 | | // the prepared one which expresses how many logic units form a discrete unit) |
149 | | // for this step. This primitive is to be displayed always unscaled (in its pixel size) |
150 | | // and unrotated, more like a marker |
151 | 0 | const double fLeft((0.0 - getCenterX()) * getDiscreteUnit()); |
152 | 0 | const double fTop((0.0 - getCenterY()) * getDiscreteUnit()); |
153 | 0 | const double fRight((aBitmapSize.getWidth() - getCenterX()) * getDiscreteUnit()); |
154 | 0 | const double fBottom((aBitmapSize.getHeight() - getCenterY()) * getDiscreteUnit()); |
155 | | |
156 | | // create a BitmapPrimitive2D using those positions |
157 | 0 | basegfx::B2DHomMatrix aTransform; |
158 | |
|
159 | 0 | aTransform.set(0, 0, fRight - fLeft); |
160 | 0 | aTransform.set(1, 1, fBottom - fTop); |
161 | 0 | aTransform.set(0, 2, fLeft); |
162 | 0 | aTransform.set(1, 2, fTop); |
163 | | |
164 | | // if shearX is used, apply it, too |
165 | 0 | if(!basegfx::fTools::equalZero(getShearX())) |
166 | 0 | { |
167 | 0 | aTransform.shearX(getShearX()); |
168 | 0 | } |
169 | | |
170 | | // if rotation is used, apply it, too |
171 | 0 | if(!basegfx::fTools::equalZero(getRotation())) |
172 | 0 | { |
173 | 0 | aTransform.rotate(getRotation()); |
174 | 0 | } |
175 | | |
176 | | // add BasePosition |
177 | 0 | aTransform.translate(getBasePosition().getX(), getBasePosition().getY()); |
178 | |
|
179 | 0 | return new BitmapPrimitive2D(getBitmap(), aTransform); |
180 | 0 | } |
181 | | |
182 | | bool OverlayBitmapPrimitive::operator==( const BasePrimitive2D& rPrimitive ) const |
183 | 0 | { |
184 | 0 | if(DiscreteMetricDependentPrimitive2D::operator==(rPrimitive)) |
185 | 0 | { |
186 | 0 | const OverlayBitmapPrimitive& rCompare = static_cast< const OverlayBitmapPrimitive& >(rPrimitive); |
187 | |
|
188 | 0 | return (getBitmap() == rCompare.getBitmap() |
189 | 0 | && getBasePosition() == rCompare.getBasePosition() |
190 | 0 | && getCenterX() == rCompare.getCenterX() |
191 | 0 | && getCenterY() == rCompare.getCenterY() |
192 | 0 | && getShearX() == rCompare.getShearX() |
193 | 0 | && getRotation() == rCompare.getRotation()); |
194 | 0 | } |
195 | | |
196 | 0 | return false; |
197 | 0 | } |
198 | | |
199 | | sal_uInt32 OverlayBitmapPrimitive::getPrimitive2DID() const |
200 | 0 | { |
201 | 0 | return PRIMITIVE2D_ID_OVERLAYBITMAPEXPRIMITIVE; |
202 | 0 | } |
203 | | |
204 | | |
205 | | |
206 | | OverlayCrosshairPrimitive::OverlayCrosshairPrimitive( |
207 | | const basegfx::B2DPoint& rBasePosition, |
208 | | const basegfx::BColor& rRGBColorA, |
209 | | const basegfx::BColor& rRGBColorB, |
210 | | double fDiscreteDashLength) |
211 | 0 | : maBasePosition(rBasePosition), |
212 | 0 | maRGBColorA(rRGBColorA), |
213 | 0 | maRGBColorB(rRGBColorB), |
214 | 0 | mfDiscreteDashLength(fDiscreteDashLength) |
215 | 0 | {} |
216 | | |
217 | | Primitive2DReference OverlayCrosshairPrimitive::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const |
218 | 0 | { |
219 | | // use the prepared Viewport information accessible using getViewport() |
220 | |
|
221 | 0 | if(getViewport().isEmpty()) |
222 | 0 | return nullptr; |
223 | | |
224 | 0 | basegfx::B2DPolygon aPolygon; |
225 | |
|
226 | 0 | aPolygon.append(basegfx::B2DPoint(getViewport().getMinX(), getBasePosition().getY())); |
227 | 0 | aPolygon.append(basegfx::B2DPoint(getViewport().getMaxX(), getBasePosition().getY())); |
228 | |
|
229 | 0 | Primitive2DReference xMarker1 = |
230 | 0 | new PolygonMarkerPrimitive2D( |
231 | 0 | aPolygon, |
232 | 0 | getRGBColorA(), |
233 | 0 | getRGBColorB(), |
234 | 0 | getDiscreteDashLength()); |
235 | |
|
236 | 0 | aPolygon.clear(); |
237 | 0 | aPolygon.append(basegfx::B2DPoint(getBasePosition().getX(), getViewport().getMinY())); |
238 | 0 | aPolygon.append(basegfx::B2DPoint(getBasePosition().getX(), getViewport().getMaxY())); |
239 | |
|
240 | 0 | Primitive2DReference xMarker2 = |
241 | 0 | new PolygonMarkerPrimitive2D( |
242 | 0 | std::move(aPolygon), |
243 | 0 | getRGBColorA(), |
244 | 0 | getRGBColorB(), |
245 | 0 | getDiscreteDashLength()); |
246 | |
|
247 | 0 | return new GroupPrimitive2D(Primitive2DContainer { xMarker1, xMarker2 }); |
248 | 0 | } |
249 | | |
250 | | bool OverlayCrosshairPrimitive::operator==( const BasePrimitive2D& rPrimitive ) const |
251 | 0 | { |
252 | 0 | if(ViewportDependentPrimitive2D::operator==(rPrimitive)) |
253 | 0 | { |
254 | 0 | const OverlayCrosshairPrimitive& rCompare = static_cast< const OverlayCrosshairPrimitive& >(rPrimitive); |
255 | |
|
256 | 0 | return (getBasePosition() == rCompare.getBasePosition() |
257 | 0 | && getRGBColorA() == rCompare.getRGBColorA() |
258 | 0 | && getRGBColorB() == rCompare.getRGBColorB() |
259 | 0 | && getDiscreteDashLength() == rCompare.getDiscreteDashLength()); |
260 | 0 | } |
261 | | |
262 | 0 | return false; |
263 | 0 | } |
264 | | |
265 | | sal_uInt32 OverlayCrosshairPrimitive::getPrimitive2DID() const |
266 | 0 | { |
267 | 0 | return PRIMITIVE2D_ID_OVERLAYCROSSHAIRPRIMITIVE; |
268 | 0 | } |
269 | | |
270 | | |
271 | | |
272 | | OverlayRectanglePrimitive::OverlayRectanglePrimitive( |
273 | | const basegfx::B2DRange& rObjectRange, |
274 | | const basegfx::BColor& rColor, |
275 | | double fTransparence, |
276 | | double fDiscreteGrow, |
277 | | double fDiscreteShrink, |
278 | | double fRotation) |
279 | 0 | : maObjectRange(rObjectRange), |
280 | 0 | maColor(rColor), |
281 | 0 | mfTransparence(fTransparence), |
282 | 0 | mfDiscreteGrow(fDiscreteGrow), |
283 | 0 | mfDiscreteShrink(fDiscreteShrink), |
284 | 0 | mfRotation(fRotation) |
285 | 0 | {} |
286 | | |
287 | | Primitive2DReference OverlayRectanglePrimitive::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const |
288 | 0 | { |
289 | 0 | Primitive2DReference aRetval; |
290 | 0 | basegfx::B2DRange aInnerRange(getObjectRange()); |
291 | |
|
292 | 0 | if(aInnerRange.isEmpty() || getDiscreteUnit() <= 0.0 || getTransparence() > 1.0) |
293 | 0 | return nullptr; |
294 | | |
295 | 0 | if (!Application::GetSettings().GetStyleSettings().GetHighContrastMode()) |
296 | 0 | { |
297 | 0 | basegfx::B2DRange aOuterRange(aInnerRange); |
298 | | // grow/shrink inner/outer polygons |
299 | 0 | aOuterRange.grow(getDiscreteUnit() * getDiscreteGrow()); |
300 | 0 | aInnerRange.grow(getDiscreteUnit() * -getDiscreteShrink()); |
301 | | |
302 | | // convert to polygons |
303 | 0 | const double fFullGrow(getDiscreteGrow() + getDiscreteShrink()); |
304 | 0 | const double fRelativeRadiusX(fFullGrow / aOuterRange.getWidth()); |
305 | 0 | const double fRelativeRadiusY(fFullGrow / aOuterRange.getHeight()); |
306 | 0 | basegfx::B2DPolygon aOuterPolygon( |
307 | 0 | basegfx::utils::createPolygonFromRect( |
308 | 0 | aOuterRange, |
309 | 0 | fRelativeRadiusX, |
310 | 0 | fRelativeRadiusY)); |
311 | 0 | basegfx::B2DPolygon aInnerPolygon( |
312 | 0 | basegfx::utils::createPolygonFromRect( |
313 | 0 | aInnerRange)); |
314 | | |
315 | | // apply evtl. existing rotation |
316 | 0 | if(!basegfx::fTools::equalZero(getRotation())) |
317 | 0 | { |
318 | 0 | const basegfx::B2DHomMatrix aTransform(basegfx::utils::createRotateAroundPoint( |
319 | 0 | getObjectRange().getMinX(), getObjectRange().getMinY(), getRotation())); |
320 | |
|
321 | 0 | aOuterPolygon.transform(aTransform); |
322 | 0 | aInnerPolygon.transform(aTransform); |
323 | 0 | } |
324 | | |
325 | | // create filled primitive |
326 | 0 | basegfx::B2DPolyPolygon aPolyPolygon; |
327 | |
|
328 | 0 | aPolyPolygon.append(aOuterPolygon); |
329 | 0 | aPolyPolygon.append(aInnerPolygon); |
330 | | |
331 | | // create fill primitive |
332 | 0 | if (getTransparence() <= 0.0) |
333 | 0 | { |
334 | | // no transparence |
335 | 0 | aRetval = new PolyPolygonColorPrimitive2D( |
336 | 0 | std::move(aPolyPolygon), |
337 | 0 | getColor()); |
338 | 0 | } |
339 | 0 | else |
340 | 0 | { |
341 | | // transparence |
342 | 0 | aRetval = new PolyPolygonRGBAPrimitive2D( |
343 | 0 | std::move(aPolyPolygon), |
344 | 0 | getColor(), |
345 | 0 | getTransparence()); |
346 | 0 | } |
347 | 0 | } |
348 | 0 | else |
349 | 0 | { |
350 | 0 | basegfx::B2DPolygon aInnerPolygon( |
351 | 0 | basegfx::utils::createPolygonFromRect( |
352 | 0 | aInnerRange)); |
353 | | |
354 | | // apply evtl. existing rotation |
355 | 0 | if(!basegfx::fTools::equalZero(getRotation())) |
356 | 0 | { |
357 | 0 | const basegfx::B2DHomMatrix aTransform(basegfx::utils::createRotateAroundPoint( |
358 | 0 | getObjectRange().getMinX(), getObjectRange().getMinY(), getRotation())); |
359 | |
|
360 | 0 | aInnerPolygon.transform(aTransform); |
361 | 0 | } |
362 | | |
363 | | // for high contrast, use a thick stroke |
364 | 0 | const basegfx::BColor aHighContrastLineColor(Application::GetSettings().GetStyleSettings().GetHighlightColor().getBColor()); |
365 | 0 | const attribute::LineAttribute aLineAttribute(aHighContrastLineColor, getDiscreteUnit() * getDiscreteGrow()); |
366 | |
|
367 | 0 | aRetval = new PolygonStrokePrimitive2D(std::move(aInnerPolygon), aLineAttribute); |
368 | 0 | } |
369 | |
|
370 | 0 | return aRetval; |
371 | 0 | } |
372 | | |
373 | | bool OverlayRectanglePrimitive::operator==( const BasePrimitive2D& rPrimitive ) const |
374 | 0 | { |
375 | 0 | if(DiscreteMetricDependentPrimitive2D::operator==(rPrimitive)) |
376 | 0 | { |
377 | 0 | const OverlayRectanglePrimitive& rCompare = static_cast< const OverlayRectanglePrimitive& >(rPrimitive); |
378 | |
|
379 | 0 | return (getObjectRange() == rCompare.getObjectRange() |
380 | 0 | && getColor() == rCompare.getColor() |
381 | 0 | && getTransparence() == rCompare.getTransparence() |
382 | 0 | && getDiscreteGrow() == rCompare.getDiscreteGrow() |
383 | 0 | && getDiscreteShrink() == rCompare.getDiscreteShrink() |
384 | 0 | && getRotation() == rCompare.getRotation()); |
385 | 0 | } |
386 | | |
387 | 0 | return false; |
388 | 0 | } |
389 | | |
390 | | sal_uInt32 OverlayRectanglePrimitive::getPrimitive2DID() const |
391 | 0 | { |
392 | 0 | return PRIMITIVE2D_ID_OVERLAYRECTANGLEPRIMITIVE; |
393 | 0 | } |
394 | | |
395 | | |
396 | | |
397 | | OverlayHelplineStripedPrimitive::OverlayHelplineStripedPrimitive( |
398 | | const basegfx::B2DPoint& rBasePosition, |
399 | | HelplineStyle eStyle, |
400 | | const basegfx::BColor& rRGBColorA, |
401 | | const basegfx::BColor& rRGBColorB, |
402 | | double fDiscreteDashLength) |
403 | 0 | : maBasePosition(rBasePosition), |
404 | 0 | meStyle(eStyle), |
405 | 0 | maRGBColorA(rRGBColorA), |
406 | 0 | maRGBColorB(rRGBColorB), |
407 | 0 | mfDiscreteDashLength(fDiscreteDashLength) |
408 | 0 | {} |
409 | | |
410 | | Primitive2DReference OverlayHelplineStripedPrimitive::create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const |
411 | 0 | { |
412 | | // use the prepared Viewport information accessible using getViewport() |
413 | |
|
414 | 0 | if(getViewport().isEmpty()) |
415 | 0 | return nullptr; |
416 | | |
417 | 0 | Primitive2DReference xRetVal; |
418 | 0 | switch(getStyle()) |
419 | 0 | { |
420 | 0 | case HELPLINESTYLE_VERTICAL : |
421 | 0 | { |
422 | 0 | basegfx::B2DPolygon aLine; |
423 | |
|
424 | 0 | aLine.append(basegfx::B2DPoint(getBasePosition().getX(), getViewport().getMinY())); |
425 | 0 | aLine.append(basegfx::B2DPoint(getBasePosition().getX(), getViewport().getMaxY())); |
426 | |
|
427 | 0 | xRetVal = |
428 | 0 | new PolygonMarkerPrimitive2D( |
429 | 0 | std::move(aLine), |
430 | 0 | getRGBColorA(), |
431 | 0 | getRGBColorB(), |
432 | 0 | getDiscreteDashLength()); |
433 | 0 | break; |
434 | 0 | } |
435 | | |
436 | 0 | case HELPLINESTYLE_HORIZONTAL : |
437 | 0 | { |
438 | 0 | basegfx::B2DPolygon aLine; |
439 | |
|
440 | 0 | aLine.append(basegfx::B2DPoint(getViewport().getMinX(), getBasePosition().getY())); |
441 | 0 | aLine.append(basegfx::B2DPoint(getViewport().getMaxX(), getBasePosition().getY())); |
442 | |
|
443 | 0 | xRetVal = |
444 | 0 | new PolygonMarkerPrimitive2D( |
445 | 0 | std::move(aLine), |
446 | 0 | getRGBColorA(), |
447 | 0 | getRGBColorB(), |
448 | 0 | getDiscreteDashLength()); |
449 | 0 | break; |
450 | 0 | } |
451 | | |
452 | 0 | default: // case HELPLINESTYLE_POINT : |
453 | 0 | { |
454 | 0 | const double fDiscreteUnit((rViewInformation.getInverseObjectToViewTransformation() * basegfx::B2DVector(1.0, 0.0)).getLength()); |
455 | 0 | basegfx::B2DPolygon aLineA, aLineB; |
456 | |
|
457 | 0 | aLineA.append(basegfx::B2DPoint(getBasePosition().getX(), getBasePosition().getY() - fDiscreteUnit)); |
458 | 0 | aLineA.append(basegfx::B2DPoint(getBasePosition().getX(), getBasePosition().getY() + fDiscreteUnit)); |
459 | |
|
460 | 0 | Primitive2DReference xMarker1 = |
461 | 0 | new PolygonMarkerPrimitive2D( |
462 | 0 | std::move(aLineA), |
463 | 0 | getRGBColorA(), |
464 | 0 | getRGBColorB(), |
465 | 0 | getDiscreteDashLength()); |
466 | |
|
467 | 0 | aLineB.append(basegfx::B2DPoint(getBasePosition().getX() - fDiscreteUnit, getBasePosition().getY())); |
468 | 0 | aLineB.append(basegfx::B2DPoint(getBasePosition().getX() + fDiscreteUnit, getBasePosition().getY())); |
469 | |
|
470 | 0 | Primitive2DReference xMarker2 = |
471 | 0 | new PolygonMarkerPrimitive2D( |
472 | 0 | std::move(aLineB), |
473 | 0 | getRGBColorA(), |
474 | 0 | getRGBColorB(), |
475 | 0 | getDiscreteDashLength()); |
476 | |
|
477 | 0 | xRetVal = new GroupPrimitive2D(Primitive2DContainer{ xMarker1, xMarker2 }); |
478 | 0 | break; |
479 | 0 | } |
480 | 0 | } |
481 | 0 | return xRetVal; |
482 | 0 | } |
483 | | |
484 | | bool OverlayHelplineStripedPrimitive::operator==( const BasePrimitive2D& rPrimitive ) const |
485 | 0 | { |
486 | 0 | if(ViewportDependentPrimitive2D::operator==(rPrimitive)) |
487 | 0 | { |
488 | 0 | const OverlayHelplineStripedPrimitive& rCompare = static_cast< const OverlayHelplineStripedPrimitive& >(rPrimitive); |
489 | |
|
490 | 0 | return (getBasePosition() == rCompare.getBasePosition() |
491 | 0 | && getStyle() == rCompare.getStyle() |
492 | 0 | && getRGBColorA() == rCompare.getRGBColorA() |
493 | 0 | && getRGBColorB() == rCompare.getRGBColorB() |
494 | 0 | && getDiscreteDashLength() == rCompare.getDiscreteDashLength()); |
495 | 0 | } |
496 | | |
497 | 0 | return false; |
498 | 0 | } |
499 | | |
500 | | sal_uInt32 OverlayHelplineStripedPrimitive::getPrimitive2DID() const |
501 | 0 | { |
502 | 0 | return PRIMITIVE2D_ID_OVERLAYHELPLINESTRIPEDPRIMITIVE; |
503 | 0 | } |
504 | | |
505 | | |
506 | | |
507 | | OverlayRollingRectanglePrimitive::OverlayRollingRectanglePrimitive( |
508 | | const basegfx::B2DRange& aRollingRectangle, |
509 | | const basegfx::BColor& rRGBColorA, |
510 | | const basegfx::BColor& rRGBColorB, |
511 | | double fDiscreteDashLength) |
512 | 0 | : maRollingRectangle(aRollingRectangle), |
513 | 0 | maRGBColorA(rRGBColorA), |
514 | 0 | maRGBColorB(rRGBColorB), |
515 | 0 | mfDiscreteDashLength(fDiscreteDashLength) |
516 | 0 | {} |
517 | | |
518 | | Primitive2DReference OverlayRollingRectanglePrimitive::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const |
519 | 0 | { |
520 | | // use the prepared Viewport information accessible using getViewport() |
521 | |
|
522 | 0 | if(getViewport().isEmpty()) |
523 | 0 | return nullptr; |
524 | | |
525 | 0 | Primitive2DContainer aContainer; |
526 | | // Left lines |
527 | 0 | basegfx::B2DPolygon aLine1; |
528 | 0 | aLine1.append(basegfx::B2DPoint(getViewport().getMinX(), getRollingRectangle().getMinY())); |
529 | 0 | aLine1.append(basegfx::B2DPoint(getRollingRectangle().getMinX(), getRollingRectangle().getMinY())); |
530 | 0 | aContainer.push_back(new PolygonMarkerPrimitive2D(std::move(aLine1), getRGBColorA(), getRGBColorB(), getDiscreteDashLength())); |
531 | |
|
532 | 0 | basegfx::B2DPolygon aLine2; |
533 | 0 | aLine2.append(basegfx::B2DPoint(getViewport().getMinX(), getRollingRectangle().getMaxY())); |
534 | 0 | aLine2.append(basegfx::B2DPoint(getRollingRectangle().getMinX(), getRollingRectangle().getMaxY())); |
535 | 0 | aContainer.push_back(new PolygonMarkerPrimitive2D(std::move(aLine2), getRGBColorA(), getRGBColorB(), getDiscreteDashLength())); |
536 | | |
537 | | // Right lines |
538 | 0 | basegfx::B2DPolygon aLine3; |
539 | 0 | aLine3.append(basegfx::B2DPoint(getRollingRectangle().getMaxX(), getRollingRectangle().getMinY())); |
540 | 0 | aLine3.append(basegfx::B2DPoint(getViewport().getMaxX(), getRollingRectangle().getMinY())); |
541 | 0 | aContainer.push_back(new PolygonMarkerPrimitive2D(std::move(aLine3), getRGBColorA(), getRGBColorB(), getDiscreteDashLength())); |
542 | |
|
543 | 0 | basegfx::B2DPolygon aLine4; |
544 | 0 | aLine4.append(basegfx::B2DPoint(getRollingRectangle().getMaxX(), getRollingRectangle().getMaxY())); |
545 | 0 | aLine4.append(basegfx::B2DPoint(getViewport().getMaxX(), getRollingRectangle().getMaxY())); |
546 | 0 | aContainer.push_back(new PolygonMarkerPrimitive2D(std::move(aLine4), getRGBColorA(), getRGBColorB(), getDiscreteDashLength())); |
547 | | |
548 | | // Top lines |
549 | 0 | basegfx::B2DPolygon aLine5; |
550 | 0 | aLine5.append(basegfx::B2DPoint(getRollingRectangle().getMinX(), getViewport().getMinY())); |
551 | 0 | aLine5.append(basegfx::B2DPoint(getRollingRectangle().getMinX(), getRollingRectangle().getMinY())); |
552 | 0 | aContainer.push_back(new PolygonMarkerPrimitive2D(std::move(aLine5), getRGBColorA(), getRGBColorB(), getDiscreteDashLength())); |
553 | |
|
554 | 0 | basegfx::B2DPolygon aLine6; |
555 | 0 | aLine6.append(basegfx::B2DPoint(getRollingRectangle().getMaxX(), getViewport().getMinY())); |
556 | 0 | aLine6.append(basegfx::B2DPoint(getRollingRectangle().getMaxX(), getRollingRectangle().getMinY())); |
557 | 0 | aContainer.push_back(new PolygonMarkerPrimitive2D(std::move(aLine6), getRGBColorA(), getRGBColorB(), getDiscreteDashLength())); |
558 | | |
559 | | // Bottom lines |
560 | 0 | basegfx::B2DPolygon aLine7; |
561 | 0 | aLine7.append(basegfx::B2DPoint(getRollingRectangle().getMinX(), getRollingRectangle().getMaxY())); |
562 | 0 | aLine7.append(basegfx::B2DPoint(getRollingRectangle().getMinX(), getViewport().getMaxY())); |
563 | 0 | aContainer.push_back(new PolygonMarkerPrimitive2D(std::move(aLine7), getRGBColorA(), getRGBColorB(), getDiscreteDashLength())); |
564 | |
|
565 | 0 | basegfx::B2DPolygon aLine8; |
566 | 0 | aLine8.append(basegfx::B2DPoint(getRollingRectangle().getMaxX(), getRollingRectangle().getMaxY())); |
567 | 0 | aLine8.append(basegfx::B2DPoint(getRollingRectangle().getMaxX(), getViewport().getMaxY())); |
568 | 0 | aContainer.push_back(new PolygonMarkerPrimitive2D(std::move(aLine8), getRGBColorA(), getRGBColorB(), getDiscreteDashLength())); |
569 | |
|
570 | 0 | return new GroupPrimitive2D(std::move(aContainer)); |
571 | 0 | } |
572 | | |
573 | | bool OverlayRollingRectanglePrimitive::operator==( const BasePrimitive2D& rPrimitive ) const |
574 | 0 | { |
575 | 0 | if(ViewportDependentPrimitive2D::operator==(rPrimitive)) |
576 | 0 | { |
577 | 0 | const OverlayRollingRectanglePrimitive& rCompare = static_cast< const OverlayRollingRectanglePrimitive& >(rPrimitive); |
578 | |
|
579 | 0 | return (getRollingRectangle() == rCompare.getRollingRectangle() |
580 | 0 | && getRGBColorA() == rCompare.getRGBColorA() |
581 | 0 | && getRGBColorB() == rCompare.getRGBColorB() |
582 | 0 | && getDiscreteDashLength() == rCompare.getDiscreteDashLength()); |
583 | 0 | } |
584 | | |
585 | 0 | return false; |
586 | 0 | } |
587 | | |
588 | | sal_uInt32 OverlayRollingRectanglePrimitive::getPrimitive2DID() const |
589 | 0 | { |
590 | 0 | return PRIMITIVE2D_ID_OVERLAYROLLINGRECTANGLEPRIMITIVE; |
591 | 0 | } |
592 | | |
593 | | } // end of namespace |
594 | | |
595 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |