1 /*************************************************************************
3 * OpenOffice.org - a multi-platform office productivity suite
5 * $RCSfile: markerarrayprimitive2d.cxx,v $
9 * last change: $Author: aw $ $Date: 2008-07-21 17:41:18 $
11 * The Contents of this file are made available subject to
12 * the terms of GNU Lesser General Public License Version 2.1.
15 * GNU Lesser General Public License Version 2.1
16 * =============================================
17 * Copyright 2005 by Sun Microsystems, Inc.
18 * 901 San Antonio Road, Palo Alto, CA 94303, USA
20 * This library is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU Lesser General Public
22 * License version 2.1, as published by the Free Software Foundation.
24 * This library is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 * Lesser General Public License for more details.
29 * You should have received a copy of the GNU Lesser General Public
30 * License along with this library; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
34 ************************************************************************/
36 // MARKER(update_precomp.py): autogen include statement, do not remove
37 #include "precompiled_drawinglayer.hxx"
39 #include <drawinglayer/primitive2d/markerarrayprimitive2d.hxx>
40 #include <basegfx/matrix/b2dhommatrix.hxx>
41 #include <drawinglayer/geometry/viewinformation2d.hxx>
42 #include <basegfx/polygon/b2dpolygon.hxx>
43 #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
44 #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
45 #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
46 #include <drawinglayer/primitive2d/bitmapprimitive2d.hxx>
48 //////////////////////////////////////////////////////////////////////////////
50 using namespace com::sun::star
;
52 //////////////////////////////////////////////////////////////////////////////
54 namespace drawinglayer
58 Primitive2DSequence
MarkerArrayPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D
& rViewInformation
) const
60 Primitive2DSequence xRetval
;
61 const std::vector
< basegfx::B2DPoint
>& rPositions
= getPositions();
62 const sal_uInt32
nMarkerCount(rPositions
.size());
64 if(nMarkerCount
&& !getMarker().IsEmpty())
67 Size
aBitmapSize(getMarker().GetSizePixel());
69 if(aBitmapSize
.Width() && aBitmapSize
.Height())
71 // get logic half pixel size
72 basegfx::B2DVector
aLogicHalfSize(rViewInformation
.getInverseObjectToViewTransformation() *
73 basegfx::B2DVector(aBitmapSize
.getWidth() - 1.0, aBitmapSize
.getHeight() - 1.0));
75 // use half size for expand
76 aLogicHalfSize
*= 0.5;
78 // number of primitives is known; realloc accordingly
79 xRetval
.realloc(nMarkerCount
);
81 for(sal_uInt32
a(0); a
< nMarkerCount
; a
++)
83 const basegfx::B2DPoint
& rPosition(rPositions
[a
]);
84 const basegfx::B2DRange
aRange(rPosition
- aLogicHalfSize
, rPosition
+ aLogicHalfSize
);
85 basegfx::B2DHomMatrix aTransform
;
87 aTransform
.set(0, 0, aRange
.getWidth());
88 aTransform
.set(1, 1, aRange
.getHeight());
89 aTransform
.set(0, 2, aRange
.getMinX());
90 aTransform
.set(1, 2, aRange
.getMinY());
92 xRetval
[a
] = Primitive2DReference(new BitmapPrimitive2D(getMarker(), aTransform
));
100 MarkerArrayPrimitive2D::MarkerArrayPrimitive2D(
101 const std::vector
< basegfx::B2DPoint
>& rPositions
,
102 const BitmapEx
& rMarker
)
104 maPositions(rPositions
),
109 bool MarkerArrayPrimitive2D::operator==(const BasePrimitive2D
& rPrimitive
) const
111 if(BasePrimitive2D::operator==(rPrimitive
))
113 const MarkerArrayPrimitive2D
& rCompare
= (MarkerArrayPrimitive2D
&)rPrimitive
;
115 return (getPositions() == rCompare
.getPositions()
116 && getMarker() == rCompare
.getMarker());
122 basegfx::B2DRange
MarkerArrayPrimitive2D::getB2DRange(const geometry::ViewInformation2D
& rViewInformation
) const
124 basegfx::B2DRange aRetval
;
126 if(getPositions().size())
128 // get the basic range from the position vector
129 for(std::vector
< basegfx::B2DPoint
>::const_iterator
aIter(getPositions().begin()); aIter
!= getPositions().end(); aIter
++)
131 aRetval
.expand(*aIter
);
134 if(!getMarker().IsEmpty())
137 const Size
aBitmapSize(getMarker().GetSizePixel());
139 if(aBitmapSize
.Width() && aBitmapSize
.Height())
141 // get logic half size
142 basegfx::B2DVector
aLogicHalfSize(rViewInformation
.getInverseObjectToViewTransformation() *
143 basegfx::B2DVector(aBitmapSize
.getWidth(), aBitmapSize
.getHeight()));
145 // use half size for expand
146 aLogicHalfSize
*= 0.5;
148 // apply aLogicHalfSize
149 aRetval
.expand(aRetval
.getMinimum() - aLogicHalfSize
);
150 aRetval
.expand(aRetval
.getMaximum() + aLogicHalfSize
);
159 ImplPrimitrive2DIDBlock(MarkerArrayPrimitive2D
, PRIMITIVE2D_ID_MARKERARRAYPRIMITIVE2D
)
161 } // end of namespace primitive2d
162 } // end of namespace drawinglayer
164 //////////////////////////////////////////////////////////////////////////////