1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_svx.hxx"
30 #include <svx/sdr/overlay/overlaytriangle.hxx>
31 #include <tools/poly.hxx>
32 #include <vcl/salbtype.hxx>
33 #include <vcl/outdev.hxx>
34 #include <basegfx/matrix/b2dhommatrix.hxx>
35 #include <basegfx/polygon/b2dpolygontools.hxx>
36 #include <basegfx/polygon/b2dpolygon.hxx>
37 #include <svx/sdr/overlay/overlaymanager.hxx>
38 #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
39 #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
40 
41 //////////////////////////////////////////////////////////////////////////////
42 
43 namespace sdr
44 {
45 	namespace overlay
46 	{
47 		drawinglayer::primitive2d::Primitive2DSequence OverlayTriangle::createOverlayObjectPrimitive2DSequence()
48 		{
49 			basegfx::B2DPolygon aPolygon;
50 
51 			aPolygon.append(getBasePosition());
52 			aPolygon.append(getSecondPosition());
53 			aPolygon.append(getThirdPosition());
54 			aPolygon.setClosed(true);
55 
56             const drawinglayer::primitive2d::Primitive2DReference aReference(
57                 new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(
58 					basegfx::B2DPolyPolygon(aPolygon),
59 					getBaseColor().getBColor()));
60 
61             return drawinglayer::primitive2d::Primitive2DSequence(&aReference, 1);
62 		}
63 
64 		OverlayTriangle::OverlayTriangle(
65 			const basegfx::B2DPoint& rBasePos,
66 			const basegfx::B2DPoint& rSecondPos,
67 			const basegfx::B2DPoint& rThirdPos,
68 			Color aTriangleColor)
69 		:	OverlayObjectWithBasePosition(rBasePos, aTriangleColor),
70 			maSecondPosition(rSecondPos),
71 			maThirdPosition(rThirdPos)
72 		{
73 		}
74 
75 		OverlayTriangle::~OverlayTriangle()
76 		{
77 		}
78 
79         void OverlayTriangle::setSecondPosition(const basegfx::B2DPoint& rNew)
80 		{
81 			if(rNew != maSecondPosition)
82 			{
83 				// remember new value
84 				maSecondPosition = rNew;
85 
86 				// register change (after change)
87 				objectChange();
88 			}
89 		}
90 
91 		void OverlayTriangle::setThirdPosition(const basegfx::B2DPoint& rNew)
92 		{
93 			if(rNew != maThirdPosition)
94 			{
95 				// remember new value
96 				maThirdPosition = rNew;
97 
98 				// register change (after change)
99 				objectChange();
100 			}
101 		}
102 	} // end of namespace overlay
103 } // end of namespace sdr
104 
105 //////////////////////////////////////////////////////////////////////////////
106 // eof
107