update emoji autocorrect entries from po-files
[LibreOffice.git] / drawinglayer / source / processor3d / geometry2dextractor.cxx
blob82216ac659175f09ee2e127d23c38fdeaf51fe61
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <drawinglayer/processor3d/geometry2dextractor.hxx>
21 #include <drawinglayer/primitive3d/drawinglayer_primitivetypes3d.hxx>
22 #include <drawinglayer/primitive3d/transformprimitive3d.hxx>
23 #include <drawinglayer/primitive3d/modifiedcolorprimitive3d.hxx>
24 #include <drawinglayer/primitive3d/polygonprimitive3d.hxx>
25 #include <basegfx/polygon/b2dpolygontools.hxx>
26 #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
27 #include <drawinglayer/primitive3d/polypolygonprimitive3d.hxx>
28 #include <basegfx/polygon/b2dpolypolygontools.hxx>
29 #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
30 #include <drawinglayer/primitive3d/textureprimitive3d.hxx>
34 using namespace com::sun::star;
38 namespace drawinglayer
40 namespace processor3d
42 // as tooling, the process() implementation takes over API handling and calls this
43 // virtual render method when the primitive implementation is BasePrimitive3D-based.
44 void Geometry2DExtractingProcessor::processBasePrimitive3D(const primitive3d::BasePrimitive3D& rCandidate)
46 // it is a BasePrimitive3D implementation, use getPrimitive3DID() call for switch
47 switch(rCandidate.getPrimitive3DID())
49 case PRIMITIVE3D_ID_TRANSFORMPRIMITIVE3D :
51 // transform group. Remember current transformations
52 const primitive3d::TransformPrimitive3D& rPrimitive = static_cast< const primitive3d::TransformPrimitive3D& >(rCandidate);
53 const geometry::ViewInformation3D aLastViewInformation3D(getViewInformation3D());
55 // create new transformation; add new object transform from right side
56 const geometry::ViewInformation3D aNewViewInformation3D(
57 aLastViewInformation3D.getObjectTransformation() * rPrimitive.getTransformation(),
58 aLastViewInformation3D.getOrientation(),
59 aLastViewInformation3D.getProjection(),
60 aLastViewInformation3D.getDeviceToView(),
61 aLastViewInformation3D.getViewTime(),
62 aLastViewInformation3D.getExtendedInformationSequence());
63 updateViewInformation(aNewViewInformation3D);
65 // let break down recursively
66 process(rPrimitive.getChildren());
68 // restore transformations
69 updateViewInformation(aLastViewInformation3D);
70 break;
72 case PRIMITIVE3D_ID_MODIFIEDCOLORPRIMITIVE3D :
74 // ModifiedColorPrimitive3D; push, process and pop
75 const primitive3d::ModifiedColorPrimitive3D& rModifiedCandidate = static_cast< const primitive3d::ModifiedColorPrimitive3D& >(rCandidate);
76 const primitive3d::Primitive3DSequence& rSubSequence = rModifiedCandidate.getChildren();
78 if(rSubSequence.hasElements())
80 maBColorModifierStack.push(rModifiedCandidate.getColorModifier());
81 process(rModifiedCandidate.getChildren());
82 maBColorModifierStack.pop();
84 break;
86 case PRIMITIVE3D_ID_POLYGONHAIRLINEPRIMITIVE3D :
88 // PolygonHairlinePrimitive3D
89 const primitive3d::PolygonHairlinePrimitive3D& rPrimitive = static_cast< const primitive3d::PolygonHairlinePrimitive3D& >(rCandidate);
90 basegfx::B2DPolygon a2DHairline(basegfx::tools::createB2DPolygonFromB3DPolygon(rPrimitive.getB3DPolygon(), getViewInformation3D().getObjectToView()));
92 if(a2DHairline.count())
94 a2DHairline.transform(getObjectTransformation());
95 const basegfx::BColor aModifiedColor(maBColorModifierStack.getModifiedColor(rPrimitive.getBColor()));
96 const primitive2d::Primitive2DReference xRef(new primitive2d::PolygonHairlinePrimitive2D(a2DHairline, aModifiedColor));
97 primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(maPrimitive2DSequence, xRef);
99 break;
101 case PRIMITIVE3D_ID_POLYPOLYGONMATERIALPRIMITIVE3D :
103 // PolyPolygonMaterialPrimitive3D
104 const primitive3d::PolyPolygonMaterialPrimitive3D& rPrimitive = static_cast< const primitive3d::PolyPolygonMaterialPrimitive3D& >(rCandidate);
105 basegfx::B2DPolyPolygon a2DFill(basegfx::tools::createB2DPolyPolygonFromB3DPolyPolygon(rPrimitive.getB3DPolyPolygon(), getViewInformation3D().getObjectToView()));
107 if(a2DFill.count())
109 a2DFill.transform(getObjectTransformation());
110 const basegfx::BColor aModifiedColor(maBColorModifierStack.getModifiedColor(rPrimitive.getMaterial().getColor()));
111 const primitive2d::Primitive2DReference xRef(new primitive2d::PolyPolygonColorPrimitive2D(a2DFill, aModifiedColor));
112 primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(maPrimitive2DSequence, xRef);
114 break;
116 case PRIMITIVE3D_ID_GRADIENTTEXTUREPRIMITIVE3D :
117 case PRIMITIVE3D_ID_HATCHTEXTUREPRIMITIVE3D :
118 case PRIMITIVE3D_ID_BITMAPTEXTUREPRIMITIVE3D :
119 case PRIMITIVE3D_ID_TRANSPARENCETEXTUREPRIMITIVE3D :
120 case PRIMITIVE3D_ID_UNIFIEDTRANSPARENCETEXTUREPRIMITIVE3D :
122 // TexturePrimitive3D: Process children, do not try to decompose
123 const primitive3d::TexturePrimitive3D& rTexturePrimitive = static_cast< const primitive3d::TexturePrimitive3D& >(rCandidate);
124 const primitive3d::Primitive3DSequence aChildren(rTexturePrimitive.getChildren());
126 if(aChildren.hasElements())
128 process(aChildren);
130 break;
132 case PRIMITIVE3D_ID_SHADOWPRIMITIVE3D :
134 // accept but ignore labels and shadow; these should be extracted separately
135 break;
137 default :
139 // process recursively
140 process(rCandidate.get3DDecomposition(getViewInformation3D()));
141 break;
146 Geometry2DExtractingProcessor::Geometry2DExtractingProcessor(
147 const geometry::ViewInformation3D& rViewInformation,
148 const basegfx::B2DHomMatrix& rObjectTransformation)
149 : BaseProcessor3D(rViewInformation),
150 maPrimitive2DSequence(),
151 maObjectTransformation(rObjectTransformation),
152 maBColorModifierStack()
155 } // end of namespace processor3d
156 } // end of namespace drawinglayer
158 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */