summaryrefslogtreecommitdiff
path: root/drawinglayer
diff options
context:
space:
mode:
authorArmin Le Grand <alg@apache.org>2012-07-23 15:40:53 +0000
committerCaolán McNamara <caolanm@redhat.com>2013-05-02 14:16:14 +0100
commit8f43c78e9a607df8c72232f03be4f9a7c80538de (patch)
tree37ff71299880163017f5513c76177365f926ddfd /drawinglayer
parente1ffd555b5c70e4bdc693711917ebffbb2423579 (diff)
Resolves: #i120230# Adapt hatch processing for a more pleasant visualisation
Adapt hatch processing to keep a view-dependent minimal distance for a more pleasant visualisation (cherry picked from commit 6a036e7ac17a1d4394d60471bd8931d9b16b7bb4) Conflicts: drawinglayer/inc/drawinglayer/attribute/fillhatchattribute.hxx drawinglayer/inc/drawinglayer/primitive2d/fillhatchprimitive2d.hxx drawinglayer/inc/drawinglayer/primitive2d/primitivetools2d.hxx drawinglayer/source/attribute/fillhatchattribute.cxx Change-Id: I15cd784ef7d3e47a20308f16d370c24ef46d2f22
Diffstat (limited to 'drawinglayer')
-rw-r--r--drawinglayer/source/attribute/fillhatchattribute.cxx17
-rw-r--r--drawinglayer/source/primitive2d/fillhatchprimitive2d.cxx42
-rw-r--r--drawinglayer/source/primitive2d/metafileprimitive2d.cxx1
-rw-r--r--drawinglayer/source/primitive2d/primitivetools2d.cxx2
4 files changed, 54 insertions, 8 deletions
diff --git a/drawinglayer/source/attribute/fillhatchattribute.cxx b/drawinglayer/source/attribute/fillhatchattribute.cxx
index e89628b43a69..1d56badae5ee 100644
--- a/drawinglayer/source/attribute/fillhatchattribute.cxx
+++ b/drawinglayer/source/attribute/fillhatchattribute.cxx
@@ -35,6 +35,7 @@ namespace drawinglayer
double mfDistance;
double mfAngle;
basegfx::BColor maColor;
+ sal_uInt32 mnMinimalDiscreteDistance;
// bitfield
unsigned mbFillBackground : 1;
@@ -44,11 +45,13 @@ namespace drawinglayer
double fDistance,
double fAngle,
const basegfx::BColor& rColor,
+ sal_uInt32 nMinimalDiscreteDistance,
bool bFillBackground)
: meStyle(eStyle),
mfDistance(fDistance),
mfAngle(fAngle),
maColor(rColor),
+ mnMinimalDiscreteDistance(nMinimalDiscreteDistance),
mbFillBackground(bFillBackground)
{
}
@@ -58,6 +61,7 @@ namespace drawinglayer
mfDistance(0.0),
mfAngle(0.0),
maColor(basegfx::BColor()),
+ mnMinimalDiscreteDistance(3), // same as VCL
mbFillBackground(false)
{
}
@@ -67,6 +71,7 @@ namespace drawinglayer
double getDistance() const { return mfDistance; }
double getAngle() const { return mfAngle; }
const basegfx::BColor& getColor() const { return maColor; }
+ sal_uInt32 getMinimalDiscreteDistance() const { return mnMinimalDiscreteDistance; }
bool isFillBackground() const { return mbFillBackground; }
bool operator==(const ImpFillHatchAttribute& rCandidate) const
@@ -75,7 +80,8 @@ namespace drawinglayer
&& getDistance() == rCandidate.getDistance()
&& getAngle() == rCandidate.getAngle()
&& getColor() == rCandidate.getColor()
- && isFillBackground() == rCandidate.isFillBackground());
+ && getMinimalDiscreteDistance() == rCandidate.getMinimalDiscreteDistance()
+ && isFillBackground() == rCandidate.isFillBackground());
}
};
@@ -90,9 +96,11 @@ namespace drawinglayer
double fDistance,
double fAngle,
const basegfx::BColor& rColor,
+ sal_uInt32 nMinimalDiscreteDistance,
bool bFillBackground)
: mpFillHatchAttribute(ImpFillHatchAttribute(
- eStyle, fDistance, fAngle, rColor, bFillBackground))
+ eStyle, fDistance, fAngle, rColor,
+ nMinimalDiscreteDistance, bFillBackground))
{
}
@@ -147,6 +155,11 @@ namespace drawinglayer
return mpFillHatchAttribute->getColor();
}
+ sal_uInt32 FillHatchAttribute::getMinimalDiscreteDistance() const
+ {
+ return mpFillHatchAttribute->getMinimalDiscreteDistance();
+ }
+
bool FillHatchAttribute::isFillBackground() const
{
return mpFillHatchAttribute->isFillBackground();
diff --git a/drawinglayer/source/primitive2d/fillhatchprimitive2d.cxx b/drawinglayer/source/primitive2d/fillhatchprimitive2d.cxx
index 1fc7e32b2986..556265c7cebf 100644
--- a/drawinglayer/source/primitive2d/fillhatchprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/fillhatchprimitive2d.cxx
@@ -25,6 +25,7 @@
#include <basegfx/tools/canvastools.hxx>
#include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
#include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
+#include <drawinglayer/geometry/viewinformation2d.hxx>
//////////////////////////////////////////////////////////////////////////////
@@ -39,12 +40,26 @@ namespace drawinglayer
Primitive2DSequence FillHatchPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
{
Primitive2DSequence aRetval;
+
if(!getFillHatch().isDefault())
{
// create hatch
const basegfx::BColor aHatchColor(getFillHatch().getColor());
const double fAngle(getFillHatch().getAngle());
::std::vector< basegfx::B2DHomMatrix > aMatrices;
+ double fDistance(getFillHatch().getDistance());
+ const bool bAdaptDistance(0 != getFillHatch().getMinimalDiscreteDistance());
+
+ // #i120230# evtl. adapt distance
+ if(bAdaptDistance)
+ {
+ const double fDiscreteDistance(getFillHatch().getDistance() / getDiscreteUnit());
+
+ if(fDiscreteDistance < (double)getFillHatch().getMinimalDiscreteDistance())
+ {
+ fDistance = (double)getFillHatch().getMinimalDiscreteDistance() * getDiscreteUnit();
+ }
+ }
// get hatch transformations
switch(getFillHatch().getStyle())
@@ -52,7 +67,7 @@ namespace drawinglayer
case attribute::HATCHSTYLE_TRIPLE:
{
// rotated 45 degrees
- texture::GeoTexSvxHatch aHatch(getObjectRange(), getFillHatch().getDistance(), fAngle - F_PI4);
+ texture::GeoTexSvxHatch aHatch(getObjectRange(), fDistance, fAngle - F_PI4);
aHatch.appendTransformations(aMatrices);
// fall-through by purpose
@@ -60,7 +75,7 @@ namespace drawinglayer
case attribute::HATCHSTYLE_DOUBLE:
{
// rotated 90 degrees
- texture::GeoTexSvxHatch aHatch(getObjectRange(), getFillHatch().getDistance(), fAngle - F_PI2);
+ texture::GeoTexSvxHatch aHatch(getObjectRange(), fDistance, fAngle - F_PI2);
aHatch.appendTransformations(aMatrices);
// fall-through by purpose
@@ -68,7 +83,7 @@ namespace drawinglayer
case attribute::HATCHSTYLE_SINGLE:
{
// angle as given
- texture::GeoTexSvxHatch aHatch(getObjectRange(), getFillHatch().getDistance(), fAngle);
+ texture::GeoTexSvxHatch aHatch(getObjectRange(), fDistance, fAngle);
aHatch.appendTransformations(aMatrices);
}
}
@@ -113,7 +128,7 @@ namespace drawinglayer
const basegfx::B2DRange& rObjectRange,
const basegfx::BColor& rBColor,
const attribute::FillHatchAttribute& rFillHatch)
- : BufferedDecompositionPrimitive2D(),
+ : DiscreteMetricDependentPrimitive2D(),
maObjectRange(rObjectRange),
maFillHatch(rFillHatch),
maBColor(rBColor)
@@ -122,7 +137,7 @@ namespace drawinglayer
bool FillHatchPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
{
- if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
+ if(DiscreteMetricDependentPrimitive2D::operator==(rPrimitive))
{
const FillHatchPrimitive2D& rCompare = (FillHatchPrimitive2D&)rPrimitive;
@@ -140,6 +155,23 @@ namespace drawinglayer
return getObjectRange();
}
+ Primitive2DSequence FillHatchPrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ bool bAdaptDistance(0 != getFillHatch().getMinimalDiscreteDistance());
+
+ if(bAdaptDistance)
+ {
+ // behave view-dependent
+ return DiscreteMetricDependentPrimitive2D::get2DDecomposition(rViewInformation);
+ }
+ else
+ {
+ // behave view-independent
+ return BufferedDecompositionPrimitive2D::get2DDecomposition(rViewInformation);
+ }
+ }
+
// provide unique ID
ImplPrimitrive2DIDBlock(FillHatchPrimitive2D, PRIMITIVE2D_ID_FILLHATCHPRIMITIVE2D)
diff --git a/drawinglayer/source/primitive2d/metafileprimitive2d.cxx b/drawinglayer/source/primitive2d/metafileprimitive2d.cxx
index f0767052d324..180d122dcc59 100644
--- a/drawinglayer/source/primitive2d/metafileprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/metafileprimitive2d.cxx
@@ -958,6 +958,7 @@ namespace
(double)rHatch.GetDistance(),
(double)rHatch.GetAngle() * F_PI1800,
rHatch.GetColor().getBColor(),
+ 3, // same default as VCL, a minimum of three discrete units (pixels) offset
false);
}
diff --git a/drawinglayer/source/primitive2d/primitivetools2d.cxx b/drawinglayer/source/primitive2d/primitivetools2d.cxx
index 24c8341f6c18..063aa1cc073e 100644
--- a/drawinglayer/source/primitive2d/primitivetools2d.cxx
+++ b/drawinglayer/source/primitive2d/primitivetools2d.cxx
@@ -43,7 +43,7 @@ namespace drawinglayer
if(!getBuffered2DDecomposition().hasElements())
{
// remember new valid DiscreteUnit
- const_cast< DiscreteMetricDependentPrimitive2D* >(this)->mfDiscreteUnit = fDiscreteUnit;
+ const_cast< DiscreteMetricDependentPrimitive2D* >(this)->updateDiscreteUnit(fDiscreteUnit);
}
// call base implementation