Coverage Report

Created: 2026-03-31 11:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/chart2/source/view/main/Stripe.cxx
Line
Count
Source
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 <Stripe.hxx>
21
#include <CommonConverters.hxx>
22
#include <com/sun/star/drawing/PolyPolygonShape3D.hpp>
23
#include <com/sun/star/drawing/DoubleSequence.hpp>
24
#include <basegfx/polygon/b3dpolygon.hxx>
25
26
using namespace ::com::sun::star;
27
28
namespace chart
29
{
30
31
Stripe::Stripe( const drawing::Position3D& rPoint1
32
        , const drawing::Direction3D& rDirectionToPoint2
33
        , const drawing::Direction3D& rDirectionToPoint4 )
34
0
            : m_aPoint1(rPoint1)
35
0
            , m_aPoint2(rPoint1+rDirectionToPoint2)
36
0
            , m_aPoint3(m_aPoint2+rDirectionToPoint4)
37
0
            , m_aPoint4(rPoint1+rDirectionToPoint4)
38
0
            , m_bInvertNormal(false)
39
0
            , m_bManualNormalSet(false)
40
0
{
41
0
}
42
43
Stripe::Stripe( const drawing::Position3D& rPoint1
44
        , const drawing::Position3D& rPoint2
45
        , double fDepth )
46
0
        : m_aPoint1(rPoint1)
47
0
        , m_aPoint2(rPoint2)
48
0
        , m_aPoint3(rPoint2)
49
0
        , m_aPoint4(rPoint1)
50
0
        , m_bInvertNormal(false)
51
0
        , m_bManualNormalSet(false)
52
0
{
53
0
    m_aPoint3.PositionZ += fDepth;
54
0
    m_aPoint4.PositionZ += fDepth;
55
0
}
56
57
Stripe::Stripe( const drawing::Position3D& rPoint1
58
          , const drawing::Position3D& rPoint2
59
          , const drawing::Position3D& rPoint3
60
          , const drawing::Position3D& rPoint4 )
61
0
            : m_aPoint1(rPoint1)
62
0
            , m_aPoint2(rPoint2)
63
0
            , m_aPoint3(rPoint3)
64
0
            , m_aPoint4(rPoint4)
65
0
            , m_bInvertNormal(false)
66
0
            , m_bManualNormalSet(false)
67
0
{
68
0
}
69
70
void Stripe::SetManualNormal( const drawing::Direction3D& rNormal )
71
0
{
72
0
    m_aManualNormal = rNormal;
73
0
    m_bManualNormalSet = true;
74
0
}
75
76
void Stripe::InvertNormal( bool bInvertNormal )
77
0
{
78
0
    m_bInvertNormal = bInvertNormal;
79
0
}
80
81
uno::Any Stripe::getPolyPolygonShape3D() const
82
0
{
83
0
    drawing::PolyPolygonShape3D aPP;
84
85
0
    aPP.SequenceX.realloc(1);
86
0
    aPP.SequenceY.realloc(1);
87
0
    aPP.SequenceZ.realloc(1);
88
89
0
    drawing::DoubleSequence* pOuterSequenceX = aPP.SequenceX.getArray();
90
0
    drawing::DoubleSequence* pOuterSequenceY = aPP.SequenceY.getArray();
91
0
    drawing::DoubleSequence* pOuterSequenceZ = aPP.SequenceZ.getArray();
92
93
0
    pOuterSequenceX->realloc(4);
94
0
    pOuterSequenceY->realloc(4);
95
0
    pOuterSequenceZ->realloc(4);
96
97
0
    double* pInnerSequenceX = pOuterSequenceX->getArray();
98
0
    double* pInnerSequenceY = pOuterSequenceY->getArray();
99
0
    double* pInnerSequenceZ = pOuterSequenceZ->getArray();
100
101
0
    *pInnerSequenceX++ = m_aPoint1.PositionX;
102
0
    *pInnerSequenceY++ = m_aPoint1.PositionY;
103
0
    *pInnerSequenceZ++ = m_aPoint1.PositionZ;
104
105
0
    *pInnerSequenceX++ = m_aPoint2.PositionX;
106
0
    *pInnerSequenceY++ = m_aPoint2.PositionY;
107
0
    *pInnerSequenceZ++ = m_aPoint2.PositionZ;
108
109
0
    *pInnerSequenceX++ = m_aPoint3.PositionX;
110
0
    *pInnerSequenceY++ = m_aPoint3.PositionY;
111
0
    *pInnerSequenceZ++ = m_aPoint3.PositionZ;
112
113
0
    *pInnerSequenceX++ = m_aPoint4.PositionX;
114
0
    *pInnerSequenceY++ = m_aPoint4.PositionY;
115
0
    *pInnerSequenceZ++ = m_aPoint4.PositionZ;
116
117
0
    return uno::Any( &aPP, cppu::UnoType<drawing::PolyPolygonShape3D>::get());
118
0
}
119
120
drawing::Direction3D Stripe::getNormal() const
121
0
{
122
0
    drawing::Direction3D aRet(1.0,0.0,0.0);
123
124
0
    if( m_bManualNormalSet )
125
0
        aRet = m_aManualNormal;
126
0
    else
127
0
    {
128
0
        ::basegfx::B3DPolygon aPolygon3D;
129
0
        aPolygon3D.append(Position3DToB3DPoint( m_aPoint1 ));
130
0
        aPolygon3D.append(Position3DToB3DPoint( m_aPoint2 ));
131
0
        aPolygon3D.append(Position3DToB3DPoint( m_aPoint3 ));
132
0
        aPolygon3D.append(Position3DToB3DPoint( m_aPoint4 ));
133
0
        ::basegfx::B3DVector aNormal(aPolygon3D.getNormal());
134
0
        aRet = B3DVectorToDirection3D(aNormal);
135
0
    }
136
137
0
    if( m_bInvertNormal )
138
0
    {
139
0
        aRet.DirectionX *= -1.0;
140
0
        aRet.DirectionY *= -1.0;
141
0
        aRet.DirectionZ *= -1.0;
142
0
    }
143
0
    return aRet;
144
0
}
145
146
uno::Any Stripe::getNormalsPolygon() const
147
0
{
148
0
    drawing::PolyPolygonShape3D aPP;
149
150
0
    aPP.SequenceX.realloc(1);
151
0
    aPP.SequenceY.realloc(1);
152
0
    aPP.SequenceZ.realloc(1);
153
154
0
    drawing::DoubleSequence* pOuterSequenceX = aPP.SequenceX.getArray();
155
0
    drawing::DoubleSequence* pOuterSequenceY = aPP.SequenceY.getArray();
156
0
    drawing::DoubleSequence* pOuterSequenceZ = aPP.SequenceZ.getArray();
157
158
0
    pOuterSequenceX->realloc(4);
159
0
    pOuterSequenceY->realloc(4);
160
0
    pOuterSequenceZ->realloc(4);
161
162
0
    double* pInnerSequenceX = pOuterSequenceX->getArray();
163
0
    double* pInnerSequenceY = pOuterSequenceY->getArray();
164
0
    double* pInnerSequenceZ = pOuterSequenceZ->getArray();
165
166
0
    drawing::Direction3D aNormal( getNormal() );
167
168
0
    for(sal_Int32 nN=4; --nN; )
169
0
    {
170
0
        *pInnerSequenceX++ = aNormal.DirectionX;
171
0
        *pInnerSequenceY++ = aNormal.DirectionY;
172
0
        *pInnerSequenceZ++ = aNormal.DirectionZ;
173
0
    }
174
0
    return uno::Any( &aPP, cppu::UnoType<drawing::PolyPolygonShape3D>::get());
175
0
}
176
177
uno::Any Stripe::getTexturePolygon( short nRotatedTexture )
178
0
{
179
0
    drawing::PolyPolygonShape3D aPP;
180
181
0
    aPP.SequenceX.realloc(1);
182
0
    aPP.SequenceY.realloc(1);
183
0
    aPP.SequenceZ.realloc(1);
184
185
0
    drawing::DoubleSequence* pOuterSequenceX = aPP.SequenceX.getArray();
186
0
    drawing::DoubleSequence* pOuterSequenceY = aPP.SequenceY.getArray();
187
0
    drawing::DoubleSequence* pOuterSequenceZ = aPP.SequenceZ.getArray();
188
189
0
    pOuterSequenceX->realloc(4);
190
0
    pOuterSequenceY->realloc(4);
191
0
    pOuterSequenceZ->realloc(4);
192
193
0
    double* pInnerSequenceX = pOuterSequenceX->getArray();
194
0
    double* pInnerSequenceY = pOuterSequenceY->getArray();
195
0
    double* pInnerSequenceZ = pOuterSequenceZ->getArray();
196
197
0
    if( nRotatedTexture==0 )
198
0
    {
199
0
        *pInnerSequenceX++ = 0.0;
200
0
        *pInnerSequenceY++ = 0.0;
201
0
        *pInnerSequenceZ++ = 0.0;
202
203
0
        *pInnerSequenceX++ = 0.0;
204
0
        *pInnerSequenceY++ = 1.0;
205
0
        *pInnerSequenceZ++ = 0.0;
206
207
0
        *pInnerSequenceX++ = 1.0;
208
0
        *pInnerSequenceY++ = 1.0;
209
0
        *pInnerSequenceZ++ = 0.0;
210
211
0
        *pInnerSequenceX++ = 1.0;
212
0
        *pInnerSequenceY++ = 0.0;
213
0
        *pInnerSequenceZ++ = 0.0;
214
0
    }
215
0
    else if( nRotatedTexture==1 )
216
0
    {
217
0
        *pInnerSequenceX++ = 1.0;
218
0
        *pInnerSequenceY++ = 0.0;
219
0
        *pInnerSequenceZ++ = 0.0;
220
221
0
        *pInnerSequenceX++ = 0.0;
222
0
        *pInnerSequenceY++ = 0.0;
223
0
        *pInnerSequenceZ++ = 0.0;
224
225
0
        *pInnerSequenceX++ = 0.0;
226
0
        *pInnerSequenceY++ = 1.0;
227
0
        *pInnerSequenceZ++ = 0.0;
228
229
0
        *pInnerSequenceX++ = 1.0;
230
0
        *pInnerSequenceY++ = 1.0;
231
0
        *pInnerSequenceZ++ = 0.0;
232
0
    }
233
0
    else if( nRotatedTexture==2 )
234
0
    {
235
0
        *pInnerSequenceX++ = 1.0;
236
0
        *pInnerSequenceY++ = 1.0;
237
0
        *pInnerSequenceZ++ = 0.0;
238
239
0
        *pInnerSequenceX++ = 1.0;
240
0
        *pInnerSequenceY++ = 0.0;
241
0
        *pInnerSequenceZ++ = 0.0;
242
243
0
        *pInnerSequenceX++ = 0.0;
244
0
        *pInnerSequenceY++ = 0.0;
245
0
        *pInnerSequenceZ++ = 0.0;
246
247
0
        *pInnerSequenceX++ = 0.0;
248
0
        *pInnerSequenceY++ = 1.0;
249
0
        *pInnerSequenceZ++ = 0.0;
250
0
    }
251
0
    else if( nRotatedTexture==3 )
252
0
    {
253
0
        *pInnerSequenceX++ = 0.0;
254
0
        *pInnerSequenceY++ = 1.0;
255
0
        *pInnerSequenceZ++ = 0.0;
256
257
0
        *pInnerSequenceX++ = 1.0;
258
0
        *pInnerSequenceY++ = 1.0;
259
0
        *pInnerSequenceZ++ = 0.0;
260
261
0
        *pInnerSequenceX++ = 1.0;
262
0
        *pInnerSequenceY++ = 0.0;
263
0
        *pInnerSequenceZ++ = 0.0;
264
265
0
        *pInnerSequenceX++ = 0.0;
266
0
        *pInnerSequenceY++ = 0.0;
267
0
        *pInnerSequenceZ++ = 0.0;
268
0
    }
269
0
    else if( nRotatedTexture==4 )
270
0
    {
271
0
        *pInnerSequenceX++ = 1.0;
272
0
        *pInnerSequenceY++ = 0.0;
273
0
        *pInnerSequenceZ++ = 0.0;
274
275
0
        *pInnerSequenceX++ = 1.0;
276
0
        *pInnerSequenceY++ = 1.0;
277
0
        *pInnerSequenceZ++ = 0.0;
278
279
0
        *pInnerSequenceX++ = 0.0;
280
0
        *pInnerSequenceY++ = 1.0;
281
0
        *pInnerSequenceZ++ = 0.0;
282
283
0
        *pInnerSequenceX++ = 0.0;
284
0
        *pInnerSequenceY++ = 0.0;
285
0
        *pInnerSequenceZ++ = 0.0;
286
0
    }
287
0
    else if( nRotatedTexture==5 )
288
0
    {
289
0
        *pInnerSequenceX++ = 0.0;
290
0
        *pInnerSequenceY++ = 0.0;
291
0
        *pInnerSequenceZ++ = 0.0;
292
293
0
        *pInnerSequenceX++ = 1.0;
294
0
        *pInnerSequenceY++ = 0.0;
295
0
        *pInnerSequenceZ++ = 0.0;
296
297
0
        *pInnerSequenceX++ = 1.0;
298
0
        *pInnerSequenceY++ = 1.0;
299
0
        *pInnerSequenceZ++ = 0.0;
300
301
0
        *pInnerSequenceX++ = 0.0;
302
0
        *pInnerSequenceY++ = 1.0;
303
0
        *pInnerSequenceZ++ = 0.0;
304
0
    }
305
0
    else if( nRotatedTexture==6 )
306
0
    {
307
0
        *pInnerSequenceX++ = 0.0;
308
0
        *pInnerSequenceY++ = 1.0;
309
0
        *pInnerSequenceZ++ = 0.0;
310
311
0
        *pInnerSequenceX++ = 0.0;
312
0
        *pInnerSequenceY++ = 0.0;
313
0
        *pInnerSequenceZ++ = 0.0;
314
315
0
        *pInnerSequenceX++ = 1.0;
316
0
        *pInnerSequenceY++ = 0.0;
317
0
        *pInnerSequenceZ++ = 0.0;
318
319
0
        *pInnerSequenceX++ = 1.0;
320
0
        *pInnerSequenceY++ = 1.0;
321
0
        *pInnerSequenceZ++ = 0.0;
322
0
    }
323
0
    else if( nRotatedTexture==7 )
324
0
    {
325
0
        *pInnerSequenceX++ = 1.0;
326
0
        *pInnerSequenceY++ = 1.0;
327
0
        *pInnerSequenceZ++ = 0.0;
328
329
0
        *pInnerSequenceX++ = 0.0;
330
0
        *pInnerSequenceY++ = 1.0;
331
0
        *pInnerSequenceZ++ = 0.0;
332
333
0
        *pInnerSequenceX++ = 0.0;
334
0
        *pInnerSequenceY++ = 0.0;
335
0
        *pInnerSequenceZ++ = 0.0;
336
337
0
        *pInnerSequenceX++ = 1.0;
338
0
        *pInnerSequenceY++ = 0.0;
339
0
        *pInnerSequenceZ++ = 0.0;
340
0
    }
341
342
0
    return uno::Any( &aPP, cppu::UnoType<drawing::PolyPolygonShape3D>::get());
343
0
}
344
345
} //namespace chart
346
347
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */