xref: /AOO41X/main/svx/source/sdr/overlay/overlaytriangle.cxx (revision f6e50924346d0b8c0b07c91832a97665dd718b0c)
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
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_svx.hxx"
26 #include <svx/sdr/overlay/overlaytriangle.hxx>
27 #include <tools/poly.hxx>
28 #include <vcl/salbtype.hxx>
29 #include <vcl/outdev.hxx>
30 #include <basegfx/matrix/b2dhommatrix.hxx>
31 #include <basegfx/polygon/b2dpolygontools.hxx>
32 #include <basegfx/polygon/b2dpolygon.hxx>
33 #include <svx/sdr/overlay/overlaymanager.hxx>
34 #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
35 #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
36 
37 //////////////////////////////////////////////////////////////////////////////
38 
39 namespace sdr
40 {
41     namespace overlay
42     {
createOverlayObjectPrimitive2DSequence()43         drawinglayer::primitive2d::Primitive2DSequence OverlayTriangle::createOverlayObjectPrimitive2DSequence()
44         {
45             basegfx::B2DPolygon aPolygon;
46 
47             aPolygon.append(getBasePosition());
48             aPolygon.append(getSecondPosition());
49             aPolygon.append(getThirdPosition());
50             aPolygon.setClosed(true);
51 
52             const drawinglayer::primitive2d::Primitive2DReference aReference(
53                 new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(
54                     basegfx::B2DPolyPolygon(aPolygon),
55                     getBaseColor().getBColor()));
56 
57             return drawinglayer::primitive2d::Primitive2DSequence(&aReference, 1);
58         }
59 
OverlayTriangle(const basegfx::B2DPoint & rBasePos,const basegfx::B2DPoint & rSecondPos,const basegfx::B2DPoint & rThirdPos,Color aTriangleColor)60         OverlayTriangle::OverlayTriangle(
61             const basegfx::B2DPoint& rBasePos,
62             const basegfx::B2DPoint& rSecondPos,
63             const basegfx::B2DPoint& rThirdPos,
64             Color aTriangleColor)
65         :   OverlayObjectWithBasePosition(rBasePos, aTriangleColor),
66             maSecondPosition(rSecondPos),
67             maThirdPosition(rThirdPos)
68         {
69         }
70 
~OverlayTriangle()71         OverlayTriangle::~OverlayTriangle()
72         {
73         }
74 
setSecondPosition(const basegfx::B2DPoint & rNew)75         void OverlayTriangle::setSecondPosition(const basegfx::B2DPoint& rNew)
76         {
77             if(rNew != maSecondPosition)
78             {
79                 // remember new value
80                 maSecondPosition = rNew;
81 
82                 // register change (after change)
83                 objectChange();
84             }
85         }
86 
setThirdPosition(const basegfx::B2DPoint & rNew)87         void OverlayTriangle::setThirdPosition(const basegfx::B2DPoint& rNew)
88         {
89             if(rNew != maThirdPosition)
90             {
91                 // remember new value
92                 maThirdPosition = rNew;
93 
94                 // register change (after change)
95                 objectChange();
96             }
97         }
98     } // end of namespace overlay
99 } // end of namespace sdr
100 
101 //////////////////////////////////////////////////////////////////////////////
102 // eof
103