1*cde9e8dcSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*cde9e8dcSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*cde9e8dcSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*cde9e8dcSAndrew Rist  * distributed with this work for additional information
6*cde9e8dcSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*cde9e8dcSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*cde9e8dcSAndrew Rist  * "License"); you may not use this file except in compliance
9*cde9e8dcSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*cde9e8dcSAndrew Rist  *
11*cde9e8dcSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*cde9e8dcSAndrew Rist  *
13*cde9e8dcSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*cde9e8dcSAndrew Rist  * software distributed under the License is distributed on an
15*cde9e8dcSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*cde9e8dcSAndrew Rist  * KIND, either express or implied.  See the License for the
17*cde9e8dcSAndrew Rist  * specific language governing permissions and limitations
18*cde9e8dcSAndrew Rist  * under the License.
19*cde9e8dcSAndrew Rist  *
20*cde9e8dcSAndrew Rist  *************************************************************/
21*cde9e8dcSAndrew Rist 
22*cde9e8dcSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_chart2.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "BubbleChart.hxx"
28cdf0e10cSrcweir #include "PlottingPositionHelper.hxx"
29cdf0e10cSrcweir #include "ShapeFactory.hxx"
30cdf0e10cSrcweir #include "CommonConverters.hxx"
31cdf0e10cSrcweir #include "macros.hxx"
32cdf0e10cSrcweir #include "ViewDefines.hxx"
33cdf0e10cSrcweir #include "ObjectIdentifier.hxx"
34cdf0e10cSrcweir #include "Splines.hxx"
35cdf0e10cSrcweir #include "LabelPositionHelper.hxx"
36cdf0e10cSrcweir #include "Clipping.hxx"
37cdf0e10cSrcweir #include "Stripe.hxx"
38cdf0e10cSrcweir 
39cdf0e10cSrcweir #include <com/sun/star/chart2/Symbol.hpp>
40cdf0e10cSrcweir #include <com/sun/star/chart/DataLabelPlacement.hpp>
41cdf0e10cSrcweir #include <tools/debug.hxx>
42cdf0e10cSrcweir #include <editeng/unoprnms.hxx>
43cdf0e10cSrcweir #include <rtl/math.hxx>
44cdf0e10cSrcweir #include <com/sun/star/drawing/DoubleSequence.hpp>
45cdf0e10cSrcweir #include <com/sun/star/drawing/NormalsKind.hpp>
46cdf0e10cSrcweir #include <com/sun/star/lang/XServiceName.hpp>
47cdf0e10cSrcweir 
48cdf0e10cSrcweir //.............................................................................
49cdf0e10cSrcweir namespace chart
50cdf0e10cSrcweir {
51cdf0e10cSrcweir //.............................................................................
52cdf0e10cSrcweir using namespace ::com::sun::star;
53cdf0e10cSrcweir using namespace ::rtl::math;
54cdf0e10cSrcweir using namespace ::com::sun::star::chart2;
55cdf0e10cSrcweir 
56cdf0e10cSrcweir //-----------------------------------------------------------------------------
57cdf0e10cSrcweir //-----------------------------------------------------------------------------
58cdf0e10cSrcweir //-----------------------------------------------------------------------------
59cdf0e10cSrcweir 
BubbleChart(const uno::Reference<XChartType> & xChartTypeModel,sal_Int32 nDimensionCount)60cdf0e10cSrcweir BubbleChart::BubbleChart( const uno::Reference<XChartType>& xChartTypeModel
61cdf0e10cSrcweir                      , sal_Int32 nDimensionCount )
62cdf0e10cSrcweir         : VSeriesPlotter( xChartTypeModel, nDimensionCount, false )
63cdf0e10cSrcweir         , m_bShowNegativeValues(false)
64cdf0e10cSrcweir         , m_bBubbleSizeAsArea(true)
65cdf0e10cSrcweir         , m_fBubbleSizeScaling(1.0)
66cdf0e10cSrcweir         , m_fMaxLogicBubbleSize( 0.0 )
67cdf0e10cSrcweir         , m_fBubbleSizeFactorToScreen( 1.0 )
68cdf0e10cSrcweir {
69cdf0e10cSrcweir     if( !m_pMainPosHelper )
70cdf0e10cSrcweir         m_pMainPosHelper = new PlottingPositionHelper();
71cdf0e10cSrcweir     PlotterBase::m_pPosHelper = m_pMainPosHelper;
72cdf0e10cSrcweir     VSeriesPlotter::m_pMainPosHelper = m_pMainPosHelper;
73cdf0e10cSrcweir }
74cdf0e10cSrcweir 
~BubbleChart()75cdf0e10cSrcweir BubbleChart::~BubbleChart()
76cdf0e10cSrcweir {
77cdf0e10cSrcweir     delete m_pMainPosHelper;
78cdf0e10cSrcweir }
79cdf0e10cSrcweir 
calculateMaximumLogicBubbleSize()80cdf0e10cSrcweir void BubbleChart::calculateMaximumLogicBubbleSize()
81cdf0e10cSrcweir {
82cdf0e10cSrcweir     double fMaxSize = 0.0;
83cdf0e10cSrcweir 
84cdf0e10cSrcweir     sal_Int32 nStartIndex = 0;
85cdf0e10cSrcweir     sal_Int32 nEndIndex = VSeriesPlotter::getPointCount();
86cdf0e10cSrcweir     for( sal_Int32 nIndex = nStartIndex; nIndex < nEndIndex; nIndex++ )
87cdf0e10cSrcweir     {
88cdf0e10cSrcweir         ::std::vector< ::std::vector< VDataSeriesGroup > >::iterator             aZSlotIter = m_aZSlots.begin();
89cdf0e10cSrcweir         const ::std::vector< ::std::vector< VDataSeriesGroup > >::const_iterator  aZSlotEnd = m_aZSlots.end();
90cdf0e10cSrcweir         for( ; aZSlotIter != aZSlotEnd; aZSlotIter++ )
91cdf0e10cSrcweir         {
92cdf0e10cSrcweir             ::std::vector< VDataSeriesGroup >::iterator             aXSlotIter = aZSlotIter->begin();
93cdf0e10cSrcweir             const ::std::vector< VDataSeriesGroup >::const_iterator aXSlotEnd = aZSlotIter->end();
94cdf0e10cSrcweir             for( ; aXSlotIter != aXSlotEnd; aXSlotIter++ )
95cdf0e10cSrcweir             {
96cdf0e10cSrcweir                 ::std::vector< VDataSeries* >* pSeriesList = &(aXSlotIter->m_aSeriesVector);
97cdf0e10cSrcweir                 ::std::vector< VDataSeries* >::const_iterator       aSeriesIter = pSeriesList->begin();
98cdf0e10cSrcweir                 const ::std::vector< VDataSeries* >::const_iterator aSeriesEnd  = pSeriesList->end();
99cdf0e10cSrcweir                 for( ; aSeriesIter != aSeriesEnd; aSeriesIter++ )
100cdf0e10cSrcweir                 {
101cdf0e10cSrcweir                     VDataSeries* pSeries( *aSeriesIter );
102cdf0e10cSrcweir                     if(!pSeries)
103cdf0e10cSrcweir                         continue;
104cdf0e10cSrcweir 
105cdf0e10cSrcweir                     double fSize = pSeries->getBubble_Size( nIndex );
106cdf0e10cSrcweir                     if( m_bShowNegativeValues )
107cdf0e10cSrcweir                         fSize = fabs(fSize);
108cdf0e10cSrcweir                     if( fSize > fMaxSize )
109cdf0e10cSrcweir                         fMaxSize = fSize;
110cdf0e10cSrcweir                 }
111cdf0e10cSrcweir             }
112cdf0e10cSrcweir         }
113cdf0e10cSrcweir     }
114cdf0e10cSrcweir 
115cdf0e10cSrcweir     m_fMaxLogicBubbleSize = fMaxSize;
116cdf0e10cSrcweir }
117cdf0e10cSrcweir 
calculateBubbleSizeScalingFactor()118cdf0e10cSrcweir void BubbleChart::calculateBubbleSizeScalingFactor()
119cdf0e10cSrcweir {
120cdf0e10cSrcweir     double fLogicZ=1.0;
121cdf0e10cSrcweir     drawing::Position3D aSceneMinPos( m_pMainPosHelper->transformLogicToScene( m_pMainPosHelper->getLogicMinX(),m_pMainPosHelper->getLogicMinY(),fLogicZ, false ) );
122cdf0e10cSrcweir     drawing::Position3D aSceneMaxPos( m_pMainPosHelper->transformLogicToScene( m_pMainPosHelper->getLogicMaxX(),m_pMainPosHelper->getLogicMaxY(),fLogicZ, false ) );
123cdf0e10cSrcweir 
124cdf0e10cSrcweir     awt::Point aScreenMinPos( LabelPositionHelper(m_pMainPosHelper,m_nDimension,m_xLogicTarget,m_pShapeFactory).transformSceneToScreenPosition( aSceneMinPos ) );
125cdf0e10cSrcweir     awt::Point aScreenMaxPos( LabelPositionHelper(m_pMainPosHelper,m_nDimension,m_xLogicTarget,m_pShapeFactory).transformSceneToScreenPosition( aSceneMaxPos ) );
126cdf0e10cSrcweir 
127cdf0e10cSrcweir     sal_Int32 nWidth = abs( aScreenMaxPos.X - aScreenMinPos.X );
128cdf0e10cSrcweir     sal_Int32 nHeight = abs( aScreenMaxPos.Y - aScreenMinPos.Y );
129cdf0e10cSrcweir 
130cdf0e10cSrcweir     sal_Int32 nMinExtend = std::min( nWidth, nHeight );
131cdf0e10cSrcweir     m_fBubbleSizeFactorToScreen = nMinExtend * 0.25;//max bubble size is 25 percent of diagram size
132cdf0e10cSrcweir }
133cdf0e10cSrcweir 
transformToScreenBubbleSize(double fLogicSize)134cdf0e10cSrcweir drawing::Direction3D BubbleChart::transformToScreenBubbleSize( double fLogicSize )
135cdf0e10cSrcweir {
136cdf0e10cSrcweir     drawing::Direction3D aRet(0,0,0);
137cdf0e10cSrcweir 
138cdf0e10cSrcweir     if( ::rtl::math::isNan(fLogicSize) || ::rtl::math::isInf(fLogicSize) )
139cdf0e10cSrcweir         return aRet;
140cdf0e10cSrcweir 
141cdf0e10cSrcweir     if( m_bShowNegativeValues )
142cdf0e10cSrcweir         fLogicSize = fabs(fLogicSize);
143cdf0e10cSrcweir 
144cdf0e10cSrcweir     double fMaxSize = m_fMaxLogicBubbleSize;
145cdf0e10cSrcweir 
146cdf0e10cSrcweir     double fMaxRadius = fMaxSize;
147cdf0e10cSrcweir     double fRaduis = fLogicSize;
148cdf0e10cSrcweir     if( m_bBubbleSizeAsArea )
149cdf0e10cSrcweir     {
150cdf0e10cSrcweir         fMaxRadius = sqrt( fMaxSize / F_PI );
151cdf0e10cSrcweir         fRaduis = sqrt( fLogicSize / F_PI );
152cdf0e10cSrcweir     }
153cdf0e10cSrcweir 
154cdf0e10cSrcweir     aRet.DirectionX = m_fBubbleSizeScaling * m_fBubbleSizeFactorToScreen * fRaduis / fMaxRadius;
155cdf0e10cSrcweir     aRet.DirectionY = aRet.DirectionX;
156cdf0e10cSrcweir 
157cdf0e10cSrcweir     return aRet;
158cdf0e10cSrcweir }
159cdf0e10cSrcweir 
isExpandIfValuesCloseToBorder(sal_Int32)160cdf0e10cSrcweir bool BubbleChart::isExpandIfValuesCloseToBorder( sal_Int32 /*nDimensionIndex*/ )
161cdf0e10cSrcweir {
162cdf0e10cSrcweir     return true;
163cdf0e10cSrcweir }
164cdf0e10cSrcweir 
isSeperateStackingForDifferentSigns(sal_Int32)165cdf0e10cSrcweir bool BubbleChart::isSeperateStackingForDifferentSigns( sal_Int32 /*nDimensionIndex*/ )
166cdf0e10cSrcweir {
167cdf0e10cSrcweir     return false;
168cdf0e10cSrcweir }
169cdf0e10cSrcweir 
170cdf0e10cSrcweir //-----------------------------------------------------------------
171cdf0e10cSrcweir 
getLegendSymbolStyle()172cdf0e10cSrcweir LegendSymbolStyle BubbleChart::getLegendSymbolStyle()
173cdf0e10cSrcweir {
174cdf0e10cSrcweir     return LegendSymbolStyle_CIRCLE;
175cdf0e10cSrcweir }
176cdf0e10cSrcweir 
getPreferredDiagramAspectRatio() const177cdf0e10cSrcweir drawing::Direction3D BubbleChart::getPreferredDiagramAspectRatio() const
178cdf0e10cSrcweir {
179cdf0e10cSrcweir     return drawing::Direction3D(-1,-1,-1);
180cdf0e10cSrcweir }
181cdf0e10cSrcweir 
addSeries(VDataSeries * pSeries,sal_Int32 zSlot,sal_Int32 xSlot,sal_Int32 ySlot)182cdf0e10cSrcweir void BubbleChart::addSeries( VDataSeries* pSeries, sal_Int32 zSlot, sal_Int32 xSlot, sal_Int32 ySlot )
183cdf0e10cSrcweir {
184cdf0e10cSrcweir     VSeriesPlotter::addSeries( pSeries, zSlot, xSlot, ySlot );
185cdf0e10cSrcweir }
186cdf0e10cSrcweir 
187cdf0e10cSrcweir //better performance for big data
188cdf0e10cSrcweir struct FormerPoint
189cdf0e10cSrcweir {
FormerPointchart::FormerPoint190cdf0e10cSrcweir     FormerPoint( double fX, double fY, double fZ )
191cdf0e10cSrcweir         : m_fX(fX), m_fY(fY), m_fZ(fZ)
192cdf0e10cSrcweir         {}
FormerPointchart::FormerPoint193cdf0e10cSrcweir     FormerPoint()
194cdf0e10cSrcweir     {
195cdf0e10cSrcweir         ::rtl::math::setNan( &m_fX );
196cdf0e10cSrcweir         ::rtl::math::setNan( &m_fY );
197cdf0e10cSrcweir         ::rtl::math::setNan( &m_fZ );
198cdf0e10cSrcweir     }
199cdf0e10cSrcweir 
200cdf0e10cSrcweir     double m_fX;
201cdf0e10cSrcweir     double m_fY;
202cdf0e10cSrcweir     double m_fZ;
203cdf0e10cSrcweir };
204cdf0e10cSrcweir 
createShapes()205cdf0e10cSrcweir void BubbleChart::createShapes()
206cdf0e10cSrcweir {
207cdf0e10cSrcweir     if( m_aZSlots.begin() == m_aZSlots.end() ) //no series
208cdf0e10cSrcweir         return;
209cdf0e10cSrcweir 
210cdf0e10cSrcweir     DBG_ASSERT(m_pShapeFactory&&m_xLogicTarget.is()&&m_xFinalTarget.is(),"BubbleChart is not proper initialized");
211cdf0e10cSrcweir     if(!(m_pShapeFactory&&m_xLogicTarget.is()&&m_xFinalTarget.is()))
212cdf0e10cSrcweir         return;
213cdf0e10cSrcweir 
214cdf0e10cSrcweir     //therefore create an own group for the texts and the error bars to move them to front
215cdf0e10cSrcweir     //(because the text group is created after the series group the texts are displayed on top)
216cdf0e10cSrcweir     uno::Reference< drawing::XShapes > xSeriesTarget(
217cdf0e10cSrcweir         createGroupShape( m_xLogicTarget,rtl::OUString() ));
218cdf0e10cSrcweir     uno::Reference< drawing::XShapes > xTextTarget(
219cdf0e10cSrcweir         m_pShapeFactory->createGroup2D( m_xFinalTarget,rtl::OUString() ));
220cdf0e10cSrcweir 
221cdf0e10cSrcweir     //update/create information for current group
222cdf0e10cSrcweir     double fLogicZ        = 1.0;//as defined
223cdf0e10cSrcweir 
224cdf0e10cSrcweir     sal_Int32 nStartIndex = 0; // inclusive       ;..todo get somehow from x scale
225cdf0e10cSrcweir     sal_Int32 nEndIndex = VSeriesPlotter::getPointCount();
226cdf0e10cSrcweir     if(nEndIndex<=0)
227cdf0e10cSrcweir         nEndIndex=1;
228cdf0e10cSrcweir 
229cdf0e10cSrcweir     //better performance for big data
230cdf0e10cSrcweir     std::map< VDataSeries*, FormerPoint > aSeriesFormerPointMap;
231cdf0e10cSrcweir     m_bPointsWereSkipped = false;
232cdf0e10cSrcweir     sal_Int32 nSkippedPoints = 0;
233cdf0e10cSrcweir     sal_Int32 nCreatedPoints = 0;
234cdf0e10cSrcweir     //
235cdf0e10cSrcweir 
236cdf0e10cSrcweir     calculateMaximumLogicBubbleSize();
237cdf0e10cSrcweir     calculateBubbleSizeScalingFactor();
238cdf0e10cSrcweir     if( m_fMaxLogicBubbleSize <= 0 || m_fBubbleSizeFactorToScreen <= 0 )
239cdf0e10cSrcweir         return;
240cdf0e10cSrcweir 
241cdf0e10cSrcweir //=============================================================================
242cdf0e10cSrcweir     //iterate through all x values per indices
243cdf0e10cSrcweir     for( sal_Int32 nIndex = nStartIndex; nIndex < nEndIndex; nIndex++ )
244cdf0e10cSrcweir     {
245cdf0e10cSrcweir         ::std::vector< ::std::vector< VDataSeriesGroup > >::iterator             aZSlotIter = m_aZSlots.begin();
246cdf0e10cSrcweir         const ::std::vector< ::std::vector< VDataSeriesGroup > >::const_iterator  aZSlotEnd = m_aZSlots.end();
247cdf0e10cSrcweir 
248cdf0e10cSrcweir         aZSlotIter = m_aZSlots.begin();
249cdf0e10cSrcweir         for( sal_Int32 nZ=1; aZSlotIter != aZSlotEnd; aZSlotIter++, nZ++ )
250cdf0e10cSrcweir         {
251cdf0e10cSrcweir             ::std::vector< VDataSeriesGroup >::iterator             aXSlotIter = aZSlotIter->begin();
252cdf0e10cSrcweir             const ::std::vector< VDataSeriesGroup >::const_iterator aXSlotEnd = aZSlotIter->end();
253cdf0e10cSrcweir 
254cdf0e10cSrcweir             aXSlotIter = aZSlotIter->begin();
255cdf0e10cSrcweir             for( sal_Int32 nX=0; aXSlotIter != aXSlotEnd; aXSlotIter++, nX++ )
256cdf0e10cSrcweir             {
257cdf0e10cSrcweir                 ::std::vector< VDataSeries* >* pSeriesList = &(aXSlotIter->m_aSeriesVector);
258cdf0e10cSrcweir                 ::std::vector< VDataSeries* >::const_iterator       aSeriesIter = pSeriesList->begin();
259cdf0e10cSrcweir                 const ::std::vector< VDataSeries* >::const_iterator aSeriesEnd  = pSeriesList->end();
260cdf0e10cSrcweir 
261cdf0e10cSrcweir     //=============================================================================
262cdf0e10cSrcweir                 //iterate through all series
263cdf0e10cSrcweir                 for( sal_Int32 nSeriesIndex = 0; aSeriesIter != aSeriesEnd; aSeriesIter++, nSeriesIndex++ )
264cdf0e10cSrcweir                 {
265cdf0e10cSrcweir                     VDataSeries* pSeries( *aSeriesIter );
266cdf0e10cSrcweir                     if(!pSeries)
267cdf0e10cSrcweir                         continue;
268cdf0e10cSrcweir 
269cdf0e10cSrcweir                     uno::Reference< drawing::XShapes > xSeriesGroupShape_Shapes = getSeriesGroupShape(*aSeriesIter, xSeriesTarget);
270cdf0e10cSrcweir 
271cdf0e10cSrcweir                     sal_Int32 nAttachedAxisIndex = pSeries->getAttachedAxisIndex();
272cdf0e10cSrcweir                     PlottingPositionHelper* pPosHelper = &(this->getPlottingPositionHelper( nAttachedAxisIndex ));
273cdf0e10cSrcweir                     if(!pPosHelper)
274cdf0e10cSrcweir                         pPosHelper = m_pMainPosHelper;
275cdf0e10cSrcweir                     PlotterBase::m_pPosHelper = pPosHelper;
276cdf0e10cSrcweir 
277cdf0e10cSrcweir                     if(m_nDimension==3)
278cdf0e10cSrcweir                         fLogicZ = nZ+0.5;
279cdf0e10cSrcweir 
280cdf0e10cSrcweir                     //collect data point information (logic coordinates, style ):
281cdf0e10cSrcweir                     double fLogicX = pSeries->getXValue(nIndex);
282cdf0e10cSrcweir                     double fLogicY = pSeries->getYValue(nIndex);
283cdf0e10cSrcweir                     double fBubbleSize = pSeries->getBubble_Size( nIndex );
284cdf0e10cSrcweir 
285cdf0e10cSrcweir                     if( !m_bShowNegativeValues && fBubbleSize<0.0 )
286cdf0e10cSrcweir                         continue;
287cdf0e10cSrcweir 
288cdf0e10cSrcweir                     if( ::rtl::math::approxEqual( fBubbleSize, 0.0 ) || ::rtl::math::isNan(fBubbleSize) )
289cdf0e10cSrcweir                         continue;
290cdf0e10cSrcweir 
291cdf0e10cSrcweir                     if(    ::rtl::math::isNan(fLogicX) || ::rtl::math::isInf(fLogicX)
292cdf0e10cSrcweir                         || ::rtl::math::isNan(fLogicY) || ::rtl::math::isInf(fLogicY) )
293cdf0e10cSrcweir                         continue;
294cdf0e10cSrcweir 
295cdf0e10cSrcweir                     bool bIsVisible = pPosHelper->isLogicVisible( fLogicX, fLogicY, fLogicZ );
296cdf0e10cSrcweir 
297cdf0e10cSrcweir                     drawing::Position3D aUnscaledLogicPosition( fLogicX, fLogicY, fLogicZ );
298cdf0e10cSrcweir                     drawing::Position3D aScaledLogicPosition(aUnscaledLogicPosition);
299cdf0e10cSrcweir                     pPosHelper->doLogicScaling( aScaledLogicPosition );
300cdf0e10cSrcweir 
301cdf0e10cSrcweir                     //transformation 3) -> 4)
302cdf0e10cSrcweir                     drawing::Position3D aScenePosition( pPosHelper->transformLogicToScene( fLogicX,fLogicY,fLogicZ, false ) );
303cdf0e10cSrcweir 
304cdf0e10cSrcweir                     //better performance for big data
305cdf0e10cSrcweir                     FormerPoint aFormerPoint( aSeriesFormerPointMap[pSeries] );
306cdf0e10cSrcweir                     pPosHelper->setCoordinateSystemResolution( m_aCoordinateSystemResolution );
307cdf0e10cSrcweir                     if( !pSeries->isAttributedDataPoint(nIndex)
308cdf0e10cSrcweir                             &&
309cdf0e10cSrcweir                         pPosHelper->isSameForGivenResolution( aFormerPoint.m_fX, aFormerPoint.m_fY, aFormerPoint.m_fZ
310cdf0e10cSrcweir                                                             , aScaledLogicPosition.PositionX, aScaledLogicPosition.PositionY, aScaledLogicPosition.PositionZ ) )
311cdf0e10cSrcweir                     {
312cdf0e10cSrcweir                         nSkippedPoints++;
313cdf0e10cSrcweir                         m_bPointsWereSkipped = true;
314cdf0e10cSrcweir                         continue;
315cdf0e10cSrcweir                     }
316cdf0e10cSrcweir                     aSeriesFormerPointMap[pSeries] = FormerPoint(aScaledLogicPosition.PositionX, aScaledLogicPosition.PositionY, aScaledLogicPosition.PositionZ);
317cdf0e10cSrcweir 
318cdf0e10cSrcweir                     //create a single datapoint if point is visible
319cdf0e10cSrcweir                     if( !bIsVisible )
320cdf0e10cSrcweir                         continue;
321cdf0e10cSrcweir 
322cdf0e10cSrcweir                     //create a group shape for this point and add to the series shape:
323cdf0e10cSrcweir                     rtl::OUString aPointCID = ObjectIdentifier::createPointCID(
324cdf0e10cSrcweir                         pSeries->getPointCID_Stub(), nIndex );
325cdf0e10cSrcweir                     uno::Reference< drawing::XShapes > xPointGroupShape_Shapes(
326cdf0e10cSrcweir                         createGroupShape(xSeriesGroupShape_Shapes,aPointCID) );
327cdf0e10cSrcweir                     uno::Reference<drawing::XShape> xPointGroupShape_Shape =
328cdf0e10cSrcweir                             uno::Reference<drawing::XShape>( xPointGroupShape_Shapes, uno::UNO_QUERY );
329cdf0e10cSrcweir 
330cdf0e10cSrcweir                     {
331cdf0e10cSrcweir                         nCreatedPoints++;
332cdf0e10cSrcweir 
333cdf0e10cSrcweir                         //create data point
334cdf0e10cSrcweir                         drawing::Direction3D aSymbolSize = transformToScreenBubbleSize( fBubbleSize );
335cdf0e10cSrcweir                         if(m_nDimension!=3)
336cdf0e10cSrcweir                         {
337cdf0e10cSrcweir                             uno::Reference<drawing::XShape> xShape;
338cdf0e10cSrcweir                             xShape = m_pShapeFactory->createCircle2D( xPointGroupShape_Shapes
339cdf0e10cSrcweir                                                                       , aScenePosition, aSymbolSize );
340cdf0e10cSrcweir 
341cdf0e10cSrcweir                             this->setMappedProperties( xShape
342cdf0e10cSrcweir                                                        , pSeries->getPropertiesOfPoint( nIndex )
343cdf0e10cSrcweir                                                        , PropertyMapper::getPropertyNameMapForFilledSeriesProperties() );
344cdf0e10cSrcweir 
345cdf0e10cSrcweir                             m_pShapeFactory->setShapeName( xShape, C2U("MarkHandles") );
346cdf0e10cSrcweir                         }
347cdf0e10cSrcweir 
348cdf0e10cSrcweir                         //create data point label
349cdf0e10cSrcweir                         if( (**aSeriesIter).getDataPointLabelIfLabel(nIndex) )
350cdf0e10cSrcweir                         {
351cdf0e10cSrcweir                             LabelAlignment eAlignment = LABEL_ALIGN_TOP;
352cdf0e10cSrcweir                             drawing::Position3D aScenePosition3D( aScenePosition.PositionX
353cdf0e10cSrcweir                                         , aScenePosition.PositionY
354cdf0e10cSrcweir                                         , aScenePosition.PositionZ+this->getTransformedDepth() );
355cdf0e10cSrcweir 
356cdf0e10cSrcweir                             sal_Int32 nLabelPlacement = pSeries->getLabelPlacement( nIndex, m_xChartTypeModel, m_nDimension, pPosHelper->isSwapXAndY() );
357cdf0e10cSrcweir 
358cdf0e10cSrcweir                             switch(nLabelPlacement)
359cdf0e10cSrcweir                             {
360cdf0e10cSrcweir                             case ::com::sun::star::chart::DataLabelPlacement::TOP:
361cdf0e10cSrcweir                                 aScenePosition3D.PositionY -= (aSymbolSize.DirectionY/2+1);
362cdf0e10cSrcweir                                 eAlignment = LABEL_ALIGN_TOP;
363cdf0e10cSrcweir                                 break;
364cdf0e10cSrcweir                             case ::com::sun::star::chart::DataLabelPlacement::BOTTOM:
365cdf0e10cSrcweir                                 aScenePosition3D.PositionY += (aSymbolSize.DirectionY/2+1);
366cdf0e10cSrcweir                                 eAlignment = LABEL_ALIGN_BOTTOM;
367cdf0e10cSrcweir                                 break;
368cdf0e10cSrcweir                             case ::com::sun::star::chart::DataLabelPlacement::LEFT:
369cdf0e10cSrcweir                                 aScenePosition3D.PositionX -= (aSymbolSize.DirectionX/2+1);
370cdf0e10cSrcweir                                 eAlignment = LABEL_ALIGN_LEFT;
371cdf0e10cSrcweir                                 break;
372cdf0e10cSrcweir                             case ::com::sun::star::chart::DataLabelPlacement::RIGHT:
373cdf0e10cSrcweir                                 aScenePosition3D.PositionX += (aSymbolSize.DirectionX/2+1);
374cdf0e10cSrcweir                                 eAlignment = LABEL_ALIGN_RIGHT;
375cdf0e10cSrcweir                                 break;
376cdf0e10cSrcweir                             case ::com::sun::star::chart::DataLabelPlacement::CENTER:
377cdf0e10cSrcweir                                 eAlignment = LABEL_ALIGN_CENTER;
378cdf0e10cSrcweir                                 break;
379cdf0e10cSrcweir                             default:
380cdf0e10cSrcweir                                 DBG_ERROR("this label alignment is not implemented yet");
381cdf0e10cSrcweir                                 aScenePosition3D.PositionY -= (aSymbolSize.DirectionY/2+1);
382cdf0e10cSrcweir                                 eAlignment = LABEL_ALIGN_TOP;
383cdf0e10cSrcweir                                 break;
384cdf0e10cSrcweir                             }
385cdf0e10cSrcweir 
386cdf0e10cSrcweir 
387cdf0e10cSrcweir                             awt::Point aScreenPosition2D( LabelPositionHelper(pPosHelper,m_nDimension,m_xLogicTarget,m_pShapeFactory)
388cdf0e10cSrcweir                                 .transformSceneToScreenPosition( aScenePosition3D ) );
389cdf0e10cSrcweir                             sal_Int32 nOffset = 0;
390cdf0e10cSrcweir                             if(LABEL_ALIGN_CENTER!=eAlignment)
391cdf0e10cSrcweir                                 nOffset = 100;//add some spacing //@todo maybe get more intelligent values
392cdf0e10cSrcweir                             this->createDataLabel( xTextTarget, **aSeriesIter, nIndex
393cdf0e10cSrcweir                                             , fBubbleSize, fBubbleSize, aScreenPosition2D, eAlignment, nOffset );
394cdf0e10cSrcweir                         }
395cdf0e10cSrcweir                     }
396cdf0e10cSrcweir 
397cdf0e10cSrcweir                     //remove PointGroupShape if empty
398cdf0e10cSrcweir                     if(!xPointGroupShape_Shapes->getCount())
399cdf0e10cSrcweir                         xSeriesGroupShape_Shapes->remove(xPointGroupShape_Shape);
400cdf0e10cSrcweir 
401cdf0e10cSrcweir                 }//next series in x slot (next y slot)
402cdf0e10cSrcweir             }//next x slot
403cdf0e10cSrcweir         }//next z slot
404cdf0e10cSrcweir     }//next category
405cdf0e10cSrcweir //=============================================================================
406cdf0e10cSrcweir //=============================================================================
407cdf0e10cSrcweir //=============================================================================
408cdf0e10cSrcweir     OSL_TRACE( "\nPPPPPPPPP<<<<<<<<<<<< area chart :: createShapes():: skipped points: %d created points: %d", nSkippedPoints, nCreatedPoints );
409cdf0e10cSrcweir }
410cdf0e10cSrcweir 
411cdf0e10cSrcweir //.............................................................................
412cdf0e10cSrcweir } //namespace chart
413cdf0e10cSrcweir //.............................................................................
414