From 10aa61df3071f40c43735b8f8690cef0668bff03 Mon Sep 17 00:00:00 2001 From: Armin Weiss Date: Wed, 30 Jan 2008 11:26:48 +0000 Subject: Adaptions for strippings --- .../source/primitive2d/sceneprimitive2d.cxx | 46 +++- .../source/processor2d/canvasprocessor.cxx | 6 +- .../source/processor2d/contourextractor2d.cxx | 267 +++++++++++++++++++++ drawinglayer/source/processor2d/makefile.mk | 5 +- .../source/processor2d/vclhelperbufferdevice.cxx | 17 +- .../source/processor2d/vclmetafileprocessor2d.cxx | 19 +- .../source/processor3d/defaultprocessor3d.cxx | 16 +- .../source/processor3d/geometry2dextractor.cxx | 228 ++++++++++++++++++ drawinglayer/source/processor3d/makefile.mk | 7 +- 9 files changed, 581 insertions(+), 30 deletions(-) create mode 100644 drawinglayer/source/processor2d/contourextractor2d.cxx create mode 100644 drawinglayer/source/processor3d/geometry2dextractor.cxx (limited to 'drawinglayer/source') diff --git a/drawinglayer/source/primitive2d/sceneprimitive2d.cxx b/drawinglayer/source/primitive2d/sceneprimitive2d.cxx index c46edd05008c..c3db747847c7 100644 --- a/drawinglayer/source/primitive2d/sceneprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/sceneprimitive2d.cxx @@ -4,9 +4,9 @@ * * $RCSfile: sceneprimitive2d.cxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: aw $ $Date: 2007-10-16 15:46:43 $ + * last change: $Author: aw $ $Date: 2008-01-30 12:25:05 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -89,6 +89,10 @@ #include #endif +#ifndef INCLUDED_DRAWINGLAYER_PROCESSOR3D_GEOMETRY2DEXTRACTOR_HXX +#include +#endif + ////////////////////////////////////////////////////////////////////////////// using namespace com::sun::star; @@ -243,6 +247,44 @@ namespace drawinglayer return aRetval; } + Primitive2DSequence ScenePrimitive2D::getGeometry2D(const geometry::ViewInformation2D& rViewInformation) const + { + Primitive2DSequence aRetval; + + // create 2D shadows from contained 3D primitives + if(impGetShadow3D(rViewInformation)) + { + // add extracted 2d shadows (before 3d scene creations itself) + aRetval = maShadowPrimitives; + } + + // create 2D projected geometry from 3D geometry + if(getChildren3D().hasElements()) + { + // create 2D geometry extraction processor + processor3d::Geometry2DExtractingProcessor aGeometryProcessor( + rViewInformation.getViewTime(), + getObjectTransformation(), + getTransformation3D().getWorldToView()); + + // process local primitives + aGeometryProcessor.process(getChildren3D()); + + // fetch result and append + Primitive2DSequence a2DExtractedPrimitives(aGeometryProcessor.getPrimitive2DSequence()); + appendPrimitive2DSequenceToPrimitive2DSequence(aRetval, a2DExtractedPrimitives); + } + + // create 2D labels from contained 3D label primitives + if(impGetLabel3D(rViewInformation)) + { + // add extracted 2d labels (after 3d scene creations) + appendPrimitive2DSequenceToPrimitive2DSequence(aRetval, maLabelPrimitives); + } + + return aRetval; + } + ScenePrimitive2D::ScenePrimitive2D( const primitive3d::Primitive3DSequence& rxChildren3D, const attribute::SdrSceneAttribute& rSdrSceneAttribute, diff --git a/drawinglayer/source/processor2d/canvasprocessor.cxx b/drawinglayer/source/processor2d/canvasprocessor.cxx index fcc978c84f25..4441ee6060a3 100644 --- a/drawinglayer/source/processor2d/canvasprocessor.cxx +++ b/drawinglayer/source/processor2d/canvasprocessor.cxx @@ -4,9 +4,9 @@ * * $RCSfile: canvasprocessor.cxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: aw $ $Date: 2007-12-18 15:10:27 $ + * last change: $Author: aw $ $Date: 2008-01-30 12:25:05 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -1310,7 +1310,7 @@ namespace drawinglayer case PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D : { // direct draw of PolyPolygon with color - const primitive2d::PolyPolygonColorPrimitive2D& rPolygonCandidate = static_cast< const primitive2d::PolyPolygonColorPrimitive2D& >(rCandidate); + const primitive2d::PolyPolygonColorPrimitive2D& rPolygonCandidate = static_cast< const primitive2d::PolyPolygonColorPrimitive2D& >(rCandidate); const basegfx::BColor aPolygonColor(maBColorModifierStack.getModifiedColor(rPolygonCandidate.getBColor())); maRenderState.DeviceColor = aPolygonColor.colorToDoubleSequence(mxCanvas->getDevice()); diff --git a/drawinglayer/source/processor2d/contourextractor2d.cxx b/drawinglayer/source/processor2d/contourextractor2d.cxx new file mode 100644 index 000000000000..db0168affaad --- /dev/null +++ b/drawinglayer/source/processor2d/contourextractor2d.cxx @@ -0,0 +1,267 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: contourextractor2d.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2008-01-30 12:26:48 $ + * + * 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_CONTOUREXTRACTOR2D_HXX +#include +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_PRIMITIVETYPES2D_HXX +#include +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_POLYGONPRIMITIVE2D_HXX +#include +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_POLYPOLYGONPRIMITIVE2D_HXX +#include +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_BITMAPPRIMITIVE2D_HXX +#include +#endif + +#ifndef _BGFX_POLYGON_B2DPOLYGONTOOLS_HXX +#include +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_METAFILEPRIMITIVE2D_HXX +#include +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_ALPHAPRIMITIVE2D_HXX +#include +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_MASKPRIMITIVE2D_HXX +#include +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_TRANSFORMPRIMITIVE2D_HXX +#include +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_SCENEPRIMITIVE2D_HXX +#include +#endif + +#ifndef _BGFX_TOOLS_CANVASTOOLS_HXX +#include +#endif + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace processor2d + { + ContourExtractor2D::ContourExtractor2D(const geometry::ViewInformation2D& rViewInformation) + : BaseProcessor2D(rViewInformation), + maExtractedContour() + { + } + + ContourExtractor2D::~ContourExtractor2D() + { + } + + void ContourExtractor2D::processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate) + { + switch(rCandidate.getPrimitiveID()) + { + case PRIMITIVE2D_ID_POLYGONHAIRLINEPRIMITIVE2D : + { + // extract hairline + const primitive2d::PolygonHairlinePrimitive2D& rPolygonCandidate(static_cast< const primitive2d::PolygonHairlinePrimitive2D& >(rCandidate)); + basegfx::B2DPolygon aLocalPolygon(rPolygonCandidate.getB2DPolygon()); + aLocalPolygon.transform(maCurrentTransformation); + + if(aLocalPolygon.isClosed()) + { + // line polygons need to be represented as open polygons to differentiate them + // from filled polygons + basegfx::tools::openWithGeometryChange(aLocalPolygon); + } + + maExtractedContour.push_back(basegfx::B2DPolyPolygon(aLocalPolygon)); + break; + } + case PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D : + { + // extract fill + const primitive2d::PolyPolygonColorPrimitive2D& rPolygonCandidate(static_cast< const primitive2d::PolyPolygonColorPrimitive2D& >(rCandidate)); + basegfx::B2DPolyPolygon aLocalPolyPolygon(rPolygonCandidate.getB2DPolyPolygon()); + aLocalPolyPolygon.transform(maCurrentTransformation); + maExtractedContour.push_back(aLocalPolyPolygon); + break; + } + case PRIMITIVE2D_ID_BITMAPPRIMITIVE2D : + { + // extract BoundRect from bitmaps + const primitive2d::BitmapPrimitive2D& rBitmapCandidate(static_cast< const primitive2d::BitmapPrimitive2D& >(rCandidate)); + basegfx::B2DHomMatrix aLocalTransform(maCurrentTransformation * rBitmapCandidate.getTransform()); + basegfx::B2DPolygon aPolygon(basegfx::tools::createPolygonFromRect(basegfx::B2DRange(0.0, 0.0, 1.0, 1.0))); + aPolygon.transform(aLocalTransform); + maExtractedContour.push_back(basegfx::B2DPolyPolygon(aPolygon)); + break; + } + case PRIMITIVE2D_ID_METAFILEPRIMITIVE2D : + { + // extract BoundRect from MetaFiles + const primitive2d::MetafilePrimitive2D& rMetaCandidate(static_cast< const primitive2d::MetafilePrimitive2D& >(rCandidate)); + basegfx::B2DHomMatrix aLocalTransform(maCurrentTransformation * rMetaCandidate.getTransform()); + basegfx::B2DPolygon aPolygon(basegfx::tools::createPolygonFromRect(basegfx::B2DRange(0.0, 0.0, 1.0, 1.0))); + aPolygon.transform(aLocalTransform); + maExtractedContour.push_back(basegfx::B2DPolyPolygon(aPolygon)); + break; + } + case PRIMITIVE2D_ID_ALPHAPRIMITIVE2D : + { + // sub-transparence group. Look at children + const primitive2d::AlphaPrimitive2D& rTransCandidate(static_cast< const primitive2d::AlphaPrimitive2D& >(rCandidate)); + process(rTransCandidate.getChildren()); + break; + } + case PRIMITIVE2D_ID_MASKPRIMITIVE2D : + { + // extract mask, ignore content + const primitive2d::MaskPrimitive2D& rMaskCandidate(static_cast< const primitive2d::MaskPrimitive2D& >(rCandidate)); + basegfx::B2DPolyPolygon aMask(rMaskCandidate.getMask()); + aMask.transform(maCurrentTransformation); + maExtractedContour.push_back(basegfx::B2DPolyPolygon(aMask)); + break; + } + case PRIMITIVE2D_ID_TRANSFORMPRIMITIVE2D : + { + // remember current transformation and ViewInformation + const primitive2d::TransformPrimitive2D& rTransformCandidate(static_cast< const primitive2d::TransformPrimitive2D& >(rCandidate)); + const basegfx::B2DHomMatrix aLastCurrentTransformation(maCurrentTransformation); + const geometry::ViewInformation2D aLastViewInformation2D(getViewInformation2D()); + + // create new transformations for CurrentTransformation and for local ViewInformation2D + maCurrentTransformation = maCurrentTransformation * rTransformCandidate.getTransformation(); + maViewInformation2D = geometry::ViewInformation2D( + getViewInformation2D().getViewTransformation() * rTransformCandidate.getTransformation(), + getViewInformation2D().getViewport(), + getViewInformation2D().getViewTime()); + + // proccess content + process(rTransformCandidate.getChildren()); + + // restore transformations + maCurrentTransformation = aLastCurrentTransformation; + maViewInformation2D = aLastViewInformation2D; + break; + } + case PRIMITIVE2D_ID_SCENEPRIMITIVE2D : + { + // 2D Scene primitive containing 3D stuff; extract 2D contour + const primitive2d::ScenePrimitive2D& rScenePrimitive2DCandidate(static_cast< const primitive2d::ScenePrimitive2D& >(rCandidate)); + const primitive2d::Primitive2DSequence xExtracted2DSceneGeometry(rScenePrimitive2DCandidate.getGeometry2D(getViewInformation2D())); + + // proccess content + if(xExtracted2DSceneGeometry.hasElements()) + { + process(xExtracted2DSceneGeometry); + } + + break; + } + case PRIMITIVE2D_ID_WRONGSPELLPRIMITIVE2D : + case PRIMITIVE2D_ID_MARKERARRAYPRIMITIVE2D : + case PRIMITIVE2D_ID_POINTARRAYPRIMITIVE2D : + { + // ignorable primitives + break; + } + case PRIMITIVE2D_ID_TEXTSIMPLEPORTIONPRIMITIVE2D : + case PRIMITIVE2D_ID_TEXTDECORATEDPORTIONPRIMITIVE2D : + { + // primitives who's BoundRect will be added + basegfx::B2DRange aRange(rCandidate.getB2DRange(getViewInformation2D())); + aRange.transform(maCurrentTransformation); + maExtractedContour.push_back(basegfx::B2DPolyPolygon(basegfx::tools::createPolygonFromRect(aRange))); + break; + } + default : + { + // process recursively + process(rCandidate.get2DDecomposition(getViewInformation2D())); + break; + } + } + } + + void ContourExtractor2D::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 local processor + processBasePrimitive2D(*pBasePrimitive); + } + 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)); + } + } + } + } + } + } // end of namespace processor2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/processor2d/makefile.mk b/drawinglayer/source/processor2d/makefile.mk index 5e74c10cffc3..8e0befe97fcf 100644 --- a/drawinglayer/source/processor2d/makefile.mk +++ b/drawinglayer/source/processor2d/makefile.mk @@ -4,9 +4,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.5 $ +# $Revision: 1.6 $ # -# last change: $Author: aw $ $Date: 2007-12-18 15:10:27 $ +# last change: $Author: aw $ $Date: 2008-01-30 12:25:05 $ # # The Contents of this file are made available subject to # the terms of GNU Lesser General Public License Version 2.1. @@ -53,6 +53,7 @@ SLOFILES= \ $(SLO)$/vclprocessor2d.obj \ $(SLO)$/vclpixelprocessor2d.obj \ $(SLO)$/vclmetafileprocessor2d.obj \ + $(SLO)$/contourextractor2d.obj \ $(SLO)$/canvasprocessor.obj # --- Targets ---------------------------------- diff --git a/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx b/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx index 03a47e2a1e58..371a953c6426 100644 --- a/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx +++ b/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx @@ -4,9 +4,9 @@ * * $RCSfile: vclhelperbufferdevice.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: aw $ $Date: 2007-12-13 16:43:09 $ + * last change: $Author: aw $ $Date: 2008-01-30 12:25:05 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -45,6 +45,10 @@ #include #endif +#ifndef _BGFX_MATRIX_B2DHOMMATRIX_HXX +#include +#endif + ////////////////////////////////////////////////////////////////////////////// // support for rendering Bitmap and BitmapEx contents @@ -58,10 +62,11 @@ namespace drawinglayer 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)); + basegfx::B2DRange aRangePixel(rRange); + aRangePixel.transform(rOutDev.GetViewTransformation()); + const Rectangle aRectPixel( + (sal_Int32)floor(aRangePixel.getMinX()), (sal_Int32)floor(aRangePixel.getMinY()), + (sal_Int32)ceil(aRangePixel.getMaxX()), (sal_Int32)ceil(aRangePixel.getMaxY())); const Point aEmptyPoint; maDestPixel = Rectangle(aEmptyPoint, rOutDev.GetOutputSizePixel()); maDestPixel.Intersection(aRectPixel); diff --git a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx index 89cfec9c1147..adf901b64259 100644 --- a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx @@ -4,9 +4,9 @@ * * $RCSfile: vclmetafileprocessor2d.cxx,v $ * - * $Revision: 1.15 $ + * $Revision: 1.16 $ * - * last change: $Author: aw $ $Date: 2007-12-20 13:13:15 $ + * last change: $Author: aw $ $Date: 2008-01-30 12:25:05 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -366,7 +366,6 @@ namespace drawinglayer aStrokeColor = maBColorModifierStack.getModifiedColor(pLineAttribute->getColor()); } - // copied from ImpDrawLineGeometry. Ckecked. // It IS needed to record the stroke color at all in the metafile, // SvtGraphicStroke has NO entry for stroke color(!) mpOutputDevice->SetLineColor(Color(aStrokeColor)); @@ -527,10 +526,10 @@ namespace drawinglayer Two producers, one is vcl/source/gdi/gdimtf.cxx, line 1273. There, it is transformed inside GDIMetaFile::Rotate, nothing to take care of here. The second producer is in graphics/svx/source/svdraw/impgrfll.cxx, line 374. This is used - with each incarnation of ImpGraphicFill when a metafile is recorded, fillstyle is not + with each incarnation of Imp_GraphicFill when a metafile is recorded, fillstyle is not XFILL_NONE and not completely transparent. It creates a SvtGraphicFill and streams it to the comment action. A closing end token is created in the destructor. - Usages of ImpGraphicFill are in DoPaintObject-methods of SdrCircObj, SdrPathObj and + Usages of Imp_GraphicFill are in Do_Paint_Object-methods of SdrCircObj, SdrPathObj and SdrRectObj. The token users pick various actions from SvtGraphicFill, so it may need to be added for all kind of filled objects, even simple colored polygons. It is added as extra information; the @@ -551,7 +550,7 @@ namespace drawinglayer Similar to pathfill, but using SvtGraphicStroke instead. It also has two producers where one is also the GDIMetaFile::Rotate. Another user is MetaCommentAction::Move which modifies the contained path accordingly. - The other one is SdrObject::ImpDrawLineGeometry. It's done when MetaFile is set at OutDev and + The other one is SdrObject::Imp_DrawLineGeometry. It's done when MetaFile is set at OutDev and only when geometry is a single polygon (!). I see no reason for that; in the PS exporter this would hinder to make use of PolyPolygon strokes. I will need to add support at: PRIMITIVE2D_ID_POLYGONHAIRLINEPRIMITIVE2D @@ -652,7 +651,7 @@ namespace drawinglayer Okay, URLs work. Checked, Done. - UnoControlPDFExportContact is only created when PDFExtOutDevData is used at the - target and uno control data is created in UnoControlPDFExportContact::doPaintObject. + target and uno control data is created in UnoControlPDFExportContact::do_PaintObject. This may be added in primitive MetaFile renderer. Adding support... OOps, the necessary helper stuff is in svx/source/form/formpdxexport.cxx in namespace @@ -819,7 +818,7 @@ namespace drawinglayer mpPDFExtOutDevData->CreateControl(*pPDFControl.get()); mpPDFExtOutDevData->EndStructureElement(); - // no normal paint needed (see original UnoControlPDFExportContact::doPaintObject); + // no normal paint needed (see original UnoControlPDFExportContact::do_PaintObject); // do not process recursively bDoProcessRecursively = false; } @@ -828,8 +827,8 @@ namespace drawinglayer // printer output preparation if(bDoProcessRecursively && !bSuppressPrinterOutput) { - // this needs to do the same as UnoControlPrintOrPreviewContact::doPaintObject - // does ATM. This means preparePrintOrPrintPreview and paintControl + // this needs to do the same as UnoControlPrintOrPreviewContact::do_PaintObject + // does ATM. This means prepare_PrintOrPrintPreview and paint_Control bool bIsPrintableControl(false); if(rControlPrimitive.getXControl().is()) diff --git a/drawinglayer/source/processor3d/defaultprocessor3d.cxx b/drawinglayer/source/processor3d/defaultprocessor3d.cxx index 301867f1b467..3186ce607eae 100644 --- a/drawinglayer/source/processor3d/defaultprocessor3d.cxx +++ b/drawinglayer/source/processor3d/defaultprocessor3d.cxx @@ -4,9 +4,9 @@ * * $RCSfile: defaultprocessor3d.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: aw $ $Date: 2007-03-06 12:35:55 $ + * last change: $Author: aw $ $Date: 2008-01-30 12:25:05 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -1856,8 +1856,16 @@ namespace drawinglayer : BaseProcessor3D(rViewInformation.getViewTime()), mrSdrSceneAttribute(rSdrSceneAttribute), mrSdrLightingAttribute(rSdrLightingAttribute), - mpGeoTexSvx(0L), - mpTransparenceGeoTexSvx(0L), + maDeviceToView(), + maWorldToEye(), + maWorldToView(), + maInvEyeToView(), + maInvWorldToView(), + maRasterRange(), + mpBZPixelRaster(0), + maBColorModifierStack(), + mpGeoTexSvx(0), + mpTransparenceGeoTexSvx(0), mbModulate(false), mbFilter(false), mbProcessTransparent(false), diff --git a/drawinglayer/source/processor3d/geometry2dextractor.cxx b/drawinglayer/source/processor3d/geometry2dextractor.cxx new file mode 100644 index 000000000000..ffeb1ddfd1f8 --- /dev/null +++ b/drawinglayer/source/processor3d/geometry2dextractor.cxx @@ -0,0 +1,228 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: geometry2dextractor.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2008-01-30 12:26:48 $ + * + * 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_PROCESSOR3D_GEOMETRY2DEXTRACTOR_HXX +#include +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_PRIMITIVETYPES3D_HXX +#include +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_TRANSFORMPRIMITIVE3D_HXX +#include +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_MODIFIEDCOLORPRIMITIVE3D_HXX +#include +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_POLYGONPRIMITIVE3D_HXX +#include +#endif + +#ifndef _BGFX_POLYGON_B2DPOLYGONTOOLS_HXX +#include +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_POLYGONPRIMITIVE2D_HXX +#include +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_POLYPOLYGONPRIMITIVE3D_HXX +#include +#endif + +#ifndef _BGFX_POLYPOLYGON_B2DPOLYGONTOOLS_HXX +#include +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_POLYPOLYGONPRIMITIVE2D_HXX +#include +#endif + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_TEXTUREPRIMITIVE3D_HXX +#include +#endif + +////////////////////////////////////////////////////////////////////////////// + +using namespace com::sun::star; + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace processor3d + { + Geometry2DExtractingProcessor::Geometry2DExtractingProcessor( + double fTime, + const basegfx::B2DHomMatrix& rObjectTransformation, + const basegfx::B3DHomMatrix& rWorldToView) + : BaseProcessor3D(fTime), + maPrimitive2DSequence(), + maObjectTransformation(rObjectTransformation), + maWorldToView(rWorldToView), + maBColorModifierStack() + { + } + + void Geometry2DExtractingProcessor::process(const primitive3d::Primitive3DSequence& rSource) + { + if(rSource.hasElements()) + { + const sal_Int32 nCount(rSource.getLength()); + + for(sal_Int32 a(0L); a < nCount; a++) + { + // get reference + const primitive3d::Primitive3DReference xReference(rSource[a]); + + if(xReference.is()) + { + // try to cast to BasePrimitive3D implementation + const primitive3d::BasePrimitive3D* pBasePrimitive = dynamic_cast< const primitive3d::BasePrimitive3D* >(xReference.get()); + + if(pBasePrimitive) + { + // it is a BasePrimitive3D implementation, use getPrimitiveID() call for switch + switch(pBasePrimitive->getPrimitiveID()) + { + case PRIMITIVE3D_ID_TRANSFORMPRIMITIVE3D : + { + // transform group. Remember current transformations + const primitive3d::TransformPrimitive3D& rPrimitive = static_cast< const primitive3d::TransformPrimitive3D& >(*(xReference.get())); + basegfx::B3DHomMatrix aLastWorldToView(getWorldToView()); + + // create new transformations + maWorldToView = getWorldToView() * rPrimitive.getTransformation(); + + // let break down recursively + process(rPrimitive.getChildren()); + + // restore transformations + maWorldToView = aLastWorldToView; + break; + } + case PRIMITIVE3D_ID_MODIFIEDCOLORPRIMITIVE3D : + { + // ModifiedColorPrimitive3D; push, process and pop + const primitive3d::ModifiedColorPrimitive3D& rModifiedCandidate = static_cast< const primitive3d::ModifiedColorPrimitive3D& >(*pBasePrimitive); + const primitive3d::Primitive3DSequence& rSubSequence = rModifiedCandidate.getChildren(); + + if(rSubSequence.hasElements()) + { + maBColorModifierStack.push(rModifiedCandidate.getColorModifier()); + process(rModifiedCandidate.getChildren()); + maBColorModifierStack.pop(); + } + break; + } + case PRIMITIVE3D_ID_POLYGONHAIRLINEPRIMITIVE3D : + { + // PolygonHairlinePrimitive3D + const primitive3d::PolygonHairlinePrimitive3D& rPrimitive = static_cast< const primitive3d::PolygonHairlinePrimitive3D& >(*pBasePrimitive); + basegfx::B2DPolygon a2DHairline(basegfx::tools::createB2DPolygonFromB3DPolygon(rPrimitive.getB3DPolygon(), getWorldToView())); + + if(a2DHairline.count()) + { + a2DHairline.transform(getObjectTransformation()); + const basegfx::BColor aModifiedColor(maBColorModifierStack.getModifiedColor(rPrimitive.getBColor())); + const primitive2d::Primitive2DReference xRef(new primitive2d::PolygonHairlinePrimitive2D(a2DHairline, aModifiedColor)); + primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(maPrimitive2DSequence, xRef); + } + break; + } + case PRIMITIVE3D_ID_POLYPOLYGONMATERIALPRIMITIVE3D : + { + // PolyPolygonMaterialPrimitive3D + const primitive3d::PolyPolygonMaterialPrimitive3D& rPrimitive = static_cast< const primitive3d::PolyPolygonMaterialPrimitive3D& >(*pBasePrimitive); + basegfx::B2DPolyPolygon a2DFill(basegfx::tools::createB2DPolyPolygonFromB3DPolyPolygon(rPrimitive.getB3DPolyPolygon(), getWorldToView())); + + if(a2DFill.count()) + { + a2DFill.transform(getObjectTransformation()); + const basegfx::BColor aModifiedColor(maBColorModifierStack.getModifiedColor(rPrimitive.getMaterial().getColor())); + const primitive2d::Primitive2DReference xRef(new primitive2d::PolyPolygonColorPrimitive2D(a2DFill, aModifiedColor)); + primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(maPrimitive2DSequence, xRef); + } + break; + } + case PRIMITIVE3D_ID_GRADIENTTEXTUREPRIMITIVE3D : + case PRIMITIVE3D_ID_HATCHTEXTUREPRIMITIVE3D : + case PRIMITIVE3D_ID_BITMAPTEXTUREPRIMITIVE3D : + case PRIMITIVE3D_ID_ALPHATEXTUREPRIMITIVE3D : + case PRIMITIVE3D_ID_UNIFIEDALPHATEXTUREPRIMITIVE3D : + { + // TexturePrimitive3D: Process children, do not try to decompose + const primitive3d::TexturePrimitive3D& rTexturePrimitive = static_cast< const primitive3d::TexturePrimitive3D& >(*pBasePrimitive); + const primitive3d::Primitive3DSequence aChildren(rTexturePrimitive.getChildren()); + + if(aChildren.hasElements()) + { + process(aChildren); + } + break; + } + case PRIMITIVE3D_ID_SDRLABELPRIMITIVE3D : + case PRIMITIVE3D_ID_SHADOWPRIMITIVE3D : + { + // accept but ignore labels and shadow; these should be extracted seperately + break; + } + default : + { + // process recursively + process(pBasePrimitive->get3DDecomposition(getTime())); + 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)); + } + } + } + } + } + } // end of namespace processor3d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/processor3d/makefile.mk b/drawinglayer/source/processor3d/makefile.mk index e21b74a256cd..873de0f29642 100644 --- a/drawinglayer/source/processor3d/makefile.mk +++ b/drawinglayer/source/processor3d/makefile.mk @@ -4,9 +4,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.2 $ +# $Revision: 1.3 $ # -# last change: $Author: aw $ $Date: 2006-10-19 10:39:22 $ +# last change: $Author: aw $ $Date: 2008-01-30 12:25:05 $ # # The Contents of this file are made available subject to # the terms of GNU Lesser General Public License Version 2.1. @@ -48,7 +48,8 @@ SLOFILES= \ $(SLO)$/baseprocessor3d.obj \ $(SLO)$/defaultprocessor3d.obj \ $(SLO)$/label3dextractor.obj \ - $(SLO)$/shadow3dextractor.obj + $(SLO)$/shadow3dextractor.obj \ + $(SLO)$/geometry2dextractor.obj -- cgit