1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include "VPolarGrid.hxx"
#include "VCartesianGrid.hxx"
#include "Tickmarks.hxx"
#include "PlottingPositionHelper.hxx"
#include "ShapeFactory.hxx"
#include "ObjectIdentifier.hxx"
#include "macros.hxx"
#include "CommonConverters.hxx"
#include "Tickmarks_Equidistant.hxx"
#include <com/sun/star/drawing/LineStyle.hpp>
#include <vector>
namespace chart
{
using namespace ::com::sun::star;
using namespace ::com::sun::star::chart2;
using ::com::sun::star::uno::Reference;
VPolarGrid::VPolarGrid( sal_Int32 nDimensionIndex, sal_Int32 nDimensionCount
, const uno::Sequence< Reference< beans::XPropertySet > > & rGridPropertiesList )
: VAxisOrGridBase( nDimensionIndex, nDimensionCount )
, m_aGridPropertiesList( rGridPropertiesList )
, m_pPosHelper( new PolarPlottingPositionHelper() )
, m_aIncrements()
{
PlotterBase::m_pPosHelper = m_pPosHelper;
}
VPolarGrid::~VPolarGrid()
{
delete m_pPosHelper;
m_pPosHelper = NULL;
}
void VPolarGrid::setIncrements( const std::vector< ExplicitIncrementData >& rIncrements )
{
m_aIncrements = rIncrements;
}
void VPolarGrid::getAllTickInfos( sal_Int32 nDimensionIndex, TickInfoArraysType& rAllTickInfos ) const
{
TickFactory aTickFactory(
m_pPosHelper->getScales()[nDimensionIndex], m_aIncrements[nDimensionIndex] );
aTickFactory.getAllTicks( rAllTickInfos );
}
void VPolarGrid::createLinePointSequence_ForAngleAxis(
drawing::PointSequenceSequence& rPoints
, TickInfoArraysType& rAllTickInfos
, const ExplicitIncrementData& rIncrement
, const ExplicitScaleData& rScale
, PolarPlottingPositionHelper* pPosHelper
, double fLogicRadius, double fLogicZ )
{
Reference< XScaling > xInverseScaling( NULL );
if( rScale.Scaling.is() )
xInverseScaling = rScale.Scaling->getInverseScaling();
sal_Int32 nTick = 0;
EquidistantTickIter aIter( rAllTickInfos, rIncrement, 0, 0 );
for( TickInfo* pTickInfo = aIter.firstInfo()
; pTickInfo
; pTickInfo = aIter.nextInfo(), nTick++ )
{
if(nTick>=rPoints[0].getLength())
rPoints[0].realloc(rPoints[0].getLength()+30);
//xxxxx pTickInfo->updateUnscaledValue( xInverseScaling );
double fLogicAngle = pTickInfo->getUnscaledTickValue();
drawing::Position3D aScenePosition3D( pPosHelper->transformAngleRadiusToScene( fLogicAngle, fLogicRadius, fLogicZ ) );
rPoints[0][nTick].X = static_cast<sal_Int32>(aScenePosition3D.PositionX);
rPoints[0][nTick].Y = static_cast<sal_Int32>(aScenePosition3D.PositionY);
}
if(rPoints[0].getLength()>1)
{
rPoints[0].realloc(nTick+1);
rPoints[0][nTick].X = rPoints[0][0].X;
rPoints[0][nTick].Y = rPoints[0][0].Y;
}
else
rPoints[0].realloc(0);
}
#ifdef NOTYET
void VPolarGrid::create2DAngleGrid( const Reference< drawing::XShapes >& xLogicTarget
, TickInfoArraysType& /* rRadiusTickInfos */
, TickInfoArraysType& rAngleTickInfos
, const ::std::vector<VLineProperties>& rLinePropertiesList )
{
Reference< drawing::XShapes > xMainTarget(
this->createGroupShape( xLogicTarget, m_aCID ) );
const ExplicitScaleData& rAngleScale = m_pPosHelper->getScales()[0];
Reference< XScaling > xInverseScaling( NULL );
if( rAngleScale.Scaling.is() )
xInverseScaling = rAngleScale.Scaling->getInverseScaling();
double fLogicInnerRadius = m_pPosHelper->getInnerLogicRadius();
double fLogicOuterRadius = m_pPosHelper->getOuterLogicRadius();
sal_Int32 nLinePropertiesCount = rLinePropertiesList.size();
TickInfoArraysType::iterator aDepthIter = rAngleTickInfos.begin();
if(nLinePropertiesCount)
{
double fLogicZ = 1.0;//as defined
sal_Int32 nDepth=0;
//create axis main lines
drawing::PointSequenceSequence aAllPoints;
TickInfoArrayType::iterator aTickIter = (*aDepthIter).begin();
const TickInfoArrayType::const_iterator aTickEnd = (*aDepthIter).end();
for( ; aTickIter != aTickEnd; ++aTickIter )
{
TickInfo& rTickInfo = *aTickIter;
if( !rTickInfo.bPaintIt )
continue;
//xxxxx rTickInfo.updateUnscaledValue( xInverseScaling );
double fLogicAngle = rTickInfo.getUnscaledTickValue();
drawing::PointSequenceSequence aPoints(1);
aPoints[0].realloc(2);
drawing::Position3D aScenePositionStart( m_pPosHelper->transformAngleRadiusToScene( fLogicAngle, fLogicInnerRadius, fLogicZ ) );
drawing::Position3D aScenePositionEnd( m_pPosHelper->transformAngleRadiusToScene( fLogicAngle, fLogicOuterRadius, fLogicZ ) );
aPoints[0][0].X = static_cast<sal_Int32>(aScenePositionStart.PositionX);
aPoints[0][0].Y = static_cast<sal_Int32>(aScenePositionStart.PositionY);
aPoints[0][1].X = static_cast<sal_Int32>(aScenePositionEnd.PositionX);
aPoints[0][1].Y = static_cast<sal_Int32>(aScenePositionEnd.PositionY);
appendPointSequence( aAllPoints, aPoints );
}
Reference< drawing::XShape > xShape = m_pShapeFactory->createLine2D(
xMainTarget, aAllPoints, &rLinePropertiesList[nDepth] );
//because of this name this line will be used for marking
m_pShapeFactory->setShapeName( xShape, "MarkHandles" );
}
}
#endif
void VPolarGrid::create2DRadiusGrid( const Reference< drawing::XShapes >& xLogicTarget
, TickInfoArraysType& rRadiusTickInfos
, TickInfoArraysType& rAngleTickInfos
, const ::std::vector<VLineProperties>& rLinePropertiesList )
{
Reference< drawing::XShapes > xMainTarget(
this->createGroupShape( xLogicTarget, m_aCID ) );
const ExplicitScaleData& rRadiusScale = m_pPosHelper->getScales()[1];
const ExplicitScaleData& rAngleScale = m_pPosHelper->getScales()[0];
const ExplicitIncrementData& rAngleIncrement = m_aIncrements[0];
Reference< XScaling > xInverseRadiusScaling( NULL );
if( rRadiusScale.Scaling.is() )
xInverseRadiusScaling = rRadiusScale.Scaling->getInverseScaling();
sal_Int32 nLinePropertiesCount = rLinePropertiesList.size();
TickInfoArraysType::iterator aDepthIter = rRadiusTickInfos.begin();
const TickInfoArraysType::const_iterator aDepthEnd = rRadiusTickInfos.end();
for( sal_Int32 nDepth=0
; aDepthIter != aDepthEnd && nDepth < nLinePropertiesCount
; ++aDepthIter, nDepth++ )
{
if( !rLinePropertiesList[nDepth].isLineVisible() )
continue;
Reference< drawing::XShapes > xTarget( xMainTarget );
if( nDepth > 0 )
{
xTarget.set( this->createGroupShape( xLogicTarget
, ObjectIdentifier::addChildParticle( m_aCID, ObjectIdentifier::createChildParticleWithIndex( OBJECTTYPE_SUBGRID, nDepth-1 ) )
) );
if(!xTarget.is())
xTarget.set( xMainTarget );
}
//create axis main lines
drawing::PointSequenceSequence aAllPoints;
TickInfoArrayType::iterator aTickIter = (*aDepthIter).begin();
const TickInfoArrayType::const_iterator aTickEnd = (*aDepthIter).end();
for( ; aTickIter != aTickEnd; ++aTickIter )
{
TickInfo& rTickInfo = *aTickIter;
if( !rTickInfo.bPaintIt )
continue;
//xxxxx rTickInfo.updateUnscaledValue( xInverseRadiusScaling );
double fLogicRadius = rTickInfo.getUnscaledTickValue();
double fLogicZ = 1.0;//as defined
drawing::PointSequenceSequence aPoints(1);
VPolarGrid::createLinePointSequence_ForAngleAxis( aPoints, rAngleTickInfos
, rAngleIncrement, rAngleScale, m_pPosHelper, fLogicRadius, fLogicZ );
if(aPoints[0].getLength())
appendPointSequence( aAllPoints, aPoints );
}
Reference< drawing::XShape > xShape = m_pShapeFactory->createLine2D(
xTarget, aAllPoints, &rLinePropertiesList[nDepth] );
//because of this name this line will be used for marking
::chart::AbstractShapeFactory::setShapeName( xShape, "MarkHandles" );
}
}
void VPolarGrid::createShapes()
{
OSL_PRECOND(m_pShapeFactory&&m_xLogicTarget.is()&&m_xFinalTarget.is(),"Axis is not proper initialized");
if(!(m_pShapeFactory&&m_xLogicTarget.is()&&m_xFinalTarget.is()))
return;
if(!m_aGridPropertiesList.getLength())
return;
//create all scaled tickmark values
TickInfoArraysType aAngleTickInfos;
TickInfoArraysType aRadiusTickInfos;
getAllTickInfos( 0, aAngleTickInfos );
getAllTickInfos( 1, aRadiusTickInfos );
::std::vector<VLineProperties> aLinePropertiesList;
VCartesianGrid::fillLinePropertiesFromGridModel( aLinePropertiesList, m_aGridPropertiesList );
//create tick mark line shapes
if(2==m_nDimension)
{
if(m_nDimensionIndex==1)
this->create2DRadiusGrid( m_xLogicTarget, aRadiusTickInfos, aAngleTickInfos, aLinePropertiesList );
//else //no Angle Grid so far as this equals exactly the y axis positions
// this->create2DAngleGrid( m_xLogicTarget, aRadiusTickInfos, aAngleTickInfos, aLinePropertiesList );
}
}
} //namespace chart
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|