diff options
author | Armin Le Grand <Armin.Le.Grand@Sun.COM> | 2010-06-03 17:18:19 +0200 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@Sun.COM> | 2010-06-03 17:18:19 +0200 |
commit | c74d53a56764858fb1ced80e729f78af1a9e98ac (patch) | |
tree | 7dc199e672c1b8a190f94261ffa17bc5c7e3dbff /drawinglayer | |
parent | #i111122# corrected the copy operator of SdrPageProperties (diff) | |
download | core-c74d53a56764858fb1ced80e729f78af1a9e98ac.tar.gz core-c74d53a56764858fb1ced80e729f78af1a9e98ac.zip |
#i112090# enhanced Shadow3DExtractingProcessor
Diffstat (limited to 'drawinglayer')
-rw-r--r-- | drawinglayer/inc/drawinglayer/processor3d/shadow3dextractor.hxx | 14 | ||||
-rw-r--r-- | drawinglayer/source/processor3d/shadow3dextractor.cxx | 76 |
2 files changed, 71 insertions, 19 deletions
diff --git a/drawinglayer/inc/drawinglayer/processor3d/shadow3dextractor.hxx b/drawinglayer/inc/drawinglayer/processor3d/shadow3dextractor.hxx index 23d8e7edd913..93ebfeab48e7 100644 --- a/drawinglayer/inc/drawinglayer/processor3d/shadow3dextractor.hxx +++ b/drawinglayer/inc/drawinglayer/processor3d/shadow3dextractor.hxx @@ -54,9 +54,12 @@ namespace drawinglayer class Shadow3DExtractingProcessor : public BaseProcessor3D { private: + /// typedef for data handling + typedef std::vector< primitive2d::BasePrimitive2D* > BasePrimitive2DVector; + /// result holding vector (2D) and target vector for stacking (inited to &maPrimitive2DSequence) - primitive2d::Primitive2DSequence maPrimitive2DSequence; - primitive2d::Primitive2DSequence* mpPrimitive2DSequence; + BasePrimitive2DVector maPrimitive2DSequence; + BasePrimitive2DVector* mpPrimitive2DSequence; /// object transformation for scene for 2d definition basegfx::B2DHomMatrix maObjectTransformation; @@ -93,6 +96,10 @@ namespace drawinglayer */ virtual void processBasePrimitive3D(const primitive3d::BasePrimitive3D& rCandidate); + /// helper to convert from BasePrimitive2DVector to primitive2d::Primitive2DSequence + const primitive2d::Primitive2DSequence getPrimitive2DSequenceFromBasePrimitive2DVector( + const BasePrimitive2DVector& rVector) const; + public: Shadow3DExtractingProcessor( const geometry::ViewInformation3D& rViewInformation, @@ -100,9 +107,10 @@ namespace drawinglayer const basegfx::B3DVector& rLightNormal, double fShadowSlant, const basegfx::B3DRange& rContained3DRange); + virtual ~Shadow3DExtractingProcessor(); /// data read access - const primitive2d::Primitive2DSequence& getPrimitive2DSequence() const { return maPrimitive2DSequence; } + const primitive2d::Primitive2DSequence getPrimitive2DSequence() const; const basegfx::B2DHomMatrix& getObjectTransformation() const { return maObjectTransformation; } const basegfx::B3DHomMatrix& getWorldToEye() const { return maWorldToEye; } const basegfx::B3DHomMatrix& getEyeToView() const { return maEyeToView; } diff --git a/drawinglayer/source/processor3d/shadow3dextractor.cxx b/drawinglayer/source/processor3d/shadow3dextractor.cxx index 2abbcaa9f83f..9e0c0674ea66 100644 --- a/drawinglayer/source/processor3d/shadow3dextractor.cxx +++ b/drawinglayer/source/processor3d/shadow3dextractor.cxx @@ -51,6 +51,25 @@ namespace drawinglayer { namespace processor3d { + /// helper to convert from BasePrimitive2DVector to primitive2d::Primitive2DSequence + const primitive2d::Primitive2DSequence Shadow3DExtractingProcessor::getPrimitive2DSequenceFromBasePrimitive2DVector( + const BasePrimitive2DVector& rVector) const + { + const sal_uInt32 nCount(rVector.size()); + primitive2d::Primitive2DSequence aRetval(nCount); + + for(sal_uInt32 a(0); a < nCount; a++) + { + aRetval[a] = rVector[a]; + } + + // all entries taken over; no need to delete entries, just reset to + // mark as empty + const_cast< BasePrimitive2DVector& >(rVector).clear(); + + return aRetval; + } + // as tooling, the process() implementation takes over API handling and calls this // virtual render method when the primitive implementation is BasePrimitive3D-based. void Shadow3DExtractingProcessor::processBasePrimitive3D(const primitive3d::BasePrimitive3D& rCandidate) @@ -64,8 +83,8 @@ namespace drawinglayer const primitive3d::ShadowPrimitive3D& rPrimitive = static_cast< const primitive3d::ShadowPrimitive3D& >(rCandidate); // set new target - primitive2d::Primitive2DSequence aNewSubList; - primitive2d::Primitive2DSequence* pLastTargetSequence = mpPrimitive2DSequence; + BasePrimitive2DVector aNewSubList; + BasePrimitive2DVector* pLastTargetSequence = mpPrimitive2DSequence; mpPrimitive2DSequence = &aNewSubList; // activate convert @@ -84,21 +103,26 @@ namespace drawinglayer mbConvert = bLastConvert; mpPrimitive2DSequence = pLastTargetSequence; - // create 2d shadow primitive with result - const primitive2d::Primitive2DReference xRef(new primitive2d::ShadowPrimitive2D(rPrimitive.getShadowTransform(), rPrimitive.getShadowColor(), aNewSubList)); + // create 2d shadow primitive with result. This also fetches all entries + // from aNewSubList, so there is no need to delete them + primitive2d::BasePrimitive2D* pNew = new primitive2d::ShadowPrimitive2D( + rPrimitive.getShadowTransform(), + rPrimitive.getShadowColor(), + getPrimitive2DSequenceFromBasePrimitive2DVector(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::UnifiedTransparencePrimitive2D(aNewTransPrimitiveVector, rPrimitive.getShadowTransparence())); - primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(*mpPrimitive2DSequence, xRef2); - } - else - { - // add directly - primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(*mpPrimitive2DSequence, xRef); + const primitive2d::Primitive2DReference xRef(pNew); + const primitive2d::Primitive2DSequence aNewTransPrimitiveVector(&xRef, 1); + + pNew = new primitive2d::UnifiedTransparencePrimitive2D( + aNewTransPrimitiveVector, + rPrimitive.getShadowTransparence()); } + + mpPrimitive2DSequence->push_back(pNew); + break; } case PRIMITIVE3D_ID_TRANSFORMPRIMITIVE3D : @@ -161,8 +185,10 @@ namespace drawinglayer if(a2DHairline.count()) { a2DHairline.transform(getObjectTransformation()); - const primitive2d::Primitive2DReference xRef(new primitive2d::PolygonHairlinePrimitive2D(a2DHairline, maPrimitiveColor)); - primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(*mpPrimitive2DSequence, xRef); + mpPrimitive2DSequence->push_back( + new primitive2d::PolygonHairlinePrimitive2D( + a2DHairline, + maPrimitiveColor)); } } break; @@ -190,8 +216,10 @@ namespace drawinglayer if(a2DFill.count()) { a2DFill.transform(getObjectTransformation()); - const primitive2d::Primitive2DReference xRef(new primitive2d::PolyPolygonColorPrimitive2D(a2DFill, maPrimitiveColor)); - primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(*mpPrimitive2DSequence, xRef); + mpPrimitive2DSequence->push_back( + new primitive2d::PolyPolygonColorPrimitive2D( + a2DFill, + maPrimitiveColor)); } } break; @@ -251,6 +279,16 @@ namespace drawinglayer } } + Shadow3DExtractingProcessor::~Shadow3DExtractingProcessor() + { + OSL_ENSURE(0 == maPrimitive2DSequence.size(), + "OOps, someone used Shadow3DExtractingProcessor, but did not fetch the results (!)"); + for(sal_uInt32 a(0); a < maPrimitive2DSequence.size(); a++) + { + delete maPrimitive2DSequence[a]; + } + } + basegfx::B2DPolygon Shadow3DExtractingProcessor::impDoShadowProjection(const basegfx::B3DPolygon& rSource) { basegfx::B2DPolygon aRetval; @@ -291,6 +329,12 @@ namespace drawinglayer return aRetval; } + + const primitive2d::Primitive2DSequence Shadow3DExtractingProcessor::getPrimitive2DSequence() const + { + return getPrimitive2DSequenceFromBasePrimitive2DVector(maPrimitive2DSequence); + } + } // end of namespace processor3d } // end of namespace drawinglayer |