Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
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/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
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 .
18 : : */
19 : :
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>
31 : :
32 : : //////////////////////////////////////////////////////////////////////////////
33 : :
34 : : using namespace com::sun::star;
35 : :
36 : : //////////////////////////////////////////////////////////////////////////////
37 : :
38 : : namespace drawinglayer
39 : : {
40 : : namespace processor3d
41 : : {
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 : 0 : void Geometry2DExtractingProcessor::processBasePrimitive3D(const primitive3d::BasePrimitive3D& rCandidate)
45 : : {
46 : : // it is a BasePrimitive3D implementation, use getPrimitive3DID() call for switch
47 [ # # # # : 0 : switch(rCandidate.getPrimitive3DID())
# # # ]
48 : : {
49 : : case PRIMITIVE3D_ID_TRANSFORMPRIMITIVE3D :
50 : : {
51 : : // transform group. Remember current transformations
52 : 0 : const primitive3d::TransformPrimitive3D& rPrimitive = static_cast< const primitive3d::TransformPrimitive3D& >(rCandidate);
53 [ # # ]: 0 : const geometry::ViewInformation3D aLastViewInformation3D(getViewInformation3D());
54 : :
55 : : // create new transformation; add new object transform from right side
56 : : const geometry::ViewInformation3D aNewViewInformation3D(
57 [ # # ]: 0 : aLastViewInformation3D.getObjectTransformation() * rPrimitive.getTransformation(),
58 [ # # ]: 0 : aLastViewInformation3D.getOrientation(),
59 [ # # ]: 0 : aLastViewInformation3D.getProjection(),
60 [ # # ]: 0 : aLastViewInformation3D.getDeviceToView(),
61 : : aLastViewInformation3D.getViewTime(),
62 [ # # ][ # # ]: 0 : aLastViewInformation3D.getExtendedInformationSequence());
[ # # ][ # # ]
[ # # ]
63 [ # # ]: 0 : updateViewInformation(aNewViewInformation3D);
64 : :
65 : : // let break down recursively
66 [ # # ][ # # ]: 0 : process(rPrimitive.getChildren());
[ # # ]
67 : :
68 : : // restore transformations
69 [ # # ]: 0 : updateViewInformation(aLastViewInformation3D);
70 [ # # ][ # # ]: 0 : break;
71 : : }
72 : : case PRIMITIVE3D_ID_MODIFIEDCOLORPRIMITIVE3D :
73 : : {
74 : : // ModifiedColorPrimitive3D; push, process and pop
75 : 0 : const primitive3d::ModifiedColorPrimitive3D& rModifiedCandidate = static_cast< const primitive3d::ModifiedColorPrimitive3D& >(rCandidate);
76 : 0 : const primitive3d::Primitive3DSequence& rSubSequence = rModifiedCandidate.getChildren();
77 : :
78 [ # # ]: 0 : if(rSubSequence.hasElements())
79 : : {
80 [ # # ]: 0 : maBColorModifierStack.push(rModifiedCandidate.getColorModifier());
81 [ # # ][ # # ]: 0 : process(rModifiedCandidate.getChildren());
[ # # ]
82 [ # # ]: 0 : maBColorModifierStack.pop();
83 : : }
84 : 0 : break;
85 : : }
86 : : case PRIMITIVE3D_ID_POLYGONHAIRLINEPRIMITIVE3D :
87 : : {
88 : : // PolygonHairlinePrimitive3D
89 : 0 : const primitive3d::PolygonHairlinePrimitive3D& rPrimitive = static_cast< const primitive3d::PolygonHairlinePrimitive3D& >(rCandidate);
90 [ # # ][ # # ]: 0 : basegfx::B2DPolygon a2DHairline(basegfx::tools::createB2DPolygonFromB3DPolygon(rPrimitive.getB3DPolygon(), getViewInformation3D().getObjectToView()));
91 : :
92 [ # # ][ # # ]: 0 : if(a2DHairline.count())
93 : : {
94 [ # # ]: 0 : a2DHairline.transform(getObjectTransformation());
95 [ # # ]: 0 : const basegfx::BColor aModifiedColor(maBColorModifierStack.getModifiedColor(rPrimitive.getBColor()));
96 [ # # ][ # # ]: 0 : const primitive2d::Primitive2DReference xRef(new primitive2d::PolygonHairlinePrimitive2D(a2DHairline, aModifiedColor));
[ # # ]
97 [ # # ]: 0 : primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(maPrimitive2DSequence, xRef);
98 : : }
99 [ # # ]: 0 : break;
100 : : }
101 : : case PRIMITIVE3D_ID_POLYPOLYGONMATERIALPRIMITIVE3D :
102 : : {
103 : : // PolyPolygonMaterialPrimitive3D
104 : 0 : const primitive3d::PolyPolygonMaterialPrimitive3D& rPrimitive = static_cast< const primitive3d::PolyPolygonMaterialPrimitive3D& >(rCandidate);
105 [ # # ][ # # ]: 0 : basegfx::B2DPolyPolygon a2DFill(basegfx::tools::createB2DPolyPolygonFromB3DPolyPolygon(rPrimitive.getB3DPolyPolygon(), getViewInformation3D().getObjectToView()));
106 : :
107 [ # # ][ # # ]: 0 : if(a2DFill.count())
108 : : {
109 [ # # ]: 0 : a2DFill.transform(getObjectTransformation());
110 [ # # ][ # # ]: 0 : const basegfx::BColor aModifiedColor(maBColorModifierStack.getModifiedColor(rPrimitive.getMaterial().getColor()));
111 [ # # ][ # # ]: 0 : const primitive2d::Primitive2DReference xRef(new primitive2d::PolyPolygonColorPrimitive2D(a2DFill, aModifiedColor));
[ # # ]
112 [ # # ]: 0 : primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(maPrimitive2DSequence, xRef);
113 : : }
114 [ # # ]: 0 : break;
115 : : }
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 :
121 : : {
122 : : // TexturePrimitive3D: Process children, do not try to decompose
123 : 0 : const primitive3d::TexturePrimitive3D& rTexturePrimitive = static_cast< const primitive3d::TexturePrimitive3D& >(rCandidate);
124 [ # # ]: 0 : const primitive3d::Primitive3DSequence aChildren(rTexturePrimitive.getChildren());
125 : :
126 [ # # ]: 0 : if(aChildren.hasElements())
127 : : {
128 [ # # ]: 0 : process(aChildren);
129 : : }
130 [ # # ]: 0 : break;
131 : : }
132 : : case PRIMITIVE3D_ID_SHADOWPRIMITIVE3D :
133 : : {
134 : : // accept but ignore labels and shadow; these should be extracted seperately
135 : 0 : break;
136 : : }
137 : : default :
138 : : {
139 : : // process recursively
140 [ # # ]: 0 : process(rCandidate.get3DDecomposition(getViewInformation3D()));
141 : 0 : break;
142 : : }
143 : : }
144 : 0 : }
145 : :
146 : 0 : Geometry2DExtractingProcessor::Geometry2DExtractingProcessor(
147 : : const geometry::ViewInformation3D& rViewInformation,
148 : : const basegfx::B2DHomMatrix& rObjectTransformation)
149 : : : BaseProcessor3D(rViewInformation),
150 : : maPrimitive2DSequence(),
151 : : maObjectTransformation(rObjectTransformation),
152 [ # # ][ # # ]: 0 : maBColorModifierStack()
[ # # ]
153 : : {
154 : 0 : }
155 : : } // end of namespace processor3d
156 : : } // end of namespace drawinglayer
157 : :
158 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|