LibreOffice Module drawinglayer (master) 1
markerarrayprimitive2d.cxx
Go to the documentation of this file.
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
26
27
28using namespace com::sun::star;
29
30
32{
34 {
35 const std::vector< basegfx::B2DPoint >& rPositions = getPositions();
36 const sal_uInt32 nMarkerCount(rPositions.size());
37
38 if(!nMarkerCount || getMarker().IsEmpty())
39 return;
40
41 // get pixel size
42 Size aBitmapSize(getMarker().GetSizePixel());
43
44 if(!(aBitmapSize.Width() && aBitmapSize.Height()))
45 return;
46
47 // get logic half pixel size
48 basegfx::B2DVector aLogicHalfSize(rViewInformation.getInverseObjectToViewTransformation() *
49 basegfx::B2DVector(aBitmapSize.getWidth() - 1.0, aBitmapSize.getHeight() - 1.0));
50
51 // use half size for expand
52 aLogicHalfSize *= 0.5;
53
54 for(const auto& rPosition : rPositions)
55 {
56 const basegfx::B2DRange aRange(rPosition - aLogicHalfSize, rPosition + aLogicHalfSize);
57 basegfx::B2DHomMatrix aTransform;
58
59 aTransform.set(0, 0, aRange.getWidth());
60 aTransform.set(1, 1, aRange.getHeight());
61 aTransform.set(0, 2, aRange.getMinX());
62 aTransform.set(1, 2, aRange.getMinY());
63
64 rContainer.push_back(
66 getMarker(),
67 aTransform));
68 }
69 }
70
72 std::vector< basegfx::B2DPoint >&& rPositions,
73 const BitmapEx& rMarker)
74 : maPositions(std::move(rPositions)),
75 maMarker(rMarker)
76 {
77 }
78
80 {
81 if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
82 {
83 const MarkerArrayPrimitive2D& rCompare = static_cast<const MarkerArrayPrimitive2D&>(rPrimitive);
84
85 return (getPositions() == rCompare.getPositions()
86 && getMarker() == rCompare.getMarker());
87 }
88
89 return false;
90 }
91
93 {
94 basegfx::B2DRange aRetval;
95
96 if(!getPositions().empty())
97 {
98 // get the basic range from the position vector
99 for (auto const& pos : getPositions())
100 {
101 aRetval.expand(pos);
102 }
103
104 if(!getMarker().IsEmpty())
105 {
106 // get pixel size
107 const Size aBitmapSize(getMarker().GetSizePixel());
108
109 if(aBitmapSize.Width() && aBitmapSize.Height())
110 {
111 // get logic half size
112 basegfx::B2DVector aLogicHalfSize(rViewInformation.getInverseObjectToViewTransformation() *
113 basegfx::B2DVector(aBitmapSize.getWidth(), aBitmapSize.getHeight()));
114
115 // use half size for expand
116 aLogicHalfSize *= 0.5;
117
118 // apply aLogicHalfSize
119 aRetval.expand(aRetval.getMinimum() - aLogicHalfSize);
120 aRetval.expand(aRetval.getMaximum() + aLogicHalfSize);
121 }
122 }
123 }
124
125 return aRetval;
126 }
127
128 // provide unique ID
130 {
132 }
133
134} // end of namespace
135
136/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr tools::Long getHeight() const
constexpr tools::Long Height() const
constexpr tools::Long getWidth() const
constexpr tools::Long Width() const
void set(sal_uInt16 nRow, sal_uInt16 nColumn, double fValue)
B2DPoint getMaximum() const
B2DPoint getMinimum() const
TYPE getWidth() const
TYPE getMinX() const
TYPE getMinY() const
void expand(const Tuple2D< TYPE > &rTuple)
TYPE getHeight() const
const basegfx::B2DHomMatrix & getInverseObjectToViewTransformation() const
const std::vector< basegfx::B2DPoint > & getPositions() const
data read access
virtual sal_uInt32 getPrimitive2DID() const override
provide unique ID
virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D &rViewInformation) const override
get range
virtual void create2DDecomposition(Primitive2DContainer &rContainer, const geometry::ViewInformation2D &rViewInformation) const override
create local decomposition
MarkerArrayPrimitive2D(std::vector< basegfx::B2DPoint > &&rPositions, const BitmapEx &rMarker)
constructor
virtual bool operator==(const BasePrimitive2D &rPrimitive) const override
compare operator
#define PRIMITIVE2D_ID_MARKERARRAYPRIMITIVE2D
size_t pos