LibreOffice Module drawinglayer (master) 1
geometry2dextractor.cxx
Go to the documentation of this file.
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
31#include <utility>
32
33
34using namespace com::sun::star;
35
36
38{
39 // as tooling, the process() implementation takes over API handling and calls this
40 // virtual render method when the primitive implementation is BasePrimitive3D-based.
42 {
43 // it is a BasePrimitive3D implementation, use getPrimitive3DID() call for switch
44 switch(rCandidate.getPrimitive3DID())
45 {
47 {
48 // transform group. Remember current transformations
49 const primitive3d::TransformPrimitive3D& rPrimitive = static_cast< const primitive3d::TransformPrimitive3D& >(rCandidate);
50 const geometry::ViewInformation3D aLastViewInformation3D(getViewInformation3D());
51
52 // create new transformation; add new object transform from right side
53 const geometry::ViewInformation3D aNewViewInformation3D(
54 aLastViewInformation3D.getObjectTransformation() * rPrimitive.getTransformation(),
55 aLastViewInformation3D.getOrientation(),
56 aLastViewInformation3D.getProjection(),
57 aLastViewInformation3D.getDeviceToView(),
58 aLastViewInformation3D.getViewTime(),
59 aLastViewInformation3D.getExtendedInformationSequence());
60 updateViewInformation(aNewViewInformation3D);
61
62 // let break down recursively
63 process(rPrimitive.getChildren());
64
65 // restore transformations
66 updateViewInformation(aLastViewInformation3D);
67 break;
68 }
70 {
71 // ModifiedColorPrimitive3D; push, process and pop
72 const primitive3d::ModifiedColorPrimitive3D& rModifiedCandidate = static_cast< const primitive3d::ModifiedColorPrimitive3D& >(rCandidate);
73 const primitive3d::Primitive3DContainer& rSubSequence = rModifiedCandidate.getChildren();
74
75 if(!rSubSequence.empty())
76 {
77 maBColorModifierStack.push(rModifiedCandidate.getColorModifier());
78 process(rModifiedCandidate.getChildren());
80 }
81 break;
82 }
84 {
85 // PolygonHairlinePrimitive3D
86 const primitive3d::PolygonHairlinePrimitive3D& rPrimitive = static_cast< const primitive3d::PolygonHairlinePrimitive3D& >(rCandidate);
88
89 if(a2DHairline.count())
90 {
92 const basegfx::BColor aModifiedColor(maBColorModifierStack.getModifiedColor(rPrimitive.getBColor()));
93 const primitive2d::Primitive2DReference xRef(new primitive2d::PolygonHairlinePrimitive2D(std::move(a2DHairline), aModifiedColor));
94 maPrimitive2DSequence.push_back(xRef);
95 }
96 break;
97 }
99 {
100 // PolyPolygonMaterialPrimitive3D
101 const primitive3d::PolyPolygonMaterialPrimitive3D& rPrimitive = static_cast< const primitive3d::PolyPolygonMaterialPrimitive3D& >(rCandidate);
103
104 if(a2DFill.count())
105 {
107 const basegfx::BColor aModifiedColor(maBColorModifierStack.getModifiedColor(rPrimitive.getMaterial().getColor()));
108 const primitive2d::Primitive2DReference xRef(new primitive2d::PolyPolygonColorPrimitive2D(std::move(a2DFill), aModifiedColor));
109 maPrimitive2DSequence.push_back(xRef);
110 }
111 break;
112 }
118 {
119 // TexturePrimitive3D: Process children, do not try to decompose
120 const primitive3d::TexturePrimitive3D& rTexturePrimitive = static_cast< const primitive3d::TexturePrimitive3D& >(rCandidate);
121 const primitive3d::Primitive3DContainer& aChildren(rTexturePrimitive.getChildren());
122
123 if(!aChildren.empty())
124 {
125 process(aChildren);
126 }
127 break;
128 }
130 {
131 // accept but ignore labels and shadow; these should be extracted separately
132 break;
133 }
134 default :
135 {
136 // process recursively
138 break;
139 }
140 }
141 }
142
144 const geometry::ViewInformation3D& rViewInformation,
145 basegfx::B2DHomMatrix aObjectTransformation)
146 : BaseProcessor3D(rViewInformation),
147 maObjectTransformation(std::move(aObjectTransformation)),
148 maBColorModifierStack()
149 {
150 }
151
152} // end of namespace
153
154/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void transform(const basegfx::B2DHomMatrix &rMatrix)
sal_uInt32 count() const
void transform(const basegfx::B2DHomMatrix &rMatrix)
sal_uInt32 count() const
void push(const BColorModifierSharedPtr &rNew)
::basegfx::BColor getModifiedColor(const ::basegfx::BColor &rSource) const
const css::uno::Sequence< css::beans::PropertyValue > & getExtendedInformationSequence() const
Get the uno::Sequence< beans::PropertyValue > which contains only ViewInformation not offered directl...
const basegfx::B3DHomMatrix & getDeviceToView() const
const basegfx::B3DHomMatrix & getObjectTransformation() const
data access
const basegfx::B3DHomMatrix & getProjection() const
const basegfx::B3DHomMatrix & getOrientation() const
virtual Primitive3DContainer get3DDecomposition(const geometry::ViewInformation3D &rViewInformation) const
The default implementation returns an empty sequence.
virtual sal_uInt32 getPrimitive3DID() const =0
provide unique ID for fast identifying of known primitive implementations in renderers.
const Primitive3DContainer & getChildren() const
data read access
const basegfx::BColorModifierSharedPtr & getColorModifier() const
data read access
const attribute::MaterialAttribute3D & getMaterial() const
const basegfx::B3DPolyPolygon & getB3DPolyPolygon() const
data read access
const basegfx::B3DPolygon & getB3DPolygon() const
data read access
const basegfx::B3DHomMatrix & getTransformation() const
data read access
void process(const primitive3d::Primitive3DContainer &rSource)
const geometry::ViewInformation3D & getViewInformation3D() const
void updateViewInformation(const geometry::ViewInformation3D &rViewInformation3D)
primitive2d::Primitive2DContainer maPrimitive2DSequence
result holding vector (2D)
basegfx::BColorModifierStack maBColorModifierStack
the modifiedColorPrimitive stack
const basegfx::B2DHomMatrix & getObjectTransformation() const
Geometry2DExtractingProcessor(const geometry::ViewInformation3D &rViewInformation, basegfx::B2DHomMatrix aObjectTransformation)
virtual void processBasePrimitive3D(const primitive3d::BasePrimitive3D &rCandidate) override
#define PRIMITIVE3D_ID_TRANSFORMPRIMITIVE3D
#define PRIMITIVE3D_ID_POLYGONHAIRLINEPRIMITIVE3D
#define PRIMITIVE3D_ID_POLYPOLYGONMATERIALPRIMITIVE3D
#define PRIMITIVE3D_ID_UNIFIEDTRANSPARENCETEXTUREPRIMITIVE3D
#define PRIMITIVE3D_ID_MODIFIEDCOLORPRIMITIVE3D
#define PRIMITIVE3D_ID_GRADIENTTEXTUREPRIMITIVE3D
#define PRIMITIVE3D_ID_SHADOWPRIMITIVE3D
#define PRIMITIVE3D_ID_TRANSPARENCETEXTUREPRIMITIVE3D
#define PRIMITIVE3D_ID_HATCHTEXTUREPRIMITIVE3D
#define PRIMITIVE3D_ID_BITMAPTEXTUREPRIMITIVE3D
B2DPolyPolygon createB2DPolyPolygonFromB3DPolyPolygon(const B3DPolyPolygon &rCandidate, const B3DHomMatrix &rMat)
B2DPolygon createB2DPolygonFromB3DPolygon(const B3DPolygon &rCandidate, const B3DHomMatrix &rMat)