summaryrefslogtreecommitdiff
path: root/drawinglayer
diff options
context:
space:
mode:
authorArmin Le Grand <alg@apache.org>2012-07-23 15:40:53 +0000
committerArmin Le Grand <alg@apache.org>2012-07-23 15:40:53 +0000
commit6a036e7ac17a1d4394d60471bd8931d9b16b7bb4 (patch)
tree3db6d98f8fa83f0f67df818ee79b4f119d7ff478 /drawinglayer
parent406c222f6fc69df7164c939e8bb23a1c176863b0 (diff)
#120230# Adapt hatch processing to keep a view-dependent minimal distance for more pleasant visualisation
Notes
Diffstat (limited to 'drawinglayer')
-rw-r--r--drawinglayer/inc/drawinglayer/attribute/fillhatchattribute.hxx11
-rw-r--r--drawinglayer/inc/drawinglayer/primitive2d/fillhatchprimitive2d.hxx12
-rw-r--r--drawinglayer/inc/drawinglayer/primitive2d/primitivetools2d.hxx7
-rw-r--r--drawinglayer/source/attribute/fillhatchattribute.cxx24
-rw-r--r--drawinglayer/source/primitive2d/fillhatchprimitive2d.cxx42
-rw-r--r--drawinglayer/source/primitive2d/metafileprimitive2d.cxx1
-rw-r--r--drawinglayer/source/primitive2d/primitivetools2d.cxx2
7 files changed, 88 insertions, 11 deletions
diff --git a/drawinglayer/inc/drawinglayer/attribute/fillhatchattribute.hxx b/drawinglayer/inc/drawinglayer/attribute/fillhatchattribute.hxx
index 7a250eefa100..86dc45d6c208 100644
--- a/drawinglayer/inc/drawinglayer/attribute/fillhatchattribute.hxx
+++ b/drawinglayer/inc/drawinglayer/attribute/fillhatchattribute.hxx
@@ -68,6 +68,7 @@ namespace drawinglayer
double fDistance,
double fAngle,
const basegfx::BColor& rColor,
+ sal_uInt32 nMinimalDiscreteDistance,
bool bFillBackground);
FillHatchAttribute();
FillHatchAttribute(const FillHatchAttribute& rCandidate);
@@ -85,6 +86,16 @@ namespace drawinglayer
double getDistance() const;
double getAngle() const;
const basegfx::BColor& getColor() const;
+
+ // #120230# If a minimal discrete distance is wanted (VCL used 3, this is the default for the
+ // global instance, too), set this unequal to zero. Zero means not to use it. If set
+ // bigger zero (should be at least two, one leads to a full plane filled with lines when
+ // Distance in discrete views is smaller than one) this will be used when the discrete
+ // value is less than the given one. This is used to 'emulate' old VCL behaviour which
+ // makes hatches look better by not making distances as small as needed, but keeping
+ // them on a minimal discrete value for more appealing visualisation.
+ sal_uInt32 getMinimalDiscreteDistance() const;
+
bool isFillBackground() const;
};
} // end of namespace attribute
diff --git a/drawinglayer/inc/drawinglayer/primitive2d/fillhatchprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/fillhatchprimitive2d.hxx
index 997812c28b33..9fbc68b0a54e 100644
--- a/drawinglayer/inc/drawinglayer/primitive2d/fillhatchprimitive2d.hxx
+++ b/drawinglayer/inc/drawinglayer/primitive2d/fillhatchprimitive2d.hxx
@@ -25,7 +25,7 @@
#define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_FILLHATCHPRIMITIVE2D_HXX
#include <drawinglayer/drawinglayerdllapi.h>
-#include <drawinglayer/primitive2d/baseprimitive2d.hxx>
+#include <drawinglayer/primitive2d/primitivetools2d.hxx>
#include <drawinglayer/attribute/fillhatchattribute.hxx>
#include <basegfx/color/bcolor.hxx>
@@ -43,9 +43,14 @@ namespace drawinglayer
If the background is to be filled, a flag in FillHatchAttribute is set and
the BColor defines the background color.
+ #120230# This primitive is now evtl. metric dependent due to the value
+ MinimalDiscreteDistance in the FillHatchAttribute if the value is not zero.
+ This is used for a more appealing, VCL-like visualisation by not letting the
+ distances get too small between lines.
+
The decomposition will deliver the hatch lines.
*/
- class DRAWINGLAYER_DLLPUBLIC FillHatchPrimitive2D : public BufferedDecompositionPrimitive2D
+ class DRAWINGLAYER_DLLPUBLIC FillHatchPrimitive2D : public DiscreteMetricDependentPrimitive2D
{
private:
/// the geometric definition
@@ -79,6 +84,9 @@ namespace drawinglayer
/// get range
virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const;
+ /// get local decomposition. Overloaded since this decomposition is view-dependent
+ virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
+
/// provide unique ID
DeclPrimitrive2DIDBlock()
};
diff --git a/drawinglayer/inc/drawinglayer/primitive2d/primitivetools2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/primitivetools2d.hxx
index cf70c3e63b9f..c04379c7384c 100644
--- a/drawinglayer/inc/drawinglayer/primitive2d/primitivetools2d.hxx
+++ b/drawinglayer/inc/drawinglayer/primitive2d/primitivetools2d.hxx
@@ -50,6 +50,13 @@ namespace drawinglayer
*/
double mfDiscreteUnit;
+ protected:
+ /// helper to update discrete unit
+ void updateDiscreteUnit(double fNew)
+ {
+ mfDiscreteUnit = fNew;
+ }
+
public:
/// constructor
DiscreteMetricDependentPrimitive2D()
diff --git a/drawinglayer/source/attribute/fillhatchattribute.cxx b/drawinglayer/source/attribute/fillhatchattribute.cxx
index b6007729467e..cddbcb5e61ed 100644
--- a/drawinglayer/source/attribute/fillhatchattribute.cxx
+++ b/drawinglayer/source/attribute/fillhatchattribute.cxx
@@ -42,6 +42,7 @@ namespace drawinglayer
double mfDistance;
double mfAngle;
basegfx::BColor maColor;
+ sal_uInt32 mnMinimalDiscreteDistance;
// bitfield
unsigned mbFillBackground : 1;
@@ -51,12 +52,14 @@ namespace drawinglayer
double fDistance,
double fAngle,
const basegfx::BColor& rColor,
+ sal_uInt32 nMinimalDiscreteDistance,
bool bFillBackground)
: mnRefCount(0),
meStyle(eStyle),
mfDistance(fDistance),
mfAngle(fAngle),
maColor(rColor),
+ mnMinimalDiscreteDistance(nMinimalDiscreteDistance),
mbFillBackground(bFillBackground)
{
}
@@ -66,6 +69,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
@@ -74,7 +78,8 @@ namespace drawinglayer
&& getDistance() == rCandidate.getDistance()
&& getAngle() == rCandidate.getAngle()
&& getColor() == rCandidate.getColor()
- && isFillBackground() == rCandidate.isFillBackground());
+ && getMinimalDiscreteDistance() == rCandidate.getMinimalDiscreteDistance()
+ && isFillBackground() == rCandidate.isFillBackground());
}
static ImpFillHatchAttribute* get_global_default()
@@ -87,6 +92,7 @@ namespace drawinglayer
HATCHSTYLE_SINGLE,
0.0, 0.0,
basegfx::BColor(),
+ 3, // same as VCL
false);
// never delete; start with RefCount 1, not 0
@@ -102,9 +108,16 @@ namespace drawinglayer
double fDistance,
double fAngle,
const basegfx::BColor& rColor,
+ sal_uInt32 nMinimalDiscreteDistance,
bool bFillBackground)
- : mpFillHatchAttribute(new ImpFillHatchAttribute(
- eStyle, fDistance, fAngle, rColor, bFillBackground))
+ : mpFillHatchAttribute(
+ new ImpFillHatchAttribute(
+ eStyle,
+ fDistance,
+ fAngle,
+ rColor,
+ nMinimalDiscreteDistance,
+ bFillBackground))
{
}
@@ -193,6 +206,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 85b0765b0ada..beb57072b7dc 100644
--- a/drawinglayer/source/primitive2d/fillhatchprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/fillhatchprimitive2d.cxx
@@ -32,6 +32,7 @@
#include <basegfx/tools/canvastools.hxx>
#include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
#include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
+#include <drawinglayer/geometry/viewinformation2d.hxx>
//////////////////////////////////////////////////////////////////////////////
@@ -46,12 +47,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());
+
+ // #120230# 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())
@@ -59,7 +74,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
@@ -67,7 +82,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
@@ -75,7 +90,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);
}
}
@@ -120,7 +135,7 @@ namespace drawinglayer
const basegfx::B2DRange& rObjectRange,
const basegfx::BColor& rBColor,
const attribute::FillHatchAttribute& rFillHatch)
- : BufferedDecompositionPrimitive2D(),
+ : DiscreteMetricDependentPrimitive2D(),
maObjectRange(rObjectRange),
maFillHatch(rFillHatch),
maBColor(rBColor)
@@ -129,7 +144,7 @@ namespace drawinglayer
bool FillHatchPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
{
- if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
+ if(DiscreteMetricDependentPrimitive2D::operator==(rPrimitive))
{
const FillHatchPrimitive2D& rCompare = (FillHatchPrimitive2D&)rPrimitive;
@@ -147,6 +162,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 2a760f44604e..2663043b9f39 100644
--- a/drawinglayer/source/primitive2d/metafileprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/metafileprimitive2d.cxx
@@ -964,6 +964,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 6f4cba96d683..1cd573ce921e 100644
--- a/drawinglayer/source/primitive2d/primitivetools2d.cxx
+++ b/drawinglayer/source/primitive2d/primitivetools2d.cxx
@@ -50,7 +50,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