incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1364705 - in /incubator/ooo/trunk/main: drawinglayer/inc/drawinglayer/attribute/ drawinglayer/inc/drawinglayer/primitive2d/ drawinglayer/source/attribute/ drawinglayer/source/primitive2d/ svx/source/sdr/contact/ svx/source/sdr/overlay/ svx...
Date Mon, 23 Jul 2012 16:40:53 GMT
Author: alg
Date: Mon Jul 23 16:40:53 2012
New Revision: 1364705

URL: http://svn.apache.org/viewvc?rev=1364705&view=rev
Log:
#120230# Adapt hatch processing to keep a view-dependent minimal distance for more pleasant
visualisation

Modified:
    incubator/ooo/trunk/main/drawinglayer/inc/drawinglayer/attribute/fillhatchattribute.hxx
    incubator/ooo/trunk/main/drawinglayer/inc/drawinglayer/primitive2d/fillhatchprimitive2d.hxx
    incubator/ooo/trunk/main/drawinglayer/inc/drawinglayer/primitive2d/primitivetools2d.hxx
    incubator/ooo/trunk/main/drawinglayer/source/attribute/fillhatchattribute.cxx
    incubator/ooo/trunk/main/drawinglayer/source/primitive2d/fillhatchprimitive2d.cxx
    incubator/ooo/trunk/main/drawinglayer/source/primitive2d/metafileprimitive2d.cxx
    incubator/ooo/trunk/main/drawinglayer/source/primitive2d/primitivetools2d.cxx
    incubator/ooo/trunk/main/svx/source/sdr/contact/viewobjectcontactofsdrole2obj.cxx
    incubator/ooo/trunk/main/svx/source/sdr/overlay/overlaytools.cxx
    incubator/ooo/trunk/main/svx/source/sdr/primitive2d/sdrattributecreator.cxx

Modified: incubator/ooo/trunk/main/drawinglayer/inc/drawinglayer/attribute/fillhatchattribute.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/drawinglayer/inc/drawinglayer/attribute/fillhatchattribute.hxx?rev=1364705&r1=1364704&r2=1364705&view=diff
==============================================================================
--- incubator/ooo/trunk/main/drawinglayer/inc/drawinglayer/attribute/fillhatchattribute.hxx
(original)
+++ incubator/ooo/trunk/main/drawinglayer/inc/drawinglayer/attribute/fillhatchattribute.hxx
Mon Jul 23 16:40:53 2012
@@ -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,7 +86,17 @@ namespace drawinglayer
 			double getDistance() const;
 			double getAngle() const;
 			const basegfx::BColor& getColor() const;
-			bool isFillBackground() 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
 } // end of namespace drawinglayer

Modified: incubator/ooo/trunk/main/drawinglayer/inc/drawinglayer/primitive2d/fillhatchprimitive2d.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/drawinglayer/inc/drawinglayer/primitive2d/fillhatchprimitive2d.hxx?rev=1364705&r1=1364704&r2=1364705&view=diff
==============================================================================
--- incubator/ooo/trunk/main/drawinglayer/inc/drawinglayer/primitive2d/fillhatchprimitive2d.hxx
(original)
+++ incubator/ooo/trunk/main/drawinglayer/inc/drawinglayer/primitive2d/fillhatchprimitive2d.hxx
Mon Jul 23 16:40:53 2012
@@ -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
@@ -61,7 +66,7 @@ namespace drawinglayer
 			/// local decomposition.
 			virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D&
rViewInformation) const;
 
-		public:
+        public:
             /// constructor
 			FillHatchPrimitive2D(
 				const basegfx::B2DRange& rObjectRange, 
@@ -79,7 +84,10 @@ namespace drawinglayer
 			/// get range
 			virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation)
const;
 
-			/// provide unique ID
+			/// get local decomposition. Overloaded since this decomposition is view-dependent
+			virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D&
rViewInformation) const;
+
+            /// provide unique ID
 			DeclPrimitrive2DIDBlock()
 		};
 	} // end of namespace primitive2d

Modified: incubator/ooo/trunk/main/drawinglayer/inc/drawinglayer/primitive2d/primitivetools2d.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/drawinglayer/inc/drawinglayer/primitive2d/primitivetools2d.hxx?rev=1364705&r1=1364704&r2=1364705&view=diff
==============================================================================
--- incubator/ooo/trunk/main/drawinglayer/inc/drawinglayer/primitive2d/primitivetools2d.hxx
(original)
+++ incubator/ooo/trunk/main/drawinglayer/inc/drawinglayer/primitive2d/primitivetools2d.hxx
Mon Jul 23 16:40:53 2012
@@ -50,6 +50,13 @@ namespace drawinglayer
              */
 			double									mfDiscreteUnit;
 
+        protected:
+            /// helper to update discrete unit
+            void updateDiscreteUnit(double fNew)
+            {
+                mfDiscreteUnit = fNew;
+            }
+
 		public:
             /// constructor
 			DiscreteMetricDependentPrimitive2D()

Modified: incubator/ooo/trunk/main/drawinglayer/source/attribute/fillhatchattribute.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/drawinglayer/source/attribute/fillhatchattribute.cxx?rev=1364705&r1=1364704&r2=1364705&view=diff
==============================================================================
--- incubator/ooo/trunk/main/drawinglayer/source/attribute/fillhatchattribute.cxx (original)
+++ incubator/ooo/trunk/main/drawinglayer/source/attribute/fillhatchattribute.cxx Mon Jul
23 16:40:53 2012
@@ -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(); 

Modified: incubator/ooo/trunk/main/drawinglayer/source/primitive2d/fillhatchprimitive2d.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/drawinglayer/source/primitive2d/fillhatchprimitive2d.cxx?rev=1364705&r1=1364704&r2=1364705&view=diff
==============================================================================
--- incubator/ooo/trunk/main/drawinglayer/source/primitive2d/fillhatchprimitive2d.cxx (original)
+++ incubator/ooo/trunk/main/drawinglayer/source/primitive2d/fillhatchprimitive2d.cxx Mon
Jul 23 16:40:53 2012
@@ -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,7 +162,24 @@ namespace drawinglayer
 			return getObjectRange();
 		}
 
-		// provide unique ID
+		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)
 
 	} // end of namespace primitive2d

Modified: incubator/ooo/trunk/main/drawinglayer/source/primitive2d/metafileprimitive2d.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/drawinglayer/source/primitive2d/metafileprimitive2d.cxx?rev=1364705&r1=1364704&r2=1364705&view=diff
==============================================================================
--- incubator/ooo/trunk/main/drawinglayer/source/primitive2d/metafileprimitive2d.cxx (original)
+++ incubator/ooo/trunk/main/drawinglayer/source/primitive2d/metafileprimitive2d.cxx Mon Jul
23 16:40:53 2012
@@ -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);
 	}
 

Modified: incubator/ooo/trunk/main/drawinglayer/source/primitive2d/primitivetools2d.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/drawinglayer/source/primitive2d/primitivetools2d.cxx?rev=1364705&r1=1364704&r2=1364705&view=diff
==============================================================================
--- incubator/ooo/trunk/main/drawinglayer/source/primitive2d/primitivetools2d.cxx (original)
+++ incubator/ooo/trunk/main/drawinglayer/source/primitive2d/primitivetools2d.cxx Mon Jul
23 16:40:53 2012
@@ -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

Modified: incubator/ooo/trunk/main/svx/source/sdr/contact/viewobjectcontactofsdrole2obj.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svx/source/sdr/contact/viewobjectcontactofsdrole2obj.cxx?rev=1364705&r1=1364704&r2=1364705&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svx/source/sdr/contact/viewobjectcontactofsdrole2obj.cxx (original)
+++ incubator/ooo/trunk/main/svx/source/sdr/contact/viewobjectcontactofsdrole2obj.cxx Mon
Jul 23 16:40:53 2012
@@ -134,6 +134,7 @@ namespace sdr
 					        125.0, // 1.25 mm
 					        45.0 * F_PI180, // 45 degree diagonal
 					        Color(COL_BLACK).getBColor(), // black color
+                            3, // same default as VCL, a minimum of three discrete units
(pixels) offset
 					        false); // no filling
 
 				        const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::PolyPolygonHatchPrimitive2D(

Modified: incubator/ooo/trunk/main/svx/source/sdr/overlay/overlaytools.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svx/source/sdr/overlay/overlaytools.cxx?rev=1364705&r1=1364704&r2=1364705&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svx/source/sdr/overlay/overlaytools.cxx (original)
+++ incubator/ooo/trunk/main/svx/source/sdr/overlay/overlaytools.cxx Mon Jul 23 16:40:53 2012
@@ -236,6 +236,7 @@ namespace drawinglayer
 					getDiscreteHatchDistance() * getDiscreteUnit(),
 					getHatchRotation() - getRotation(),
 					getHatchColor(),
+                    3, // same default as VCL, a minimum of three discrete units (pixels)
offset
 					false);
                 const Primitive2DReference aPrimitive(
                     new PolyPolygonHatchPrimitive2D(

Modified: incubator/ooo/trunk/main/svx/source/sdr/primitive2d/sdrattributecreator.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svx/source/sdr/primitive2d/sdrattributecreator.cxx?rev=1364705&r1=1364704&r2=1364705&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svx/source/sdr/primitive2d/sdrattributecreator.cxx (original)
+++ incubator/ooo/trunk/main/svx/source/sdr/primitive2d/sdrattributecreator.cxx Mon Jul 23
16:40:53 2012
@@ -458,6 +458,7 @@ namespace drawinglayer
 								(double)rHatch.GetDistance(),
 								(double)rHatch.GetAngle() * F_PI1800,
 								aColorB.getBColor(),
+                                3, // same default as VCL, a minimum of three discrete units
(pixels) offset
 								((const XFillBackgroundItem&)(rSet.Get(XATTR_FILLBACKGROUND))).GetValue());
 							
 							break;



Mime
View raw message