diff options
Diffstat (limited to 'drawinglayer/source')
61 files changed, 8773 insertions, 1509 deletions
diff --git a/drawinglayer/source/animation/animationtiming.cxx b/drawinglayer/source/animation/animationtiming.cxx index f281742a7311..92f0e1a3fbcf 100644 --- a/drawinglayer/source/animation/animationtiming.cxx +++ b/drawinglayer/source/animation/animationtiming.cxx @@ -4,9 +4,9 @@ * * $RCSfile: animationtiming.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: aw $ $Date: 2006-09-27 16:32:56 $ + * last change: $Author: aw $ $Date: 2006-10-19 10:36:00 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -33,7 +33,7 @@ * ************************************************************************/ -#ifndef _DRAWINGLAYER_ANIMATION_ANIMATIONTIMING_HXX +#ifndef INCLUDED_DRAWINGLAYER_ANIMATION_ANIMATIONTIMING_HXX #include <drawinglayer/animation/animationtiming.hxx> #endif @@ -49,51 +49,51 @@ namespace drawinglayer { ////////////////////////////////////////////////////////////////////////////// - animationEntry::animationEntry() + AnimationEntry::AnimationEntry() { } - animationEntry::~animationEntry() + AnimationEntry::~AnimationEntry() { } ////////////////////////////////////////////////////////////////////////////// - animationEntryFixed::animationEntryFixed(double fDuration, double fState) + AnimationEntryFixed::AnimationEntryFixed(double fDuration, double fState) : mfDuration(fDuration), mfState(fState) { } - animationEntryFixed::~animationEntryFixed() + AnimationEntryFixed::~AnimationEntryFixed() { } - animationEntry* animationEntryFixed::clone() const + AnimationEntry* AnimationEntryFixed::clone() const { - return new animationEntryFixed(mfDuration, mfState); + return new AnimationEntryFixed(mfDuration, mfState); } - bool animationEntryFixed::operator==(const animationEntry& rCandidate) const + bool AnimationEntryFixed::operator==(const AnimationEntry& rCandidate) const { - const animationEntryFixed* pCompare = dynamic_cast< const animationEntryFixed* >(&rCandidate); + const AnimationEntryFixed* pCompare = dynamic_cast< const AnimationEntryFixed* >(&rCandidate); return (pCompare && basegfx::fTools::equal(mfDuration, pCompare->mfDuration) && basegfx::fTools::equal(mfState, pCompare->mfState)); } - double animationEntryFixed::getDuration() const + double AnimationEntryFixed::getDuration() const { return mfDuration; } - double animationEntryFixed::getStateAtTime(double /*fTime*/) const + double AnimationEntryFixed::getStateAtTime(double /*fTime*/) const { return mfState; } - double animationEntryFixed::getNextEventTime(double fTime) const + double AnimationEntryFixed::getNextEventTime(double fTime) const { if(basegfx::fTools::less(fTime, mfDuration)) { @@ -107,7 +107,7 @@ namespace drawinglayer ////////////////////////////////////////////////////////////////////////////// - animationEntryLinear::animationEntryLinear(double fDuration, double fFrequency, double fStart, double fStop) + AnimationEntryLinear::AnimationEntryLinear(double fDuration, double fFrequency, double fStart, double fStop) : mfDuration(fDuration), mfFrequency(fFrequency), mfStart(fStart), @@ -115,18 +115,18 @@ namespace drawinglayer { } - animationEntryLinear::~animationEntryLinear() + AnimationEntryLinear::~AnimationEntryLinear() { } - animationEntry* animationEntryLinear::clone() const + AnimationEntry* AnimationEntryLinear::clone() const { - return new animationEntryLinear(mfDuration, mfFrequency, mfStart, mfStop); + return new AnimationEntryLinear(mfDuration, mfFrequency, mfStart, mfStop); } - bool animationEntryLinear::operator==(const animationEntry& rCandidate) const + bool AnimationEntryLinear::operator==(const AnimationEntry& rCandidate) const { - const animationEntryLinear* pCompare = dynamic_cast< const animationEntryLinear* >(&rCandidate); + const AnimationEntryLinear* pCompare = dynamic_cast< const AnimationEntryLinear* >(&rCandidate); return (pCompare && basegfx::fTools::equal(mfDuration, pCompare->mfDuration) @@ -134,12 +134,12 @@ namespace drawinglayer && basegfx::fTools::equal(mfStop, pCompare->mfStop)); } - double animationEntryLinear::getDuration() const + double AnimationEntryLinear::getDuration() const { return mfDuration; } - double animationEntryLinear::getStateAtTime(double fTime) const + double AnimationEntryLinear::getStateAtTime(double fTime) const { if(basegfx::fTools::more(mfDuration, 0.0)) { @@ -160,7 +160,7 @@ namespace drawinglayer } } - double animationEntryLinear::getNextEventTime(double fTime) const + double AnimationEntryLinear::getNextEventTime(double fTime) const { if(basegfx::fTools::less(fTime, mfDuration)) { @@ -184,7 +184,7 @@ namespace drawinglayer ////////////////////////////////////////////////////////////////////////////// - sal_uInt32 animationEntryList::impGetIndexAtTime(double fTime, double &rfAddedTime) const + sal_uInt32 AnimationEntryList::impGetIndexAtTime(double fTime, double &rfAddedTime) const { sal_uInt32 nIndex(0L); @@ -196,12 +196,12 @@ namespace drawinglayer return nIndex; } - animationEntryList::animationEntryList() + AnimationEntryList::AnimationEntryList() : mfDuration(0.0) { } - animationEntryList::~animationEntryList() + AnimationEntryList::~AnimationEntryList() { for(sal_uInt32 a(0L); a < maEntries.size(); a++) { @@ -209,9 +209,9 @@ namespace drawinglayer } } - animationEntry* animationEntryList::clone() const + AnimationEntry* AnimationEntryList::clone() const { - animationEntryList* pNew = new animationEntryList(); + AnimationEntryList* pNew = new AnimationEntryList(); for(sal_uInt32 a(0L); a < maEntries.size(); a++) { @@ -221,9 +221,9 @@ namespace drawinglayer return pNew; } - bool animationEntryList::operator==(const animationEntry& rCandidate) const + bool AnimationEntryList::operator==(const AnimationEntry& rCandidate) const { - const animationEntryList* pCompare = dynamic_cast< const animationEntryList* >(&rCandidate); + const AnimationEntryList* pCompare = dynamic_cast< const AnimationEntryList* >(&rCandidate); if(pCompare && mfDuration == pCompare->mfDuration) { @@ -241,7 +241,7 @@ namespace drawinglayer return false; } - void animationEntryList::append(const animationEntry& rCandidate) + void AnimationEntryList::append(const AnimationEntry& rCandidate) { const double fDuration(rCandidate.getDuration()); @@ -252,12 +252,12 @@ namespace drawinglayer } } - double animationEntryList::getDuration() const + double AnimationEntryList::getDuration() const { return mfDuration; } - double animationEntryList::getStateAtTime(double fTime) const + double AnimationEntryList::getStateAtTime(double fTime) const { if(!basegfx::fTools::equalZero(mfDuration)) { @@ -273,7 +273,7 @@ namespace drawinglayer return 0.0; } - double animationEntryList::getNextEventTime(double fTime) const + double AnimationEntryList::getNextEventTime(double fTime) const { double fNewTime(0.0); @@ -293,19 +293,19 @@ namespace drawinglayer ////////////////////////////////////////////////////////////////////////////// - animationEntryLoop::animationEntryLoop(sal_uInt32 nRepeat) - : animationEntryList(), + AnimationEntryLoop::AnimationEntryLoop(sal_uInt32 nRepeat) + : AnimationEntryList(), mnRepeat(nRepeat) { } - animationEntryLoop::~animationEntryLoop() + AnimationEntryLoop::~AnimationEntryLoop() { } - animationEntry* animationEntryLoop::clone() const + AnimationEntry* AnimationEntryLoop::clone() const { - animationEntryLoop* pNew = new animationEntryLoop(mnRepeat); + AnimationEntryLoop* pNew = new AnimationEntryLoop(mnRepeat); for(sal_uInt32 a(0L); a < maEntries.size(); a++) { @@ -315,21 +315,21 @@ namespace drawinglayer return pNew; } - bool animationEntryLoop::operator==(const animationEntry& rCandidate) const + bool AnimationEntryLoop::operator==(const AnimationEntry& rCandidate) const { - const animationEntryLoop* pCompare = dynamic_cast< const animationEntryLoop* >(&rCandidate); + const AnimationEntryLoop* pCompare = dynamic_cast< const AnimationEntryLoop* >(&rCandidate); return (pCompare && mnRepeat == pCompare->mnRepeat - && animationEntryList::operator==(rCandidate)); + && AnimationEntryList::operator==(rCandidate)); } - double animationEntryLoop::getDuration() const + double AnimationEntryLoop::getDuration() const { return (mfDuration * (double)mnRepeat); } - double animationEntryLoop::getStateAtTime(double fTime) const + double AnimationEntryLoop::getStateAtTime(double fTime) const { if(mnRepeat && !basegfx::fTools::equalZero(mfDuration)) { @@ -343,14 +343,14 @@ namespace drawinglayer { const double fTimeAtLoopStart((double)nCurrentLoop * mfDuration); const double fRelativeTime(fTime - fTimeAtLoopStart); - return animationEntryList::getStateAtTime(fRelativeTime); + return AnimationEntryList::getStateAtTime(fRelativeTime); } } return 0.0; } - double animationEntryLoop::getNextEventTime(double fTime) const + double AnimationEntryLoop::getNextEventTime(double fTime) const { double fNewTime(0.0); @@ -362,7 +362,7 @@ namespace drawinglayer { const double fTimeAtLoopStart((double)nCurrentLoop * mfDuration); const double fRelativeTime(fTime - fTimeAtLoopStart); - const double fNextEventAtLoop(animationEntryList::getNextEventTime(fRelativeTime)); + const double fNextEventAtLoop(AnimationEntryList::getNextEventTime(fRelativeTime)); if(!basegfx::fTools::equalZero(fNextEventAtLoop)) { diff --git a/drawinglayer/source/attribute/fillattribute.cxx b/drawinglayer/source/attribute/fillattribute.cxx index 197f65071a0f..3807fbb293ae 100644 --- a/drawinglayer/source/attribute/fillattribute.cxx +++ b/drawinglayer/source/attribute/fillattribute.cxx @@ -4,9 +4,9 @@ * * $RCSfile: fillattribute.cxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: aw $ $Date: 2006-08-09 16:47:33 $ + * last change: $Author: aw $ $Date: 2006-10-19 10:36:13 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -33,7 +33,7 @@ * ************************************************************************/ -#ifndef _DRAWINGLAYER_ATTRIBUTE_FILLATTRIBUTE_HXX +#ifndef INCLUDED_DRAWINGLAYER_ATTRIBUTE_FILLATTRIBUTE_HXX #include <drawinglayer/attribute/fillattribute.hxx> #endif @@ -47,7 +47,7 @@ namespace drawinglayer { namespace attribute { - fillGradientAttribute::fillGradientAttribute(GradientStyle eStyle, double fBorder, double fOffsetX, double fOffsetY, double fAngle, + FillGradientAttribute::FillGradientAttribute(GradientStyle eStyle, double fBorder, double fOffsetX, double fOffsetY, double fAngle, const basegfx::BColor& rStartColor, const basegfx::BColor& rEndColor, sal_uInt16 nSteps) : maStartColor(rStartColor), maEndColor(rEndColor), @@ -60,7 +60,7 @@ namespace drawinglayer { } - bool fillGradientAttribute::operator==(const fillGradientAttribute& rCandidate) const + bool FillGradientAttribute::operator==(const FillGradientAttribute& rCandidate) const { return (meStyle == rCandidate.meStyle && maStartColor == rCandidate.maStartColor @@ -80,7 +80,7 @@ namespace drawinglayer { namespace attribute { - fillHatchAttribute::fillHatchAttribute(HatchStyle eStyle, double fDistance, double fAngle, const basegfx::BColor& rColor, bool bFillBackground) + FillHatchAttribute::FillHatchAttribute(HatchStyle eStyle, double fDistance, double fAngle, const basegfx::BColor& rColor, bool bFillBackground) : mfDistance(fDistance), mfAngle(fAngle), maColor(rColor), @@ -89,7 +89,7 @@ namespace drawinglayer { } - bool fillHatchAttribute::operator==(const fillHatchAttribute& rCandidate) const + bool FillHatchAttribute::operator==(const FillHatchAttribute& rCandidate) const { return (meStyle == rCandidate.meStyle && mfDistance == rCandidate.mfDistance diff --git a/drawinglayer/source/attribute/fillbitmapattribute.cxx b/drawinglayer/source/attribute/fillbitmapattribute.cxx index 625657412eaa..daf02163a2f9 100644 --- a/drawinglayer/source/attribute/fillbitmapattribute.cxx +++ b/drawinglayer/source/attribute/fillbitmapattribute.cxx @@ -4,9 +4,9 @@ * * $RCSfile: fillbitmapattribute.cxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: aw $ $Date: 2006-08-09 16:47:33 $ + * last change: $Author: aw $ $Date: 2006-10-19 10:36:13 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -33,7 +33,7 @@ * ************************************************************************/ -#ifndef _DRAWINGLAYER_ATTRIBUTE_FILLBITMAPATTRIBUTE_HXX +#ifndef INCLUDED_DRAWINGLAYER_ATTRIBUTE_FILLBITMAPATTRIBUTE_HXX #include <drawinglayer/attribute/fillbitmapattribute.hxx> #endif @@ -43,7 +43,7 @@ namespace drawinglayer { namespace attribute { - fillBitmapAttribute::fillBitmapAttribute(const Bitmap& rBitmap, const basegfx::B2DPoint& rTopLeft, const basegfx::B2DVector& rSize, bool bTiling) + FillBitmapAttribute::FillBitmapAttribute(const Bitmap& rBitmap, const basegfx::B2DPoint& rTopLeft, const basegfx::B2DVector& rSize, bool bTiling) : maBitmap(rBitmap), maTopLeft(rTopLeft), maSize(rSize), @@ -51,7 +51,7 @@ namespace drawinglayer { } - bool fillBitmapAttribute::operator==(const fillBitmapAttribute& rCandidate) const + bool FillBitmapAttribute::operator==(const FillBitmapAttribute& rCandidate) const { return (maBitmap == rCandidate.maBitmap && maTopLeft == rCandidate.maTopLeft diff --git a/drawinglayer/source/attribute/materialattribute3d.cxx b/drawinglayer/source/attribute/materialattribute3d.cxx index 4a2c0b30cdbc..b4c9d7257429 100644 --- a/drawinglayer/source/attribute/materialattribute3d.cxx +++ b/drawinglayer/source/attribute/materialattribute3d.cxx @@ -4,9 +4,9 @@ * * $RCSfile: materialattribute3d.cxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: aw $ $Date: 2006-08-09 16:47:33 $ + * last change: $Author: aw $ $Date: 2006-10-19 10:36:13 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -33,7 +33,7 @@ * ************************************************************************/ -#ifndef _DRAWINGLAYER_ATTRIBUTE_MATERIALATTRIBUTE3D_HXX +#ifndef INCLUDED_DRAWINGLAYER_ATTRIBUTE_MATERIALATTRIBUTE3D_HXX #include <drawinglayer/attribute/materialattribute3d.hxx> #endif @@ -47,7 +47,7 @@ namespace drawinglayer { namespace { - class impMaterialAttribute3D + class ImpMaterialAttribute3D { public: // materialAttribute3D definitions @@ -59,7 +59,7 @@ namespace drawinglayer // refcounter sal_uInt32 mnRefCount; - impMaterialAttribute3D(const basegfx::BColor& rColor, const basegfx::BColor& rSpecular, const basegfx::BColor& rEmission, sal_uInt16 nSpecularIntensity) + ImpMaterialAttribute3D(const basegfx::BColor& rColor, const basegfx::BColor& rSpecular, const basegfx::BColor& rEmission, sal_uInt16 nSpecularIntensity) : maColor(rColor), maSpecular(rSpecular), maEmission(rEmission), @@ -68,7 +68,7 @@ namespace drawinglayer { } - impMaterialAttribute3D(const basegfx::BColor& rColor) + ImpMaterialAttribute3D(const basegfx::BColor& rColor) : maColor(rColor), maSpecular(1.0, 1.0, 1.0), maEmission(), @@ -77,13 +77,13 @@ namespace drawinglayer { } - impMaterialAttribute3D() + ImpMaterialAttribute3D() : mnSpecularIntensity(0), mnRefCount(0L) { } - bool operator==(const impMaterialAttribute3D& rCandidate) const + bool operator==(const ImpMaterialAttribute3D& rCandidate) const { return (maColor == rCandidate.maColor && maSpecular == rCandidate.maSpecular @@ -105,28 +105,28 @@ namespace drawinglayer { namespace attribute { - materialAttribute3D::materialAttribute3D(const basegfx::BColor& rColor, const basegfx::BColor& rSpecular, const basegfx::BColor& rEmission, sal_uInt16 nSpecularIntensity) - : mpMaterialAttribute3D(new impMaterialAttribute3D(rColor, rSpecular, rEmission, nSpecularIntensity)) + MaterialAttribute3D::MaterialAttribute3D(const basegfx::BColor& rColor, const basegfx::BColor& rSpecular, const basegfx::BColor& rEmission, sal_uInt16 nSpecularIntensity) + : mpMaterialAttribute3D(new ImpMaterialAttribute3D(rColor, rSpecular, rEmission, nSpecularIntensity)) { } - materialAttribute3D::materialAttribute3D(const basegfx::BColor& rColor) - : mpMaterialAttribute3D(new impMaterialAttribute3D(rColor)) + MaterialAttribute3D::MaterialAttribute3D(const basegfx::BColor& rColor) + : mpMaterialAttribute3D(new ImpMaterialAttribute3D(rColor)) { } - materialAttribute3D::materialAttribute3D() - : mpMaterialAttribute3D(new impMaterialAttribute3D()) + MaterialAttribute3D::MaterialAttribute3D() + : mpMaterialAttribute3D(new ImpMaterialAttribute3D()) { } - materialAttribute3D::materialAttribute3D(const materialAttribute3D& rCandidate) + MaterialAttribute3D::MaterialAttribute3D(const MaterialAttribute3D& rCandidate) : mpMaterialAttribute3D(rCandidate.mpMaterialAttribute3D) { mpMaterialAttribute3D->mnRefCount++; } - materialAttribute3D::~materialAttribute3D() + MaterialAttribute3D::~MaterialAttribute3D() { if(mpMaterialAttribute3D->mnRefCount) { @@ -138,7 +138,7 @@ namespace drawinglayer } } - materialAttribute3D& materialAttribute3D::operator=(const materialAttribute3D& rCandidate) + MaterialAttribute3D& MaterialAttribute3D::operator=(const MaterialAttribute3D& rCandidate) { if(rCandidate.mpMaterialAttribute3D != mpMaterialAttribute3D) { @@ -158,7 +158,7 @@ namespace drawinglayer return *this; } - bool materialAttribute3D::operator==(const materialAttribute3D& rCandidate) const + bool MaterialAttribute3D::operator==(const MaterialAttribute3D& rCandidate) const { if(rCandidate.mpMaterialAttribute3D == mpMaterialAttribute3D) { @@ -168,22 +168,22 @@ namespace drawinglayer return (*rCandidate.mpMaterialAttribute3D == *mpMaterialAttribute3D); } - const basegfx::BColor& materialAttribute3D::getColor() const + const basegfx::BColor& MaterialAttribute3D::getColor() const { return mpMaterialAttribute3D->getColor(); } - const basegfx::BColor& materialAttribute3D::getSpecular() const + const basegfx::BColor& MaterialAttribute3D::getSpecular() const { return mpMaterialAttribute3D->getSpecular(); } - const basegfx::BColor& materialAttribute3D::getEmission() const + const basegfx::BColor& MaterialAttribute3D::getEmission() const { return mpMaterialAttribute3D->getEmission(); } - sal_uInt16 materialAttribute3D::getSpecularIntensity() const + sal_uInt16 MaterialAttribute3D::getSpecularIntensity() const { return mpMaterialAttribute3D->getSpecularIntensity(); } diff --git a/drawinglayer/source/attribute/sdrallattribute3d.cxx b/drawinglayer/source/attribute/sdrallattribute3d.cxx index 1ac32323c7ef..2fa01f0ec661 100644 --- a/drawinglayer/source/attribute/sdrallattribute3d.cxx +++ b/drawinglayer/source/attribute/sdrallattribute3d.cxx @@ -4,9 +4,9 @@ * * $RCSfile: sdrallattribute3d.cxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: aw $ $Date: 2006-08-09 16:47:33 $ + * last change: $Author: aw $ $Date: 2006-10-19 10:36:13 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -33,15 +33,15 @@ * ************************************************************************/ -#ifndef _DRAWINGLAYER_ATTRIBUTE_SDRALLATTRIBUTE3D_HXX +#ifndef INCLUDED_DRAWINGLAYER_ATTRIBUTE_SDRALLATTRIBUTE3D_HXX #include <drawinglayer/attribute/sdrallattribute3d.hxx> #endif -#ifndef _DRAWINGLAYER_ATTRIBUTE_SDRATTRIBUTE_HXX +#ifndef INCLUDED_DRAWINGLAYER_ATTRIBUTE_SDRATTRIBUTE_HXX #include <drawinglayer/attribute/sdrattribute.hxx> #endif -#ifndef _DRAWINGLAYER_ATTRIBUTE_FILLATTRIBUTE_HXX +#ifndef INCLUDED_DRAWINGLAYER_ATTRIBUTE_FILLATTRIBUTE_HXX #include <drawinglayer/attribute/fillattribute.hxx> #endif @@ -55,12 +55,12 @@ namespace drawinglayer { namespace attribute { - sdrLineFillShadowAttribute::sdrLineFillShadowAttribute( - sdrLineAttribute* pLine, - sdrFillAttribute* pFill, - sdrLineStartEndAttribute* pLineStartEnd, - sdrShadowAttribute* pShadow, - fillGradientAttribute* pFillFloatTransGradient) + SdrLineFillShadowAttribute::SdrLineFillShadowAttribute( + SdrLineAttribute* pLine, + SdrFillAttribute* pFill, + SdrLineStartEndAttribute* pLineStartEnd, + SdrShadowAttribute* pShadow, + FillGradientAttribute* pFillFloatTransGradient) : mpShadow(pShadow), mpLine(pLine), mpLineStartEnd(pLineStartEnd), @@ -69,7 +69,7 @@ namespace drawinglayer { } - sdrLineFillShadowAttribute::sdrLineFillShadowAttribute(const sdrLineFillShadowAttribute& rCandidate) + SdrLineFillShadowAttribute::SdrLineFillShadowAttribute(const SdrLineFillShadowAttribute& rCandidate) : mpShadow(0L), mpLine(0L), mpLineStartEnd(0L), @@ -82,7 +82,7 @@ namespace drawinglayer } } - sdrLineFillShadowAttribute::~sdrLineFillShadowAttribute() + SdrLineFillShadowAttribute::~SdrLineFillShadowAttribute() { delete mpShadow; delete mpLine; @@ -91,7 +91,7 @@ namespace drawinglayer delete mpFillFloatTransGradient; } - sdrLineFillShadowAttribute& sdrLineFillShadowAttribute::operator=(const sdrLineFillShadowAttribute& rCandidate) + SdrLineFillShadowAttribute& SdrLineFillShadowAttribute::operator=(const SdrLineFillShadowAttribute& rCandidate) { // handle mpShadow { @@ -105,7 +105,7 @@ namespace drawinglayer // copy mpShadow if necessary if(!mpShadow && rCandidate.mpShadow) { - mpShadow = new sdrShadowAttribute(*rCandidate.mpShadow); + mpShadow = new SdrShadowAttribute(*rCandidate.mpShadow); } } @@ -121,7 +121,7 @@ namespace drawinglayer // copy mpLine if necessary if(!mpLine && rCandidate.mpLine) { - mpLine = new sdrLineAttribute(*rCandidate.mpLine); + mpLine = new SdrLineAttribute(*rCandidate.mpLine); } } @@ -137,7 +137,7 @@ namespace drawinglayer // copy mpLineStartEnd if necessary if(!mpLineStartEnd && rCandidate.mpLineStartEnd) { - mpLineStartEnd = new sdrLineStartEndAttribute(*rCandidate.mpLineStartEnd); + mpLineStartEnd = new SdrLineStartEndAttribute(*rCandidate.mpLineStartEnd); } } @@ -153,7 +153,7 @@ namespace drawinglayer // copy mpFill if necessary if(!mpFill && rCandidate.mpFill) { - mpFill = new sdrFillAttribute(*rCandidate.mpFill); + mpFill = new SdrFillAttribute(*rCandidate.mpFill); } } @@ -169,14 +169,14 @@ namespace drawinglayer // copy mpFillFloatTransGradient if necessary if(!mpFillFloatTransGradient && rCandidate.mpFillFloatTransGradient) { - mpFillFloatTransGradient = new fillGradientAttribute(*rCandidate.mpFillFloatTransGradient); + mpFillFloatTransGradient = new FillGradientAttribute(*rCandidate.mpFillFloatTransGradient); } } return *this; } - bool sdrLineFillShadowAttribute::operator==(const sdrLineFillShadowAttribute& rCandidate) const + bool SdrLineFillShadowAttribute::operator==(const SdrLineFillShadowAttribute& rCandidate) const { // handle mpShadow if(!pointerOrContentEqual(mpShadow, rCandidate.mpShadow)) diff --git a/drawinglayer/source/attribute/sdrattribute.cxx b/drawinglayer/source/attribute/sdrattribute.cxx index 6c4a8ff84501..0ce4a4f56763 100644 --- a/drawinglayer/source/attribute/sdrattribute.cxx +++ b/drawinglayer/source/attribute/sdrattribute.cxx @@ -4,9 +4,9 @@ * * $RCSfile: sdrattribute.cxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: aw $ $Date: 2006-08-09 16:47:34 $ + * last change: $Author: aw $ $Date: 2006-10-19 10:36:14 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -33,15 +33,15 @@ * ************************************************************************/ -#ifndef _DRAWINGLAYER_ATTRIBUTE_SDRATTRIBUTE_HXX +#ifndef INCLUDED_DRAWINGLAYER_ATTRIBUTE_SDRATTRIBUTE_HXX #include <drawinglayer/attribute/sdrattribute.hxx> #endif -#ifndef _DRAWINGLAYER_ATTRIBUTE_FILLATTRIBUTE_HXX +#ifndef INCLUDED_DRAWINGLAYER_ATTRIBUTE_FILLATTRIBUTE_HXX #include <drawinglayer/attribute/fillattribute.hxx> #endif -#ifndef _DRAWINGLAYER_ATTRIBUTE_SDRFILLBITMAPATTRIBUTE_HXX +#ifndef INCLUDED_DRAWINGLAYER_ATTRIBUTE_SDRFILLBITMAPATTRIBUTE_HXX #include <drawinglayer/attribute/sdrfillbitmapattribute.hxx> #endif @@ -51,7 +51,7 @@ namespace drawinglayer { namespace attribute { - sdrLineAttribute::sdrLineAttribute( + SdrLineAttribute::SdrLineAttribute( basegfx::tools::B2DLineJoin eJoin, double fWidth, double fTransparence, const basegfx::BColor& rColor, const ::std::vector< double >& rDotDashArray, double fFullDotDashLen) : meJoin(eJoin), @@ -63,11 +63,11 @@ namespace drawinglayer { } - sdrLineAttribute::~sdrLineAttribute() + SdrLineAttribute::~SdrLineAttribute() { } - bool sdrLineAttribute::operator==(const sdrLineAttribute& rCandidate) const + bool SdrLineAttribute::operator==(const SdrLineAttribute& rCandidate) const { return (meJoin == rCandidate.meJoin && mfWidth == rCandidate.mfWidth @@ -84,7 +84,7 @@ namespace drawinglayer { namespace attribute { - sdrLineStartEndAttribute::sdrLineStartEndAttribute( + SdrLineStartEndAttribute::SdrLineStartEndAttribute( const basegfx::B2DPolyPolygon& rStartPolyPolygon, const basegfx::B2DPolyPolygon& rEndPolyPolygon, double fStartWidth, double fEndWidth, bool bStartActive, bool bEndActive, bool bStartCentered, bool bEndCentered) : maStartPolyPolygon(rStartPolyPolygon), @@ -98,11 +98,11 @@ namespace drawinglayer { } - sdrLineStartEndAttribute::~sdrLineStartEndAttribute() + SdrLineStartEndAttribute::~SdrLineStartEndAttribute() { } - bool sdrLineStartEndAttribute::operator==(const sdrLineStartEndAttribute& rCandidate) const + bool SdrLineStartEndAttribute::operator==(const SdrLineStartEndAttribute& rCandidate) const { return (mbStartActive == rCandidate.mbStartActive && mbEndActive == rCandidate.mbEndActive @@ -122,18 +122,18 @@ namespace drawinglayer { namespace attribute { - sdrShadowAttribute::sdrShadowAttribute(const basegfx::B2DVector& rOffset, double fTransparence, const basegfx::BColor& rColor) + SdrShadowAttribute::SdrShadowAttribute(const basegfx::B2DVector& rOffset, double fTransparence, const basegfx::BColor& rColor) : maOffset(rOffset), mfTransparence(fTransparence), maColor(rColor) { } - sdrShadowAttribute::~sdrShadowAttribute() + SdrShadowAttribute::~SdrShadowAttribute() { } - bool sdrShadowAttribute::operator==(const sdrShadowAttribute& rCandidate) const + bool SdrShadowAttribute::operator==(const SdrShadowAttribute& rCandidate) const { return (mfTransparence == rCandidate.mfTransparence && maColor == rCandidate.maColor @@ -148,9 +148,12 @@ namespace drawinglayer { namespace attribute { - sdrFillAttribute::sdrFillAttribute( - double fTransparence, const basegfx::BColor& rColor, fillGradientAttribute* pGradient, - fillHatchAttribute* pHatch, sdrFillBitmapAttribute* pBitmap) + SdrFillAttribute::SdrFillAttribute( + double fTransparence, + const basegfx::BColor& rColor, + FillGradientAttribute* pGradient, + FillHatchAttribute* pHatch, + SdrFillBitmapAttribute* pBitmap) : mfTransparence(fTransparence), maColor(rColor), mpGradient(pGradient), @@ -159,7 +162,7 @@ namespace drawinglayer { } - sdrFillAttribute::sdrFillAttribute(const sdrFillAttribute& rCandidate) + SdrFillAttribute::SdrFillAttribute(const SdrFillAttribute& rCandidate) : mfTransparence(1.0), mpGradient(0L), mpHatch(0L), @@ -171,14 +174,14 @@ namespace drawinglayer } } - sdrFillAttribute::~sdrFillAttribute() + SdrFillAttribute::~SdrFillAttribute() { delete mpGradient; delete mpHatch; delete mpBitmap; } - sdrFillAttribute& sdrFillAttribute::operator=(const sdrFillAttribute& rCandidate) + SdrFillAttribute& SdrFillAttribute::operator=(const SdrFillAttribute& rCandidate) { // copy data mfTransparence = rCandidate.mfTransparence; @@ -196,7 +199,7 @@ namespace drawinglayer // copy mpGradient if necessary if(!mpGradient && rCandidate.mpGradient) { - mpGradient = new fillGradientAttribute(*rCandidate.mpGradient); + mpGradient = new FillGradientAttribute(*rCandidate.mpGradient); } } @@ -212,7 +215,7 @@ namespace drawinglayer // copy mpHatch if necessary if(!mpHatch && rCandidate.mpHatch) { - mpHatch = new fillHatchAttribute(*rCandidate.mpHatch); + mpHatch = new FillHatchAttribute(*rCandidate.mpHatch); } } @@ -228,14 +231,14 @@ namespace drawinglayer // copy mpBitmap if necessary if(!mpBitmap && rCandidate.mpBitmap) { - mpBitmap = new sdrFillBitmapAttribute(*rCandidate.mpBitmap); + mpBitmap = new SdrFillBitmapAttribute(*rCandidate.mpBitmap); } } return *this; } - bool sdrFillAttribute::operator==(const sdrFillAttribute& rCandidate) const + bool SdrFillAttribute::operator==(const SdrFillAttribute& rCandidate) const { if(mfTransparence != rCandidate.mfTransparence) return false; diff --git a/drawinglayer/source/attribute/sdrattribute3d.cxx b/drawinglayer/source/attribute/sdrattribute3d.cxx index ccbe27181256..831e23484c40 100644 --- a/drawinglayer/source/attribute/sdrattribute3d.cxx +++ b/drawinglayer/source/attribute/sdrattribute3d.cxx @@ -4,9 +4,9 @@ * * $RCSfile: sdrattribute3d.cxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: aw $ $Date: 2006-08-09 16:47:34 $ + * last change: $Author: aw $ $Date: 2006-10-19 10:36:14 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -33,7 +33,7 @@ * ************************************************************************/ -#ifndef _DRAWINGLAYER_ATTRIBUTE_SDRATTRIBUTE3D_HXX +#ifndef INCLUDED_DRAWINGLAYER_ATTRIBUTE_SDRATTRIBUTE3D_HXX #include <drawinglayer/attribute/sdrattribute3d.hxx> #endif @@ -43,13 +43,13 @@ namespace drawinglayer { namespace attribute { - sdr3DObjectAttribute::sdr3DObjectAttribute( + Sdr3DObjectAttribute::Sdr3DObjectAttribute( ::com::sun::star::drawing::NormalsKind aNormalsKind, ::com::sun::star::drawing::TextureProjectionMode aTextureProjectionX, ::com::sun::star::drawing::TextureProjectionMode aTextureProjectionY, ::com::sun::star::drawing::TextureKind2 aTextureKind, ::com::sun::star::drawing::TextureMode aTextureMode, - const materialAttribute3D& rMaterial, + const MaterialAttribute3D& rMaterial, bool bNormalsInvert, bool bDoubleSided, bool bShadow3D, @@ -67,22 +67,18 @@ namespace drawinglayer { } - sdr3DObjectAttribute::~sdr3DObjectAttribute() - { - } - - bool sdr3DObjectAttribute::operator==(const sdr3DObjectAttribute& rCandidate) const + bool Sdr3DObjectAttribute::operator==(const Sdr3DObjectAttribute& rCandidate) const { return (maNormalsKind == rCandidate.maNormalsKind - && maTextureProjectionX == rCandidate.maTextureProjectionX - && maTextureProjectionY == rCandidate.maTextureProjectionY - && maTextureKind == rCandidate.maTextureKind - && maTextureMode == rCandidate.maTextureMode - && maMaterial == rCandidate.maMaterial - && mbNormalsInvert == rCandidate.mbNormalsInvert - && mbDoubleSided == rCandidate.mbDoubleSided - && mbShadow3D == rCandidate.mbShadow3D - && mbTextureFilter == rCandidate.mbTextureFilter); + && maTextureProjectionX == rCandidate.maTextureProjectionX + && maTextureProjectionY == rCandidate.maTextureProjectionY + && maTextureKind == rCandidate.maTextureKind + && maTextureMode == rCandidate.maTextureMode + && maMaterial == rCandidate.maMaterial + && mbNormalsInvert == rCandidate.mbNormalsInvert + && mbDoubleSided == rCandidate.mbDoubleSided + && mbShadow3D == rCandidate.mbShadow3D + && mbTextureFilter == rCandidate.mbTextureFilter); } } // end of namespace attribute } // end of namespace drawinglayer @@ -93,18 +89,14 @@ namespace drawinglayer { namespace attribute { - sdr3DLightAttribute::sdr3DLightAttribute(const basegfx::BColor& rColor, const basegfx::B3DVector& rDirection, bool bSpecular) + Sdr3DLightAttribute::Sdr3DLightAttribute(const basegfx::BColor& rColor, const basegfx::B3DVector& rDirection, bool bSpecular) : maColor(rColor), maDirection(rDirection), mbSpecular(bSpecular) { } - sdr3DLightAttribute::~sdr3DLightAttribute() - { - } - - bool sdr3DLightAttribute::operator==(const sdr3DLightAttribute& rCandidate) const + bool Sdr3DLightAttribute::operator==(const Sdr3DLightAttribute& rCandidate) const { return (maColor == rCandidate.maColor && maDirection == rCandidate.maDirection @@ -119,26 +111,22 @@ namespace drawinglayer { namespace attribute { - sdrLightingAttribute::sdrLightingAttribute( + SdrLightingAttribute::SdrLightingAttribute( const basegfx::BColor& rAmbientLight, - const ::std::vector< sdr3DLightAttribute >& rLightVector) + const ::std::vector< Sdr3DLightAttribute >& rLightVector) : maAmbientLight(rAmbientLight), maLightVector(rLightVector) { } - sdrLightingAttribute::~sdrLightingAttribute() - { - } - - bool sdrLightingAttribute::operator==(const sdrLightingAttribute& rCandidate) const + bool SdrLightingAttribute::operator==(const SdrLightingAttribute& rCandidate) const { return (maAmbientLight == rCandidate.maAmbientLight && maLightVector == rCandidate.maLightVector); } // color model solver - basegfx::BColor sdrLightingAttribute::solveColorModel( + basegfx::BColor SdrLightingAttribute::solveColorModel( const basegfx::B3DVector& rNormalInEyeCoordinates, const basegfx::BColor& rColor, const basegfx::BColor& rSpecular, const basegfx::BColor& rEmission, sal_uInt16 nSpecularIntensity) const @@ -160,7 +148,7 @@ namespace drawinglayer for(sal_uInt32 a(0L); a < nLightCount; a++) { - const sdr3DLightAttribute& rLight(maLightVector[a]); + const Sdr3DLightAttribute& rLight(maLightVector[a]); const double fCosFac(rLight.getDirection().scalar(aEyeNormal)); if(basegfx::fTools::more(fCosFac, 0.0)) @@ -198,7 +186,7 @@ namespace drawinglayer { namespace attribute { - sdrSceneAttribute::sdrSceneAttribute( + SdrSceneAttribute::SdrSceneAttribute( double fDistance, double fShadowSlant, ::com::sun::star::drawing::ProjectionMode aProjectionMode, @@ -212,11 +200,7 @@ namespace drawinglayer { } - sdrSceneAttribute::~sdrSceneAttribute() - { - } - - bool sdrSceneAttribute::operator==(const sdrSceneAttribute& rCandidate) const + bool SdrSceneAttribute::operator==(const SdrSceneAttribute& rCandidate) const { return (mfDistance == rCandidate.mfDistance && mfShadowSlant == rCandidate.mfShadowSlant diff --git a/drawinglayer/source/attribute/sdrfillbitmapattribute.cxx b/drawinglayer/source/attribute/sdrfillbitmapattribute.cxx index 4f7e8b5947a2..afa2ee17f261 100644 --- a/drawinglayer/source/attribute/sdrfillbitmapattribute.cxx +++ b/drawinglayer/source/attribute/sdrfillbitmapattribute.cxx @@ -4,9 +4,9 @@ * * $RCSfile: sdrfillbitmapattribute.cxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: aw $ $Date: 2006-08-09 16:47:34 $ + * last change: $Author: aw $ $Date: 2006-10-19 10:36:14 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -33,11 +33,11 @@ * ************************************************************************/ -#ifndef _DRAWINGLAYER_ATTRIBUTE_SDRFILLBITMAPATTRIBUTE_HXX +#ifndef INCLUDED_DRAWINGLAYER_ATTRIBUTE_SDRFILLBITMAPATTRIBUTE_HXX #include <drawinglayer/attribute/sdrfillbitmapattribute.hxx> #endif -#ifndef _DRAWINGLAYER_ATTRIBUTE_FILLBITMAPATTRIBUTE_HXX +#ifndef INCLUDED_DRAWINGLAYER_ATTRIBUTE_FILLBITMAPATTRIBUTE_HXX #include <drawinglayer/attribute/fillbitmapattribute.hxx> #endif @@ -55,7 +55,7 @@ namespace drawinglayer { namespace attribute { - sdrFillBitmapAttribute::sdrFillBitmapAttribute( + SdrFillBitmapAttribute::SdrFillBitmapAttribute( const Bitmap& rBitmap, const basegfx::B2DVector& rSize, const basegfx::B2DVector& rOffset, const basegfx::B2DVector& rOffsetPosition, const basegfx::B2DVector& rRectPoint, bool bTiling, bool bStretch, bool bLogSize) @@ -70,7 +70,7 @@ namespace drawinglayer { } - bool sdrFillBitmapAttribute::operator==(const sdrFillBitmapAttribute& rCandidate) const + bool SdrFillBitmapAttribute::operator==(const SdrFillBitmapAttribute& rCandidate) const { return (maBitmap == rCandidate.maBitmap && maSize == rCandidate.maSize @@ -82,7 +82,7 @@ namespace drawinglayer && mbLogSize == rCandidate.mbLogSize); } - fillBitmapAttribute sdrFillBitmapAttribute::getFillBitmapAttribute(const basegfx::B2DRange& rRange) const + FillBitmapAttribute SdrFillBitmapAttribute::getFillBitmapAttribute(const basegfx::B2DRange& rRange) const { // get logical size of bitmap (before expanding eventually) Bitmap aBitmap(maBitmap); @@ -236,7 +236,7 @@ namespace drawinglayer aBitmapSize.setY(aBitmapSize.getY() / fRangeHeight); } - return fillBitmapAttribute(aBitmap, aBitmapTopLeft, aBitmapSize, mbTiling); + return FillBitmapAttribute(aBitmap, aBitmapTopLeft, aBitmapSize, mbTiling); } } // end of namespace attribute } // end of namespace drawinglayer diff --git a/drawinglayer/source/geometry/makefile.mk b/drawinglayer/source/geometry/makefile.mk index 3e1f2074a5b6..5c52333c57ae 100644 --- a/drawinglayer/source/geometry/makefile.mk +++ b/drawinglayer/source/geometry/makefile.mk @@ -4,9 +4,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.1 $ +# $Revision: 1.2 $ # -# last change: $Author: aw $ $Date: 2006-05-12 11:49:41 $ +# last change: $Author: aw $ $Date: 2006-10-19 10:36:46 $ # # The Contents of this file are made available subject to # the terms of GNU Lesser General Public License Version 2.1. @@ -44,8 +44,8 @@ TARGET=geometry # --- Files ------------------------------------- SLOFILES= \ - $(SLO)$/viewinformation.obj \ - $(SLO)$/transformation3d.obj + $(SLO)$/transformation3d.obj \ + $(SLO)$/viewinformation2d.obj # --- Targets ---------------------------------- diff --git a/drawinglayer/source/geometry/viewinformation2d.cxx b/drawinglayer/source/geometry/viewinformation2d.cxx new file mode 100644 index 000000000000..0ad71b94dd80 --- /dev/null +++ b/drawinglayer/source/geometry/viewinformation2d.cxx @@ -0,0 +1,267 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: viewinformation2d.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-10-19 10:40:02 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef INCLUDED_DRAWINGLAYER_GEOMETRY_VIEWINFORMATION2D_HXX +#include <drawinglayer/geometry/viewinformation2d.hxx> +#endif + +#ifndef _BGFX_MATRIX_B2DHOMMATRIX_HXX +#include <basegfx/matrix/b2dhommatrix.hxx> +#endif + +#ifndef _BGFX_RANGE_B2DRANGE_HXX +#include <basegfx/range/b2drange.hxx> +#endif + +#ifndef _OSL_MUTEX_HXX_ +#include <osl/mutex.hxx> +#endif + +#ifndef _BGFX_TOOLS_CANVASTOOLS_HXX +#include <basegfx/tools/canvastools.hxx> +#endif + +#ifndef _COM_SUN_STAR_GRAPHIC_PRIMITIVE2DPARAMETERS_HPP_ +#include "com/sun/star/graphic/Primitive2DParameters.hpp" +#endif + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace + { + class ImpViewInformation2D + { + private: + // ViewInformation2D implementation can change refcount, so we have only + // two memory regions for pairs of ViewInformation2D/ImpViewInformation2D + friend class ::drawinglayer::geometry::ViewInformation2D; + + // the refcounter + sal_uInt32 mnRefCount; + + protected: + // the view transformation + ::basegfx::B2DHomMatrix maViewTransformation; + ::basegfx::B2DHomMatrix maInverseViewTransformation; + + // the visible ranges + ::basegfx::B2DRange maViewport; + ::basegfx::B2DRange maDiscreteViewport; + + // the point in time + double mfViewTime; + + // bitfield + unsigned mbInverseValid : 1; + unsigned mbDiscreteViewportValid : 1; + + public: + ImpViewInformation2D( + const ::basegfx::B2DHomMatrix& rViewTransformation, + const ::basegfx::B2DRange& rViewport, + double fViewTime) + : mnRefCount(0L), + maViewTransformation(rViewTransformation), + maInverseViewTransformation(maViewTransformation), + maViewport(rViewport), + maDiscreteViewport(), + mfViewTime(fViewTime), + mbInverseValid(false), + mbDiscreteViewportValid(false) + { + } + + ImpViewInformation2D( + const ::com::sun::star::graphic::Primitive2DParameters& rParams) + : mnRefCount(0L), + maViewTransformation(basegfx::unotools::homMatrixFromAffineMatrix(rParams.ViewTransformation)), + maInverseViewTransformation(maViewTransformation), + maViewport(basegfx::unotools::b2DRectangleFromRealRectangle2D(rParams.Viewport)), + maDiscreteViewport(), + mfViewTime(rParams.Time), + mbInverseValid(false), + mbDiscreteViewportValid(false) + { + } + + bool operator==(const ImpViewInformation2D& rCandidate) const + { + return (maViewTransformation == rCandidate.maViewTransformation + && mfViewTime == rCandidate.mfViewTime + && maViewport == rCandidate.maViewport); + } + + const ::basegfx::B2DHomMatrix& getViewTransformation() const { return maViewTransformation; } + + const ::basegfx::B2DRange& getViewport() const { return maViewport; } + + const ::basegfx::B2DRange& getDiscreteViewport() const + { + ::osl::Mutex m_mutex; + + if(!mbDiscreteViewportValid) + { + ::basegfx::B2DRange aDiscreteViewport(maViewport); + aDiscreteViewport.transform(getViewTransformation()); + const_cast< ImpViewInformation2D* >(this)->maDiscreteViewport = aDiscreteViewport; + const_cast< ImpViewInformation2D* >(this)->mbDiscreteViewportValid = true; + } + + return maDiscreteViewport; + } + + const ::basegfx::B2DHomMatrix& getInverseViewTransformation() const + { + ::osl::Mutex m_mutex; + + if(!mbInverseValid) + { + const_cast< ImpViewInformation2D* >(this)->maInverseViewTransformation.invert(); + const_cast< ImpViewInformation2D* >(this)->mbInverseValid = true; + } + + return maInverseViewTransformation; + } + + double getViewTime() const { return mfViewTime; } + }; + } // end of anonymous namespace +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace geometry + { + ViewInformation2D::ViewInformation2D( + const ::basegfx::B2DHomMatrix& rViewTransformation, + const ::basegfx::B2DRange& rViewport, + double fViewTime) + : mpViewInformation2D(new ImpViewInformation2D(rViewTransformation, rViewport, fViewTime)) + { + } + + ViewInformation2D::ViewInformation2D( + const ::com::sun::star::graphic::Primitive2DParameters& rParams) + : mpViewInformation2D(new ImpViewInformation2D(rParams)) + { + } + + ViewInformation2D::ViewInformation2D( + const ViewInformation2D& rCandidate) + : mpViewInformation2D(rCandidate.mpViewInformation2D) + { + ::osl::Mutex m_mutex; + mpViewInformation2D->mnRefCount++; + } + + ViewInformation2D::~ViewInformation2D() + { + ::osl::Mutex m_mutex; + + if(mpViewInformation2D->mnRefCount) + { + mpViewInformation2D->mnRefCount--; + } + else + { + delete mpViewInformation2D; + } + } + + ViewInformation2D& ViewInformation2D::operator=(const ViewInformation2D& rCandidate) + { + ::osl::Mutex m_mutex; + + if(rCandidate.mpViewInformation2D != mpViewInformation2D) + { + if(mpViewInformation2D->mnRefCount) + { + mpViewInformation2D->mnRefCount--; + } + else + { + delete mpViewInformation2D; + } + + mpViewInformation2D = rCandidate.mpViewInformation2D; + mpViewInformation2D->mnRefCount++; + } + + return *this; + } + + bool ViewInformation2D::operator==(const ViewInformation2D& rCandidate) const + { + if(rCandidate.mpViewInformation2D == mpViewInformation2D) + { + return true; + } + + return (*rCandidate.mpViewInformation2D == *mpViewInformation2D); + } + + const ::basegfx::B2DHomMatrix& ViewInformation2D::getViewTransformation() const + { + return mpViewInformation2D->getViewTransformation(); + } + + const ::basegfx::B2DRange& ViewInformation2D::getViewport() const + { + return mpViewInformation2D->getViewport(); + } + + const ::basegfx::B2DRange& ViewInformation2D::getDiscreteViewport() const + { + return mpViewInformation2D->getDiscreteViewport(); + } + + const ::basegfx::B2DHomMatrix& ViewInformation2D::getInverseViewTransformation() const + { + return mpViewInformation2D->getInverseViewTransformation(); + } + + double ViewInformation2D::getViewTime() const + { + return mpViewInformation2D->getViewTime(); + } + } // end of namespace geometry +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/primitive2d/alphaprimitive2d.cxx b/drawinglayer/source/primitive2d/alphaprimitive2d.cxx new file mode 100644 index 000000000000..5aedcead73b5 --- /dev/null +++ b/drawinglayer/source/primitive2d/alphaprimitive2d.cxx @@ -0,0 +1,78 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: alphaprimitive2d.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-10-19 10:35:01 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_ALPHAPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/alphaprimitive2d.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// + +using namespace com::sun::star; + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + AlphaPrimitive2D::AlphaPrimitive2D( + const Primitive2DSequence& rChildren, + const Primitive2DSequence& rAlpha) + : GroupPrimitive2D(rChildren), + maAlpha(rAlpha) + { + } + + bool AlphaPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const + { + if(GroupPrimitive2D::operator==(rPrimitive)) + { + const AlphaPrimitive2D& rCompare = (AlphaPrimitive2D&)rPrimitive; + + return (getAlpha() == rCompare.getAlpha()); + } + + return false; + } + + sal_uInt32 AlphaPrimitive2D::getPrimitiveID() const + { + return Create2DPrimitiveID('2','A','l','p'); + } + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/primitive2d/animatedprimitive2d.cxx b/drawinglayer/source/primitive2d/animatedprimitive2d.cxx new file mode 100644 index 000000000000..18e39d7e086a --- /dev/null +++ b/drawinglayer/source/primitive2d/animatedprimitive2d.cxx @@ -0,0 +1,256 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: animatedprimitive2d.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-10-19 10:35:01 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_ANIMATEDPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/animatedprimitive2d.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_ANIMATION_ANIMATIONTIMING_HXX +#include <drawinglayer/animation/animationtiming.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_TRANSFORMPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/transformprimitive2d.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_GEOMETRY_VIEWINFORMATION2D_HXX +#include <drawinglayer/geometry/viewinformation2d.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// + +using namespace com::sun::star; + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + Primitive2DSequence AnimatedSwitchPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const + { + if(getChildren().hasElements()) + { + const double fState(getAnimationEntry().getStateAtTime(rViewInformation.getViewTime())); + const sal_Int32 nLen(getChildren().getLength()); + sal_Int32 nIndex(basegfx::fround(fState * (double)nLen)); + + if(nIndex >= nLen) + { + nIndex = nLen - 1L; + } + + const Primitive2DReference xRef(getChildren()[nIndex], uno::UNO_QUERY_THROW); + return Primitive2DSequence(&xRef, 1L); + } + + return Primitive2DSequence(); + } + + AnimatedSwitchPrimitive2D::AnimatedSwitchPrimitive2D( + const animation::AnimationEntry& rAnimationEntry, + const Primitive2DSequence& rChildren, + bool bIsTextAnimation) + : GroupPrimitive2D(rChildren), + mpAnimationEntry(0), + mfDecomposeViewTime(0.0), + mbIsTextAnimation(bIsTextAnimation) + { + // clone given animation description + mpAnimationEntry = rAnimationEntry.clone(); + } + + AnimatedSwitchPrimitive2D::~AnimatedSwitchPrimitive2D() + { + // delete cloned animation description + delete mpAnimationEntry; + } + + bool AnimatedSwitchPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const + { + if(GroupPrimitive2D::operator==(rPrimitive)) + { + const AnimatedSwitchPrimitive2D& rCompare = static_cast< const AnimatedSwitchPrimitive2D& >(rPrimitive); + + return (getAnimationEntry() == rCompare.getAnimationEntry()); + } + + return false; + } + + Primitive2DSequence AnimatedSwitchPrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const + { + ::osl::MutexGuard aGuard( m_aMutex ); + + if(getLocalDecomposition().hasElements() && mfDecomposeViewTime != rViewInformation.getViewTime()) + { + // conditions of last local decomposition have changed, delete + const_cast< AnimatedSwitchPrimitive2D* >(this)->setLocalDecomposition(Primitive2DSequence()); + } + + if(!getLocalDecomposition().hasElements()) + { + // remember time + const_cast< AnimatedSwitchPrimitive2D* >(this)->mfDecomposeViewTime = rViewInformation.getViewTime(); + } + + // use parent implementation + return GroupPrimitive2D::get2DDecomposition(rViewInformation); + } + + basegfx::B2DRange AnimatedSwitchPrimitive2D::getB2DRange(const geometry::ViewInformation2D& rViewInformation) const + { + // to get range from decomposition and not from group content, call implementation from + // BasePrimitive2D here + return BasePrimitive2D::getB2DRange(rViewInformation); + } + + sal_uInt32 AnimatedSwitchPrimitive2D::getPrimitiveID() const + { + return Create2DPrimitiveID('2','A','S','w'); + } + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + Primitive2DSequence AnimatedBlinkPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const + { + if(getChildren().hasElements()) + { + const double fState(getAnimationEntry().getStateAtTime(rViewInformation.getViewTime())); + + if(fState < 0.5) + { + return getChildren(); + } + } + + return Primitive2DSequence(); + } + + AnimatedBlinkPrimitive2D::AnimatedBlinkPrimitive2D( + const animation::AnimationEntry& rAnimationEntry, + const Primitive2DSequence& rChildren, + bool bIsTextAnimation) + : AnimatedSwitchPrimitive2D(rAnimationEntry, rChildren, bIsTextAnimation) + { + } + + sal_uInt32 AnimatedBlinkPrimitive2D::getPrimitiveID() const + { + return Create2DPrimitiveID('2','A','B','l'); + } + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + Primitive2DSequence AnimatedInterpolatePrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const + { + // ensure matrices are decomposed + if(!mbDecomposed) + { + const_cast< AnimatedInterpolatePrimitive2D* >(this)->implDecompose(); + } + + // create state at time + double fState(getAnimationEntry().getStateAtTime(rViewInformation.getViewTime())); + + if(fState < 0.0) + { + fState = 0.0; + } + + if(fState > 1.0) + { + fState = 1.0; + } + + // interpolate for state + basegfx::B2DVector aScale(basegfx::interpolate(maScaleA, maScaleB, fState)); + basegfx::B2DVector aTranslate(basegfx::interpolate(maTranslateA, maTranslateB, fState)); + const double fRotate(((mfRotateB - mfRotateA) * fState) + mfRotateA); + const double fShearX(((mfShearXB - mfShearXA) * fState) + mfShearXA); + + // build matrix for state + basegfx::B2DHomMatrix aMergedTransform; + aMergedTransform.scale(aScale.getX(), aScale.getY()); + aMergedTransform.shearX(fShearX); + aMergedTransform.rotate(fRotate); + aMergedTransform.translate(aTranslate.getX(), aTranslate.getY()); + + // create new transform primitive reference, return new sequence + const Primitive2DReference xRef(new TransformPrimitive2D(aMergedTransform, getChildren())); + return Primitive2DSequence(&xRef, 1L); + } + + void AnimatedInterpolatePrimitive2D::implDecompose() + { + maStart.decompose(maScaleA, maTranslateA, mfRotateA, mfShearXA); + maStop.decompose(maScaleB, maTranslateB, mfRotateB, mfShearXB); + mbDecomposed = true; + } + + AnimatedInterpolatePrimitive2D::AnimatedInterpolatePrimitive2D( + const animation::AnimationEntry& rAnimationEntry, + const Primitive2DSequence& rChildren, + const basegfx::B2DHomMatrix& rStart, + const basegfx::B2DHomMatrix& rStop, + bool bIsTextAnimation) + : AnimatedSwitchPrimitive2D(rAnimationEntry, rChildren, bIsTextAnimation), + maStart(rStart), + maStop(rStop), + mbDecomposed(false) + { + } + + sal_uInt32 AnimatedInterpolatePrimitive2D::getPrimitiveID() const + { + return Create2DPrimitiveID('2','A','I','n'); + } + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/primitive2d/backgroundcolorprimitive2d.cxx b/drawinglayer/source/primitive2d/backgroundcolorprimitive2d.cxx new file mode 100644 index 000000000000..644cd916da56 --- /dev/null +++ b/drawinglayer/source/primitive2d/backgroundcolorprimitive2d.cxx @@ -0,0 +1,138 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: backgroundcolorprimitive2d.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-10-19 10:35:01 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_BACKGROUNDCOLORPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/backgroundcolorprimitive2d.hxx> +#endif + +#ifndef _BGFX_POLYGON_B2DPOLYGON_HXX +#include <basegfx/polygon/b2dpolygon.hxx> +#endif + +#ifndef _BGFX_POLYGON_B2DPOLYGONTOOLS_HXX +#include <basegfx/polygon/b2dpolygontools.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_POLYPOLYGONPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx> +#endif + +#ifndef _BGFX_TOOLS_CANVASTOOLS_HXX +#include <basegfx/tools/canvastools.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_GEOMETRY_VIEWINFORMATION2D_HXX +#include <drawinglayer/geometry/viewinformation2d.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// + +using namespace com::sun::star; + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + Primitive2DSequence BackgroundColorPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const + { + if(!rViewInformation.getViewport().isEmpty()) + { + const basegfx::B2DPolygon aOutline(basegfx::tools::createPolygonFromRect(rViewInformation.getViewport())); + const Primitive2DReference xRef(new PolyPolygonColorPrimitive2D(basegfx::B2DPolyPolygon(aOutline), getBColor())); + return Primitive2DSequence(&xRef, 1L); + } + else + { + return Primitive2DSequence(); + } + } + + BackgroundColorPrimitive2D::BackgroundColorPrimitive2D( + const basegfx::BColor& rBColor) + : BasePrimitive2D(), + maBColor(rBColor), + maLastViewport() + { + } + + bool BackgroundColorPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const + { + if(BasePrimitive2D::operator==(rPrimitive)) + { + const BackgroundColorPrimitive2D& rCompare = (BackgroundColorPrimitive2D&)rPrimitive; + + return (getBColor() == rCompare.getBColor()); + } + + return false; + } + + basegfx::B2DRange BackgroundColorPrimitive2D::getB2DRange(const geometry::ViewInformation2D& rViewInformation) const + { + // always as big as the view + return rViewInformation.getViewport(); + } + + sal_uInt32 BackgroundColorPrimitive2D::getPrimitiveID() const + { + return Create2DPrimitiveID('2','B','C','o'); + } + + Primitive2DSequence BackgroundColorPrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const + { + ::osl::MutexGuard aGuard( m_aMutex ); + + if(getLocalDecomposition().hasElements() && (maLastViewport != rViewInformation.getViewport())) + { + // conditions of last local decomposition have changed, delete + const_cast< BackgroundColorPrimitive2D* >(this)->setLocalDecomposition(Primitive2DSequence()); + } + + if(!getLocalDecomposition().hasElements()) + { + // remember ViewRange + const_cast< BackgroundColorPrimitive2D* >(this)->maLastViewport = rViewInformation.getViewport(); + } + + // use parent implementation + return BasePrimitive2D::get2DDecomposition(rViewInformation); + } + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/primitive2d/baseprimitive2d.cxx b/drawinglayer/source/primitive2d/baseprimitive2d.cxx new file mode 100644 index 000000000000..2865904aa828 --- /dev/null +++ b/drawinglayer/source/primitive2d/baseprimitive2d.cxx @@ -0,0 +1,274 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: baseprimitive2d.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-10-19 10:35:02 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_BASEPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/baseprimitive2d.hxx> +#endif + +#ifndef _BGFX_TOOLS_CANVASTOOLS_HXX +#include <basegfx/tools/canvastools.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_GEOMETRY_VIEWINFORMATION2D_HXX +#include <drawinglayer/geometry/viewinformation2d.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// + +using namespace com::sun::star; + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + Primitive2DSequence BasePrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + { + return Primitive2DSequence(); + } + + BasePrimitive2D::BasePrimitive2D() + : BasePrimitive2DImplBase(m_aMutex), + maLocalDecomposition() + { + } + + bool BasePrimitive2D::operator==( const BasePrimitive2D& rPrimitive ) const + { + return (getPrimitiveID() == rPrimitive.getPrimitiveID()); + } + + basegfx::B2DRange BasePrimitive2D::getB2DRange(const geometry::ViewInformation2D& rViewInformation) const + { + return getB2DRangeFromPrimitive2DSequence(get2DDecomposition(rViewInformation), rViewInformation); + } + + Primitive2DSequence BasePrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const + { + ::osl::MutexGuard aGuard( m_aMutex ); + + if(!getLocalDecomposition().hasElements()) + { + const Primitive2DSequence aNewSequence(createLocalDecomposition(rViewInformation)); + const_cast< BasePrimitive2D* >(this)->setLocalDecomposition(aNewSequence); + } + + return getLocalDecomposition(); + } + + Primitive2DSequence SAL_CALL BasePrimitive2D::getDecomposition( const graphic::Primitive2DParameters& aPrimitive2DParameters ) throw ( uno::RuntimeException ) + { + const geometry::ViewInformation2D aViewInformation(aPrimitive2DParameters); + return get2DDecomposition(aViewInformation); + } + + com::sun::star::geometry::RealRectangle2D SAL_CALL BasePrimitive2D::getRange( const graphic::Primitive2DParameters& aPrimitive2DParameters ) throw ( uno::RuntimeException ) + { + const geometry::ViewInformation2D aViewInformation(aPrimitive2DParameters); + return basegfx::unotools::rectangle2DFromB2DRectangle(getB2DRange(aViewInformation)); + } + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// tooling + +namespace drawinglayer +{ + namespace primitive2d + { + // get B2DRange from a given Primitive2DReference + basegfx::B2DRange getB2DRangeFromPrimitive2DReference(const Primitive2DReference& rCandidate, const geometry::ViewInformation2D& aViewInformation) + { + basegfx::B2DRange aRetval; + + if(rCandidate.is()) + { + // try to get C++ implementation base + const BasePrimitive2D* pCandidate(dynamic_cast< BasePrimitive2D* >(rCandidate.get())); + + if(pCandidate) + { + // use it if possible + aRetval.expand(pCandidate->getB2DRange(aViewInformation)); + } + else + { + // use UNO API call instead + graphic::Primitive2DParameters aPrimitive2DParameters; + + basegfx::unotools::affineMatrixFromHomMatrix(aPrimitive2DParameters.ViewTransformation, aViewInformation.getViewTransformation()); + aPrimitive2DParameters.Viewport = basegfx::unotools::rectangle2DFromB2DRectangle(aViewInformation.getViewport()); + aPrimitive2DParameters.Time = aViewInformation.getViewTime(); + + aRetval.expand(basegfx::unotools::b2DRectangleFromRealRectangle2D(rCandidate->getRange(aPrimitive2DParameters))); + } + } + + return aRetval; + } + + // get B2DRange from a given Primitive2DSequence + basegfx::B2DRange getB2DRangeFromPrimitive2DSequence(const Primitive2DSequence& rCandidate, const geometry::ViewInformation2D& aViewInformation) + { + basegfx::B2DRange aRetval; + + if(rCandidate.hasElements()) + { + const sal_Int32 nCount(rCandidate.getLength()); + + for(sal_Int32 a(0L); a < nCount; a++) + { + aRetval.expand(getB2DRangeFromPrimitive2DReference(rCandidate[a], aViewInformation)); + } + } + + return aRetval; + } + + bool arePrimitive2DReferencesEqual(const Primitive2DReference& rxA, const Primitive2DReference& rxB) + { + const sal_Bool bAIs(rxA.is()); + + if(bAIs != rxB.is()) + { + return false; + } + + if(!bAIs) + { + return true; + } + + const BasePrimitive2D* pA(dynamic_cast< const BasePrimitive2D* >(rxA.get())); + const BasePrimitive2D* pB(dynamic_cast< const BasePrimitive2D* >(rxB.get())); + const bool bAEqualZero(pA == 0L); + + if(bAEqualZero != (pB == 0L)) + { + return false; + } + + if(bAEqualZero) + { + return false; + } + + return (pA->operator==(*pB)); + } + + bool arePrimitive2DSequencesEqual(const Primitive2DSequence& rA, const Primitive2DSequence& rB) + { + const sal_Bool bAHasElements(rA.hasElements()); + + if(bAHasElements != rB.hasElements()) + { + return false; + } + + if(!bAHasElements) + { + return true; + } + + const sal_Int32 nCount(rA.getLength()); + + if(nCount != rB.getLength()) + { + return false; + } + + for(sal_Int32 a(0L); a < nCount; a++) + { + if(!arePrimitive2DReferencesEqual(rA[a], rB[a])) + { + return false; + } + } + + return true; + } + + // concatenate sequence + void appendPrimitive2DSequenceToPrimitive2DSequence(Primitive2DSequence& rDest, const Primitive2DSequence& rSource) + { + if(rSource.hasElements()) + { + if(rDest.hasElements()) + { + const sal_Int32 nSourceCount(rSource.getLength()); + const sal_Int32 nDestCount(rDest.getLength()); + const sal_Int32 nTargetCount(nSourceCount + nDestCount); + sal_Int32 nInsertPos(nDestCount); + + rDest.realloc(nTargetCount); + + for(sal_Int32 a(0L); a < nSourceCount; a++) + { + if(rSource[a].is()) + { + rDest[nInsertPos++] = rSource[a]; + } + } + + if(nInsertPos != nTargetCount) + { + rDest.realloc(nInsertPos); + } + } + else + { + rDest = rSource; + } + } + } + + // concatenate single Primitive2D + void appendPrimitive2DReferenceToPrimitive2DSequence(Primitive2DSequence& rDest, const Primitive2DReference& rSource) + { + if(rSource.is()) + { + const sal_Int32 nDestCount(rDest.getLength()); + rDest.realloc(nDestCount + 1L); + rDest[nDestCount] = rSource; + } + } + + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/primitive2d/bitmapprimitive2d.cxx b/drawinglayer/source/primitive2d/bitmapprimitive2d.cxx new file mode 100644 index 000000000000..c228f57a4ba9 --- /dev/null +++ b/drawinglayer/source/primitive2d/bitmapprimitive2d.cxx @@ -0,0 +1,91 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: bitmapprimitive2d.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-10-19 10:35:02 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_BITMAPPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/bitmapprimitive2d.hxx> +#endif + +#ifndef _BGFX_TOOLS_CANVASTOOLS_HXX +#include <basegfx/tools/canvastools.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// + +using namespace com::sun::star; + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + BitmapPrimitive2D::BitmapPrimitive2D( + const BitmapEx& rBitmapEx, + const basegfx::B2DHomMatrix& rTransform) + : BasePrimitive2D(), + maBitmapEx(rBitmapEx), + maTransform(rTransform) + { + } + + bool BitmapPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const + { + if(BasePrimitive2D::operator==(rPrimitive)) + { + const BitmapPrimitive2D& rCompare = (BitmapPrimitive2D&)rPrimitive; + + return (maBitmapEx == rCompare.maBitmapEx + && maTransform == rCompare.maTransform); + } + + return false; + } + + sal_uInt32 BitmapPrimitive2D::getPrimitiveID() const + { + return Create2DPrimitiveID('2','B','i','t'); + } + + basegfx::B2DRange BitmapPrimitive2D::getB2DRange(const geometry::ViewInformation2D& /*rViewInformation*/) const + { + basegfx::B2DRange aRetval(0.0, 0.0, 1.0, 1.0); + aRetval.transform(maTransform); + return aRetval; + } + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/primitive2d/embedded3dprimitive2d.cxx b/drawinglayer/source/primitive2d/embedded3dprimitive2d.cxx new file mode 100644 index 000000000000..959f9d028d4b --- /dev/null +++ b/drawinglayer/source/primitive2d/embedded3dprimitive2d.cxx @@ -0,0 +1,137 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: embedded3dprimitive2d.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-10-19 10:35:02 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_EMBEDDED3DPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/embedded3dprimitive2d.hxx> +#endif + +#ifndef _BGFX_POLYGON_B2DPOLYGON_HXX +#include <basegfx/polygon/b2dpolygon.hxx> +#endif + +#ifndef _BGFX_POLYGON_B2DPOLYGONTOOLS_HXX +#include <basegfx/polygon/b2dpolygontools.hxx> +#endif + +#ifndef _BGFX_COLOR_BCOLOR_HXX +#include <basegfx/color/bcolor.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_POLYGONPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/polygonprimitive2d.hxx> +#endif + +#ifndef _BGFX_TOOLS_CANVASTOOLS_HXX +#include <basegfx/tools/canvastools.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_GEOMETRY_VIEWINFORMATION2D_HXX +#include <drawinglayer/geometry/viewinformation2d.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// + +using namespace com::sun::star; + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + Primitive2DSequence Embedded3DPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const + { + // use info to create a yellow 2d rectangle, similar to empty 3d scenes and/or groups + basegfx::B3DRange a3DRange(primitive3d::getB3DRangeFromPrimitive3DSequence(getChildren3D(), rViewInformation.getViewTime())); + a3DRange.transform(getTransformation3D().getWorldToView()); + + // create 2d range from projected 3d and transform with scene's object transformation + basegfx::B2DRange a2DRange; + a2DRange.expand(basegfx::B2DPoint(a3DRange.getMinX(), a3DRange.getMinY())); + a2DRange.expand(basegfx::B2DPoint(a3DRange.getMaxX(), a3DRange.getMaxY())); + a2DRange.transform(getTransformation3D().getObjectTransformation()); + + const basegfx::B2DPolygon aOutline(basegfx::tools::createPolygonFromRect(a2DRange)); + const basegfx::BColor aYellow(1.0, 1.0, 0.0); + const Primitive2DReference xRef(new PolygonHairlinePrimitive2D(aOutline, aYellow)); + return Primitive2DSequence(&xRef, 1L); + } + + Embedded3DPrimitive2D::Embedded3DPrimitive2D( + const primitive3d::Primitive3DSequence& rxChildren3D, + const geometry::Transformation3D& rTransformation3D) + : BasePrimitive2D(), + mxChildren3D(rxChildren3D), + maTransformation3D(rTransformation3D) + { + } + + bool Embedded3DPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const + { + if(BasePrimitive2D::operator==(rPrimitive)) + { + const Embedded3DPrimitive2D& rCompare = static_cast< const Embedded3DPrimitive2D& >(rPrimitive); + + return (primitive3d::arePrimitive3DSequencesEqual(getChildren3D(), rCompare.getChildren3D()) + && getTransformation3D() == rCompare.getTransformation3D()); + } + + return false; + } + + sal_uInt32 Embedded3DPrimitive2D::getPrimitiveID() const + { + return Create2DPrimitiveID('2','E','m','b'); + } + + basegfx::B2DRange Embedded3DPrimitive2D::getB2DRange(const geometry::ViewInformation2D& rViewInformation) const + { + // use the 3d transformation stack to create a projection of the 3D range + basegfx::B3DRange a3DRange(primitive3d::getB3DRangeFromPrimitive3DSequence(getChildren3D(), rViewInformation.getViewTime())); + a3DRange.transform(getTransformation3D().getWorldToView()); + + // create 2d range from projected 3d and transform with scene's object transformation + basegfx::B2DRange aRetval; + aRetval.expand(basegfx::B2DPoint(a3DRange.getMinX(), a3DRange.getMinY())); + aRetval.expand(basegfx::B2DPoint(a3DRange.getMaxX(), a3DRange.getMaxY())); + aRetval.transform(getTransformation3D().getObjectTransformation()); + + return aRetval; + } + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/primitive2d/fillbitmapprimitive2d.cxx b/drawinglayer/source/primitive2d/fillbitmapprimitive2d.cxx new file mode 100644 index 000000000000..cabbc2b7afab --- /dev/null +++ b/drawinglayer/source/primitive2d/fillbitmapprimitive2d.cxx @@ -0,0 +1,156 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: fillbitmapprimitive2d.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-10-19 10:35:02 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_FILLBITMAPPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/fillbitmapprimitive2d.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE_BITMAPPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/bitmapprimitive2d.hxx> +#endif + +#ifndef _BGFX_POLYGON_B2DPOLYGON_HXX +#include <basegfx/polygon/b2dpolygon.hxx> +#endif + +#ifndef _BGFX_POLYGON_B2DPOLYGONTOOLS_HXX +#include <basegfx/polygon/b2dpolygontools.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_TEXTURE_TEXTURE_HXX +#include <drawinglayer/texture/texture.hxx> +#endif + +#ifndef _BGFX_TOOLS_CANVASTOOLS_HXX +#include <basegfx/tools/canvastools.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// + +using namespace com::sun::star; + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + Primitive2DSequence FillBitmapPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + { + const Size aTileSizePixel(getFillBitmap().getBitmap().GetSizePixel()); + Primitive2DSequence aRetval; + + // is there a tile with some size at all? + if(aTileSizePixel.getWidth() && aTileSizePixel.getHeight()) + { + if(getFillBitmap().getTiling()) + { + // get object range and create tiling matrices + ::std::vector< basegfx::B2DHomMatrix > aMatrices; + texture::GeoTexSvxTiled aTiling(getFillBitmap().getTopLeft(), getFillBitmap().getSize()); + aTiling.appendTransformations(aMatrices); + + // resize result + aRetval.realloc(aMatrices.size()); + + // create one primitive for each matrix + for(sal_uInt32 a(0L); a < aMatrices.size(); a++) + { + basegfx::B2DHomMatrix aNewMatrix = aMatrices[a]; + aNewMatrix *= getTransformation(); + + // create bitmap primitive and add to result + const Primitive2DReference xRef(new BitmapPrimitive2D(BitmapEx(getFillBitmap().getBitmap()), aNewMatrix)); + aRetval[a] = xRef; + } + } + else + { + // create new object transform + basegfx::B2DHomMatrix aObjectTransform; + aObjectTransform.set(0L, 0L, getFillBitmap().getSize().getX()); + aObjectTransform.set(1L, 1L, getFillBitmap().getSize().getY()); + aObjectTransform.set(0L, 2L, getFillBitmap().getTopLeft().getX()); + aObjectTransform.set(1L, 2L, getFillBitmap().getTopLeft().getY()); + aObjectTransform *= getTransformation(); + + // create bitmap primitive and add exclusive to decomposition (hand over ownership) + const Primitive2DReference xRef(new BitmapPrimitive2D(BitmapEx(getFillBitmap().getBitmap()), aObjectTransform)); + aRetval = Primitive2DSequence(&xRef, 1L); + } + } + + return aRetval; + } + + FillBitmapPrimitive2D::FillBitmapPrimitive2D( + const basegfx::B2DHomMatrix& rTransformation, + const attribute::FillBitmapAttribute& rFillBitmap) + : BasePrimitive2D(), + maTransformation(rTransformation), + maFillBitmap(rFillBitmap) + { + } + + bool FillBitmapPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const + { + if(BasePrimitive2D::operator==(rPrimitive)) + { + const FillBitmapPrimitive2D& rCompare = static_cast< const FillBitmapPrimitive2D& >(rPrimitive); + + return (getTransformation() == rCompare.getTransformation() + && getFillBitmap() == rCompare.getFillBitmap()); + } + + return false; + } + + basegfx::B2DRange FillBitmapPrimitive2D::getB2DRange(const geometry::ViewInformation2D& /*rViewInformation*/) const + { + // return range of it + basegfx::B2DPolygon aPolygon(basegfx::tools::createPolygonFromRect(basegfx::B2DRange(0.0, 0.0, 1.0, 1.0))); + aPolygon.transform(getTransformation()); + return basegfx::tools::getRange(aPolygon); + } + + sal_uInt32 FillBitmapPrimitive2D::getPrimitiveID() const + { + return Create2DPrimitiveID('2','F','B','i'); + } + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/primitive2d/fillgradientprimitive2d.cxx b/drawinglayer/source/primitive2d/fillgradientprimitive2d.cxx new file mode 100644 index 000000000000..e5ddbacbdbc9 --- /dev/null +++ b/drawinglayer/source/primitive2d/fillgradientprimitive2d.cxx @@ -0,0 +1,217 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: fillgradientprimitive2d.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-10-19 10:35:02 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_FILLGRADIENTPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/fillgradientprimitive2d.hxx> +#endif + +#ifndef _BGFX_POLYGON_B2DPOLYGON_HXX +#include <basegfx/polygon/b2dpolygon.hxx> +#endif + +#ifndef _BGFX_POLYGON_B2DPOLYGONTOOLS_HXX +#include <basegfx/polygon/b2dpolygontools.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_TEXTURE_TEXTURE_HXX +#include <drawinglayer/texture/texture.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_POLYPOLYGONPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx> +#endif + +#ifndef _BGFX_TOOLS_CANVASTOOLS_HXX +#include <basegfx/tools/canvastools.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// + +using namespace com::sun::star; + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + Primitive2DSequence FillGradientPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + { + const attribute::GradientStyle aGradientStyle(maFillGradient.getStyle()); + ::std::vector< basegfx::B2DHomMatrix > aMatrices; + ::std::vector< basegfx::BColor > aColors; + basegfx::B2DPolygon aUnitPolygon; + sal_uInt32 nSteps(maFillGradient.getSteps()); + + if(attribute::GRADIENTSTYLE_RADIAL == aGradientStyle || attribute::GRADIENTSTYLE_ELLIPTICAL == aGradientStyle) + { + const basegfx::B2DPoint aCircleCenter(0.5, 0.5); + aUnitPolygon = basegfx::tools::createPolygonFromEllipse(aCircleCenter, 0.5, 0.5); + aUnitPolygon = basegfx::tools::adaptiveSubdivideByAngle(aUnitPolygon); + } + else + { + aUnitPolygon = basegfx::tools::createPolygonFromRect(basegfx::B2DRange(0.0, 0.0, 1.0, 1.0)); + } + + // make sure steps is not too high/low + const basegfx::BColor aStart(maFillGradient.getStartColor()); + const basegfx::BColor aEnd(maFillGradient.getEndColor()); + const sal_uInt32 nMaxSteps(sal_uInt32((aStart.getMaximumDistance(aEnd) * 127.5) + 0.5)); + + if(nSteps == 0L) + { + nSteps = nMaxSteps; + } + + if(nSteps < 2L) + { + nSteps = 2L; + } + + if(nSteps > nMaxSteps) + { + nSteps = nMaxSteps; + } + + switch(aGradientStyle) + { + case attribute::GRADIENTSTYLE_LINEAR: + { + texture::GeoTexSvxGradientLinear aGradient(getObjectRange(), aStart, aEnd, nSteps, maFillGradient.getBorder(), -maFillGradient.getAngle()); + aGradient.appendTransformations(aMatrices); + aGradient.appendColors(aColors); + break; + } + case attribute::GRADIENTSTYLE_AXIAL: + { + texture::GeoTexSvxGradientAxial aGradient(getObjectRange(), aStart, aEnd, nSteps, maFillGradient.getBorder(), -maFillGradient.getAngle()); + aGradient.appendTransformations(aMatrices); + aGradient.appendColors(aColors); + break; + } + case attribute::GRADIENTSTYLE_RADIAL: + { + texture::GeoTexSvxGradientRadial aGradient(getObjectRange(), aStart, aEnd, nSteps, maFillGradient.getBorder(), maFillGradient.getOffsetX(), maFillGradient.getOffsetY()); + aGradient.appendTransformations(aMatrices); + aGradient.appendColors(aColors); + break; + } + case attribute::GRADIENTSTYLE_ELLIPTICAL: + { + texture::GeoTexSvxGradientElliptical aGradient(getObjectRange(), aStart, aEnd, nSteps, maFillGradient.getBorder(), maFillGradient.getOffsetX(), maFillGradient.getOffsetY(), -maFillGradient.getAngle()); + aGradient.appendTransformations(aMatrices); + aGradient.appendColors(aColors); + break; + } + case attribute::GRADIENTSTYLE_SQUARE: + { + texture::GeoTexSvxGradientSquare aGradient(getObjectRange(), aStart, aEnd, nSteps, maFillGradient.getBorder(), maFillGradient.getOffsetX(), maFillGradient.getOffsetY(), -maFillGradient.getAngle()); + aGradient.appendTransformations(aMatrices); + aGradient.appendColors(aColors); + break; + } + case attribute::GRADIENTSTYLE_RECT: + { + texture::GeoTexSvxGradientRect aGradient(getObjectRange(), aStart, aEnd, nSteps, maFillGradient.getBorder(), maFillGradient.getOffsetX(), maFillGradient.getOffsetY(), -maFillGradient.getAngle()); + aGradient.appendTransformations(aMatrices); + aGradient.appendColors(aColors); + break; + } + } + + // prepare return value + Primitive2DSequence aRetval(aColors.size() ? aMatrices.size() + 1L : aMatrices.size()); + + // create solid fill with start color + if(aColors.size()) + { + // create primitive + const Primitive2DReference xRef(new PolyPolygonColorPrimitive2D(basegfx::B2DPolyPolygon(basegfx::tools::createPolygonFromRect(getObjectRange())), aColors[0L])); + aRetval[0L] = xRef; + } + + // create solid fill steps + for(sal_uInt32 a(0L); a < aMatrices.size(); a++) + { + // create part polygon + basegfx::B2DPolygon aNewPoly(aUnitPolygon); + aNewPoly.transform(aMatrices[a]); + + // create solid fill + const Primitive2DReference xRef(new PolyPolygonColorPrimitive2D(basegfx::B2DPolyPolygon(aNewPoly), aColors[a + 1L])); + aRetval[a + 1L] = xRef; + } + + return aRetval; + } + + FillGradientPrimitive2D::FillGradientPrimitive2D( + const basegfx::B2DRange& rObjectRange, + const attribute::FillGradientAttribute& rFillGradient) + : BasePrimitive2D(), + maObjectRange(rObjectRange), + maFillGradient(rFillGradient) + { + } + + bool FillGradientPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const + { + if(BasePrimitive2D::operator==(rPrimitive)) + { + const FillGradientPrimitive2D& rCompare = (FillGradientPrimitive2D&)rPrimitive; + + return (getObjectRange() == rCompare.getObjectRange() + && maFillGradient == rCompare.maFillGradient); + } + + return false; + } + + basegfx::B2DRange FillGradientPrimitive2D::getB2DRange(const geometry::ViewInformation2D& /*rViewInformation*/) const + { + // return ObjectRange + return getObjectRange(); + } + + sal_uInt32 FillGradientPrimitive2D::getPrimitiveID() const + { + return Create2DPrimitiveID('2','F','G','r'); + } + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/primitive2d/fillhatchprimitive2d.cxx b/drawinglayer/source/primitive2d/fillhatchprimitive2d.cxx new file mode 100644 index 000000000000..a5f813839349 --- /dev/null +++ b/drawinglayer/source/primitive2d/fillhatchprimitive2d.cxx @@ -0,0 +1,175 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: fillhatchprimitive2d.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-10-19 10:35:02 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_FILLHATCHPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/fillhatchprimitive2d.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_TEXTURE_TEXTURE_HXX +#include <drawinglayer/texture/texture.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_POLYPOLYGONPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx> +#endif + +#ifndef _BGFX_POLYGON_B2DPOLYGONTOOLS_HXX +#include <basegfx/polygon/b2dpolygontools.hxx> +#endif + +#ifndef _BGFX_POLYGON_B2DPOLYGON_HXX +#include <basegfx/polygon/b2dpolygon.hxx> +#endif + +#ifndef _BGFX_TOOLS_CANVASTOOLS_HXX +#include <basegfx/tools/canvastools.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_POLYGONPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/polygonprimitive2d.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// + +using namespace com::sun::star; + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + Primitive2DSequence FillHatchPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + { + // create hatch + const basegfx::BColor aHatchColor(maFillHatch.getColor()); + const double fAngle(-maFillHatch.getAngle()); + ::std::vector< basegfx::B2DHomMatrix > aMatrices; + + // get hatch transformations + switch(maFillHatch.getStyle()) + { + case attribute::HATCHSTYLE_TRIPLE: + { + // rotated 45 degrees + texture::GeoTexSvxHatch aHatch(getObjectRange(), maFillHatch.getDistance(), fAngle + F_PI4); + aHatch.appendTransformations(aMatrices); + } + case attribute::HATCHSTYLE_DOUBLE: + { + // rotated 90 degrees + texture::GeoTexSvxHatch aHatch(getObjectRange(), maFillHatch.getDistance(), fAngle + F_PI2); + aHatch.appendTransformations(aMatrices); + } + case attribute::HATCHSTYLE_SINGLE: + { + // angle as given + texture::GeoTexSvxHatch aHatch(getObjectRange(), maFillHatch.getDistance(), fAngle); + aHatch.appendTransformations(aMatrices); + } + } + + // prepare return value + const bool bFillBackground(maFillHatch.isFillBackground()); + Primitive2DSequence aRetval(bFillBackground ? aMatrices.size() + 1L : aMatrices.size()); + + // evtl. create filled background + if(bFillBackground) + { + // create primitive for background + const Primitive2DReference xRef(new PolyPolygonColorPrimitive2D(basegfx::B2DPolyPolygon(basegfx::tools::createPolygonFromRect(getObjectRange())), maBColor)); + aRetval[0L] = xRef; + } + + // create primitives + const basegfx::B2DPoint aStart(0.0, 0.0); + const basegfx::B2DPoint aEnd(1.0, 0.0); + + for(sal_uInt32 a(0L); a < aMatrices.size(); a++) + { + const basegfx::B2DHomMatrix& rMatrix = aMatrices[a]; + basegfx::B2DPolygon aNewLine; + + aNewLine.append(rMatrix * aStart); + aNewLine.append(rMatrix * aEnd); + + // create hairline + const Primitive2DReference xRef(new PolygonHairlinePrimitive2D(aNewLine, aHatchColor)); + aRetval[bFillBackground ? (a + 1L) : a] = xRef; + } + + return aRetval; + } + + FillHatchPrimitive2D::FillHatchPrimitive2D( + const basegfx::B2DRange& rObjectRange, + const basegfx::BColor& rBColor, + const attribute::FillHatchAttribute& rFillHatch) + : BasePrimitive2D(), + maObjectRange(rObjectRange), + maFillHatch(rFillHatch), + maBColor(rBColor) + { + } + + bool FillHatchPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const + { + if(BasePrimitive2D::operator==(rPrimitive)) + { + const FillHatchPrimitive2D& rCompare = (FillHatchPrimitive2D&)rPrimitive; + + return (getObjectRange() == rCompare.getObjectRange() + && maFillHatch == rCompare.maFillHatch + && maBColor == rCompare.maBColor); + } + + return false; + } + + basegfx::B2DRange FillHatchPrimitive2D::getB2DRange(const geometry::ViewInformation2D& /*rViewInformation*/) const + { + // return ObjectRange + return getObjectRange(); + } + + sal_uInt32 FillHatchPrimitive2D::getPrimitiveID() const + { + return Create2DPrimitiveID('2','F','H','a'); + } + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/primitive2d/gridprimitive2d.cxx b/drawinglayer/source/primitive2d/gridprimitive2d.cxx new file mode 100644 index 000000000000..9bb9d88fefd7 --- /dev/null +++ b/drawinglayer/source/primitive2d/gridprimitive2d.cxx @@ -0,0 +1,302 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: gridprimitive2d.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-10-19 10:35:02 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_GRIDPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/gridprimitive2d.hxx> +#endif + +#ifndef _BGFX_TOOLS_CANVASTOOLS_HXX +#include <basegfx/tools/canvastools.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_MARKERPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/markerprimitive2d.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_GEOMETRY_VIEWINFORMATION2D_HXX +#include <drawinglayer/geometry/viewinformation2d.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// + +using namespace com::sun::star; + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + Primitive2DSequence GridPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const + { + std::vector< BasePrimitive2D* > aTempPrimitiveTarget; + + if(!rViewInformation.getViewport().isEmpty() && getWidth() > 0.0 && getHeight() > 0.0) + { + // decompose grid matrix to get logic size + basegfx::B2DVector aScale, aTranslate; + double fRotate, fShearX; + getTransform().decompose(aScale, aTranslate, fRotate, fShearX); + + // create grid matrix which transforms from scaled logic to view + basegfx::B2DHomMatrix aRST; + aRST.rotate(fRotate); + aRST.shearX(fShearX); + aRST.translate(aTranslate.getX(), aTranslate.getY()); + aRST *= rViewInformation.getViewTransformation(); + + // get step widths + double fStepX(getWidth()); + double fStepY(getHeight()); + const double fMinimalStep(10.0); + + // guarantee a step width of 100.0 + if(basegfx::fTools::less(fStepX, fMinimalStep)) + { + fStepX = fMinimalStep; + } + + if(basegfx::fTools::less(fStepY, fMinimalStep)) + { + fStepY = fMinimalStep; + } + + // get relative distances in view + double fViewStepX((rViewInformation.getViewTransformation() * basegfx::B2DVector(fStepX, 0.0)).getLength()); + double fViewStepY((rViewInformation.getViewTransformation() * basegfx::B2DVector(0.0, fStepY)).getLength()); + double fSmallStepX(1.0), fViewSmallStepX(1.0), fSmallStepY(1.0), fViewSmallStepY(1.0); + sal_uInt32 nSmallStepsX(0L), nSmallStepsY(0L); + + // setup subdivisions + if(getSubdivisionsX()) + { + fSmallStepX = fStepX / getSubdivisionsX(); + fViewSmallStepX = fViewStepX / getSubdivisionsX(); + } + + if(getSubdivisionsY()) + { + fSmallStepY = fStepY / getSubdivisionsY(); + fViewSmallStepY = fViewStepY / getSubdivisionsY(); + } + + // correct step width + while(fViewStepX < getSmallestViewDistance()) + { + fViewStepX *= 2.0; + fStepX *= 2.0; + } + + while(fViewStepY < getSmallestViewDistance()) + { + fViewStepY *= 2.0; + fStepY *= 2.0; + } + + // correct small step width + if(getSubdivisionsX()) + { + while(fViewSmallStepX < getSmallestSubdivisionViewDistance()) + { + fViewSmallStepX *= 2.0; + fSmallStepX *= 2.0; + } + + nSmallStepsX = (sal_uInt32)(fStepX / fSmallStepX); + } + + if(getSubdivisionsY()) + { + while(fViewSmallStepY < getSmallestSubdivisionViewDistance()) + { + fViewSmallStepY *= 2.0; + fSmallStepY *= 2.0; + } + + nSmallStepsY = (sal_uInt32)(fStepY / fSmallStepY); + } + + for(double fX(0.0); fX < aScale.getX(); fX += fStepX) + { + const bool bXZero(basegfx::fTools::equalZero(fX)); + + for(double fY(0.0); fY < aScale.getY(); fY += fStepY) + { + const bool bYZero(basegfx::fTools::equalZero(fY)); + basegfx::B2DPoint aViewPos(aRST * basegfx::B2DPoint(fX, fY)); + + if(rViewInformation.getDiscreteViewport().isInside(aViewPos) && !bXZero && !bYZero) + { + const basegfx::B2DPoint aLogicPos(rViewInformation.getInverseViewTransformation() * aViewPos); + MarkerPrimitive2D* pNew = new MarkerPrimitive2D(aLogicPos, 0.5, 0.5, getBColor(), MARKERSTYLE2D_CROSS); + aTempPrimitiveTarget.push_back(pNew); + } + + if(getSubdivisionsX() && !bYZero) + { + double fF(fX + fSmallStepX); + + for(sal_uInt32 a(0L); a < nSmallStepsX && fF < aScale.getX(); a++, fF += fSmallStepX) + { + aViewPos = aRST * basegfx::B2DPoint(fF, fY); + + if(rViewInformation.getDiscreteViewport().isInside(aViewPos)) + { + const basegfx::B2DPoint aLogicPos(rViewInformation.getInverseViewTransformation() * aViewPos); + MarkerPrimitive2D* pNew = new MarkerPrimitive2D(aLogicPos, 0.5, 0.5, getBColor(), MARKERSTYLE2D_POINT); + aTempPrimitiveTarget.push_back(pNew); + } + } + } + + if(getSubdivisionsY() && !bXZero) + { + double fF(fY + fSmallStepY); + + for(sal_uInt32 a(0L); a < nSmallStepsY && fF < aScale.getY(); a++, fF += fSmallStepY) + { + aViewPos = aRST * basegfx::B2DPoint(fX, fF); + + if(rViewInformation.getDiscreteViewport().isInside(aViewPos)) + { + const basegfx::B2DPoint aLogicPos(rViewInformation.getInverseViewTransformation() * aViewPos); + MarkerPrimitive2D* pNew = new MarkerPrimitive2D(aLogicPos, 0.5, 0.5, getBColor(), MARKERSTYLE2D_POINT); + aTempPrimitiveTarget.push_back(pNew); + } + } + } + } + } + } + + // prepare return value + Primitive2DSequence aRetval(aTempPrimitiveTarget.size()); + + for(sal_uInt32 a(0L); a < aTempPrimitiveTarget.size(); a++) + { + const Primitive2DReference xRef(aTempPrimitiveTarget[a]); + aRetval[a] = xRef; + } + + return aRetval; + } + + GridPrimitive2D::GridPrimitive2D( + const basegfx::B2DHomMatrix& rTransform, + double fWidth, + double fHeight, + double fSmallestViewDistance, + double fSmallestSubdivisionViewDistance, + sal_uInt32 nSubdivisionsX, + sal_uInt32 nSubdivisionsY, + const basegfx::BColor& rBColor) + : BasePrimitive2D(), + maTransform(rTransform), + mfWidth(fWidth), + mfHeight(fHeight), + mfSmallestViewDistance(fSmallestViewDistance), + mfSmallestSubdivisionViewDistance(fSmallestSubdivisionViewDistance), + mnSubdivisionsX(nSubdivisionsX), + mnSubdivisionsY(nSubdivisionsY), + maBColor(rBColor), + maLastViewTransformation(), + maLastViewport() + { + } + + bool GridPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const + { + if(BasePrimitive2D::operator==(rPrimitive)) + { + const GridPrimitive2D& rCompare = (GridPrimitive2D&)rPrimitive; + + return (getTransform() == rCompare.getTransform() + && getWidth() == rCompare.getWidth() + && getHeight() == rCompare.getHeight() + && getSmallestViewDistance() == rCompare.getSmallestViewDistance() + && getSmallestSubdivisionViewDistance() == rCompare.getSmallestSubdivisionViewDistance() + && getSubdivisionsX() == rCompare.getSubdivisionsX() + && getSubdivisionsY() == rCompare.getSubdivisionsY() + && getBColor() == rCompare.getBColor()); + } + + return false; + } + + basegfx::B2DRange GridPrimitive2D::getB2DRange(const geometry::ViewInformation2D& rViewInformation) const + { + // get object's range + basegfx::B2DRange aUnitRange(0.0, 0.0, 1.0, 1.0); + aUnitRange.transform(getTransform()); + + // intersect with visible part + aUnitRange.intersect(rViewInformation.getViewport()); + + return aUnitRange; + } + + sal_uInt32 GridPrimitive2D::getPrimitiveID() const + { + return Create2DPrimitiveID('2','G','r','i'); + } + + Primitive2DSequence GridPrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const + { + ::osl::MutexGuard aGuard( m_aMutex ); + + if(getLocalDecomposition().hasElements()) + { + if(maLastViewport != rViewInformation.getViewport() || maLastViewTransformation != rViewInformation.getViewTransformation()) + { + // conditions of last local decomposition have changed, delete + const_cast< GridPrimitive2D* >(this)->setLocalDecomposition(Primitive2DSequence()); + } + } + + if(!getLocalDecomposition().hasElements()) + { + // remember ViewRange and ViewTransformation + const_cast< GridPrimitive2D* >(this)->maLastViewTransformation = rViewInformation.getViewTransformation(); + const_cast< GridPrimitive2D* >(this)->maLastViewport = rViewInformation.getViewport(); + } + + // use parent implementation + return BasePrimitive2D::get2DDecomposition(rViewInformation); + } + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/primitive2d/groupprimitive2d.cxx b/drawinglayer/source/primitive2d/groupprimitive2d.cxx new file mode 100644 index 000000000000..da6a0c370f86 --- /dev/null +++ b/drawinglayer/source/primitive2d/groupprimitive2d.cxx @@ -0,0 +1,86 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: groupprimitive2d.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-10-19 10:35:02 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_GROUPPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/groupprimitive2d.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// + +using namespace com::sun::star; + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + /// default: just return children, so all renderers not supporting group will use it's content + Primitive2DSequence GroupPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + { + return getChildren(); + } + + GroupPrimitive2D::GroupPrimitive2D( const Primitive2DSequence& rChildren ) + : BasePrimitive2D(), + maChildren(rChildren) + { + } + + /** The compare opertator uses the Sequence::==operator, so only checking if + the rererences are equal. All non-equal references are interpreted as + non-equal. + */ + bool GroupPrimitive2D::operator==( const BasePrimitive2D& rPrimitive ) const + { + if(BasePrimitive2D::operator==(rPrimitive)) + { + const GroupPrimitive2D& rCompare = static_cast< const GroupPrimitive2D& >(rPrimitive); + + return (arePrimitive2DSequencesEqual(getChildren(), rCompare.getChildren())); + } + + return false; + } + + sal_uInt32 GroupPrimitive2D::getPrimitiveID() const + { + return Create2DPrimitiveID('2','G','r','o'); + } + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/primitive2d/helplineprimitive2d.cxx b/drawinglayer/source/primitive2d/helplineprimitive2d.cxx new file mode 100644 index 000000000000..231c683812db --- /dev/null +++ b/drawinglayer/source/primitive2d/helplineprimitive2d.cxx @@ -0,0 +1,245 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: helplineprimitive2d.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-10-19 10:35:03 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_HELPLINEPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/helplineprimitive2d.hxx> +#endif + +#ifndef _BGFX_POLYGON_B2DPOLYGON_HXX +#include <basegfx/polygon/b2dpolygon.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_POLYGONPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/polygonprimitive2d.hxx> +#endif + +#ifndef _BGFX_POLYPOLYGON_B2DPOLYGONCLIPPER_HXX +#include <basegfx/polygon/b2dpolygonclipper.hxx> +#endif + +#ifndef _BGFX_TOOLS_CANVASTOOLS_HXX +#include <basegfx/tools/canvastools.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_GEOMETRY_VIEWINFORMATION2D_HXX +#include <drawinglayer/geometry/viewinformation2d.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// + +using namespace com::sun::star; + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + Primitive2DSequence HelplinePrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const + { + std::vector< BasePrimitive2D* > aTempPrimitiveTarget; + + if(!rViewInformation.getViewport().isEmpty() && !getDirection().equalZero()) + { + // position to view coordinates, DashLen and DashLen in logic + const basegfx::B2DPoint aViewPosition(rViewInformation.getViewTransformation() * getPosition()); + const double fLogicDashLen((rViewInformation.getInverseViewTransformation() * basegfx::B2DVector(getViewDashLength(), 0.0)).getLength()); + + switch(getStyle()) + { + default : // HELPLINESTYLE2D_POINT + { + const double fViewFixValue(15.0); + basegfx::B2DVector aNormalizedDirection(getDirection()); + aNormalizedDirection.normalize(); + aNormalizedDirection *= fViewFixValue; + const basegfx::B2DPoint aStartA(aViewPosition - aNormalizedDirection); + const basegfx::B2DPoint aEndA(aViewPosition + aNormalizedDirection); + basegfx::B2DPolygon aLineA; + aLineA.append(aStartA); + aLineA.append(aEndA); + aLineA.transform(rViewInformation.getInverseViewTransformation()); + PolygonMarkerPrimitive2D* pNewA = new PolygonMarkerPrimitive2D(aLineA, getRGBColA(), getRGBColB(), fLogicDashLen); + aTempPrimitiveTarget.push_back(pNewA); + + const basegfx::B2DVector aPerpendicularNormalizedDirection(getPerpendicular(aNormalizedDirection)); + const basegfx::B2DPoint aStartB(aViewPosition - aPerpendicularNormalizedDirection); + const basegfx::B2DPoint aEndB(aViewPosition + aPerpendicularNormalizedDirection); + basegfx::B2DPolygon aLineB; + aLineB.append(aStartB); + aLineB.append(aEndB); + aLineB.transform(rViewInformation.getInverseViewTransformation()); + PolygonMarkerPrimitive2D* pNewB = new PolygonMarkerPrimitive2D(aLineB, getRGBColA(), getRGBColB(), fLogicDashLen); + aTempPrimitiveTarget.push_back(pNewB); + + break; + } + case HELPLINESTYLE2D_LINE : + { + basegfx::B2DPolygon aLine; + + if(basegfx::areParallel(getDirection(), basegfx::B2DVector(1.0, 0.0))) + { + // parallel to X-Axis, get cuts with Y-Axes + const double fCutA((rViewInformation.getDiscreteViewport().getMinX() - aViewPosition.getX()) / getDirection().getX()); + const double fCutB((rViewInformation.getDiscreteViewport().getMaxX() - aViewPosition.getX()) / getDirection().getX()); + const basegfx::B2DPoint aPosA(aViewPosition + (fCutA * getDirection())); + const basegfx::B2DPoint aPosB(aViewPosition + (fCutB * getDirection())); + const bool bBothLeft(aPosA.getX() < rViewInformation.getDiscreteViewport().getMinX() && aPosB.getX() < rViewInformation.getDiscreteViewport().getMinX()); + const bool bBothRight(aPosA.getX() > rViewInformation.getDiscreteViewport().getMaxX() && aPosB.getX() < rViewInformation.getDiscreteViewport().getMaxX()); + + if(!bBothLeft && !bBothRight) + { + aLine.append(aPosA); + aLine.append(aPosB); + } + } + else + { + // get cuts with X-Axes + const double fCutA((rViewInformation.getDiscreteViewport().getMinY() - aViewPosition.getY()) / getDirection().getY()); + const double fCutB((rViewInformation.getDiscreteViewport().getMaxY() - aViewPosition.getY()) / getDirection().getY()); + const basegfx::B2DPoint aPosA(aViewPosition + (fCutA * getDirection())); + const basegfx::B2DPoint aPosB(aViewPosition + (fCutB * getDirection())); + const bool bBothAbove(aPosA.getY() < rViewInformation.getDiscreteViewport().getMinY() && aPosB.getY() < rViewInformation.getDiscreteViewport().getMinY()); + const bool bBothBelow(aPosA.getY() > rViewInformation.getDiscreteViewport().getMaxY() && aPosB.getY() < rViewInformation.getDiscreteViewport().getMaxY()); + + if(!bBothAbove && !bBothBelow) + { + aLine.append(aPosA); + aLine.append(aPosB); + } + } + + if(aLine.count()) + { + // clip against visible area + const basegfx::B2DPolyPolygon aResult(basegfx::tools::clipPolygonOnRange(aLine, rViewInformation.getDiscreteViewport(), true, true)); + + for(sal_uInt32 a(0L); a < aResult.count(); a++) + { + basegfx::B2DPolygon aPart(aResult.getB2DPolygon(a)); + aPart.transform(rViewInformation.getInverseViewTransformation()); + PolygonMarkerPrimitive2D* pNew = new PolygonMarkerPrimitive2D(aPart, getRGBColA(), getRGBColB(), fLogicDashLen); + aTempPrimitiveTarget.push_back(pNew); + } + } + + break; + } + } + } + + // prepare return value + Primitive2DSequence aRetval(aTempPrimitiveTarget.size()); + + for(sal_uInt32 a(0L); a < aTempPrimitiveTarget.size(); a++) + { + const Primitive2DReference xRef(aTempPrimitiveTarget[a]); + aRetval[a] = xRef; + } + + return aRetval; + } + + HelplinePrimitive2D::HelplinePrimitive2D( + const basegfx::B2DPoint& rPosition, + const basegfx::B2DVector& rDirection, + HelplineStyle2D eStyle, + const basegfx::BColor& rRGBColA, + const basegfx::BColor& rRGBColB, + double fViewDashLength) + : BasePrimitive2D(), + maPosition(rPosition), + maDirection(rDirection), + meStyle(eStyle), + maRGBColA(rRGBColA), + maRGBColB(rRGBColB), + mfViewDashLength(fViewDashLength), + maLastViewTransformation(), + maLastViewport() + { + } + + bool HelplinePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const + { + if(BasePrimitive2D::operator==(rPrimitive)) + { + const HelplinePrimitive2D& rCompare = (HelplinePrimitive2D&)rPrimitive; + + return (getPosition() == rCompare.getPosition() + && getDirection() == rCompare.getDirection() + && getStyle() == rCompare.getStyle() + && getRGBColA() == rCompare.getRGBColA() + && getRGBColB() == rCompare.getRGBColB() + && getViewDashLength() == rCompare.getViewDashLength()); + } + + return false; + } + + sal_uInt32 HelplinePrimitive2D::getPrimitiveID() const + { + return Create2DPrimitiveID('2','H','e','l'); + } + + Primitive2DSequence HelplinePrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const + { + ::osl::MutexGuard aGuard( m_aMutex ); + + if(getLocalDecomposition().hasElements()) + { + if(maLastViewport != rViewInformation.getViewport() || maLastViewTransformation != rViewInformation.getViewTransformation()) + { + // conditions of last local decomposition have changed, delete + const_cast< HelplinePrimitive2D* >(this)->setLocalDecomposition(Primitive2DSequence()); + } + } + + if(!getLocalDecomposition().hasElements()) + { + // remember ViewRange and ViewTransformation + const_cast< HelplinePrimitive2D* >(this)->maLastViewTransformation = rViewInformation.getViewTransformation(); + const_cast< HelplinePrimitive2D* >(this)->maLastViewport = rViewInformation.getViewport(); + } + + // use parent implementation + return BasePrimitive2D::get2DDecomposition(rViewInformation); + } + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/primitive2d/makefile.mk b/drawinglayer/source/primitive2d/makefile.mk new file mode 100644 index 000000000000..a4d65536d4a0 --- /dev/null +++ b/drawinglayer/source/primitive2d/makefile.mk @@ -0,0 +1,75 @@ +#************************************************************************* +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1 $ +# +# last change: $Author: aw $ $Date: 2006-10-19 10:35:03 $ +# +# The Contents of this file are made available subject to +# the terms of GNU Lesser General Public License Version 2.1. +# +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2005 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +#************************************************************************* + +PRJ=..$/.. +PRJNAME=drawinglayer +TARGET=primitive2d +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ---------------------------------- + +.INCLUDE : settings.mk + +# --- Files ------------------------------------- + +SLOFILES= \ + $(SLO)$/alphaprimitive2d.obj \ + $(SLO)$/animatedprimitive2d.obj \ + $(SLO)$/baseprimitive2d.obj \ + $(SLO)$/backgroundcolorprimitive2d.obj \ + $(SLO)$/bitmapprimitive2d.obj \ + $(SLO)$/embedded3dprimitive2d.obj \ + $(SLO)$/fillbitmapprimitive2d.obj \ + $(SLO)$/fillgradientprimitive2d.obj \ + $(SLO)$/fillhatchprimitive2d.obj \ + $(SLO)$/gridprimitive2d.obj \ + $(SLO)$/groupprimitive2d.obj \ + $(SLO)$/helplineprimitive2d.obj \ + $(SLO)$/markerprimitive2d.obj \ + $(SLO)$/maskprimitive2d.obj \ + $(SLO)$/metafileprimitive2d.obj \ + $(SLO)$/modifiedcolorprimitive2d.obj \ + $(SLO)$/polypolygonprimitive2d.obj \ + $(SLO)$/polygonprimitive2d.obj \ + $(SLO)$/sceneprimitive2d.obj \ + $(SLO)$/shadowprimitive2d.obj \ + $(SLO)$/textlayoutdevice.obj \ + $(SLO)$/textprimitive2d.obj \ + $(SLO)$/transformprimitive2d.obj \ + $(SLO)$/unifiedalphaprimitive2d.obj + +# --- Targets ---------------------------------- + +.INCLUDE : target.mk diff --git a/drawinglayer/source/primitive2d/maskprimitive2d.cxx b/drawinglayer/source/primitive2d/maskprimitive2d.cxx new file mode 100644 index 000000000000..7aae26bdf45c --- /dev/null +++ b/drawinglayer/source/primitive2d/maskprimitive2d.cxx @@ -0,0 +1,78 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: maskprimitive2d.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-10-19 10:35:03 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_MASKPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/maskprimitive2d.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// + +using namespace com::sun::star; + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + MaskPrimitive2D::MaskPrimitive2D( + const basegfx::B2DPolyPolygon& rMask, + const Primitive2DSequence& rChildren) + : GroupPrimitive2D(rChildren), + maMask(rMask) + { + } + + bool MaskPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const + { + if(GroupPrimitive2D::operator==(rPrimitive)) + { + const MaskPrimitive2D& rCompare = static_cast< const MaskPrimitive2D& >(rPrimitive); + + return (getMask() == rCompare.getMask()); + } + + return false; + } + + sal_uInt32 MaskPrimitive2D::getPrimitiveID() const + { + return Create2DPrimitiveID('2','M','a','s'); + } + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/primitive2d/metafileprimitive2d.cxx b/drawinglayer/source/primitive2d/metafileprimitive2d.cxx new file mode 100644 index 000000000000..cbdefa340c7b --- /dev/null +++ b/drawinglayer/source/primitive2d/metafileprimitive2d.cxx @@ -0,0 +1,91 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: metafileprimitive2d.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-10-19 10:35:03 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_METAFILEPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/metafileprimitive2d.hxx> +#endif + +#ifndef _BGFX_TOOLS_CANVASTOOLS_HXX +#include <basegfx/tools/canvastools.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// + +using namespace com::sun::star; + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + MetafilePrimitive2D::MetafilePrimitive2D( + const GDIMetaFile& rMetaFile, + const basegfx::B2DHomMatrix& rMetaFileTransform) + : BasePrimitive2D(), + maMetaFile(rMetaFile), + maMetaFileTransform(rMetaFileTransform) + { + } + + bool MetafilePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const + { + if(BasePrimitive2D::operator==(rPrimitive)) + { + const MetafilePrimitive2D& rCompare = (MetafilePrimitive2D&)rPrimitive; + + return (getMetaFile() == rCompare.getMetaFile() + && getTransform() == rCompare.getTransform()); + } + + return false; + } + + sal_uInt32 MetafilePrimitive2D::getPrimitiveID() const + { + return Create2DPrimitiveID('2','M','e','t'); + } + + basegfx::B2DRange MetafilePrimitive2D::getB2DRange(const geometry::ViewInformation2D& /*rViewInformation*/) const + { + basegfx::B2DRange aRetval(0.0, 0.0, 1.0, 1.0); + aRetval.transform(getTransform()); + return aRetval; + } + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/primitive2d/modifiedcolorprimitive2d.cxx b/drawinglayer/source/primitive2d/modifiedcolorprimitive2d.cxx new file mode 100644 index 000000000000..36432333122c --- /dev/null +++ b/drawinglayer/source/primitive2d/modifiedcolorprimitive2d.cxx @@ -0,0 +1,78 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: modifiedcolorprimitive2d.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-10-19 10:35:03 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_MODIFIEDCOLORPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// + +using namespace com::sun::star; + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + ModifiedColorPrimitive2D::ModifiedColorPrimitive2D( + const Primitive2DSequence& rChildren, + const basegfx::BColorModifier& rColorModifier) + : GroupPrimitive2D(rChildren), + maColorModifier(rColorModifier) + { + } + + bool ModifiedColorPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const + { + if(GroupPrimitive2D::operator==(rPrimitive)) + { + const ModifiedColorPrimitive2D& rCompare = (ModifiedColorPrimitive2D&)rPrimitive; + + return (getColorModifier() == rCompare.getColorModifier()); + } + + return false; + } + + sal_uInt32 ModifiedColorPrimitive2D::getPrimitiveID() const + { + return Create2DPrimitiveID('2','M','C','o'); + } + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/primitive2d/polygonprimitive2d.cxx b/drawinglayer/source/primitive2d/polygonprimitive2d.cxx new file mode 100644 index 000000000000..9dc860899b09 --- /dev/null +++ b/drawinglayer/source/primitive2d/polygonprimitive2d.cxx @@ -0,0 +1,434 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: polygonprimitive2d.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-10-19 10:35:03 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_POLYGONPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/polygonprimitive2d.hxx> +#endif + +#ifndef _BGFX_TOOLS_CANVASTOOLS_HXX +#include <basegfx/tools/canvastools.hxx> +#endif + +#ifndef _BGFX_POLYGON_B2DPOLYGONTOOLS_HXX +#include <basegfx/polygon/b2dpolygontools.hxx> +#endif + +#ifndef _BGFX_POLYPOLYGON_B2DPOLYGONTOOLS_HXX +#include <basegfx/polygon/b2dpolypolygontools.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_POLYPOLYGONPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// + +using namespace com::sun::star; + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + PolygonHairlinePrimitive2D::PolygonHairlinePrimitive2D( + const basegfx::B2DPolygon& rPolygon, + const basegfx::BColor& rBColor) + : BasePrimitive2D(), + maPolygon(rPolygon), + maBColor(rBColor) + { + } + + bool PolygonHairlinePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const + { + if(BasePrimitive2D::operator==(rPrimitive)) + { + const PolygonHairlinePrimitive2D& rCompare = (PolygonHairlinePrimitive2D&)rPrimitive; + + return (getB2DPolygon() == rCompare.getB2DPolygon() + && getBColor() == rCompare.getBColor()); + } + + return false; + } + + basegfx::B2DRange PolygonHairlinePrimitive2D::getB2DRange(const geometry::ViewInformation2D& /*rViewInformation*/) const + { + // return range + return basegfx::tools::getRange(basegfx::tools::adaptiveSubdivideByAngle(getB2DPolygon())); + } + + sal_uInt32 PolygonHairlinePrimitive2D::getPrimitiveID() const + { + return Create2DPrimitiveID('2','P','H','a'); + } + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + Primitive2DSequence PolygonMarkerPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + { + if(getDashLength() > 0.0) + { + ::std::vector< double > aDashA; + ::std::vector< double > aDashB; + + aDashA.push_back(getDashLength()); + aDashA.push_back(getDashLength()); + + aDashB.push_back(0.0); + aDashB.push_back(getDashLength()); + aDashB.push_back(getDashLength()); + aDashB.push_back(0.0); + + const basegfx::B2DPolyPolygon aDashedPolyPolyA(basegfx::tools::applyLineDashing(getB2DPolygon(), aDashA, 2.0 * getDashLength())); + const basegfx::B2DPolyPolygon aDashedPolyPolyB(basegfx::tools::applyLineDashing(getB2DPolygon(), aDashB, 2.0 * getDashLength())); + + // prepare return value + Primitive2DSequence aRetval(aDashedPolyPolyA.count() + aDashedPolyPolyB.count()); + sal_uInt32 a(0L), b(0L); + + for(; a < aDashedPolyPolyA.count(); a++) + { + const Primitive2DReference xRef(new PolygonHairlinePrimitive2D(aDashedPolyPolyA.getB2DPolygon(a), getRGBColorA())); + aRetval[a] = xRef; + } + + for(; b < aDashedPolyPolyB.count(); b++) + { + const Primitive2DReference xRef(new PolygonHairlinePrimitive2D(aDashedPolyPolyB.getB2DPolygon(b), getRGBColorB())); + aRetval[a + b] = xRef; + } + + return aRetval; + } + else + { + const Primitive2DReference xRef(new PolygonHairlinePrimitive2D(getB2DPolygon(), getRGBColorA())); + return Primitive2DSequence(&xRef, 1L); + } + } + + PolygonMarkerPrimitive2D::PolygonMarkerPrimitive2D( + const basegfx::B2DPolygon& rPolygon, + const basegfx::BColor& rRGBColorA, + const basegfx::BColor& rRGBColorB, + double fDashLength) + : BasePrimitive2D(), + maPolygon(rPolygon), + maRGBColorA(rRGBColorA), + maRGBColorB(rRGBColorB), + mfDashLength(fDashLength) + { + } + + bool PolygonMarkerPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const + { + if(BasePrimitive2D::operator==(rPrimitive)) + { + const PolygonMarkerPrimitive2D& rCompare = (PolygonMarkerPrimitive2D&)rPrimitive; + + return (getB2DPolygon() == rCompare.getB2DPolygon() + && getRGBColorA() == rCompare.getRGBColorA() + && getRGBColorB() == rCompare.getRGBColorB() + && getDashLength() == rCompare.getDashLength()); + } + + return false; + } + + basegfx::B2DRange PolygonMarkerPrimitive2D::getB2DRange(const geometry::ViewInformation2D& /*rViewInformation*/) const + { + // return range + return basegfx::tools::getRange(basegfx::tools::adaptiveSubdivideByAngle(getB2DPolygon())); + } + + sal_uInt32 PolygonMarkerPrimitive2D::getPrimitiveID() const + { + return Create2DPrimitiveID('2','P','M','a'); + } + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + Primitive2DSequence PolygonStrokePrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + { + if(getB2DPolygon().count()) + { + basegfx::B2DPolyPolygon aHairLinePolyPolygon; + + if(0.0 == getStrokeAttribute().getFullDotDashLen()) + { + aHairLinePolyPolygon.append(getB2DPolygon()); + } + else + { + // apply LineStyle + const basegfx::B2DPolygon aHairLinePolygon(basegfx::tools::adaptiveSubdivideByAngle(getB2DPolygon())); + aHairLinePolyPolygon = basegfx::tools::applyLineDashing(aHairLinePolygon, getStrokeAttribute().getDotDashArray(), getStrokeAttribute().getFullDotDashLen()); + + // merge LineStyle polygons to bigger parts + aHairLinePolyPolygon = basegfx::tools::mergeDashedLines(aHairLinePolyPolygon); + } + + if(getStrokeAttribute().getWidth()) + { + // create fat line data + aHairLinePolyPolygon = basegfx::tools::adaptiveSubdivideByAngle(aHairLinePolyPolygon); + const double fHalfLineWidth(getStrokeAttribute().getWidth() / 2.0); + const double fDegreeStepWidth(10.0 * F_PI180); + const double fMiterMinimumAngle(15.0 * F_PI180); + const basegfx::tools::B2DLineJoin aLineJoin(getStrokeAttribute().getLineJoin()); + basegfx::B2DPolyPolygon aAreaPolyPolygon; + + for(sal_uInt32 a(0L); a < aHairLinePolyPolygon.count(); a++) + { + const basegfx::B2DPolyPolygon aNewPolyPolygon(basegfx::tools::createAreaGeometryForPolygon( + aHairLinePolyPolygon.getB2DPolygon(a), fHalfLineWidth, aLineJoin, fDegreeStepWidth, fMiterMinimumAngle)); + aAreaPolyPolygon.append(aNewPolyPolygon); + } + + // prepare return value + Primitive2DSequence aRetval(aAreaPolyPolygon.count()); + + // create primitive + for(sal_uInt32 b(0L); b < aAreaPolyPolygon.count(); b++) + { + // put into single polyPolygon primitives to make clear thta this is NOT meant + // to be painted XORed as fill rule. Alternatively, a melting process may be used + // here one day. + const basegfx::B2DPolyPolygon aNewPolyPolygon(aAreaPolyPolygon.getB2DPolygon(b)); + const Primitive2DReference xRef(new PolyPolygonColorPrimitive2D(aNewPolyPolygon, getStrokeAttribute().getColor())); + aRetval[b] = xRef; + } + + return aRetval; + } + else + { + // prepare return value + Primitive2DSequence aRetval(aHairLinePolyPolygon.count()); + + // create hair line data for all sub polygons + for(sal_uInt32 a(0L); a < aHairLinePolyPolygon.count(); a++) + { + const basegfx::B2DPolygon aCandidate = aHairLinePolyPolygon.getB2DPolygon(a); + const Primitive2DReference xRef(new PolygonHairlinePrimitive2D(aCandidate, getStrokeAttribute().getColor())); + aRetval[a] = xRef; + } + + return aRetval; + } + } + else + { + return Primitive2DSequence(); + } + } + + PolygonStrokePrimitive2D::PolygonStrokePrimitive2D( + const basegfx::B2DPolygon& rPolygon, + const attribute::StrokeAttribute& rStrokeAttribute) + : BasePrimitive2D(), + maPolygon(rPolygon), + maStrokeAttribute(rStrokeAttribute) + { + } + + bool PolygonStrokePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const + { + if(BasePrimitive2D::operator==(rPrimitive)) + { + const PolygonStrokePrimitive2D& rCompare = (PolygonStrokePrimitive2D&)rPrimitive; + + return (getB2DPolygon() == rCompare.getB2DPolygon() + && getStrokeAttribute() == rCompare.getStrokeAttribute()); + } + + return false; + } + + basegfx::B2DRange PolygonStrokePrimitive2D::getB2DRange(const geometry::ViewInformation2D& /*rViewInformation*/) const + { + // get range of it (subdivided) + basegfx::B2DRange aRetval(basegfx::tools::getRange(basegfx::tools::adaptiveSubdivideByAngle(getB2DPolygon()))); + + // if width, grow by line width + if(getStrokeAttribute().getWidth()) + { + aRetval.grow(getStrokeAttribute().getWidth() / 2.0); + } + + return aRetval; + } + + sal_uInt32 PolygonStrokePrimitive2D::getPrimitiveID() const + { + return Create2DPrimitiveID('2','P','S','t'); + } + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + Primitive2DSequence PolygonStrokeArrowPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + { + // copy local polygon, it may be changed + basegfx::B2DPolygon aLocalPolygon(getB2DPolygon()); + basegfx::B2DPolyPolygon aArrowA; + basegfx::B2DPolyPolygon aArrowB; + + if(!aLocalPolygon.isClosed()) + { + // apply arrows. To do that, make sure it's not a curve (necessary at the moment, maybe optimized later) + aLocalPolygon = basegfx::tools::adaptiveSubdivideByAngle(aLocalPolygon); + const double fPolyLength(basegfx::tools::getLength(aLocalPolygon)); + double fStart(0.0); + double fEnd(0.0); + + if(getStart().isActive()) + { + // create start arrow primitive and consume + aArrowA = basegfx::tools::createAreaGeometryForLineStartEnd( + aLocalPolygon, getStart().getB2DPolyPolygon(), true, getStart().getWidth(), getStart().isCentered() ? 0.5 : 0.0, &fStart); + + // create some overlapping + fStart *= 0.8; + } + + if(getEnd().isActive()) + { + // create end arrow primitive and consume + aArrowB = basegfx::tools::createAreaGeometryForLineStartEnd( + aLocalPolygon, getEnd().getB2DPolyPolygon(), false, getEnd().getWidth(), getEnd().isCentered() ? 0.5 : 0.0, &fEnd); + + // create some overlapping + fEnd *= 0.8; + } + + if(0.0 != fStart || 0.0 != fEnd) + { + // build new poly, consume something from old poly + aLocalPolygon = basegfx::tools::getSnippetAbsolute(aLocalPolygon, fStart, fPolyLength - fEnd, fPolyLength); + } + } + + // prepare return value + Primitive2DSequence aRetval(1L + (aArrowA.count() ? 1L : 0L) + (aArrowB.count() ? 1L : 0L)); + sal_uInt32 nInd(0L); + + // add shaft + const Primitive2DReference xRefShaft(new PolygonStrokePrimitive2D(aLocalPolygon, getStrokeAttribute())); + aRetval[nInd++] = xRefShaft; + + if(aArrowA.count()) + { + const Primitive2DReference xRefA(new PolyPolygonColorPrimitive2D(aArrowA, getStrokeAttribute().getColor())); + aRetval[nInd++] = xRefA; + } + + if(aArrowB.count()) + { + const Primitive2DReference xRefB(new PolyPolygonColorPrimitive2D(aArrowB, getStrokeAttribute().getColor())); + aRetval[nInd++] = xRefB; + } + + return aRetval; + } + + PolygonStrokeArrowPrimitive2D::PolygonStrokeArrowPrimitive2D( + const basegfx::B2DPolygon& rPolygon, + const attribute::StrokeAttribute& rStrokeAttribute, + const attribute::StrokeArrowAttribute& rStart, + const attribute::StrokeArrowAttribute& rEnd) + : PolygonStrokePrimitive2D(rPolygon, rStrokeAttribute), + maStart(rStart), + maEnd(rEnd) + { + } + + bool PolygonStrokeArrowPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const + { + if(PolygonStrokePrimitive2D::operator==(rPrimitive)) + { + const PolygonStrokeArrowPrimitive2D& rCompare = (PolygonStrokeArrowPrimitive2D&)rPrimitive; + + return (getStart() == rCompare.getStart() + && getEnd() == rCompare.getEnd()); + } + + return false; + } + + basegfx::B2DRange PolygonStrokeArrowPrimitive2D::getB2DRange(const geometry::ViewInformation2D& rViewInformation) const + { + basegfx::B2DRange aRetval; + + if(getStart().isActive() || getEnd().isActive()) + { + // use decomposition when line start/end is used + return BasePrimitive2D::getB2DRange(rViewInformation); + } + else + { + // get range from parent + return PolygonStrokePrimitive2D::getB2DRange(rViewInformation); + } + } + + sal_uInt32 PolygonStrokeArrowPrimitive2D::getPrimitiveID() const + { + return Create2DPrimitiveID('2','P','S','A'); + } + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/primitive2d/polypolygonprimitive2d.cxx b/drawinglayer/source/primitive2d/polypolygonprimitive2d.cxx new file mode 100644 index 000000000000..6320dd6f04d8 --- /dev/null +++ b/drawinglayer/source/primitive2d/polypolygonprimitive2d.cxx @@ -0,0 +1,261 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: polypolygonprimitive2d.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-10-19 10:35:04 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_POLYPOLYGONPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx> +#endif + +#ifndef _BGFX_POLYPOLYGON_B2DPOLYGONTOOLS_HXX +#include <basegfx/polygon/b2dpolypolygontools.hxx> +#endif + +#ifndef _BGFX_TOOLS_CANVASTOOLS_HXX +#include <basegfx/tools/canvastools.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_FILLGRADIENTPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/fillgradientprimitive2d.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_MASKPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/maskprimitive2d.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_FILLHATCHPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/fillhatchprimitive2d.hxx> +#endif + +#ifndef _BGFX_MATRIX_B2DHOMMATRIX_HXX +#include <basegfx/matrix/b2dhommatrix.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_FILLBITMAPPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/fillbitmapprimitive2d.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// + +using namespace com::sun::star; + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + PolyPolygonColorPrimitive2D::PolyPolygonColorPrimitive2D( + const basegfx::B2DPolyPolygon& rPolyPolygon, + const basegfx::BColor& rBColor) + : BasePrimitive2D(), + maPolyPolygon(rPolyPolygon), + maBColor(rBColor) + { + } + + bool PolyPolygonColorPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const + { + if(BasePrimitive2D::operator==(rPrimitive)) + { + const PolyPolygonColorPrimitive2D& rCompare = (PolyPolygonColorPrimitive2D&)rPrimitive; + + return (getB2DPolyPolygon() == rCompare.getB2DPolyPolygon() + && getBColor() == rCompare.getBColor()); + } + + return false; + } + + basegfx::B2DRange PolyPolygonColorPrimitive2D::getB2DRange(const geometry::ViewInformation2D& /*rViewInformation*/) const + { + // return range + return basegfx::tools::getRange(basegfx::tools::adaptiveSubdivideByAngle(getB2DPolyPolygon())); + } + + sal_uInt32 PolyPolygonColorPrimitive2D::getPrimitiveID() const + { + return Create2DPrimitiveID('2','P','P','C'); + } + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + Primitive2DSequence PolyPolygonGradientPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const + { + // create SubSequence with FillGradientPrimitive2D + FillGradientPrimitive2D* pNewGradient = new FillGradientPrimitive2D(getB2DRange(rViewInformation), getFillGradient()); + const Primitive2DReference xSubRef(pNewGradient); + const Primitive2DSequence aSubSequence(&xSubRef, 1L); + + // create mask primitive + MaskPrimitive2D* pNewMask = new MaskPrimitive2D(getB2DPolyPolygon(), aSubSequence); + const Primitive2DReference xRef(pNewMask); + return Primitive2DSequence(&xRef, 1L); + } + + PolyPolygonGradientPrimitive2D::PolyPolygonGradientPrimitive2D( + const basegfx::B2DPolyPolygon& rPolyPolygon, + const basegfx::BColor& rBColor, + const attribute::FillGradientAttribute& rFillGradient) + : PolyPolygonColorPrimitive2D(rPolyPolygon, rBColor), + maFillGradient(rFillGradient) + { + } + + bool PolyPolygonGradientPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const + { + if(PolyPolygonColorPrimitive2D::operator==(rPrimitive)) + { + const PolyPolygonGradientPrimitive2D& rCompare = (PolyPolygonGradientPrimitive2D&)rPrimitive; + + return (getFillGradient() == rCompare.getFillGradient()); + } + + return false; + } + + sal_uInt32 PolyPolygonGradientPrimitive2D::getPrimitiveID() const + { + return Create2DPrimitiveID('2','P','P','G'); + } + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + Primitive2DSequence PolyPolygonHatchPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const + { + // create SubSequence with FillHatchPrimitive2D + FillHatchPrimitive2D* pNewHatch = new FillHatchPrimitive2D(getB2DRange(rViewInformation), getBColor(), getFillHatch()); + const Primitive2DReference xSubRef(pNewHatch); + const Primitive2DSequence aSubSequence(&xSubRef, 1L); + + // create mask primitive + MaskPrimitive2D* pNewMask = new MaskPrimitive2D(getB2DPolyPolygon(), aSubSequence); + const Primitive2DReference xRef(pNewMask); + return Primitive2DSequence(&xRef, 1L); + } + + PolyPolygonHatchPrimitive2D::PolyPolygonHatchPrimitive2D( + const basegfx::B2DPolyPolygon& rPolyPolygon, + const basegfx::BColor& rBColor, + const attribute::FillHatchAttribute& rFillHatch) + : PolyPolygonColorPrimitive2D(rPolyPolygon, rBColor), + maFillHatch(rFillHatch) + { + } + + bool PolyPolygonHatchPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const + { + if(PolyPolygonColorPrimitive2D::operator==(rPrimitive)) + { + const PolyPolygonHatchPrimitive2D& rCompare = (PolyPolygonHatchPrimitive2D&)rPrimitive; + + return (getFillHatch() == rCompare.getFillHatch()); + } + + return false; + } + + sal_uInt32 PolyPolygonHatchPrimitive2D::getPrimitiveID() const + { + return Create2DPrimitiveID('2','P','P','H'); + } + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + Primitive2DSequence PolyPolygonBitmapPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const + { + // create SubSequence with FillBitmapPrimitive2D + const basegfx::B2DRange aOwnRange(getB2DRange(rViewInformation)); + basegfx::B2DHomMatrix aNewObjectTransform; + aNewObjectTransform.set(0, 0, aOwnRange.getWidth()); + aNewObjectTransform.set(1, 1, aOwnRange.getHeight()); + aNewObjectTransform.set(0, 2, aOwnRange.getMinX()); + aNewObjectTransform.set(1, 2, aOwnRange.getMinY()); + FillBitmapPrimitive2D* pNewBitmap = new FillBitmapPrimitive2D(aNewObjectTransform, getFillBitmap()); + const Primitive2DReference xSubRef(pNewBitmap); + const Primitive2DSequence aSubSequence(&xSubRef, 1L); + + // create mask primitive + MaskPrimitive2D* pNewMask = new MaskPrimitive2D(getB2DPolyPolygon(), aSubSequence); + const Primitive2DReference xRef(pNewMask); + return Primitive2DSequence(&xRef, 1L); + } + + PolyPolygonBitmapPrimitive2D::PolyPolygonBitmapPrimitive2D( + const basegfx::B2DPolyPolygon& rPolyPolygon, + const basegfx::BColor& rBColor, + const attribute::FillBitmapAttribute& rFillBitmap) + : PolyPolygonColorPrimitive2D(rPolyPolygon, rBColor), + maFillBitmap(rFillBitmap) + { + } + + bool PolyPolygonBitmapPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const + { + if(PolyPolygonColorPrimitive2D::operator==(rPrimitive)) + { + const PolyPolygonBitmapPrimitive2D& rCompare = (PolyPolygonBitmapPrimitive2D&)rPrimitive; + + return (getFillBitmap() == rCompare.getFillBitmap()); + } + + return false; + } + + sal_uInt32 PolyPolygonBitmapPrimitive2D::getPrimitiveID() const + { + return Create2DPrimitiveID('2','P','P','B'); + } + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/primitive2d/sceneprimitive2d.cxx b/drawinglayer/source/primitive2d/sceneprimitive2d.cxx new file mode 100644 index 000000000000..1b4584582dc9 --- /dev/null +++ b/drawinglayer/source/primitive2d/sceneprimitive2d.cxx @@ -0,0 +1,427 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: sceneprimitive2d.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-10-19 10:35:04 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_SCENEPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/sceneprimitive2d.hxx> +#endif + +#ifndef _BGFX_TOOLS_CANVASTOOLS_HXX +#include <basegfx/tools/canvastools.hxx> +#endif + +#ifndef _BGFX_POLYGON_B2DPOLYGONTOOLS_HXX +#include <basegfx/polygon/b2dpolygontools.hxx> +#endif + +#ifndef _BGFX_POLYGON_B2DPOLYGON_HXX +#include <basegfx/polygon/b2dpolygon.hxx> +#endif + +#ifndef _BGFX_POLYPOLYGON_B2DPOLYGONCLIPPER_HXX +#include <basegfx/polygon/b2dpolygonclipper.hxx> +#endif + +#ifndef _BGFX_POLYPOLYGON_B2DPOLYGONTOOLS_HXX +#include <basegfx/polygon/b2dpolypolygontools.hxx> +#endif + +#ifndef _BGFX_MATRIX_B2DHOMMATRIX_HXX +#include <basegfx/matrix/b2dhommatrix.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_BITMAPPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/bitmapprimitive2d.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PROCESSOR3D_DEFAULTPROCESSOR3D_HXX +#include <drawinglayer/processor3d/defaultprocessor3d.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PROCESSOR3D_SHADOW3DEXTRACTOR_HXX +#include <drawinglayer/processor3d/shadow3dextractor.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PROCESSOR3D_LABEL3DEXTRACTOR_HXX +#include <drawinglayer/processor3d/label3dextractor.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_GEOMETRY_VIEWINFORMATION2D_HXX +#include <drawinglayer/geometry/viewinformation2d.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// + +using namespace com::sun::star; + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + Primitive2DSequence ScenePrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const + { + Primitive2DSequence aRetval; + + // create 2D shadows from contained 3D primitives. This creates the shadow primitives on demand and tells if + // there are some or not. Do this at start, the shadow might still be visible even when the scene is not + if(impGetShadow3D(rViewInformation)) + { + // test visibility + const basegfx::B2DRange aShadow2DRange(getB2DRangeFromPrimitive2DSequence(maShadowPrimitives, rViewInformation)); + + if(aShadow2DRange.overlaps(rViewInformation.getViewport())) + { + // add extracted 2d shadows (before 3d scene creations itself) + aRetval = maShadowPrimitives; + } + } + + // get geometry of output range + basegfx::B2DPolygon aLogicOutline(basegfx::tools::createPolygonFromRect(basegfx::B2DRange(0.0, 0.0, 1.0, 1.0))); + aLogicOutline.transform(getTransformation3D().getObjectTransformation()); + + // clip it against ViewRange + const basegfx::B2DPolyPolygon aLogicClippedOutline(basegfx::tools::clipPolygonOnRange(aLogicOutline, rViewInformation.getViewport(), true, false)); + const basegfx::B2DRange aLogicVisiblePart(basegfx::tools::getRange(aLogicClippedOutline)); + + if(!aLogicVisiblePart.isEmpty()) + { + // transform back to unity + basegfx::B2DHomMatrix aInverseTransform(getTransformation3D().getObjectTransformation()); + basegfx::B2DPolyPolygon aUnitClippedOutline(aLogicClippedOutline); + aInverseTransform.invert(); + aUnitClippedOutline.transform(aInverseTransform); + + // get logical size by decomposing + basegfx::B2DVector aScale, aTranslate; + double fRotate, fShearX; + getTransformation3D().getObjectTransformation().decompose(aScale, aTranslate, fRotate, fShearX); + + // get logical sizes and generate visible part in unit coordinates + double fLogicSizeX(aScale.getX()); + double fLogicSizeY(aScale.getY()); + const basegfx::B2DRange aUnitVisiblePart(basegfx::tools::getRange(aUnitClippedOutline)); + + // test if view size (pixel) maybe too big and limit it + const double fViewSizeX(fLogicSizeX * (rViewInformation.getViewTransformation() * basegfx::B2DVector(aUnitVisiblePart.getWidth(), 0.0)).getLength()); + const double fViewSizeY(fLogicSizeY * (rViewInformation.getViewTransformation() * basegfx::B2DVector(0.0, aUnitVisiblePart.getHeight())).getLength()); + const double fViewVisibleArea(fViewSizeX * fViewSizeY); + double fReduceFactor(1.0); + + if(fViewVisibleArea > 1000000.0) + { + fReduceFactor = sqrt(1000000.0 / fViewVisibleArea); + fLogicSizeX *= fReduceFactor; + fLogicSizeY *= fReduceFactor; + } + + // use default 3D primitive processor to create BitmapEx for aUnitVisiblePart and process + processor3d::DefaultProcessor3D aProcessor3D( + rViewInformation, + getTransformation3D(), + getSdrSceneAttribute(), + getSdrLightingAttribute(), + fLogicSizeX, + fLogicSizeY, + aUnitVisiblePart); + + aProcessor3D.processNonTransparent(getChildren3D()); + aProcessor3D.processTransparent(getChildren3D()); + + const BitmapEx aNewBitmap(aProcessor3D.getBitmapEx()); + const Size aBitmapSizePixel(aNewBitmap.GetSizePixel()); + + if(aBitmapSizePixel.getWidth() && aBitmapSizePixel.getHeight()) + { + // correct reduce-factor free logic, view-unit-aligned coordinates for the created bitmap + // without translation + basegfx::B2DPoint aViewTopLeft(aUnitVisiblePart.getMinX() * aScale.getX(), aUnitVisiblePart.getMinY() * aScale.getY()); + aViewTopLeft *= rViewInformation.getViewTransformation(); + aViewTopLeft.setX(floor(aViewTopLeft.getX())); + aViewTopLeft.setY(floor(aViewTopLeft.getY())); + const basegfx::B2DPoint aLogicTopLeft(rViewInformation.getInverseViewTransformation() * aViewTopLeft); + + // same for size, do not forget to correct by fReduceFactor + const basegfx::B2DVector aViewSize(aBitmapSizePixel.getWidth() / fReduceFactor, aBitmapSizePixel.getHeight() / fReduceFactor); + const basegfx::B2DVector aLogicSize(rViewInformation.getInverseViewTransformation() * aViewSize); + + // create 2d transform from it. Target is to always have a output-pixel-aligned + // logic position and size wich corresponds to the bitmap size (when no reduceFactor) + basegfx::B2DHomMatrix aNew2DTransform; + aNew2DTransform.scale(aLogicSize.getX(), aLogicSize.getY()); + aNew2DTransform.translate(aLogicTopLeft.getX(), aLogicTopLeft.getY()); + aNew2DTransform.shearX(fShearX); + aNew2DTransform.rotate(fRotate); + aNew2DTransform.translate(aTranslate.getX(), aTranslate.getY()); + + // create bitmap primitive and add + BitmapPrimitive2D* pNewTextBitmap = new BitmapPrimitive2D(aNewBitmap, aNew2DTransform); + const Primitive2DReference xRef(pNewTextBitmap); + appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, xRef); + +#ifdef DBG_UTIL + { + // check if pixel size and transformation is correct + if(basegfx::fTools::equal(fReduceFactor, 1.0)) + { + if(basegfx::fTools::equalZero(fShearX) && basegfx::fTools::equalZero(fRotate)) + { + basegfx::B2DVector aScale, aTranslate; + double fRotate, fShearX; + + pNewTextBitmap->getTransform().decompose(aScale, aTranslate, fRotate, fShearX); + basegfx::B2DVector aViewSize(basegfx::absolute(aScale)); + aViewSize *= rViewInformation.getViewTransformation(); + const Size aSourceSizePixel(pNewTextBitmap->getBitmapEx().GetSizePixel()); + const bool bXEqual(aSourceSizePixel.getWidth() == basegfx::fround(aViewSize.getX())); + const bool bYEqual(aSourceSizePixel.getHeight() == basegfx::fround(aViewSize.getY())); + OSL_ENSURE(bXEqual && bYEqual, "3D renderer produced non-pixel-aligned graphic (!)"); + } + } + } +#endif + } + } + + // create 2D labels from contained 3D label primitives. This creates the label primitives on demand and tells if + // there are some or not. Do this at end, the labels might still be visible even when the scene is not + if(impGetLabel3D(rViewInformation)) + { + // test visibility + const basegfx::B2DRange aLabel2DRange(getB2DRangeFromPrimitive2DSequence(maLabelPrimitives, rViewInformation)); + + if(aLabel2DRange.overlaps(rViewInformation.getViewport())) + { + // add extracted 2d labels (after 3d scene creations) + appendPrimitive2DSequenceToPrimitive2DSequence(aRetval, maLabelPrimitives); + } + } + + return aRetval; + } + + ScenePrimitive2D::ScenePrimitive2D( + const primitive3d::Primitive3DSequence& rxChildren3D, + const attribute::SdrSceneAttribute& rSdrSceneAttribute, + const attribute::SdrLightingAttribute& rSdrLightingAttribute, + const geometry::Transformation3D& rTransformation3D) + : BasePrimitive2D(), + mxChildren3D(rxChildren3D), + maSdrSceneAttribute(rSdrSceneAttribute), + maSdrLightingAttribute(rSdrLightingAttribute), + maTransformation3D(rTransformation3D), + mbShadow3DChecked(false), + mbLabel3DChecked(false), + maLastViewTransformation(), + maLastViewport() + { + } + + bool ScenePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const + { + if(BasePrimitive2D::operator==(rPrimitive)) + { + const ScenePrimitive2D& rCompare = (ScenePrimitive2D&)rPrimitive; + + return (primitive3d::arePrimitive3DSequencesEqual(getChildren3D(), rCompare.getChildren3D()) + && getSdrSceneAttribute() == rCompare.getSdrSceneAttribute() + && getSdrLightingAttribute() == rCompare.getSdrLightingAttribute() + && getTransformation3D() == rCompare.getTransformation3D()); + } + + return false; + } + + sal_uInt32 ScenePrimitive2D::getPrimitiveID() const + { + return Create2DPrimitiveID('2','S','c','e'); + } + + basegfx::B2DRange ScenePrimitive2D::getB2DRange(const geometry::ViewInformation2D& rViewInformation) const + { + // call parent. Do not calculate using unit range since the decomposition may extend the range + // by single pixels to level out the boundaries of the created bitmap primitives. So, use + // the default mechanism to use the range of the sub-primitives. + basegfx::B2DRange aRetval(BasePrimitive2D::getB2DRange(rViewInformation)); + + // expand by evtl. existing shadow primitives + if(impGetShadow3D(rViewInformation)) + { + const basegfx::B2DRange aShadow2DRange(getB2DRangeFromPrimitive2DSequence(maShadowPrimitives, rViewInformation)); + + if(!aShadow2DRange.isEmpty()) + { + aRetval.expand(aShadow2DRange); + } + } + + // expand by evtl. existing label primitives + if(impGetLabel3D(rViewInformation)) + { + const basegfx::B2DRange aLabel2DRange(getB2DRangeFromPrimitive2DSequence(maLabelPrimitives, rViewInformation)); + + if(!aLabel2DRange.isEmpty()) + { + aRetval.expand(aLabel2DRange); + } + } + + return aRetval; + } + + Primitive2DSequence ScenePrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const + { + ::osl::MutexGuard aGuard( m_aMutex ); + + // check if mpLocalDecomposition can be reused. Basic decision is based on the + // comparison of old and new viewTransformations, if they are equal reuse is possible anyways. + bool bNeedNewDecomposition(false); + + if(getLocalDecomposition().hasElements()) + { + if(maLastViewport != rViewInformation.getViewport() || maLastViewTransformation != rViewInformation.getViewTransformation()) + { + bNeedNewDecomposition = true; + } + } + + if(bNeedNewDecomposition) + { + // here is space to find out if only the visible view area has changed (scroll) + // and thus the object decomposition may be reused. For that, the logic visible part + // and the view sizes need to be the same + basegfx::B2DPolygon aWorldOutline(basegfx::tools::createPolygonFromRect(basegfx::B2DRange(0.0, 0.0, 1.0, 1.0))); + aWorldOutline.transform(getTransformation3D().getObjectTransformation()); + + // calculate last clipped visible part + const basegfx::B2DPolyPolygon aLastLogicClippedOutline(basegfx::tools::clipPolygonOnRange(aWorldOutline, maLastViewport, true, false)); + const basegfx::B2DRange aLastLogicVisiblePart(basegfx::tools::getRange(aLastLogicClippedOutline)); + + // calculate new clipped visible part + const basegfx::B2DPolyPolygon aNewLogicClippedOutline(basegfx::tools::clipPolygonOnRange(aWorldOutline, rViewInformation.getViewport(), true, false)); + const basegfx::B2DRange aNewLogicVisiblePart(basegfx::tools::getRange(aNewLogicClippedOutline)); + + if(aLastLogicVisiblePart.equal(aNewLogicVisiblePart)) + { + // logic visible part is the same, check for same view size to test for zooming + basegfx::B2DRange aLastViewVisiblePart(aLastLogicVisiblePart); + aLastViewVisiblePart.transform(maLastViewTransformation); + const basegfx::B2DVector aLastViewSize(aLastViewVisiblePart.getRange()); + + basegfx::B2DRange aNewViewVisiblePart(aNewLogicVisiblePart); + aNewViewVisiblePart.transform(rViewInformation.getViewTransformation()); + const basegfx::B2DVector aNewViewSize(aNewViewVisiblePart.getRange()); + + if(aLastViewSize.equal(aNewViewSize)) + { + // view size is the same, reuse possible + bNeedNewDecomposition = false; + } + } + } + + if(bNeedNewDecomposition) + { + // conditions of last local decomposition have changed, delete + const_cast< ScenePrimitive2D* >(this)->setLocalDecomposition(Primitive2DSequence()); + } + + if(!getLocalDecomposition().hasElements()) + { + // remember ViewRange and ViewTransformation + const_cast< ScenePrimitive2D* >(this)->maLastViewTransformation = rViewInformation.getViewTransformation(); + const_cast< ScenePrimitive2D* >(this)->maLastViewport = rViewInformation.getViewport(); + } + + // use parent implementation + return BasePrimitive2D::get2DDecomposition(rViewInformation); + } + + bool ScenePrimitive2D::impGetShadow3D(const geometry::ViewInformation2D& rViewInformation) const + { + osl::MutexGuard aGuard( m_aMutex ); + + // create on demand + if(!mbShadow3DChecked && getChildren3D().hasElements()) + { + // create shadow extraction processor + processor3d::Shadow3DExtractingProcessor aShadowProcessor( + rViewInformation.getViewTime(), + getTransformation3D(), + getSdrLightingAttribute(), + getChildren3D(), + getSdrSceneAttribute().getShadowSlant()); + + // process local primitives + aShadowProcessor.process(getChildren3D()); + + // fetch result and set checked flag + const_cast< ScenePrimitive2D* >(this)->maShadowPrimitives = aShadowProcessor.getPrimitive2DSequence(); + const_cast< ScenePrimitive2D* >(this)->mbShadow3DChecked = true; + } + + // return if there are shadow primitives + return maShadowPrimitives.hasElements(); + } + + bool ScenePrimitive2D::impGetLabel3D(const geometry::ViewInformation2D& rViewInformation) const + { + osl::MutexGuard aGuard( m_aMutex ); + + // create on demand + if(!mbLabel3DChecked && getChildren3D().hasElements()) + { + // create label extraction processor + processor3d::Label3DExtractingProcessor aLabelProcessor( + rViewInformation.getViewTime(), + getTransformation3D()); + + // process local primitives + aLabelProcessor.process(getChildren3D()); + + // fetch result and set checked flag + const_cast< ScenePrimitive2D* >(this)->maLabelPrimitives = aLabelProcessor.getPrimitive2DSequence(); + const_cast< ScenePrimitive2D* >(this)->mbLabel3DChecked = true; + } + + // return if there are label primitives + return maLabelPrimitives.hasElements(); + } + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/primitive2d/shadowprimitive2d.cxx b/drawinglayer/source/primitive2d/shadowprimitive2d.cxx new file mode 100644 index 000000000000..b716a2ae6835 --- /dev/null +++ b/drawinglayer/source/primitive2d/shadowprimitive2d.cxx @@ -0,0 +1,131 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: shadowprimitive2d.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-10-19 10:35:04 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_SHADOWPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/shadowprimitive2d.hxx> +#endif + +#ifndef _BGFX_COLOR_BCOLORMODIFIER_HXX +#include <basegfx/color/bcolormodifier.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_MODIFIEDCOLORPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_TRANSFORMPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/transformprimitive2d.hxx> +#endif + +#ifndef _BGFX_TOOLS_CANVASTOOLS_HXX +#include <basegfx/tools/canvastools.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_ALPHAPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/alphaprimitive2d.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_UNIFIEDALPHAPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/unifiedalphaprimitive2d.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// + +using namespace com::sun::star; + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + Primitive2DSequence ShadowPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + { + Primitive2DSequence aRetval; + + if(getChildren().hasElements()) + { + // create a modifiedColorPrimitive containing the shadow color and the content + const basegfx::BColorModifier aBColorModifier(getShadowColor()); + const Primitive2DReference xRefA(new ModifiedColorPrimitive2D(getChildren(), aBColorModifier)); + const Primitive2DSequence aSequenceB(&xRefA, 1L); + + // build transformed primitiveVector with shadow offset and add to target + const Primitive2DReference xRefB(new TransformPrimitive2D(getShadowTransform(), aSequenceB)); + aRetval = Primitive2DSequence(&xRefB, 1L); + } + + return aRetval; + } + + ShadowPrimitive2D::ShadowPrimitive2D( + const basegfx::B2DHomMatrix& rShadowTransform, + const basegfx::BColor& rShadowColor, + const Primitive2DSequence& rChildren) + : GroupPrimitive2D(rChildren), + maShadowTransform(rShadowTransform), + maShadowColor(rShadowColor) + { + } + + bool ShadowPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const + { + if(GroupPrimitive2D::operator==(rPrimitive)) + { + const ShadowPrimitive2D& rCompare = static_cast< const ShadowPrimitive2D& >(rPrimitive); + + return (getShadowTransform() == rCompare.getShadowTransform() + && getShadowColor() == rCompare.getShadowColor()); + } + + return false; + } + + sal_uInt32 ShadowPrimitive2D::getPrimitiveID() const + { + return Create2DPrimitiveID('2','S','h','a'); + } + + basegfx::B2DRange ShadowPrimitive2D::getB2DRange(const geometry::ViewInformation2D& rViewInformation) const + { + basegfx::B2DRange aRetval(getB2DRangeFromPrimitive2DSequence(getChildren(), rViewInformation)); + aRetval.transform(getShadowTransform()); + return aRetval; + } + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/primitive2d/textlayoutdevice.cxx b/drawinglayer/source/primitive2d/textlayoutdevice.cxx new file mode 100644 index 000000000000..0156d114ffa2 --- /dev/null +++ b/drawinglayer/source/primitive2d/textlayoutdevice.cxx @@ -0,0 +1,217 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: textlayoutdevice.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-10-19 10:35:04 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef INCLUDED_DRAWINGLAYER_TEXTLAYOUTDEVICE_HXX +#include <drawinglayer/primitive2d/textlayoutdevice.hxx> +#endif + +#ifndef _SV_TIMER_HXX +#include <vcl/timer.hxx> +#endif + +#ifndef _SV_VIRDEV_HXX +#include <vcl/virdev.hxx> +#endif + +#ifndef _SV_FONT_HXX +#include <vcl/font.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_TEXTPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/textprimitive2d.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// +// VDev RevDevice provider + +namespace +{ + class ImpTimedRefDev : public Timer + { + ImpTimedRefDev** mppStaticPointerOnMe; + VirtualDevice* mpVirDev; + sal_uInt32 mnUseCount; + + public: + ImpTimedRefDev(ImpTimedRefDev** ppStaticPointerOnMe); + ~ImpTimedRefDev(); + virtual void Timeout(); + + VirtualDevice& acquireVirtualDevice(); + void releaseVirtualDevice(); + }; + + ImpTimedRefDev::ImpTimedRefDev(ImpTimedRefDev** ppStaticPointerOnMe) + : mppStaticPointerOnMe(ppStaticPointerOnMe), + mpVirDev(0L), + mnUseCount(0L) + { + SetTimeout(3L * 60L * 1000L); // three minutes + Start(); + } + + ImpTimedRefDev::~ImpTimedRefDev() + { + OSL_ENSURE(0L == mnUseCount, "destruction of a still used ImpTimedRefDev (!)"); + + if(mppStaticPointerOnMe && *mppStaticPointerOnMe) + { + *mppStaticPointerOnMe = 0L; + } + + if(mpVirDev) + { + delete mpVirDev; + } + } + + void ImpTimedRefDev::Timeout() + { + // for obvious reasons, do not call anything after this + delete (this); + } + + VirtualDevice& ImpTimedRefDev::acquireVirtualDevice() + { + if(!mpVirDev) + { + mpVirDev = new VirtualDevice(); + mpVirDev->SetMapMode(MAP_100TH_MM); + mpVirDev->SetReferenceDevice(VirtualDevice::REFDEV_MODE06); + } + + if(!mnUseCount) + { + Stop(); + } + + mnUseCount++; + + return *mpVirDev; + } + + void ImpTimedRefDev::releaseVirtualDevice() + { + OSL_ENSURE(mnUseCount, "mismatch call number to releaseVirtualDevice() (!)"); + mnUseCount--; + + if(!mnUseCount) + { + Start(); + } + } +} // end of anonymous namespace + +////////////////////////////////////////////////////////////////////////////// +// access to one global ImpTimedRefDev incarnation in namespace drawinglayer::primitive + +namespace drawinglayer +{ + namespace primitive2d + { + // static pointer here + ImpTimedRefDev* pImpGlobalRefDev = 0L; + + // static methods here + VirtualDevice& acquireGlobalVirtualDevice() + { + if(!pImpGlobalRefDev) + { + pImpGlobalRefDev = new ImpTimedRefDev(&pImpGlobalRefDev); + } + + return pImpGlobalRefDev->acquireVirtualDevice(); + } + + void releaseGlobalVirtualDevice() + { + OSL_ENSURE(pImpGlobalRefDev, "releaseGlobalVirtualDevice() without prior acquireGlobalVirtualDevice() call(!)"); + pImpGlobalRefDev->releaseVirtualDevice(); + } + + TextLayouterDevice::TextLayouterDevice() + : mrDevice(acquireGlobalVirtualDevice()) + { + } + + TextLayouterDevice::~TextLayouterDevice() + { + releaseGlobalVirtualDevice(); + } + + void TextLayouterDevice::setFont(const Font& rFont) + { + mrDevice.SetFont(rFont); + } + + void TextLayouterDevice::setFontAttributes(const FontAttributes& rFontAttributes, const basegfx::B2DHomMatrix& rTransform) + { + mrDevice.SetFont(getVclFontFromFontAttributes(rFontAttributes, rTransform)); + } + + double TextLayouterDevice::getTextHeight() + { + return mrDevice.GetTextHeight(); + } + + double TextLayouterDevice::getTextWidth(const String& rText, xub_StrLen nIndex, xub_StrLen nLength) + { + return mrDevice.GetTextWidth(rText, nIndex, nLength); + } + + bool TextLayouterDevice::getTextOutlines(PolyPolyVector& rPolyPolyVector, const String& rText, xub_StrLen nIndex, xub_StrLen nLength, const ::std::vector< sal_Int32 >& rDXArray) + { + return mrDevice.GetTextOutlines(rPolyPolyVector, rText, nIndex, nIndex, nLength, true, 0, &(rDXArray[0])); + } + + basegfx::B2DRange TextLayouterDevice::getTextBoundRect(const String& rText, xub_StrLen nIndex, xub_StrLen nLength) + { + if(rText.Len() && nLength) + { + Rectangle aRect; + mrDevice.GetTextBoundRect(aRect, rText, nIndex, nIndex, nLength); + + return basegfx::B2DRange(aRect.Left(), aRect.Top(), aRect.Right(), aRect.Bottom()); + } + else + { + return basegfx::B2DRange(); + } + } + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/primitive2d/textprimitive2d.cxx b/drawinglayer/source/primitive2d/textprimitive2d.cxx new file mode 100644 index 000000000000..286cf88bf2e1 --- /dev/null +++ b/drawinglayer/source/primitive2d/textprimitive2d.cxx @@ -0,0 +1,378 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: textprimitive2d.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-10-19 10:35:04 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE_TEXTPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/textprimitive2d.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_TEXTLAYOUTDEVICE_HXX +#include <drawinglayer/primitive2d/textlayoutdevice.hxx> +#endif + +#ifndef _SV_VIRDEV_HXX +#include <vcl/virdev.hxx> +#endif + +#ifndef _BGFX_COLOR_BCOLOR_HXX +#include <basegfx/color/bcolor.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_POLYPOLYGONPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx> +#endif + +#ifndef _BGFX_POLYGON_B2DPOLYGONTOOLS_HXX +#include <basegfx/polygon/b2dpolygontools.hxx> +#endif + +#ifndef _BGFX_POLYGON_B2DPOLYGON_HXX +#include <basegfx/polygon/b2dpolygon.hxx> +#endif + +#ifndef _BGFX_NUMERIC_FTOOLS_HXX +#include <basegfx/numeric/ftools.hxx> +#endif + +#ifndef _BGFX_TOOLS_CANVASTOOLS_HXX +#include <basegfx/tools/canvastools.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + Font getVclFontFromFontAttributes(const FontAttributes& rFontAttributes, const basegfx::B2DHomMatrix& rTransform) + { + // decompose matrix to have position and size of text + basegfx::B2DVector aScale, aTranslate; + double fRotate, fShearX; + rTransform.decompose(aScale, aTranslate, fRotate, fShearX); + return getVclFontFromFontAttributes(rFontAttributes, aScale, fRotate); + } + + Font getVclFontFromFontAttributes(const FontAttributes& rFontAttributes, const basegfx::B2DVector& rFontSize, double fFontRotation) + { + sal_uInt32 nWidth(basegfx::fround(fabs(rFontSize.getX()))); + sal_uInt32 nHeight(basegfx::fround(fabs(rFontSize.getY()))); + + if(nWidth == nHeight) + { + nWidth = 0L; + } + + Font aRetval( + rFontAttributes.maFamilyName, + rFontAttributes.maStyleName, + Size(nWidth, nHeight)); + + if(!basegfx::fTools::equalZero(fFontRotation)) + { + sal_Int16 aRotate10th((sal_Int16)(fFontRotation * (-1800.0/F_PI))); + aRetval.SetOrientation(aRotate10th % 3600); + } + + aRetval.SetAlign(ALIGN_BASELINE); + aRetval.SetCharSet(rFontAttributes.mbSymbol ? RTL_TEXTENCODING_SYMBOL : RTL_TEXTENCODING_UNICODE); + aRetval.SetVertical(rFontAttributes.mbVertical ? TRUE : FALSE); + aRetval.SetWeight(static_cast<FontWeight>(rFontAttributes.mnWeight)); + aRetval.SetItalic(rFontAttributes.mbItalic ? ITALIC_NORMAL : ITALIC_NONE); + + return aRetval; + } + + FontAttributes getFontAttributesFromVclFont(basegfx::B2DVector& rSize, const Font& rFont) + { + FontAttributes aRetval; + + aRetval.maFamilyName = rFont.GetName(); + aRetval.maStyleName = rFont.GetStyleName(); + aRetval.mbSymbol = (RTL_TEXTENCODING_SYMBOL == rFont.GetCharSet()); + aRetval.mbVertical = rFont.IsVertical(); + aRetval.mnWeight = static_cast<sal_uInt16>(rFont.GetWeight()); + aRetval.mbItalic = (rFont.GetItalic() != ITALIC_NONE); + + const sal_Int32 nWidth(rFont.GetSize().getWidth()); + const sal_Int32 nHeight(rFont.GetSize().getHeight()); + rSize.setX(nWidth ? nWidth : nHeight); + rSize.setY(nHeight); + + return aRetval; + } + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +using namespace com::sun::star; + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + Primitive2DSequence TextSimplePortionPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + { + // get integer DXArray for getTextOutlines call (ATM uses vcl) + ::std::vector< sal_Int32 > aNewIntegerDXArray; + getIntegerDXArray(aNewIntegerDXArray); + + // get outlines + TextLayouterDevice aTextLayouter; + aTextLayouter.setFontAttributes(getFontAttributes(), getTextTransform()); + PolyPolyVector aPolyPolyVector; + aTextLayouter.getTextOutlines(aPolyPolyVector, getText(), 0L, getText().Len(), aNewIntegerDXArray); + + // get result count + const sal_uInt32 nCount(aPolyPolyVector.size()); + + if(nCount) + { + // outlines already have scale and rotate included, so build new transformation + basegfx::B2DVector aScale, aTranslate; + double fRotate, fShearX; + getTextTransform().decompose(aScale, aTranslate, fRotate, fShearX); + basegfx::B2DHomMatrix aNewTransform; + const bool bShearUsed(!basegfx::fTools::equalZero(fShearX)); + const bool bRotateUsed(!basegfx::fTools::equalZero(fRotate)); + + if(bShearUsed) + { + // The order would be wrong when just adding shear, so rotate back, apply shear, rotate again + if(bRotateUsed) + { + aNewTransform.rotate(-fRotate); + } + + // add shear (before rotate) + aNewTransform.shearX(fShearX); + + if(bRotateUsed) + { + aNewTransform.rotate(fRotate); + } + } + + // add translation + aNewTransform.translate(aTranslate.getX(), aTranslate.getY()); + + // prepare retval + Primitive2DSequence aRetval(nCount); + + for(sal_uInt32 a(0L); a < nCount; a++) + { + // prepare polygon + basegfx::B2DPolyPolygon aPolyPolygon(aPolyPolyVector[a].getB2DPolyPolygon()); + aPolyPolygon.transform(aNewTransform); + + // create primitive + const Primitive2DReference xRef(new PolyPolygonColorPrimitive2D(aPolyPolygon, getFontColor())); + aRetval[a] = xRef; + } + + return aRetval; + } + else + { + return Primitive2DSequence(); + } + } + + TextSimplePortionPrimitive2D::TextSimplePortionPrimitive2D( + const basegfx::B2DHomMatrix& rNewTransform, + const String& rText, + const ::std::vector< double >& rDXArray, + const FontAttributes& rFontAttributes, + const basegfx::BColor& rFontColor) + : BasePrimitive2D(), + maTextTransform(rNewTransform), + maText(rText), + maDXArray(rDXArray), + maFontAttributes(rFontAttributes), + maFontColor(rFontColor) + { + } + + void TextSimplePortionPrimitive2D::getIntegerDXArray(::std::vector< sal_Int32 >& rDXArray) const + { + rDXArray.clear(); + + if(getDXArray().size()) + { + rDXArray.reserve(getDXArray().size()); + const basegfx::B2DVector aPixelVector(getTextTransform() * basegfx::B2DVector(1.0, 0.0)); + const double fPixelVectorLength(aPixelVector.getLength()); + + for(::std::vector< double >::const_iterator aStart(getDXArray().begin()); aStart != getDXArray().end(); aStart++) + { + rDXArray.push_back(basegfx::fround((*aStart) * fPixelVectorLength)); + } + } + } + + bool TextSimplePortionPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const + { + if(BasePrimitive2D::operator==(rPrimitive)) + { + const TextSimplePortionPrimitive2D& rCompare = (TextSimplePortionPrimitive2D&)rPrimitive; + + return (getTextTransform() == rCompare.getTextTransform() + && getText() == rCompare.getText() + && getDXArray() == rCompare.getDXArray() + && getFontAttributes() == rCompare.getFontAttributes() + && getFontColor() == rCompare.getFontColor()); + } + + return false; + } + + sal_uInt32 TextSimplePortionPrimitive2D::getPrimitiveID() const + { + return Create2DPrimitiveID('2','T','S','i'); + } + + basegfx::B2DRange TextSimplePortionPrimitive2D::getB2DRange(const geometry::ViewInformation2D& /*rViewInformation*/) const + { + const xub_StrLen aStrLen(getText().Len()); + basegfx::B2DRange aRetval; + + if(aStrLen) + { + // get TextBoundRect as base size + TextLayouterDevice aTextLayouter; + aTextLayouter.setFontAttributes(getFontAttributes(), getTextTransform()); + aRetval = aTextLayouter.getTextBoundRect(getText(), 0L, aStrLen); + + // apply textTransform to it, but without scaling. The scale defines the font size + // which is already part of the fetched textRange + basegfx::B2DVector aScale, aTranslate; + double fRotate, fShearX; + basegfx::B2DHomMatrix aTextTransformWithoutScale; + + getTextTransform().decompose(aScale, aTranslate, fRotate, fShearX); + aTextTransformWithoutScale.shearX(fShearX); + aTextTransformWithoutScale.rotate(fRotate); + aTextTransformWithoutScale.translate(aTranslate.getX(), aTranslate.getY()); + aRetval.transform(aTextTransformWithoutScale); + } + + return aRetval; + } + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + Primitive2DSequence TextComplexPortionPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + { + // TODO: need to take care of + // -underline + // -strikethrough + // -emphasis mark + // -relief (embosses/engraved) + // -shadow + // -outline + + // ATM: Just create a simple text primitive and ignore other attributes + const Primitive2DReference xRef(new TextSimplePortionPrimitive2D(getTextTransform(), getText(), getDXArray(), getFontAttributes(), getFontColor())); + return Primitive2DSequence(&xRef, 1L); + } + + TextComplexPortionPrimitive2D::TextComplexPortionPrimitive2D( + const basegfx::B2DHomMatrix& rNewTransform, + const String& rText, + const ::std::vector< double >& rDXArray, + const FontAttributes& rFontAttributes, + const basegfx::BColor& rFontColor, + FontUnderline eFontUnderline, + bool bUnderlineAbove, + FontStrikeout eFontStrikeout, + bool bWordLineMode, + FontEmphasisMark eFontEmphasisMark, + bool bEmphasisMarkAbove, + bool bEmphasisMarkBelow, + FontRelief eFontRelief, + bool bShadow, + bool bOutline) + : TextSimplePortionPrimitive2D(rNewTransform, rText, rDXArray, rFontAttributes, rFontColor), + meFontUnderline(eFontUnderline), + meFontStrikeout(eFontStrikeout), + meFontRelief(eFontRelief), + mbUnderlineAbove(bUnderlineAbove), + mbWordLineMode(bWordLineMode), + meFontEmphasisMark(eFontEmphasisMark), + mbEmphasisMarkAbove(bEmphasisMarkAbove), + mbEmphasisMarkBelow(bEmphasisMarkBelow), + mbShadow(bShadow), + mbOutline(bOutline) + { + } + + bool TextComplexPortionPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const + { + if(TextSimplePortionPrimitive2D::operator==(rPrimitive)) + { + const TextComplexPortionPrimitive2D& rCompare = (TextComplexPortionPrimitive2D&)rPrimitive; + + return (getFontUnderline() == rCompare.getFontUnderline() + && getFontStrikeout() == rCompare.getFontStrikeout() + && getUnderlineAbove() == rCompare.getUnderlineAbove() + && getWordLineMode() == rCompare.getWordLineMode() + && getFontEmphasisMark() == rCompare.getFontEmphasisMark() + && getEmphasisMarkAbove() == rCompare.getEmphasisMarkAbove() + && getEmphasisMarkBelow() == rCompare.getEmphasisMarkBelow() + && getFontRelief() == rCompare.getFontRelief() + && getShadow() == rCompare.getShadow() + && getOutline() == rCompare.getOutline()); + } + + return false; + } + + sal_uInt32 TextComplexPortionPrimitive2D::getPrimitiveID() const + { + return Create2DPrimitiveID('2','T','C','o'); + } + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/primitive2d/transformprimitive2d.cxx b/drawinglayer/source/primitive2d/transformprimitive2d.cxx new file mode 100644 index 000000000000..eba0b39020cd --- /dev/null +++ b/drawinglayer/source/primitive2d/transformprimitive2d.cxx @@ -0,0 +1,89 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: transformprimitive2d.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-10-19 10:35:04 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_TRANSFORMPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/transformprimitive2d.hxx> +#endif + +#ifndef _BGFX_TOOLS_CANVASTOOLS_HXX +#include <basegfx/tools/canvastools.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// + +using namespace com::sun::star; + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + TransformPrimitive2D::TransformPrimitive2D( + const basegfx::B2DHomMatrix& rTransformation, + const Primitive2DSequence& rChildren) + : GroupPrimitive2D(rChildren), + maTransformation(rTransformation) + { + } + + bool TransformPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const + { + if(GroupPrimitive2D::operator==(rPrimitive)) + { + const TransformPrimitive2D& rCompare = static_cast< const TransformPrimitive2D& >(rPrimitive); + + return (getTransformation() == rCompare.getTransformation()); + } + + return false; + } + + basegfx::B2DRange TransformPrimitive2D::getB2DRange(const geometry::ViewInformation2D& rViewInformation) const + { + basegfx::B2DRange aRetval(getB2DRangeFromPrimitive2DSequence(getChildren(), rViewInformation)); + aRetval.transform(getTransformation()); + return aRetval; + } + + sal_uInt32 TransformPrimitive2D::getPrimitiveID() const + { + return Create2DPrimitiveID('2','T','r','a'); + } + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/primitive2d/unifiedalphaprimitive2d.cxx b/drawinglayer/source/primitive2d/unifiedalphaprimitive2d.cxx new file mode 100644 index 000000000000..29dda5d3a66e --- /dev/null +++ b/drawinglayer/source/primitive2d/unifiedalphaprimitive2d.cxx @@ -0,0 +1,124 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: unifiedalphaprimitive2d.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-10-19 10:35:04 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_UNIFIEDALPHAPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/unifiedalphaprimitive2d.hxx> +#endif + +#ifndef _BGFX_POLYGON_B2DPOLYGON_HXX +#include <basegfx/polygon/b2dpolygon.hxx> +#endif + +#ifndef _BGFX_POLYGON_B2DPOLYGONTOOLS_HXX +#include <basegfx/polygon/b2dpolygontools.hxx> +#endif + +#ifndef _BGFX_COLOR_BCOLOR_HXX +#include <basegfx/color/bcolor.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_POLYPOLYGONPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_ALPHAPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/alphaprimitive2d.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// + +using namespace com::sun::star; + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + Primitive2DSequence UnifiedAlphaPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const + { + if(0.0 == getAlpha()) + { + // no transparence used, so just use the content + return getChildren(); + } + else if(getAlpha() > 0.0 && getAlpha() < 1.0) + { + // create fill polygon for TransparenceList + const basegfx::B2DPolygon aPolygon(basegfx::tools::createPolygonFromRect(getB2DRangeFromPrimitive2DSequence(getChildren(), rViewInformation))); + const basegfx::BColor aGray(getAlpha(), getAlpha(), getAlpha()); + const Primitive2DReference xRefA(new PolyPolygonColorPrimitive2D(basegfx::B2DPolyPolygon(aPolygon), aGray)); + const Primitive2DSequence aAlphaContent(&xRefA, 1L); + + // create sub-transparence group with a gray-colored rectangular fill polygon + const Primitive2DReference xRefB(new AlphaPrimitive2D(getChildren(), aAlphaContent)); + return Primitive2DSequence(&xRefB, 1L); + } + else + { + // completely transparent or invalid definition, add nothing + return Primitive2DSequence(); + } + } + + UnifiedAlphaPrimitive2D::UnifiedAlphaPrimitive2D( + const Primitive2DSequence& rChildren, + double fAlpha) + : GroupPrimitive2D(rChildren), + mfAlpha(fAlpha) + { + } + + bool UnifiedAlphaPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const + { + if(GroupPrimitive2D::operator==(rPrimitive)) + { + const UnifiedAlphaPrimitive2D& rCompare = (UnifiedAlphaPrimitive2D&)rPrimitive; + + return (getAlpha() == rCompare.getAlpha()); + } + + return false; + } + + sal_uInt32 UnifiedAlphaPrimitive2D::getPrimitiveID() const + { + return Create2DPrimitiveID('2','U','A','l'); + } + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/primitive3d/baseprimitive3d.cxx b/drawinglayer/source/primitive3d/baseprimitive3d.cxx new file mode 100644 index 000000000000..10525a13d0d7 --- /dev/null +++ b/drawinglayer/source/primitive3d/baseprimitive3d.cxx @@ -0,0 +1,266 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: baseprimitive3d.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-10-19 10:38:32 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_BASEPRIMITIVE3D_HXX +#include <drawinglayer/primitive3d/baseprimitive3d.hxx> +#endif + +#ifndef _BGFX_TOOLS_CANVASTOOLS_HXX +#include <basegfx/tools/canvastools.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// + +using namespace com::sun::star; + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive3d + { + Primitive3DSequence BasePrimitive3D::createLocalDecomposition(double /*fTime*/) const + { + // default returns an empty sequence + return Primitive3DSequence(); + } + + BasePrimitive3D::BasePrimitive3D() + : BasePrimitive3DImplBase(m_aMutex), + maLocalDecomposition() + { + } + + bool BasePrimitive3D::operator==( const BasePrimitive3D& rPrimitive ) const + { + return (getPrimitiveID() == rPrimitive.getPrimitiveID()); + } + + basegfx::B3DRange BasePrimitive3D::getB3DRange(double fTime) const + { + return getB3DRangeFromPrimitive3DSequence(get3DDecomposition(fTime), fTime); + } + + + Primitive3DSequence BasePrimitive3D::get3DDecomposition(double fTime) const + { + ::osl::MutexGuard aGuard( m_aMutex ); + + if(!getLocalDecomposition().hasElements()) + { + const Primitive3DSequence aNewSequence(createLocalDecomposition(fTime)); + const_cast< BasePrimitive3D* >(this)->setLocalDecomposition(aNewSequence); + } + + return getLocalDecomposition(); + } + + Primitive3DSequence SAL_CALL BasePrimitive3D::getDecomposition( const graphic::Primitive3DParameters& aPrimitive2DParameters ) throw ( uno::RuntimeException ) + { + return get3DDecomposition(aPrimitive2DParameters.Time); + } + + geometry::RealRectangle3D SAL_CALL BasePrimitive3D::getRange( const graphic::Primitive3DParameters& aPrimitive2DParameters ) throw ( uno::RuntimeException ) + { + return basegfx::unotools::rectangle3DFromB3DRectangle(getB3DRange(aPrimitive2DParameters.Time)); + } + } // end of namespace primitive3d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// tooling + +namespace drawinglayer +{ + namespace primitive3d + { + // get range3D from a given Primitive3DReference + basegfx::B3DRange getB3DRangeFromPrimitive3DReference(const Primitive3DReference& rCandidate, double fTime) + { + basegfx::B3DRange aRetval; + + if(rCandidate.is()) + { + // try to get C++ implementation base + const BasePrimitive3D* pCandidate(dynamic_cast< BasePrimitive3D* >(rCandidate.get())); + + if(pCandidate) + { + // use it if possible + aRetval.expand(pCandidate->getB3DRange(fTime)); + } + else + { + // use UNO API call instead + graphic::Primitive3DParameters aPrimitive3DParameters; + aPrimitive3DParameters.Time = fTime; + aRetval.expand(basegfx::unotools::b3DRectangleFromRealRectangle3D(rCandidate->getRange(aPrimitive3DParameters))); + } + } + + return aRetval; + } + + // get range3D from a given Primitive3DSequence + basegfx::B3DRange getB3DRangeFromPrimitive3DSequence(const Primitive3DSequence& rCandidate, double fTime) + { + basegfx::B3DRange aRetval; + + if(rCandidate.hasElements()) + { + const sal_Int32 nCount(rCandidate.getLength()); + + for(sal_Int32 a(0L); a < nCount; a++) + { + aRetval.expand(getB3DRangeFromPrimitive3DReference(rCandidate[a], fTime)); + } + } + + return aRetval; + } + + bool arePrimitive3DReferencesEqual(const Primitive3DReference& rxA, const Primitive3DReference& rxB) + { + const sal_Bool bAIs(rxA.is()); + + if(bAIs != rxB.is()) + { + return false; + } + + if(!bAIs) + { + return true; + } + + const BasePrimitive3D* pA(dynamic_cast< const BasePrimitive3D* >(rxA.get())); + const BasePrimitive3D* pB(dynamic_cast< const BasePrimitive3D* >(rxB.get())); + const bool bAEqualZero(pA == 0L); + + if(bAEqualZero != (pB == 0L)) + { + return false; + } + + if(bAEqualZero) + { + return false; + } + + return (pA->operator==(*pB)); + } + + bool arePrimitive3DSequencesEqual(const Primitive3DSequence& rA, const Primitive3DSequence& rB) + { + const sal_Bool bAHasElements(rA.hasElements()); + + if(bAHasElements != rB.hasElements()) + { + return false; + } + + if(!bAHasElements) + { + return true; + } + + const sal_Int32 nCount(rA.getLength()); + + if(nCount != rB.getLength()) + { + return false; + } + + for(sal_Int32 a(0L); a < nCount; a++) + { + if(!arePrimitive3DReferencesEqual(rA[a], rB[a])) + { + return false; + } + } + + return true; + } + + // concatenate sequence + void appendPrimitive3DSequenceToPrimitive3DSequence(Primitive3DSequence& rDest, const Primitive3DSequence& rSource) + { + if(rSource.hasElements()) + { + if(rDest.hasElements()) + { + const sal_Int32 nSourceCount(rSource.getLength()); + const sal_Int32 nDestCount(rDest.getLength()); + const sal_Int32 nTargetCount(nSourceCount + nDestCount); + sal_Int32 nInsertPos(nDestCount); + + rDest.realloc(nTargetCount); + + for(sal_Int32 a(0L); a < nSourceCount; a++) + { + if(rSource[a].is()) + { + rDest[nInsertPos++] = rSource[a]; + } + } + + if(nInsertPos != nTargetCount) + { + rDest.realloc(nInsertPos); + } + } + else + { + rDest = rSource; + } + } + } + + // concatenate single Primitive3D + void appendPrimitive3DReferenceToPrimitive3DSequence(Primitive3DSequence& rDest, const Primitive3DReference& rSource) + { + if(rSource.is()) + { + const sal_Int32 nDestCount(rDest.getLength()); + rDest.realloc(nDestCount + 1L); + rDest[nDestCount] = rSource; + } + } + + } // end of namespace primitive3d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/primitive3d/groupprimitive3d.cxx b/drawinglayer/source/primitive3d/groupprimitive3d.cxx new file mode 100644 index 000000000000..1b89299acf27 --- /dev/null +++ b/drawinglayer/source/primitive3d/groupprimitive3d.cxx @@ -0,0 +1,86 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: groupprimitive3d.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-10-19 10:38:32 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_GROUPPRIMITIVE3D_HXX +#include <drawinglayer/primitive3d/groupprimitive3d.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// + +using namespace com::sun::star; + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive3d + { + /// default: just return children, so all renderers not supporting group will use it's content + Primitive3DSequence GroupPrimitive3D::createLocalDecomposition(double /*fTime*/) const + { + return getChildren(); + } + + GroupPrimitive3D::GroupPrimitive3D( const Primitive3DSequence& rChildren ) + : BasePrimitive3D(), + maChildren(rChildren) + { + } + + /** The compare opertator uses the Sequence::==operator, so only checking if + the rererences are equal. All non-equal references are interpreted as + non-equal. + */ + bool GroupPrimitive3D::operator==( const BasePrimitive3D& rPrimitive ) const + { + if(BasePrimitive3D::operator==(rPrimitive)) + { + const GroupPrimitive3D& rCompare = static_cast< const GroupPrimitive3D& >(rPrimitive); + + return (arePrimitive3DSequencesEqual(getChildren(), rCompare.getChildren())); + } + + return false; + } + + sal_uInt32 GroupPrimitive3D::getPrimitiveID() const + { + return Create3DPrimitiveID('3','G','r','o'); + } + } // end of namespace primitive3d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/primitive3d/hatchtextureprimitive3d.cxx b/drawinglayer/source/primitive3d/hatchtextureprimitive3d.cxx index 1ab1baa2827d..9b7c47f62ed3 100644 --- a/drawinglayer/source/primitive3d/hatchtextureprimitive3d.cxx +++ b/drawinglayer/source/primitive3d/hatchtextureprimitive3d.cxx @@ -4,9 +4,9 @@ * * $RCSfile: hatchtextureprimitive3d.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: aw $ $Date: 2006-08-09 16:51:14 $ + * last change: $Author: aw $ $Date: 2006-10-19 10:38:32 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -33,11 +33,11 @@ * ************************************************************************/ -#ifndef _DRAWINGLAYER_PRIMITIVE3D_HATCHTEXTUREPRIMITIVE3D_HXX +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_HATCHTEXTUREPRIMITIVE3D_HXX #include <drawinglayer/primitive3d/hatchtextureprimitive3d.hxx> #endif -#ifndef _DRAWINGLAYER_PRIMITIVE3D_POLYPOLYGONPRIMITIVE_HXX +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_POLYPOLYGONPRIMITIVE3D_HXX #include <drawinglayer/primitive3d/polypolygonprimitive3d.hxx> #endif @@ -57,6 +57,14 @@ #include <basegfx/polygon/b2dpolypolygontools.hxx> #endif +#ifndef _BGFX_RANGE_B2DRANGE_HXX +#include <basegfx/range/b2drange.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_TEXTURE_TEXTURE_HXX +#include <drawinglayer/texture/texture.hxx> +#endif + #ifndef _BGFX_POLYPOLYGON_B2DPOLYGONCLIPPER_HXX #include <basegfx/polygon/b2dpolygonclipper.hxx> #endif @@ -65,244 +73,268 @@ #include <basegfx/matrix/b3dhommatrix.hxx> #endif -#ifndef _DRAWINGLAYER_PRIMITIVE3D_POLYGONPRIMITIVE3D_HXX +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_POLYGONPRIMITIVE3D_HXX #include <drawinglayer/primitive3d/polygonprimitive3d.hxx> #endif ////////////////////////////////////////////////////////////////////////////// +using namespace com::sun::star; + +////////////////////////////////////////////////////////////////////////////// + namespace drawinglayer { namespace primitive3d { - void hatchTexturePrimitive3D::impCreateDecomposition(const primitiveVector3D& rSource, primitiveVector3D& rDest) + Primitive3DSequence HatchTexturePrimitive3D::createLocalDecomposition(double /*fTime*/) const { - for(sal_uInt32 a(0L); a < rSource.size(); a++) + Primitive3DSequence aRetval; + + if(getChildren().hasElements()) { - // get reference - const referencedPrimitive3D& rCandidate = rSource[a]; + const Primitive3DSequence aSource(getChildren()); + const sal_Int32 nSourceCount(aSource.getLength()); + std::vector< Primitive3DReference > aDestination; - // not all content is needed, remove transparencies and ModifiedColorPrimitives - switch(rCandidate.getID()) + for(sal_Int32 a(0L); a < nSourceCount; a++) { - case CreatePrimitiveID('P', 'O', 'M', '3'): + // get reference + const Primitive3DReference xReference(aSource[a]); + + if(xReference.is()) { - // polyPolygonMaterialPrimitive3D, check texturing and hatching - const polyPolygonMaterialPrimitive3D& rPrimitive = static_cast< const polyPolygonMaterialPrimitive3D& >(rCandidate.getBasePrimitive()); - const basegfx::B3DPolyPolygon aFillPolyPolygon(rPrimitive.getB3DPolyPolygon()); + // try to cast to BasePrimitive2D implementation + const BasePrimitive3D* pBasePrimitive = dynamic_cast< const BasePrimitive3D* >(xReference.get()); - if(aFillPolyPolygon.areTextureCoordinatesUsed()) + if(pBasePrimitive) { - const sal_uInt32 nPolyCount(aFillPolyPolygon.count()); - basegfx::B2DPolyPolygon aTexPolyPolygon; - basegfx::B2DPoint a2N; - basegfx::B2DVector a2X, a2Y; - basegfx::B3DPoint a3N; - basegfx::B3DVector a3X, a3Y; - bool b2N(false), b2X(false), b2Y(false); - sal_uInt32 a, b; - - for(a = 0L; a < nPolyCount; a++) + // it is a BasePrimitive3D implementation, use getPrimitiveID() call for switch + // not all content is needed, remove transparencies and ModifiedColorPrimitives + switch(pBasePrimitive->getPrimitiveID()) { - const basegfx::B3DPolygon aPartPoly(aFillPolyPolygon.getB3DPolygon(a)); - const sal_uInt32 nPointCount(aPartPoly.count()); - basegfx::B2DPolygon aTexPolygon; - - for(b = 0L; b < nPointCount; b++) + case Create3DPrimitiveID('3','P','P','M') : { - const basegfx::B2DPoint a2Candidate(aPartPoly.getTextureCoordinate(b)); + // polyPolygonMaterialPrimitive3D, check texturing and hatching + const PolyPolygonMaterialPrimitive3D& rPrimitive = static_cast< const PolyPolygonMaterialPrimitive3D& >(*pBasePrimitive); + const basegfx::B3DPolyPolygon aFillPolyPolygon(rPrimitive.getB3DPolyPolygon()); - if(!b2N) + if(maHatch.isFillBackground()) { - a2N = a2Candidate; - a3N = aPartPoly.getB3DPoint(b); - b2N = true; + // add original primitive for background + aDestination.push_back(xReference); } - else if(!b2X && !a2N.equal(a2Candidate)) - { - a2X = a2Candidate - a2N; - a3X = aPartPoly.getB3DPoint(b) - a3N; - b2X = true; - } - else if(!b2Y && !a2N.equal(a2Candidate) && !a2X.equal(a2Candidate)) - { - a2Y = a2Candidate - a2N; - - const double fCross(a2X.cross(a2Y)); - if(!basegfx::fTools::equalZero(fCross)) + if(aFillPolyPolygon.areTextureCoordinatesUsed()) + { + const sal_uInt32 nPolyCount(aFillPolyPolygon.count()); + basegfx::B2DPolyPolygon aTexPolyPolygon; + basegfx::B2DPoint a2N; + basegfx::B2DVector a2X, a2Y; + basegfx::B3DPoint a3N; + basegfx::B3DVector a3X, a3Y; + bool b2N(false), b2X(false), b2Y(false); + sal_uInt32 a, b; + + for(a = 0L; a < nPolyCount; a++) { - a3Y = aPartPoly.getB3DPoint(b) - a3N; - b2Y = true; + const basegfx::B3DPolygon aPartPoly(aFillPolyPolygon.getB3DPolygon(a)); + const sal_uInt32 nPointCount(aPartPoly.count()); + basegfx::B2DPolygon aTexPolygon; + + for(b = 0L; b < nPointCount; b++) + { + const basegfx::B2DPoint a2Candidate(aPartPoly.getTextureCoordinate(b)); + + if(!b2N) + { + a2N = a2Candidate; + a3N = aPartPoly.getB3DPoint(b); + b2N = true; + } + else if(!b2X && !a2N.equal(a2Candidate)) + { + a2X = a2Candidate - a2N; + a3X = aPartPoly.getB3DPoint(b) - a3N; + b2X = true; + } + else if(!b2Y && !a2N.equal(a2Candidate) && !a2X.equal(a2Candidate)) + { + a2Y = a2Candidate - a2N; + + const double fCross(a2X.cross(a2Y)); + + if(!basegfx::fTools::equalZero(fCross)) + { + a3Y = aPartPoly.getB3DPoint(b) - a3N; + b2Y = true; + } + } + + aTexPolygon.append(a2Candidate); + } + + aTexPolygon.setClosed(true); + aTexPolyPolygon.append(aTexPolygon); } - } - - aTexPolygon.append(a2Candidate); - } - aTexPolygon.setClosed(true); - aTexPolyPolygon.append(aTexPolygon); - } - - if(b2N && b2X && b2Y) - { - // found two linearly independent 2D vectors - // get 2d range of texture coordinates - const basegfx::B2DRange aOutlineRange(basegfx::tools::getRange(aTexPolyPolygon)); - const basegfx::BColor aHatchColor(maHatch.getColor()); - const double fAngle(-maHatch.getAngle()); - ::std::vector< basegfx::B2DHomMatrix > aMatrices; - - // get hatch transformations - switch(maHatch.getStyle()) - { - case attribute::HATCHSTYLE_TRIPLE: - { - // rotated 45 degrees - texture::geoTexSvxHatch aHatch(aOutlineRange, maHatch.getDistance(), fAngle + F_PI4); - aHatch.appendTransformations(aMatrices); - } - case attribute::HATCHSTYLE_DOUBLE: - { - // rotated 90 degrees - texture::geoTexSvxHatch aHatch(aOutlineRange, maHatch.getDistance(), fAngle + F_PI2); - aHatch.appendTransformations(aMatrices); - } - case attribute::HATCHSTYLE_SINGLE: - { - // angle as given - texture::geoTexSvxHatch aHatch(aOutlineRange, maHatch.getDistance(), fAngle); - aHatch.appendTransformations(aMatrices); + if(b2N && b2X && b2Y) + { + // found two linearly independent 2D vectors + // get 2d range of texture coordinates + const basegfx::B2DRange aOutlineRange(basegfx::tools::getRange(aTexPolyPolygon)); + const basegfx::BColor aHatchColor(getHatch().getColor()); + const double fAngle(-getHatch().getAngle()); + ::std::vector< basegfx::B2DHomMatrix > aMatrices; + + // get hatch transformations + switch(getHatch().getStyle()) + { + case attribute::HATCHSTYLE_TRIPLE: + { + // rotated 45 degrees + texture::GeoTexSvxHatch aHatch(aOutlineRange, getHatch().getDistance(), fAngle + F_PI4); + aHatch.appendTransformations(aMatrices); + } + case attribute::HATCHSTYLE_DOUBLE: + { + // rotated 90 degrees + texture::GeoTexSvxHatch aHatch(aOutlineRange, getHatch().getDistance(), fAngle + F_PI2); + aHatch.appendTransformations(aMatrices); + } + case attribute::HATCHSTYLE_SINGLE: + { + // angle as given + texture::GeoTexSvxHatch aHatch(aOutlineRange, getHatch().getDistance(), fAngle); + aHatch.appendTransformations(aMatrices); + } + } + + // create geometry from unit line + basegfx::B2DPolyPolygon a2DHatchLines; + basegfx::B2DPolygon a2DUnitLine; + a2DUnitLine.append(basegfx::B2DPoint(0.0, 0.0)); + a2DUnitLine.append(basegfx::B2DPoint(1.0, 0.0)); + + for(a = 0L; a < aMatrices.size(); a++) + { + const basegfx::B2DHomMatrix& rMatrix = aMatrices[a]; + basegfx::B2DPolygon aNewLine(a2DUnitLine); + aNewLine.transform(rMatrix); + a2DHatchLines.append(aNewLine); + } + + if(a2DHatchLines.count()) + { + // clip against texture polygon + a2DHatchLines = basegfx::tools::clipPolyPolygonOnPolyPolygon(a2DHatchLines, aTexPolyPolygon, true, false); + } + + if(a2DHatchLines.count()) + { + // create 2d matrix with 2d vectors as column vectors and 2d point as offset, this represents + // a coordinate system transformation from unit coordinates to the new coordinate system + basegfx::B2DHomMatrix a2D; + a2D.set(0, 0, a2X.getX()); + a2D.set(1, 0, a2X.getY()); + a2D.set(0, 1, a2Y.getX()); + a2D.set(1, 1, a2Y.getY()); + a2D.set(0, 2, a2N.getX()); + a2D.set(1, 2, a2N.getY()); + + // invert that transformation, so we have a back-transformation from texture coordinates + // to unit coordinates + a2D.invert(); + a2DHatchLines.transform(a2D); + + // expand back-transformated geometry tpo 3D + basegfx::B3DPolyPolygon a3DHatchLines(basegfx::tools::createB3DPolyPolygonFromB2DPolyPolygon(a2DHatchLines, 0.0)); + + // create 3d matrix with 3d vectors as column vectors (0,0,1 as Z) and 3d point as offset, this represents + // a coordinate system transformation from unit coordinates to the object's 3d coordinate system + basegfx::B3DHomMatrix a3D; + a3D.set(0, 0, a3X.getX()); + a3D.set(1, 0, a3X.getY()); + a3D.set(2, 0, a3X.getZ()); + a3D.set(0, 1, a3Y.getX()); + a3D.set(1, 1, a3Y.getY()); + a3D.set(2, 1, a3Y.getZ()); + a3D.set(0, 3, a3N.getX()); + a3D.set(1, 3, a3N.getY()); + a3D.set(2, 3, a3N.getZ()); + + // transform hatch lines to 3D object coordinates + a3DHatchLines.transform(a3D); + + // build primitives from this geometry + const sal_uInt32 nHatchLines(a3DHatchLines.count()); + + for(a = 0L; a < nHatchLines; a++) + { + const Primitive3DReference xRef(new PolygonHairlinePrimitive3D(a3DHatchLines.getB3DPolygon(a), aHatchColor)); + aDestination.push_back(xRef); + } + } + } } - } - - // create geometry from unit line - basegfx::B2DPolyPolygon a2DHatchLines; - basegfx::B2DPolygon a2DUnitLine; - a2DUnitLine.append(basegfx::B2DPoint(0.0, 0.0)); - a2DUnitLine.append(basegfx::B2DPoint(1.0, 0.0)); - for(a = 0L; a < aMatrices.size(); a++) - { - const basegfx::B2DHomMatrix& rMatrix = aMatrices[a]; - basegfx::B2DPolygon aNewLine(a2DUnitLine); - aNewLine.transform(rMatrix); - a2DHatchLines.append(aNewLine); + break; } - - if(a2DHatchLines.count()) + default : { - // clip against texture polygon - a2DHatchLines = basegfx::tools::clipPolyPolygonOnPolyPolygon(a2DHatchLines, aTexPolyPolygon, true, false); - } - - if(a2DHatchLines.count()) - { - // create 2d matrix with 2d vectors as column vectors and 2d point as offset, this represents - // a coordinate system transformation from unit coordinates to the new coordinate system - basegfx::B2DHomMatrix a2D; - a2D.set(0, 0, a2X.getX()); - a2D.set(1, 0, a2X.getY()); - a2D.set(0, 1, a2Y.getX()); - a2D.set(1, 1, a2Y.getY()); - a2D.set(0, 2, a2N.getX()); - a2D.set(1, 2, a2N.getY()); - - // invert that transformation, so we have a back-transformation from texture coordinates - // to unit coordinates - a2D.invert(); - a2DHatchLines.transform(a2D); - - // expand back-transformated geometry tpo 3D - basegfx::B3DPolyPolygon a3DHatchLines(basegfx::tools::createB3DPolyPolygonFromB2DPolyPolygon(a2DHatchLines, 0.0)); - - // create 3d matrix with 3d vectors as column vectors (0,0,1 as Z) and 3d point as offset, this represents - // a coordinate system transformation from unit coordinates to the object's 3d coordinate system - basegfx::B3DHomMatrix a3D; - a3D.set(0, 0, a3X.getX()); - a3D.set(1, 0, a3X.getY()); - a3D.set(2, 0, a3X.getZ()); - a3D.set(0, 1, a3Y.getX()); - a3D.set(1, 1, a3Y.getY()); - a3D.set(2, 1, a3Y.getZ()); - a3D.set(0, 3, a3N.getX()); - a3D.set(1, 3, a3N.getY()); - a3D.set(2, 3, a3N.getZ()); - - // transform hatch lines to 3D object coordinates - a3DHatchLines.transform(a3D); - - // build primitives from this geometry - const sal_uInt32 nHatchLines(a3DHatchLines.count()); - - for(a = 0L; a < nHatchLines; a++) - { - basePrimitive3D* pNew = new polygonHairlinePrimitive3D(a3DHatchLines.getB3DPolygon(a), aHatchColor); - rDest.push_back(referencedPrimitive3D(*pNew)); - } + // add reference to result + aDestination.push_back(xReference); + break; } } } - - if(maHatch.isFillBackground()) + else { - // add original primitive for background - rDest.push_back(rCandidate); + // unknown implementation, add to result + aDestination.push_back(xReference); } - - break; } + } - default: - { - // add to destination - rDest.push_back(rCandidate); - break; - } + // prepare return value + const sal_uInt32 nDestSize(aDestination.size()); + aRetval.realloc(nDestSize); + + for(sal_uInt32 b(0L); b < nDestSize; b++) + { + aRetval[b] = aDestination[b]; } } - } - void hatchTexturePrimitive3D::decompose(primitiveVector3D& rTarget) - { - if(maPrimitiveVector.size()) - { - // create decomposition - primitiveVector3D aNewPrimitiveVector; - impCreateDecomposition(maPrimitiveVector, aNewPrimitiveVector); - rTarget.insert(rTarget.end(), aNewPrimitiveVector.begin(), aNewPrimitiveVector.end()); - } + return aRetval; } - hatchTexturePrimitive3D::hatchTexturePrimitive3D( - const attribute::fillHatchAttribute& rHatch, - const primitiveVector3D& rPrimitiveVector, + HatchTexturePrimitive3D::HatchTexturePrimitive3D( + const attribute::FillHatchAttribute& rHatch, + const Primitive3DSequence& rChildren, const basegfx::B2DVector& rTextureSize, bool bModulate, bool bFilter) - : texturePrimitive3D(rPrimitiveVector, rTextureSize, bModulate, bFilter), + : TexturePrimitive3D(rChildren, rTextureSize, bModulate, bFilter), maHatch(rHatch) { } - hatchTexturePrimitive3D::~hatchTexturePrimitive3D() - { - } - - bool hatchTexturePrimitive3D::operator==(const basePrimitive3D& rPrimitive) const + bool HatchTexturePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const { - if(texturePrimitive3D::operator==(rPrimitive)) + if(TexturePrimitive3D::operator==(rPrimitive)) { - const hatchTexturePrimitive3D& rCompare = (hatchTexturePrimitive3D&)rPrimitive; - return (maHatch == rCompare.maHatch); + const HatchTexturePrimitive3D& rCompare = (HatchTexturePrimitive3D&)rPrimitive; + + return (getHatch() == rCompare.getHatch()); } return false; } - PrimitiveID hatchTexturePrimitive3D::getID() const + sal_uInt32 HatchTexturePrimitive3D::getPrimitiveID() const { - return CreatePrimitiveID('H', 'A', 'X', '3'); + return Create3DPrimitiveID('3','H','T','e'); } } // end of namespace primitive3d } // end of namespace drawinglayer diff --git a/drawinglayer/source/primitive3d/makefile.mk b/drawinglayer/source/primitive3d/makefile.mk index dcb84b36d464..d30d1dd942f5 100644 --- a/drawinglayer/source/primitive3d/makefile.mk +++ b/drawinglayer/source/primitive3d/makefile.mk @@ -4,9 +4,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.3 $ +# $Revision: 1.4 $ # -# last change: $Author: aw $ $Date: 2006-08-09 16:51:14 $ +# last change: $Author: aw $ $Date: 2006-10-19 10:38:32 $ # # The Contents of this file are made available subject to # the terms of GNU Lesser General Public License Version 2.1. @@ -36,6 +36,7 @@ PRJ=..$/.. PRJNAME=drawinglayer TARGET=primitive3d +ENABLE_EXCEPTIONS=TRUE # --- Settings ---------------------------------- @@ -44,25 +45,25 @@ TARGET=primitive3d # --- Files ------------------------------------- SLOFILES= \ - $(SLO)$/primitive3d.obj \ - $(SLO)$/vectorprimitive3d.obj \ - $(SLO)$/shadowprimitive3d.obj \ - $(SLO)$/textureprimitive3d.obj \ + $(SLO)$/baseprimitive3d.obj \ + $(SLO)$/groupprimitive3d.obj \ $(SLO)$/hatchtextureprimitive3d.obj \ - $(SLO)$/polygontubeprimitive3d.obj \ - $(SLO)$/polygonprimitive3d.obj \ + $(SLO)$/modifiedcolorprimitive3d.obj \ $(SLO)$/polypolygonprimitive3d.obj \ - $(SLO)$/transformprimitive3d.obj \ + $(SLO)$/polygonprimitive3d.obj \ + $(SLO)$/polygontubeprimitive3d.obj \ + $(SLO)$/sdrcubeprimitive3d.obj \ $(SLO)$/sdrdecompositiontools3d.obj \ $(SLO)$/sdrextrudelathetools3d.obj \ - $(SLO)$/sdrprimitive3d.obj \ - $(SLO)$/sdrlabelprimitive3d.obj \ - $(SLO)$/sdrcubeprimitive3d.obj \ $(SLO)$/sdrextrudeprimitive3d.obj \ - $(SLO)$/sdrsphereprimitive3d.obj \ + $(SLO)$/sdrlabelprimitive3d.obj \ $(SLO)$/sdrlatheprimitive3d.obj \ - $(SLO)$/sdrpolygonprimitive3d.obj \ - $(SLO)$/modifiedcolorprimitive3d.obj + $(SLO)$/sdrpolypolygonprimitive3d.obj \ + $(SLO)$/sdrprimitive3d.obj \ + $(SLO)$/sdrsphereprimitive3d.obj \ + $(SLO)$/shadowprimitive3d.obj \ + $(SLO)$/textureprimitive3d.obj \ + $(SLO)$/transformprimitive3d.obj # --- Targets ---------------------------------- diff --git a/drawinglayer/source/primitive3d/modifiedcolorprimitive3d.cxx b/drawinglayer/source/primitive3d/modifiedcolorprimitive3d.cxx index 0d5d911919d3..e96d54b9e512 100644 --- a/drawinglayer/source/primitive3d/modifiedcolorprimitive3d.cxx +++ b/drawinglayer/source/primitive3d/modifiedcolorprimitive3d.cxx @@ -4,9 +4,9 @@ * * $RCSfile: modifiedcolorprimitive3d.cxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: aw $ $Date: 2006-08-09 16:51:15 $ + * last change: $Author: aw $ $Date: 2006-10-19 10:38:32 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -33,42 +33,43 @@ * ************************************************************************/ -#ifndef _DRAWINGLAYER_PRIMITIVE3D_MODIFIEDCOLORPRIMITIVE3D_HXX +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_MODIFIEDCOLORPRIMITIVE3D_HXX #include <drawinglayer/primitive3d/modifiedcolorprimitive3d.hxx> #endif ////////////////////////////////////////////////////////////////////////////// +using namespace com::sun::star; + +////////////////////////////////////////////////////////////////////////////// + namespace drawinglayer { namespace primitive3d { - modifiedColorPrimitive3D::modifiedColorPrimitive3D( - const primitiveVector3D& rPrimitiveVector, + ModifiedColorPrimitive3D::ModifiedColorPrimitive3D( + const Primitive3DSequence& rChildren, const basegfx::BColorModifier& rColorModifier) - : vectorPrimitive3D(rPrimitiveVector), + : GroupPrimitive3D(rChildren), maColorModifier(rColorModifier) { } - modifiedColorPrimitive3D::~modifiedColorPrimitive3D() + bool ModifiedColorPrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const { - } - - bool modifiedColorPrimitive3D::operator==(const basePrimitive3D& rPrimitive) const - { - if(vectorPrimitive3D::operator==(rPrimitive)) + if(GroupPrimitive3D::operator==(rPrimitive)) { - const modifiedColorPrimitive3D& rCompare = (modifiedColorPrimitive3D&)rPrimitive; + const ModifiedColorPrimitive3D& rCompare = (ModifiedColorPrimitive3D&)rPrimitive; + return (maColorModifier == rCompare.maColorModifier); } return false; } - PrimitiveID modifiedColorPrimitive3D::getID() const + sal_uInt32 ModifiedColorPrimitive3D::getPrimitiveID() const { - return CreatePrimitiveID('M', 'C', 'L', '3'); + return Create3DPrimitiveID('3','M','C','o'); } } // end of namespace primitive3d } // end of namespace drawinglayer diff --git a/drawinglayer/source/primitive3d/polygonprimitive3d.cxx b/drawinglayer/source/primitive3d/polygonprimitive3d.cxx index 435ccca60716..753eecfac098 100644 --- a/drawinglayer/source/primitive3d/polygonprimitive3d.cxx +++ b/drawinglayer/source/primitive3d/polygonprimitive3d.cxx @@ -4,9 +4,9 @@ * * $RCSfile: polygonprimitive3d.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: aw $ $Date: 2006-08-09 16:51:15 $ + * last change: $Author: aw $ $Date: 2006-10-19 10:38:32 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -33,7 +33,7 @@ * ************************************************************************/ -#ifndef _DRAWINGLAYER_PRIMITIVE3D_POLYGONPRIMITIVE3D_HXX +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_POLYGONPRIMITIVE3D_HXX #include <drawinglayer/primitive3d/polygonprimitive3d.hxx> #endif @@ -41,52 +41,58 @@ #include <basegfx/polygon/b3dpolygontools.hxx> #endif +#ifndef _BGFX_TOOLS_CANVASTOOLS_HXX +#include <basegfx/tools/canvastools.hxx> +#endif + #ifndef _BGFX_POLYPOLYGON_B3DPOLYGONTOOLS_HXX #include <basegfx/polygon/b3dpolypolygontools.hxx> #endif -#ifndef _DRAWINGLAYER_PRIMITIVE3D_POLYGONTUBEPRIMITIVE3D_HXX +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_POLYGONTUBEPRIMITIVE3D_HXX #include <drawinglayer/primitive3d/polygontubeprimitive3d.hxx> #endif ////////////////////////////////////////////////////////////////////////////// +using namespace com::sun::star; + +////////////////////////////////////////////////////////////////////////////// + namespace drawinglayer { namespace primitive3d { - polygonHairlinePrimitive3D::polygonHairlinePrimitive3D(const basegfx::B3DPolygon& rPolygon, const basegfx::BColor& rBColor) - : basePrimitive3D(), + PolygonHairlinePrimitive3D::PolygonHairlinePrimitive3D( + const basegfx::B3DPolygon& rPolygon, + const basegfx::BColor& rBColor) + : BasePrimitive3D(), maPolygon(rPolygon), maBColor(rBColor) { } - polygonHairlinePrimitive3D::~polygonHairlinePrimitive3D() + bool PolygonHairlinePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const { - } - - bool polygonHairlinePrimitive3D::operator==(const basePrimitive3D& rPrimitive) const - { - if(getID() == rPrimitive.getID()) + if(BasePrimitive3D::operator==(rPrimitive)) { - const polygonHairlinePrimitive3D& rCompare = (polygonHairlinePrimitive3D&)rPrimitive; + const PolygonHairlinePrimitive3D& rCompare = (PolygonHairlinePrimitive3D&)rPrimitive; - return (maPolygon == rCompare.maPolygon - && maBColor == rCompare.maBColor); + return (getB3DPolygon() == rCompare.getB3DPolygon() + && getBColor() == rCompare.getBColor()); } return false; } - PrimitiveID polygonHairlinePrimitive3D::getID() const + basegfx::B3DRange PolygonHairlinePrimitive3D::getB3DRange(double /*fTime*/) const { - return CreatePrimitiveID('P', 'O', 'H', '3'); + return basegfx::tools::getRange(getB3DPolygon()); } - basegfx::B3DRange polygonHairlinePrimitive3D::get3DRange() const + sal_uInt32 PolygonHairlinePrimitive3D::getPrimitiveID() const { - return basegfx::tools::getRange(maPolygon); + return Create3DPrimitiveID('3','P','H','a'); } } // end of namespace primitive3d } // end of namespace drawinglayer @@ -97,34 +103,37 @@ namespace drawinglayer { namespace primitive3d { - void polygonStrokePrimitive3D::decompose(primitiveVector3D& rTarget) + Primitive3DSequence PolygonStrokePrimitive3D::createLocalDecomposition(double /*fTime*/) const { - if(maPolygon.count()) + Primitive3DSequence aRetval; + + if(getB3DPolygon().count()) { - basegfx::B3DPolyPolygon aHairLinePolyPolygon(maPolygon); + basegfx::B3DPolyPolygon aHairLinePolyPolygon(getB3DPolygon()); - if(0.0 != maStrokeAttribute.getFullDotDashLen()) + if(0.0 != getStrokeAttribute().getFullDotDashLen()) { // apply LineStyle - aHairLinePolyPolygon = basegfx::tools::applyLineDashing(aHairLinePolyPolygon, maStrokeAttribute.getDotDashArray(), maStrokeAttribute.getFullDotDashLen()); + aHairLinePolyPolygon = basegfx::tools::applyLineDashing(aHairLinePolyPolygon, getStrokeAttribute().getDotDashArray(), getStrokeAttribute().getFullDotDashLen()); // merge LineStyle polygons to bigger parts aHairLinePolyPolygon = basegfx::tools::mergeDashedLines(aHairLinePolyPolygon); } - if(maStrokeAttribute.getWidth()) + // prepare result + aRetval.realloc(aHairLinePolyPolygon.count()); + + if(getStrokeAttribute().getWidth()) { // create fat line data - const double fRadius(maStrokeAttribute.getWidth() / 2.0); - const basegfx::tools::B2DLineJoin aLineJoin(maStrokeAttribute.getLineJoin()); + const double fRadius(getStrokeAttribute().getWidth() / 2.0); + const basegfx::tools::B2DLineJoin aLineJoin(getStrokeAttribute().getLineJoin()); for(sal_uInt32 a(0L); a < aHairLinePolyPolygon.count(); a++) { // create tube primitives - polygonTubePrimitive3D* pNew = new polygonTubePrimitive3D(aHairLinePolyPolygon.getB3DPolygon(a), - maStrokeAttribute.getColor(), - fRadius, aLineJoin); - rTarget.push_back(referencedPrimitive3D(*pNew)); + const Primitive3DReference xRef(new PolygonTubePrimitive3D(aHairLinePolyPolygon.getB3DPolygon(a), getStrokeAttribute().getColor(), fRadius, aLineJoin)); + aRetval[a] = xRef; } } else @@ -133,42 +142,40 @@ namespace drawinglayer for(sal_uInt32 a(0L); a < aHairLinePolyPolygon.count(); a++) { const basegfx::B3DPolygon aCandidate = aHairLinePolyPolygon.getB3DPolygon(a); - basePrimitive3D* pNew = new polygonHairlinePrimitive3D(aCandidate, maStrokeAttribute.getColor()); - rTarget.push_back(referencedPrimitive3D(*pNew)); + const Primitive3DReference xRef(new PolygonHairlinePrimitive3D(aCandidate, getStrokeAttribute().getColor())); + aRetval[a] = xRef; } } } + + return aRetval; } - polygonStrokePrimitive3D::polygonStrokePrimitive3D( + PolygonStrokePrimitive3D::PolygonStrokePrimitive3D( const basegfx::B3DPolygon& rPolygon, - const attribute::strokeAttribute& rStrokeAttribute) - : basePrimitive3D(), + const attribute::StrokeAttribute& rStrokeAttribute) + : BasePrimitive3D(), maPolygon(rPolygon), maStrokeAttribute(rStrokeAttribute) { } - polygonStrokePrimitive3D::~polygonStrokePrimitive3D() - { - } - - bool polygonStrokePrimitive3D::operator==(const basePrimitive3D& rPrimitive) const + bool PolygonStrokePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const { - if(getID() == rPrimitive.getID()) + if(BasePrimitive3D::operator==(rPrimitive)) { - const polygonStrokePrimitive3D& rCompare = (polygonStrokePrimitive3D&)rPrimitive; + const PolygonStrokePrimitive3D& rCompare = (PolygonStrokePrimitive3D&)rPrimitive; - return (maPolygon == rCompare.maPolygon - && maStrokeAttribute == rCompare.maStrokeAttribute); + return (getB3DPolygon() == rCompare.getB3DPolygon() + && getStrokeAttribute() == rCompare.getStrokeAttribute()); } return false; } - PrimitiveID polygonStrokePrimitive3D::getID() const + sal_uInt32 PolygonStrokePrimitive3D::getPrimitiveID() const { - return CreatePrimitiveID('P', 'L', 'S', '3'); + return Create3DPrimitiveID('3','P','S','t'); } } // end of namespace primitive3d } // end of namespace drawinglayer diff --git a/drawinglayer/source/primitive3d/polygontubeprimitive3d.cxx b/drawinglayer/source/primitive3d/polygontubeprimitive3d.cxx index 7b18f2b4030a..3eaf0e695758 100644 --- a/drawinglayer/source/primitive3d/polygontubeprimitive3d.cxx +++ b/drawinglayer/source/primitive3d/polygontubeprimitive3d.cxx @@ -4,9 +4,9 @@ * * $RCSfile: polygontubeprimitive3d.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: aw $ $Date: 2006-09-27 16:33:17 $ + * last change: $Author: aw $ $Date: 2006-10-19 10:38:33 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -33,35 +33,31 @@ * ************************************************************************/ -#ifndef _DRAWINGLAYER_PRIMITIVE3D_POLYGONTUBEPRIMITIVE3D_HXX +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_POLYGONTUBEPRIMITIVE3D_HXX #include <drawinglayer/primitive3d/polygontubeprimitive3d.hxx> #endif -#ifndef _BGFX_POLYGON_B3DPOLYPOLYGON_HXX -#include <basegfx/polygon/b3dpolypolygon.hxx> +#ifndef INCLUDED_DRAWINGLAYER_ATTRIBUTE_MATERIALATTRIBUTE3D_HXX +#include <drawinglayer/attribute/materialattribute3d.hxx> #endif #ifndef _BGFX_MATRIX_B3DHOMMATRIX_HXX #include <basegfx/matrix/b3dhommatrix.hxx> #endif -#ifndef _DRAWINGLAYER_ATTRIBUTE_MATERIALATTRIBUTE3D_HXX -#include <drawinglayer/attribute/materialattribute3d.hxx> +#ifndef _BGFX_POLYGON_B3DPOLYPOLYGON_HXX +#include <basegfx/polygon/b3dpolypolygon.hxx> #endif -#ifndef _DRAWINGLAYER_PRIMITIVE3D_POLYPOLYGONPRIMITIVE_HXX +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_POLYPOLYGONPRIMITIVE3D_HXX #include <drawinglayer/primitive3d/polypolygonprimitive3d.hxx> #endif -#ifndef _OSL_MUTEX_HXX_ -#include <osl/mutex.hxx> -#endif - #ifndef _BGFX_POLYPOLYGON_B3DPOLYGONTOOLS_HXX #include <basegfx/polygon/b3dpolypolygontools.hxx> #endif -#ifndef _DRAWINGLAYER_PRIMITIVE3D_TRANSFORMPRIMITIVE3D_HXX +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_TRANSFORMPRIMITIVE3D_HXX #include <drawinglayer/primitive3d/transformprimitive3d.hxx> #endif @@ -73,14 +69,14 @@ namespace drawinglayer { namespace // anonymous namespace { - const primitiveVector3D& getLineTubeSegments( + Primitive3DSequence getLineTubeSegments( sal_uInt32 nSegments, - const attribute::materialAttribute3D& rMaterial) + const attribute::MaterialAttribute3D& rMaterial) { // static data for buffered tube primitives - static primitiveVector3D aLineTubeList; + static Primitive3DSequence aLineTubeList; static sal_uInt32 nLineTubeSegments(0L); - static attribute::materialAttribute3D aLineMaterial; + static attribute::MaterialAttribute3D aLineMaterial; // may exclusively change static data, use mutex ::osl::Mutex m_mutex; @@ -89,10 +85,10 @@ namespace drawinglayer { nLineTubeSegments = nSegments; aLineMaterial = rMaterial; - aLineTubeList.clear(); + aLineTubeList = Primitive3DSequence(); } - if(0L == aLineTubeList.size() && 0L != nLineTubeSegments) + if(!aLineTubeList.hasElements() && 0L != nLineTubeSegments) { const basegfx::B3DPoint aLeft(0.0, 0.0, 0.0); const basegfx::B3DPoint aRight(1.0, 0.0, 0.0); @@ -100,6 +96,7 @@ namespace drawinglayer basegfx::B3DPoint aLastRight(1.0, 1.0, 0.0); basegfx::B3DHomMatrix aRot; aRot.rotate(F_2PI / (double)nLineTubeSegments, 0.0, 0.0); + aLineTubeList.realloc(nLineTubeSegments); for(sal_uInt32 a(0L); a < nLineTubeSegments; a++) { @@ -122,8 +119,8 @@ namespace drawinglayer aNewPolygon.setClosed(true); const basegfx::B3DPolyPolygon aNewPolyPolygon(aNewPolygon); - basePrimitive3D* pNew = new polyPolygonMaterialPrimitive3D(aNewPolyPolygon, aLineMaterial, false); - aLineTubeList.push_back(referencedPrimitive3D(*pNew)); + const Primitive3DReference xRef(new PolyPolygonMaterialPrimitive3D(aNewPolyPolygon, aLineMaterial, false)); + aLineTubeList[a] = xRef; aLastLeft = aNextLeft; aLastRight = aNextRight; @@ -133,14 +130,14 @@ namespace drawinglayer return aLineTubeList; } - const primitiveVector3D& getLineCapSegments( + Primitive3DSequence getLineCapSegments( sal_uInt32 nSegments, - const attribute::materialAttribute3D& rMaterial) + const attribute::MaterialAttribute3D& rMaterial) { // static data for buffered tube primitives - static primitiveVector3D aLineCapList; + static Primitive3DSequence aLineCapList; static sal_uInt32 nLineCapSegments(0L); - static attribute::materialAttribute3D aLineMaterial; + static attribute::MaterialAttribute3D aLineMaterial; // may exclusively change static data, use mutex ::osl::Mutex m_mutex; @@ -149,15 +146,16 @@ namespace drawinglayer { nLineCapSegments = nSegments; aLineMaterial = rMaterial; - aLineCapList.clear(); + aLineCapList = Primitive3DSequence(); } - if(0L == aLineCapList.size() && 0L != nLineCapSegments) + if(!aLineCapList.hasElements() && 0L != nLineCapSegments) { const basegfx::B3DPoint aNull(0.0, 0.0, 0.0); basegfx::B3DPoint aLast(0.0, 1.0, 0.0); basegfx::B3DHomMatrix aRot; aRot.rotate(F_2PI / (double)nLineCapSegments, 0.0, 0.0); + aLineCapList.realloc(nLineCapSegments); for(sal_uInt32 a(0L); a < nLineCapSegments; a++) { @@ -176,8 +174,8 @@ namespace drawinglayer aNewPolygon.setClosed(true); const basegfx::B3DPolyPolygon aNewPolyPolygon(aNewPolygon); - basePrimitive3D* pNew = new polyPolygonMaterialPrimitive3D(aNewPolyPolygon, aLineMaterial, false); - aLineCapList.push_back(referencedPrimitive3D(*pNew)); + const Primitive3DReference xRef(new PolyPolygonMaterialPrimitive3D(aNewPolyPolygon, aLineMaterial, false)); + aLineCapList[a] = xRef; aLast = aNext; } @@ -186,10 +184,9 @@ namespace drawinglayer return aLineCapList; } - void getLineJoinSegments( - primitiveVector3D& rDest, + Primitive3DSequence getLineJoinSegments( sal_uInt32 nSegments, - const attribute::materialAttribute3D& rMaterial, + const attribute::MaterialAttribute3D& rMaterial, double fAngle, double /*fDegreeStepWidth*/, double fMiterMinimumAngle, @@ -197,6 +194,7 @@ namespace drawinglayer { // nSegments is for whole circle, adapt to half circle const sal_uInt32 nVerSeg(nSegments >> 1L); + std::vector< BasePrimitive3D* > aResultVector; if(nVerSeg) { @@ -214,8 +212,8 @@ namespace drawinglayer { const basegfx::B3DPolygon aPartPolygon(aSphere.getB3DPolygon(a)); const basegfx::B3DPolyPolygon aPartPolyPolygon(aPartPolygon); - basePrimitive3D* pNew = new polyPolygonMaterialPrimitive3D(aPartPolyPolygon, rMaterial, false); - rDest.push_back(referencedPrimitive3D(*pNew)); + BasePrimitive3D* pNew = new PolyPolygonMaterialPrimitive3D(aPartPolyPolygon, rMaterial, false); + aResultVector.push_back(pNew); } } else @@ -363,8 +361,8 @@ namespace drawinglayer if(aNewPolygon.count()) { const basegfx::B3DPolyPolygon aNewPolyPolygon(aNewPolygon); - basePrimitive3D* pNew = new polyPolygonMaterialPrimitive3D(aNewPolyPolygon, rMaterial, false); - rDest.push_back(referencedPrimitive3D(*pNew)); + BasePrimitive3D* pNew = new PolyPolygonMaterialPrimitive3D(aNewPolyPolygon, rMaterial, false); + aResultVector.push_back(pNew); } if(bMiter && aMiterPolygon.count()) @@ -377,8 +375,8 @@ namespace drawinglayer // create primitive const basegfx::B3DPolyPolygon aMiterPolyPolygon(aMiterPolygon); - basePrimitive3D* pNew = new polyPolygonMaterialPrimitive3D(aMiterPolyPolygon, rMaterial, false); - rDest.push_back(referencedPrimitive3D(*pNew)); + BasePrimitive3D* pNew = new PolyPolygonMaterialPrimitive3D(aMiterPolyPolygon, rMaterial, false); + aResultVector.push_back(pNew); } // prepare next step @@ -395,6 +393,15 @@ namespace drawinglayer } } } + + Primitive3DSequence aRetval(aResultVector.size()); + + for(sal_uInt32 a(0L); a < aResultVector.size(); a++) + { + aRetval[a] = Primitive3DReference(aResultVector[a]); + } + + return aRetval; } basegfx::B3DHomMatrix getRotationFromVector(const basegfx::B3DVector& rVector) @@ -418,30 +425,35 @@ namespace drawinglayer ////////////////////////////////////////////////////////////////////////////// +using namespace com::sun::star; + +////////////////////////////////////////////////////////////////////////////// + namespace drawinglayer { namespace primitive3d { - void polygonTubePrimitive3D::decompose(primitiveVector3D& rTarget) + Primitive3DSequence PolygonTubePrimitive3D::createLocalDecomposition(double /*fTime*/) const { - const sal_uInt32 nPointCount(maPolygon.count()); + const sal_uInt32 nPointCount(getB3DPolygon().count()); + std::vector< BasePrimitive3D* > aResultVector; if(0L != nPointCount) { - if(basegfx::fTools::more(mfRadius, 0.0)) + if(basegfx::fTools::more(getRadius(), 0.0)) { - const attribute::materialAttribute3D aMaterial(maBColor); + const attribute::MaterialAttribute3D aMaterial(getBColor()); static sal_uInt32 nSegments(8L); // default for 3d line segments, for more quality just raise this value (in even steps) - const bool bClosed(maPolygon.isClosed()); - const bool bNoLineJoin(basegfx::tools::B2DLINEJOIN_NONE == maLineJoin); + const bool bClosed(getB3DPolygon().isClosed()); + const bool bNoLineJoin(basegfx::tools::B2DLINEJOIN_NONE == getLineJoin()); const sal_uInt32 nLoopCount(bClosed ? nPointCount : nPointCount - 1L); - basegfx::B3DPoint aLast(maPolygon.getB3DPoint(nPointCount - 1L)); - basegfx::B3DPoint aCurr(maPolygon.getB3DPoint(0L)); + basegfx::B3DPoint aLast(getB3DPolygon().getB3DPoint(nPointCount - 1L)); + basegfx::B3DPoint aCurr(getB3DPolygon().getB3DPoint(0L)); for(sal_uInt32 a(0L); a < nLoopCount; a++) { // get next data - const basegfx::B3DPoint aNext(maPolygon.getB3DPoint((a + 1L) % nPointCount)); + const basegfx::B3DPoint aNext(getB3DPolygon().getB3DPoint((a + 1L) % nPointCount)); const basegfx::B3DVector aForw(aNext - aCurr); const double fForwLen(aForw.getLength()); @@ -452,15 +464,15 @@ namespace drawinglayer // create default transformation with scale and rotate basegfx::B3DHomMatrix aVectorTrans; - aVectorTrans.scale(fForwLen, mfRadius, mfRadius); + aVectorTrans.scale(fForwLen, getRadius(), getRadius()); aVectorTrans *= aRotVector; aVectorTrans.translate(aCurr.getX(), aCurr.getY(), aCurr.getZ()); if(bNoLineJoin || (!bClosed && !a)) { // line start edge, build transformed primitiveVector3D - transformPrimitive3D* pNewTransformedA = new transformPrimitive3D(aVectorTrans, getLineCapSegments(nSegments, aMaterial)); - rTarget.push_back(referencedPrimitive3D(*pNewTransformedA)); + TransformPrimitive3D* pNewTransformedA = new TransformPrimitive3D(aVectorTrans, getLineCapSegments(nSegments, aMaterial)); + aResultVector.push_back(pNewTransformedA); } else { @@ -469,10 +481,9 @@ namespace drawinglayer if(!basegfx::fTools::equalZero(fCross)) { - // line connect non-parallel, aBack, aForw, use maLineJoin - primitiveVector3D aNewList; + // line connect non-parallel, aBack, aForw, use getLineJoin() const double fAngle(acos(aBack.scalar(aForw) / (fForwLen * aBack.getLength()))); // 0.0 .. F_PI2 - getLineJoinSegments(aNewList, nSegments, aMaterial, fAngle, mfDegreeStepWidth, mfMiterMinimumAngle, maLineJoin); + Primitive3DSequence aNewList(getLineJoinSegments(nSegments, aMaterial, fAngle, getDegreeStepWidth(), getMiterMinimumAngle(), getLineJoin())); // calculate transformation. First, get angle in YZ between nForw projected on (1, 0, 0) and nBack basegfx::B3DHomMatrix aInvRotVector(aRotVector); @@ -486,18 +497,18 @@ namespace drawinglayer aSphereTrans.rotate(0.0, F_PI2, 0.0); aSphereTrans.rotate(F_PI - fRotInYZ, 0.0, 0.0); aSphereTrans *= aRotVector; - aSphereTrans.scale(mfRadius, mfRadius, mfRadius); + aSphereTrans.scale(getRadius(), getRadius(), getRadius()); aSphereTrans.translate(aCurr.getX(), aCurr.getY(), aCurr.getZ()); // line start edge, build transformed primitiveVector3D - transformPrimitive3D* pNewTransformedB = new transformPrimitive3D(aSphereTrans, aNewList); - rTarget.push_back(referencedPrimitive3D(*pNewTransformedB)); + TransformPrimitive3D* pNewTransformedB = new TransformPrimitive3D(aSphereTrans, aNewList); + aResultVector.push_back(pNewTransformedB); } } // create line segments, build transformed primitiveVector3D - transformPrimitive3D* pNewTransformedC = new transformPrimitive3D(aVectorTrans, getLineTubeSegments(nSegments, aMaterial)); - rTarget.push_back(referencedPrimitive3D(*pNewTransformedC)); + TransformPrimitive3D* pNewTransformedC = new TransformPrimitive3D(aVectorTrans, getLineTubeSegments(nSegments, aMaterial)); + aResultVector.push_back(pNewTransformedC); if(bNoLineJoin || (!bClosed && ((a + 1L) == nLoopCount))) { @@ -505,13 +516,13 @@ namespace drawinglayer basegfx::B3DHomMatrix aBackTrans; aBackTrans.rotate(0.0, F_PI, 0.0); aBackTrans.translate(1.0, 0.0, 0.0); - aBackTrans.scale(fForwLen, mfRadius, mfRadius); + aBackTrans.scale(fForwLen, getRadius(), getRadius()); aBackTrans *= aRotVector; aBackTrans.translate(aCurr.getX(), aCurr.getY(), aCurr.getZ()); // line end edge, build transformed primitiveVector3D - transformPrimitive3D* pNewTransformedD = new transformPrimitive3D(aBackTrans, getLineCapSegments(nSegments, aMaterial)); - rTarget.push_back(referencedPrimitive3D(*pNewTransformedD)); + TransformPrimitive3D* pNewTransformedD = new TransformPrimitive3D(aBackTrans, getLineCapSegments(nSegments, aMaterial)); + aResultVector.push_back(pNewTransformedD); } } @@ -523,19 +534,29 @@ namespace drawinglayer else { // create hairline - polygonHairlinePrimitive3D* pNew = new polygonHairlinePrimitive3D(maPolygon, maBColor); - rTarget.push_back(referencedPrimitive3D(*pNew)); + PolygonHairlinePrimitive3D* pNew = new PolygonHairlinePrimitive3D(getB3DPolygon(), getBColor()); + aResultVector.push_back(pNew); } } + + // prepare return value + Primitive3DSequence aRetval(aResultVector.size()); + + for(sal_uInt32 a(0L); a < aResultVector.size(); a++) + { + aRetval[a] = Primitive3DReference(aResultVector[a]); + } + + return aRetval; } - polygonTubePrimitive3D::polygonTubePrimitive3D( + PolygonTubePrimitive3D::PolygonTubePrimitive3D( const basegfx::B3DPolygon& rPolygon, const basegfx::BColor& rBColor, double fRadius, basegfx::tools::B2DLineJoin aLineJoin, double fDegreeStepWidth, double fMiterMinimumAngle) - : polygonHairlinePrimitive3D(rPolygon, rBColor), + : PolygonHairlinePrimitive3D(rPolygon, rBColor), mfRadius(fRadius), mfDegreeStepWidth(fDegreeStepWidth), mfMiterMinimumAngle(fMiterMinimumAngle), @@ -543,28 +564,24 @@ namespace drawinglayer { } - polygonTubePrimitive3D::~polygonTubePrimitive3D() - { - } - - bool polygonTubePrimitive3D::operator==(const basePrimitive3D& rPrimitive) const + bool PolygonTubePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const { - if(polygonHairlinePrimitive3D::operator==(rPrimitive)) + if(PolygonHairlinePrimitive3D::operator==(rPrimitive)) { - const polygonTubePrimitive3D& rCompare = (polygonTubePrimitive3D&)rPrimitive; + const PolygonTubePrimitive3D& rCompare = (PolygonTubePrimitive3D&)rPrimitive; - return (mfRadius == rCompare.mfRadius - && mfDegreeStepWidth == rCompare.mfDegreeStepWidth - && mfMiterMinimumAngle == rCompare.mfMiterMinimumAngle - && maLineJoin == rCompare.maLineJoin); + return (getRadius() == rCompare.getRadius() + && getDegreeStepWidth() == rCompare.getDegreeStepWidth() + && getMiterMinimumAngle() == rCompare.getMiterMinimumAngle() + && getLineJoin() == rCompare.getLineJoin()); } return false; } - PrimitiveID polygonTubePrimitive3D::getID() const + sal_uInt32 PolygonTubePrimitive3D::getPrimitiveID() const { - return CreatePrimitiveID('T', 'U', 'B', '3'); + return Create3DPrimitiveID('3','P','T','u'); } } // end of namespace primitive3d } // end of namespace drawinglayer diff --git a/drawinglayer/source/primitive3d/polypolygonprimitive3d.cxx b/drawinglayer/source/primitive3d/polypolygonprimitive3d.cxx index 6e838043762b..ff7aba0a8fbc 100644 --- a/drawinglayer/source/primitive3d/polypolygonprimitive3d.cxx +++ b/drawinglayer/source/primitive3d/polypolygonprimitive3d.cxx @@ -4,9 +4,9 @@ * * $RCSfile: polypolygonprimitive3d.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: aw $ $Date: 2006-08-09 16:51:15 $ + * last change: $Author: aw $ $Date: 2006-10-19 10:38:33 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -33,7 +33,7 @@ * ************************************************************************/ -#ifndef _DRAWINGLAYER_PRIMITIVE3D_POLYPOLYGONPRIMITIVE_HXX +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_POLYPOLYGONPRIMITIVE3D_HXX #include <drawinglayer/primitive3d/polypolygonprimitive3d.hxx> #endif @@ -41,49 +41,53 @@ #include <basegfx/polygon/b3dpolypolygontools.hxx> #endif +#ifndef _BGFX_TOOLS_CANVASTOOLS_HXX +#include <basegfx/tools/canvastools.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// + +using namespace com::sun::star; + ////////////////////////////////////////////////////////////////////////////// namespace drawinglayer { namespace primitive3d { - polyPolygonMaterialPrimitive3D::polyPolygonMaterialPrimitive3D( + PolyPolygonMaterialPrimitive3D::PolyPolygonMaterialPrimitive3D( const basegfx::B3DPolyPolygon& rPolyPolygon, - const attribute::materialAttribute3D& rMaterial, + const attribute::MaterialAttribute3D& rMaterial, bool bDoubleSided) - : basePrimitive3D(), + : BasePrimitive3D(), maPolyPolygon(rPolyPolygon), maMaterial(rMaterial), mbDoubleSided(bDoubleSided) { } - polyPolygonMaterialPrimitive3D::~polyPolygonMaterialPrimitive3D() - { - } - - bool polyPolygonMaterialPrimitive3D::operator==(const basePrimitive3D& rPrimitive) const + bool PolyPolygonMaterialPrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const { - if(getID() == rPrimitive.getID()) + if(BasePrimitive3D::operator==(rPrimitive)) { - const polyPolygonMaterialPrimitive3D& rCompare = (polyPolygonMaterialPrimitive3D&)rPrimitive; + const PolyPolygonMaterialPrimitive3D& rCompare = (PolyPolygonMaterialPrimitive3D&)rPrimitive; - return (maPolyPolygon == rCompare.maPolyPolygon - && maMaterial == rCompare.maMaterial - && mbDoubleSided == rCompare.mbDoubleSided); + return (getB3DPolyPolygon() == rCompare.getB3DPolyPolygon() + && getMaterial() == rCompare.getMaterial() + && getDoubleSided() == rCompare.getDoubleSided()); } return false; } - PrimitiveID polyPolygonMaterialPrimitive3D::getID() const + basegfx::B3DRange PolyPolygonMaterialPrimitive3D::getB3DRange(double /*fTime*/) const { - return CreatePrimitiveID('P', 'O', 'M', '3'); + return basegfx::tools::getRange(getB3DPolyPolygon()); } - basegfx::B3DRange polyPolygonMaterialPrimitive3D::get3DRange() const + sal_uInt32 PolyPolygonMaterialPrimitive3D::getPrimitiveID() const { - return basegfx::tools::getRange(maPolyPolygon); + return Create3DPrimitiveID('3','P','P','M'); } } // end of namespace primitive3d } // end of namespace drawinglayer diff --git a/drawinglayer/source/primitive3d/sdrcubeprimitive3d.cxx b/drawinglayer/source/primitive3d/sdrcubeprimitive3d.cxx index aa2a43198df4..7fe1b1fd896d 100644 --- a/drawinglayer/source/primitive3d/sdrcubeprimitive3d.cxx +++ b/drawinglayer/source/primitive3d/sdrcubeprimitive3d.cxx @@ -4,9 +4,9 @@ * * $RCSfile: sdrcubeprimitive3d.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: aw $ $Date: 2006-08-09 16:51:15 $ + * last change: $Author: aw $ $Date: 2006-10-19 10:38:33 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -33,37 +33,33 @@ * ************************************************************************/ -#ifndef _DRAWINGLAYER_PRIMITIVE3D_SDRCUBEPRIMITIVE3D_HXX +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDRCUBEPRIMITIVE3D_HXX #include <drawinglayer/primitive3d/sdrcubeprimitive3d.hxx> #endif -#ifndef _BGFX_RANGE_B3DRANGE_HXX -#include <basegfx/range/b3drange.hxx> +#ifndef _BGFX_POLYPOLYGON_B3DPOLYGONTOOLS_HXX +#include <basegfx/polygon/b3dpolypolygontools.hxx> #endif -#ifndef _BGFX_POLYGON_B3DPOLYPOLYGON_HXX -#include <basegfx/polygon/b3dpolypolygon.hxx> +#ifndef _BGFX_POLYGON_B3DPOLYGON_HXX +#include <basegfx/polygon/b3dpolygon.hxx> #endif -#ifndef _BGFX_POLYPOLYGON_B3DPOLYGONTOOLS_HXX -#include <basegfx/polygon/b3dpolypolygontools.hxx> +#ifndef _BGFX_MATRIX_B2DHOMMATRIX_HXX +#include <basegfx/matrix/b2dhommatrix.hxx> #endif -#ifndef _DRAWINGLAYER_PRIMITIVE3D_SDRDECOMPOSITIONTOOLS3D_HXX +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDRDECOMPOSITIONTOOLS3D_HXX #include <drawinglayer/primitive3d/sdrdecompositiontools3d.hxx> #endif -#ifndef _BGFX_POLYGON_B3DPOLYGON_HXX -#include <basegfx/polygon/b3dpolygon.hxx> +#ifndef _BGFX_TOOLS_CANVASTOOLS_HXX +#include <basegfx/tools/canvastools.hxx> #endif -#ifndef _BGFX_POLYGON_B3DPOLYGONTOOLS_HXX -#include <basegfx/polygon/b3dpolygontools.hxx> -#endif +////////////////////////////////////////////////////////////////////////////// -#ifndef _BGFX_MATRIX_B2DHOMMATRIX_HXX -#include <basegfx/matrix/b2dhommatrix.hxx> -#endif +using namespace com::sun::star; ////////////////////////////////////////////////////////////////////////////// @@ -71,9 +67,10 @@ namespace drawinglayer { namespace primitive3d { - void sdrCubePrimitive3D::decompose(primitiveVector3D& rTarget) + Primitive3DSequence SdrCubePrimitive3D::createLocalDecomposition(double /*fTime*/) const { const basegfx::B3DRange aUnitRange(0.0, 0.0, 0.0, 1.0, 1.0, 1.0); + Primitive3DSequence aRetval; // add fill if(getSdrLFSAttribute().getFill()) @@ -157,7 +154,7 @@ namespace drawinglayer // transform texture coordinates to texture size basegfx::B2DHomMatrix aTexMatrix; - aTexMatrix.scale(maTextureSize.getX(), maTextureSize.getY()); + aTexMatrix.scale(getTextureSize().getX(), getTextureSize().getY()); aFill.transformTextureCoordiantes(aTexMatrix); } @@ -170,8 +167,8 @@ namespace drawinglayer } // create single PolyPolygonFill primitives - add3DPolyPolygonFillPrimitive( - a3DPolyPolygonVector, maTransform, maTextureSize, rTarget, + aRetval = create3DPolyPolygonFillPrimitives( + a3DPolyPolygonVector, getTransform(), getTextureSize(), getSdr3DObjectAttribute(), *getSdrLFSAttribute().getFill(), getSdrLFSAttribute().getFillFloatTransGradient()); } @@ -180,40 +177,35 @@ namespace drawinglayer if(getSdrLFSAttribute().getLine()) { basegfx::B3DPolyPolygon aLine(basegfx::tools::createCubePolyPolygonFromB3DRange(aUnitRange)); - add3DPolyPolygonLinePrimitive(aLine, maTransform, rTarget, *getSdrLFSAttribute().getLine()); + const Primitive3DSequence aLines(create3DPolyPolygonLinePrimitives(aLine, getTransform(), *getSdrLFSAttribute().getLine())); + appendPrimitive3DSequenceToPrimitive3DSequence(aRetval, aLines); } // add shadow - if(getSdrLFSAttribute().getShadow()) + if(getSdrLFSAttribute().getShadow() && aRetval.hasElements()) { - addShadowPrimitive3D(rTarget, *getSdrLFSAttribute().getShadow(), getSdr3DObjectAttribute().getShadow3D()); + const Primitive3DSequence aShadow(createShadowPrimitive3D(aRetval, *getSdrLFSAttribute().getShadow(), getSdr3DObjectAttribute().getShadow3D())); + appendPrimitive3DSequenceToPrimitive3DSequence(aRetval, aShadow); } + + return aRetval; } - sdrCubePrimitive3D::sdrCubePrimitive3D( + SdrCubePrimitive3D::SdrCubePrimitive3D( const basegfx::B3DHomMatrix& rTransform, const basegfx::B2DVector& rTextureSize, - const attribute::sdrLineFillShadowAttribute& rSdrLFSAttribute, - const attribute::sdr3DObjectAttribute& rSdr3DObjectAttribute) - : sdrPrimitive3D(rTransform, rTextureSize, rSdrLFSAttribute, rSdr3DObjectAttribute) - { - } - - sdrCubePrimitive3D::~sdrCubePrimitive3D() + const attribute::SdrLineFillShadowAttribute& rSdrLFSAttribute, + const attribute::Sdr3DObjectAttribute& rSdr3DObjectAttribute) + : SdrPrimitive3D(rTransform, rTextureSize, rSdrLFSAttribute, rSdr3DObjectAttribute) { } - bool sdrCubePrimitive3D::operator==(const basePrimitive3D& rPrimitive) const + bool SdrCubePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const { - return sdrPrimitive3D::operator==(rPrimitive); + return SdrPrimitive3D::operator==(rPrimitive); } - PrimitiveID sdrCubePrimitive3D::getID() const - { - return CreatePrimitiveID('S', 'C', 'U', '3'); - } - - basegfx::B3DRange sdrCubePrimitive3D::get3DRange() const + basegfx::B3DRange SdrCubePrimitive3D::getB3DRange(double /*fTime*/) const { // use defaut from sdrPrimitive3D which uses transformation expanded by line width/2. // The parent implementation which uses the ranges of the decomposition would be more @@ -223,6 +215,11 @@ namespace drawinglayer // has priority here. return getStandard3DRange(); } + + sal_uInt32 SdrCubePrimitive3D::getPrimitiveID() const + { + return Create3DPrimitiveID('3','C','u','b'); + } } // end of namespace primitive3d } // end of namespace drawinglayer diff --git a/drawinglayer/source/primitive3d/sdrdecompositiontools3d.cxx b/drawinglayer/source/primitive3d/sdrdecompositiontools3d.cxx index 0e9c053b15cf..1593e3d8d319 100644 --- a/drawinglayer/source/primitive3d/sdrdecompositiontools3d.cxx +++ b/drawinglayer/source/primitive3d/sdrdecompositiontools3d.cxx @@ -4,9 +4,9 @@ * * $RCSfile: sdrdecompositiontools3d.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: aw $ $Date: 2006-08-09 16:51:15 $ + * last change: $Author: aw $ $Date: 2006-10-19 10:38:33 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -33,7 +33,7 @@ * ************************************************************************/ -#ifndef _DRAWINGLAYER_PRIMITIVE3D_SDRDECOMPOSITIONTOOLS3D_HXX +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDRDECOMPOSITIONTOOLS3D_HXX #include <drawinglayer/primitive3d/sdrdecompositiontools3d.hxx> #endif @@ -41,35 +41,31 @@ #include <basegfx/polygon/b3dpolygon.hxx> #endif -#ifndef _DRAWINGLAYER_ATTRIBUTE_STROKEATTRIBUTE_HXX +#ifndef INCLUDED_DRAWINGLAYER_ATTRIBUTE_STROKEATTRIBUTE_HXX #include <drawinglayer/attribute/strokeattribute.hxx> #endif -#ifndef _DRAWINGLAYER_ATTRIBUTE_SDRATTRIBUTE_HXX +#ifndef INCLUDED_DRAWINGLAYER_ATTRIBUTE_SDRATTRIBUTE_HXX #include <drawinglayer/attribute/sdrattribute.hxx> #endif -#ifndef _DRAWINGLAYER_PRIMITIVE3D_PRIMITIVE3D_HXX -#include <drawinglayer/primitive3d/primitive3d.hxx> +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_BASEPRIMITIVE3D_HXX +#include <drawinglayer/primitive3d/baseprimitive3d.hxx> #endif -#ifndef _DRAWINGLAYER_PRIMITIVE3D_POLYGONPRIMITIVE3D_HXX +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_POLYGONPRIMITIVE3D_HXX #include <drawinglayer/primitive3d/polygonprimitive3d.hxx> #endif -#ifndef _DRAWINGLAYER_PRIMITIVE_SIMPLETRANSPARENCEPRIMITIVE_HXX -#include <drawinglayer/primitive/simpletransparenceprimitive.hxx> -#endif - #ifndef _BGFX_POLYGON_B3DPOLYPOLYGON_HXX #include <basegfx/polygon/b3dpolypolygon.hxx> #endif -#ifndef _DRAWINGLAYER_PRIMITIVE3D_POLYPOLYGONPRIMITIVE_HXX +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_POLYPOLYGONPRIMITIVE_HXX #include <drawinglayer/primitive3d/polypolygonprimitive3d.hxx> #endif -#ifndef _DRAWINGLAYER_ATTRIBUTE_SDRATTRIBUTE_HXX +#ifndef INCLUDED_DRAWINGLAYER_ATTRIBUTE_SDRATTRIBUTE_HXX #include <drawinglayer/attribute/sdrattribute.hxx> #endif @@ -77,15 +73,15 @@ #include <vcl/vclenum.hxx> #endif -#ifndef _DRAWINGLAYER_ATTRIBUTE_FILLATTRIBUTE_HXX +#ifndef INCLUDED_DRAWINGLAYER_ATTRIBUTE_FILLATTRIBUTE_HXX #include <drawinglayer/attribute/fillattribute.hxx> #endif -#ifndef _DRAWINGLAYER_ATTRIBUTE_FILLBITMAPATTRIBUTE_HXX +#ifndef INCLUDED_DRAWINGLAYER_ATTRIBUTE_FILLBITMAPATTRIBUTE_HXX #include <drawinglayer/attribute/fillbitmapattribute.hxx> #endif -#ifndef _DRAWINGLAYER_ATTRIBUTE_SDRFILLBITMAPATTRIBUTE_HXX +#ifndef INCLUDED_DRAWINGLAYER_ATTRIBUTE_SDRFILLBITMAPATTRIBUTE_HXX #include <drawinglayer/attribute/sdrfillbitmapattribute.hxx> #endif @@ -97,80 +93,81 @@ #include <basegfx/polygon/b3dpolypolygontools.hxx> #endif -#ifndef _DRAWINGLAYER_PRIMITIVE3D_TEXTUREPRIMITIVE3D_HXX +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_TEXTUREPRIMITIVE3D_HXX #include <drawinglayer/primitive3d/textureprimitive3d.hxx> #endif -#ifndef _DRAWINGLAYER_PRIMITIVE3D_MODIFIEDCOLORPRIMITIVE3D_HXX +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_MODIFIEDCOLORPRIMITIVE3D_HXX #include <drawinglayer/primitive3d/modifiedcolorprimitive3d.hxx> #endif -#ifndef _DRAWINGLAYER_PRIMITIVE3D_HATCHTEXTUREPRIMITIVE3D_HXX +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_HATCHTEXTUREPRIMITIVE3D_HXX #include <drawinglayer/primitive3d/hatchtextureprimitive3d.hxx> #endif -#ifndef _DRAWINGLAYER_PRIMITIVE3D_SHADOWPRIMITIVE3D_HXX +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SHADOWPRIMITIVE3D_HXX #include <drawinglayer/primitive3d/shadowprimitive3d.hxx> #endif -#ifndef _DRAWINGLAYER_ATTRIBUTE_SDRATTRIBUTE3D_HXX +#ifndef INCLUDED_DRAWINGLAYER_ATTRIBUTE_SDRATTRIBUTE3D_HXX #include <drawinglayer/attribute/sdrattribute3d.hxx> #endif +#ifndef _BGFX_RANGE_B2DRANGE_HXX +#include <basegfx/range/b2drange.hxx> +#endif + ////////////////////////////////////////////////////////////////////////////// namespace drawinglayer { namespace primitive3d { - void add3DPolyPolygonLinePrimitive( + Primitive3DSequence create3DPolyPolygonLinePrimitives( const basegfx::B3DPolyPolygon& rUnitPolyPolygon, const basegfx::B3DHomMatrix& rObjectTransform, - primitiveVector3D& rTarget, - const attribute::sdrLineAttribute& rLine) + const attribute::SdrLineAttribute& rLine) { // prepare fully scaled polyPolygon basegfx::B3DPolyPolygon aScaledPolyPolygon(rUnitPolyPolygon); aScaledPolyPolygon.transform(rObjectTransform); // create stroke attribute - const attribute::strokeAttribute aStrokeAttribute(rLine.getColor(), rLine.getWidth(), rLine.getJoin(), rLine.getDotDashArray(), rLine.getFullDotDashLen()); + const attribute::StrokeAttribute aStrokeAttribute(rLine.getColor(), rLine.getWidth(), rLine.getJoin(), rLine.getDotDashArray(), rLine.getFullDotDashLen()); // create primitives - primitiveVector3D aNewPrimitiveVector; + Primitive3DSequence aRetval(aScaledPolyPolygon.count()); for(sal_uInt32 a(0L); a < aScaledPolyPolygon.count(); a++) { - basePrimitive3D* pNewLinePrimitive = new polygonStrokePrimitive3D(aScaledPolyPolygon.getB3DPolygon(a), aStrokeAttribute); - aNewPrimitiveVector.push_back(referencedPrimitive3D(*pNewLinePrimitive)); + const Primitive3DReference xRef(new PolygonStrokePrimitive3D(aScaledPolyPolygon.getB3DPolygon(a), aStrokeAttribute)); + aRetval[a] = xRef; } if(0.0 != rLine.getTransparence()) { - // create simpleTransparencePrimitive, add created fill primitives - basePrimitive3D* pNewSimpleTransparenceTexturePrimitive3D = new simpleTransparenceTexturePrimitive3D(rLine.getTransparence(), aNewPrimitiveVector); - rTarget.push_back(referencedPrimitive3D(*pNewSimpleTransparenceTexturePrimitive3D)); - } - else - { - // add to decomposition - rTarget.insert(rTarget.end(), aNewPrimitiveVector.begin(), aNewPrimitiveVector.end()); + // create UnifiedAlphaTexturePrimitive3D, add created primitives and exchange + const Primitive3DReference xRef(new UnifiedAlphaTexturePrimitive3D(rLine.getTransparence(), aRetval)); + aRetval = Primitive3DSequence(&xRef, 1L); } + + return aRetval; } - void add3DPolyPolygonFillPrimitive( + Primitive3DSequence create3DPolyPolygonFillPrimitives( const ::std::vector< basegfx::B3DPolyPolygon >& r3DPolyPolygonVector, const basegfx::B3DHomMatrix& rObjectTransform, const basegfx::B2DVector& rTextureSize, - primitiveVector3D& rTarget, - const attribute::sdr3DObjectAttribute& aSdr3DObjectAttribute, - const attribute::sdrFillAttribute& rFill, - const attribute::fillGradientAttribute* pFillGradient) + const attribute::Sdr3DObjectAttribute& aSdr3DObjectAttribute, + const attribute::SdrFillAttribute& rFill, + const attribute::FillGradientAttribute* pFillGradient) { + Primitive3DSequence aRetval; + if(r3DPolyPolygonVector.size()) { // create list of simple fill primitives - primitiveVector3D aNewPrimitiveVector; + aRetval.realloc(r3DPolyPolygonVector.size()); for(sal_uInt32 a(0L); a < r3DPolyPolygonVector.size(); a++) { @@ -183,11 +180,11 @@ namespace drawinglayer aScaledPolyPolygon.transformNormals(rObjectTransform); } - basePrimitive3D* pNewFillPrimitive = new polyPolygonMaterialPrimitive3D( + const Primitive3DReference xRef(new PolyPolygonMaterialPrimitive3D( aScaledPolyPolygon, aSdr3DObjectAttribute.getMaterial(), - aSdr3DObjectAttribute.getDoubleSided()); - aNewPrimitiveVector.push_back(referencedPrimitive3D(*pNewFillPrimitive)); + aSdr3DObjectAttribute.getDoubleSided())); + aRetval[a] = xRef; } // look for and evtl. build texture sub-group primitive @@ -195,79 +192,75 @@ namespace drawinglayer { bool bModulate(::com::sun::star::drawing::TextureMode_MODULATE == aSdr3DObjectAttribute.getTextureMode()); bool bFilter(aSdr3DObjectAttribute.getTextureFilter()); - basePrimitive3D* pNewTexturePrimitive3D = 0L; + BasePrimitive3D* pNewTexturePrimitive3D = 0L; if(rFill.isGradient()) { - // create gradientTexture3D with sublist, add to local aNewPrimitiveVector - pNewTexturePrimitive3D = new gradientTexturePrimitive3D(*rFill.getGradient(), aNewPrimitiveVector, rTextureSize, bModulate, bFilter); + // create gradientTexture3D with sublist, add to local aRetval + pNewTexturePrimitive3D = new GradientTexturePrimitive3D(*rFill.getGradient(), aRetval, rTextureSize, bModulate, bFilter); } else if(rFill.isHatch()) { - // create hatchTexture3D with sublist, add to local aNewPrimitiveVector - pNewTexturePrimitive3D = new hatchTexturePrimitive3D(*rFill.getHatch(), aNewPrimitiveVector, rTextureSize, bModulate, bFilter); + // create hatchTexture3D with sublist, add to local aRetval + pNewTexturePrimitive3D = new HatchTexturePrimitive3D(*rFill.getHatch(), aRetval, rTextureSize, bModulate, bFilter); } else // if(rFill.isBitmap()) { - // create bitmapTexture3D with sublist, add to local aNewPrimitiveVector + // create bitmapTexture3D with sublist, add to local aRetval basegfx::B2DRange aTexRange(0.0, 0.0, rTextureSize.getX(), rTextureSize.getY()); - pNewTexturePrimitive3D = new bitmapTexturePrimitive3D(rFill.getBitmap()->getFillBitmapAttribute(aTexRange), aNewPrimitiveVector, rTextureSize, bModulate, bFilter); + pNewTexturePrimitive3D = new BitmapTexturePrimitive3D(rFill.getBitmap()->getFillBitmapAttribute(aTexRange), aRetval, rTextureSize, bModulate, bFilter); } - // exchange aNewPrimitiveVector content with texture group - aNewPrimitiveVector.clear(); - aNewPrimitiveVector.push_back(referencedPrimitive3D(*pNewTexturePrimitive3D)); + // exchange aRetval content with texture group + const Primitive3DReference xRef(pNewTexturePrimitive3D); + aRetval = Primitive3DSequence(&xRef, 1L); if(::com::sun::star::drawing::TextureKind2_LUMINANCE == aSdr3DObjectAttribute.getTextureKind()) { // use modified color primitive to force textures to gray const basegfx::BColorModifier aBColorModifier(basegfx::BColor(), 0.0, basegfx::BCOLORMODIFYMODE_GRAY); - basePrimitive3D* pModifiedColor = new modifiedColorPrimitive3D(aNewPrimitiveVector, aBColorModifier); - aNewPrimitiveVector.clear(); - aNewPrimitiveVector.push_back(referencedPrimitive3D(*pModifiedColor)); + const Primitive3DReference xRef2(new ModifiedColorPrimitive3D(aRetval, aBColorModifier)); + aRetval = Primitive3DSequence(&xRef2, 1L); } } if(0.0 != rFill.getTransparence()) { - // create simpleTransparenceTexturePrimitive3D with sublist and append - basePrimitive3D* pNewSimpleTransparenceTexturePrimitive3D = new simpleTransparenceTexturePrimitive3D(rFill.getTransparence(), aNewPrimitiveVector); - rTarget.push_back(referencedPrimitive3D(*pNewSimpleTransparenceTexturePrimitive3D)); + // create UnifiedAlphaTexturePrimitive3D with sublist and exchange + const Primitive3DReference xRef(new UnifiedAlphaTexturePrimitive3D(rFill.getTransparence(), aRetval)); + aRetval = Primitive3DSequence(&xRef, 1L); } else if(pFillGradient) { - // create transparenceTexture3D with sublist and append - basePrimitive3D* pNewTransparenceTexturePrimitive3D = new transparenceTexturePrimitive3D(*pFillGradient, aNewPrimitiveVector, rTextureSize); - rTarget.push_back(referencedPrimitive3D(*pNewTransparenceTexturePrimitive3D)); - } - else - { - // append list - rTarget.insert(rTarget.end(), aNewPrimitiveVector.begin(), aNewPrimitiveVector.end()); + // create AlphaTexturePrimitive3D with sublist and exchange + const Primitive3DReference xRef(new AlphaTexturePrimitive3D(*pFillGradient, aRetval, rTextureSize)); + aRetval = Primitive3DSequence(&xRef, 1L); } } + + return aRetval; } - void addShadowPrimitive3D( - primitiveVector3D& rTarget, - const attribute::sdrShadowAttribute& rShadow, + Primitive3DSequence createShadowPrimitive3D( + const Primitive3DSequence& rSource, + const attribute::SdrShadowAttribute& rShadow, bool bShadow3D) { - // create Shadow primitives. Need to be added in front, should use already created primitives - if(rTarget.size() && !basegfx::fTools::moreOrEqual(rShadow.getTransparence(), 1.0)) + // create Shadow primitives. Uses already created primitives + if(rSource.hasElements() && !basegfx::fTools::moreOrEqual(rShadow.getTransparence(), 1.0)) { // prepare new list for shadow geometry - primitiveVector3D aNewList; - - // prepare shadow offset - basegfx::B2DHomMatrix aShadowOffset; + basegfx::B2DHomMatrix aShadowOffset; aShadowOffset.set(0, 2, rShadow.getOffset().getX()); aShadowOffset.set(1, 2, rShadow.getOffset().getY()); // create shadow primitive and add primitives - shadowPrimitive3D* pNewShadow3D = new shadowPrimitive3D(aShadowOffset, rShadow.getColor(), rShadow.getTransparence(), bShadow3D, rTarget); - rTarget.clear(); - rTarget.push_back(referencedPrimitive3D(*pNewShadow3D)); + const Primitive3DReference xRef(new ShadowPrimitive3D(aShadowOffset, rShadow.getColor(), rShadow.getTransparence(), bShadow3D, rSource)); + return Primitive3DSequence(&xRef, 1L); + } + else + { + return Primitive3DSequence(); } } } // end of namespace primitive3d diff --git a/drawinglayer/source/primitive3d/sdrextrudelathetools3d.cxx b/drawinglayer/source/primitive3d/sdrextrudelathetools3d.cxx index 98148757edf4..8474600605af 100644 --- a/drawinglayer/source/primitive3d/sdrextrudelathetools3d.cxx +++ b/drawinglayer/source/primitive3d/sdrextrudelathetools3d.cxx @@ -4,9 +4,9 @@ * * $RCSfile: sdrextrudelathetools3d.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: aw $ $Date: 2006-09-27 16:33:18 $ + * last change: $Author: aw $ $Date: 2006-10-19 10:38:33 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -33,7 +33,7 @@ * ************************************************************************/ -#ifndef _DRAWINGLAYER_PRIMITIVE3D_SDREXTRUDELATHETOOLS3D_HXX +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDREXTRUDELATHETOOLS3D_HXX #include <drawinglayer/primitive3d/sdrextrudelathetools3d.hxx> #endif @@ -91,7 +91,9 @@ namespace ////////////////////////////////////////////////////////////////////////////// // common helpers - basegfx::B2DPolyPolygon impScalePolyPolygonOnCenter(const basegfx::B2DPolyPolygon& rSource, double fScale) + basegfx::B2DPolyPolygon impScalePolyPolygonOnCenter( + const basegfx::B2DPolyPolygon& rSource, + double fScale) { basegfx::B2DPolyPolygon aRetval(rSource); @@ -110,7 +112,11 @@ namespace return aRetval; } - void impGetOuterPolyPolygon(basegfx::B2DPolyPolygon& rPolygon, basegfx::B2DPolyPolygon& rOuterPolyPolygon, double fOffset, bool bCharacterMode) + void impGetOuterPolyPolygon( + basegfx::B2DPolyPolygon& rPolygon, + basegfx::B2DPolyPolygon& rOuterPolyPolygon, + double fOffset, + bool bCharacterMode) { rOuterPolyPolygon = rPolygon; @@ -144,8 +150,14 @@ namespace } } - void impAddInBetweenFill(basegfx::B3DPolyPolygon& rTarget, const basegfx::B3DPolyPolygon& rPolA, const basegfx::B3DPolyPolygon& rPolB, - double fTexVerStart, double fTexVerStop, bool bCreateNormals, bool bCreateTextureCoordinates) + void impAddInBetweenFill( + basegfx::B3DPolyPolygon& rTarget, + const basegfx::B3DPolyPolygon& rPolA, + const basegfx::B3DPolyPolygon& rPolB, + double fTexVerStart, + double fTexVerStop, + bool bCreateNormals, + bool bCreateTextureCoordinates) { OSL_ENSURE(rPolA.count() == rPolB.count(), "impAddInBetweenFill: unequally sized polygons (!)"); const sal_uInt32 nPolygonCount(rPolA.count()); @@ -222,7 +234,9 @@ namespace } } - void impSetNormal(basegfx::B3DPolyPolygon& rCandidate, const basegfx::B3DVector& rNormal) + void impSetNormal( + basegfx::B3DPolyPolygon& rCandidate, + const basegfx::B3DVector& rNormal) { for(sal_uInt32 a(0L); a < rCandidate.count(); a++) { @@ -237,7 +251,10 @@ namespace } } - void impCreateInBetweenNormals(basegfx::B3DPolyPolygon& rPolA, basegfx::B3DPolyPolygon& rPolB, bool bSmoothHorizontalNormals) + void impCreateInBetweenNormals( + basegfx::B3DPolyPolygon& rPolA, + basegfx::B3DPolyPolygon& rPolB, + bool bSmoothHorizontalNormals) { OSL_ENSURE(rPolA.count() == rPolB.count(), "sdrExtrudePrimitive3D: unequally sized polygons (!)"); @@ -316,7 +333,10 @@ namespace } } - void impMixNormals(basegfx::B3DPolyPolygon& rPolA, const basegfx::B3DPolyPolygon& rPolB, double fWeightA) + void impMixNormals( + basegfx::B3DPolyPolygon& rPolA, + const basegfx::B3DPolyPolygon& rPolB, + double fWeightA) { const double fWeightB(1.0 - fWeightA); OSL_ENSURE(rPolA.count() == rPolB.count(), "sdrExtrudePrimitive3D: unequally sized polygons (!)"); @@ -340,7 +360,6 @@ namespace rPolA.setB3DPolygon(a, aSubA); } } - } // end of anonymous namespace ////////////////////////////////////////////////////////////////////////////// @@ -349,14 +368,21 @@ namespace drawinglayer { namespace primitive3d { - void createLatheSlices(sliceVector& rSliceVector, const basegfx::B2DPolyPolygon& rSource, - double fBackScale, double fDiagonal, double fRotation, sal_uInt32 nSteps, - bool bCharacterMode, bool bCloseFront, bool bCloseBack) + void createLatheSlices( + Slice3DVector& rSliceVector, + const basegfx::B2DPolyPolygon& rSource, + double fBackScale, + double fDiagonal, + double fRotation, + sal_uInt32 nSteps, + bool bCharacterMode, + bool bCloseFront, + bool bCloseBack) { if(basegfx::fTools::equalZero(fRotation) || 0L == nSteps) { // no rotation or no steps, just one plane - rSliceVector.push_back(slice(rSource, basegfx::B3DHomMatrix())); + rSliceVector.push_back(Slice3D(rSource, basegfx::B3DHomMatrix())); } else { @@ -398,7 +424,7 @@ namespace drawinglayer impGetOuterPolyPolygon(aFront, aOuterFront, fOffsetLen, bCharacterMode); basegfx::B3DHomMatrix aTransform; aTransform.translate(0.0, 0.0, fOffsetLen); - rSliceVector.push_back(slice(aOuterFront, aTransform, SLICETYPE_FRONTCAP)); + rSliceVector.push_back(Slice3D(aOuterFront, aTransform, SLICETYPE3D_FRONTCAP)); } if(bCloseBack) @@ -413,7 +439,7 @@ namespace drawinglayer // add start polygon (a = 0L) if(!bClosedRotation) { - rSliceVector.push_back(slice(aFront, basegfx::B3DHomMatrix())); + rSliceVector.push_back(Slice3D(aFront, basegfx::B3DHomMatrix())); } // create segments (a + 1 .. nSteps) @@ -425,24 +451,30 @@ namespace drawinglayer basegfx::B2DPolyPolygon aNewPoly(bBackScale ? basegfx::tools::interpolate(aFront, aBack, fStep) : aFront); basegfx::B3DHomMatrix aNewMat; aNewMat.rotate(0.0, fRotation * fStep, 0.0); - rSliceVector.push_back(slice(aNewPoly, aNewMat)); + rSliceVector.push_back(Slice3D(aNewPoly, aNewMat)); } if(bCloseBack) { - rSliceVector.push_back(slice(aOuterBack, aTransformBack, SLICETYPE_BACKCAP)); + rSliceVector.push_back(Slice3D(aOuterBack, aTransformBack, SLICETYPE3D_BACKCAP)); } } } - void createExtrudeSlices(sliceVector& rSliceVector, const basegfx::B2DPolyPolygon& rSource, - double fBackScale, double fDiagonal, double fDepth, - bool bCharacterMode, bool bCloseFront, bool bCloseBack) + void createExtrudeSlices( + Slice3DVector& rSliceVector, + const basegfx::B2DPolyPolygon& rSource, + double fBackScale, + double fDiagonal, + double fDepth, + bool bCharacterMode, + bool bCloseFront, + bool bCloseBack) { if(basegfx::fTools::equalZero(fDepth)) { // no depth, just one plane - rSliceVector.push_back(slice(rSource, basegfx::B3DHomMatrix())); + rSliceVector.push_back(Slice3D(rSource, basegfx::B3DHomMatrix())); } else { @@ -474,7 +506,7 @@ namespace drawinglayer impGetOuterPolyPolygon(aFront, aOuterFront, fOffset, bCharacterMode); basegfx::B3DHomMatrix aTransformFront; aTransformFront.translate(0.0, 0.0, fDepth); - rSliceVector.push_back(slice(aOuterFront, aTransformFront, SLICETYPE_FRONTCAP)); + rSliceVector.push_back(Slice3D(aOuterFront, aTransformFront, SLICETYPE3D_FRONTCAP)); } if(bCloseBack) @@ -489,26 +521,29 @@ namespace drawinglayer basegfx::B3DHomMatrix aTransformA, aTransformB; aTransformA.translate(0.0, 0.0, fZFront); - rSliceVector.push_back(slice(aFront, aTransformA)); + rSliceVector.push_back(Slice3D(aFront, aTransformA)); aTransformB.translate(0.0, 0.0, fZBack); - rSliceVector.push_back(slice(aBack, aTransformB)); + rSliceVector.push_back(Slice3D(aBack, aTransformB)); } if(bCloseBack) { - rSliceVector.push_back(slice(aOuterBack, basegfx::B3DHomMatrix(), SLICETYPE_BACKCAP)); + rSliceVector.push_back(Slice3D(aOuterBack, basegfx::B3DHomMatrix(), SLICETYPE3D_BACKCAP)); } } } - void extractLinesFromSlice(basegfx::B3DPolyPolygon& rLine, const sliceVector& rSliceVector, bool bClosed) + void extractLinesFromSlice( + basegfx::B3DPolyPolygon& rLine, + const Slice3DVector& rSliceVector, + bool bClosed) { const sal_uInt32 nNumSlices(rSliceVector.size()); if(nNumSlices) { - // slices self + // Slice3Ds self for(sal_uInt32 a(0L); a < nNumSlices; a++) { rLine.append(rSliceVector[a].getB3DPolyPolygon()); @@ -539,9 +574,18 @@ namespace drawinglayer } } - void extractPlanesFromSlice(::std::vector< basegfx::B3DPolyPolygon >& rFill, const sliceVector& rSliceVector, - bool bCreateNormals, bool bSmoothHorizontalNormals, bool bSmoothNormals, bool bSmoothLids, bool bClosed, - double fSmoothNormalsMix, double fSmoothLidsMix, bool bCreateTextureCoordinates, const basegfx::B2DHomMatrix& rTexTransform) + void extractPlanesFromSlice( + ::std::vector< basegfx::B3DPolyPolygon >& rFill, + const Slice3DVector& rSliceVector, + bool bCreateNormals, + bool bSmoothHorizontalNormals, + bool bSmoothNormals, + bool bSmoothLids, + bool bClosed, + double fSmoothNormalsMix, + double fSmoothLidsMix, + bool bCreateTextureCoordinates, + const basegfx::B2DHomMatrix& rTexTransform) { const sal_uInt32 nNumSlices(rSliceVector.size()); @@ -596,9 +640,9 @@ namespace drawinglayer for(a = 0L; a < nLoopCount; a++) { - const slice& rSliceA(rSliceVector[a]); - const slice& rSliceB(rSliceVector[(a + 1L) % nNumSlices]); - const bool bAcceptPair(SLICETYPE_REGULAR == rSliceA.getSliceType() && SLICETYPE_REGULAR == rSliceB.getSliceType()); + const Slice3D& rSliceA(rSliceVector[a]); + const Slice3D& rSliceB(rSliceVector[(a + 1L) % nNumSlices]); + const bool bAcceptPair(SLICETYPE3D_REGULAR == rSliceA.getSliceType() && SLICETYPE3D_REGULAR == rSliceB.getSliceType()); basegfx::B3DPolyPolygon aPolA(rSliceA.getB3DPolyPolygon()); basegfx::B3DPolyPolygon aPolB(rSliceB.getB3DPolyPolygon()); @@ -611,11 +655,11 @@ namespace drawinglayer { const sal_uInt32 nIndPrev((a + nNumSlices - 1L) % nNumSlices); - const slice& rSlicePrev(rSliceVector[nIndPrev]); + const Slice3D& rSlicePrev(rSliceVector[nIndPrev]); basegfx::B3DPolyPolygon aPrev(rSlicePrev.getB3DPolyPolygon()); basegfx::B3DPolyPolygon aPolAA(rSliceA.getB3DPolyPolygon()); - if(SLICETYPE_FRONTCAP == rSlicePrev.getSliceType()) + if(SLICETYPE3D_FRONTCAP == rSlicePrev.getSliceType()) { basegfx::B3DPolyPolygon aFront(rSlicePrev.getB3DPolyPolygon()); const bool bHasSlant(aPolAA != aPrev); @@ -701,11 +745,11 @@ namespace drawinglayer { const sal_uInt32 nIndNext((a + 2L) % nNumSlices); - const slice& rSliceNext(rSliceVector[nIndNext]); + const Slice3D& rSliceNext(rSliceVector[nIndNext]); basegfx::B3DPolyPolygon aNext(rSliceNext.getB3DPolyPolygon()); basegfx::B3DPolyPolygon aPolBB(rSliceB.getB3DPolyPolygon()); - if(SLICETYPE_BACKCAP == rSliceNext.getSliceType()) + if(SLICETYPE3D_BACKCAP == rSliceNext.getSliceType()) { basegfx::B3DPolyPolygon aBack(rSliceNext.getB3DPolyPolygon()); const bool bHasSlant(aPolBB != aNext); diff --git a/drawinglayer/source/primitive3d/sdrextrudeprimitive3d.cxx b/drawinglayer/source/primitive3d/sdrextrudeprimitive3d.cxx index 117274b3ca42..e5648f05f546 100644 --- a/drawinglayer/source/primitive3d/sdrextrudeprimitive3d.cxx +++ b/drawinglayer/source/primitive3d/sdrextrudeprimitive3d.cxx @@ -4,9 +4,9 @@ * * $RCSfile: sdrextrudeprimitive3d.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: aw $ $Date: 2006-08-09 16:51:15 $ + * last change: $Author: aw $ $Date: 2006-10-19 10:38:33 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -33,37 +33,33 @@ * ************************************************************************/ -#ifndef _DRAWINGLAYER_PRIMITIVE3D_SDREXTRUDEPRIMITIVE3D_HXX +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDREXTRUDEPRIMITIVE3D_HXX #include <drawinglayer/primitive3d/sdrextrudeprimitive3d.hxx> #endif -#ifndef _DRAWINGLAYER_PRIMITIVE3D_SDREXTRUDELATHETOOLS3D_HXX -#include <drawinglayer/primitive3d/sdrextrudelathetools3d.hxx> -#endif - -#ifndef _BGFX_POLYPOLYGON_B3DPOLYGONTOOLS_HXX -#include <basegfx/polygon/b3dpolypolygontools.hxx> +#ifndef _BGFX_MATRIX_B2DHOMMATRIX_HXX +#include <basegfx/matrix/b2dhommatrix.hxx> #endif -#ifndef _BGFX_POLYGON_B3DPOLYPOLYGON_HXX -#include <basegfx/polygon/b3dpolypolygon.hxx> +#ifndef _BGFX_POLYGON_B2DPOLYGONTOOLS_HXX +#include <basegfx/polygon/b2dpolygontools.hxx> #endif -#ifndef _BGFX_MATRIX_B2DHOMMATRIX_HXX -#include <basegfx/matrix/b2dhommatrix.hxx> +#ifndef _BGFX_POLYPOLYGON_B3DPOLYGONTOOLS_HXX +#include <basegfx/polygon/b3dpolypolygontools.hxx> #endif -#ifndef _DRAWINGLAYER_PRIMITIVE3D_SDRDECOMPOSITIONTOOLS3D_HXX +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDRDECOMPOSITIONTOOLS3D_HXX #include <drawinglayer/primitive3d/sdrdecompositiontools3d.hxx> #endif -#ifndef _BGFX_POLYPOLYGON_B2DPOLYGONTOOLS_HXX -#include <basegfx/polygon/b2dpolypolygontools.hxx> +#ifndef _BGFX_TOOLS_CANVASTOOLS_HXX +#include <basegfx/tools/canvastools.hxx> #endif -#ifndef _BGFX_POLYGON_B2DPOLYGONTOOLS_HXX -#include <basegfx/polygon/b2dpolygontools.hxx> -#endif +////////////////////////////////////////////////////////////////////////////// + +using namespace com::sun::star; ////////////////////////////////////////////////////////////////////////////// @@ -71,10 +67,12 @@ namespace drawinglayer { namespace primitive3d { - void sdrExtrudePrimitive3D::decompose(primitiveVector3D& rTarget) + Primitive3DSequence SdrExtrudePrimitive3D::createLocalDecomposition(double /*fTime*/) const { + Primitive3DSequence aRetval; + // get slices - const sliceVector& rSliceVector = getSlices(); + const Slice3DVector& rSliceVector = getSlices(); if(rSliceVector.size()) { @@ -114,7 +112,7 @@ namespace drawinglayer // create geometry ::std::vector< basegfx::B3DPolyPolygon > aFill; extractPlanesFromSlice(aFill, rSliceVector, - bCreateNormals, mbSmoothHorizontalNormals, mbSmoothNormals, mbSmoothLids, false, + bCreateNormals, getSmoothHorizontalNormals(), getSmoothNormals(), getSmoothLids(), false, 0.5, 0.6, bCreateTextureCoordiantesX || bCreateTextureCoordiantesY, aTexTransform); // get full range @@ -186,7 +184,7 @@ namespace drawinglayer // transform texture coordinates to texture size basegfx::B2DHomMatrix aTexMatrix; - aTexMatrix.scale(maTextureSize.getX(), maTextureSize.getY()); + aTexMatrix.scale(getTextureSize().getX(), getTextureSize().getY()); for(a = 0L; a < aFill.size(); a++) { @@ -195,8 +193,8 @@ namespace drawinglayer } // create single PolyPolygonFill primitives - add3DPolyPolygonFillPrimitive( - aFill, maTransform, maTextureSize, rTarget, + aRetval = create3DPolyPolygonFillPrimitives( + aFill, getTransform(), getTextureSize(), getSdr3DObjectAttribute(), *getSdrLFSAttribute().getFill(), getSdrLFSAttribute().getFillFloatTransGradient()); } @@ -206,46 +204,49 @@ namespace drawinglayer { basegfx::B3DPolyPolygon aLine; extractLinesFromSlice(aLine, rSliceVector, false); - add3DPolyPolygonLinePrimitive(aLine, maTransform, rTarget, *maSdrLFSAttribute.getLine()); + const Primitive3DSequence aLines(create3DPolyPolygonLinePrimitives(aLine, getTransform(), *getSdrLFSAttribute().getLine())); + appendPrimitive3DSequenceToPrimitive3DSequence(aRetval, aLines); } // add shadow - if(getSdrLFSAttribute().getShadow()) + if(getSdrLFSAttribute().getShadow() && aRetval.hasElements()) { - addShadowPrimitive3D(rTarget, *getSdrLFSAttribute().getShadow(), getSdr3DObjectAttribute().getShadow3D()); + const Primitive3DSequence aShadow(createShadowPrimitive3D(aRetval, *getSdrLFSAttribute().getShadow(), getSdr3DObjectAttribute().getShadow3D())); + appendPrimitive3DSequenceToPrimitive3DSequence(aRetval, aShadow); } } + + return aRetval; } - void sdrExtrudePrimitive3D::impCreateSlices() + void SdrExtrudePrimitive3D::impCreateSlices() { - maCorrectedPolyPolygon = maPolyPolygon; - // prepare the polygon + maCorrectedPolyPolygon = getPolyPolygon(); maCorrectedPolyPolygon.removeDoublePoints(); maCorrectedPolyPolygon = basegfx::tools::correctOrientations(maCorrectedPolyPolygon); maCorrectedPolyPolygon = basegfx::tools::correctOutmostPolygon(maCorrectedPolyPolygon); // prepare slices as geometry - createExtrudeSlices(maSlices, maCorrectedPolyPolygon, mfBackScale, mfDiagonal, mfDepth, mbCharacterMode, mbCloseFront, mbCloseBack); + createExtrudeSlices(maSlices, maCorrectedPolyPolygon, getBackScale(), getDiagonal(), getDepth(), getCharacterMode(), getCloseFront(), getCloseBack()); } - const sliceVector& sdrExtrudePrimitive3D::getSlices() const + const Slice3DVector& SdrExtrudePrimitive3D::getSlices() const { - if(maPolyPolygon.count() && !maSlices.size() && (getSdrLFSAttribute().getFill() || getSdrLFSAttribute().getLine())) + if(getPolyPolygon().count() && !maSlices.size() && (getSdrLFSAttribute().getFill() || getSdrLFSAttribute().getLine())) { ::osl::Mutex m_mutex; - const_cast< sdrExtrudePrimitive3D& >(*this).impCreateSlices(); + const_cast< SdrExtrudePrimitive3D& >(*this).impCreateSlices(); } return maSlices; } - sdrExtrudePrimitive3D::sdrExtrudePrimitive3D( + SdrExtrudePrimitive3D::SdrExtrudePrimitive3D( const basegfx::B3DHomMatrix& rTransform, const basegfx::B2DVector& rTextureSize, - const attribute::sdrLineFillShadowAttribute& rSdrLFSAttribute, - const attribute::sdr3DObjectAttribute& rSdr3DObjectAttribute, + const attribute::SdrLineFillShadowAttribute& rSdrLFSAttribute, + const attribute::Sdr3DObjectAttribute& rSdr3DObjectAttribute, const basegfx::B2DPolyPolygon& rPolyPolygon, double fDepth, double fDiagonal, @@ -256,7 +257,7 @@ namespace drawinglayer bool bCharacterMode, bool bCloseFront, bool bCloseBack) - : sdrPrimitive3D(rTransform, rTextureSize, rSdrLFSAttribute, rSdr3DObjectAttribute), + : SdrPrimitive3D(rTransform, rTextureSize, rSdrLFSAttribute, rSdr3DObjectAttribute), maPolyPolygon(rPolyPolygon), mfDepth(fDepth), mfDiagonal(fDiagonal), @@ -269,64 +270,56 @@ namespace drawinglayer mbCloseBack(bCloseBack) { // make sure depth is positive - if(basegfx::fTools::lessOrEqual(mfDepth, 0.0)) + if(basegfx::fTools::lessOrEqual(getDepth(), 0.0)) { mfDepth = 0.0; } - // make sure the percentage value mfDiagonal is between 0.0 and 1.0 - if(basegfx::fTools::lessOrEqual(mfDiagonal, 0.0)) + // make sure the percentage value getDiagonal() is between 0.0 and 1.0 + if(basegfx::fTools::lessOrEqual(getDiagonal(), 0.0)) { mfDiagonal = 0.0; } - else if(basegfx::fTools::moreOrEqual(mfDiagonal, 1.0)) + else if(basegfx::fTools::moreOrEqual(getDiagonal(), 1.0)) { mfDiagonal = 1.0; } // no close front/back when polygon is not closed - if(maPolyPolygon.count() && !maPolyPolygon.getB2DPolygon(0L).isClosed()) + if(getPolyPolygon().count() && !getPolyPolygon().getB2DPolygon(0L).isClosed()) { mbCloseFront = mbCloseBack = false; } // no edge rounding when not closing - if(!mbCloseFront && !mbCloseBack) + if(!getCloseFront() && !getCloseBack()) { mfDiagonal = 0.0; } } - sdrExtrudePrimitive3D::~sdrExtrudePrimitive3D() - { - } - - bool sdrExtrudePrimitive3D::operator==(const basePrimitive3D& rPrimitive) const + bool SdrExtrudePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const { - if(sdrPrimitive3D::operator==(rPrimitive)) + if(SdrPrimitive3D::operator==(rPrimitive)) { - const sdrExtrudePrimitive3D& rCompare = static_cast< const sdrExtrudePrimitive3D& >(rPrimitive); - return (maPolyPolygon == rCompare.maPolyPolygon - && mfDepth == rCompare.mfDepth - && mfDiagonal == rCompare.mfDiagonal - && mfBackScale == rCompare.mfBackScale - && mbSmoothNormals == rCompare.mbSmoothNormals - && mbSmoothHorizontalNormals == rCompare.mbSmoothHorizontalNormals - && mbSmoothLids == rCompare.mbSmoothLids - && mbCharacterMode == rCompare.mbCharacterMode - && mbCloseFront == rCompare.mbCloseFront - && mbCloseBack == rCompare.mbCloseBack); + const SdrExtrudePrimitive3D& rCompare = static_cast< const SdrExtrudePrimitive3D& >(rPrimitive); + + return (getPolyPolygon() == rCompare.getPolyPolygon() + && getDepth() == rCompare.getDepth() + && getDiagonal() == rCompare.getDiagonal() + && getBackScale() == rCompare.getBackScale() + && getSmoothNormals() == rCompare.getSmoothNormals() + && getSmoothHorizontalNormals() == rCompare.getSmoothHorizontalNormals() + && getSmoothLids() == rCompare.getSmoothLids() + && getCharacterMode() == rCompare.getCharacterMode() + && getCloseFront() == rCompare.getCloseFront() + && getCloseBack() == rCompare.getCloseBack()); } return false; } - PrimitiveID sdrExtrudePrimitive3D::getID() const - { - return CreatePrimitiveID('S', 'X', 'T', '3'); - } - - basegfx::B3DRange sdrExtrudePrimitive3D::get3DRange() const + basegfx::B3DRange SdrExtrudePrimitive3D::getB3DRange(double /*fTime*/) const { // use defaut from sdrPrimitive3D which uses transformation expanded by line width/2 // The parent implementation which uses the ranges of the decomposition would be more @@ -336,6 +329,11 @@ namespace drawinglayer // has priority here. return get3DRangeFromSlices(getSlices()); } + + sal_uInt32 SdrExtrudePrimitive3D::getPrimitiveID() const + { + return Create3DPrimitiveID('3','E','x','t'); + } } // end of namespace primitive3d } // end of namespace drawinglayer diff --git a/drawinglayer/source/primitive3d/sdrlatheprimitive3d.cxx b/drawinglayer/source/primitive3d/sdrlatheprimitive3d.cxx index 5ef59dbeedec..86ecce156d15 100644 --- a/drawinglayer/source/primitive3d/sdrlatheprimitive3d.cxx +++ b/drawinglayer/source/primitive3d/sdrlatheprimitive3d.cxx @@ -4,9 +4,9 @@ * * $RCSfile: sdrlatheprimitive3d.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: aw $ $Date: 2006-08-09 16:51:15 $ + * last change: $Author: aw $ $Date: 2006-10-19 10:38:33 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -33,20 +33,12 @@ * ************************************************************************/ -#ifndef _DRAWINGLAYER_PRIMITIVE3D_SDRLATHEPRIMITIVE3D_HXX +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDRLATHEPRIMITIVE3D_HXX #include <drawinglayer/primitive3d/sdrlatheprimitive3d.hxx> #endif -#ifndef _BGFX_POLYPOLYGON_B2DPOLYGONTOOLS_HXX -#include <basegfx/polygon/b2dpolypolygontools.hxx> -#endif - -#ifndef _DRAWINGLAYER_PRIMITIVE3D_SDREXTRUDELATHETOOLS3D_HXX -#include <drawinglayer/primitive3d/sdrextrudelathetools3d.hxx> -#endif - -#ifndef _DRAWINGLAYER_PRIMITIVE3D_SDRDECOMPOSITIONTOOLS3D_HXX -#include <drawinglayer/primitive3d/sdrdecompositiontools3d.hxx> +#ifndef _BGFX_MATRIX_B2DHOMMATRIX_HXX +#include <basegfx/matrix/b2dhommatrix.hxx> #endif #ifndef _BGFX_POLYGON_B2DPOLYGONTOOLS_HXX @@ -57,25 +49,35 @@ #include <basegfx/polygon/b3dpolypolygontools.hxx> #endif -#ifndef _BGFX_MATRIX_B2DHOMMATRIX_HXX -#include <basegfx/matrix/b2dhommatrix.hxx> +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDRDECOMPOSITIONTOOLS3D_HXX +#include <drawinglayer/primitive3d/sdrdecompositiontools3d.hxx> #endif +#ifndef _BGFX_TOOLS_CANVASTOOLS_HXX +#include <basegfx/tools/canvastools.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// + +using namespace com::sun::star; + ////////////////////////////////////////////////////////////////////////////// namespace drawinglayer { namespace primitive3d { - void sdrLathePrimitive3D::decompose(primitiveVector3D& rTarget) + Primitive3DSequence SdrLathePrimitive3D::createLocalDecomposition(double /*fTime*/) const { + Primitive3DSequence aRetval; + // get slices - const sliceVector& rSliceVector = getSlices(); + const Slice3DVector& rSliceVector = getSlices(); if(rSliceVector.size()) { - const bool bBackScale(!basegfx::fTools::equal(mfBackScale, 1.0)); - const bool bClosedRotation(!bBackScale && mnHorizontalSegments && basegfx::fTools::equal(mfRotation, F_2PI)); + const bool bBackScale(!basegfx::fTools::equal(getBackScale(), 1.0)); + const bool bClosedRotation(!bBackScale && getHorizontalSegments() && basegfx::fTools::equal(getRotation(), F_2PI)); // add fill if(getSdrLFSAttribute().getFill()) @@ -104,7 +106,7 @@ namespace drawinglayer // create geometry ::std::vector< basegfx::B3DPolyPolygon > aFill; extractPlanesFromSlice(aFill, rSliceVector, - bCreateNormals, mbSmoothHorizontalNormals, mbSmoothNormals, mbSmoothLids, bClosedRotation, + bCreateNormals, getSmoothHorizontalNormals(), getSmoothNormals(), getSmoothLids(), bClosedRotation, 0.85, 0.6, bCreateTextureCoordiantesX || bCreateTextureCoordiantesY, aTexTransform); // get full range @@ -176,7 +178,7 @@ namespace drawinglayer // transform texture coordinates to texture size basegfx::B2DHomMatrix aTexMatrix; - aTexMatrix.scale(maTextureSize.getX(), maTextureSize.getY()); + aTexMatrix.scale(getTextureSize().getX(), getTextureSize().getY()); for(a = 0L; a < aFill.size(); a++) { @@ -185,8 +187,8 @@ namespace drawinglayer } // create single PolyPolygonFill primitives - add3DPolyPolygonFillPrimitive( - aFill, maTransform, maTextureSize, rTarget, + aRetval = create3DPolyPolygonFillPrimitives( + aFill, getTransform(), getTextureSize(), getSdr3DObjectAttribute(), *getSdrLFSAttribute().getFill(), getSdrLFSAttribute().getFillFloatTransGradient()); } @@ -196,21 +198,25 @@ namespace drawinglayer { basegfx::B3DPolyPolygon aLine; extractLinesFromSlice(aLine, rSliceVector, bClosedRotation); - add3DPolyPolygonLinePrimitive(aLine, maTransform, rTarget, *maSdrLFSAttribute.getLine()); + const Primitive3DSequence aLines(create3DPolyPolygonLinePrimitives(aLine, getTransform(), *getSdrLFSAttribute().getLine())); + appendPrimitive3DSequenceToPrimitive3DSequence(aRetval, aLines); } // add shadow - if(getSdrLFSAttribute().getShadow()) + if(getSdrLFSAttribute().getShadow() && aRetval.hasElements()) { - addShadowPrimitive3D(rTarget, *getSdrLFSAttribute().getShadow(), getSdr3DObjectAttribute().getShadow3D()); + const Primitive3DSequence aShadow(createShadowPrimitive3D(aRetval, *getSdrLFSAttribute().getShadow(), getSdr3DObjectAttribute().getShadow3D())); + appendPrimitive3DSequenceToPrimitive3DSequence(aRetval, aShadow); } } + + return aRetval; } - void sdrLathePrimitive3D::impCreateSlices() + void SdrLathePrimitive3D::impCreateSlices() { // prepare the polygon - basegfx::B2DPolyPolygon aCandidate(basegfx::tools::adaptiveSubdivideByDistance(maPolyPolygon)); + basegfx::B2DPolyPolygon aCandidate(basegfx::tools::adaptiveSubdivideByDistance(getPolyPolygon())); aCandidate.removeDoublePoints(); aCandidate = basegfx::tools::correctOrientations(aCandidate); aCandidate = basegfx::tools::correctOutmostPolygon(aCandidate); @@ -221,31 +227,31 @@ namespace drawinglayer const basegfx::B2DPolygon aSubCandidate(aCandidate.getB2DPolygon(0L)); const sal_uInt32 nSubEdgeCount(aSubCandidate.isClosed() ? aSubCandidate.count() : (aSubCandidate.count() ? aSubCandidate.count() - 1L : 0L)); - if(nSubEdgeCount != mnVerticalSegments) + if(nSubEdgeCount != getVerticalSegments()) { - aCandidate = basegfx::tools::reSegmentPolyPolygon(aCandidate, mnVerticalSegments); + aCandidate = basegfx::tools::reSegmentPolyPolygon(aCandidate, getVerticalSegments()); } // prepare slices as geometry - createLatheSlices(maSlices, aCandidate, mfBackScale, mfDiagonal, mfRotation, mnHorizontalSegments, mbCharacterMode, mbCloseFront, mbCloseBack); + createLatheSlices(maSlices, aCandidate, getBackScale(), getDiagonal(), getRotation(), getHorizontalSegments(), getCharacterMode(), getCloseFront(), getCloseBack()); } - const sliceVector& sdrLathePrimitive3D::getSlices() const + const Slice3DVector& SdrLathePrimitive3D::getSlices() const { - if(maPolyPolygon.count() && !maSlices.size() && (getSdrLFSAttribute().getFill() || getSdrLFSAttribute().getLine())) + if(getPolyPolygon().count() && !maSlices.size() && (getSdrLFSAttribute().getFill() || getSdrLFSAttribute().getLine())) { ::osl::Mutex m_mutex; - const_cast< sdrLathePrimitive3D& >(*this).impCreateSlices(); + const_cast< SdrLathePrimitive3D& >(*this).impCreateSlices(); } return maSlices; } - sdrLathePrimitive3D::sdrLathePrimitive3D( + SdrLathePrimitive3D::SdrLathePrimitive3D( const basegfx::B3DHomMatrix& rTransform, const basegfx::B2DVector& rTextureSize, - const attribute::sdrLineFillShadowAttribute& rSdrLFSAttribute, - const attribute::sdr3DObjectAttribute& rSdr3DObjectAttribute, + const attribute::SdrLineFillShadowAttribute& rSdrLFSAttribute, + const attribute::Sdr3DObjectAttribute& rSdr3DObjectAttribute, const basegfx::B2DPolyPolygon& rPolyPolygon, sal_uInt32 nHorizontalSegments, sal_uInt32 nVerticalSegments, @@ -258,7 +264,7 @@ namespace drawinglayer bool bCharacterMode, bool bCloseFront, bool bCloseBack) - : sdrPrimitive3D(rTransform, rTextureSize, rSdrLFSAttribute, rSdr3DObjectAttribute), + : SdrPrimitive3D(rTransform, rTextureSize, rSdrLFSAttribute, rSdr3DObjectAttribute), maPolyPolygon(rPolyPolygon), mnHorizontalSegments(nHorizontalSegments), mnVerticalSegments(nVerticalSegments), @@ -273,66 +279,58 @@ namespace drawinglayer mbCloseBack(bCloseBack) { // make sure Rotation is positive - if(basegfx::fTools::lessOrEqual(mfRotation, 0.0)) + if(basegfx::fTools::lessOrEqual(getRotation(), 0.0)) { mfRotation = 0.0; } - // make sure the percentage value mfDiagonal is between 0.0 and 1.0 - if(basegfx::fTools::lessOrEqual(mfDiagonal, 0.0)) + // make sure the percentage value getDiagonal() is between 0.0 and 1.0 + if(basegfx::fTools::lessOrEqual(getDiagonal(), 0.0)) { mfDiagonal = 0.0; } - else if(basegfx::fTools::moreOrEqual(mfDiagonal, 1.0)) + else if(basegfx::fTools::moreOrEqual(getDiagonal(), 1.0)) { mfDiagonal = 1.0; } // no close front/back when polygon is not closed - if(maPolyPolygon.count() && !maPolyPolygon.getB2DPolygon(0L).isClosed()) + if(getPolyPolygon().count() && !getPolyPolygon().getB2DPolygon(0L).isClosed()) { mbCloseFront = mbCloseBack = false; } // no edge rounding when not closing - if(!mbCloseFront && !mbCloseBack) + if(!getCloseFront() && !getCloseBack()) { mfDiagonal = 0.0; } } - sdrLathePrimitive3D::~sdrLathePrimitive3D() - { - } - - bool sdrLathePrimitive3D::operator==(const basePrimitive3D& rPrimitive) const + bool SdrLathePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const { - if(sdrPrimitive3D::operator==(rPrimitive)) + if(SdrPrimitive3D::operator==(rPrimitive)) { - const sdrLathePrimitive3D& rCompare = static_cast< const sdrLathePrimitive3D& >(rPrimitive); - return (maPolyPolygon == rCompare.maPolyPolygon - && mnHorizontalSegments == rCompare.mnHorizontalSegments - && mnVerticalSegments == rCompare.mnVerticalSegments - && mfDiagonal == rCompare.mfDiagonal - && mfBackScale == rCompare.mfBackScale - && mfRotation == rCompare.mfRotation - && mbSmoothNormals == rCompare.mbSmoothNormals - && mbSmoothHorizontalNormals == rCompare.mbSmoothHorizontalNormals - && mbSmoothLids == rCompare.mbSmoothLids - && mbCharacterMode == rCompare.mbCharacterMode - && mbCloseFront == rCompare.mbCloseFront - && mbCloseBack == rCompare.mbCloseBack); + const SdrLathePrimitive3D& rCompare = static_cast< const SdrLathePrimitive3D& >(rPrimitive); + + return (getPolyPolygon() == rCompare.getPolyPolygon() + && getHorizontalSegments() == rCompare.getHorizontalSegments() + && getVerticalSegments() == rCompare.getVerticalSegments() + && getDiagonal() == rCompare.getDiagonal() + && getBackScale() == rCompare.getBackScale() + && getRotation() == rCompare.getRotation() + && getSmoothNormals() == rCompare.getSmoothNormals() + && getSmoothHorizontalNormals() == rCompare.getSmoothHorizontalNormals() + && getSmoothLids() == rCompare.getSmoothLids() + && getCharacterMode() == rCompare.getCharacterMode() + && getCloseFront() == rCompare.getCloseFront() + && getCloseBack() == rCompare.getCloseBack()); } return false; } - PrimitiveID sdrLathePrimitive3D::getID() const - { - return CreatePrimitiveID('S', 'L', 'A', '3'); - } - - basegfx::B3DRange sdrLathePrimitive3D::get3DRange() const + basegfx::B3DRange SdrLathePrimitive3D::getB3DRange(double /*fTime*/) const { // use defaut from sdrPrimitive3D which uses transformation expanded by line width/2 // The parent implementation which uses the ranges of the decomposition would be more @@ -342,6 +340,11 @@ namespace drawinglayer // has priority here. return get3DRangeFromSlices(getSlices()); } + + sal_uInt32 SdrLathePrimitive3D::getPrimitiveID() const + { + return Create3DPrimitiveID('3','L','a','t'); + } } // end of namespace primitive3d } // end of namespace drawinglayer diff --git a/drawinglayer/source/primitive3d/sdrpolypolygonprimitive3d.cxx b/drawinglayer/source/primitive3d/sdrpolypolygonprimitive3d.cxx new file mode 100644 index 000000000000..c91be70dc08f --- /dev/null +++ b/drawinglayer/source/primitive3d/sdrpolypolygonprimitive3d.cxx @@ -0,0 +1,125 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: sdrpolypolygonprimitive3d.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-10-19 10:38:34 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDRPOLYPOLYGONPRIMITIVE3D_HXX +#include <drawinglayer/primitive3d/sdrpolypolygonprimitive3d.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDRDECOMPOSITIONTOOLS3D_HXX +#include <drawinglayer/primitive3d/sdrdecompositiontools3d.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// + +using namespace com::sun::star; + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive3d + { + Primitive3DSequence SdrPolyPolygonPrimitive3D::createLocalDecomposition(double /*fTime*/) const + { + Primitive3DSequence aRetval; + + if(getPolyPolygon3D().count()) + { + // add fill + if(getSdrLFSAttribute().getFill()) + { + // create single PolyPolygonFill primitives + ::std::vector< basegfx::B3DPolyPolygon > aFill; + aFill.push_back(getPolyPolygon3D()); + + aRetval = create3DPolyPolygonFillPrimitives( + aFill, getTransform(), getTextureSize(), + getSdr3DObjectAttribute(), *getSdrLFSAttribute().getFill(), + getSdrLFSAttribute().getFillFloatTransGradient()); + } + + // add line + if(getSdrLFSAttribute().getLine()) + { + basegfx::B3DPolyPolygon aLine(getPolyPolygon3D()); + aLine.clearNormals(); + aLine.clearTextureCoordinates(); + const Primitive3DSequence aLines(create3DPolyPolygonLinePrimitives(aLine, getTransform(), *getSdrLFSAttribute().getLine())); + appendPrimitive3DSequenceToPrimitive3DSequence(aRetval, aLines); + } + + // add shadow + if(getSdrLFSAttribute().getShadow() && aRetval.hasElements()) + { + const Primitive3DSequence aShadow(createShadowPrimitive3D(aRetval, *getSdrLFSAttribute().getShadow(), getSdr3DObjectAttribute().getShadow3D())); + appendPrimitive3DSequenceToPrimitive3DSequence(aRetval, aShadow); + } + } + + return aRetval; + } + + SdrPolyPolygonPrimitive3D::SdrPolyPolygonPrimitive3D( + const basegfx::B3DPolyPolygon& rPolyPolygon3D, + const basegfx::B3DHomMatrix& rTransform, + const basegfx::B2DVector& rTextureSize, + const attribute::SdrLineFillShadowAttribute& rSdrLFSAttribute, + const attribute::Sdr3DObjectAttribute& rSdr3DObjectAttribute) + : SdrPrimitive3D(rTransform, rTextureSize, rSdrLFSAttribute, rSdr3DObjectAttribute), + maPolyPolygon3D(rPolyPolygon3D) + { + } + + bool SdrPolyPolygonPrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const + { + if(SdrPrimitive3D::operator==(rPrimitive)) + { + const SdrPolyPolygonPrimitive3D& rCompare = static_cast< const SdrPolyPolygonPrimitive3D& >(rPrimitive); + + return (getPolyPolygon3D() == rCompare.getPolyPolygon3D()); + } + + return false; + } + + sal_uInt32 SdrPolyPolygonPrimitive3D::getPrimitiveID() const + { + return Create3DPrimitiveID('3','P','P','o'); + } + } // end of namespace primitive3d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/primitive3d/sdrprimitive3d.cxx b/drawinglayer/source/primitive3d/sdrprimitive3d.cxx index bc7f5a7878bc..7e6b47f28f04 100644 --- a/drawinglayer/source/primitive3d/sdrprimitive3d.cxx +++ b/drawinglayer/source/primitive3d/sdrprimitive3d.cxx @@ -4,9 +4,9 @@ * * $RCSfile: sdrprimitive3d.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: aw $ $Date: 2006-08-09 16:51:15 $ + * last change: $Author: aw $ $Date: 2006-10-19 10:38:34 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -33,11 +33,11 @@ * ************************************************************************/ -#ifndef _DRAWINGLAYER_PRIMITIVE3D_SDRPRIMITIVE3D_HXX +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDRPRIMITIVE3D_HXX #include <drawinglayer/primitive3d/sdrprimitive3d.hxx> #endif -#ifndef _DRAWINGLAYER_ATTRIBUTE_SDRATTRIBUTE_HXX +#ifndef INCLUDED_DRAWINGLAYER_ATTRIBUTE_SDRATTRIBUTE_HXX #include <drawinglayer/attribute/sdrattribute.hxx> #endif @@ -47,18 +47,22 @@ ////////////////////////////////////////////////////////////////////////////// +using namespace com::sun::star; + +////////////////////////////////////////////////////////////////////////////// + namespace drawinglayer { namespace primitive3d { - basegfx::B3DRange sdrPrimitive3D::getStandard3DRange() const + basegfx::B3DRange SdrPrimitive3D::getStandard3DRange() const { basegfx::B3DRange aUnitRange(0.0, 0.0, 0.0, 1.0, 1.0, 1.0); aUnitRange.transform(getTransform()); - if(maSdrLFSAttribute.getLine()) + if(getSdrLFSAttribute().getLine()) { - const attribute::sdrLineAttribute& rLine = *maSdrLFSAttribute.getLine(); + const attribute::SdrLineAttribute& rLine = *getSdrLFSAttribute().getLine(); if(rLine.isVisible() && !basegfx::fTools::equalZero(rLine.getWidth())) { @@ -70,7 +74,7 @@ namespace drawinglayer return aUnitRange; } - basegfx::B3DRange sdrPrimitive3D::get3DRangeFromSlices(const sliceVector& rSlices) const + basegfx::B3DRange SdrPrimitive3D::get3DRangeFromSlices(const Slice3DVector& rSlices) const { basegfx::B3DRange aRetval; @@ -83,9 +87,9 @@ namespace drawinglayer aRetval.transform(getTransform()); - if(maSdrLFSAttribute.getLine()) + if(getSdrLFSAttribute().getLine()) { - const attribute::sdrLineAttribute& rLine = *maSdrLFSAttribute.getLine(); + const attribute::SdrLineAttribute& rLine = *getSdrLFSAttribute().getLine(); if(rLine.isVisible() && !basegfx::fTools::equalZero(rLine.getWidth())) { @@ -98,12 +102,12 @@ namespace drawinglayer return aRetval; } - sdrPrimitive3D::sdrPrimitive3D( + SdrPrimitive3D::SdrPrimitive3D( const basegfx::B3DHomMatrix& rTransform, const basegfx::B2DVector& rTextureSize, - const attribute::sdrLineFillShadowAttribute& rSdrLFSAttribute, - const attribute::sdr3DObjectAttribute& rSdr3DObjectAttribute) - : basePrimitive3D(), + const attribute::SdrLineFillShadowAttribute& rSdrLFSAttribute, + const attribute::Sdr3DObjectAttribute& rSdr3DObjectAttribute) + : BasePrimitive3D(), maTransform(rTransform), maTextureSize(rTextureSize), maSdrLFSAttribute(rSdrLFSAttribute), @@ -111,20 +115,16 @@ namespace drawinglayer { } - sdrPrimitive3D::~sdrPrimitive3D() - { - } - - bool sdrPrimitive3D::operator==(const basePrimitive3D& rPrimitive) const + bool SdrPrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const { - if(getID() == rPrimitive.getID()) + if(BasePrimitive3D::operator==(rPrimitive)) { - const sdrPrimitive3D& rCompare = static_cast< const sdrPrimitive3D& >(rPrimitive); + const SdrPrimitive3D& rCompare = static_cast< const SdrPrimitive3D& >(rPrimitive); - return (maTransform == rCompare.maTransform - && maTextureSize == rCompare.maTextureSize - && maSdrLFSAttribute == rCompare.maSdrLFSAttribute - && maSdr3DObjectAttribute == rCompare.maSdr3DObjectAttribute); + return (getTransform() == rCompare.getTransform() + && getTextureSize() == rCompare.getTextureSize() + && getSdrLFSAttribute() == rCompare.getSdrLFSAttribute() + && getSdr3DObjectAttribute() == rCompare.getSdr3DObjectAttribute()); } return false; diff --git a/drawinglayer/source/primitive3d/sdrsphereprimitive3d.cxx b/drawinglayer/source/primitive3d/sdrsphereprimitive3d.cxx index 7c299a1215ca..bb01dc7cbfbe 100644 --- a/drawinglayer/source/primitive3d/sdrsphereprimitive3d.cxx +++ b/drawinglayer/source/primitive3d/sdrsphereprimitive3d.cxx @@ -4,9 +4,9 @@ * * $RCSfile: sdrsphereprimitive3d.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: aw $ $Date: 2006-09-27 16:33:18 $ + * last change: $Author: aw $ $Date: 2006-10-19 10:38:34 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -33,38 +33,43 @@ * ************************************************************************/ -#ifndef _DRAWINGLAYER_PRIMITIVE3D_SDRSPHEREPRIMITIVE3D_HXX +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDRSPHEREPRIMITIVE3D_HXX #include <drawinglayer/primitive3d/sdrsphereprimitive3d.hxx> #endif -#ifndef _BGFX_POLYGON_B3DPOLYPOLYGON_HXX -#include <basegfx/polygon/b3dpolypolygon.hxx> -#endif - #ifndef _BGFX_POLYPOLYGON_B3DPOLYGONTOOLS_HXX #include <basegfx/polygon/b3dpolypolygontools.hxx> #endif -#ifndef _DRAWINGLAYER_PRIMITIVE3D_SDRDECOMPOSITIONTOOLS3D_HXX -#include <drawinglayer/primitive3d/sdrdecompositiontools3d.hxx> +#ifndef _BGFX_MATRIX_B2DHOMMATRIX_HXX +#include <basegfx/matrix/b2dhommatrix.hxx> #endif #ifndef _BGFX_POLYGON_B3DPOLYGON_HXX #include <basegfx/polygon/b3dpolygon.hxx> #endif -#ifndef _BGFX_MATRIX_B2DHOMMATRIX_HXX -#include <basegfx/matrix/b2dhommatrix.hxx> +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDRDECOMPOSITIONTOOLS3D_HXX +#include <drawinglayer/primitive3d/sdrdecompositiontools3d.hxx> +#endif + +#ifndef _BGFX_TOOLS_CANVASTOOLS_HXX +#include <basegfx/tools/canvastools.hxx> #endif ////////////////////////////////////////////////////////////////////////////// +using namespace com::sun::star; + +////////////////////////////////////////////////////////////////////////////// + namespace drawinglayer { namespace primitive3d { - void sdrSpherePrimitive3D::decompose(primitiveVector3D& rTarget) + Primitive3DSequence SdrSpherePrimitive3D::createLocalDecomposition(double /*fTime*/) const { + Primitive3DSequence aRetval; const basegfx::B3DRange aUnitRange(0.0, 0.0, 0.0, 1.0, 1.0, 1.0); // add fill @@ -136,7 +141,7 @@ namespace drawinglayer // transform texture coordinates to texture size basegfx::B2DHomMatrix aTexMatrix; - aTexMatrix.scale(maTextureSize.getX(), maTextureSize.getY()); + aTexMatrix.scale(getTextureSize().getX(), getTextureSize().getY()); aFill.transformTextureCoordiantes(aTexMatrix); } @@ -149,60 +154,57 @@ namespace drawinglayer } // create single PolyPolygonFill primitives - add3DPolyPolygonFillPrimitive( - a3DPolyPolygonVector, maTransform, maTextureSize, rTarget, + aRetval = create3DPolyPolygonFillPrimitives( + a3DPolyPolygonVector, getTransform(), getTextureSize(), getSdr3DObjectAttribute(), *getSdrLFSAttribute().getFill(), getSdrLFSAttribute().getFillFloatTransGradient()); } // add line - if(maSdrLFSAttribute.getLine()) + if(getSdrLFSAttribute().getLine()) { basegfx::B3DPolyPolygon aSphere(basegfx::tools::createSpherePolyPolygonFromB3DRange(aUnitRange, getHorizontalSegments(), getVerticalSegments())); - add3DPolyPolygonLinePrimitive(aSphere, maTransform, rTarget, *maSdrLFSAttribute.getLine()); + const Primitive3DSequence aLines(create3DPolyPolygonLinePrimitives(aSphere, getTransform(), *getSdrLFSAttribute().getLine())); + appendPrimitive3DSequenceToPrimitive3DSequence(aRetval, aLines); } // add shadow - if(getSdrLFSAttribute().getShadow()) + if(getSdrLFSAttribute().getShadow() && aRetval.hasElements()) { - addShadowPrimitive3D(rTarget, *getSdrLFSAttribute().getShadow(), getSdr3DObjectAttribute().getShadow3D()); + const Primitive3DSequence aShadow(createShadowPrimitive3D(aRetval, *getSdrLFSAttribute().getShadow(), getSdr3DObjectAttribute().getShadow3D())); + appendPrimitive3DSequenceToPrimitive3DSequence(aRetval, aShadow); } + + return aRetval; } - sdrSpherePrimitive3D::sdrSpherePrimitive3D( + SdrSpherePrimitive3D::SdrSpherePrimitive3D( const basegfx::B3DHomMatrix& rTransform, const basegfx::B2DVector& rTextureSize, - const attribute::sdrLineFillShadowAttribute& rSdrLFSAttribute, - const attribute::sdr3DObjectAttribute& rSdr3DObjectAttribute, - sal_uInt32 nHorizontalSegments, sal_uInt32 nVerticalSegments) - : sdrPrimitive3D(rTransform, rTextureSize, rSdrLFSAttribute, rSdr3DObjectAttribute), + const attribute::SdrLineFillShadowAttribute& rSdrLFSAttribute, + const attribute::Sdr3DObjectAttribute& rSdr3DObjectAttribute, + sal_uInt32 nHorizontalSegments, + sal_uInt32 nVerticalSegments) + : SdrPrimitive3D(rTransform, rTextureSize, rSdrLFSAttribute, rSdr3DObjectAttribute), mnHorizontalSegments(nHorizontalSegments), mnVerticalSegments(nVerticalSegments) { } - sdrSpherePrimitive3D::~sdrSpherePrimitive3D() - { - } - - bool sdrSpherePrimitive3D::operator==(const basePrimitive3D& rPrimitive) const + bool SdrSpherePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const { - if(sdrPrimitive3D::operator==(rPrimitive)) + if(SdrPrimitive3D::operator==(rPrimitive)) { - const sdrSpherePrimitive3D& rCompare = static_cast< const sdrSpherePrimitive3D& >(rPrimitive); - return (mnHorizontalSegments == rCompare.mnHorizontalSegments - && mnVerticalSegments == rCompare.mnVerticalSegments); + const SdrSpherePrimitive3D& rCompare = static_cast< const SdrSpherePrimitive3D& >(rPrimitive); + + return (getHorizontalSegments() == rCompare.getHorizontalSegments() + && getVerticalSegments() == rCompare.getVerticalSegments()); } return false; } - PrimitiveID sdrSpherePrimitive3D::getID() const - { - return CreatePrimitiveID('S', 'S', 'P', '3'); - } - - basegfx::B3DRange sdrSpherePrimitive3D::get3DRange() const + basegfx::B3DRange SdrSpherePrimitive3D::getB3DRange(double /*fTime*/) const { // use defaut from sdrPrimitive3D which uses transformation expanded by line width/2 // The parent implementation which uses the ranges of the decomposition would be more @@ -212,6 +214,11 @@ namespace drawinglayer // has priority here. return getStandard3DRange(); } + + sal_uInt32 SdrSpherePrimitive3D::getPrimitiveID() const + { + return Create3DPrimitiveID('3','S','p','h'); + } } // end of namespace primitive3d } // end of namespace drawinglayer diff --git a/drawinglayer/source/primitive3d/shadowprimitive3d.cxx b/drawinglayer/source/primitive3d/shadowprimitive3d.cxx index f806265eefc2..10ebb54f23a6 100644 --- a/drawinglayer/source/primitive3d/shadowprimitive3d.cxx +++ b/drawinglayer/source/primitive3d/shadowprimitive3d.cxx @@ -4,9 +4,9 @@ * * $RCSfile: shadowprimitive3d.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: aw $ $Date: 2006-08-09 16:51:16 $ + * last change: $Author: aw $ $Date: 2006-10-19 10:38:34 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -33,20 +33,27 @@ * ************************************************************************/ -#ifndef _DRAWINGLAYER_PRIMITIVE3D_SHADOWPRIMITIVE3D_HXX +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SHADOWPRIMITIVE3D_HXX #include <drawinglayer/primitive3d/shadowprimitive3d.hxx> #endif ////////////////////////////////////////////////////////////////////////////// +using namespace com::sun::star; + +////////////////////////////////////////////////////////////////////////////// + namespace drawinglayer { namespace primitive3d { - shadowPrimitive3D::shadowPrimitive3D( - const basegfx::B2DHomMatrix& rShadowTransform, const basegfx::BColor& rShadowColor, - double fShadowTransparence, bool bShadow3D, const primitiveVector3D& rPrimitiveVector) - : vectorPrimitive3D(rPrimitiveVector), + ShadowPrimitive3D::ShadowPrimitive3D( + const basegfx::B2DHomMatrix& rShadowTransform, + const basegfx::BColor& rShadowColor, + double fShadowTransparence, + bool bShadow3D, + const Primitive3DSequence& rChildren) + : GroupPrimitive3D(rChildren), maShadowTransform(rShadowTransform), maShadowColor(rShadowColor), mfShadowTransparence(fShadowTransparence), @@ -54,27 +61,24 @@ namespace drawinglayer { } - shadowPrimitive3D::~shadowPrimitive3D() + bool ShadowPrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const { - } - - bool shadowPrimitive3D::operator==(const basePrimitive3D& rPrimitive) const - { - if(vectorPrimitive3D::operator==(rPrimitive)) + if(GroupPrimitive3D::operator==(rPrimitive)) { - const shadowPrimitive3D& rCompare = (shadowPrimitive3D&)rPrimitive; - return (maShadowTransform == rCompare.maShadowTransform - && maShadowColor == rCompare.maShadowColor - && mfShadowTransparence == rCompare.mfShadowTransparence - && mbShadow3D == rCompare.mbShadow3D); + const ShadowPrimitive3D& rCompare = (ShadowPrimitive3D&)rPrimitive; + + return (getShadowTransform() == rCompare.getShadowTransform() + && getShadowColor() == rCompare.getShadowColor() + && getShadowTransparence() == rCompare.getShadowTransparence() + && getShadow3D() == rCompare.getShadow3D()); } return false; } - PrimitiveID shadowPrimitive3D::getID() const + sal_uInt32 ShadowPrimitive3D::getPrimitiveID() const { - return CreatePrimitiveID('S', 'H', 'D', '3'); + return Create3DPrimitiveID('3','S','h','a'); } } // end of namespace primitive3d } // end of namespace drawinglayer diff --git a/drawinglayer/source/primitive3d/textureprimitive3d.cxx b/drawinglayer/source/primitive3d/textureprimitive3d.cxx index a220c5c76ae4..876765b948d9 100644 --- a/drawinglayer/source/primitive3d/textureprimitive3d.cxx +++ b/drawinglayer/source/primitive3d/textureprimitive3d.cxx @@ -4,9 +4,9 @@ * * $RCSfile: textureprimitive3d.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: aw $ $Date: 2006-08-09 16:51:16 $ + * last change: $Author: aw $ $Date: 2006-10-19 10:38:34 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -33,37 +33,39 @@ * ************************************************************************/ -#ifndef _DRAWINGLAYER_PRIMITIVE3D_TEXTUREPRIMITIVE3D_HXX +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_TEXTUREPRIMITIVE3D_HXX #include <drawinglayer/primitive3d/textureprimitive3d.hxx> #endif ////////////////////////////////////////////////////////////////////////////// +using namespace com::sun::star; + +////////////////////////////////////////////////////////////////////////////// + namespace drawinglayer { namespace primitive3d { - texturePrimitive3D::texturePrimitive3D( - const primitiveVector3D& rPrimitiveVector, + TexturePrimitive3D::TexturePrimitive3D( + const Primitive3DSequence& rChildren, const basegfx::B2DVector& rTextureSize, bool bModulate, bool bFilter) - : vectorPrimitive3D(rPrimitiveVector), + : GroupPrimitive3D(rChildren), maTextureSize(rTextureSize), mbModulate(bModulate), mbFilter(bFilter) { } - texturePrimitive3D::~texturePrimitive3D() - { - } - - bool texturePrimitive3D::operator==(const basePrimitive3D& rPrimitive) const + bool TexturePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const { - if(vectorPrimitive3D::operator==(rPrimitive)) + if(GroupPrimitive3D::operator==(rPrimitive)) { - const texturePrimitive3D& rCompare = (texturePrimitive3D&)rPrimitive; - return (mbModulate == rCompare.mbModulate && mbFilter == rCompare.mbFilter); + const TexturePrimitive3D& rCompare = (TexturePrimitive3D&)rPrimitive; + + return (getModulate() == rCompare.getModulate() + && getFilter() == rCompare.getFilter()); } return false; @@ -77,53 +79,51 @@ namespace drawinglayer { namespace primitive3d { - void simpleTransparenceTexturePrimitive3D::decompose(primitiveVector3D& rTarget) + Primitive3DSequence UnifiedAlphaTexturePrimitive3D::createLocalDecomposition(double /*fTime*/) const { - if(0.0 == mfTransparence) + if(0.0 == getTransparence()) { - // no transparence used, so just add the content - rTarget.insert(rTarget.end(), maPrimitiveVector.begin(), maPrimitiveVector.end()); + // no transparence used, so just use content + return getChildren(); } - else if(mfTransparence > 0.0 && mfTransparence < 1.0) + else if(getTransparence() > 0.0 && getTransparence() < 1.0) { - // create transparenceTexturePrimitive3D with fixed transparence as replacement - const basegfx::BColor aGray(mfTransparence, mfTransparence, mfTransparence); - const attribute::fillGradientAttribute aFillGradient(attribute::GRADIENTSTYLE_LINEAR, 0.0, 0.0, 0.0, 0.0, aGray, aGray, 1); - basePrimitive3D* pNewTransparenceTexturePrimitive3D = new transparenceTexturePrimitive3D(aFillGradient, maPrimitiveVector, maTextureSize); - rTarget.push_back(referencedPrimitive3D(*pNewTransparenceTexturePrimitive3D)); + // create AlphaTexturePrimitive3D with fixed transparence as replacement + const basegfx::BColor aGray(getTransparence(), getTransparence(), getTransparence()); + const attribute::FillGradientAttribute aFillGradient(attribute::GRADIENTSTYLE_LINEAR, 0.0, 0.0, 0.0, 0.0, aGray, aGray, 1); + const Primitive3DReference xRef(new AlphaTexturePrimitive3D(aFillGradient, getChildren(), getTextureSize())); + return Primitive3DSequence(&xRef, 1L); } else { // completely transparent or invalid definition, add nothing + return Primitive3DSequence(); } } - simpleTransparenceTexturePrimitive3D::simpleTransparenceTexturePrimitive3D( + UnifiedAlphaTexturePrimitive3D::UnifiedAlphaTexturePrimitive3D( double fTransparence, - const primitiveVector3D& rPrimitiveVector) - : texturePrimitive3D(rPrimitiveVector, basegfx::B2DVector(), false, false), + const Primitive3DSequence& rChildren) + : TexturePrimitive3D(rChildren, basegfx::B2DVector(), false, false), mfTransparence(fTransparence) { } - simpleTransparenceTexturePrimitive3D::~simpleTransparenceTexturePrimitive3D() + bool UnifiedAlphaTexturePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const { - } - - bool simpleTransparenceTexturePrimitive3D::operator==(const basePrimitive3D& rPrimitive) const - { - if(texturePrimitive3D::operator==(rPrimitive)) + if(TexturePrimitive3D::operator==(rPrimitive)) { - const simpleTransparenceTexturePrimitive3D& rCompare = (simpleTransparenceTexturePrimitive3D&)rPrimitive; - return (mfTransparence == rCompare.mfTransparence); + const UnifiedAlphaTexturePrimitive3D& rCompare = (UnifiedAlphaTexturePrimitive3D&)rPrimitive; + + return (getTransparence() == rCompare.getTransparence()); } return false; } - PrimitiveID simpleTransparenceTexturePrimitive3D::getID() const + sal_uInt32 UnifiedAlphaTexturePrimitive3D::getPrimitiveID() const { - return CreatePrimitiveID('S', 'T', 'X', '3'); + return Create3DPrimitiveID('3','U','A','T'); } } // end of namespace primitive3d } // end of namespace drawinglayer @@ -134,40 +134,37 @@ namespace drawinglayer { namespace primitive3d { - void gradientTexturePrimitive3D::decompose(primitiveVector3D& rTarget) + Primitive3DSequence GradientTexturePrimitive3D::createLocalDecomposition(double /*fTime*/) const { - rTarget.insert(rTarget.end(), maPrimitiveVector.begin(), maPrimitiveVector.end()); + return getChildren(); } - gradientTexturePrimitive3D::gradientTexturePrimitive3D( - const attribute::fillGradientAttribute& rGradient, - const primitiveVector3D& rPrimitiveVector, + GradientTexturePrimitive3D::GradientTexturePrimitive3D( + const attribute::FillGradientAttribute& rGradient, + const Primitive3DSequence& rChildren, const basegfx::B2DVector& rTextureSize, bool bModulate, bool bFilter) - : texturePrimitive3D(rPrimitiveVector, rTextureSize, bModulate, bFilter), + : TexturePrimitive3D(rChildren, rTextureSize, bModulate, bFilter), maGradient(rGradient) { } - gradientTexturePrimitive3D::~gradientTexturePrimitive3D() + bool GradientTexturePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const { - } - - bool gradientTexturePrimitive3D::operator==(const basePrimitive3D& rPrimitive) const - { - if(texturePrimitive3D::operator==(rPrimitive)) + if(TexturePrimitive3D::operator==(rPrimitive)) { - const gradientTexturePrimitive3D& rCompare = (gradientTexturePrimitive3D&)rPrimitive; - return (maGradient == rCompare.maGradient); + const GradientTexturePrimitive3D& rCompare = (GradientTexturePrimitive3D&)rPrimitive; + + return (getGradient() == rCompare.getGradient()); } return false; } - PrimitiveID gradientTexturePrimitive3D::getID() const + sal_uInt32 GradientTexturePrimitive3D::getPrimitiveID() const { - return CreatePrimitiveID('G', 'R', 'X', '3'); + return Create3DPrimitiveID('3','G','T','e'); } } // end of namespace primitive3d } // end of namespace drawinglayer @@ -178,39 +175,36 @@ namespace drawinglayer { namespace primitive3d { - void bitmapTexturePrimitive3D::decompose(primitiveVector3D& rTarget) + Primitive3DSequence BitmapTexturePrimitive3D::createLocalDecomposition(double /*fTime*/) const { - rTarget.insert(rTarget.end(), maPrimitiveVector.begin(), maPrimitiveVector.end()); + return getChildren(); } - bitmapTexturePrimitive3D::bitmapTexturePrimitive3D( - const attribute::fillBitmapAttribute& rBitmap, - const primitiveVector3D& rPrimitiveVector, + BitmapTexturePrimitive3D::BitmapTexturePrimitive3D( + const attribute::FillBitmapAttribute& rBitmap, + const Primitive3DSequence& rChildren, const basegfx::B2DVector& rTextureSize, bool bModulate, bool bFilter) - : texturePrimitive3D(rPrimitiveVector, rTextureSize, bModulate, bFilter), + : TexturePrimitive3D(rChildren, rTextureSize, bModulate, bFilter), maBitmap(rBitmap) { } - bitmapTexturePrimitive3D::~bitmapTexturePrimitive3D() + bool BitmapTexturePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const { - } - - bool bitmapTexturePrimitive3D::operator==(const basePrimitive3D& rPrimitive) const - { - if(texturePrimitive3D::operator==(rPrimitive)) + if(TexturePrimitive3D::operator==(rPrimitive)) { - const bitmapTexturePrimitive3D& rCompare = (bitmapTexturePrimitive3D&)rPrimitive; - return (maBitmap == rCompare.maBitmap); + const BitmapTexturePrimitive3D& rCompare = (BitmapTexturePrimitive3D&)rPrimitive; + + return (getBitmap() == rCompare.getBitmap()); } return false; } - PrimitiveID bitmapTexturePrimitive3D::getID() const + sal_uInt32 BitmapTexturePrimitive3D::getPrimitiveID() const { - return CreatePrimitiveID('B', 'M', 'X', '3'); + return Create3DPrimitiveID('3','B','T','e'); } } // end of namespace primitive3d } // end of namespace drawinglayer @@ -221,26 +215,22 @@ namespace drawinglayer { namespace primitive3d { - transparenceTexturePrimitive3D::transparenceTexturePrimitive3D( - const attribute::fillGradientAttribute& rGradient, - const primitiveVector3D& rPrimitiveVector, + AlphaTexturePrimitive3D::AlphaTexturePrimitive3D( + const attribute::FillGradientAttribute& rGradient, + const Primitive3DSequence& rChildren, const basegfx::B2DVector& rTextureSize) - : gradientTexturePrimitive3D(rGradient, rPrimitiveVector, rTextureSize, false, false) - { - } - - transparenceTexturePrimitive3D::~transparenceTexturePrimitive3D() + : GradientTexturePrimitive3D(rGradient, rChildren, rTextureSize, false, false) { } - bool transparenceTexturePrimitive3D::operator==(const basePrimitive3D& rPrimitive) const + bool AlphaTexturePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const { - return (gradientTexturePrimitive3D::operator==(rPrimitive)); + return (GradientTexturePrimitive3D::operator==(rPrimitive)); } - PrimitiveID transparenceTexturePrimitive3D::getID() const + sal_uInt32 AlphaTexturePrimitive3D::getPrimitiveID() const { - return CreatePrimitiveID('T', 'R', 'X', '3'); + return Create3DPrimitiveID('3','A','T','e'); } } // end of namespace primitive3d } // end of namespace drawinglayer diff --git a/drawinglayer/source/primitive3d/transformprimitive3d.cxx b/drawinglayer/source/primitive3d/transformprimitive3d.cxx index 22fafbcac2b2..80a2635b6061 100644 --- a/drawinglayer/source/primitive3d/transformprimitive3d.cxx +++ b/drawinglayer/source/primitive3d/transformprimitive3d.cxx @@ -4,9 +4,9 @@ * * $RCSfile: transformprimitive3d.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: aw $ $Date: 2006-08-09 16:51:16 $ + * last change: $Author: aw $ $Date: 2006-10-19 10:38:34 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -33,47 +33,54 @@ * ************************************************************************/ -#ifndef _DRAWINGLAYER_PRIMITIVE3D_TRANSFORMPRIMITIVE3D_HXX +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_TRANSFORMPRIMITIVE3D_HXX #include <drawinglayer/primitive3d/transformprimitive3d.hxx> #endif +#ifndef _BGFX_TOOLS_CANVASTOOLS_HXX +#include <basegfx/tools/canvastools.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// + +using namespace com::sun::star; + ////////////////////////////////////////////////////////////////////////////// namespace drawinglayer { namespace primitive3d { - transformPrimitive3D::transformPrimitive3D(const basegfx::B3DHomMatrix& rTransformation, const primitiveVector3D& rPrimitiveVector) - : vectorPrimitive3D(rPrimitiveVector), + TransformPrimitive3D::TransformPrimitive3D( + const basegfx::B3DHomMatrix& rTransformation, + const Primitive3DSequence& rChildren) + : GroupPrimitive3D(rChildren), maTransformation(rTransformation) { } - transformPrimitive3D::~transformPrimitive3D() + bool TransformPrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const { - } - - bool transformPrimitive3D::operator==(const basePrimitive3D& rPrimitive) const - { - if(vectorPrimitive3D::operator==(rPrimitive)) + if(GroupPrimitive3D::operator==(rPrimitive)) { - const transformPrimitive3D& rCompare = static_cast< const transformPrimitive3D& >(rPrimitive); - return (maTransformation == rCompare.maTransformation); + const TransformPrimitive3D& rCompare = static_cast< const TransformPrimitive3D& >(rPrimitive); + + return (getTransformation() == rCompare.getTransformation()); } return false; } - PrimitiveID transformPrimitive3D::getID() const + basegfx::B3DRange TransformPrimitive3D::getB3DRange(double fTime) const { - return CreatePrimitiveID('T', 'R', 'N', '3'); + basegfx::B3DRange aRetval(getB3DRangeFromPrimitive3DSequence(getChildren(), fTime)); + aRetval.transform(getTransformation()); + return aRetval; } - basegfx::B3DRange transformPrimitive3D::get3DRange() const + sal_uInt32 TransformPrimitive3D::getPrimitiveID() const { - basegfx::B3DRange aRetval(get3DRangeFromVector(maPrimitiveVector)); - aRetval.transform(maTransformation); - return aRetval; + return Create3DPrimitiveID('3','T','r','a'); } } // end of namespace primitive3d } // end of namespace drawinglayer diff --git a/drawinglayer/source/processor2d/baseprocessor2d.cxx b/drawinglayer/source/processor2d/baseprocessor2d.cxx new file mode 100644 index 000000000000..e68d2870a315 --- /dev/null +++ b/drawinglayer/source/processor2d/baseprocessor2d.cxx @@ -0,0 +1,82 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: baseprocessor2d.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-10-19 10:35:37 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef INCLUDED_DRAWINGLAYER_PROCESSOR2D_BASEPROCESSOR2D_HXX +#include <drawinglayer/processor2d/baseprocessor2d.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// + +using namespace com::sun::star; + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace processor2d + { + BaseProcessor2D::BaseProcessor2D(const geometry::ViewInformation2D& rViewInformation) + : maViewInformation2D(rViewInformation) + { + } + + BaseProcessor2D::~BaseProcessor2D() + { + } + } // end of namespace processor2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace processor2d + { + CollectingProcessor2D::CollectingProcessor2D(const geometry::ViewInformation2D& rViewInformation) + : BaseProcessor2D(rViewInformation), + maPrimitiveSequence() + { + } + + void CollectingProcessor2D::process(const primitive2d::Primitive2DSequence& rSource) + { + // accept everything + primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(maPrimitiveSequence, rSource); + } + } // end of namespace processor2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/processor2d/makefile.mk b/drawinglayer/source/processor2d/makefile.mk new file mode 100644 index 000000000000..ac668486e739 --- /dev/null +++ b/drawinglayer/source/processor2d/makefile.mk @@ -0,0 +1,54 @@ +#************************************************************************* +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1 $ +# +# last change: $Author: aw $ $Date: 2006-10-19 10:35:37 $ +# +# The Contents of this file are made available subject to +# the terms of GNU Lesser General Public License Version 2.1. +# +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2005 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +#************************************************************************* + +PRJ=..$/.. +PRJNAME=drawinglayer +TARGET=processor2d +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ---------------------------------- + +.INCLUDE : settings.mk + +# --- Files ------------------------------------- + +SLOFILES= \ + $(SLO)$/animatedextractor2d.obj \ + $(SLO)$/baseprocessor2d.obj \ + $(SLO)$/vclprocessor2d.obj + +# --- Targets ---------------------------------- + +.INCLUDE : target.mk diff --git a/drawinglayer/source/processor2d/vclprocessor2d.cxx b/drawinglayer/source/processor2d/vclprocessor2d.cxx new file mode 100644 index 000000000000..b45f0146f99b --- /dev/null +++ b/drawinglayer/source/processor2d/vclprocessor2d.cxx @@ -0,0 +1,1718 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: vclprocessor2d.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-10-19 10:35:37 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef INCLUDED_DRAWINGLAYER_PROCESSOR2D_VCLPROCESSOR2D_HXX +#include <drawinglayer/processor2d/vclprocessor2d.hxx> +#endif + +#ifndef _SV_OUTDEV_HXX +#include <vcl/outdev.hxx> +#endif + +#ifndef _BGFX_POLYGON_B2DPOLYGON_HXX +#include <basegfx/polygon/b2dpolygon.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_ATTRIBUTE_FILLATTRIBUTE_HXX +#include <drawinglayer/attribute/fillattribute.hxx> +#endif + +#ifndef _BGFX_POLYPOLYGON_B2DPOLYGONTOOLS_HXX +#include <basegfx/polygon/b2dpolypolygontools.hxx> +#endif + +#ifndef _BGFX_POLYGON_B2DPOLYGONTOOLS_HXX +#include <basegfx/polygon/b2dpolygontools.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_TEXTURE_TEXTURE_HXX +#include <drawinglayer/texture/texture.hxx> +#endif + +#ifndef _SV_BMPACC_HXX +#include <vcl/bmpacc.hxx> +#endif + +#ifndef _SV_BITMAPEX_HXX +#include <vcl/bitmapex.hxx> +#endif + +#ifndef _SV_VIRDEV_HXX +#include <vcl/virdev.hxx> +#endif + +#ifndef _GRFMGR_HXX +#include <goodies/grfmgr.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE_TEXTPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/textprimitive2d.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_POLYGONPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/polygonprimitive2d.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_BITMAPPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/bitmapprimitive2d.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_ATTRIBUTE_SDRFILLBITMAPATTRIBUTE_HXX +#include <drawinglayer/attribute/sdrfillbitmapattribute.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_FILLBITMAPPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/fillbitmapprimitive2d.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_POLYPOLYGONPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_METAFILEPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/metafileprimitive2d.hxx> +#endif + +#ifndef _BGFX_TOOLS_CANVASTOOLS_HXX +#include <basegfx/tools/canvastools.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_MASKPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/maskprimitive2d.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_ALPHAPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/alphaprimitive2d.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_TRANSFORMPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/transformprimitive2d.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_MARKERPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/markerprimitive2d.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// + +using namespace com::sun::star; + +////////////////////////////////////////////////////////////////////////////// +// support methods for vcl direct gradeint renderering + +namespace drawinglayer +{ + namespace + { + sal_uInt32 impCalcGradientSteps(OutputDevice& rOutDev, sal_uInt32 nSteps, const basegfx::B2DRange& rRange, sal_uInt32 nMaxDist) + { + if(nSteps == 0L) + { + const Size aSize(rOutDev.LogicToPixel(Size(basegfx::fround(rRange.getWidth()), basegfx::fround(rRange.getHeight())))); + nSteps = (aSize.getWidth() + aSize.getHeight()) >> 3L; + } + + if(nSteps < 2L) + { + nSteps = 2L; + } + + if(nSteps > nMaxDist) + { + nSteps = nMaxDist; + } + + return nSteps; + } + + void impDrawGradientToOutDevSimple( + OutputDevice& rOutDev, + const basegfx::B2DPolyPolygon& rTargetForm, + const ::std::vector< basegfx::B2DHomMatrix >& rMatrices, + const ::std::vector< basegfx::BColor >& rColors, + const basegfx::B2DPolygon& rUnitPolygon) + { + rOutDev.SetLineColor(); + + for(sal_uInt32 a(0L); a < rColors.size(); a++) + { + // set correct color + const basegfx::BColor aFillColor(rColors[a]); + rOutDev.SetFillColor(Color(aFillColor)); + + if(a) + { + if(a - 1L < rMatrices.size()) + { + basegfx::B2DPolygon aNewPoly(rUnitPolygon); + aNewPoly.transform(rMatrices[a - 1L]); + rOutDev.DrawPolygon(Polygon(aNewPoly)); + } + } + else + { + rOutDev.DrawPolyPolygon(PolyPolygon(rTargetForm)); + } + } + } + + void impDrawGradientToOutDevComplex( + OutputDevice& rOutDev, + const basegfx::B2DPolyPolygon& rTargetForm, + const ::std::vector< basegfx::B2DHomMatrix >& rMatrices, + const ::std::vector< basegfx::BColor >& rColors, + const basegfx::B2DPolygon& rUnitPolygon) + { + PolyPolygon aVclTargetForm(rTargetForm); + ::std::vector< Polygon > aVclPolygons; + sal_uInt32 a; + + // remember and set to XOR + rOutDev.SetLineColor(); + rOutDev.Push(PUSH_RASTEROP); + rOutDev.SetRasterOp(ROP_XOR); + + // draw gradient PolyPolygons + for(a = 0L; a < rMatrices.size(); a++) + { + // create polygon and remember + basegfx::B2DPolygon aNewPoly(rUnitPolygon); + aNewPoly.transform(rMatrices[a]); + aVclPolygons.push_back(Polygon(aNewPoly)); + + // set correct color + if(rColors.size() > a) + { + const basegfx::BColor aFillColor(rColors[a]); + rOutDev.SetFillColor(Color(aFillColor)); + } + + // create vcl PolyPolygon and draw it + if(a) + { + PolyPolygon aVclPolyPoly(aVclPolygons[a - 1L]); + aVclPolyPoly.Insert(aVclPolygons[a]); + rOutDev.DrawPolyPolygon(aVclPolyPoly); + } + else + { + PolyPolygon aVclPolyPoly(aVclTargetForm); + aVclPolyPoly.Insert(aVclPolygons[0L]); + rOutDev.DrawPolyPolygon(aVclPolyPoly); + } + } + + // draw last poly in last color + if(rColors.size()) + { + const basegfx::BColor aFillColor(rColors[rColors.size() - 1L]); + rOutDev.SetFillColor(Color(aFillColor)); + rOutDev.DrawPolygon(aVclPolygons[aVclPolygons.size() - 1L]); + } + + // draw object form in black and go back to XOR + rOutDev.SetFillColor(COL_BLACK); + rOutDev.SetRasterOp(ROP_0); + rOutDev.DrawPolyPolygon(aVclTargetForm); + rOutDev.SetRasterOp(ROP_XOR); + + // draw gradient PolyPolygons again + for(a = 0L; a < rMatrices.size(); a++) + { + // set correct color + if(rColors.size() > a) + { + const basegfx::BColor aFillColor(rColors[a]); + rOutDev.SetFillColor(Color(aFillColor)); + } + + // create vcl PolyPolygon and draw it + if(a) + { + PolyPolygon aVclPolyPoly(aVclPolygons[a - 1L]); + aVclPolyPoly.Insert(aVclPolygons[a]); + rOutDev.DrawPolyPolygon(aVclPolyPoly); + } + else + { + PolyPolygon aVclPolyPoly(aVclTargetForm); + aVclPolyPoly.Insert(aVclPolygons[0L]); + rOutDev.DrawPolyPolygon(aVclPolyPoly); + } + } + + // draw last poly in last color + if(rColors.size()) + { + const basegfx::BColor aFillColor(rColors[rColors.size() - 1L]); + rOutDev.SetFillColor(Color(aFillColor)); + rOutDev.DrawPolygon(aVclPolygons[aVclPolygons.size() - 1L]); + } + + // reset drawmode + rOutDev.Pop(); + } + + void impDrawGradientToOutDev( + OutputDevice& rOutDev, + const basegfx::B2DPolyPolygon& rTargetForm, + attribute::GradientStyle eGradientStyle, + sal_uInt32 nSteps, + const basegfx::BColor& rStart, + const basegfx::BColor& rEnd, + double fBorder, double fAngle, double fOffsetX, double fOffsetY, bool bSimple) + { + const basegfx::B2DRange aOutlineRange(basegfx::tools::getRange(rTargetForm)); + ::std::vector< basegfx::B2DHomMatrix > aMatrices; + ::std::vector< basegfx::BColor > aColors; + basegfx::B2DPolygon aUnitPolygon; + + if(attribute::GRADIENTSTYLE_RADIAL == eGradientStyle || attribute::GRADIENTSTYLE_ELLIPTICAL == eGradientStyle) + { + const basegfx::B2DPoint aCircleCenter(0.5, 0.5); + aUnitPolygon = basegfx::tools::createPolygonFromEllipse(aCircleCenter, 0.5, 0.5); + // aUnitPolygon = basegfx::tools::adaptiveSubdivideByAngle(aUnitPolygon); + } + else + { + aUnitPolygon = basegfx::tools::createPolygonFromRect(basegfx::B2DRange(0.0, 0.0, 1.0, 1.0)); + } + + // make sure steps is not too high/low + nSteps = impCalcGradientSteps(rOutDev, nSteps, aOutlineRange, sal_uInt32((rStart.getMaximumDistance(rEnd) * 127.5) + 0.5)); + + // create geometries + switch(eGradientStyle) + { + case attribute::GRADIENTSTYLE_LINEAR: + { + texture::GeoTexSvxGradientLinear aGradient(aOutlineRange, rStart, rEnd, nSteps, fBorder, fAngle); + aGradient.appendTransformations(aMatrices); + aGradient.appendColors(aColors); + break; + } + case attribute::GRADIENTSTYLE_AXIAL: + { + texture::GeoTexSvxGradientAxial aGradient(aOutlineRange, rStart, rEnd, nSteps, fBorder, fAngle); + aGradient.appendTransformations(aMatrices); + aGradient.appendColors(aColors); + break; + } + case attribute::GRADIENTSTYLE_RADIAL: + { + texture::GeoTexSvxGradientRadial aGradient(aOutlineRange, rStart, rEnd, nSteps, fBorder, fOffsetX, fOffsetY); + aGradient.appendTransformations(aMatrices); + aGradient.appendColors(aColors); + break; + } + case attribute::GRADIENTSTYLE_ELLIPTICAL: + { + texture::GeoTexSvxGradientElliptical aGradient(aOutlineRange, rStart, rEnd, nSteps, fBorder, fOffsetX, fOffsetX, fAngle); + aGradient.appendTransformations(aMatrices); + aGradient.appendColors(aColors); + break; + } + case attribute::GRADIENTSTYLE_SQUARE: + { + texture::GeoTexSvxGradientSquare aGradient(aOutlineRange, rStart, rEnd, nSteps, fBorder, fOffsetX, fOffsetX, fAngle); + aGradient.appendTransformations(aMatrices); + aGradient.appendColors(aColors); + break; + } + case attribute::GRADIENTSTYLE_RECT: + { + texture::GeoTexSvxGradientRect aGradient(aOutlineRange, rStart, rEnd, nSteps, fBorder, fOffsetX, fOffsetX, fAngle); + aGradient.appendTransformations(aMatrices); + aGradient.appendColors(aColors); + break; + } + } + + // paint them with mask using the XOR method + if(aMatrices.size()) + { + if(bSimple) + { + impDrawGradientToOutDevSimple(rOutDev, rTargetForm, aMatrices, aColors, aUnitPolygon); + } + else + { + impDrawGradientToOutDevComplex(rOutDev, rTargetForm, aMatrices, aColors, aUnitPolygon); + } + } + } + } // end of anonymous namespace +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// support for rendering Bitmap and BitmapEx contents + +namespace drawinglayer +{ + namespace + { + void impSmoothPoint(BitmapColor& rValue, const basegfx::B2DPoint& rSource, sal_Int32 nIntX, sal_Int32 nIntY, BitmapReadAccess& rRead) + { + double fDeltaX(rSource.getX() - nIntX); + double fDeltaY(rSource.getY() - nIntY); + sal_Int32 nIndX(0L); + sal_Int32 nIndY(0L); + + if(fDeltaX > 0.0 && nIntX + 1L < rRead.Width()) + { + nIndX++; + } + else if(fDeltaX < 0.0 && nIntX >= 1L) + { + fDeltaX = -fDeltaX; + nIndX--; + } + + if(fDeltaY > 0.0 && nIntY + 1L < rRead.Height()) + { + nIndY++; + } + else if(fDeltaY < 0.0 && nIntY >= 1L) + { + fDeltaY = -fDeltaY; + nIndY--; + } + + if(nIndX || nIndY) + { + const double fColorToReal(1.0 / 255.0); + double fR(rValue.GetRed() * fColorToReal); + double fG(rValue.GetGreen() * fColorToReal); + double fB(rValue.GetBlue() * fColorToReal); + double fRBottom(0.0), fGBottom(0.0), fBBottom(0.0); + + if(nIndX) + { + const double fMulA(fDeltaX * fColorToReal); + double fMulB(1.0 - fDeltaX); + const BitmapColor aTopPartner(rRead.GetColor(nIntY, nIntX + nIndX)); + + fR = (fR * fMulB) + (aTopPartner.GetRed() * fMulA); + fG = (fG * fMulB) + (aTopPartner.GetGreen() * fMulA); + fB = (fB * fMulB) + (aTopPartner.GetBlue() * fMulA); + + if(nIndY) + { + fMulB *= fColorToReal; + const BitmapColor aBottom(rRead.GetColor(nIntY + nIndY, nIntX)); + const BitmapColor aBottomPartner(rRead.GetColor(nIntY + nIndY, nIntX + nIndX)); + + fRBottom = (aBottom.GetRed() * fMulB) + (aBottomPartner.GetRed() * fMulA); + fGBottom = (aBottom.GetGreen() * fMulB) + (aBottomPartner.GetGreen() * fMulA); + fBBottom = (aBottom.GetBlue() * fMulB) + (aBottomPartner.GetBlue() * fMulA); + } + } + + if(nIndY) + { + if(!nIndX) + { + const BitmapColor aBottom(rRead.GetColor(nIntY + nIndY, nIntX)); + + fRBottom = aBottom.GetRed() * fColorToReal; + fGBottom = aBottom.GetGreen() * fColorToReal; + fBBottom = aBottom.GetBlue() * fColorToReal; + } + + const double fMulB(1.0 - fDeltaY); + + fR = (fR * fMulB) + (fRBottom * fDeltaY); + fG = (fG * fMulB) + (fGBottom * fDeltaY); + fB = (fB * fMulB) + (fBBottom * fDeltaY); + } + + rValue.SetRed((sal_uInt8)(fR * 255.0)); + rValue.SetGreen((sal_uInt8)(fG * 255.0)); + rValue.SetBlue((sal_uInt8)(fB * 255.0)); + } + } + + void impSmoothIndex(BitmapColor& rValue, const basegfx::B2DPoint& rSource, sal_Int32 nIntX, sal_Int32 nIntY, BitmapReadAccess& rRead) + { + double fDeltaX(rSource.getX() - nIntX); + double fDeltaY(rSource.getY() - nIntY); + sal_Int32 nIndX(0L); + sal_Int32 nIndY(0L); + + if(fDeltaX > 0.0 && nIntX + 1L < rRead.Width()) + { + nIndX++; + } + else if(fDeltaX < 0.0 && nIntX >= 1L) + { + fDeltaX = -fDeltaX; + nIndX--; + } + + if(fDeltaY > 0.0 && nIntY + 1L < rRead.Height()) + { + nIndY++; + } + else if(fDeltaY < 0.0 && nIntY >= 1L) + { + fDeltaY = -fDeltaY; + nIndY--; + } + + if(nIndX || nIndY) + { + const double fColorToReal(1.0 / 255.0); + double fVal(rValue.GetIndex() * fColorToReal); + double fValBottom(0.0); + + if(nIndX) + { + const double fMulA(fDeltaX * fColorToReal); + double fMulB(1.0 - fDeltaX); + const BitmapColor aTopPartner(rRead.GetPixel(nIntY, nIntX + nIndX)); + + fVal = (fVal * fMulB) + (aTopPartner.GetIndex() * fMulA); + + if(nIndY) + { + fMulB *= fColorToReal; + const BitmapColor aBottom(rRead.GetPixel(nIntY + nIndY, nIntX)); + const BitmapColor aBottomPartner(rRead.GetPixel(nIntY + nIndY, nIntX + nIndX)); + + fValBottom = (aBottom.GetIndex() * fMulB) + (aBottomPartner.GetIndex() * fMulA); + } + } + + if(nIndY) + { + if(!nIndX) + { + const BitmapColor aBottom(rRead.GetPixel(nIntY + nIndY, nIntX)); + + fValBottom = aBottom.GetIndex() * fColorToReal; + } + + const double fMulB(1.0 - fDeltaY); + + fVal = (fVal * fMulB) + (fValBottom * fDeltaY); + } + + rValue.SetIndex((sal_uInt8)(fVal * 255.0)); + } + } + + void impTransformBitmap(const Bitmap& rSource, Bitmap& rDestination, const basegfx::B2DHomMatrix& rTransform, bool bSmooth) + { + BitmapWriteAccess* pWrite = rDestination.AcquireWriteAccess(); + + if(pWrite) + { + const Size aContentSizePixel(rSource.GetSizePixel()); + BitmapReadAccess* pRead = (const_cast< Bitmap& >(rSource)).AcquireReadAccess(); + + if(pRead) + { + const Size aDestinationSizePixel(rDestination.GetSizePixel()); + bool bWorkWithIndex(rDestination.GetBitCount() <= 8); + BitmapColor aOutside(pRead->GetBestMatchingColor(BitmapColor(0xff, 0xff, 0xff))); + + for(sal_Int32 y(0L); y < aDestinationSizePixel.getHeight(); y++) + { + for(sal_Int32 x(0L); x < aDestinationSizePixel.getWidth(); x++) + { + const basegfx::B2DPoint aSourceCoor(rTransform * basegfx::B2DPoint(x, y)); + const sal_Int32 nIntX(basegfx::fround(aSourceCoor.getX())); + + if(nIntX >= 0L && nIntX < aContentSizePixel.getWidth()) + { + const sal_Int32 nIntY(basegfx::fround(aSourceCoor.getY())); + + if(nIntY >= 0L && nIntY < aContentSizePixel.getHeight()) + { + if(bWorkWithIndex) + { + BitmapColor aValue(pRead->GetPixel(nIntY, nIntX)); + + if(bSmooth) + { + impSmoothIndex(aValue, aSourceCoor, nIntX, nIntY, *pRead); + } + + pWrite->SetPixel(y, x, aValue); + } + else + { + BitmapColor aValue(pRead->GetColor(nIntY, nIntX)); + + if(bSmooth) + { + impSmoothPoint(aValue, aSourceCoor, nIntX, nIntY, *pRead); + } + + pWrite->SetPixel(y, x, aValue.IsIndex() ? aValue : pWrite->GetBestMatchingColor(aValue)); + } + + continue; + } + } + + // here are outside pixels. Complete mask + if(bWorkWithIndex) + { + pWrite->SetPixel(y, x, aOutside); + } + } + } + + delete pRead; + } + + delete pWrite; + } + } + + Bitmap impCreateEmptyBitmapWithPattern(const Bitmap& rSource, const Size& aTargetSizePixel) + { + Bitmap aRetval; + BitmapReadAccess* pReadAccess = (const_cast< Bitmap& >(rSource)).AcquireReadAccess(); + + if(pReadAccess) + { + if(rSource.GetBitCount() <= 8) + { + BitmapPalette aPalette(pReadAccess->GetPalette()); + aRetval = Bitmap(aTargetSizePixel, rSource.GetBitCount(), &aPalette); + } + else + { + aRetval = Bitmap(aTargetSizePixel, rSource.GetBitCount()); + } + + delete pReadAccess; + } + + return aRetval; + } + + BitmapEx impTransformBitmapEx(const BitmapEx& rSource, const Rectangle &rCroppedRectPixel, const basegfx::B2DHomMatrix& rTransform) + { + // force destination to 24 bit, we want to smooth output + const Size aDestinationSize(rCroppedRectPixel.GetSize()); + Bitmap aDestination(impCreateEmptyBitmapWithPattern(rSource.GetBitmap(), aDestinationSize)); + static bool bDoSmoothAtAll(true); + impTransformBitmap(rSource.GetBitmap(), aDestination, rTransform, bDoSmoothAtAll); + + // create mask + if(rSource.IsTransparent()) + { + if(rSource.IsAlpha()) + { + Bitmap aAlpha(impCreateEmptyBitmapWithPattern(rSource.GetAlpha().GetBitmap(), aDestinationSize)); + impTransformBitmap(rSource.GetAlpha().GetBitmap(), aAlpha, rTransform, bDoSmoothAtAll); + return BitmapEx(aDestination, AlphaMask(aAlpha)); + } + else + { + Bitmap aMask(impCreateEmptyBitmapWithPattern(rSource.GetMask(), aDestinationSize)); + impTransformBitmap(rSource.GetMask(), aMask, rTransform, false); + return BitmapEx(aDestination, aMask); + } + } + + return BitmapEx(aDestination); + } + + } // end of anonymous namespace +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// support class for OutputDevice output with mask + +namespace drawinglayer +{ + namespace + { + class impBufferDevice + { + OutputDevice& mrOutDev; + VirtualDevice maContent; + VirtualDevice* mpMask; + VirtualDevice* mpAlpha; + Rectangle maDestPixel; + + public: + impBufferDevice(OutputDevice& rOutDev, const basegfx::B2DRange& rRange); + ~impBufferDevice(); + + void paint(double fTrans = 0.0); + bool isVisible() const { return !maDestPixel.IsEmpty(); } + VirtualDevice& getContent() { return maContent; } + VirtualDevice& getMask(); + VirtualDevice& getAlpha(); + }; + + impBufferDevice::impBufferDevice(OutputDevice& rOutDev, const basegfx::B2DRange& rRange) + : mrOutDev(rOutDev), + maContent(rOutDev), + mpMask(0L), + mpAlpha(0L) + { + const Rectangle aRectLogic( + (sal_Int32)floor(rRange.getMinX()), (sal_Int32)floor(rRange.getMinY()), + (sal_Int32)floor(rRange.getMaxX()) + 1L, (sal_Int32)floor(rRange.getMaxY()) + 1L); + const Rectangle aRectPixel(rOutDev.LogicToPixel(aRectLogic)); + const Point aEmptyPoint; + maDestPixel = Rectangle(aEmptyPoint, rOutDev.GetOutputSizePixel()); + maDestPixel.Intersection(aRectPixel); + + if(isVisible()) + { + maContent.SetOutputSizePixel(maDestPixel.GetSize(), false); + + const bool bWasEnabledSrc(rOutDev.IsMapModeEnabled()); + rOutDev.EnableMapMode(false); + maContent.DrawOutDev(aEmptyPoint, maDestPixel.GetSize(), maDestPixel.TopLeft(), maDestPixel.GetSize(), rOutDev); + rOutDev.EnableMapMode(bWasEnabledSrc); + + MapMode aNewMapMode(rOutDev.GetMapMode()); + const Point aLogicTopLeft(rOutDev.PixelToLogic(maDestPixel.TopLeft())); + aNewMapMode.SetOrigin(Point(-aLogicTopLeft.X(), -aLogicTopLeft.Y())); + + maContent.SetMapMode(aNewMapMode); + } + } + + impBufferDevice::~impBufferDevice() + { + delete mpMask; + delete mpAlpha; + } + + void impBufferDevice::paint(double fTrans) + { + const Point aEmptyPoint; + const Size aSizePixel(maContent.GetOutputSizePixel()); + const bool bWasEnabledDst(mrOutDev.IsMapModeEnabled()); + + mrOutDev.EnableMapMode(false); + maContent.EnableMapMode(false); + Bitmap aContent(maContent.GetBitmap(aEmptyPoint, aSizePixel)); + + if(mpAlpha) + { + mpAlpha->EnableMapMode(false); + AlphaMask aAlphaMask(mpAlpha->GetBitmap(aEmptyPoint, aSizePixel)); + mrOutDev.DrawBitmapEx(maDestPixel.TopLeft(), BitmapEx(aContent, aAlphaMask)); + } + else if(mpMask) + { + mpMask->EnableMapMode(false); + Bitmap aMask(mpMask->GetBitmap(aEmptyPoint, aSizePixel)); + mrOutDev.DrawBitmapEx(maDestPixel.TopLeft(), BitmapEx(aContent, aMask)); + } + else if(0.0 != fTrans) + { + sal_uInt8 nMaskValue((sal_uInt8)basegfx::fround(fTrans * 255.0)); + AlphaMask aAlphaMask(aSizePixel, &nMaskValue); + mrOutDev.DrawBitmapEx(maDestPixel.TopLeft(), BitmapEx(aContent, aAlphaMask)); + } + else + { + mrOutDev.DrawBitmap(maDestPixel.TopLeft(), aContent); + } + + mrOutDev.EnableMapMode(bWasEnabledDst); + } + + VirtualDevice& impBufferDevice::getMask() + { + if(!mpMask) + { + mpMask = new VirtualDevice(mrOutDev, 1); + mpMask->SetOutputSizePixel(maDestPixel.GetSize(), true); + mpMask->SetMapMode(maContent.GetMapMode()); + } + + return *mpMask; + } + + VirtualDevice& impBufferDevice::getAlpha() + { + if(!mpAlpha) + { + mpAlpha = new VirtualDevice(); + mpAlpha->SetOutputSizePixel(maDestPixel.GetSize(), true); + mpAlpha->SetMapMode(maContent.GetMapMode()); + } + + return *mpAlpha; + } + } // end of anonymous namespace +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// support for different kinds of bitmap rendering using vcl + +namespace drawinglayer +{ + namespace + { + void RenderBitmapPrimitive2D_GraphicManager(OutputDevice& rOutDev, const BitmapEx& rBitmapEx, const basegfx::B2DHomMatrix& rTransform) + { + // prepare attributes + GraphicAttr aAttributes; + + // decompose matrix to check for shear, rotate and mirroring + basegfx::B2DVector aScale, aTranslate; + double fRotate, fShearX; + rTransform.decompose(aScale, aTranslate, fRotate, fShearX); + + // mirror flags + aAttributes.SetMirrorFlags( + (basegfx::fTools::less(aScale.getX(), 0.0) ? BMP_MIRROR_HORZ : 0)| + (basegfx::fTools::less(aScale.getY(), 0.0) ? BMP_MIRROR_VERT : 0)); + + // rotation + if(!basegfx::fTools::equalZero(fRotate)) + { + double fRotation(fmod(3600.0 - (fRotate * (10.0 / F_PI180)), 3600.0)); + aAttributes.SetRotation((sal_uInt16)(fRotation)); + } + + // prepare Bitmap + basegfx::B2DRange aOutlineRange(0.0, 0.0, 1.0, 1.0); + + if(basegfx::fTools::equalZero(fRotate)) + { + aOutlineRange.transform(rTransform); + } + else + { + // if rotated, create the unrotated output rectangle for the GraphicManager paint + basegfx::B2DHomMatrix aSimpleObjectMatrix; + + aSimpleObjectMatrix.scale(fabs(aScale.getX()), fabs(aScale.getY())); + aSimpleObjectMatrix.translate(aTranslate.getX(), aTranslate.getY()); + + aOutlineRange.transform(aSimpleObjectMatrix); + } + + // prepare dest coor + const Rectangle aDestRectPixel( + basegfx::fround(aOutlineRange.getMinX()), basegfx::fround(aOutlineRange.getMinY()), + basegfx::fround(aOutlineRange.getMaxX()), basegfx::fround(aOutlineRange.getMaxY())); + + // paint it using GraphicManager + Graphic aGraphic(rBitmapEx); + GraphicObject aGraphicObject(aGraphic); + aGraphicObject.Draw(&rOutDev, aDestRectPixel.TopLeft(), aDestRectPixel.GetSize(), &aAttributes); + } + + void RenderBitmapPrimitive2D_BitmapEx(OutputDevice& rOutDev, const BitmapEx& rBitmapEx, const basegfx::B2DHomMatrix& rTransform) + { + // only translate and scale, use vcl's DrawBitmapEx(). + BitmapEx aContent(rBitmapEx); + + // prepare dest coor. Necessary to expand since vcl's DrawBitmapEx draws one pix less + basegfx::B2DRange aOutlineRange(0.0, 0.0, 1.0, 1.0); + aOutlineRange.transform(rTransform); + const Rectangle aDestRectPixel( + basegfx::fround(aOutlineRange.getMinX()), basegfx::fround(aOutlineRange.getMinY()), + basegfx::fround(aOutlineRange.getMaxX()), basegfx::fround(aOutlineRange.getMaxY())); + + // decompose matrix to check for shear, rotate and mirroring + basegfx::B2DVector aScale, aTranslate; + double fRotate, fShearX; + rTransform.decompose(aScale, aTranslate, fRotate, fShearX); + + // Check mirroring. + sal_uInt32 nMirrorFlags(BMP_MIRROR_NONE); + + if(basegfx::fTools::less(aScale.getX(), 0.0)) + { + nMirrorFlags |= BMP_MIRROR_HORZ; + } + + if(basegfx::fTools::less(aScale.getY(), 0.0)) + { + nMirrorFlags |= BMP_MIRROR_VERT; + } + + if(BMP_MIRROR_NONE != nMirrorFlags) + { + aContent.Mirror(nMirrorFlags); + } + + // draw bitmap + rOutDev.DrawBitmapEx(aDestRectPixel.TopLeft(), aDestRectPixel.GetSize(), aContent); + } + + void RenderBitmapPrimitive2D_self(OutputDevice& rOutDev, const BitmapEx& rBitmapEx, const basegfx::B2DHomMatrix& rTransform) + { + // process self with free transformation (containing shear and rotate). Get dest rect in pixels. + basegfx::B2DRange aOutlineRange(0.0, 0.0, 1.0, 1.0); + aOutlineRange.transform(rTransform); + const Rectangle aDestRectLogic( + basegfx::fround(aOutlineRange.getMinX()), basegfx::fround(aOutlineRange.getMinY()), + basegfx::fround(aOutlineRange.getMaxX()), basegfx::fround(aOutlineRange.getMaxY())); + const Rectangle aDestRectPixel(rOutDev.LogicToPixel(aDestRectLogic)); + + // intersect with output pixel size + const Rectangle aOutputRectPixel(Point(), rOutDev.GetOutputSizePixel()); + const Rectangle aCroppedRectPixel(aDestRectPixel.GetIntersection(aOutputRectPixel)); + + if(!aCroppedRectPixel.IsEmpty()) + { + // build transform from pixel in aDestination to pixel in rBitmapEx + basegfx::B2DHomMatrix aTransform; + + // from relative in aCroppedRectPixel to relative in aDestRectPixel + aTransform.translate(aCroppedRectPixel.Left() - aDestRectPixel.Left(), aCroppedRectPixel.Top() - aDestRectPixel.Top()); + + // from relative in aDestRectPixel to absolute Logic + aTransform.scale((double)aDestRectLogic.getWidth() / (double)aDestRectPixel.getWidth(), (double)aDestRectLogic.getHeight() / (double)aDestRectPixel.getHeight()); + aTransform.translate(aDestRectLogic.Left(), aDestRectLogic.Top()); + + // from absolute in Logic to unified object coordinates (0.0 .. 1.0 in x and y) + basegfx::B2DHomMatrix aInvBitmapTransform(rTransform); + aInvBitmapTransform.invert(); + aTransform = aInvBitmapTransform * aTransform; + + // from unit object coordinates to rBitmapEx pixel coordintes + const Size aSourceSizePixel(rBitmapEx.GetSizePixel()); + aTransform.scale(aSourceSizePixel.getWidth() - 1L, aSourceSizePixel.getHeight() - 1L); + + // create bitmap using source, destination and linear back-transformation + BitmapEx aDestination = impTransformBitmapEx(rBitmapEx, aCroppedRectPixel, aTransform); + + // paint + const bool bWasEnabled(rOutDev.IsMapModeEnabled()); + rOutDev.EnableMapMode(false); + rOutDev.DrawBitmapEx(aCroppedRectPixel.TopLeft(), aDestination); + rOutDev.EnableMapMode(bWasEnabled); + } + } + + BitmapEx impModifyBitmapEx(const basegfx::BColorModifierStack& rBColorModifierStack, const BitmapEx& rSource) + { + Bitmap aChangedBitmap(rSource.GetBitmap()); + bool bDone(false); + + for(sal_uInt32 a(rBColorModifierStack.count()); a && !bDone; ) + { + const basegfx::BColorModifier& rModifier = rBColorModifierStack.getBColorModifier(--a); + + switch(rModifier.getMode()) + { + case basegfx::BCOLORMODIFYMODE_REPLACE : + { + // complete replace + if(rSource.IsTransparent()) + { + // clear bitmap with dest color + aChangedBitmap.Erase(Color(rModifier.getBColor())); + } + else + { + // erase bitmap, caller will know to paint direct + aChangedBitmap.SetEmpty(); + } + + bDone = true; + break; + } + + default : // BCOLORMODIFYMODE_INTERPOLATE, BCOLORMODIFYMODE_GRAY, BCOLORMODIFYMODE_BLACKANDWHITE + { + BitmapWriteAccess* pContent = aChangedBitmap.AcquireWriteAccess(); + + if(pContent) + { + for(sal_uInt32 y(0L); y < (sal_uInt32)pContent->Height(); y++) + { + for(sal_uInt32 x(0L); x < (sal_uInt32)pContent->Width(); x++) + { + const basegfx::BColor aBColor(rModifier.getModifiedColor(Color(pContent->GetPixel(y, x)).getBColor())); + pContent->SetPixel(y, x, BitmapColor(Color(aBColor))); + } + } + + delete pContent; + } + + break; + } + } + } + + if(aChangedBitmap.IsEmpty()) + { + return BitmapEx(); + } + else + { + if(rSource.IsTransparent()) + { + if(rSource.IsAlpha()) + { + return BitmapEx(aChangedBitmap, rSource.GetAlpha()); + } + else + { + return BitmapEx(aChangedBitmap, rSource.GetMask()); + } + } + else + { + return BitmapEx(aChangedBitmap); + } + } + } + } // end of anonymous namespace +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace processor2d + { + ////////////////////////////////////////////////////////////////////////////// + // rendering support + + // directdraw of text simple portion + void VclProcessor2D::RenderTextSimplePortionPrimitive2D(const primitive2d::TextSimplePortionPrimitive2D& rTextCandidate) + { + // decompose matrix to have position and size of text + basegfx::B2DHomMatrix aLocalTransform(maCurrentTransformation * rTextCandidate.getTextTransform()); + basegfx::B2DVector aScale, aTranslate; + double fRotate, fShearX; + aLocalTransform.decompose(aScale, aTranslate, fRotate, fShearX); + bool bPrimitiveAccepted(false); + + if(basegfx::fTools::equalZero(fShearX)) + { + if(basegfx::fTools::less(aScale.getX(), 0.0) && basegfx::fTools::less(aScale.getY(), 0.0)) + { + // handle special case: If scale is negative in (x,y) (3rd quadrant), it can + // be expressed as rotation by PI + aScale = basegfx::absolute(aScale); + fRotate += (180.0 * F_PI180); + } + + if(basegfx::fTools::more(aScale.getX(), 0.0) && basegfx::fTools::more(aScale.getY(), 0.0)) + { + // handle, there is no shear and no mirror + bPrimitiveAccepted = true; + const Font aFont(getVclFontFromFontAttributes(rTextCandidate.getFontAttributes(), aScale, fRotate)); + const basegfx::B2DPoint aPoint(aLocalTransform * basegfx::B2DPoint(0.0, 0.0)); + const Point aStartPoint(basegfx::fround(aPoint.getX()), basegfx::fround(aPoint.getY())); + + // create transformed integer DXArray in view coordinate system + ::std::vector< sal_Int32 > aTransformedDXArray; + + if(rTextCandidate.getDXArray().size()) + { + aTransformedDXArray.reserve(rTextCandidate.getDXArray().size()); + const basegfx::B2DVector aPixelVector(aLocalTransform * basegfx::B2DVector(1.0, 0.0)); + const double fPixelVectorLength(aPixelVector.getLength()); + + for(::std::vector< double >::const_iterator aStart(rTextCandidate.getDXArray().begin()); aStart != rTextCandidate.getDXArray().end(); aStart++) + { + aTransformedDXArray.push_back(basegfx::fround((*aStart) * fPixelVectorLength)); + } + } + + // set parameters and paint + const basegfx::BColor aRGBFontColor(maBColorModifierStack.getModifiedColor(rTextCandidate.getFontColor())); + mpOutputDevice->SetFont(aFont); + mpOutputDevice->SetTextColor(Color(aRGBFontColor)); + mpOutputDevice->DrawTextArray(aStartPoint, rTextCandidate.getText(), &(aTransformedDXArray[0])); + } + } + + if(!bPrimitiveAccepted) + { + // let break down + process(rTextCandidate.get2DDecomposition(getViewInformation2D())); + } + } + + // direct draw of hairline + void VclProcessor2D::RenderPolygonHairlinePrimitive2D(const primitive2d::PolygonHairlinePrimitive2D& rPolygonCandidate) + { + const basegfx::BColor aHairlineColor(maBColorModifierStack.getModifiedColor(rPolygonCandidate.getBColor())); + mpOutputDevice->SetLineColor(Color(aHairlineColor)); + mpOutputDevice->SetFillColor(); + + basegfx::B2DPolygon aLocalPolygon(rPolygonCandidate.getB2DPolygon()); + aLocalPolygon.transform(maCurrentTransformation); + + mpOutputDevice->DrawPolyLine(Polygon(aLocalPolygon)); + } + + // direct draw of transformed BitmapEx primitive + void VclProcessor2D::RenderBitmapPrimitive2D(const primitive2d::BitmapPrimitive2D& rBitmapCandidate) + { + // decompose matrix to check for shear, rotate and mirroring + basegfx::B2DHomMatrix aLocalTransform(maCurrentTransformation * rBitmapCandidate.getTransform()); + basegfx::B2DVector aScale, aTranslate; + double fRotate, fShearX; + aLocalTransform.decompose(aScale, aTranslate, fRotate, fShearX); + BitmapEx aBitmapEx(rBitmapCandidate.getBitmapEx()); + bool bPainted(false); + + if(maBColorModifierStack.count()) + { + aBitmapEx = impModifyBitmapEx(maBColorModifierStack, aBitmapEx); + + if(aBitmapEx.IsEmpty()) + { + // color gets completely replaced, get it + const basegfx::BColor aModifiedColor(maBColorModifierStack.getModifiedColor(basegfx::BColor())); + basegfx::B2DPolygon aPolygon(basegfx::tools::createPolygonFromRect(basegfx::B2DRange(0.0, 0.0, 1.0, 1.0))); + aPolygon.transform(aLocalTransform); + + mpOutputDevice->SetFillColor(Color(aModifiedColor)); + mpOutputDevice->SetLineColor(); + mpOutputDevice->DrawPolygon(Polygon(aPolygon)); + + bPainted = true; + } + } + + if(!bPainted) + { + static bool bForceUseOfOwnTransformer(false); + static bool bUseGraphicManager(true); + + if(!bForceUseOfOwnTransformer && basegfx::fTools::equalZero(fShearX)) + { + if(basegfx::fTools::equalZero(fRotate) && !bUseGraphicManager) + { + RenderBitmapPrimitive2D_BitmapEx(*mpOutputDevice, aBitmapEx, aLocalTransform); + } + else + { + RenderBitmapPrimitive2D_GraphicManager(*mpOutputDevice, aBitmapEx, aLocalTransform); + } + } + else + { + if(!aBitmapEx.IsTransparent() && (!basegfx::fTools::equalZero(fShearX) || !basegfx::fTools::equalZero(fRotate))) + { + // parts will be uncovered, extend aBitmapEx with a mask bitmap + const Bitmap aContent(aBitmapEx.GetBitmap()); + aBitmapEx = BitmapEx(aContent, Bitmap(aContent.GetSizePixel(), 1)); + } + + RenderBitmapPrimitive2D_self(*mpOutputDevice, aBitmapEx, aLocalTransform); + } + } + } + + void VclProcessor2D::RenderFillBitmapPrimitive2D(const primitive2d::FillBitmapPrimitive2D& rFillBitmapCandidate) + { + const attribute::FillBitmapAttribute& rFillBitmapAttribute(rFillBitmapCandidate.getFillBitmap()); + bool bPrimitiveAccepted(false); + + if(rFillBitmapAttribute.getTiling()) + { + // decompose matrix to check for shear, rotate and mirroring + basegfx::B2DHomMatrix aLocalTransform(maCurrentTransformation * rFillBitmapCandidate.getTransformation()); + basegfx::B2DVector aScale, aTranslate; + double fRotate, fShearX; + aLocalTransform.decompose(aScale, aTranslate, fRotate, fShearX); + + if(basegfx::fTools::equalZero(fRotate) && basegfx::fTools::equalZero(fShearX)) + { + // no shear or rotate, draw direct in pixel coordinates + bPrimitiveAccepted = true; + BitmapEx aBitmapEx(rFillBitmapAttribute.getBitmap()); + bool bPainted(false); + + if(maBColorModifierStack.count()) + { + aBitmapEx = impModifyBitmapEx(maBColorModifierStack, aBitmapEx); + + if(aBitmapEx.IsEmpty()) + { + // color gets completely replaced, get it + const basegfx::BColor aModifiedColor(maBColorModifierStack.getModifiedColor(basegfx::BColor())); + basegfx::B2DPolygon aPolygon(basegfx::tools::createPolygonFromRect(basegfx::B2DRange(0.0, 0.0, 1.0, 1.0))); + aPolygon.transform(aLocalTransform); + + mpOutputDevice->SetFillColor(Color(aModifiedColor)); + mpOutputDevice->SetLineColor(); + mpOutputDevice->DrawPolygon(Polygon(aPolygon)); + + bPainted = true; + } + } + + if(!bPainted) + { + const basegfx::B2DPoint aObjTopLeft(aTranslate.getX(), aTranslate.getY()); + const basegfx::B2DPoint aObjBottomRight(aTranslate.getX() + aScale.getX(), aTranslate.getY() + aScale.getY()); + const Point aObjTL(mpOutputDevice->LogicToPixel(Point((sal_Int32)aObjTopLeft.getX(), (sal_Int32)aObjTopLeft.getY()))); + const Point aObjBR(mpOutputDevice->LogicToPixel(Point((sal_Int32)aObjBottomRight.getX(), (sal_Int32)aObjBottomRight.getY()))); + + const basegfx::B2DPoint aBmpTopLeft(aLocalTransform * rFillBitmapAttribute.getTopLeft()); + const basegfx::B2DPoint aBmpBottomRight(aLocalTransform * basegfx::B2DPoint(rFillBitmapAttribute.getTopLeft() + rFillBitmapAttribute.getSize())); + const Point aBmpTL(mpOutputDevice->LogicToPixel(Point((sal_Int32)aBmpTopLeft.getX(), (sal_Int32)aBmpTopLeft.getY()))); + const Point aBmpBR(mpOutputDevice->LogicToPixel(Point((sal_Int32)aBmpBottomRight.getX(), (sal_Int32)aBmpBottomRight.getY()))); + + sal_Int32 nOWidth(aObjBR.X() - aObjTL.X()); + sal_Int32 nOHeight(aObjBR.Y() - aObjTL.Y()); + + if(nOWidth < 0L) + { + nOWidth = 1L; + } + + if(nOHeight < 0L) + { + nOHeight = 1L; + } + + sal_Int32 nBWidth(aBmpBR.X() - aBmpTL.X()); + sal_Int32 nBHeight(aBmpBR.Y() - aBmpTL.Y()); + + if(nBWidth < 0L) + { + nBWidth = 1L; + } + + if(nBHeight < 0L) + { + nBHeight = 1L; + } + + sal_Int32 nBLeft(aBmpTL.X()); + sal_Int32 nBTop(aBmpTL.Y()); + + if(nBLeft > aObjTL.X()) + { + nBLeft -= ((nBLeft / nBWidth) + 1L) * nBWidth; + } + + if(nBLeft + nBWidth <= aObjTL.X()) + { + nBLeft -= (nBLeft / nBWidth) * nBWidth; + } + + if(nBTop > aObjTL.Y()) + { + nBTop -= ((nBTop / nBHeight) + 1L) * nBHeight; + } + + if(nBTop + nBHeight <= aObjTL.Y()) + { + nBTop -= (nBTop / nBHeight) * nBHeight; + } + + // nBWidth, nBHeight is the pixel size of the neede bitmap. To not need to scale it + // in vcl many times, create a size-optimized version + const Size aNeededBitmapSizePixel(nBWidth, nBHeight); + + if(aNeededBitmapSizePixel != aBitmapEx.GetSizePixel()) + { + aBitmapEx.Scale(aNeededBitmapSizePixel); + } + + // prepare OutDev + const Point aEmptyPoint(0, 0); + const Rectangle aVisiblePixel(aEmptyPoint, mpOutputDevice->GetOutputSizePixel()); + const bool bWasEnabled(mpOutputDevice->IsMapModeEnabled()); + mpOutputDevice->EnableMapMode(false); + + for(sal_Int32 nXPos(nBLeft); nXPos < aObjTL.X() + nOWidth; nXPos += nBWidth) + { + for(sal_Int32 nYPos(nBTop); nYPos < aObjTL.Y() + nOHeight; nYPos += nBHeight) + { + const Rectangle aOutRectPixel(Point(nXPos, nYPos), aNeededBitmapSizePixel); + + if(aOutRectPixel.IsOver(aVisiblePixel)) + { + mpOutputDevice->DrawBitmapEx(aOutRectPixel.TopLeft(), aBitmapEx); + } + } + } + + // restore OutDev + mpOutputDevice->EnableMapMode(bWasEnabled); + } + } + } + + if(!bPrimitiveAccepted) + { + // do not accept, use decomposition + process(rFillBitmapCandidate.get2DDecomposition(getViewInformation2D())); + } + } + + // direct draw of gradient + void VclProcessor2D::RenderPolyPolygonGradientPrimitive2D(const primitive2d::PolyPolygonGradientPrimitive2D& rPolygonCandidate) + { + const attribute::FillGradientAttribute& rGradient(rPolygonCandidate.getFillGradient()); + basegfx::BColor aStartColor(maBColorModifierStack.getModifiedColor(rGradient.getStartColor())); + basegfx::BColor aEndColor(maBColorModifierStack.getModifiedColor(rGradient.getEndColor())); + basegfx::B2DPolyPolygon aLocalPolyPolygon(rPolygonCandidate.getB2DPolyPolygon()); + aLocalPolyPolygon.transform(maCurrentTransformation); + + if(aStartColor == aEndColor) + { + // no gradient at all, draw as polygon + mpOutputDevice->SetLineColor(); + mpOutputDevice->SetFillColor(Color(aStartColor)); + mpOutputDevice->DrawPolyPolygon(aLocalPolyPolygon); + } + else + { + impDrawGradientToOutDev( + *mpOutputDevice, aLocalPolyPolygon, rGradient.getStyle(), rGradient.getSteps(), + aStartColor, aEndColor, rGradient.getBorder(), + -rGradient.getAngle(), rGradient.getOffsetX(), rGradient.getOffsetY(), false); + } + } + + // direct draw of PolyPolygon with color + void VclProcessor2D::RenderPolyPolygonColorPrimitive2D(const primitive2d::PolyPolygonColorPrimitive2D& rPolygonCandidate) + { + const basegfx::BColor aPolygonColor(maBColorModifierStack.getModifiedColor(rPolygonCandidate.getBColor())); + mpOutputDevice->SetFillColor(Color(aPolygonColor)); + mpOutputDevice->SetLineColor(); + + basegfx::B2DPolyPolygon aLocalPolyPolygon(rPolygonCandidate.getB2DPolyPolygon()); + aLocalPolyPolygon.transform(maCurrentTransformation); + + mpOutputDevice->DrawPolyPolygon(PolyPolygon(aLocalPolyPolygon)); + } + + // direct draw of MetaFile + void VclProcessor2D::RenderMetafilePrimitive2D(const primitive2d::MetafilePrimitive2D& rMetaCandidate) + { + // decompose matrix to check for shear, rotate and mirroring + basegfx::B2DHomMatrix aLocalTransform(maCurrentTransformation * rMetaCandidate.getTransform()); + basegfx::B2DVector aScale, aTranslate; + double fRotate, fShearX; + aLocalTransform.decompose(aScale, aTranslate, fRotate, fShearX); + + // get BoundRect + basegfx::B2DRange aOutlineRange(rMetaCandidate.getB2DRange(getViewInformation2D())); + aOutlineRange.transform(maCurrentTransformation); + const Rectangle aDestRectView( + basegfx::fround(aOutlineRange.getMinX()), basegfx::fround(aOutlineRange.getMinY()), + basegfx::fround(aOutlineRange.getMaxX()), basegfx::fround(aOutlineRange.getMaxY())); + + // get metafile (copy it) + GDIMetaFile aMetaFile; + + if(maBColorModifierStack.count()) + { + const basegfx::BColor aRGBBaseColor(0, 0, 0); + const basegfx::BColor aRGBColor(maBColorModifierStack.getModifiedColor(aRGBBaseColor)); + aMetaFile = rMetaCandidate.getMetaFile().GetMonochromeMtf(Color(aRGBColor)); + } + else + { + aMetaFile = rMetaCandidate.getMetaFile(); + } + + // rotation + if(!basegfx::fTools::equalZero(fRotate)) + { + double fRotation((fRotate / F_PI180) * -10.0); + aMetaFile.Rotate((sal_uInt16)(fRotation)); + } + + // paint it + aMetaFile.WindStart(); + aMetaFile.Play(mpOutputDevice, aDestRectView.TopLeft(), aDestRectView.GetSize()); + } + + // mask group. Force output to VDev and create mask from given mask + void VclProcessor2D::RenderMaskPrimitive2D(const primitive2d::MaskPrimitive2D& rMaskCandidate) + { + if(rMaskCandidate.getChildren().hasElements()) + { + basegfx::B2DPolyPolygon aMask(rMaskCandidate.getMask()); + aMask.transform(maCurrentTransformation); + const basegfx::B2DRange aRange(basegfx::tools::getRange(aMask)); + impBufferDevice aBufferDevice(*mpOutputDevice, aRange); + + if(aBufferDevice.isVisible()) + { + // remember last OutDev and set to content + OutputDevice* pLastOutputDevice = mpOutputDevice; + mpOutputDevice = &aBufferDevice.getContent(); + + // paint to it + process(rMaskCandidate.getChildren()); + + // back to old OutDev + mpOutputDevice = pLastOutputDevice; + + // draw mask + VirtualDevice& rMask = aBufferDevice.getMask(); + rMask.SetLineColor(); + rMask.SetFillColor(COL_BLACK); + rMask.DrawPolyPolygon(PolyPolygon(aMask)); + + // dump buffer to outdev + aBufferDevice.paint(); + } + } + } + + // modified color group. Force output to unified color. + void VclProcessor2D::RenderModifiedColorPrimitive2D(const primitive2d::ModifiedColorPrimitive2D& rModifiedCandidate) + { + if(rModifiedCandidate.getChildren().hasElements()) + { + maBColorModifierStack.push(rModifiedCandidate.getColorModifier()); + process(rModifiedCandidate.getChildren()); + maBColorModifierStack.pop(); + } + } + + // sub-transparence group. Draw to VDev first. + void VclProcessor2D::RenderAlphaPrimitive2D(const primitive2d::AlphaPrimitive2D& rTransCandidate) + { + if(rTransCandidate.getChildren().hasElements()) + { + basegfx::B2DRange aRange(primitive2d::getB2DRangeFromPrimitive2DSequence(rTransCandidate.getChildren(), getViewInformation2D())); + aRange.transform(maCurrentTransformation); + impBufferDevice aBufferDevice(*mpOutputDevice, aRange); + + if(aBufferDevice.isVisible()) + { + // remember last OutDev and set to content + OutputDevice* pLastOutputDevice = mpOutputDevice; + mpOutputDevice = &aBufferDevice.getContent(); + + // paint content to it + process(rTransCandidate.getChildren()); + + // set to mask + mpOutputDevice = &aBufferDevice.getAlpha(); + + // when painting alpha masks, reset the color stack + basegfx::BColorModifierStack aLastBColorModifierStack(maBColorModifierStack); + maBColorModifierStack = basegfx::BColorModifierStack(); + + // paint mask to it + process(rTransCandidate.getAlpha()); + + // back to old color stack + maBColorModifierStack = aLastBColorModifierStack; + + // back to old OutDev + mpOutputDevice = pLastOutputDevice; + + // dump buffer to outdev + aBufferDevice.paint(); + } + } + } + + // transform group. + void VclProcessor2D::RenderTransformPrimitive2D(const primitive2d::TransformPrimitive2D& rTransformCandidate) + { + // remember current transformation + basegfx::B2DHomMatrix aLastCurrentTransformation(maCurrentTransformation); + + // create new transformations + maCurrentTransformation = maCurrentTransformation * rTransformCandidate.getTransformation(); + + // let break down + process(rTransformCandidate.getChildren()); + + // restore transformations + maCurrentTransformation = aLastCurrentTransformation; + } + + // marker + void VclProcessor2D::RenderMarkerPrimitive2D(const primitive2d::MarkerPrimitive2D& rMarkCandidate) + { + const basegfx::BColor aRGBColor(maBColorModifierStack.getModifiedColor(rMarkCandidate.getRGBColor())); + const Color aColor(aRGBColor); + + // evtl. just test markers + static bool bForceMarkersToRangeTest(false); + + if(bForceMarkersToRangeTest) + { + // ATM just test marker range + const basegfx::B2DRange aRange(rMarkCandidate.getB2DRange(getViewInformation2D())); + basegfx::B2DPolygon aPolygon(basegfx::tools::createPolygonFromRect(aRange)); + aPolygon.transform(maCurrentTransformation); + + mpOutputDevice->SetFillColor(); + mpOutputDevice->SetLineColor(aColor); + mpOutputDevice->DrawPolygon(Polygon(aPolygon)); + } + else + { + const basegfx::B2DPoint aViewPosition(maCurrentTransformation * rMarkCandidate.getPosition()); + Point aPos(basegfx::fround(aViewPosition.getX()), basegfx::fround(aViewPosition.getY())); + + switch(rMarkCandidate.getStyle()) + { + default : // MARKERSTYLE2D_POINT + { + mpOutputDevice->DrawPixel(aPos, aColor); + break; + } + case primitive2d::MARKERSTYLE2D_CROSS : + { + basegfx::B2DRange aRange; + rMarkCandidate.getRealtiveViewRange(aRange); + const basegfx::B2DPoint aCenter(aRange.getCenter()); + + aPos = mpOutputDevice->LogicToPixel(aPos); + aPos.X() += basegfx::fround(aCenter.getX()); + aPos.Y() += basegfx::fround(aCenter.getY()); + + const bool bWasEnabled(mpOutputDevice->IsMapModeEnabled()); + mpOutputDevice->EnableMapMode(false); + + mpOutputDevice->DrawPixel(aPos, aColor); + mpOutputDevice->DrawPixel(Point(aPos.X() - 1L, aPos.Y()), aColor); + mpOutputDevice->DrawPixel(Point(aPos.X() + 1L, aPos.Y()), aColor); + mpOutputDevice->DrawPixel(Point(aPos.X(), aPos.Y() - 1L), aColor); + mpOutputDevice->DrawPixel(Point(aPos.X(), aPos.Y() + 1L), aColor); + + mpOutputDevice->EnableMapMode(bWasEnabled); + break; + } + case primitive2d::MARKERSTYLE2D_GLUEPOINT : + { + basegfx::B2DRange aRange; + rMarkCandidate.getRealtiveViewRange(aRange); + const basegfx::B2DPoint aCenter(aRange.getCenter()); + + aPos = mpOutputDevice->LogicToPixel(aPos); + aPos.X() += basegfx::fround(aCenter.getX()); + aPos.Y() += basegfx::fround(aCenter.getY()); + + const bool bWasEnabled(mpOutputDevice->IsMapModeEnabled()); + mpOutputDevice->EnableMapMode(false); + + // backpen + mpOutputDevice->SetLineColor(aColor); + mpOutputDevice->DrawLine(aPos + Point(-2, -3), aPos + Point(+3, +2)); + mpOutputDevice->DrawLine(aPos + Point(-3, -2), aPos + Point(+2, +3)); + mpOutputDevice->DrawLine(aPos + Point(-3, +2), aPos + Point(+2, -3)); + mpOutputDevice->DrawLine(aPos + Point(-2, +3), aPos + Point(+3, -2)); + + // frontpen (hard coded) + mpOutputDevice->SetLineColor(COL_LIGHTBLUE); + mpOutputDevice->DrawLine(aPos + Point(-2, -2), aPos + Point(+2, +2)); + mpOutputDevice->DrawLine(aPos + Point(-2, +2), aPos + Point(+2, -2)); + + mpOutputDevice->EnableMapMode(bWasEnabled); + break; + } + } + } + } + + ////////////////////////////////////////////////////////////////////////////// + // internal processing support + + void VclProcessor2D::process(const primitive2d::Primitive2DSequence& rSource) + { + if(rSource.hasElements()) + { + const sal_Int32 nCount(rSource.getLength()); + + for(sal_Int32 a(0L); a < nCount; a++) + { + // get reference + const primitive2d::Primitive2DReference xReference(rSource[a]); + + if(xReference.is()) + { + // try to cast to BasePrimitive2D implementation + const primitive2d::BasePrimitive2D* pBasePrimitive = dynamic_cast< const primitive2d::BasePrimitive2D* >(xReference.get()); + + if(pBasePrimitive) + { + // it is a BasePrimitive2D implementation, use getPrimitiveID() call for switch + switch(pBasePrimitive->getPrimitiveID()) + { + case Create2DPrimitiveID('2','T','S','i') : + { + // directdraw of text simple portion + RenderTextSimplePortionPrimitive2D(static_cast< const primitive2d::TextSimplePortionPrimitive2D& >(*pBasePrimitive)); + break; + } + case Create2DPrimitiveID('2','P','H','a') : + { + // direct draw of hairline + RenderPolygonHairlinePrimitive2D(static_cast< const primitive2d::PolygonHairlinePrimitive2D& >(*pBasePrimitive)); + break; + } + case Create2DPrimitiveID('2','B','i','t') : + { + // direct draw of transformed BitmapEx primitive + RenderBitmapPrimitive2D(static_cast< const primitive2d::BitmapPrimitive2D& >(*pBasePrimitive)); + break; + } + case Create2DPrimitiveID('2','F','B','i') : + { + // direct draw of fillBitmapPrimitive + RenderFillBitmapPrimitive2D(static_cast< const primitive2d::FillBitmapPrimitive2D& >(*pBasePrimitive)); + break; + } + case Create2DPrimitiveID('2','P','P','G') : + { + // direct draw of gradient + RenderPolyPolygonGradientPrimitive2D(static_cast< const primitive2d::PolyPolygonGradientPrimitive2D& >(*pBasePrimitive)); + break; + } + case Create2DPrimitiveID('2','P','P','C') : + { + // direct draw of PolyPolygon with color + RenderPolyPolygonColorPrimitive2D(static_cast< const primitive2d::PolyPolygonColorPrimitive2D& >(*pBasePrimitive)); + break; + } + case Create2DPrimitiveID('2','M','e','t') : + { + // direct draw of MetaFile + RenderMetafilePrimitive2D(static_cast< const primitive2d::MetafilePrimitive2D& >(*pBasePrimitive)); + break; + } + case Create2DPrimitiveID('2','M','a','s') : + { + // mask group. Force output to VDev and create mask from given mask + RenderMaskPrimitive2D(static_cast< const primitive2d::MaskPrimitive2D& >(*pBasePrimitive)); + break; + } + case Create2DPrimitiveID('2','M','C','o') : + { + // modified color group. Force output to unified color. + RenderModifiedColorPrimitive2D(static_cast< const primitive2d::ModifiedColorPrimitive2D& >(*pBasePrimitive)); + break; + } + case Create2DPrimitiveID('2','A','l','p') : + { + // sub-transparence group. Draw to VDev first. + RenderAlphaPrimitive2D(static_cast< const primitive2d::AlphaPrimitive2D& >(*pBasePrimitive)); + break; + } + case Create2DPrimitiveID('2','T','r','a') : + { + // transform group. + RenderTransformPrimitive2D(static_cast< const primitive2d::TransformPrimitive2D& >(*pBasePrimitive)); + break; + } + case Create2DPrimitiveID('2','M','a','r') : + { + // marker + RenderMarkerPrimitive2D(static_cast< const primitive2d::MarkerPrimitive2D& >(*pBasePrimitive)); + break; + } + default : + { + // process recursively + process(pBasePrimitive->get2DDecomposition(getViewInformation2D())); + break; + } + } + } + else + { + // unknown implementation, use UNO API call instead and process recursively + com::sun::star::graphic::Primitive2DParameters aPrimitive2DParameters; + + basegfx::unotools::affineMatrixFromHomMatrix(aPrimitive2DParameters.ViewTransformation, getViewInformation2D().getViewTransformation()); + aPrimitive2DParameters.Viewport = basegfx::unotools::rectangle2DFromB2DRectangle(getViewInformation2D().getViewport()); + aPrimitive2DParameters.Time = getViewInformation2D().getViewTime(); + + process(xReference->getDecomposition(aPrimitive2DParameters)); + } + } + } + } + } + + VclProcessor2D::VclProcessor2D( + const geometry::ViewInformation2D& rViewInformation, + OutputDevice& rOutDev) + : BaseProcessor2D(rViewInformation), + mbOutputToRecordingMetaFile(false) + { + // initialize destination OutDev + mpOutputDevice = &rOutDev; + + // check if output is recorded to metafile + const GDIMetaFile* pMetaFile = mpOutputDevice->GetConnectMetaFile(); + mbOutputToRecordingMetaFile = (pMetaFile && pMetaFile->IsRecord() && !pMetaFile->IsPause()); + + if(mbOutputToRecordingMetaFile) + { + // draw to logic coordinates, do not initialize maCurrentTransformation to viewTransformation, + // do not change MapMode of destination + } + else + { + // prepare maCurrentTransformation matrix with viewTransformation to go directly to pixels + maCurrentTransformation = rViewInformation.getViewTransformation(); + + // prepare output to pixels + mpOutputDevice->Push(PUSH_MAPMODE); + mpOutputDevice->SetMapMode(); + } + } + + VclProcessor2D::~VclProcessor2D() + { + if(mbOutputToRecordingMetaFile) + { + } + else + { + // restore MapMode + mpOutputDevice->Pop(); + } + } + } // end of namespace processor2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/processor3d/baseprocessor3d.cxx b/drawinglayer/source/processor3d/baseprocessor3d.cxx index 01e40b43f904..b8da56b28719 100644 --- a/drawinglayer/source/processor3d/baseprocessor3d.cxx +++ b/drawinglayer/source/processor3d/baseprocessor3d.cxx @@ -4,9 +4,9 @@ * * $RCSfile: baseprocessor3d.cxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: aw $ $Date: 2006-08-09 16:57:47 $ + * last change: $Author: aw $ $Date: 2006-10-19 10:39:22 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -33,25 +33,26 @@ * ************************************************************************/ -#ifndef _DRAWINGLAYER_PROCESSOR3D_BASEPROCESSOR3D_HXX +#ifndef INCLUDED_DRAWINGLAYER_PROCESSOR3D_BASEPROCESSOR3D_HXX #include <drawinglayer/processor3d/baseprocessor3d.hxx> #endif ////////////////////////////////////////////////////////////////////////////// +using namespace com::sun::star; + +////////////////////////////////////////////////////////////////////////////// + namespace drawinglayer { namespace processor3d { - baseProcessor3D::baseProcessor3D( - const geometry::viewInformation& rViewInformation, - const geometry::transformation3D& rTransformation3D) - : maViewInformation(rViewInformation), - maTransformation3D(rTransformation3D) + BaseProcessor3D::BaseProcessor3D(double fTime) + : mfTime(fTime) { } - baseProcessor3D::~baseProcessor3D() + BaseProcessor3D::~BaseProcessor3D() { } } // end of namespace processor3d @@ -63,21 +64,16 @@ namespace drawinglayer { namespace processor3d { - collectingProcessor3D::collectingProcessor3D( - const geometry::viewInformation& rViewInformation, - const geometry::transformation3D& rTransformation3D) - : baseProcessor3D(rViewInformation, rTransformation3D) - { - } - - collectingProcessor3D::~collectingProcessor3D() + CollectingProcessor3D::CollectingProcessor3D(double fTime) + : BaseProcessor3D(fTime), + maPrimitiveSequence() { } - void collectingProcessor3D::process(const primitive3d::primitiveVector3D& rSource) + void CollectingProcessor3D::process(const primitive3d::Primitive3DSequence& rSource) { // accept everything - maPrimitiveVector.insert(maPrimitiveVector.end(), rSource.begin(), rSource.end()); + primitive3d::appendPrimitive3DSequenceToPrimitive3DSequence(maPrimitiveSequence, rSource); } } // end of namespace processor3d } // end of namespace drawinglayer diff --git a/drawinglayer/source/processor3d/defaultprocessor3d.cxx b/drawinglayer/source/processor3d/defaultprocessor3d.cxx index 1ec617b0a944..6e04192319ff 100644 --- a/drawinglayer/source/processor3d/defaultprocessor3d.cxx +++ b/drawinglayer/source/processor3d/defaultprocessor3d.cxx @@ -4,9 +4,9 @@ * * $RCSfile: defaultprocessor3d.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: aw $ $Date: 2006-09-27 16:33:27 $ + * last change: $Author: aw $ $Date: 2006-10-19 10:39:22 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -33,60 +33,82 @@ * ************************************************************************/ -#ifndef _DRAWINGLAYER_PROCESSOR3D_DEFAULTPROCESSOR3D_HXX +////////////////////////////////////////////////////////////////////////////// +// includes for namespace basegfx + +#ifndef INCLUDED_DRAWINGLAYER_PROCESSOR3D_DEFAULTPROCESSOR3D_HXX #include <drawinglayer/processor3d/defaultprocessor3d.hxx> #endif +#ifndef _BGFX_POLYGON_B3DPOLYGON_HXX +#include <basegfx/polygon/b3dpolygon.hxx> +#endif + +#ifndef _BGFX_RASTER_BZPIXELRASTER_HXX +#include <basegfx/raster/bzpixelraster.hxx> +#endif + #ifndef _SV_BMPACC_HXX #include <vcl/bmpacc.hxx> #endif -#ifndef _BGFX_POLYGON_B3DPOLYGON_HXX -#include <basegfx/polygon/b3dpolygon.hxx> +#ifndef INCLUDED_DRAWINGLAYER_ATTRIBUTE_MATERIALATTRIBUTE3D_HXX +#include <drawinglayer/attribute/materialattribute3d.hxx> #endif -#ifndef _DRAWINGLAYER_PRIMITIVE3D_POLYGONPRIMITIVE3D_HXX -#include <drawinglayer/primitive3d/polygonprimitive3d.hxx> +////////////////////////////////////////////////////////////////////////////// +// includes for namespace drawinglayer + +#ifndef INCLUDED_DRAWINGLAYER_TEXTURE_TEXTURE_HXX +#include <drawinglayer/texture/texture.hxx> #endif -#ifndef _DRAWINGLAYER_PRIMITIVE3D_MODIFIEDCOLORPRIMITIVE3D_HXX -#include <drawinglayer/primitive3d/modifiedcolorprimitive3d.hxx> +#ifndef INCLUDED_DRAWINGLAYER_ATTRIBUTE_SDRATTRIBUTE3D_HXX +#include <drawinglayer/attribute/sdrattribute3d.hxx> #endif -#ifndef _DRAWINGLAYER_PRIMITIVE3D_POLYPOLYGONPRIMITIVE_HXX -#include <drawinglayer/primitive3d/polypolygonprimitive3d.hxx> +#ifndef INCLUDED_DRAWINGLAYER_ATTRIBUTE_FILLATTRIBUTE_HXX +#include <drawinglayer/attribute/fillattribute.hxx> #endif -#ifndef _BGFX_POLYPOLYGON_B3DPOLYGONCLIPPER_HXX -#include <basegfx/polygon/b3dpolygonclipper.hxx> +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_HATCHTEXTUREPRIMITIVE3D_HXX +#include <drawinglayer/primitive3d/hatchtextureprimitive3d.hxx> #endif -#ifndef _BGFX_RASTER_BZPIXELRASTER_HXX -#include <basegfx/raster/bzpixelraster.hxx> +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_MODIFIEDCOLORPRIMITIVE3D_HXX +#include <drawinglayer/primitive3d/modifiedcolorprimitive3d.hxx> #endif -#ifndef _DRAWINGLAYER_ATTRIBUTE_SDRATTRIBUTE3D_HXX -#include <drawinglayer/attribute/sdrattribute3d.hxx> +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_POLYGONPRIMITIVE3D_HXX +#include <drawinglayer/primitive3d/polygonprimitive3d.hxx> #endif #ifndef _BGFX_POLYGON_B3DPOLYGONTOOLS_HXX #include <basegfx/polygon/b3dpolygontools.hxx> #endif +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_POLYPOLYGONPRIMITIVE3D_HXX +#include <drawinglayer/primitive3d/polypolygonprimitive3d.hxx> +#endif + #ifndef _BGFX_POLYPOLYGON_B3DPOLYGONTOOLS_HXX #include <basegfx/polygon/b3dpolypolygontools.hxx> #endif -#ifndef _DRAWINGLAYER_PRIMITIVE3D_TEXTUREPRIMITIVE3D_HXX -#include <drawinglayer/primitive3d/textureprimitive3d.hxx> +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_TRANSFORMPRIMITIVE3D_HXX +#include <drawinglayer/primitive3d/transformprimitive3d.hxx> #endif -#ifndef _DRAWINGLAYER_PRIMITIVE3D_HATCHTEXTUREPRIMITIVE3D_HXX -#include <drawinglayer/primitive3d/hatchtextureprimitive3d.hxx> +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDRLABELPRIMITIVE3D_HXX +#include <drawinglayer/primitive3d/sdrlabelprimitive3d.hxx> #endif -#ifndef _DRAWINGLAYER_PRIMITIVE3D_TRANSFORMPRIMITIVE3D_HXX -#include <drawinglayer/primitive3d/transformprimitive3d.hxx> +#ifndef _BGFX_TOOLS_CANVASTOOLS_HXX +#include <basegfx/tools/canvastools.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_GEOMETRY_VIEWINFORMATION2D_HXX +#include <drawinglayer/geometry/viewinformation2d.hxx> #endif ////////////////////////////////////////////////////////////////////////////// @@ -606,8 +628,8 @@ namespace drawinglayer { protected: basegfx::BZPixelRaster& mrBuffer; - const attribute::materialAttribute3D& mrMaterial; - const processor3d::defaultProcessor3D& mrProcessor; + const attribute::MaterialAttribute3D& mrMaterial; + const processor3d::DefaultProcessor3D& mrProcessor; // virtual rasterconverter virtual void processSpan(const basegfx::B3DScanlineEntry& rA, const basegfx::B3DScanlineEntry& rB, sal_Int32 nLine, sal_uInt32 nSpanCount); @@ -617,8 +639,8 @@ namespace drawinglayer BZPolyRaCon( bool bArea, basegfx::BZPixelRaster& rBuffer, - const attribute::materialAttribute3D& rMaterial, - const processor3d::defaultProcessor3D& rProcessor) + const attribute::MaterialAttribute3D& rMaterial, + const processor3d::DefaultProcessor3D& rProcessor) : B3DPolyPolygonRasterConverter(bArea), mrBuffer(rBuffer), mrMaterial(rMaterial), @@ -942,46 +964,41 @@ namespace drawinglayer { namespace texture { - class geoTexSvxMono : public geoTexSvx + class GeoTexSvxMono : public GeoTexSvx { protected: - basegfx::BColor maSingleColor; + basegfx::BColor maSingleColor; double mfOpacity; public: - geoTexSvxMono(const basegfx::BColor& rSingleColor, double fOpacity); - virtual ~geoTexSvxMono(); + GeoTexSvxMono(const basegfx::BColor& rSingleColor, double fOpacity); // compare operator - virtual bool operator==(const geoTexSvx& rGeoTexSvx) const; + virtual bool operator==(const GeoTexSvx& rGeoTexSvx) const; virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const; virtual void modifyOpacity(const basegfx::B2DPoint& rUV, double& rfOpacity) const; }; - geoTexSvxMono::geoTexSvxMono(const basegfx::BColor& rSingleColor, double fOpacity) + GeoTexSvxMono::GeoTexSvxMono(const basegfx::BColor& rSingleColor, double fOpacity) : maSingleColor(rSingleColor), mfOpacity(fOpacity) { } - geoTexSvxMono::~geoTexSvxMono() - { - } - - bool geoTexSvxMono::operator==(const geoTexSvx& rGeoTexSvx) const + bool GeoTexSvxMono::operator==(const GeoTexSvx& rGeoTexSvx) const { - const geoTexSvxMono* pCompare = dynamic_cast< const geoTexSvxMono* >(&rGeoTexSvx); + const GeoTexSvxMono* pCompare = dynamic_cast< const GeoTexSvxMono* >(&rGeoTexSvx); return (pCompare && maSingleColor == pCompare->maSingleColor && mfOpacity == pCompare->mfOpacity); } - void geoTexSvxMono::modifyBColor(const basegfx::B2DPoint& /*rUV*/, basegfx::BColor& rBColor, double& /*rfOpacity*/) const + void GeoTexSvxMono::modifyBColor(const basegfx::B2DPoint& /*rUV*/, basegfx::BColor& rBColor, double& /*rfOpacity*/) const { rBColor = maSingleColor; } - void geoTexSvxMono::modifyOpacity(const basegfx::B2DPoint& /*rUV*/, double& rfOpacity) const + void GeoTexSvxMono::modifyOpacity(const basegfx::B2DPoint& /*rUV*/, double& rfOpacity) const { rfOpacity = mfOpacity; } @@ -994,13 +1011,13 @@ namespace drawinglayer { namespace texture { - class geoTexSvxBitmap : public geoTexSvx + class GeoTexSvxBitmap : public GeoTexSvx { protected: Bitmap maBitmap; BitmapReadAccess* mpRead; basegfx::B2DPoint maTopLeft; - basegfx::B2DVector maSize; + basegfx::B2DVector maSize; double mfMulX; double mfMulY; @@ -1008,13 +1025,13 @@ namespace drawinglayer bool impIsValid(const basegfx::B2DPoint& rUV, sal_Int32& rX, sal_Int32& rY) const; public: - geoTexSvxBitmap(const Bitmap& rBitmap, const basegfx::B2DPoint& rTopLeft, const basegfx::B2DVector& rSize); - virtual ~geoTexSvxBitmap(); + GeoTexSvxBitmap(const Bitmap& rBitmap, const basegfx::B2DPoint& rTopLeft, const basegfx::B2DVector& rSize); + virtual ~GeoTexSvxBitmap(); virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const; virtual void modifyOpacity(const basegfx::B2DPoint& rUV, double& rfOpacity) const; }; - geoTexSvxBitmap::geoTexSvxBitmap(const Bitmap& rBitmap, const basegfx::B2DPoint& rTopLeft, const basegfx::B2DVector& rSize) + GeoTexSvxBitmap::GeoTexSvxBitmap(const Bitmap& rBitmap, const basegfx::B2DPoint& rTopLeft, const basegfx::B2DVector& rSize) : maBitmap(rBitmap), mpRead(0L), maTopLeft(rTopLeft), @@ -1023,17 +1040,17 @@ namespace drawinglayer mfMulY(0.0) { mpRead = maBitmap.AcquireReadAccess(); - OSL_ENSURE(mpRead, "geoTexSvxBitmap: Got no read access to Bitmap (!)"); + OSL_ENSURE(mpRead, "GeoTexSvxBitmap: Got no read access to Bitmap (!)"); mfMulX = (double)mpRead->Width() / maSize.getX(); mfMulY = (double)mpRead->Height() / maSize.getY(); } - geoTexSvxBitmap::~geoTexSvxBitmap() + GeoTexSvxBitmap::~GeoTexSvxBitmap() { delete mpRead; } - bool geoTexSvxBitmap::impIsValid(const basegfx::B2DPoint& rUV, sal_Int32& rX, sal_Int32& rY) const + bool GeoTexSvxBitmap::impIsValid(const basegfx::B2DPoint& rUV, sal_Int32& rX, sal_Int32& rY) const { if(mpRead) { @@ -1050,7 +1067,7 @@ namespace drawinglayer return false; } - void geoTexSvxBitmap::modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const + void GeoTexSvxBitmap::modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const { sal_Int32 nX, nY; @@ -1064,7 +1081,7 @@ namespace drawinglayer } } - void geoTexSvxBitmap::modifyOpacity(const basegfx::B2DPoint& rUV, double& rfOpacity) const + void GeoTexSvxBitmap::modifyOpacity(const basegfx::B2DPoint& rUV, double& rfOpacity) const { sal_Int32 nX, nY; @@ -1086,7 +1103,7 @@ namespace drawinglayer { namespace texture { - class geoTexSvxBitmapTiled : public geoTexSvxBitmap + class GeoTexSvxBitmapTiled : public GeoTexSvxBitmap { protected: // helpers @@ -1109,34 +1126,29 @@ namespace drawinglayer } public: - geoTexSvxBitmapTiled(const Bitmap& rBitmap, const basegfx::B2DPoint& rTopLeft, const basegfx::B2DVector& rSize); - virtual ~geoTexSvxBitmapTiled(); + GeoTexSvxBitmapTiled(const Bitmap& rBitmap, const basegfx::B2DPoint& rTopLeft, const basegfx::B2DVector& rSize); virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const; virtual void modifyOpacity(const basegfx::B2DPoint& rUV, double& rfOpacity) const; }; - geoTexSvxBitmapTiled::geoTexSvxBitmapTiled(const Bitmap& rBitmap, const basegfx::B2DPoint& rTopLeft, const basegfx::B2DVector& rSize) - : geoTexSvxBitmap(rBitmap, rTopLeft, rSize) + GeoTexSvxBitmapTiled::GeoTexSvxBitmapTiled(const Bitmap& rBitmap, const basegfx::B2DPoint& rTopLeft, const basegfx::B2DVector& rSize) + : GeoTexSvxBitmap(rBitmap, rTopLeft, rSize) { } - geoTexSvxBitmapTiled::~geoTexSvxBitmapTiled() - { - } - - void geoTexSvxBitmapTiled::modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const + void GeoTexSvxBitmapTiled::modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const { if(mpRead) { - geoTexSvxBitmap::modifyBColor(impGetCorrected(rUV), rBColor, rfOpacity); + GeoTexSvxBitmap::modifyBColor(impGetCorrected(rUV), rBColor, rfOpacity); } } - void geoTexSvxBitmapTiled::modifyOpacity(const basegfx::B2DPoint& rUV, double& rfOpacity) const + void GeoTexSvxBitmapTiled::modifyOpacity(const basegfx::B2DPoint& rUV, double& rfOpacity) const { if(mpRead) { - geoTexSvxBitmap::modifyOpacity(impGetCorrected(rUV), rfOpacity); + GeoTexSvxBitmap::modifyOpacity(impGetCorrected(rUV), rfOpacity); } } } // end of namespace texture @@ -1148,14 +1160,14 @@ namespace drawinglayer { namespace texture { - class geoTexSvxMultiHatch : public geoTexSvx + class GeoTexSvxMultiHatch : public GeoTexSvx { protected: - basegfx::BColor maColor; + basegfx::BColor maColor; double mfLogicPixelSize; - geoTexSvxHatch* mp0; - geoTexSvxHatch* mp1; - geoTexSvxHatch* mp2; + GeoTexSvxHatch* mp0; + GeoTexSvxHatch* mp1; + GeoTexSvxHatch* mp2; // bitfield unsigned mbFillBackground : 1; @@ -1164,8 +1176,8 @@ namespace drawinglayer bool impIsOnHatch(const basegfx::B2DPoint& rUV) const; public: - geoTexSvxMultiHatch(const primitive3d::hatchTexturePrimitive3D& rPrimitive, double fLogicPixelSize); - virtual ~geoTexSvxMultiHatch(); + GeoTexSvxMultiHatch(const primitive3d::HatchTexturePrimitive3D& rPrimitive, double fLogicPixelSize); + virtual ~GeoTexSvxMultiHatch(); virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const; virtual void modifyOpacity(const basegfx::B2DPoint& rUV, double& rfOpacity) const; @@ -1173,38 +1185,38 @@ namespace drawinglayer bool getFillBackground() const { return mbFillBackground; } }; - geoTexSvxMultiHatch::geoTexSvxMultiHatch(const primitive3d::hatchTexturePrimitive3D& rPrimitive, double fLogicPixelSize) + GeoTexSvxMultiHatch::GeoTexSvxMultiHatch(const primitive3d::HatchTexturePrimitive3D& rPrimitive, double fLogicPixelSize) : mfLogicPixelSize(fLogicPixelSize), mp0(0L), mp1(0L), mp2(0L) { - const attribute::fillHatchAttribute& rHatch(rPrimitive.getHatch()); + const attribute::FillHatchAttribute& rHatch(rPrimitive.getHatch()); const basegfx::B2DRange aOutlineRange(0.0, 0.0, rPrimitive.getTextureSize().getX(), rPrimitive.getTextureSize().getY()); const double fAngleA(-rHatch.getAngle()); maColor = rHatch.getColor(); mbFillBackground = rHatch.isFillBackground(); - mp0 = new geoTexSvxHatch(aOutlineRange, rHatch.getDistance(), fAngleA); + mp0 = new GeoTexSvxHatch(aOutlineRange, rHatch.getDistance(), fAngleA); if(attribute::HATCHSTYLE_DOUBLE == rHatch.getStyle() || attribute::HATCHSTYLE_TRIPLE == rHatch.getStyle()) { - mp1 = new geoTexSvxHatch(aOutlineRange, rHatch.getDistance(), fAngleA + F_PI2); + mp1 = new GeoTexSvxHatch(aOutlineRange, rHatch.getDistance(), fAngleA + F_PI2); } if(attribute::HATCHSTYLE_TRIPLE == rHatch.getStyle()) { - mp2 = new geoTexSvxHatch(aOutlineRange, rHatch.getDistance(), fAngleA + F_PI4); + mp2 = new GeoTexSvxHatch(aOutlineRange, rHatch.getDistance(), fAngleA + F_PI4); } } - geoTexSvxMultiHatch::~geoTexSvxMultiHatch() + GeoTexSvxMultiHatch::~GeoTexSvxMultiHatch() { delete mp0; delete mp1; delete mp2; } - bool geoTexSvxMultiHatch::impIsOnHatch(const basegfx::B2DPoint& rUV) const + bool GeoTexSvxMultiHatch::impIsOnHatch(const basegfx::B2DPoint& rUV) const { double fSmallestDistance(); @@ -1226,7 +1238,7 @@ namespace drawinglayer return false; } - void geoTexSvxMultiHatch::modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const + void GeoTexSvxMultiHatch::modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const { if(impIsOnHatch(rUV)) { @@ -1238,7 +1250,7 @@ namespace drawinglayer } } - void geoTexSvxMultiHatch::modifyOpacity(const basegfx::B2DPoint& rUV, double& rfOpacity) const + void GeoTexSvxMultiHatch::modifyOpacity(const basegfx::B2DPoint& rUV, double& rfOpacity) const { if(mbFillBackground || impIsOnHatch(rUV)) { @@ -1260,26 +1272,26 @@ namespace drawinglayer { namespace processor3d { - void defaultProcessor3D::impRender_GRX3(const primitive3d::gradientTexturePrimitive3D& rPrimitive, bool bTransparence) + void DefaultProcessor3D::impRender_GRX3(const primitive3d::GradientTexturePrimitive3D& rPrimitive, bool bTransparence) { - const primitive3d::primitiveVector3D& rSubList = rPrimitive.getPrimitives(); + const primitive3d::Primitive3DSequence& rSubSequence = rPrimitive.getChildren(); - if(rSubList.size()) + if(rSubSequence.hasElements()) { // rescue values const bool bOldModulate(mbModulate); mbModulate = rPrimitive.getModulate(); const bool bOldFilter(mbFilter); mbFilter = rPrimitive.getFilter(); - texture::geoTexSvx* pOldTex = (bTransparence) ? mpTransparenceGeoTexSvx : mpGeoTexSvx; + texture::GeoTexSvx* pOldTex = (bTransparence) ? mpTransparenceGeoTexSvx : mpGeoTexSvx; // create texture - const attribute::fillGradientAttribute& rFillGradient = rPrimitive.getGradient(); + const attribute::FillGradientAttribute& rFillGradient = rPrimitive.getGradient(); const basegfx::B2DRange aOutlineRange(0.0, 0.0, rPrimitive.getTextureSize().getX(), rPrimitive.getTextureSize().getY()); const attribute::GradientStyle aGradientStyle(rFillGradient.getStyle()); sal_uInt32 nSteps(rFillGradient.getSteps()); const basegfx::BColor aStart(rFillGradient.getStartColor()); const basegfx::BColor aEnd(rFillGradient.getEndColor()); const sal_uInt32 nMaxSteps(sal_uInt32((aStart.getMaximumDistance(aEnd) * 127.5) + 0.5)); - texture::geoTexSvx* pNewTex = 0L; + texture::GeoTexSvx* pNewTex = 0L; if(nMaxSteps) { @@ -1303,32 +1315,32 @@ namespace drawinglayer { case attribute::GRADIENTSTYLE_LINEAR: { - pNewTex = new texture::geoTexSvxGradientLinear(aOutlineRange, aStart, aEnd, nSteps, rFillGradient.getBorder(), -rFillGradient.getAngle()); + pNewTex = new texture::GeoTexSvxGradientLinear(aOutlineRange, aStart, aEnd, nSteps, rFillGradient.getBorder(), -rFillGradient.getAngle()); break; } case attribute::GRADIENTSTYLE_AXIAL: { - pNewTex = new texture::geoTexSvxGradientAxial(aOutlineRange, aStart, aEnd, nSteps, rFillGradient.getBorder(), -rFillGradient.getAngle()); + pNewTex = new texture::GeoTexSvxGradientAxial(aOutlineRange, aStart, aEnd, nSteps, rFillGradient.getBorder(), -rFillGradient.getAngle()); break; } case attribute::GRADIENTSTYLE_RADIAL: { - pNewTex = new texture::geoTexSvxGradientRadial(aOutlineRange, aStart, aEnd, nSteps, rFillGradient.getBorder(), rFillGradient.getOffsetX(), rFillGradient.getOffsetY()); + pNewTex = new texture::GeoTexSvxGradientRadial(aOutlineRange, aStart, aEnd, nSteps, rFillGradient.getBorder(), rFillGradient.getOffsetX(), rFillGradient.getOffsetY()); break; } case attribute::GRADIENTSTYLE_ELLIPTICAL: { - pNewTex = new texture::geoTexSvxGradientElliptical(aOutlineRange, aStart, aEnd, nSteps, rFillGradient.getBorder(), rFillGradient.getOffsetX(), rFillGradient.getOffsetY(), -rFillGradient.getAngle()); + pNewTex = new texture::GeoTexSvxGradientElliptical(aOutlineRange, aStart, aEnd, nSteps, rFillGradient.getBorder(), rFillGradient.getOffsetX(), rFillGradient.getOffsetY(), -rFillGradient.getAngle()); break; } case attribute::GRADIENTSTYLE_SQUARE: { - pNewTex = new texture::geoTexSvxGradientSquare(aOutlineRange, aStart, aEnd, nSteps, rFillGradient.getBorder(), rFillGradient.getOffsetX(), rFillGradient.getOffsetY(), -rFillGradient.getAngle()); + pNewTex = new texture::GeoTexSvxGradientSquare(aOutlineRange, aStart, aEnd, nSteps, rFillGradient.getBorder(), rFillGradient.getOffsetX(), rFillGradient.getOffsetY(), -rFillGradient.getAngle()); break; } case attribute::GRADIENTSTYLE_RECT: { - pNewTex = new texture::geoTexSvxGradientRect(aOutlineRange, aStart, aEnd, nSteps, rFillGradient.getBorder(), rFillGradient.getOffsetX(), rFillGradient.getOffsetY(), -rFillGradient.getAngle()); + pNewTex = new texture::GeoTexSvxGradientRect(aOutlineRange, aStart, aEnd, nSteps, rFillGradient.getBorder(), rFillGradient.getOffsetX(), rFillGradient.getOffsetY(), -rFillGradient.getAngle()); break; } } @@ -1336,7 +1348,7 @@ namespace drawinglayer else { // no color distance -> same color, use simple texture - pNewTex = new texture::geoTexSvxMono(aStart, 1.0 - aStart.luminance()); + pNewTex = new texture::GeoTexSvxMono(aStart, 1.0 - aStart.luminance()); } // set created texture @@ -1350,7 +1362,7 @@ namespace drawinglayer } // process sub-list - process(rSubList); + process(rSubSequence); // delete texture delete pNewTex; @@ -1370,16 +1382,16 @@ namespace drawinglayer } } - void defaultProcessor3D::impRender_HAX3(const primitive3d::hatchTexturePrimitive3D& rPrimitive) + void DefaultProcessor3D::impRender_HAX3(const primitive3d::HatchTexturePrimitive3D& rPrimitive) { - const primitive3d::primitiveVector3D& rSubList = rPrimitive.getPrimitives(); + const primitive3d::Primitive3DSequence& rSubSequence = rPrimitive.getChildren(); - if(rSubList.size()) + if(rSubSequence.hasElements()) { // rescue values const bool bOldModulate(mbModulate); mbModulate = rPrimitive.getModulate(); const bool bOldFilter(mbFilter); mbFilter = rPrimitive.getFilter(); - texture::geoTexSvx* pOldTex = mpGeoTexSvx; + texture::GeoTexSvx* pOldTex = mpGeoTexSvx; // calculate logic pixel size in world coordinates const basegfx::B3DPoint aZero(maInvWorldToView * basegfx::B3DPoint(0.0, 0.0, 0.0)); @@ -1403,11 +1415,11 @@ namespace drawinglayer const double fLogicTexSize(fLogicTexSizeX > fLogicTexSizeY ? fLogicTexSizeX : fLogicTexSizeY); // create texture and set - texture::geoTexSvxMultiHatch* pNewTex = new texture::geoTexSvxMultiHatch(rPrimitive, fLogicTexSize); + texture::GeoTexSvxMultiHatch* pNewTex = new texture::GeoTexSvxMultiHatch(rPrimitive, fLogicTexSize); mpGeoTexSvx = pNewTex; // process sub-list - process(rSubList); + process(rSubSequence); // delete texture delete mpGeoTexSvx; @@ -1419,37 +1431,37 @@ namespace drawinglayer } } - void defaultProcessor3D::impRender_BMX3(const primitive3d::bitmapTexturePrimitive3D& rPrimitive) + void DefaultProcessor3D::impRender_BMX3(const primitive3d::BitmapTexturePrimitive3D& rPrimitive) { - const primitive3d::primitiveVector3D& rSubList = rPrimitive.getPrimitives(); + const primitive3d::Primitive3DSequence& rSubSequence = rPrimitive.getChildren(); - if(rSubList.size()) + if(rSubSequence.hasElements()) { // rescue values const bool bOldModulate(mbModulate); mbModulate = rPrimitive.getModulate(); const bool bOldFilter(mbFilter); mbFilter = rPrimitive.getFilter(); - texture::geoTexSvx* pOldTex = mpGeoTexSvx; + texture::GeoTexSvx* pOldTex = mpGeoTexSvx; // create texture - const attribute::fillBitmapAttribute& rFillBitmapAttribute = rPrimitive.getBitmap(); + const attribute::FillBitmapAttribute& rFillBitmapAttribute = rPrimitive.getBitmap(); if(rFillBitmapAttribute.getTiling()) { - mpGeoTexSvx = new texture::geoTexSvxBitmapTiled( + mpGeoTexSvx = new texture::GeoTexSvxBitmapTiled( rFillBitmapAttribute.getBitmap(), rFillBitmapAttribute.getTopLeft() * rPrimitive.getTextureSize(), rFillBitmapAttribute.getSize() * rPrimitive.getTextureSize()); } else { - mpGeoTexSvx = new texture::geoTexSvxBitmap( + mpGeoTexSvx = new texture::GeoTexSvxBitmap( rFillBitmapAttribute.getBitmap(), rFillBitmapAttribute.getTopLeft() * rPrimitive.getTextureSize(), rFillBitmapAttribute.getSize() * rPrimitive.getTextureSize()); } // process sub-list - process(rSubList); + process(rSubSequence); // delete texture delete mpGeoTexSvx; @@ -1461,19 +1473,19 @@ namespace drawinglayer } } - void defaultProcessor3D::impRender_MCOL(const primitive3d::modifiedColorPrimitive3D& rModifiedCandidate) + void DefaultProcessor3D::impRender_MCOL(const primitive3d::ModifiedColorPrimitive3D& rModifiedCandidate) { - const primitive3d::primitiveVector3D& rSubList = rModifiedCandidate.getPrimitives(); + const primitive3d::Primitive3DSequence& rSubSequence = rModifiedCandidate.getChildren(); - if(rSubList.size()) + if(rSubSequence.hasElements()) { maBColorModifierStack.push(rModifiedCandidate.getColorModifier()); - process(rModifiedCandidate.getPrimitives()); + process(rModifiedCandidate.getChildren()); maBColorModifierStack.pop(); } } - void defaultProcessor3D::impRender_POH3(const primitive3d::polygonHairlinePrimitive3D& rPrimitive) + void DefaultProcessor3D::impRender_POH3(const primitive3d::PolygonHairlinePrimitive3D& rPrimitive) { basegfx::B3DPolygon aHairline(rPrimitive.getB3DPolygon()); @@ -1491,7 +1503,7 @@ namespace drawinglayer if(a2DRange.overlaps(maRasterRange)) { - const attribute::materialAttribute3D aMaterial(rPrimitive.getBColor()); + const attribute::MaterialAttribute3D aMaterial(rPrimitive.getBColor()); BZPolyRaCon aNewRaCon(false, *mpBZPixelRaster, aMaterial, *this); aNewRaCon.addPolygon(aHairline, maInvEyeToView); aNewRaCon.rasterconvert(0L, mpBZPixelRaster->getHeight()); @@ -1499,7 +1511,7 @@ namespace drawinglayer } } - void defaultProcessor3D::impRender_POM3(const primitive3d::polyPolygonMaterialPrimitive3D& rPrimitive) + void DefaultProcessor3D::impRender_POM3(const primitive3d::PolyPolygonMaterialPrimitive3D& rPrimitive) { basegfx::B3DPolyPolygon aFill(rPrimitive.getB3DPolyPolygon()); basegfx::BColor aObjectColor(rPrimitive.getMaterial().getColor()); @@ -1636,7 +1648,7 @@ namespace drawinglayer if(bPaintIt) { // draw it to ZBuffer - const attribute::materialAttribute3D aMaterial( + const attribute::MaterialAttribute3D aMaterial( aObjectColor, rPrimitive.getMaterial().getSpecular(), rPrimitive.getMaterial().getEmission(), rPrimitive.getMaterial().getSpecularIntensity()); @@ -1651,7 +1663,7 @@ namespace drawinglayer } } - void defaultProcessor3D::impRender_TRN3(const primitive3d::transformPrimitive3D& rTransformCandidate) + void DefaultProcessor3D::impRender_TRN3(const primitive3d::TransformPrimitive3D& rTransformCandidate) { // remember current transformations basegfx::B3DHomMatrix aLastWorldToView(maWorldToView); @@ -1665,7 +1677,7 @@ namespace drawinglayer maInvWorldToView.invert(); // let break down - process(rTransformCandidate.getPrimitives()); + process(rTransformCandidate.getChildren()); // restore transformations maWorldToView = aLastWorldToView; @@ -1673,132 +1685,144 @@ namespace drawinglayer maInvWorldToView = aLastInvWorldToView; } - void defaultProcessor3D::process(const primitive3d::primitiveVector3D& rSource) + void DefaultProcessor3D::process(const primitive3d::Primitive3DSequence& rSource) { - for(sal_uInt32 a(0L); a < rSource.size(); a++) + if(rSource.hasElements()) { - const primitive3d::referencedPrimitive3D& rCandidate = rSource[a]; + const sal_Int32 nCount(rSource.getLength()); - switch(rCandidate.getID()) + for(sal_Int32 a(0L); a < nCount; a++) { - case CreatePrimitiveID('G', 'R', 'X', '3'): - { - // gradientTexturePrimitive3D - const primitive3d::gradientTexturePrimitive3D& rPrimitive = static_cast< const primitive3d::gradientTexturePrimitive3D& >(rCandidate.getBasePrimitive()); - impRender_GRX3(rPrimitive, false); - break; - } + // get reference + const primitive3d::Primitive3DReference xReference(rSource[a]); - case CreatePrimitiveID('H', 'A', 'X', '3'): + if(xReference.is()) { - static bool bDoHatchDecomposition(true); + // try to cast to BasePrimitive3D implementation + const primitive3d::BasePrimitive3D* pBasePrimitive = dynamic_cast< const primitive3d::BasePrimitive3D* >(xReference.get()); - if(bDoHatchDecomposition) + if(pBasePrimitive) { - // let break down - process(rCandidate.getBasePrimitive().getDecomposition()); - } - else - { - // hatchTexturePrimitive3D - const primitive3d::hatchTexturePrimitive3D& rPrimitive = static_cast< const primitive3d::hatchTexturePrimitive3D& >(rCandidate.getBasePrimitive()); - impRender_HAX3(rPrimitive); - } + // it is a BasePrimitive3D implementation, use getPrimitiveID() call for switch + switch(pBasePrimitive->getPrimitiveID()) + { + case Create3DPrimitiveID('3','G','T','e') : + { + // GradientTexturePrimitive3D + const primitive3d::GradientTexturePrimitive3D& rPrimitive = static_cast< const primitive3d::GradientTexturePrimitive3D& >(*pBasePrimitive); + impRender_GRX3(rPrimitive, false); + break; + } + case Create3DPrimitiveID('3','H','T','e') : + { + // HatchTexturePrimitive3D + static bool bDoHatchDecomposition(true); - break; - } + if(bDoHatchDecomposition) + { + // let break down + process(pBasePrimitive->get3DDecomposition(getTime())); + } + else + { + // hatchTexturePrimitive3D + const primitive3d::HatchTexturePrimitive3D& rPrimitive = static_cast< const primitive3d::HatchTexturePrimitive3D& >(*pBasePrimitive); + impRender_HAX3(rPrimitive); + } + break; + } + case Create3DPrimitiveID('3','B','T','e') : + { + // BitmapTexturePrimitive3D + const primitive3d::BitmapTexturePrimitive3D& rPrimitive = static_cast< const primitive3d::BitmapTexturePrimitive3D& >(*pBasePrimitive); + impRender_BMX3(rPrimitive); + break; + } + case Create3DPrimitiveID('3','A','T','e') : + { + // AlphaTexturePrimitive3D + const primitive3d::AlphaTexturePrimitive3D& rPrimitive = static_cast< const primitive3d::AlphaTexturePrimitive3D& >(*pBasePrimitive); - case CreatePrimitiveID('B', 'M', 'X', '3'): - { - // bitmapTexturePrimitive3D - const primitive3d::bitmapTexturePrimitive3D& rPrimitive = static_cast< const primitive3d::bitmapTexturePrimitive3D& >(rCandidate.getBasePrimitive()); - impRender_BMX3(rPrimitive); - break; - } + if(mbProcessTransparent) + { + impRender_GRX3(rPrimitive, true); + } + else + { + mbContainsTransparent = true; + } + break; + } + case Create3DPrimitiveID('3','M','C','o') : + { + // ModifiedColorPrimitive3D + // Force output to unified color. + const primitive3d::ModifiedColorPrimitive3D& rPrimitive = static_cast< const primitive3d::ModifiedColorPrimitive3D& >(*pBasePrimitive); + impRender_MCOL(rPrimitive); + break; + } + case Create3DPrimitiveID('3','P','H','a') : + { + // directdraw of PolygonHairlinePrimitive3D + const primitive3d::PolygonHairlinePrimitive3D& rPrimitive = static_cast< const primitive3d::PolygonHairlinePrimitive3D& >(*pBasePrimitive); - case CreatePrimitiveID('T', 'R', 'X', '3'): - { - // transparenceTexturePrimitive3D - const primitive3d::transparenceTexturePrimitive3D& rPrimitive = static_cast< const primitive3d::transparenceTexturePrimitive3D& >(rCandidate.getBasePrimitive()); + if((bool)mbProcessTransparent == (0L != mpTransparenceGeoTexSvx)) + { + impRender_POH3(rPrimitive); + } + break; + } + case Create3DPrimitiveID('3','P','P','M') : + { + // directdraw of PolyPolygonMaterialPrimitive3D + const primitive3d::PolyPolygonMaterialPrimitive3D& rPrimitive = static_cast< const primitive3d::PolyPolygonMaterialPrimitive3D& >(*pBasePrimitive); - if(mbProcessTransparent) - { - impRender_GRX3(rPrimitive, true); + if((bool)mbProcessTransparent == (0L != mpTransparenceGeoTexSvx)) + { + impRender_POM3(rPrimitive); + } + break; + } + case Create3DPrimitiveID('3','T','r','a') : + { + // transform group (TransformPrimitive3D) + impRender_TRN3(static_cast< const primitive3d::TransformPrimitive3D& >(*pBasePrimitive)); + break; + } + case Create3DPrimitiveID('3','L','a','b') : + { + // SdrLabelPrimitive3D. Accept, but ignore. Is handled by the scenePrimitive decompose + // method which creates 2d text objects at the 3d-projection-dependent positions. + break; + } + default: + { + // process recursively + process(pBasePrimitive->get3DDecomposition(getTime())); + break; + } + } } else { - mbContainsTransparent = true; + // unknown implementation, use UNO API call instead and process recursively + com::sun::star::graphic::Primitive3DParameters aPrimitive3DParameters; + aPrimitive3DParameters.Time = getTime(); + process(xReference->getDecomposition(aPrimitive3DParameters)); } - - break; - } - - case CreatePrimitiveID('M', 'C', 'L', '3'): - { - // modified color group. Force output to unified color. - const primitive3d::modifiedColorPrimitive3D& rPrimitive = static_cast< const primitive3d::modifiedColorPrimitive3D& >(rCandidate.getBasePrimitive()); - impRender_MCOL(rPrimitive); - break; - } - - case CreatePrimitiveID('P', 'O', 'H', '3'): - { - // directdraw of polygonHairlinePrimitive3D - const primitive3d::polygonHairlinePrimitive3D& rPrimitive = static_cast< const primitive3d::polygonHairlinePrimitive3D& >(rCandidate.getBasePrimitive()); - - if((bool)mbProcessTransparent == (0L != mpTransparenceGeoTexSvx)) - { - impRender_POH3(rPrimitive); - } - - break; - } - - case CreatePrimitiveID('P', 'O', 'M', '3'): - { - // directdraw of polyPolygonMaterialPrimitive3D - const primitive3d::polyPolygonMaterialPrimitive3D& rPrimitive = static_cast< const primitive3d::polyPolygonMaterialPrimitive3D& >(rCandidate.getBasePrimitive()); - - if((bool)mbProcessTransparent == (0L != mpTransparenceGeoTexSvx)) - { - impRender_POM3(rPrimitive); - } - - break; - } - - case CreatePrimitiveID('T', 'R', 'N', '3'): - { - // transform group. - impRender_TRN3(static_cast< const primitive3d::transformPrimitive3D& >(rCandidate.getBasePrimitive())); - break; - } - - case CreatePrimitiveID('L', 'A', 'B', '3'): - { - // sdrLabelPrimitive3D. Accept, but ignore. Is handled by the scenePrimitive decompose - // method which creates 2d text objects at the 3d-projection-dependent positions. - break; - } - - default: - { - // let break down - process(rCandidate.getBasePrimitive().getDecomposition()); - break; } } } } - void defaultProcessor3D::processNonTransparent(const primitive3d::primitiveVector3D& rSource) + void DefaultProcessor3D::processNonTransparent(const primitive3d::Primitive3DSequence& rSource) { mbProcessTransparent = false; mbContainsTransparent = false; process(rSource); } - void defaultProcessor3D::processTransparent(const primitive3d::primitiveVector3D& rSource) + void DefaultProcessor3D::processTransparent(const primitive3d::Primitive3DSequence& rSource) { if(mbContainsTransparent) { @@ -1807,17 +1831,17 @@ namespace drawinglayer } } - defaultProcessor3D::defaultProcessor3D( - const geometry::viewInformation& rViewInformation, - const geometry::transformation3D& rTransformation3D, - const attribute::sdrSceneAttribute& rSdrSceneAttribute, - const attribute::sdrLightingAttribute& rsdrLightingAttribute, + DefaultProcessor3D::DefaultProcessor3D( + const geometry::ViewInformation2D& rViewInformation, + const geometry::Transformation3D& rTransformation3D, + const attribute::SdrSceneAttribute& rSdrSceneAttribute, + const attribute::SdrLightingAttribute& rSdrLightingAttribute, double fSizeX, double fSizeY, const basegfx::B2DRange& rVisiblePart) - : baseProcessor3D(rViewInformation, rTransformation3D), + : BaseProcessor3D(rViewInformation.getViewTime()), mrSdrSceneAttribute(rSdrSceneAttribute), - mrSdrLightingAttribute(rsdrLightingAttribute), + mrSdrLightingAttribute(rSdrLightingAttribute), mpGeoTexSvx(0L), mpTransparenceGeoTexSvx(0L), mbModulate(false), @@ -1826,8 +1850,8 @@ namespace drawinglayer mbContainsTransparent(false) { // generate ViewSizes - const double fFullViewSizeX((getViewInformation().getViewTransformation() * basegfx::B2DVector(fSizeX, 0.0)).getLength()); - const double fFullViewSizeY((getViewInformation().getViewTransformation() * basegfx::B2DVector(0.0, fSizeY)).getLength()); + const double fFullViewSizeX((rViewInformation.getViewTransformation() * basegfx::B2DVector(fSizeX, 0.0)).getLength()); + const double fFullViewSizeY((rViewInformation.getViewTransformation() * basegfx::B2DVector(0.0, fSizeY)).getLength()); const double fViewSizeX(fFullViewSizeX * rVisiblePart.getWidth()); const double fViewSizeY(fFullViewSizeY * rVisiblePart.getHeight()); const sal_uInt32 nViewSizeX((sal_uInt32)floor(fViewSizeX)); @@ -1837,7 +1861,7 @@ namespace drawinglayer { // create view unit buffer mpBZPixelRaster = new basegfx::BZPixelRaster(nViewSizeX + 1L, nViewSizeY + 1L); - OSL_ENSURE(mpBZPixelRaster, "defaultProcessor3D: Could not allocate basegfx::BZPixelRaster (!)"); + OSL_ENSURE(mpBZPixelRaster, "DefaultProcessor3D: Could not allocate basegfx::BZPixelRaster (!)"); // create DeviceToView // outcome is [-1.0 .. 1.0] in X,Y and Z. @@ -1865,13 +1889,13 @@ namespace drawinglayer } // create world to eye transformation - maWorldToEye = getTransformation3D().getOrientation() * getTransformation3D().getTransformation(); + maWorldToEye = rTransformation3D.getOrientation() * rTransformation3D.getTransformation(); // create EyeToView transformation - maWorldToView = maDeviceToView * getTransformation3D().getProjection() * maWorldToEye; + maWorldToView = maDeviceToView * rTransformation3D.getProjection() * maWorldToEye; // create inverse EyeToView transformation - maInvEyeToView = maDeviceToView * getTransformation3D().getProjection(); + maInvEyeToView = maDeviceToView * rTransformation3D.getProjection(); maInvEyeToView.invert(); // create inverse WorldToView transformation @@ -1884,7 +1908,7 @@ namespace drawinglayer } } - defaultProcessor3D::~defaultProcessor3D() + DefaultProcessor3D::~DefaultProcessor3D() { if(mpBZPixelRaster) { @@ -1892,7 +1916,7 @@ namespace drawinglayer } } - BitmapEx defaultProcessor3D::getBitmapEx() const + BitmapEx DefaultProcessor3D::getBitmapEx() const { if(mpBZPixelRaster) { diff --git a/drawinglayer/source/processor3d/makefile.mk b/drawinglayer/source/processor3d/makefile.mk index c05046d27daa..e21b74a256cd 100644 --- a/drawinglayer/source/processor3d/makefile.mk +++ b/drawinglayer/source/processor3d/makefile.mk @@ -4,9 +4,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.1 $ +# $Revision: 1.2 $ # -# last change: $Author: aw $ $Date: 2006-08-09 16:57:48 $ +# last change: $Author: aw $ $Date: 2006-10-19 10:39:22 $ # # The Contents of this file are made available subject to # the terms of GNU Lesser General Public License Version 2.1. @@ -36,6 +36,7 @@ PRJ=..$/.. PRJNAME=drawinglayer TARGET=processor3d +ENABLE_EXCEPTIONS=TRUE # --- Settings ---------------------------------- @@ -46,8 +47,11 @@ TARGET=processor3d SLOFILES= \ $(SLO)$/baseprocessor3d.obj \ $(SLO)$/defaultprocessor3d.obj \ - $(SLO)$/shadow3dextractor.obj \ - $(SLO)$/label3dextractor.obj + $(SLO)$/label3dextractor.obj \ + $(SLO)$/shadow3dextractor.obj + + + # --- Targets ---------------------------------- diff --git a/drawinglayer/source/processor3d/shadow3dextractor.cxx b/drawinglayer/source/processor3d/shadow3dextractor.cxx index c9a0d854061d..6dc2383681b8 100644 --- a/drawinglayer/source/processor3d/shadow3dextractor.cxx +++ b/drawinglayer/source/processor3d/shadow3dextractor.cxx @@ -4,9 +4,9 @@ * * $RCSfile: shadow3dextractor.cxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: aw $ $Date: 2006-08-09 16:57:48 $ + * last change: $Author: aw $ $Date: 2006-10-19 10:39:22 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -33,23 +33,27 @@ * ************************************************************************/ -#ifndef _DRAWINGLAYER_PROCESSOR3D_SHADOW3DEXTRACTOR_HXX +#ifndef INCLUDED_DRAWINGLAYER_PROCESSOR3D_SHADOW3DEXTRACTOR_HXX #include <drawinglayer/processor3d/shadow3dextractor.hxx> #endif -#ifndef _DRAWINGLAYER_PRIMITIVE3D_SHADOWPRIMITIVE3D_HXX +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SHADOWPRIMITIVE3D_HXX #include <drawinglayer/primitive3d/shadowprimitive3d.hxx> #endif -#ifndef _DRAWINGLAYER_PRIMITIVE_SHADOWPRIMITIVE_HXX -#include <drawinglayer/primitive/shadowprimitive.hxx> +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_SHADOWPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/shadowprimitive2d.hxx> #endif -#ifndef _DRAWINGLAYER_PRIMITIVE3D_TRANSFORMPRIMITIVE3D_HXX +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_UNIFIEDALPHAPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/unifiedalphaprimitive2d.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_TRANSFORMPRIMITIVE3D_HXX #include <drawinglayer/primitive3d/transformprimitive3d.hxx> #endif -#ifndef _DRAWINGLAYER_PRIMITIVE3D_POLYGONPRIMITIVE3D_HXX +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_POLYGONPRIMITIVE3D_HXX #include <drawinglayer/primitive3d/polygonprimitive3d.hxx> #endif @@ -57,7 +61,11 @@ #include <basegfx/polygon/b2dpolygontools.hxx> #endif -#ifndef _DRAWINGLAYER_PRIMITIVE3D_POLYPOLYGONPRIMITIVE_HXX +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_POLYGONPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/polygonprimitive2d.hxx> +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_POLYPOLYGONPRIMITIVE3D_HXX #include <drawinglayer/primitive3d/polypolygonprimitive3d.hxx> #endif @@ -65,25 +73,17 @@ #include <basegfx/polygon/b2dpolypolygontools.hxx> #endif -#ifndef _DRAWINGLAYER_GEOMETRY_TRANSFORMATION3D_HXX -#include <drawinglayer/geometry/transformation3d.hxx> +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_POLYPOLYGONPRIMITIVE2D_HXX +#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx> #endif -#ifndef _DRAWINGLAYER_ATTRIBUTE_SDRATTRIBUTE3D_HXX -#include <drawinglayer/attribute/sdrattribute3d.hxx> +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDRLABELPRIMITIVE3D_HXX +#include <drawinglayer/primitive3d/sdrlabelprimitive3d.hxx> #endif -#ifndef _DRAWINGLAYER_PRIMITIVE_SIMPLETRANSPARENCEPRIMITIVE_HXX -#include <drawinglayer/primitive/simpletransparenceprimitive.hxx> -#endif - -#ifndef _DRAWINGLAYER_PRIMITIVE_POLYGONPRIMITIVE_HXX -#include <drawinglayer/primitive/polygonprimitive.hxx> -#endif +////////////////////////////////////////////////////////////////////////////// -#ifndef _DRAWINGLAYER_PRIMITIVE_POLYPOLYGONPRIMITIVE_HXX -#include <drawinglayer/primitive/polypolygonprimitive.hxx> -#endif +using namespace com::sun::star; ////////////////////////////////////////////////////////////////////////////// @@ -91,14 +91,16 @@ namespace drawinglayer { namespace processor3d { - shadow3DExtractingProcessor::shadow3DExtractingProcessor( - const geometry::viewInformation& rViewInformation, - const geometry::transformation3D& rTransformation3D, - const attribute::sdrLightingAttribute& rSdrLightingAttribute, - const primitive3d::primitiveVector3D& rPrimitiveVector, + Shadow3DExtractingProcessor::Shadow3DExtractingProcessor( + double fTime, + const geometry::Transformation3D& rTransformation3D, + const attribute::SdrLightingAttribute& rSdrLightingAttribute, + const primitive3d::Primitive3DSequence& rPrimitiveSequence, double fShadowSlant) - : baseProcessor3D(rViewInformation, rTransformation3D), - mpTargetVector(&maPrimitiveVector), + : BaseProcessor3D(fTime), + maPrimitive2DSequence(), + mpPrimitive2DSequence(&maPrimitive2DSequence), + maTransformation3D(rTransformation3D), mbShadowProjectionIsValid(false), mbConvert(false), mbUseProjection(false) @@ -126,10 +128,10 @@ namespace drawinglayer maShadowPlaneNormal.normalize(); mfLightPlaneScalar = maLightNormal.scalar(maShadowPlaneNormal); + // use only when scalar is > 0.0, so the light is in front of the object if(basegfx::fTools::more(mfLightPlaneScalar, 0.0)) { - // use only when scalar is > 0.0, so the light is in front of the object - basegfx::B3DRange aContained3DRange(get3DRangeFromVector(rPrimitiveVector)); + basegfx::B3DRange aContained3DRange(primitive3d::getB3DRangeFromPrimitive3DSequence(rPrimitiveSequence, getTime())); aContained3DRange.transform(maWorldToEye); maPlanePoint.setX(maShadowPlaneNormal.getX() < 0.0 ? aContained3DRange.getMinX() : aContained3DRange.getMaxX()); maPlanePoint.setY(maShadowPlaneNormal.getY() > 0.0 ? aContained3DRange.getMinY() : aContained3DRange.getMaxY()); @@ -141,164 +143,174 @@ namespace drawinglayer } } - shadow3DExtractingProcessor::~shadow3DExtractingProcessor() + void Shadow3DExtractingProcessor::process(const primitive3d::Primitive3DSequence& rSource) { - } - - void shadow3DExtractingProcessor::process(const primitive3d::primitiveVector3D& rSource) - { - for(sal_uInt32 a(0L); a < rSource.size(); a++) + if(rSource.hasElements()) { - // get reference - const primitive3d::referencedPrimitive3D& rCandidate = rSource[a]; + const sal_Int32 nCount(rSource.getLength()); - switch(rCandidate.getID()) + for(sal_Int32 a(0L); a < nCount; a++) { - case CreatePrimitiveID('S', 'H', 'D', '3'): - { - // shadow3d object. Call recursive with content and start conversion - const primitive3d::shadowPrimitive3D& rPrimitive = static_cast< const primitive3d::shadowPrimitive3D& >(rCandidate.getBasePrimitive()); - - // set new target - primitive::primitiveVector aNewSubList; - primitive::primitiveVector* pLastTargetVector = mpTargetVector; - mpTargetVector = &aNewSubList; - - // activate convert - const bool bLastConvert(mbConvert); - mbConvert = true; - - // set projection flag - const bool bLastUseProjection(mbUseProjection); - mbUseProjection = rPrimitive.getShadow3D(); - - // process content - process(rPrimitive.getPrimitives()); + // get reference + const primitive3d::Primitive3DReference xReference(rSource[a]); - // restore values - mbUseProjection = bLastUseProjection; - mbConvert = bLastConvert; - mpTargetVector = pLastTargetVector; - - // create 2d shadow primitive with result - primitive::shadowPrimitive* pNew = new primitive::shadowPrimitive(rPrimitive.getShadowTransform(), rPrimitive.getShadowColor(), aNewSubList); - - if(basegfx::fTools::more(rPrimitive.getShadowTransparence(), 0.0)) - { - // create simpleTransparencePrimitive, add created primitives - primitive::primitiveVector aNewTransPrimitiveVector; - aNewTransPrimitiveVector.push_back(primitive::referencedPrimitive(*pNew)); - primitive::simpleTransparencePrimitive* pNewTrans = new primitive::simpleTransparencePrimitive(rPrimitive.getShadowTransparence(), aNewTransPrimitiveVector); - mpTargetVector->push_back(primitive::referencedPrimitive(*pNewTrans)); - } - else - { - // add directly - mpTargetVector->push_back(primitive::referencedPrimitive(*pNew)); - } - - break; - } - - case CreatePrimitiveID('T', 'R', 'N', '3'): + if(xReference.is()) { - // transform group. Remember current transformations - const primitive3d::transformPrimitive3D& rPrimitive = static_cast< const primitive3d::transformPrimitive3D& >(rCandidate.getBasePrimitive()); - basegfx::B3DHomMatrix aLastWorldToView(maWorldToView); - basegfx::B3DHomMatrix aLastWorldToEye(maWorldToEye); - - // create new transformations - maWorldToView = maWorldToView * rPrimitive.getTransformation(); - maWorldToEye = maWorldToEye * rPrimitive.getTransformation(); - - // let break down - process(rPrimitive.getPrimitives()); - - // restore transformations - maWorldToView = aLastWorldToView; - maWorldToEye = aLastWorldToEye; - break; - } + // try to cast to BasePrimitive3D implementation + const primitive3d::BasePrimitive3D* pBasePrimitive = dynamic_cast< const primitive3d::BasePrimitive3D* >(xReference.get()); - case CreatePrimitiveID('P', 'O', 'H', '3'): - { - // polygonHairlinePrimitive3D - if(mbConvert) + if(pBasePrimitive) { - const primitive3d::polygonHairlinePrimitive3D& rPrimitive = static_cast< const primitive3d::polygonHairlinePrimitive3D& >(rCandidate.getBasePrimitive()); - basegfx::B2DPolygon a2DHairline; - - if(mbUseProjection) + // it is a BasePrimitive3D implementation, use getPrimitiveID() call for switch + switch(pBasePrimitive->getPrimitiveID()) { - if(mbShadowProjectionIsValid) + case Create3DPrimitiveID('3','S','h','a') : { - a2DHairline = impDoShadowProjection(rPrimitive.getB3DPolygon()); + // shadow3d object. Call recursive with content and start conversion + const primitive3d::ShadowPrimitive3D& rPrimitive = static_cast< const primitive3d::ShadowPrimitive3D& >(*pBasePrimitive); + + // set new target + primitive2d::Primitive2DSequence aNewSubList; + primitive2d::Primitive2DSequence* pLastTargetSequence = mpPrimitive2DSequence; + mpPrimitive2DSequence = &aNewSubList; + + // activate convert + const bool bLastConvert(mbConvert); + mbConvert = true; + + // set projection flag + const bool bLastUseProjection(mbUseProjection); + mbUseProjection = rPrimitive.getShadow3D(); + + // process content + process(rPrimitive.getChildren()); + + // restore values + mbUseProjection = bLastUseProjection; + mbConvert = bLastConvert; + mpPrimitive2DSequence = pLastTargetSequence; + + // create 2d shadow primitive with result + const primitive2d::Primitive2DReference xRef(new primitive2d::ShadowPrimitive2D(rPrimitive.getShadowTransform(), rPrimitive.getShadowColor(), aNewSubList)); + + if(basegfx::fTools::more(rPrimitive.getShadowTransparence(), 0.0)) + { + // create simpleTransparencePrimitive, add created primitives + const primitive2d::Primitive2DSequence aNewTransPrimitiveVector(&xRef, 1L); + const primitive2d::Primitive2DReference xRef2(new primitive2d::UnifiedAlphaPrimitive2D(aNewTransPrimitiveVector, rPrimitive.getShadowTransparence())); + primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(*mpPrimitive2DSequence, xRef2); + } + else + { + // add directly + primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(*mpPrimitive2DSequence, xRef); + } + break; } - } - else - { - a2DHairline = basegfx::tools::createB2DPolygonFromB3DPolygon(rPrimitive.getB3DPolygon(), maWorldToView); - } - - if(a2DHairline.count()) - { - a2DHairline.transform(getTransformation3D().getObjectTransformation()); - primitive::polygonHairlinePrimitive* pNew = new primitive::polygonHairlinePrimitive(a2DHairline, maPrimitiveColor); - mpTargetVector->push_back(primitive::referencedPrimitive(*pNew)); - } - } - - break; - } - - case CreatePrimitiveID('P', 'O', 'M', '3'): - { - // polyPolygonMaterialPrimitive3D - if(mbConvert) - { - const primitive3d::polyPolygonMaterialPrimitive3D& rPrimitive = static_cast< const primitive3d::polyPolygonMaterialPrimitive3D& >(rCandidate.getBasePrimitive()); - basegfx::B2DPolyPolygon a2DFill; - - if(mbUseProjection) - { - if(mbShadowProjectionIsValid) + case Create3DPrimitiveID('3','T','r','a') : { - a2DFill = impDoShadowProjection(rPrimitive.getB3DPolyPolygon()); + // transform group. Remember current transformations + const primitive3d::TransformPrimitive3D& rPrimitive = static_cast< const primitive3d::TransformPrimitive3D& >(*pBasePrimitive); + basegfx::B3DHomMatrix aLastWorldToView(maWorldToView); + basegfx::B3DHomMatrix aLastWorldToEye(maWorldToEye); + + // create new transformations + maWorldToView = maWorldToView * rPrimitive.getTransformation(); + maWorldToEye = maWorldToEye * rPrimitive.getTransformation(); + + // let break down + process(rPrimitive.getChildren()); + + // restore transformations + maWorldToView = aLastWorldToView; + maWorldToEye = aLastWorldToEye; + break; + } + case Create3DPrimitiveID('3','P','H','a') : + { + // PolygonHairlinePrimitive3D + if(mbConvert) + { + const primitive3d::PolygonHairlinePrimitive3D& rPrimitive = static_cast< const primitive3d::PolygonHairlinePrimitive3D& >(*pBasePrimitive); + basegfx::B2DPolygon a2DHairline; + + if(mbUseProjection) + { + if(mbShadowProjectionIsValid) + { + a2DHairline = impDoShadowProjection(rPrimitive.getB3DPolygon()); + } + } + else + { + a2DHairline = basegfx::tools::createB2DPolygonFromB3DPolygon(rPrimitive.getB3DPolygon(), maWorldToView); + } + + if(a2DHairline.count()) + { + a2DHairline.transform(getTransformation3D().getObjectTransformation()); + const primitive2d::Primitive2DReference xRef(new primitive2d::PolygonHairlinePrimitive2D(a2DHairline, maPrimitiveColor)); + primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(*mpPrimitive2DSequence, xRef); + } + } + break; + } + case Create3DPrimitiveID('3','P','P','M') : + { + // PolyPolygonMaterialPrimitive3D + if(mbConvert) + { + const primitive3d::PolyPolygonMaterialPrimitive3D& rPrimitive = static_cast< const primitive3d::PolyPolygonMaterialPrimitive3D& >(*pBasePrimitive); + basegfx::B2DPolyPolygon a2DFill; + + if(mbUseProjection) + { + if(mbShadowProjectionIsValid) + { + a2DFill = impDoShadowProjection(rPrimitive.getB3DPolyPolygon()); + } + } + else + { + a2DFill = basegfx::tools::createB2DPolyPolygonFromB3DPolyPolygon(rPrimitive.getB3DPolyPolygon(), maWorldToView); + } + + if(a2DFill.count()) + { + a2DFill.transform(getTransformation3D().getObjectTransformation()); + const primitive2d::Primitive2DReference xRef(new primitive2d::PolyPolygonColorPrimitive2D(a2DFill, maPrimitiveColor)); + primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(*mpPrimitive2DSequence, xRef); + } + } + break; + } + case Create3DPrimitiveID('3','L','a','b') : + { + // SdrLabelPrimitive3D + // has no 3d shadow, accept and ignore + break; + } + default : + { + // process recursively + process(pBasePrimitive->get3DDecomposition(getTime())); + break; } - } - else - { - a2DFill = basegfx::tools::createB2DPolyPolygonFromB3DPolyPolygon(rPrimitive.getB3DPolyPolygon(), maWorldToView); - } - - if(a2DFill.count()) - { - a2DFill.transform(getTransformation3D().getObjectTransformation()); - primitive::polyPolygonColorPrimitive* pNew = new primitive::polyPolygonColorPrimitive(a2DFill, maPrimitiveColor); - mpTargetVector->push_back(primitive::referencedPrimitive(*pNew)); } } - - break; - } - - case CreatePrimitiveID('L', 'A', 'B', '3'): - { - // has no 3d shadow, accept and ignore - break; - } - - default: - { - // let break down - process(rCandidate.getBasePrimitive().getDecomposition()); - break; + else + { + // unknown implementation, use UNO API call instead and process recursively + com::sun::star::graphic::Primitive3DParameters aPrimitive3DParameters; + aPrimitive3DParameters.Time = getTime(); + process(xReference->getDecomposition(aPrimitive3DParameters)); + } } } } } - basegfx::B2DPolygon shadow3DExtractingProcessor::impDoShadowProjection(const basegfx::B3DPolygon& rSource) + basegfx::B2DPolygon Shadow3DExtractingProcessor::impDoShadowProjection(const basegfx::B3DPolygon& rSource) { basegfx::B2DPolygon aRetval; @@ -327,7 +339,7 @@ namespace drawinglayer return aRetval; } - basegfx::B2DPolyPolygon shadow3DExtractingProcessor::impDoShadowProjection(const basegfx::B3DPolyPolygon& rSource) + basegfx::B2DPolyPolygon Shadow3DExtractingProcessor::impDoShadowProjection(const basegfx::B3DPolyPolygon& rSource) { basegfx::B2DPolyPolygon aRetval; diff --git a/drawinglayer/source/texture/texture.cxx b/drawinglayer/source/texture/texture.cxx index 60e3042f6b31..b836ab854ad5 100644 --- a/drawinglayer/source/texture/texture.cxx +++ b/drawinglayer/source/texture/texture.cxx @@ -4,9 +4,9 @@ * * $RCSfile: texture.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: aw $ $Date: 2006-09-27 16:33:43 $ + * last change: $Author: aw $ $Date: 2006-10-19 10:39:34 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -33,7 +33,7 @@ * ************************************************************************/ -#ifndef _DRAWINGLAYER_TEXTURE_TEXTURE_HXX +#ifndef INCLUDED_DRAWINGLAYER_TEXTURE_TEXTURE_HXX #include <drawinglayer/texture/texture.hxx> #endif @@ -47,26 +47,26 @@ namespace drawinglayer { namespace texture { - geoTexSvx::geoTexSvx() + GeoTexSvx::GeoTexSvx() { } - geoTexSvx::~geoTexSvx() + GeoTexSvx::~GeoTexSvx() { } - bool geoTexSvx::operator==(const geoTexSvx& /*rGeoTexSvx*/) const + bool GeoTexSvx::operator==(const GeoTexSvx& /*rGeoTexSvx*/) const { // default implementation says yes (no data -> no difference) return true; } - void geoTexSvx::appendTransformations(::std::vector< basegfx::B2DHomMatrix >& /*rMatrices*/) + void GeoTexSvx::appendTransformations(::std::vector< basegfx::B2DHomMatrix >& /*rMatrices*/) { // default implementation does nothing } - void geoTexSvx::modifyBColor(const basegfx::B2DPoint& /*rUV*/, basegfx::BColor& rBColor, double& /*rfOpacity*/) const + void GeoTexSvx::modifyBColor(const basegfx::B2DPoint& /*rUV*/, basegfx::BColor& rBColor, double& /*rfOpacity*/) const { // base implementation creates random color (for testing only, may also be pure virtual) rBColor.setRed((rand() & 0x7fff) / 32767.0); @@ -74,7 +74,7 @@ namespace drawinglayer rBColor.setBlue((rand() & 0x7fff) / 32767.0); } - void geoTexSvx::modifyOpacity(const basegfx::B2DPoint& rUV, double& rfOpacity) const + void GeoTexSvx::modifyOpacity(const basegfx::B2DPoint& rUV, double& rfOpacity) const { // base implementation uses inverse of luminance of solved color basegfx::BColor aBaseColor; @@ -90,7 +90,7 @@ namespace drawinglayer { namespace texture { - void geoTexSvxGradient::impAppendMatrix(::std::vector< basegfx::B2DHomMatrix >& rMatrices, const basegfx::B2DRange& rRange) + void GeoTexSvxGradient::impAppendMatrix(::std::vector< basegfx::B2DHomMatrix >& rMatrices, const basegfx::B2DRange& rRange) { basegfx::B2DHomMatrix aNew; aNew.set(0, 0, rRange.getWidth()); @@ -100,7 +100,7 @@ namespace drawinglayer rMatrices.push_back(maTextureTransform * aNew); } - void geoTexSvxGradient::impAppendColorsRadial(::std::vector< basegfx::BColor >& rColors) + void GeoTexSvxGradient::impAppendColorsRadial(::std::vector< basegfx::BColor >& rColors) { if(mnSteps) { @@ -115,7 +115,7 @@ namespace drawinglayer } } - geoTexSvxGradient::geoTexSvxGradient(const basegfx::B2DRange& rTargetRange, const basegfx::BColor& rStart, const basegfx::BColor& rEnd, sal_uInt32 nSteps, double fBorder) + GeoTexSvxGradient::GeoTexSvxGradient(const basegfx::B2DRange& rTargetRange, const basegfx::BColor& rStart, const basegfx::BColor& rEnd, sal_uInt32 nSteps, double fBorder) : maTargetRange(rTargetRange), maStart(rStart), maEnd(rEnd), @@ -125,13 +125,13 @@ namespace drawinglayer { } - geoTexSvxGradient::~geoTexSvxGradient() + GeoTexSvxGradient::~GeoTexSvxGradient() { } - bool geoTexSvxGradient::operator==(const geoTexSvx& rGeoTexSvx) const + bool GeoTexSvxGradient::operator==(const GeoTexSvx& rGeoTexSvx) const { - const geoTexSvxGradient* pCompare = dynamic_cast< const geoTexSvxGradient* >(&rGeoTexSvx); + const GeoTexSvxGradient* pCompare = dynamic_cast< const GeoTexSvxGradient* >(&rGeoTexSvx); return (pCompare && maTextureTransform == pCompare->maTextureTransform && maTargetRange == pCompare->maTargetRange @@ -148,8 +148,8 @@ namespace drawinglayer { namespace texture { - geoTexSvxGradientLinear::geoTexSvxGradientLinear(const basegfx::B2DRange& rTargetRange, const basegfx::BColor& rStart, const basegfx::BColor& rEnd, sal_uInt32 nSteps, double fBorder, double fAngle) - : geoTexSvxGradient(rTargetRange, rStart, rEnd, nSteps, fBorder) + GeoTexSvxGradientLinear::GeoTexSvxGradientLinear(const basegfx::B2DRange& rTargetRange, const basegfx::BColor& rStart, const basegfx::BColor& rEnd, sal_uInt32 nSteps, double fBorder, double fAngle) + : GeoTexSvxGradient(rTargetRange, rStart, rEnd, nSteps, fBorder) { double fTargetSizeX(maTargetRange.getWidth()); double fTargetSizeY(maTargetRange.getHeight()); @@ -201,11 +201,11 @@ namespace drawinglayer } } - geoTexSvxGradientLinear::~geoTexSvxGradientLinear() + GeoTexSvxGradientLinear::~GeoTexSvxGradientLinear() { } - void geoTexSvxGradientLinear::appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices) + void GeoTexSvxGradientLinear::appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices) { if(mnSteps) { @@ -223,7 +223,7 @@ namespace drawinglayer } } - void geoTexSvxGradientLinear::appendColors(::std::vector< basegfx::BColor >& rColors) + void GeoTexSvxGradientLinear::appendColors(::std::vector< basegfx::BColor >& rColors) { if(mnSteps) { @@ -236,7 +236,7 @@ namespace drawinglayer } } - void geoTexSvxGradientLinear::modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& /*rfOpacity*/) const + void GeoTexSvxGradientLinear::modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& /*rfOpacity*/) const { const basegfx::B2DPoint aCoor(maBackTextureTransform * rUV); @@ -270,8 +270,8 @@ namespace drawinglayer { namespace texture { - geoTexSvxGradientAxial::geoTexSvxGradientAxial(const basegfx::B2DRange& rTargetRange, const basegfx::BColor& rStart, const basegfx::BColor& rEnd, sal_uInt32 nSteps, double fBorder, double fAngle) - : geoTexSvxGradient(rTargetRange, rStart, rEnd, nSteps, fBorder) + GeoTexSvxGradientAxial::GeoTexSvxGradientAxial(const basegfx::B2DRange& rTargetRange, const basegfx::BColor& rStart, const basegfx::BColor& rEnd, sal_uInt32 nSteps, double fBorder, double fAngle) + : GeoTexSvxGradient(rTargetRange, rStart, rEnd, nSteps, fBorder) { double fTargetSizeX(maTargetRange.getWidth()); double fTargetSizeY(maTargetRange.getHeight()); @@ -326,11 +326,11 @@ namespace drawinglayer mfInternalSteps = (double)((mnSteps * 2L) - 1L); } - geoTexSvxGradientAxial::~geoTexSvxGradientAxial() + GeoTexSvxGradientAxial::~GeoTexSvxGradientAxial() { } - void geoTexSvxGradientAxial::appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices) + void GeoTexSvxGradientAxial::appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices) { if(mnSteps) { @@ -350,7 +350,7 @@ namespace drawinglayer } } - void geoTexSvxGradientAxial::appendColors(::std::vector< basegfx::BColor >& rColors) + void GeoTexSvxGradientAxial::appendColors(::std::vector< basegfx::BColor >& rColors) { if(mnSteps) { @@ -363,7 +363,7 @@ namespace drawinglayer } } - void geoTexSvxGradientAxial::modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& /*rfOpacity*/) const + void GeoTexSvxGradientAxial::modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& /*rfOpacity*/) const { const basegfx::B2DPoint aCoor(maBackTextureTransform * rUV); const double fAbsY(fabs(aCoor.getY())); @@ -392,8 +392,8 @@ namespace drawinglayer { namespace texture { - geoTexSvxGradientRadial::geoTexSvxGradientRadial(const basegfx::B2DRange& rTargetRange, const basegfx::BColor& rStart, const basegfx::BColor& rEnd, sal_uInt32 nSteps, double fBorder, double fOffsetX, double fOffsetY) - : geoTexSvxGradient(rTargetRange, rStart, rEnd, nSteps, fBorder) + GeoTexSvxGradientRadial::GeoTexSvxGradientRadial(const basegfx::B2DRange& rTargetRange, const basegfx::BColor& rStart, const basegfx::BColor& rEnd, sal_uInt32 nSteps, double fBorder, double fOffsetX, double fOffsetY) + : GeoTexSvxGradient(rTargetRange, rStart, rEnd, nSteps, fBorder) { double fTargetSizeX(maTargetRange.getWidth()); double fTargetSizeY(maTargetRange.getHeight()); @@ -437,11 +437,11 @@ namespace drawinglayer } } - geoTexSvxGradientRadial::~geoTexSvxGradientRadial() + GeoTexSvxGradientRadial::~GeoTexSvxGradientRadial() { } - void geoTexSvxGradientRadial::appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices) + void GeoTexSvxGradientRadial::appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices) { if(mnSteps) { @@ -478,12 +478,12 @@ namespace drawinglayer } } - void geoTexSvxGradientRadial::appendColors(::std::vector< basegfx::BColor >& rColors) + void GeoTexSvxGradientRadial::appendColors(::std::vector< basegfx::BColor >& rColors) { impAppendColorsRadial(rColors); } - void geoTexSvxGradientRadial::modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& /*rfOpacity*/) const + void GeoTexSvxGradientRadial::modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& /*rfOpacity*/) const { const basegfx::B2DPoint aCoor(maBackTextureTransform * rUV); const double fDist(aCoor.getX() * aCoor.getX() + aCoor.getY() * aCoor.getY()); @@ -512,8 +512,8 @@ namespace drawinglayer { namespace texture { - geoTexSvxGradientElliptical::geoTexSvxGradientElliptical(const basegfx::B2DRange& rTargetRange, const basegfx::BColor& rStart, const basegfx::BColor& rEnd, sal_uInt32 nSteps, double fBorder, double fOffsetX, double fOffsetY, double fAngle) - : geoTexSvxGradient(rTargetRange, rStart, rEnd, nSteps, fBorder) + GeoTexSvxGradientElliptical::GeoTexSvxGradientElliptical(const basegfx::B2DRange& rTargetRange, const basegfx::BColor& rStart, const basegfx::BColor& rEnd, sal_uInt32 nSteps, double fBorder, double fOffsetX, double fOffsetY, double fAngle) + : GeoTexSvxGradient(rTargetRange, rStart, rEnd, nSteps, fBorder) { double fTargetSizeX(maTargetRange.getWidth()); double fTargetSizeY(maTargetRange.getHeight()); @@ -567,11 +567,11 @@ namespace drawinglayer } } - geoTexSvxGradientElliptical::~geoTexSvxGradientElliptical() + GeoTexSvxGradientElliptical::~GeoTexSvxGradientElliptical() { } - void geoTexSvxGradientElliptical::appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices) + void GeoTexSvxGradientElliptical::appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices) { if(mnSteps) { @@ -608,12 +608,12 @@ namespace drawinglayer } } - void geoTexSvxGradientElliptical::appendColors(::std::vector< basegfx::BColor >& rColors) + void GeoTexSvxGradientElliptical::appendColors(::std::vector< basegfx::BColor >& rColors) { impAppendColorsRadial(rColors); } - void geoTexSvxGradientElliptical::modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& /*rfOpacity*/) const + void GeoTexSvxGradientElliptical::modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& /*rfOpacity*/) const { const basegfx::B2DPoint aCoor(maBackTextureTransform * rUV); const double fDist(aCoor.getX() * aCoor.getX() + aCoor.getY() * aCoor.getY()); @@ -642,8 +642,8 @@ namespace drawinglayer { namespace texture { - geoTexSvxGradientSquare::geoTexSvxGradientSquare(const basegfx::B2DRange& rTargetRange, const basegfx::BColor& rStart, const basegfx::BColor& rEnd, sal_uInt32 nSteps, double fBorder, double fOffsetX, double fOffsetY, double fAngle) - : geoTexSvxGradient(rTargetRange, rStart, rEnd, nSteps, fBorder) + GeoTexSvxGradientSquare::GeoTexSvxGradientSquare(const basegfx::B2DRange& rTargetRange, const basegfx::BColor& rStart, const basegfx::BColor& rEnd, sal_uInt32 nSteps, double fBorder, double fOffsetX, double fOffsetY, double fAngle) + : GeoTexSvxGradient(rTargetRange, rStart, rEnd, nSteps, fBorder) { double fTargetSizeX(maTargetRange.getWidth()); double fTargetSizeY(maTargetRange.getHeight()); @@ -704,11 +704,11 @@ namespace drawinglayer } } - geoTexSvxGradientSquare::~geoTexSvxGradientSquare() + GeoTexSvxGradientSquare::~GeoTexSvxGradientSquare() { } - void geoTexSvxGradientSquare::appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices) + void GeoTexSvxGradientSquare::appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices) { if(mnSteps) { @@ -753,12 +753,12 @@ namespace drawinglayer } } - void geoTexSvxGradientSquare::appendColors(::std::vector< basegfx::BColor >& rColors) + void GeoTexSvxGradientSquare::appendColors(::std::vector< basegfx::BColor >& rColors) { impAppendColorsRadial(rColors); } - void geoTexSvxGradientSquare::modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& /*rfOpacity*/) const + void GeoTexSvxGradientSquare::modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& /*rfOpacity*/) const { const basegfx::B2DPoint aCoor(maBackTextureTransform * rUV); const double fAbsX(fabs(aCoor.getX())); @@ -788,8 +788,8 @@ namespace drawinglayer { namespace texture { - geoTexSvxGradientRect::geoTexSvxGradientRect(const basegfx::B2DRange& rTargetRange, const basegfx::BColor& rStart, const basegfx::BColor& rEnd, sal_uInt32 nSteps, double fBorder, double fOffsetX, double fOffsetY, double fAngle) - : geoTexSvxGradient(rTargetRange, rStart, rEnd, nSteps, fBorder) + GeoTexSvxGradientRect::GeoTexSvxGradientRect(const basegfx::B2DRange& rTargetRange, const basegfx::BColor& rStart, const basegfx::BColor& rEnd, sal_uInt32 nSteps, double fBorder, double fOffsetX, double fOffsetY, double fAngle) + : GeoTexSvxGradient(rTargetRange, rStart, rEnd, nSteps, fBorder) { double fTargetSizeX(maTargetRange.getWidth()); double fTargetSizeY(maTargetRange.getHeight()); @@ -850,11 +850,11 @@ namespace drawinglayer } } - geoTexSvxGradientRect::~geoTexSvxGradientRect() + GeoTexSvxGradientRect::~GeoTexSvxGradientRect() { } - void geoTexSvxGradientRect::appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices) + void GeoTexSvxGradientRect::appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices) { if(mnSteps) { @@ -891,12 +891,12 @@ namespace drawinglayer } } - void geoTexSvxGradientRect::appendColors(::std::vector< basegfx::BColor >& rColors) + void GeoTexSvxGradientRect::appendColors(::std::vector< basegfx::BColor >& rColors) { impAppendColorsRadial(rColors); } - void geoTexSvxGradientRect::modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& /*rfOpacity*/) const + void GeoTexSvxGradientRect::modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& /*rfOpacity*/) const { const basegfx::B2DPoint aCoor(maBackTextureTransform * rUV); const double fAbsX(fabs(aCoor.getX())); @@ -926,7 +926,7 @@ namespace drawinglayer { namespace texture { - geoTexSvxHatch::geoTexSvxHatch(const basegfx::B2DRange& rTargetRange, double fDistance, double fAngle) + GeoTexSvxHatch::GeoTexSvxHatch(const basegfx::B2DRange& rTargetRange, double fDistance, double fAngle) : mfDistance(0.1), mfAngle(fAngle), mnSteps(10L) @@ -976,13 +976,13 @@ namespace drawinglayer maBackTextureTransform.invert(); } - geoTexSvxHatch::~geoTexSvxHatch() + GeoTexSvxHatch::~GeoTexSvxHatch() { } - bool geoTexSvxHatch::operator==(const geoTexSvx& rGeoTexSvx) const + bool GeoTexSvxHatch::operator==(const GeoTexSvx& rGeoTexSvx) const { - const geoTexSvxHatch* pCompare = dynamic_cast< const geoTexSvxHatch* >(&rGeoTexSvx); + const GeoTexSvxHatch* pCompare = dynamic_cast< const GeoTexSvxHatch* >(&rGeoTexSvx); return (pCompare && maTextureTransform == pCompare->maTextureTransform && mfDistance == pCompare->mfDistance @@ -990,7 +990,7 @@ namespace drawinglayer && mnSteps == pCompare->mnSteps); } - void geoTexSvxHatch::appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices) + void GeoTexSvxHatch::appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices) { for(sal_uInt32 a(1L); a < mnSteps; a++) { @@ -1002,7 +1002,7 @@ namespace drawinglayer } } - double geoTexSvxHatch::getDistanceToHatch(const basegfx::B2DPoint& rUV) const + double GeoTexSvxHatch::getDistanceToHatch(const basegfx::B2DPoint& rUV) const { const basegfx::B2DPoint aCoor(maBackTextureTransform * rUV); return fmod(aCoor.getY(), mfDistance); @@ -1016,7 +1016,7 @@ namespace drawinglayer { namespace texture { - geoTexSvxTiled::geoTexSvxTiled(const basegfx::B2DPoint& rTopLeft, const basegfx::B2DVector& rSize) + GeoTexSvxTiled::GeoTexSvxTiled(const basegfx::B2DPoint& rTopLeft, const basegfx::B2DVector& rSize) : maTopLeft(rTopLeft), maSize(rSize) { @@ -1031,19 +1031,19 @@ namespace drawinglayer } } - geoTexSvxTiled::~geoTexSvxTiled() + GeoTexSvxTiled::~GeoTexSvxTiled() { } - bool geoTexSvxTiled::operator==(const geoTexSvx& rGeoTexSvx) const + bool GeoTexSvxTiled::operator==(const GeoTexSvx& rGeoTexSvx) const { - const geoTexSvxTiled* pCompare = dynamic_cast< const geoTexSvxTiled* >(&rGeoTexSvx); + const GeoTexSvxTiled* pCompare = dynamic_cast< const GeoTexSvxTiled* >(&rGeoTexSvx); return (pCompare && maTopLeft == pCompare->maTopLeft && maSize == pCompare->maSize); } - void geoTexSvxTiled::appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices) + void GeoTexSvxTiled::appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices) { double fStartX(maTopLeft.getX()); double fStartY(maTopLeft.getY()); |