1f6e50924SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3f6e50924SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4f6e50924SAndrew Rist * or more contributor license agreements. See the NOTICE file 5f6e50924SAndrew Rist * distributed with this work for additional information 6f6e50924SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7f6e50924SAndrew Rist * to you under the Apache License, Version 2.0 (the 8f6e50924SAndrew Rist * "License"); you may not use this file except in compliance 9f6e50924SAndrew Rist * with the License. You may obtain a copy of the License at 10f6e50924SAndrew Rist * 11f6e50924SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12f6e50924SAndrew Rist * 13f6e50924SAndrew Rist * Unless required by applicable law or agreed to in writing, 14f6e50924SAndrew Rist * software distributed under the License is distributed on an 15f6e50924SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16f6e50924SAndrew Rist * KIND, either express or implied. See the License for the 17f6e50924SAndrew Rist * specific language governing permissions and limitations 18f6e50924SAndrew Rist * under the License. 19f6e50924SAndrew Rist * 20f6e50924SAndrew Rist *************************************************************/ 21f6e50924SAndrew Rist 22f6e50924SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_svx.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <svx/sdr/overlay/overlaytools.hxx> 28cdf0e10cSrcweir #include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx> 29cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx> 30cdf0e10cSrcweir #include <drawinglayer/primitive2d/bitmapprimitive2d.hxx> 31cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygon.hxx> 32cdf0e10cSrcweir #include <drawinglayer/primitive2d/polygonprimitive2d.hxx> 33cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygontools.hxx> 34cdf0e10cSrcweir #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx> 35cdf0e10cSrcweir #include <drawinglayer/geometry/viewinformation2d.hxx> 36cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrixtools.hxx> 37*1cd65da9SArmin Le Grand #include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx> 38*1cd65da9SArmin Le Grand #include <vcl/svapp.hxx> 39cdf0e10cSrcweir 40cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 41cdf0e10cSrcweir 42cdf0e10cSrcweir namespace drawinglayer 43cdf0e10cSrcweir { 44cdf0e10cSrcweir namespace primitive2d 45cdf0e10cSrcweir { 46cdf0e10cSrcweir OverlayBitmapExPrimitive::OverlayBitmapExPrimitive( 47cdf0e10cSrcweir const BitmapEx& rBitmapEx, 48cdf0e10cSrcweir const basegfx::B2DPoint& rBasePosition, 49cdf0e10cSrcweir sal_uInt16 nCenterX, 50cdf0e10cSrcweir sal_uInt16 nCenterY) 51cdf0e10cSrcweir : DiscreteMetricDependentPrimitive2D(), 52cdf0e10cSrcweir maBitmapEx(rBitmapEx), 53cdf0e10cSrcweir maBasePosition(rBasePosition), 54cdf0e10cSrcweir mnCenterX(nCenterX), 55cdf0e10cSrcweir mnCenterY(nCenterY) 56cdf0e10cSrcweir {} 57cdf0e10cSrcweir 58cdf0e10cSrcweir Primitive2DSequence OverlayBitmapExPrimitive::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const 59cdf0e10cSrcweir { 60cdf0e10cSrcweir Primitive2DSequence aRetval; 61cdf0e10cSrcweir const Size aBitmapSize(getBitmapEx().GetSizePixel()); 62cdf0e10cSrcweir 63cdf0e10cSrcweir if(aBitmapSize.Width() && aBitmapSize.Height() && basegfx::fTools::more(getDiscreteUnit(), 0.0)) 64cdf0e10cSrcweir { 65cdf0e10cSrcweir // calculate back from internal bitmap's extreme coordinates (the edges) 66cdf0e10cSrcweir // to logical coordinates. Only use a unified scaling value (getDiscreteUnit(), 67cdf0e10cSrcweir // the prepared one which expresses how many logic units form a discrete unit) 68cdf0e10cSrcweir // for this step. This primitive is to be displayed always unscaled (in it's pixel size) 69cdf0e10cSrcweir // and unrotated, more like a marker 70cdf0e10cSrcweir const double fLeft(((0.0 - getCenterX()) * getDiscreteUnit()) + getBasePosition().getX()); 71cdf0e10cSrcweir const double fTop(((0.0 - getCenterY()) * getDiscreteUnit()) + getBasePosition().getY()); 726de8cae6SArmin Le Grand const double fRight(((aBitmapSize.getWidth() - getCenterX()) * getDiscreteUnit()) + getBasePosition().getX()); 736de8cae6SArmin Le Grand const double fBottom(((aBitmapSize.getHeight() - getCenterY()) * getDiscreteUnit()) + getBasePosition().getY()); 74cdf0e10cSrcweir 75cdf0e10cSrcweir // create a BitmapPrimitive2D using those positions 76cdf0e10cSrcweir basegfx::B2DHomMatrix aTransform; 77cdf0e10cSrcweir 78cdf0e10cSrcweir aTransform.set(0, 0, fRight - fLeft); 79cdf0e10cSrcweir aTransform.set(1, 1, fBottom - fTop); 80cdf0e10cSrcweir aTransform.set(0, 2, fLeft); 81cdf0e10cSrcweir aTransform.set(1, 2, fTop); 82cdf0e10cSrcweir 83cdf0e10cSrcweir const Primitive2DReference aPrimitive(new BitmapPrimitive2D(getBitmapEx(), aTransform)); 84cdf0e10cSrcweir aRetval = Primitive2DSequence(&aPrimitive, 1); 85cdf0e10cSrcweir } 86cdf0e10cSrcweir 87cdf0e10cSrcweir return aRetval; 88cdf0e10cSrcweir } 89cdf0e10cSrcweir 90cdf0e10cSrcweir bool OverlayBitmapExPrimitive::operator==( const BasePrimitive2D& rPrimitive ) const 91cdf0e10cSrcweir { 92cdf0e10cSrcweir if(DiscreteMetricDependentPrimitive2D::operator==(rPrimitive)) 93cdf0e10cSrcweir { 94cdf0e10cSrcweir const OverlayBitmapExPrimitive& rCompare = static_cast< const OverlayBitmapExPrimitive& >(rPrimitive); 95cdf0e10cSrcweir 96cdf0e10cSrcweir return (getBitmapEx() == rCompare.getBitmapEx() 97cdf0e10cSrcweir && getBasePosition() == rCompare.getBasePosition() 98cdf0e10cSrcweir && getCenterX() == rCompare.getCenterX() 99cdf0e10cSrcweir && getCenterY() == rCompare.getCenterY()); 100cdf0e10cSrcweir } 101cdf0e10cSrcweir 102cdf0e10cSrcweir return false; 103cdf0e10cSrcweir } 104cdf0e10cSrcweir 105cdf0e10cSrcweir ImplPrimitrive2DIDBlock(OverlayBitmapExPrimitive, PRIMITIVE2D_ID_OVERLAYBITMAPEXPRIMITIVE) 106cdf0e10cSrcweir 107cdf0e10cSrcweir } // end of namespace primitive2d 108cdf0e10cSrcweir } // end of namespace drawinglayer 109cdf0e10cSrcweir 110cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 111cdf0e10cSrcweir 112cdf0e10cSrcweir namespace drawinglayer 113cdf0e10cSrcweir { 114cdf0e10cSrcweir namespace primitive2d 115cdf0e10cSrcweir { 116cdf0e10cSrcweir OverlayCrosshairPrimitive::OverlayCrosshairPrimitive( 117cdf0e10cSrcweir const basegfx::B2DPoint& rBasePosition, 118cdf0e10cSrcweir const basegfx::BColor& rRGBColorA, 119cdf0e10cSrcweir const basegfx::BColor& rRGBColorB, 120cdf0e10cSrcweir double fDiscreteDashLength) 121cdf0e10cSrcweir : ViewportDependentPrimitive2D(), 122cdf0e10cSrcweir maBasePosition(rBasePosition), 123cdf0e10cSrcweir maRGBColorA(rRGBColorA), 124cdf0e10cSrcweir maRGBColorB(rRGBColorB), 125cdf0e10cSrcweir mfDiscreteDashLength(fDiscreteDashLength) 126cdf0e10cSrcweir {} 127cdf0e10cSrcweir 128cdf0e10cSrcweir Primitive2DSequence OverlayCrosshairPrimitive::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const 129cdf0e10cSrcweir { 130cdf0e10cSrcweir // use the prepared Viewport information accessible using getViewport() 131cdf0e10cSrcweir Primitive2DSequence aRetval; 132cdf0e10cSrcweir 133cdf0e10cSrcweir if(!getViewport().isEmpty()) 134cdf0e10cSrcweir { 135cdf0e10cSrcweir aRetval.realloc(2); 136cdf0e10cSrcweir basegfx::B2DPolygon aPolygon; 137cdf0e10cSrcweir 138cdf0e10cSrcweir aPolygon.append(basegfx::B2DPoint(getViewport().getMinX(), getBasePosition().getY())); 139cdf0e10cSrcweir aPolygon.append(basegfx::B2DPoint(getViewport().getMaxX(), getBasePosition().getY())); 140cdf0e10cSrcweir 141cdf0e10cSrcweir aRetval[0] = Primitive2DReference( 142cdf0e10cSrcweir new PolygonMarkerPrimitive2D( 143cdf0e10cSrcweir aPolygon, 144cdf0e10cSrcweir getRGBColorA(), 145cdf0e10cSrcweir getRGBColorB(), 146cdf0e10cSrcweir getDiscreteDashLength())); 147cdf0e10cSrcweir 148cdf0e10cSrcweir aPolygon.clear(); 149cdf0e10cSrcweir aPolygon.append(basegfx::B2DPoint(getBasePosition().getX(), getViewport().getMinY())); 150cdf0e10cSrcweir aPolygon.append(basegfx::B2DPoint(getBasePosition().getX(), getViewport().getMaxY())); 151cdf0e10cSrcweir 152cdf0e10cSrcweir aRetval[1] = Primitive2DReference( 153cdf0e10cSrcweir new PolygonMarkerPrimitive2D( 154cdf0e10cSrcweir aPolygon, 155cdf0e10cSrcweir getRGBColorA(), 156cdf0e10cSrcweir getRGBColorB(), 157cdf0e10cSrcweir getDiscreteDashLength())); 158cdf0e10cSrcweir } 159cdf0e10cSrcweir 160cdf0e10cSrcweir return aRetval; 161cdf0e10cSrcweir } 162cdf0e10cSrcweir 163cdf0e10cSrcweir bool OverlayCrosshairPrimitive::operator==( const BasePrimitive2D& rPrimitive ) const 164cdf0e10cSrcweir { 165cdf0e10cSrcweir if(ViewportDependentPrimitive2D::operator==(rPrimitive)) 166cdf0e10cSrcweir { 167cdf0e10cSrcweir const OverlayCrosshairPrimitive& rCompare = static_cast< const OverlayCrosshairPrimitive& >(rPrimitive); 168cdf0e10cSrcweir 169cdf0e10cSrcweir return (getBasePosition() == rCompare.getBasePosition() 170cdf0e10cSrcweir && getRGBColorA() == rCompare.getRGBColorA() 171cdf0e10cSrcweir && getRGBColorB() == rCompare.getRGBColorB() 172cdf0e10cSrcweir && getDiscreteDashLength() == rCompare.getDiscreteDashLength()); 173cdf0e10cSrcweir } 174cdf0e10cSrcweir 175cdf0e10cSrcweir return false; 176cdf0e10cSrcweir } 177cdf0e10cSrcweir 178cdf0e10cSrcweir ImplPrimitrive2DIDBlock(OverlayCrosshairPrimitive, PRIMITIVE2D_ID_OVERLAYCROSSHAIRPRIMITIVE) 179cdf0e10cSrcweir 180cdf0e10cSrcweir } // end of namespace primitive2d 181cdf0e10cSrcweir } // end of namespace drawinglayer 182cdf0e10cSrcweir 183cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 184cdf0e10cSrcweir 185cdf0e10cSrcweir namespace drawinglayer 186cdf0e10cSrcweir { 187cdf0e10cSrcweir namespace primitive2d 188cdf0e10cSrcweir { 189*1cd65da9SArmin Le Grand OverlayRectanglePrimitive::OverlayRectanglePrimitive( 190cdf0e10cSrcweir const basegfx::B2DRange& rObjectRange, 191*1cd65da9SArmin Le Grand const basegfx::BColor& rColor, 192*1cd65da9SArmin Le Grand double fTransparence, 193cdf0e10cSrcweir double fDiscreteGrow, 194cdf0e10cSrcweir double fDiscreteShrink, 195cdf0e10cSrcweir double fRotation) 196cdf0e10cSrcweir : DiscreteMetricDependentPrimitive2D(), 197cdf0e10cSrcweir maObjectRange(rObjectRange), 198*1cd65da9SArmin Le Grand maColor(rColor), 199*1cd65da9SArmin Le Grand mfTransparence(fTransparence), 200cdf0e10cSrcweir mfDiscreteGrow(fDiscreteGrow), 201cdf0e10cSrcweir mfDiscreteShrink(fDiscreteShrink), 202cdf0e10cSrcweir mfRotation(fRotation) 203cdf0e10cSrcweir {} 204cdf0e10cSrcweir 205*1cd65da9SArmin Le Grand Primitive2DSequence OverlayRectanglePrimitive::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const 206cdf0e10cSrcweir { 207cdf0e10cSrcweir Primitive2DSequence aRetval; 208*1cd65da9SArmin Le Grand basegfx::B2DRange aInnerRange(getObjectRange()); 209cdf0e10cSrcweir 210*1cd65da9SArmin Le Grand if(!aInnerRange.isEmpty() && basegfx::fTools::more(getDiscreteUnit(), 0.0) && getTransparence() <= 1.0) 211*1cd65da9SArmin Le Grand { 212*1cd65da9SArmin Le Grand basegfx::B2DRange aInnerRange(getObjectRange()); 213*1cd65da9SArmin Le Grand basegfx::B2DRange aOuterRange(getObjectRange()); 214*1cd65da9SArmin Le Grand 215*1cd65da9SArmin Le Grand // grow/shrink inner/outer polygons 216*1cd65da9SArmin Le Grand aOuterRange.grow(getDiscreteUnit() * getDiscreteGrow()); 217*1cd65da9SArmin Le Grand aInnerRange.grow(getDiscreteUnit() * -getDiscreteShrink()); 218*1cd65da9SArmin Le Grand 219*1cd65da9SArmin Le Grand // convert to polygons 220*1cd65da9SArmin Le Grand const double fFullGrow(getDiscreteGrow() + getDiscreteShrink()); 221*1cd65da9SArmin Le Grand const double fRelativeRadiusX(fFullGrow / aOuterRange.getWidth()); 222*1cd65da9SArmin Le Grand const double fRelativeRadiusY(fFullGrow / aOuterRange.getHeight()); 223*1cd65da9SArmin Le Grand basegfx::B2DPolygon aOuterPolygon( 224*1cd65da9SArmin Le Grand basegfx::tools::createPolygonFromRect( 225*1cd65da9SArmin Le Grand aOuterRange, 226*1cd65da9SArmin Le Grand fRelativeRadiusX, 227*1cd65da9SArmin Le Grand fRelativeRadiusY)); 228*1cd65da9SArmin Le Grand basegfx::B2DPolygon aInnerPolygon( 229*1cd65da9SArmin Le Grand basegfx::tools::createPolygonFromRect( 230*1cd65da9SArmin Le Grand aInnerRange)); 231*1cd65da9SArmin Le Grand 232*1cd65da9SArmin Le Grand // apply evtl. existing rotation 233*1cd65da9SArmin Le Grand if(!basegfx::fTools::equalZero(getRotation())) 234*1cd65da9SArmin Le Grand { 235cdf0e10cSrcweir const basegfx::B2DHomMatrix aTransform(basegfx::tools::createRotateAroundPoint( 236cdf0e10cSrcweir getObjectRange().getMinX(), getObjectRange().getMinY(), getRotation())); 237cdf0e10cSrcweir 238*1cd65da9SArmin Le Grand aOuterPolygon.transform(aTransform); 239*1cd65da9SArmin Le Grand aInnerPolygon.transform(aTransform); 240*1cd65da9SArmin Le Grand } 241*1cd65da9SArmin Le Grand 242*1cd65da9SArmin Le Grand // create filled primitive 243*1cd65da9SArmin Le Grand basegfx::B2DPolyPolygon aPolyPolygon; 244*1cd65da9SArmin Le Grand 245*1cd65da9SArmin Le Grand aPolyPolygon.append(aOuterPolygon); 246*1cd65da9SArmin Le Grand aPolyPolygon.append(aInnerPolygon); 247*1cd65da9SArmin Le Grand 248*1cd65da9SArmin Le Grand if(Application::GetSettings().GetStyleSettings().GetHighContrastMode()) 249*1cd65da9SArmin Le Grand { 250*1cd65da9SArmin Le Grand // for high contrast, use hatch 251*1cd65da9SArmin Le Grand const basegfx::BColor aHighContrastLineColor(Application::GetSettings().GetStyleSettings().GetFontColor().getBColor()); 252*1cd65da9SArmin Le Grand const basegfx::BColor aEmptyColor(0.0, 0.0, 0.0); 253*1cd65da9SArmin Le Grand const double fHatchRotation(45 * F_PI180); 254*1cd65da9SArmin Le Grand const double fDiscreteHatchDistance(3.0); 255*1cd65da9SArmin Le Grand const drawinglayer::attribute::FillHatchAttribute aFillHatchAttribute( 256*1cd65da9SArmin Le Grand drawinglayer::attribute::HATCHSTYLE_SINGLE, 257*1cd65da9SArmin Le Grand fDiscreteHatchDistance * getDiscreteUnit(), 258*1cd65da9SArmin Le Grand fHatchRotation - getRotation(), 259*1cd65da9SArmin Le Grand aHighContrastLineColor, 260*1cd65da9SArmin Le Grand 3, // same default as VCL, a minimum of three discrete units (pixels) offset 261*1cd65da9SArmin Le Grand false); 262*1cd65da9SArmin Le Grand const Primitive2DReference aHatch( 263*1cd65da9SArmin Le Grand new PolyPolygonHatchPrimitive2D( 264*1cd65da9SArmin Le Grand aPolyPolygon, 265*1cd65da9SArmin Le Grand aEmptyColor, 266*1cd65da9SArmin Le Grand aFillHatchAttribute)); 267*1cd65da9SArmin Le Grand 268*1cd65da9SArmin Le Grand aRetval = Primitive2DSequence(&aHatch, 1); 269*1cd65da9SArmin Le Grand } 270*1cd65da9SArmin Le Grand else 271*1cd65da9SArmin Le Grand { 272*1cd65da9SArmin Le Grand // create fill primitive 273*1cd65da9SArmin Le Grand const Primitive2DReference aFill( 274*1cd65da9SArmin Le Grand new PolyPolygonColorPrimitive2D( 275*1cd65da9SArmin Le Grand aPolyPolygon, 276*1cd65da9SArmin Le Grand getColor())); 277*1cd65da9SArmin Le Grand 278*1cd65da9SArmin Le Grand aRetval = Primitive2DSequence(&aFill, 1); 279*1cd65da9SArmin Le Grand 280*1cd65da9SArmin Le Grand // embed filled to transparency (if used) 281*1cd65da9SArmin Le Grand if(getTransparence() > 0.0) 282*1cd65da9SArmin Le Grand { 283*1cd65da9SArmin Le Grand const Primitive2DReference aFillTransparent( 284*1cd65da9SArmin Le Grand new UnifiedTransparencePrimitive2D( 285*1cd65da9SArmin Le Grand aRetval, 286*1cd65da9SArmin Le Grand getTransparence())); 287*1cd65da9SArmin Le Grand 288*1cd65da9SArmin Le Grand aRetval = Primitive2DSequence(&aFillTransparent, 1); 289*1cd65da9SArmin Le Grand } 290*1cd65da9SArmin Le Grand } 291cdf0e10cSrcweir } 292cdf0e10cSrcweir 293cdf0e10cSrcweir return aRetval; 294*1cd65da9SArmin Le Grand } 295cdf0e10cSrcweir 296*1cd65da9SArmin Le Grand bool OverlayRectanglePrimitive::operator==( const BasePrimitive2D& rPrimitive ) const 297cdf0e10cSrcweir { 298cdf0e10cSrcweir if(DiscreteMetricDependentPrimitive2D::operator==(rPrimitive)) 299cdf0e10cSrcweir { 300*1cd65da9SArmin Le Grand const OverlayRectanglePrimitive& rCompare = static_cast< const OverlayRectanglePrimitive& >(rPrimitive); 301cdf0e10cSrcweir 302cdf0e10cSrcweir return (getObjectRange() == rCompare.getObjectRange() 303*1cd65da9SArmin Le Grand && getColor() == rCompare.getColor() 304*1cd65da9SArmin Le Grand && getTransparence() == rCompare.getTransparence() 305cdf0e10cSrcweir && getDiscreteGrow() == rCompare.getDiscreteGrow() 306cdf0e10cSrcweir && getDiscreteShrink() == rCompare.getDiscreteShrink() 307cdf0e10cSrcweir && getRotation() == rCompare.getRotation()); 308cdf0e10cSrcweir } 309cdf0e10cSrcweir 310cdf0e10cSrcweir return false; 311cdf0e10cSrcweir } 312cdf0e10cSrcweir 313*1cd65da9SArmin Le Grand ImplPrimitrive2DIDBlock(OverlayRectanglePrimitive, PRIMITIVE2D_ID_OVERLAYRECTANGLEPRIMITIVE) 314cdf0e10cSrcweir 315cdf0e10cSrcweir } // end of namespace primitive2d 316cdf0e10cSrcweir } // end of namespace drawinglayer 317cdf0e10cSrcweir 318cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 319cdf0e10cSrcweir 320cdf0e10cSrcweir namespace drawinglayer 321cdf0e10cSrcweir { 322cdf0e10cSrcweir namespace primitive2d 323cdf0e10cSrcweir { 324cdf0e10cSrcweir OverlayHelplineStripedPrimitive::OverlayHelplineStripedPrimitive( 325cdf0e10cSrcweir const basegfx::B2DPoint& rBasePosition, 326cdf0e10cSrcweir HelplineStyle eStyle, 327cdf0e10cSrcweir const basegfx::BColor& rRGBColorA, 328cdf0e10cSrcweir const basegfx::BColor& rRGBColorB, 329cdf0e10cSrcweir double fDiscreteDashLength) 330cdf0e10cSrcweir : ViewportDependentPrimitive2D(), 331cdf0e10cSrcweir maBasePosition(rBasePosition), 332cdf0e10cSrcweir meStyle(eStyle), 333cdf0e10cSrcweir maRGBColorA(rRGBColorA), 334cdf0e10cSrcweir maRGBColorB(rRGBColorB), 335cdf0e10cSrcweir mfDiscreteDashLength(fDiscreteDashLength) 336cdf0e10cSrcweir {} 337cdf0e10cSrcweir 338cdf0e10cSrcweir Primitive2DSequence OverlayHelplineStripedPrimitive::create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const 339cdf0e10cSrcweir { 340cdf0e10cSrcweir // use the prepared Viewport information accessible using getViewport() 341cdf0e10cSrcweir Primitive2DSequence aRetval; 342cdf0e10cSrcweir 343cdf0e10cSrcweir if(!getViewport().isEmpty()) 344cdf0e10cSrcweir { 345cdf0e10cSrcweir switch(getStyle()) 346cdf0e10cSrcweir { 347cdf0e10cSrcweir case HELPLINESTYLE_VERTICAL : 348cdf0e10cSrcweir { 349cdf0e10cSrcweir aRetval.realloc(1); 350cdf0e10cSrcweir basegfx::B2DPolygon aLine; 351cdf0e10cSrcweir 352cdf0e10cSrcweir aLine.append(basegfx::B2DPoint(getBasePosition().getX(), getViewport().getMinY())); 353cdf0e10cSrcweir aLine.append(basegfx::B2DPoint(getBasePosition().getX(), getViewport().getMaxY())); 354cdf0e10cSrcweir 355cdf0e10cSrcweir aRetval[0] = Primitive2DReference( 356cdf0e10cSrcweir new PolygonMarkerPrimitive2D( 357cdf0e10cSrcweir aLine, 358cdf0e10cSrcweir getRGBColorA(), 359cdf0e10cSrcweir getRGBColorB(), 360cdf0e10cSrcweir getDiscreteDashLength())); 361cdf0e10cSrcweir break; 362cdf0e10cSrcweir } 363cdf0e10cSrcweir 364cdf0e10cSrcweir case HELPLINESTYLE_HORIZONTAL : 365cdf0e10cSrcweir { 366cdf0e10cSrcweir aRetval.realloc(1); 367cdf0e10cSrcweir basegfx::B2DPolygon aLine; 368cdf0e10cSrcweir 369cdf0e10cSrcweir aLine.append(basegfx::B2DPoint(getViewport().getMinX(), getBasePosition().getY())); 370cdf0e10cSrcweir aLine.append(basegfx::B2DPoint(getViewport().getMaxX(), getBasePosition().getY())); 371cdf0e10cSrcweir 372cdf0e10cSrcweir aRetval[0] = Primitive2DReference( 373cdf0e10cSrcweir new PolygonMarkerPrimitive2D( 374cdf0e10cSrcweir aLine, 375cdf0e10cSrcweir getRGBColorA(), 376cdf0e10cSrcweir getRGBColorB(), 377cdf0e10cSrcweir getDiscreteDashLength())); 378cdf0e10cSrcweir break; 379cdf0e10cSrcweir } 380cdf0e10cSrcweir 381cdf0e10cSrcweir default: // case HELPLINESTYLE_POINT : 382cdf0e10cSrcweir { 383cdf0e10cSrcweir const double fDiscreteUnit((rViewInformation.getInverseObjectToViewTransformation() * basegfx::B2DVector(1.0, 0.0)).getLength()); 384cdf0e10cSrcweir aRetval.realloc(2); 385cdf0e10cSrcweir basegfx::B2DPolygon aLineA, aLineB; 386cdf0e10cSrcweir 387cdf0e10cSrcweir aLineA.append(basegfx::B2DPoint(getBasePosition().getX(), getBasePosition().getY() - fDiscreteUnit)); 388cdf0e10cSrcweir aLineA.append(basegfx::B2DPoint(getBasePosition().getX(), getBasePosition().getY() + fDiscreteUnit)); 389cdf0e10cSrcweir 390cdf0e10cSrcweir aRetval[0] = Primitive2DReference( 391cdf0e10cSrcweir new PolygonMarkerPrimitive2D( 392cdf0e10cSrcweir aLineA, 393cdf0e10cSrcweir getRGBColorA(), 394cdf0e10cSrcweir getRGBColorB(), 395cdf0e10cSrcweir getDiscreteDashLength())); 396cdf0e10cSrcweir 397cdf0e10cSrcweir aLineB.append(basegfx::B2DPoint(getBasePosition().getX() - fDiscreteUnit, getBasePosition().getY())); 398cdf0e10cSrcweir aLineB.append(basegfx::B2DPoint(getBasePosition().getX() + fDiscreteUnit, getBasePosition().getY())); 399cdf0e10cSrcweir 400cdf0e10cSrcweir aRetval[1] = Primitive2DReference( 401cdf0e10cSrcweir new PolygonMarkerPrimitive2D( 402cdf0e10cSrcweir aLineB, 403cdf0e10cSrcweir getRGBColorA(), 404cdf0e10cSrcweir getRGBColorB(), 405cdf0e10cSrcweir getDiscreteDashLength())); 406cdf0e10cSrcweir 407cdf0e10cSrcweir break; 408cdf0e10cSrcweir } 409cdf0e10cSrcweir } 410cdf0e10cSrcweir } 411cdf0e10cSrcweir 412cdf0e10cSrcweir return aRetval; 413cdf0e10cSrcweir } 414cdf0e10cSrcweir 415cdf0e10cSrcweir bool OverlayHelplineStripedPrimitive::operator==( const BasePrimitive2D& rPrimitive ) const 416cdf0e10cSrcweir { 417cdf0e10cSrcweir if(ViewportDependentPrimitive2D::operator==(rPrimitive)) 418cdf0e10cSrcweir { 419cdf0e10cSrcweir const OverlayHelplineStripedPrimitive& rCompare = static_cast< const OverlayHelplineStripedPrimitive& >(rPrimitive); 420cdf0e10cSrcweir 421cdf0e10cSrcweir return (getBasePosition() == rCompare.getBasePosition() 422cdf0e10cSrcweir && getStyle() == rCompare.getStyle() 423cdf0e10cSrcweir && getRGBColorA() == rCompare.getRGBColorA() 424cdf0e10cSrcweir && getRGBColorB() == rCompare.getRGBColorB() 425cdf0e10cSrcweir && getDiscreteDashLength() == rCompare.getDiscreteDashLength()); 426cdf0e10cSrcweir } 427cdf0e10cSrcweir 428cdf0e10cSrcweir return false; 429cdf0e10cSrcweir } 430cdf0e10cSrcweir 431cdf0e10cSrcweir ImplPrimitrive2DIDBlock(OverlayHelplineStripedPrimitive, PRIMITIVE2D_ID_OVERLAYHELPLINESTRIPEDPRIMITIVE) 432cdf0e10cSrcweir 433cdf0e10cSrcweir } // end of namespace primitive2d 434cdf0e10cSrcweir } // end of namespace drawinglayer 435cdf0e10cSrcweir 436cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 437cdf0e10cSrcweir 438cdf0e10cSrcweir namespace drawinglayer 439cdf0e10cSrcweir { 440cdf0e10cSrcweir namespace primitive2d 441cdf0e10cSrcweir { 442cdf0e10cSrcweir OverlayRollingRectanglePrimitive::OverlayRollingRectanglePrimitive( 443cdf0e10cSrcweir const basegfx::B2DRange& aRollingRectangle, 444cdf0e10cSrcweir const basegfx::BColor& rRGBColorA, 445cdf0e10cSrcweir const basegfx::BColor& rRGBColorB, 446cdf0e10cSrcweir double fDiscreteDashLength) 447cdf0e10cSrcweir : ViewportDependentPrimitive2D(), 448cdf0e10cSrcweir maRollingRectangle(aRollingRectangle), 449cdf0e10cSrcweir maRGBColorA(rRGBColorA), 450cdf0e10cSrcweir maRGBColorB(rRGBColorB), 451cdf0e10cSrcweir mfDiscreteDashLength(fDiscreteDashLength) 452cdf0e10cSrcweir {} 453cdf0e10cSrcweir 454cdf0e10cSrcweir Primitive2DSequence OverlayRollingRectanglePrimitive::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const 455cdf0e10cSrcweir { 456cdf0e10cSrcweir // use the prepared Viewport information accessible using getViewport() 457cdf0e10cSrcweir Primitive2DSequence aRetval; 458cdf0e10cSrcweir 459cdf0e10cSrcweir if(!getViewport().isEmpty()) 460cdf0e10cSrcweir { 461cdf0e10cSrcweir basegfx::B2DPolygon aLine; 462cdf0e10cSrcweir aRetval.realloc(8); 463cdf0e10cSrcweir 464cdf0e10cSrcweir // Left lines 465cdf0e10cSrcweir aLine.append(basegfx::B2DPoint(getViewport().getMinX(), getRollingRectangle().getMinY())); 466cdf0e10cSrcweir aLine.append(basegfx::B2DPoint(getRollingRectangle().getMinX(), getRollingRectangle().getMinY())); 467cdf0e10cSrcweir aRetval[0] = Primitive2DReference(new PolygonMarkerPrimitive2D(aLine, getRGBColorA(), getRGBColorB(), getDiscreteDashLength())); 468cdf0e10cSrcweir 469cdf0e10cSrcweir aLine.clear(); 470cdf0e10cSrcweir aLine.append(basegfx::B2DPoint(getViewport().getMinX(), getRollingRectangle().getMaxY())); 471cdf0e10cSrcweir aLine.append(basegfx::B2DPoint(getRollingRectangle().getMinX(), getRollingRectangle().getMaxY())); 472cdf0e10cSrcweir aRetval[1] = Primitive2DReference(new PolygonMarkerPrimitive2D(aLine, getRGBColorA(), getRGBColorB(), getDiscreteDashLength())); 473cdf0e10cSrcweir 474cdf0e10cSrcweir // Right lines 475cdf0e10cSrcweir aLine.clear(); 476cdf0e10cSrcweir aLine.append(basegfx::B2DPoint(getRollingRectangle().getMaxX(), getRollingRectangle().getMinY())); 477cdf0e10cSrcweir aLine.append(basegfx::B2DPoint(getViewport().getMaxX(), getRollingRectangle().getMinY())); 478cdf0e10cSrcweir aRetval[2] = Primitive2DReference(new PolygonMarkerPrimitive2D(aLine, getRGBColorA(), getRGBColorB(), getDiscreteDashLength())); 479cdf0e10cSrcweir 480cdf0e10cSrcweir aLine.clear(); 481cdf0e10cSrcweir aLine.append(basegfx::B2DPoint(getRollingRectangle().getMaxX(), getRollingRectangle().getMaxY())); 482cdf0e10cSrcweir aLine.append(basegfx::B2DPoint(getViewport().getMaxX(), getRollingRectangle().getMaxY())); 483cdf0e10cSrcweir aRetval[3] = Primitive2DReference(new PolygonMarkerPrimitive2D(aLine, getRGBColorA(), getRGBColorB(), getDiscreteDashLength())); 484cdf0e10cSrcweir 485cdf0e10cSrcweir // Top lines 486cdf0e10cSrcweir aLine.clear(); 487cdf0e10cSrcweir aLine.append(basegfx::B2DPoint(getRollingRectangle().getMinX(), getViewport().getMinY())); 488cdf0e10cSrcweir aLine.append(basegfx::B2DPoint(getRollingRectangle().getMinX(), getRollingRectangle().getMinY())); 489cdf0e10cSrcweir aRetval[4] = Primitive2DReference(new PolygonMarkerPrimitive2D(aLine, getRGBColorA(), getRGBColorB(), getDiscreteDashLength())); 490cdf0e10cSrcweir 491cdf0e10cSrcweir aLine.clear(); 492cdf0e10cSrcweir aLine.append(basegfx::B2DPoint(getRollingRectangle().getMaxX(), getViewport().getMinY())); 493cdf0e10cSrcweir aLine.append(basegfx::B2DPoint(getRollingRectangle().getMaxX(), getRollingRectangle().getMinY())); 494cdf0e10cSrcweir aRetval[5] = Primitive2DReference(new PolygonMarkerPrimitive2D(aLine, getRGBColorA(), getRGBColorB(), getDiscreteDashLength())); 495cdf0e10cSrcweir 496cdf0e10cSrcweir // Bottom lines 497cdf0e10cSrcweir aLine.clear(); 498cdf0e10cSrcweir aLine.append(basegfx::B2DPoint(getRollingRectangle().getMinX(), getRollingRectangle().getMaxY())); 499cdf0e10cSrcweir aLine.append(basegfx::B2DPoint(getRollingRectangle().getMinX(), getViewport().getMaxY())); 500cdf0e10cSrcweir aRetval[6] = Primitive2DReference(new PolygonMarkerPrimitive2D(aLine, getRGBColorA(), getRGBColorB(), getDiscreteDashLength())); 501cdf0e10cSrcweir 502cdf0e10cSrcweir aLine.clear(); 503cdf0e10cSrcweir aLine.append(basegfx::B2DPoint(getRollingRectangle().getMaxX(), getRollingRectangle().getMaxY())); 504cdf0e10cSrcweir aLine.append(basegfx::B2DPoint(getRollingRectangle().getMaxX(), getViewport().getMaxY())); 505cdf0e10cSrcweir aRetval[7] = Primitive2DReference(new PolygonMarkerPrimitive2D(aLine, getRGBColorA(), getRGBColorB(), getDiscreteDashLength())); 506cdf0e10cSrcweir } 507cdf0e10cSrcweir 508cdf0e10cSrcweir return aRetval; 509cdf0e10cSrcweir } 510cdf0e10cSrcweir 511cdf0e10cSrcweir bool OverlayRollingRectanglePrimitive::operator==( const BasePrimitive2D& rPrimitive ) const 512cdf0e10cSrcweir { 513cdf0e10cSrcweir if(ViewportDependentPrimitive2D::operator==(rPrimitive)) 514cdf0e10cSrcweir { 515cdf0e10cSrcweir const OverlayRollingRectanglePrimitive& rCompare = static_cast< const OverlayRollingRectanglePrimitive& >(rPrimitive); 516cdf0e10cSrcweir 517cdf0e10cSrcweir return (getRollingRectangle() == rCompare.getRollingRectangle() 518cdf0e10cSrcweir && getRGBColorA() == rCompare.getRGBColorA() 519cdf0e10cSrcweir && getRGBColorB() == rCompare.getRGBColorB() 520cdf0e10cSrcweir && getDiscreteDashLength() == rCompare.getDiscreteDashLength()); 521cdf0e10cSrcweir } 522cdf0e10cSrcweir 523cdf0e10cSrcweir return false; 524cdf0e10cSrcweir } 525cdf0e10cSrcweir 526cdf0e10cSrcweir ImplPrimitrive2DIDBlock(OverlayRollingRectanglePrimitive, PRIMITIVE2D_ID_OVERLAYROLLINGRECTANGLEPRIMITIVE) 527cdf0e10cSrcweir 528cdf0e10cSrcweir } // end of namespace primitive2d 529cdf0e10cSrcweir } // end of namespace drawinglayer 530cdf0e10cSrcweir 531cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 532cdf0e10cSrcweir // eof 533