Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <svx/sdr/overlay/overlayrollingrectangle.hxx>
21 : #include <tools/gen.hxx>
22 : #include <vcl/outdev.hxx>
23 : #include <basegfx/matrix/b2dhommatrix.hxx>
24 : #include <svx/sdr/overlay/overlaytools.hxx>
25 : #include <svx/sdr/overlay/overlaymanager.hxx>
26 : #include <basegfx/polygon/b2dpolygontools.hxx>
27 : #include <basegfx/polygon/b2dpolygon.hxx>
28 : #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
29 :
30 : //////////////////////////////////////////////////////////////////////////////
31 :
32 : namespace sdr
33 : {
34 : namespace overlay
35 : {
36 0 : drawinglayer::primitive2d::Primitive2DSequence OverlayRollingRectangleStriped::createOverlayObjectPrimitive2DSequence()
37 : {
38 0 : drawinglayer::primitive2d::Primitive2DSequence aRetval;
39 :
40 0 : if(getOverlayManager() && (getShowBounds() || getExtendedLines()))
41 : {
42 0 : const basegfx::BColor aRGBColorA(getOverlayManager()->getStripeColorA().getBColor());
43 0 : const basegfx::BColor aRGBColorB(getOverlayManager()->getStripeColorB().getBColor());
44 0 : const double fStripeLengthPixel(getOverlayManager()->getStripeLengthPixel());
45 0 : const basegfx::B2DRange aRollingRectangle(getBasePosition(), getSecondPosition());
46 :
47 0 : if(getShowBounds())
48 : {
49 : // view-independent part, create directly
50 0 : const basegfx::B2DPolygon aPolygon(basegfx::tools::createPolygonFromRect(aRollingRectangle));
51 : const drawinglayer::primitive2d::Primitive2DReference aReference(
52 : new drawinglayer::primitive2d::PolygonMarkerPrimitive2D(
53 : aPolygon,
54 : aRGBColorA,
55 : aRGBColorB,
56 0 : fStripeLengthPixel));
57 :
58 0 : drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, aReference);
59 : }
60 :
61 0 : if(getExtendedLines())
62 : {
63 : // view-dependent part, use helper primitive
64 : const drawinglayer::primitive2d::Primitive2DReference aReference(
65 : new drawinglayer::primitive2d::OverlayRollingRectanglePrimitive(
66 : aRollingRectangle,
67 : aRGBColorA,
68 : aRGBColorB,
69 0 : fStripeLengthPixel));
70 :
71 0 : drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, aReference);
72 0 : }
73 : }
74 :
75 0 : return aRetval;
76 : }
77 :
78 0 : void OverlayRollingRectangleStriped::stripeDefinitionHasChanged()
79 : {
80 : // react on OverlayManager's stripe definition change
81 0 : objectChange();
82 0 : }
83 :
84 0 : OverlayRollingRectangleStriped::OverlayRollingRectangleStriped(
85 : const basegfx::B2DPoint& rBasePos,
86 : const basegfx::B2DPoint& rSecondPos,
87 : bool bExtendedLines,
88 : bool bShowBounds)
89 : : OverlayObjectWithBasePosition(rBasePos, Color(COL_BLACK)),
90 : maSecondPosition(rSecondPos),
91 : mbExtendedLines(bExtendedLines),
92 0 : mbShowBounds(bShowBounds)
93 : {
94 0 : }
95 :
96 0 : OverlayRollingRectangleStriped::~OverlayRollingRectangleStriped()
97 : {
98 0 : }
99 :
100 0 : void OverlayRollingRectangleStriped::setSecondPosition(const basegfx::B2DPoint& rNew)
101 : {
102 0 : if(rNew != maSecondPosition)
103 : {
104 : // remember new value
105 0 : maSecondPosition = rNew;
106 :
107 : // register change (after change)
108 0 : objectChange();
109 : }
110 0 : }
111 : } // end of namespace overlay
112 : } // end of namespace sdr
113 :
114 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|