From fc5ecdc4ba5492392711863e09d61859deaad340 Mon Sep 17 00:00:00 2001 From: Armin Weiss Date: Tue, 20 Nov 2007 09:20:18 +0000 Subject: #i39532# adaptions to fat line specials --- .../processor2d/vclpixelprocessor2d.hxx | 11 ++- .../drawinglayer/processor2d/vclprocessor2d.hxx | 6 +- .../source/processor2d/vclpixelprocessor2d.cxx | 40 +++++++--- drawinglayer/source/processor2d/vclprocessor2d.cxx | 85 +++++++++++++++++++++- 4 files changed, 125 insertions(+), 17 deletions(-) (limited to 'drawinglayer') diff --git a/drawinglayer/inc/drawinglayer/processor2d/vclpixelprocessor2d.hxx b/drawinglayer/inc/drawinglayer/processor2d/vclpixelprocessor2d.hxx index b6c289656905..e2a3b8b1b4d2 100644 --- a/drawinglayer/inc/drawinglayer/processor2d/vclpixelprocessor2d.hxx +++ b/drawinglayer/inc/drawinglayer/processor2d/vclpixelprocessor2d.hxx @@ -4,9 +4,9 @@ * * $RCSfile: vclpixelprocessor2d.hxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: aw $ $Date: 2007-07-27 09:03:17 $ + * last change: $Author: aw $ $Date: 2007-11-20 10:20:08 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -40,6 +40,10 @@ #include #endif +#ifndef INCLUDED_SVTOOLS_OPTIONSDRAWINGLAYER_HXX +#include +#endif + ////////////////////////////////////////////////////////////////////////////// // predefines @@ -52,6 +56,9 @@ namespace drawinglayer class VclPixelProcessor2D : public VclProcessor2D { private: + // SvtOptionsDrawinglayer incarnation to react on diverse settings + const SvtOptionsDrawinglayer maDrawinglayerOpt; + protected: // the local processor for BasePrinitive2D-Implementation based primitives, // called from the common process()-implementation diff --git a/drawinglayer/inc/drawinglayer/processor2d/vclprocessor2d.hxx b/drawinglayer/inc/drawinglayer/processor2d/vclprocessor2d.hxx index 8d51b201593f..679736ac8049 100644 --- a/drawinglayer/inc/drawinglayer/processor2d/vclprocessor2d.hxx +++ b/drawinglayer/inc/drawinglayer/processor2d/vclprocessor2d.hxx @@ -4,9 +4,9 @@ * * $RCSfile: vclprocessor2d.hxx,v $ * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * - * last change: $Author: aw $ $Date: 2007-10-15 16:10:57 $ + * last change: $Author: aw $ $Date: 2007-11-20 10:20:08 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -71,6 +71,7 @@ namespace drawinglayer { namespace primitive2d { class PointArrayPrimitive2D; class ModifiedColorPrimitive2D; class WrongSpellPrimitive2D; + class PolygonStrokePrimitive2D; class ControlPrimitive2D; }} @@ -109,6 +110,7 @@ namespace drawinglayer void RenderMarkerArrayPrimitive2D(const primitive2d::MarkerArrayPrimitive2D& rMarkerArrayCandidate); void RenderPointArrayPrimitive2D(const primitive2d::PointArrayPrimitive2D& rPointArrayCandidate); void RenderWrongSpellPrimitive2D(const primitive2d::WrongSpellPrimitive2D& rWrongSpellCandidate); + void RenderPolygonStrokePrimitive2D(const primitive2d::PolygonStrokePrimitive2D& rPolygonStrokeCandidate); ///////////////////////////////////////////////////////////////////////////// // FormControl support diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx index 468ff0005689..5ee9af406e22 100644 --- a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx @@ -4,9 +4,9 @@ * * $RCSfile: vclpixelprocessor2d.cxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: aw $ $Date: 2007-10-16 15:46:43 $ + * last change: $Author: aw $ $Date: 2007-11-20 10:20:18 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -105,10 +105,6 @@ #include #endif -#ifndef INCLUDED_SVTOOLS_OPTIONSDRAWINGLAYER_HXX -#include -#endif - ////////////////////////////////////////////////////////////////////////////// namespace drawinglayer @@ -116,7 +112,8 @@ namespace drawinglayer namespace processor2d { VclPixelProcessor2D::VclPixelProcessor2D(const geometry::ViewInformation2D& rViewInformation, OutputDevice& rOutDev) - : VclProcessor2D(rViewInformation, rOutDev) + : VclProcessor2D(rViewInformation, rOutDev), + maDrawinglayerOpt() { // prepare maCurrentTransformation matrix with viewTransformation to target directly to pixels maCurrentTransformation = rViewInformation.getViewTransformation(); @@ -125,10 +122,8 @@ namespace drawinglayer mpOutputDevice->Push(PUSH_MAPMODE); mpOutputDevice->SetMapMode(); - // set AntiAliasing - const SvtOptionsDrawinglayer aDrawinglayerOpt; - - if(aDrawinglayerOpt.IsAntiAliasing()) + // react on AntiAliasing settings + if(maDrawinglayerOpt.IsAntiAliasing()) { mpOutputDevice->SetAntialiasing(mpOutputDevice->GetAntialiasing() & ~ANTIALIASING_DISABLE_POLYGONS); } @@ -307,6 +302,29 @@ namespace drawinglayer break; } + case PRIMITIVE2D_ID_POLYGONSTROKEPRIMITIVE2D: + { + // polygon stroke primitive + static bool bSuppressFatToHairlineCorrection(false); + + if(maDrawinglayerOpt.IsAntiAliasing() || bSuppressFatToHairlineCorrection) + { + // with AA there is no need to handle thin lines special + process(rCandidate.get2DDecomposition(getViewInformation2D())); + } + else + { + // Lines with 1 and 2 pixel width without AA need special treatment since their vsiualisation + // as filled polygons is geometrically corret but looks wrong since polygon filling avoids + // the right and bottom pixels. The used method evaluates that and takes the correct action, + // including calling recursively with decomposition if line is wide enough + const primitive2d::PolygonStrokePrimitive2D& rPolygonStrokePrimitive = static_cast< const primitive2d::PolygonStrokePrimitive2D& >(rCandidate); + + RenderPolygonStrokePrimitive2D(rPolygonStrokePrimitive); + } + + break; + } default : { // process recursively diff --git a/drawinglayer/source/processor2d/vclprocessor2d.cxx b/drawinglayer/source/processor2d/vclprocessor2d.cxx index f40146b86d09..328bf8d1eaa1 100644 --- a/drawinglayer/source/processor2d/vclprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclprocessor2d.cxx @@ -4,9 +4,9 @@ * * $RCSfile: vclprocessor2d.cxx,v $ * - * $Revision: 1.19 $ + * $Revision: 1.20 $ * - * last change: $Author: aw $ $Date: 2007-11-19 10:21:42 $ + * last change: $Author: aw $ $Date: 2007-11-20 10:20:18 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -913,6 +913,87 @@ namespace drawinglayer } } + void VclProcessor2D::RenderPolygonStrokePrimitive2D(const primitive2d::PolygonStrokePrimitive2D& rPolygonStrokeCandidate) + { + const attribute::LineAttribute& rLineAttribute = rPolygonStrokeCandidate.getLineAttribute(); + const double fLineWidth(rLineAttribute.getWidth()); + bool bDone(false); + + if(basegfx::fTools::more(fLineWidth, 0.0)) + { + const basegfx::B2DVector aDiscreteUnit(maCurrentTransformation * basegfx::B2DVector(1.0, 1.0)); + const double fDiscreteLineWidth((fLineWidth * aDiscreteUnit.getX() + fLineWidth * aDiscreteUnit.getY()) * 0.5); + + if(basegfx::fTools::lessOrEqual(fDiscreteLineWidth, 2.5)) + { + // force to hairline + const attribute::StrokeAttribute& rStrokeAttribute = rPolygonStrokeCandidate.getStrokeAttribute(); + const basegfx::BColor aHairlineColor(maBColorModifierStack.getModifiedColor(rLineAttribute.getColor())); + basegfx::B2DPolyPolygon aHairlinePolyPolygon; + + mpOutputDevice->SetLineColor(Color(aHairlineColor)); + mpOutputDevice->SetFillColor(); + + if(0.0 == rStrokeAttribute.getFullDotDashLen()) + { + // no line dashing, just copy + aHairlinePolyPolygon.append(rPolygonStrokeCandidate.getB2DPolygon()); + } + else + { + // else apply LineStyle + basegfx::tools::applyLineDashing(rPolygonStrokeCandidate.getB2DPolygon(), + rStrokeAttribute.getDotDashArray(), + &aHairlinePolyPolygon, 0, rStrokeAttribute.getFullDotDashLen()); + } + + const sal_uInt32 nCount(aHairlinePolyPolygon.count()); + + if(nCount) + { + const bool bNeedQuadro(basegfx::fTools::more(fDiscreteLineWidth, 1.5)); + aHairlinePolyPolygon.transform(maCurrentTransformation); + + for(sal_uInt32 a(0); a < nCount; a++) + { + // draw the basic hairline polygon + basegfx::B2DPolygon aCandidate(aHairlinePolyPolygon.getB2DPolygon(a)); + mpOutputDevice->DrawPolyLine(aCandidate, 0.0); + + if(bNeedQuadro) + { + // line width is in range ]1.5 .. 2.5], use four hairlines + // drawn in a square. Create the three other ones + basegfx::B2DHomMatrix aMat; + + aMat.set(0, 2, 1); + aCandidate.transform(aMat); + mpOutputDevice->DrawPolyLine(aCandidate, 0.0); + + aMat.set(0, 2, 0); + aMat.set(1, 2, 1); + aCandidate.transform(aMat); + mpOutputDevice->DrawPolyLine(aCandidate, 0.0); + + aMat.set(0, 2, -1); + aMat.set(1, 2, 0); + aCandidate.transform(aMat); + mpOutputDevice->DrawPolyLine(aCandidate, 0.0); + } + } + } + + bDone = true; + } + } + + if(!bDone) + { + // line width is big enough for standard filled polygon visualisation or zero + process(rPolygonStrokeCandidate.get2DDecomposition(getViewInformation2D())); + } + } + basegfx::B2DPoint VclProcessor2D::PositionAndSizeControl(const primitive2d::ControlPrimitive2D& rControlPrimitive2D) { // prepare output for given device -- cgit