overlaytools.cxx (1cd65da9) overlaytools.cxx (414a0e15)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 33 unchanged lines hidden (view full) ---

42namespace drawinglayer
43{
44 namespace primitive2d
45 {
46 OverlayBitmapExPrimitive::OverlayBitmapExPrimitive(
47 const BitmapEx& rBitmapEx,
48 const basegfx::B2DPoint& rBasePosition,
49 sal_uInt16 nCenterX,
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 33 unchanged lines hidden (view full) ---

42namespace drawinglayer
43{
44 namespace primitive2d
45 {
46 OverlayBitmapExPrimitive::OverlayBitmapExPrimitive(
47 const BitmapEx& rBitmapEx,
48 const basegfx::B2DPoint& rBasePosition,
49 sal_uInt16 nCenterX,
50 sal_uInt16 nCenterY)
50 sal_uInt16 nCenterY,
51 double fShearX,
52 double fRotation)
51 : DiscreteMetricDependentPrimitive2D(),
52 maBitmapEx(rBitmapEx),
53 maBasePosition(rBasePosition),
54 mnCenterX(nCenterX),
53 : DiscreteMetricDependentPrimitive2D(),
54 maBitmapEx(rBitmapEx),
55 maBasePosition(rBasePosition),
56 mnCenterX(nCenterX),
55 mnCenterY(nCenterY)
57 mnCenterY(nCenterY),
58 mfShearX(fShearX),
59 mfRotation(fRotation)
56 {}
57
58 Primitive2DSequence OverlayBitmapExPrimitive::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
59 {
60 Primitive2DSequence aRetval;
61 const Size aBitmapSize(getBitmapEx().GetSizePixel());
62
63 if(aBitmapSize.Width() && aBitmapSize.Height() && basegfx::fTools::more(getDiscreteUnit(), 0.0))
64 {
65 // calculate back from internal bitmap's extreme coordinates (the edges)
66 // to logical coordinates. Only use a unified scaling value (getDiscreteUnit(),
67 // the prepared one which expresses how many logic units form a discrete unit)
68 // for this step. This primitive is to be displayed always unscaled (in it's pixel size)
69 // and unrotated, more like a marker
60 {}
61
62 Primitive2DSequence OverlayBitmapExPrimitive::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
63 {
64 Primitive2DSequence aRetval;
65 const Size aBitmapSize(getBitmapEx().GetSizePixel());
66
67 if(aBitmapSize.Width() && aBitmapSize.Height() && basegfx::fTools::more(getDiscreteUnit(), 0.0))
68 {
69 // calculate back from internal bitmap's extreme coordinates (the edges)
70 // to logical coordinates. Only use a unified scaling value (getDiscreteUnit(),
71 // the prepared one which expresses how many logic units form a discrete unit)
72 // for this step. This primitive is to be displayed always unscaled (in it's pixel size)
73 // and unrotated, more like a marker
70 const double fLeft(((0.0 - getCenterX()) * getDiscreteUnit()) + getBasePosition().getX());
71 const double fTop(((0.0 - getCenterY()) * getDiscreteUnit()) + getBasePosition().getY());
72 const double fRight(((aBitmapSize.getWidth() - getCenterX()) * getDiscreteUnit()) + getBasePosition().getX());
73 const double fBottom(((aBitmapSize.getHeight() - getCenterY()) * getDiscreteUnit()) + getBasePosition().getY());
74 const double fLeft((0.0 - getCenterX()) * getDiscreteUnit());
75 const double fTop((0.0 - getCenterY()) * getDiscreteUnit());
76 const double fRight((aBitmapSize.getWidth() - getCenterX()) * getDiscreteUnit());
77 const double fBottom((aBitmapSize.getHeight() - getCenterY()) * getDiscreteUnit());
74
75 // create a BitmapPrimitive2D using those positions
78
79 // create a BitmapPrimitive2D using those positions
76 basegfx::B2DHomMatrix aTransform;
80 basegfx::B2DHomMatrix aTransform;
77
81
78 aTransform.set(0, 0, fRight - fLeft);
79 aTransform.set(1, 1, fBottom - fTop);
80 aTransform.set(0, 2, fLeft);
81 aTransform.set(1, 2, fTop);
82 aTransform.set(0, 0, fRight - fLeft);
83 aTransform.set(1, 1, fBottom - fTop);
84 aTransform.set(0, 2, fLeft);
85 aTransform.set(1, 2, fTop);
82
86
87 // if shearX is used, apply it, too
88 if(!basegfx::fTools::equalZero(getShearX()))
89 {
90 aTransform.shearX(getShearX());
91 }
92
93 // if rotation is used, apply it, too
94 if(!basegfx::fTools::equalZero(getRotation()))
95 {
96 aTransform.rotate(getRotation());
97 }
98
99 // add BasePosition
100 aTransform.translate(getBasePosition().getX(), getBasePosition().getY());
101
83 const Primitive2DReference aPrimitive(new BitmapPrimitive2D(getBitmapEx(), aTransform));
84 aRetval = Primitive2DSequence(&aPrimitive, 1);
85 }
86
87 return aRetval;
88 }
89
90 bool OverlayBitmapExPrimitive::operator==( const BasePrimitive2D& rPrimitive ) const
91 {
92 if(DiscreteMetricDependentPrimitive2D::operator==(rPrimitive))
93 {
94 const OverlayBitmapExPrimitive& rCompare = static_cast< const OverlayBitmapExPrimitive& >(rPrimitive);
95
96 return (getBitmapEx() == rCompare.getBitmapEx()
97 && getBasePosition() == rCompare.getBasePosition()
98 && getCenterX() == rCompare.getCenterX()
102 const Primitive2DReference aPrimitive(new BitmapPrimitive2D(getBitmapEx(), aTransform));
103 aRetval = Primitive2DSequence(&aPrimitive, 1);
104 }
105
106 return aRetval;
107 }
108
109 bool OverlayBitmapExPrimitive::operator==( const BasePrimitive2D& rPrimitive ) const
110 {
111 if(DiscreteMetricDependentPrimitive2D::operator==(rPrimitive))
112 {
113 const OverlayBitmapExPrimitive& rCompare = static_cast< const OverlayBitmapExPrimitive& >(rPrimitive);
114
115 return (getBitmapEx() == rCompare.getBitmapEx()
116 && getBasePosition() == rCompare.getBasePosition()
117 && getCenterX() == rCompare.getCenterX()
99 && getCenterY() == rCompare.getCenterY());
118 && getCenterY() == rCompare.getCenterY()
119 && getShearX() == rCompare.getShearX()
120 && getRotation() == rCompare.getRotation());
100 }
101
102 return false;
103 }
104
105 ImplPrimitrive2DIDBlock(OverlayBitmapExPrimitive, PRIMITIVE2D_ID_OVERLAYBITMAPEXPRIMITIVE)
106
107 } // end of namespace primitive2d

--- 425 unchanged lines hidden ---
121 }
122
123 return false;
124 }
125
126 ImplPrimitrive2DIDBlock(OverlayBitmapExPrimitive, PRIMITIVE2D_ID_OVERLAYBITMAPEXPRIMITIVE)
127
128 } // end of namespace primitive2d

--- 425 unchanged lines hidden ---