LibreOffice Module drawinglayer (master) 1
baseprimitive3d.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
24
25
26using namespace com::sun::star;
27
28
30{
32 {
33 }
34
36 {
37 }
38
39 bool BasePrimitive3D::operator==( const BasePrimitive3D& rPrimitive ) const
40 {
41 return (getPrimitive3DID() == rPrimitive.getPrimitive3DID());
42 }
43
45 {
46 return get3DDecomposition(rViewInformation).getB3DRange(rViewInformation);
47 }
48
50 {
51 return Primitive3DContainer();
52 }
53
54 css::uno::Sequence< ::css::uno::Reference< ::css::graphic::XPrimitive3D > > SAL_CALL BasePrimitive3D::getDecomposition( const uno::Sequence< beans::PropertyValue >& rViewParameters )
55 {
56 const geometry::ViewInformation3D aViewInformation(rViewParameters);
58 }
59
60 css::geometry::RealRectangle3D SAL_CALL BasePrimitive3D::getRange( const uno::Sequence< beans::PropertyValue >& rViewParameters )
61 {
62 const geometry::ViewInformation3D aViewInformation(rViewParameters);
64 }
65
66
68 {
69 return Primitive3DContainer();
70 }
71
73 {
74 }
75
77 {
78 std::unique_lock aGuard( m_aMutex );
79
80 if(getBuffered3DDecomposition().empty())
81 {
82 const Primitive3DContainer aNewSequence(create3DDecomposition(rViewInformation));
83 const_cast< BufferedDecompositionPrimitive3D* >(this)->setBuffered3DDecomposition(aNewSequence);
84 }
85
87 }
88
89// tooling
90
91 // get range3D from a given Primitive3DReference
93 {
94 basegfx::B3DRange aRetval;
95
96 if(rCandidate.is())
97 {
98 const BasePrimitive3D* pCandidate(static_cast< BasePrimitive3D* >(rCandidate.get()));
99 aRetval.expand(pCandidate->getB3DRange(aViewInformation));
100 }
101
102 return aRetval;
103 }
104
105 // get range3D from a given Primitive3DContainer
107 {
108 basegfx::B3DRange aRetval;
109
110 if(!empty())
111 {
112 const size_t nCount(size());
113
114 for(size_t a(0); a < nCount; a++)
115 {
116 aRetval.expand(getB3DRangeFromPrimitive3DReference((*this)[a], aViewInformation));
117 }
118 }
119
120 return aRetval;
121 }
122
124 {
125 const bool bAIs(rxA.is());
126
127 if(bAIs != rxB.is())
128 {
129 return false;
130 }
131
132 if(!bAIs)
133 {
134 return true;
135 }
136
137 const BasePrimitive3D* pA(static_cast< const BasePrimitive3D* >(rxA.get()));
138 const BasePrimitive3D* pB(static_cast< const BasePrimitive3D* >(rxB.get()));
139
140 return pA->operator==(*pB);
141 }
142
144 {
145 const bool bAHasElements(!empty());
146
147 if(bAHasElements != !rB.empty())
148 {
149 return false;
150 }
151
152 if(!bAHasElements)
153 {
154 return true;
155 }
156
157 const size_t nCount(size());
158
159 if(nCount != rB.size())
160 {
161 return false;
162 }
163
164 for(size_t a(0); a < nCount; a++)
165 {
166 if(!arePrimitive3DReferencesEqual((*this)[a], rB[a]))
167 {
168 return false;
169 }
170 }
171
172 return true;
173 }
174
176 {
177 insert(end(), rSource.begin(), rSource.end());
178 }
179
180} // end of namespace
181
182/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void expand(const B3DTuple &rTuple)
virtual Primitive3DContainer get3DDecomposition(const geometry::ViewInformation3D &rViewInformation) const
The default implementation returns an empty sequence.
virtual basegfx::B3DRange getB3DRange(const geometry::ViewInformation3D &rViewInformation) const
This method is for places where using the C++ implementation directly is possible.
virtual css::geometry::RealRectangle3D SAL_CALL getRange(const css::uno::Sequence< css::beans::PropertyValue > &rViewParameters) override
the getRange default implementation will use getDecomposition to create the range information from me...
virtual sal_uInt32 getPrimitive3DID() const =0
provide unique ID for fast identifying of known primitive implementations in renderers.
virtual css::uno::Sequence< ::css::uno::Reference< ::css::graphic::XPrimitive3D > > SAL_CALL getDecomposition(const css::uno::Sequence< css::beans::PropertyValue > &rViewParameters) override
The getDecomposition implementation for UNO API will use getDecomposition from this implementation.
virtual bool operator==(const BasePrimitive3D &rPrimitive) const
the ==operator is mainly needed to allow testing newly-created high level primitives against their la...
void setBuffered3DDecomposition(const Primitive3DContainer &rNew)
virtual Primitive3DContainer create3DDecomposition(const geometry::ViewInformation3D &rViewInformation) const
method which is to be used to implement the local decomposition of a 2D primitive.
const Primitive3DContainer & getBuffered3DDecomposition() const
access methods to maBuffered3DDecomposition.
virtual Primitive3DContainer get3DDecomposition(const geometry::ViewInformation3D &rViewInformation) const override
The getDecomposition default implementation will on demand use create3DDecomposition() if maBuffered3...
bool operator==(const Primitive3DContainer &rB) const
basegfx::B3DRange getB3DRange(const geometry::ViewInformation3D &aViewInformation) const
void append(const Primitive3DContainer &rSource)
int nCount
uno_Any a
geometry::RealRectangle3D rectangle3DFromB3DRectangle(const ::basegfx::B3DRange &rRect)
size
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
SdrPrimitive3D class.
css::uno::Reference< css::graphic::XPrimitive3D > Primitive3DReference
bool arePrimitive3DReferencesEqual(const Primitive3DReference &rxA, const Primitive3DReference &rxB)
compare two Primitive2DReferences for equality, including trying to get implementations (BasePrimitiv...
basegfx::B3DRange getB3DRangeFromPrimitive3DReference(const Primitive3DReference &rCandidate, const geometry::ViewInformation3D &aViewInformation)
get B3DRange from a given Primitive3DReference
end