LibreOffice Module drawinglayer (master) 1
discretebitmapprimitive2d.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
24
25
27{
29 {
30 // use getViewTransformation() and getObjectTransformation() from
31 // ObjectAndViewTransformationDependentPrimitive2D to create a BitmapPrimitive2D
32 // with the correct mapping
33
34 if(getBitmapEx().IsEmpty())
35 return;
36
37 // get discrete size
38 const Size& rSizePixel = getBitmapEx().GetSizePixel();
39 const basegfx::B2DVector aDiscreteSize(rSizePixel.Width(), rSizePixel.Height());
40
41 // get inverse ViewTransformation
42 basegfx::B2DHomMatrix aInverseViewTransformation(getViewTransformation());
43 aInverseViewTransformation.invert();
44
45 // get size and position in world coordinates
46 const basegfx::B2DVector aWorldSize(aInverseViewTransformation * aDiscreteSize);
47 const basegfx::B2DPoint aWorldTopLeft(getObjectTransformation() * getTopLeft());
48
49 // build object matrix in world coordinates so that the top-left
50 // position remains, but possible transformations (e.g. rotations)
51 // in the ObjectToView stack remain and get correctly applied
52 basegfx::B2DHomMatrix aObjectTransform;
53
54 aObjectTransform.set(0, 0, aWorldSize.getX());
55 aObjectTransform.set(1, 1, aWorldSize.getY());
56 aObjectTransform.set(0, 2, aWorldTopLeft.getX());
57 aObjectTransform.set(1, 2, aWorldTopLeft.getY());
58
59 // get inverse ObjectTransformation
60 basegfx::B2DHomMatrix aInverseObjectTransformation(getObjectTransformation());
61 aInverseObjectTransformation.invert();
62
63 // transform to object coordinate system
64 aObjectTransform = aInverseObjectTransformation * aObjectTransform;
65
66 // create BitmapPrimitive2D with now object-local coordinate data
67 rContainer.push_back(
70 aObjectTransform));
71 }
72
74 const BitmapEx& rBitmapEx,
75 const basegfx::B2DPoint& rTopLeft)
76 : maBitmapEx(rBitmapEx),
77 maTopLeft(rTopLeft)
78 {
79 }
80
82 {
83 if(ObjectAndViewTransformationDependentPrimitive2D::operator==(rPrimitive))
84 {
85 const DiscreteBitmapPrimitive2D& rCompare = static_cast<const DiscreteBitmapPrimitive2D&>(rPrimitive);
86
87 return (getBitmapEx() == rCompare.getBitmapEx()
88 && getTopLeft() == rCompare.getTopLeft());
89 }
90
91 return false;
92 }
93
94 // provide unique ID
96 {
98 }
99
100} // end of namespace
101
102/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const Size & GetSizePixel() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
void set(sal_uInt16 nRow, sal_uInt16 nColumn, double fValue)
TYPE getX() const
TYPE getY() const
DiscreteBitmapPrimitive2D(const BitmapEx &rBitmapEx, const basegfx::B2DPoint &rTopLeft)
constructor
virtual void create2DDecomposition(Primitive2DContainer &rContainer, const geometry::ViewInformation2D &rViewInformation) const override
local decomposition.
virtual bool operator==(const BasePrimitive2D &rPrimitive) const override
compare operator
virtual sal_uInt32 getPrimitive2DID() const override
provide unique ID
const basegfx::B2DHomMatrix & getViewTransformation() const
data read access
#define PRIMITIVE2D_ID_DISCRETEBITMAPPRIMITIVE2D