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/overlayrollingrectangle.hxx> 27 #include <tools/gen.hxx> 28 #include <vcl/salbtype.hxx> 29 #include <vcl/outdev.hxx> 30 #include <basegfx/matrix/b2dhommatrix.hxx> 31 #include <svx/sdr/overlay/overlaytools.hxx> 32 #include <svx/sdr/overlay/overlaymanager.hxx> 33 #include <basegfx/polygon/b2dpolygontools.hxx> 34 #include <basegfx/polygon/b2dpolygon.hxx> 35 #include <drawinglayer/primitive2d/polygonprimitive2d.hxx> 36 37 ////////////////////////////////////////////////////////////////////////////// 38 39 namespace sdr 40 { 41 namespace overlay 42 { 43 drawinglayer::primitive2d::Primitive2DSequence OverlayRollingRectangleStriped::createOverlayObjectPrimitive2DSequence() 44 { 45 drawinglayer::primitive2d::Primitive2DSequence aRetval; 46 47 if(getOverlayManager() && (getShowBounds() || getExtendedLines())) 48 { 49 const basegfx::BColor aRGBColorA(getOverlayManager()->getStripeColorA().getBColor()); 50 const basegfx::BColor aRGBColorB(getOverlayManager()->getStripeColorB().getBColor()); 51 const double fStripeLengthPixel(getOverlayManager()->getStripeLengthPixel()); 52 const basegfx::B2DRange aRollingRectangle(getBasePosition(), getSecondPosition()); 53 54 if(getShowBounds()) 55 { 56 // view-independent part, create directly 57 const basegfx::B2DPolygon aPolygon(basegfx::tools::createPolygonFromRect(aRollingRectangle)); 58 const drawinglayer::primitive2d::Primitive2DReference aReference( 59 new drawinglayer::primitive2d::PolygonMarkerPrimitive2D( 60 aPolygon, 61 aRGBColorA, 62 aRGBColorB, 63 fStripeLengthPixel)); 64 65 drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, aReference); 66 } 67 68 if(getExtendedLines()) 69 { 70 // view-dependent part, use helper primitive 71 const drawinglayer::primitive2d::Primitive2DReference aReference( 72 new drawinglayer::primitive2d::OverlayRollingRectanglePrimitive( 73 aRollingRectangle, 74 aRGBColorA, 75 aRGBColorB, 76 fStripeLengthPixel)); 77 78 drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, aReference); 79 } 80 } 81 82 return aRetval; 83 } 84 85 void OverlayRollingRectangleStriped::stripeDefinitionHasChanged() 86 { 87 // react on OverlayManager's stripe definition change 88 objectChange(); 89 } 90 91 OverlayRollingRectangleStriped::OverlayRollingRectangleStriped( 92 const basegfx::B2DPoint& rBasePos, 93 const basegfx::B2DPoint& rSecondPos, 94 bool bExtendedLines, 95 bool bShowBounds) 96 : OverlayObjectWithBasePosition(rBasePos, Color(COL_BLACK)), 97 maSecondPosition(rSecondPos), 98 mbExtendedLines(bExtendedLines), 99 mbShowBounds(bShowBounds) 100 { 101 } 102 103 OverlayRollingRectangleStriped::~OverlayRollingRectangleStriped() 104 { 105 } 106 107 void OverlayRollingRectangleStriped::setSecondPosition(const basegfx::B2DPoint& rNew) 108 { 109 if(rNew != maSecondPosition) 110 { 111 // remember new value 112 maSecondPosition = rNew; 113 114 // register change (after change) 115 objectChange(); 116 } 117 } 118 119 void OverlayRollingRectangleStriped::setExtendedLines(bool bNew) 120 { 121 if(bNew != (bool)mbExtendedLines) 122 { 123 // remember new value 124 mbExtendedLines = bNew; 125 126 // register change (after change) 127 objectChange(); 128 } 129 } 130 131 void OverlayRollingRectangleStriped::setShowBounds(bool bNew) 132 { 133 if(bNew != (bool)mbShowBounds) 134 { 135 // remember new value 136 mbShowBounds = bNew; 137 138 // register change (after change) 139 objectChange(); 140 } 141 } 142 } // end of namespace overlay 143 } // end of namespace sdr 144 145 ////////////////////////////////////////////////////////////////////////////// 146 // eof 147