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/overlayline.hxx>
27 #include <tools/gen.hxx>
28 #include <vcl/salbtype.hxx>
29 #include <vcl/outdev.hxx>
30 #include <basegfx/vector/b2dvector.hxx>
31 #include <basegfx/matrix/b2dhommatrix.hxx>
32 #include <basegfx/polygon/b2dpolygontools.hxx>
33 #include <svx/sdr/overlay/overlaymanager.hxx>
34 #include <basegfx/polygon/b2dpolygon.hxx>
35 #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
36 
37 //////////////////////////////////////////////////////////////////////////////
38 
39 namespace sdr
40 {
41 	namespace overlay
42 	{
createOverlayObjectPrimitive2DSequence()43 		drawinglayer::primitive2d::Primitive2DSequence OverlayLineStriped::createOverlayObjectPrimitive2DSequence()
44 		{
45 			drawinglayer::primitive2d::Primitive2DSequence aRetval;
46 
47             if(getOverlayManager())
48             {
49                 const basegfx::BColor aRGBColorA(getOverlayManager()->getStripeColorA().getBColor());
50                 const basegfx::BColor aRGBColorB(getOverlayManager()->getStripeColorB().getBColor());
51                 const double fStripeLengthPixel(getOverlayManager()->getStripeLengthPixel());
52                 basegfx::B2DPolygon aLine;
53 
54                 aLine.append(getBasePosition());
55                 aLine.append(getSecondPosition());
56 
57                 const drawinglayer::primitive2d::Primitive2DReference aReference(
58                     new drawinglayer::primitive2d::PolygonMarkerPrimitive2D(
59                         aLine,
60                         aRGBColorA,
61                         aRGBColorB,
62                         fStripeLengthPixel));
63 
64                 aRetval = drawinglayer::primitive2d::Primitive2DSequence(&aReference, 1);
65             }
66 
67             return aRetval;
68 		}
69 
stripeDefinitionHasChanged()70 		void OverlayLineStriped::stripeDefinitionHasChanged()
71 		{
72 			// react on OverlayManager's stripe definition change
73 			objectChange();
74 		}
75 
OverlayLineStriped(const basegfx::B2DPoint & rBasePos,const basegfx::B2DPoint & rSecondPos)76 		OverlayLineStriped::OverlayLineStriped(
77 			const basegfx::B2DPoint& rBasePos,
78 			const basegfx::B2DPoint& rSecondPos)
79 		:	OverlayObjectWithBasePosition(rBasePos, Color(COL_BLACK)),
80 			maSecondPosition(rSecondPos)
81 		{
82 		}
83 
~OverlayLineStriped()84 		OverlayLineStriped::~OverlayLineStriped()
85 		{
86 		}
87 
setSecondPosition(const basegfx::B2DPoint & rNew)88 		void OverlayLineStriped::setSecondPosition(const basegfx::B2DPoint& rNew)
89 		{
90 			if(rNew != maSecondPosition)
91 			{
92 				// remember new value
93 				maSecondPosition = rNew;
94 
95 				// register change (after change)
96 				objectChange();
97 			}
98 		}
99 	} // end of namespace overlay
100 } // end of namespace sdr
101 
102 //////////////////////////////////////////////////////////////////////////////
103 // eof
104