summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIngrid Halama <iha@openoffice.org>2004-01-22 18:20:40 +0000
committerIngrid Halama <iha@openoffice.org>2004-01-22 18:20:40 +0000
commit2283e0e6943e25389f33d64e43104c6b8d0cda57 (patch)
treef8b96e25cd99f4f00a23af029d558b36bf894f1d
parent50f4d52dd8a62fcc189b8c87afaf55f1c27052bd (diff)
restructure of cartesian axis, integrate polar axis
-rw-r--r--chart2/source/view/axes/TickmarkHelper.cxx129
-rw-r--r--chart2/source/view/axes/TickmarkHelper.hxx44
-rw-r--r--chart2/source/view/axes/TickmarkProperties.hxx87
-rw-r--r--chart2/source/view/axes/VAxisProperties.cxx150
-rw-r--r--chart2/source/view/axes/VAxisProperties.hxx50
-rw-r--r--chart2/source/view/axes/VCartesianAxis.cxx745
-rw-r--r--chart2/source/view/axes/VCartesianAxis.hxx37
-rw-r--r--chart2/source/view/axes/VCartesianCoordinateSystem.cxx39
-rw-r--r--chart2/source/view/axes/VCartesianGrid.cxx189
-rw-r--r--chart2/source/view/axes/VPolarAxis.cxx122
-rw-r--r--chart2/source/view/axes/VPolarAxis.hxx11
-rw-r--r--chart2/source/view/axes/VPolarCoordinateSystem.cxx12
-rw-r--r--chart2/source/view/axes/VPolarGrid.cxx25
-rw-r--r--chart2/source/view/charttypes/AreaChart.cxx1
-rw-r--r--chart2/source/view/charttypes/VSeriesPlotter.cxx1
-rw-r--r--chart2/source/view/inc/Clipping.hxx24
-rw-r--r--chart2/source/view/inc/PlottingPositionHelper.hxx17
-rw-r--r--chart2/source/view/main/Clipping.cxx45
-rw-r--r--chart2/source/view/main/PlottingPositionHelper.cxx57
-rw-r--r--chart2/source/view/main/makefile.mk5
20 files changed, 814 insertions, 976 deletions
diff --git a/chart2/source/view/axes/TickmarkHelper.cxx b/chart2/source/view/axes/TickmarkHelper.cxx
index 3ffb4c911a4b..ff01d39e53c2 100644
--- a/chart2/source/view/axes/TickmarkHelper.cxx
+++ b/chart2/source/view/axes/TickmarkHelper.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: TickmarkHelper.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: iha $ $Date: 2003-11-26 12:42:02 $
+ * last change: $Author: iha $ $Date: 2004-01-22 19:20:32 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -79,7 +79,7 @@ using namespace ::rtl::math;
TickInfo::TickInfo()
: fScaledTickValue( 0.0 )
, fUnscaledTickValue( 0.0 )
-, nScreenTickValue( 0 )
+, aTickScreenPosition(0.0,0.0)
, bPaintIt( true )
, xTextShape( NULL )
{
@@ -346,6 +346,11 @@ double TickmarkHelper::getMaximumAtIncrement( double fMax, const ExplicitIncreme
return fRet;
}
+double TickmarkHelper::getScaledWidth() const
+{
+ return m_fScaledVisibleMax - m_fScaledVisibleMin;
+}
+
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
@@ -692,21 +697,24 @@ void TickmarkHelper::addSubTicks( sal_Int32 nDepth, uno::Sequence< uno::Sequence
//-----------------------------------------------------------------------------
TickmarkHelper_2D::TickmarkHelper_2D(
const ExplicitScaleData& rScale, const ExplicitIncrementData& rIncrement
- , double fStrech_SceneToScreen, double fOffset_SceneToScreen )
+ //, double fStrech_SceneToScreen, double fOffset_SceneToScreen )
+ , const Vector2D& rStartScreenPos, const Vector2D& rEndScreenPos )
: TickmarkHelper( rScale, rIncrement )
+ , m_aAxisStartScreenPosition2D(rStartScreenPos)
+ , m_aAxisEndScreenPosition2D(rEndScreenPos)
, m_fStrech_LogicToScreen(1.0)
, m_fOffset_LogicToScreen(0.0)
{
double fWidthY = m_fScaledVisibleMax - m_fScaledVisibleMin;
if( AxisOrientation_MATHEMATICAL==m_rScale.Orientation )
{
- m_fStrech_LogicToScreen = FIXED_SIZE_FOR_3D_CHART_VOLUME/fWidthY * fStrech_SceneToScreen;
- m_fOffset_LogicToScreen = -m_fScaledVisibleMin*m_fStrech_LogicToScreen + fOffset_SceneToScreen;
+ m_fStrech_LogicToScreen = 1.0/fWidthY;
+ m_fOffset_LogicToScreen = -m_fScaledVisibleMin;
}
else
{
- m_fStrech_LogicToScreen = -FIXED_SIZE_FOR_3D_CHART_VOLUME/fWidthY * fStrech_SceneToScreen;
- m_fOffset_LogicToScreen = -m_fScaledVisibleMax*m_fStrech_LogicToScreen + fOffset_SceneToScreen;
+ m_fStrech_LogicToScreen = -1.0/fWidthY;
+ m_fOffset_LogicToScreen = -m_fScaledVisibleMax;
}
}
@@ -714,13 +722,6 @@ TickmarkHelper_2D::~TickmarkHelper_2D()
{
}
-sal_Int32 TickmarkHelper_2D::transformScaledLogicTickToScreen( double fValue ) const
-{
- sal_Int32 nRet = static_cast<sal_Int32>(
- fValue*m_fStrech_LogicToScreen + m_fOffset_LogicToScreen);
- return nRet;
-}
-
//static
sal_Int32 TickmarkHelper_2D::getTickScreenDistance( TickIter& rIter )
{
@@ -732,26 +733,90 @@ sal_Int32 TickmarkHelper_2D::getTickScreenDistance( TickIter& rIter )
if(!pSecondTickInfo || !pFirstTickInfo)
return -1;
- sal_Int32 nRet = pSecondTickInfo->nScreenTickValue - pFirstTickInfo->nScreenTickValue;
+ Vector2D aDistance = pSecondTickInfo->aTickScreenPosition-pFirstTickInfo->aTickScreenPosition;
+ sal_Int32 nRet = static_cast<sal_Int32>(aDistance.GetLength());
if(nRet<0)
nRet *= -1;
return nRet;
}
-sal_Int32 TickmarkHelper_2D::getScreenValueForMinimum() const
+Vector2D TickmarkHelper_2D::getTickScreenPosition2D( double fScaledLogicTickValue ) const
+{
+ Vector2D aRet(m_aAxisStartScreenPosition2D);
+ aRet += (m_aAxisEndScreenPosition2D-m_aAxisStartScreenPosition2D)
+ *((fScaledLogicTickValue+m_fOffset_LogicToScreen)*m_fStrech_LogicToScreen);
+ return aRet;
+}
+
+void TickmarkHelper_2D::addPointSequenceForTickLine( drawing::PointSequenceSequence& rPoints
+ , sal_Int32 nSequenceIndex
+ , double fScaledLogicTickValue, double fInnerDirectionSign
+ , const TickmarkProperties& rTickmarkProperties ) const
{
- //return the screen value at the end of the axis where the scale has its minimum
- //(lower end of axis line)
- return this->transformScaledLogicTickToScreen(
- m_fScaledVisibleMin );
+ if( fInnerDirectionSign==0.0 )
+ fInnerDirectionSign = 1.0;
+
+ Vector2D aTickScreenPosition = this->getTickScreenPosition2D(fScaledLogicTickValue);
+
+ Vector2D aMainDirection = m_aAxisEndScreenPosition2D-m_aAxisStartScreenPosition2D;
+ aMainDirection.Normalize();
+ Vector2D aOrthoDirection(-aMainDirection.Y(),aMainDirection.X());
+ aOrthoDirection *= fInnerDirectionSign;
+ aOrthoDirection.Normalize();
+
+ Vector2D aStart = aTickScreenPosition + aOrthoDirection*rTickmarkProperties.RelativePos;
+ Vector2D aEnd = aStart - aOrthoDirection*rTickmarkProperties.Length;
+
+ rPoints[nSequenceIndex].realloc(2);
+ rPoints[nSequenceIndex][0].X = static_cast<sal_Int32>(aStart.X());
+ rPoints[nSequenceIndex][0].Y = static_cast<sal_Int32>(aStart.Y());
+ rPoints[nSequenceIndex][1].X = static_cast<sal_Int32>(aEnd.X());
+ rPoints[nSequenceIndex][1].Y = static_cast<sal_Int32>(aEnd.Y());
+}
+
+Vector2D TickmarkHelper_2D::getDistanceTickToText( const AxisProperties& rAxisProperties ) const
+{
+ double fInnerDirectionSign = rAxisProperties.m_fInnerDirectionSign;
+ if( fInnerDirectionSign==0.0 )
+ fInnerDirectionSign = 1.0;
+
+ Vector2D aMainDirection = m_aAxisEndScreenPosition2D-m_aAxisStartScreenPosition2D;
+ aMainDirection.Normalize();
+ Vector2D aOrthoDirection(-aMainDirection.Y(),aMainDirection.X());
+ aOrthoDirection *= fInnerDirectionSign;
+ aOrthoDirection.Normalize();
+
+ Vector2D aStart(0,0), aEnd(0,0);
+ for( sal_Int32 nN=rAxisProperties.m_aTickmarkPropertiesList.size();nN--;)
+ {
+ const TickmarkProperties& rProps = rAxisProperties.m_aTickmarkPropertiesList[0];
+ Vector2D aNewStart = aOrthoDirection*rProps.RelativePos;
+ Vector2D aNewEnd = aNewStart - aOrthoDirection*rProps.Length;
+ if(aNewStart.GetLength()>aStart.GetLength())
+ aStart=aNewStart;
+ if(aNewEnd.GetLength()>aEnd.GetLength())
+ aEnd=aNewEnd;
+ }
+
+ Vector2D aLabelDirection(aStart);
+ if(!rAxisProperties.m_bLabelsOutside)
+ aLabelDirection = aEnd;
+
+ Vector2D aOrthoLabelDirection(aOrthoDirection);
+ if(!rAxisProperties.m_bLabelsOutside)
+ aOrthoLabelDirection*=-1.0;
+ aOrthoLabelDirection.Normalize();
+ aLabelDirection += aOrthoLabelDirection*AXIS2D_TICKLABELSPACING;
+ return aLabelDirection;
}
-sal_Int32 TickmarkHelper_2D::getScreenValueForMaximum() const
+void TickmarkHelper_2D::createPointSequenceForAxisMainLine( drawing::PointSequenceSequence& rPoints ) const
{
- //return the screen value at the end of the axis where the scale has its maximum
- //(upper end of axis line)
- return this->transformScaledLogicTickToScreen(
- m_fScaledVisibleMax );
+ rPoints[0].realloc(2);
+ rPoints[0][0].X = static_cast<sal_Int32>(m_aAxisStartScreenPosition2D.X());
+ rPoints[0][0].Y = static_cast<sal_Int32>(m_aAxisStartScreenPosition2D.Y());
+ rPoints[0][1].X = static_cast<sal_Int32>(m_aAxisEndScreenPosition2D.X());
+ rPoints[0][1].Y = static_cast<sal_Int32>(m_aAxisEndScreenPosition2D.Y());
}
void TickmarkHelper_2D::updateScreenValues( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const
@@ -766,9 +831,8 @@ void TickmarkHelper_2D::updateScreenValues( ::std::vector< ::std::vector< TickIn
for( ; aTickIter != aTickEnd; aTickIter++ )
{
TickInfo& rTickInfo = (*aTickIter);
- rTickInfo.nScreenTickValue =
- this->transformScaledLogicTickToScreen(
- rTickInfo.fScaledTickValue );
+ rTickInfo.aTickScreenPosition =
+ this->getTickScreenPosition2D( rTickInfo.fScaledTickValue );
}
}
}
@@ -785,7 +849,12 @@ void TickmarkHelper_2D::hideIdenticalScreenValues(
pPreviousTickInfo->bPaintIt = true;
for( TickInfo* pTickInfo = aIter.nextInfo(); pTickInfo; pTickInfo = aIter.nextInfo())
{
- pTickInfo->bPaintIt = pTickInfo->nScreenTickValue != pPreviousTickInfo->nScreenTickValue;
+ pTickInfo->bPaintIt =
+ ( static_cast<sal_Int32>(pTickInfo->aTickScreenPosition.X())
+ != static_cast<sal_Int32>(pPreviousTickInfo->aTickScreenPosition.X()) )
+ ||
+ ( static_cast<sal_Int32>(pTickInfo->aTickScreenPosition.Y())
+ != static_cast<sal_Int32>(pPreviousTickInfo->aTickScreenPosition.Y()) );
pPreviousTickInfo = pTickInfo;
}
}
diff --git a/chart2/source/view/axes/TickmarkHelper.hxx b/chart2/source/view/axes/TickmarkHelper.hxx
index 1462cc8dcb5c..6cecd1610e36 100644
--- a/chart2/source/view/axes/TickmarkHelper.hxx
+++ b/chart2/source/view/axes/TickmarkHelper.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: TickmarkHelper.hxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: bm $ $Date: 2003-10-06 09:58:33 $
+ * last change: $Author: iha $ $Date: 2004-01-22 19:20:33 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -61,7 +61,8 @@
#ifndef _CHART2_TICKMARKHELPER_HXX
#define _CHART2_TICKMARKHELPER_HXX
-#include <vector>
+#include "TickmarkProperties.hxx"
+#include "VAxisProperties.hxx"
#ifndef _DRAFTS_COM_SUN_STAR_CHART2_EXPLICITINCREMENTDATA_HPP_
#include <drafts/com/sun/star/chart2/ExplicitIncrementData.hpp>
@@ -70,6 +71,15 @@
#include <drafts/com/sun/star/chart2/ExplicitScaleData.hpp>
#endif
+
+// header for class Vector2D
+#ifndef _VECTOR2D_HXX
+#include <tools/vector2d.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_DRAWING_POINTSEQUENCESEQUENCE_HPP_
+#include <com/sun/star/drawing/PointSequenceSequence.hpp>
+#endif
#ifndef _COM_SUN_STAR_DRAWING_XSHAPE_HPP_
#include <com/sun/star/drawing/XShape.hpp>
#endif
@@ -77,6 +87,8 @@
#include <com/sun/star/uno/Sequence.h>
#endif
+#include <vector>
+
//.............................................................................
namespace chart
{
@@ -91,8 +103,7 @@ struct TickInfo
double fScaledTickValue;
double fUnscaledTickValue;
- sal_Int32 nScreenTickValue;
-
+ Vector2D aTickScreenPosition;
bool bPaintIt;
::com::sun::star::uno::Reference<
@@ -190,6 +201,8 @@ public:
static double getMinimumAtIncrement( double fMin, const ::drafts::com::sun::star::chart2::ExplicitIncrementData& rIncrement );
static double getMaximumAtIncrement( double fMax, const ::drafts::com::sun::star::chart2::ExplicitIncrementData& rIncrement );
+ double getScaledWidth() const;
+
protected: //methods
void addSubTicks( sal_Int32 nDepth,
::com::sun::star::uno::Sequence<
@@ -229,24 +242,31 @@ public:
TickmarkHelper_2D(
const ::drafts::com::sun::star::chart2::ExplicitScaleData& rScale
, const ::drafts::com::sun::star::chart2::ExplicitIncrementData& rIncrement
- , double fStrech_SceneToScreen, double fOffset_SceneToScreen );
+ , const Vector2D& rStartScreenPos, const Vector2D& rEndScreenPos );
+ //, double fStrech_SceneToScreen, double fOffset_SceneToScreen );
virtual ~TickmarkHelper_2D();
static sal_Int32 getTickScreenDistance( TickIter& rIter );
- //methods more for axis line
- sal_Int32 getScreenValueForMinimum() const;
- sal_Int32 getScreenValueForMaximum() const;
+ void createPointSequenceForAxisMainLine( ::com::sun::star::drawing::PointSequenceSequence& rPoints ) const;
+ void addPointSequenceForTickLine( ::com::sun::star::drawing::PointSequenceSequence& rPoints
+ , sal_Int32 nSequenceIndex
+ , double fScaledLogicTickValue, double fInnerDirectionSign
+ , const TickmarkProperties& rTickmarkProperties ) const;
+ Vector2D getDistanceTickToText( const AxisProperties& rAxisProperties ) const;
protected: //methods
virtual void updateScreenValues( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const;
virtual void hideIdenticalScreenValues( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const;
- sal_Int32 transformScaledLogicTickToScreen( double fValue ) const;
+ Vector2D getTickScreenPosition2D( double fScaledLogicTickValue ) const;
private: //member
- double m_fStrech_LogicToScreen;
- double m_fOffset_LogicToScreen;
+ Vector2D m_aAxisStartScreenPosition2D;
+ Vector2D m_aAxisEndScreenPosition2D;
+
+ double m_fStrech_LogicToScreen;
+ double m_fOffset_LogicToScreen;
};
class TickmarkHelper_3D : public TickmarkHelper
diff --git a/chart2/source/view/axes/TickmarkProperties.hxx b/chart2/source/view/axes/TickmarkProperties.hxx
new file mode 100644
index 000000000000..be2636d81053
--- /dev/null
+++ b/chart2/source/view/axes/TickmarkProperties.hxx
@@ -0,0 +1,87 @@
+/*************************************************************************
+ *
+ * $RCSfile: TickmarkProperties.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: iha $ $Date: 2004-01-22 19:20:33 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2003 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CHART2_VTICKMARKPROPERTIES_HXX
+#define _CHART2_VTICKMARKPROPERTIES_HXX
+
+#include "VLineProperties.hxx"
+
+//.............................................................................
+namespace chart
+{
+//.............................................................................
+
+//-----------------------------------------------------------------------------
+/**
+*/
+
+struct TickmarkProperties
+{
+ sal_Int32 RelativePos;//Position in screen values relative to the axis where the tickmark line starts
+ sal_Int32 Length;//Length of the tickmark line in screen values
+
+ VLineProperties aLineProperties;
+};
+
+//.............................................................................
+} //namespace chart
+//.............................................................................
+#endif
diff --git a/chart2/source/view/axes/VAxisProperties.cxx b/chart2/source/view/axes/VAxisProperties.cxx
index 63adbf2d46cc..4ee64ab3f8c0 100644
--- a/chart2/source/view/axes/VAxisProperties.cxx
+++ b/chart2/source/view/axes/VAxisProperties.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: VAxisProperties.cxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: iha $ $Date: 2004-01-17 13:09:55 $
+ * last change: $Author: iha $ $Date: 2004-01-22 19:20:33 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -87,7 +87,7 @@ namespace chart
using namespace ::com::sun::star;
using namespace ::drafts::com::sun::star::chart2;
-sal_Int32 AxisProperties::calcTickLengthForDepth(sal_Int32 nDepth,sal_Int32 nTickmarkStyle) const
+sal_Int32 lcl_calcTickLengthForDepth(sal_Int32 nDepth,sal_Int32 nTickmarkStyle)
{
sal_Int32 nWidth = AXIS2D_TICKLENGTH; //@maybefuturetodo this length could be offered by the model
double fPercent = 1.0;
@@ -111,7 +111,7 @@ sal_Int32 AxisProperties::calcTickLengthForDepth(sal_Int32 nDepth,sal_Int32 nTic
return static_cast<sal_Int32>(nWidth*fPercent);
}
-sal_Int32 getTickOffset(sal_Int32 nLength,sal_Int32 nTickmarkStyle)
+double lcl_getTickOffset(sal_Int32 nLength,sal_Int32 nTickmarkStyle)
{
double fPercent = 0.0; //0<=fPercent<=1
//0.0: completly inner
@@ -136,7 +136,7 @@ sal_Int32 getTickOffset(sal_Int32 nLength,sal_Int32 nTickmarkStyle)
fPercent = 0.5;
break;
}
- return static_cast<sal_Int32>(fPercent*nLength);
+ return fPercent*nLength;
}
VLineProperties AxisProperties::makeLinePropertiesForDepth( sal_Int32 nDepth ) const
@@ -171,32 +171,32 @@ TickmarkProperties AxisProperties::makeTickmarkProperties(
nTickmarkStyle = m_nMinorTickmarks;
}
- TickmarkProperties aTickmarkProperties;
- aTickmarkProperties.Length = this->calcTickLengthForDepth(nDepth,nTickmarkStyle);
+ if( m_fInnerDirectionSign == 0.0 )
+ {
+ if( nTickmarkStyle != 0 )
+ nTickmarkStyle = 3; //inner and outer tickmarks
+ }
- sal_Int32 nSign = m_bIsLeftOrBottomAxis ? 1 : -1;
- if(m_bIsYAxis)
- nSign *= -1;
- aTickmarkProperties.RelativePos = nSign*getTickOffset(aTickmarkProperties.Length,nTickmarkStyle);
- aTickmarkProperties.Length *= -nSign;
+ TickmarkProperties aTickmarkProperties;
+ aTickmarkProperties.Length = lcl_calcTickLengthForDepth(nDepth,nTickmarkStyle);
+ aTickmarkProperties.RelativePos = static_cast<sal_Int32>(lcl_getTickOffset(aTickmarkProperties.Length,nTickmarkStyle));
aTickmarkProperties.aLineProperties = this->makeLinePropertiesForDepth( nDepth );
return aTickmarkProperties;
}
//--------------------------------------------------------------------------
-AxisProperties::AxisProperties()
- : m_xAxisModel(NULL)
- , m_bIsYAxis(true)
- , m_bIsLeftOrBottomAxis(true)
+AxisProperties::AxisProperties( const uno::Reference< XAxis >& xAxisModel
+ , const ::com::sun::star::awt::Size& rReferenceSize )
+ : m_xAxisModel(xAxisModel)
+ , m_aReferenceSize(rReferenceSize)
+ , m_bIsMainAxis(true)
, m_pfMainLinePositionAtOtherAxis(NULL)
, m_pfExrtaLinePositionAtOtherAxis(NULL)
- /*
- , m_nOrthogonalAxisScreenPosition(0)
- , m_nOrthogonalAxisExtraLineScreenPosition(0)
- */
- , m_eRelativeLabelPosition(LEFTORBOTTOM_OF_AXIS)
- , m_aReferenceSize()
+ , m_fInnerDirectionSign(1.0)
+ , m_bLabelsOutside(true)
+ , m_aLabelAlignment(LABEL_ALIGN_RIGHT_TOP)
+// , m_eRelativeLabelPosition(LEFTORBOTTOM_OF_AXIS)
, m_nMajorTickmarks(1)
, m_nMinorTickmarks(1)
, m_aTickmarkPropertiesList()
@@ -206,12 +206,14 @@ AxisProperties::AxisProperties()
AxisProperties::AxisProperties( const AxisProperties& rAxisProperties )
: m_xAxisModel( rAxisProperties.m_xAxisModel )
- , m_bIsYAxis( rAxisProperties.m_bIsYAxis )
- , m_bIsLeftOrBottomAxis( rAxisProperties.m_bIsLeftOrBottomAxis )
+ , m_aReferenceSize( rAxisProperties.m_aReferenceSize )
+ , m_bIsMainAxis( rAxisProperties.m_bIsMainAxis )
, m_pfMainLinePositionAtOtherAxis( NULL )
, m_pfExrtaLinePositionAtOtherAxis( NULL )
- , m_eRelativeLabelPosition( rAxisProperties.m_eRelativeLabelPosition )
- , m_aReferenceSize( rAxisProperties.m_aReferenceSize )
+ , m_fInnerDirectionSign( rAxisProperties.m_fInnerDirectionSign )
+ , m_bLabelsOutside( rAxisProperties.m_bLabelsOutside )
+ , m_aLabelAlignment( rAxisProperties.m_aLabelAlignment )
+// , m_eRelativeLabelPosition( rAxisProperties.m_eRelativeLabelPosition )
, m_nMajorTickmarks( rAxisProperties.m_nMajorTickmarks )
, m_nMinorTickmarks( rAxisProperties.m_nMinorTickmarks )
, m_aTickmarkPropertiesList( rAxisProperties.m_aTickmarkPropertiesList )
@@ -229,44 +231,88 @@ AxisProperties::~AxisProperties()
delete m_pfExrtaLinePositionAtOtherAxis;
}
-void AxisProperties::init()
+LabelAlignment lcl_getLabelAlignment( const AxisProperties& rAxisProperties, bool bIsYAxis )
+{
+ LabelAlignment aRet( LABEL_ALIGN_LEFT );
+ if(bIsYAxis)
+ {
+ if(rAxisProperties.m_bIsMainAxis)
+ {
+ if( rAxisProperties.m_bLabelsOutside )
+ aRet = LABEL_ALIGN_LEFT;
+ else
+ aRet = LABEL_ALIGN_RIGHT;
+ }
+ else
+ {
+ if( !rAxisProperties.m_bLabelsOutside )
+ aRet = LABEL_ALIGN_LEFT;
+ else
+ aRet = LABEL_ALIGN_RIGHT;
+ }
+ }
+ else
+ {
+ if(rAxisProperties.m_bIsMainAxis )
+ {
+ if(rAxisProperties.m_bLabelsOutside)
+ aRet = LABEL_ALIGN_BOTTOM;
+ else
+ aRet = LABEL_ALIGN_TOP;
+ }
+ else
+ {
+ if(!rAxisProperties.m_bLabelsOutside)
+ aRet = LABEL_ALIGN_BOTTOM;
+ else
+ aRet = LABEL_ALIGN_TOP;
+ }
+ }
+ return aRet;
+}
+
+void AxisProperties::init( bool bCartesian )
{
- if( !m_xAxisModel.is() )
+ if( bCartesian )
+ {
+ sal_Int32 nDimensionIndex = m_xAxisModel->getRepresentedDimension();
+ m_fInnerDirectionSign = m_bIsMainAxis ? 1 : -1;
+ if(nDimensionIndex==1)
+ m_fInnerDirectionSign*=-1;
+ m_aLabelAlignment = lcl_getLabelAlignment(*this,nDimensionIndex==1);
+ }
+
+ uno::Reference< beans::XPropertySet > xProp =
+ uno::Reference<beans::XPropertySet>::query( this->m_xAxisModel );
+ if( !xProp.is() )
return;
- sal_Int32 nDimension = m_xAxisModel->getRepresentedDimension();
- m_bIsYAxis = (nDimension==1);
//init LineProperties
- m_aLineProperties.initFromPropertySet( uno::Reference<beans::XPropertySet>::query( m_xAxisModel ) );
+ m_aLineProperties.initFromPropertySet( xProp );
//init TickmarkProperties
- uno::Reference< beans::XPropertySet > xProp =
- uno::Reference<beans::XPropertySet>::query( this->m_xAxisModel );
- if(xProp.is())
+ try
{
- try
- {
- xProp->getPropertyValue( C2U( "MajorTickmarks" ) ) >>= m_nMajorTickmarks;
- xProp->getPropertyValue( C2U( "MinorTickmarks" ) ) >>= m_nMinorTickmarks;
+ xProp->getPropertyValue( C2U( "MajorTickmarks" ) ) >>= m_nMajorTickmarks;
+ xProp->getPropertyValue( C2U( "MinorTickmarks" ) ) >>= m_nMinorTickmarks;
- sal_Int32 nMaxDepth = 0;
- if(m_nMinorTickmarks!=0)
- nMaxDepth=2;
- else if(m_nMajorTickmarks!=0)
- nMaxDepth=1;
+ sal_Int32 nMaxDepth = 0;
+ if(m_nMinorTickmarks!=0)
+ nMaxDepth=2;
+ else if(m_nMajorTickmarks!=0)
+ nMaxDepth=1;
- this->m_aTickmarkPropertiesList.clear();
- for( sal_Int32 nDepth=0; nDepth<nMaxDepth; nDepth++ )
- {
- TickmarkProperties aTickmarkProperties = this->makeTickmarkProperties( nDepth );
- this->m_aTickmarkPropertiesList.push_back( aTickmarkProperties );
- }
- }
- catch( uno::Exception& e )
+ this->m_aTickmarkPropertiesList.clear();
+ for( sal_Int32 nDepth=0; nDepth<nMaxDepth; nDepth++ )
{
- e;
+ TickmarkProperties aTickmarkProperties = this->makeTickmarkProperties( nDepth );
+ this->m_aTickmarkPropertiesList.push_back( aTickmarkProperties );
}
}
+ catch( uno::Exception& e )
+ {
+ e;
+ }
}
//-----------------------------------------------------------------------------
diff --git a/chart2/source/view/axes/VAxisProperties.hxx b/chart2/source/view/axes/VAxisProperties.hxx
index cfb51c6877bf..0c3fea9a57ee 100644
--- a/chart2/source/view/axes/VAxisProperties.hxx
+++ b/chart2/source/view/axes/VAxisProperties.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: VAxisProperties.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: iha $ $Date: 2004-01-17 13:09:55 $
+ * last change: $Author: iha $ $Date: 2004-01-22 19:20:33 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -61,8 +61,9 @@
#ifndef _CHART2_VAXIS_PROPERTIES_HXX
#define _CHART2_VAXIS_PROPERTIES_HXX
-#include "VLineProperties.hxx"
+#include "TickmarkProperties.hxx"
#include "PlottingPositionHelper.hxx"
+#include "LabelAlignment.hxx"
#ifndef _DRAFTS_COM_SUN_STAR_CHART2_NUMBERFORMAT_HPP_
#include <drafts/com/sun/star/chart2/NumberFormat.hpp>
@@ -95,14 +96,6 @@ namespace chart
/**
*/
-struct TickmarkProperties
-{
- sal_Int32 RelativePos;//Position in screen values relative to the axis where the tickmark line starts
- sal_Int32 Length;//Length of the tickmark line in screen values
-
- VLineProperties aLineProperties;
-};
-
//These properties describe how a couple of labels are arranged one to another.
//The couple can contain all labels for all tickmark depth or just the labels for one single depth or
//the labels from an coherent range of tick depths (e.g. the major and first minor tickmarks should be handled together).
@@ -144,24 +137,21 @@ struct AxisLabelProperties
struct AxisProperties
{
::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XAxis > m_xAxisModel;
+ ::com::sun::star::awt::Size m_aReferenceSize;
- bool m_bIsYAxis;
- bool m_bIsLeftOrBottomAxis;
+ bool m_bIsMainAxis;//not secondary axis
double* m_pfMainLinePositionAtOtherAxis;
double* m_pfExrtaLinePositionAtOtherAxis;
+ //this direction is used to indicate in which direction inner tickmarks are to be drawn
+ double m_fInnerDirectionSign;
+ bool m_bLabelsOutside;
- /*
- sal_Int32 m_nOrthogonalAxisScreenPosition;//gives a position in the direction orthogonal to the axis direction
- //e.g. for an y-axis this value describes a x position on the screen
- sal_Int32 m_nOrthogonalAxisExtraLineScreenPosition;//gives the screen value for an additional line ( e.g. a line at 0 ) at the other axis
- */
+ LabelAlignment m_aLabelAlignment;
- enum RelativeLabelPosition { NONE, LEFTORBOTTOM_OF_DIAGRAM, RIGHTORTOP_OF_DIAGRAM,
- LEFTORBOTTOM_OF_AXIS, RIGHTORTOP_OF_AXIS };
-
- RelativeLabelPosition m_eRelativeLabelPosition;
- ::com::sun::star::awt::Size m_aReferenceSize;
+// enum RelativeLabelPosition { NONE, LEFTORBOTTOM_OF_DIAGRAM, RIGHTORTOP_OF_DIAGRAM,
+// LEFTORBOTTOM_OF_AXIS, RIGHTORTOP_OF_AXIS };
+// RelativeLabelPosition m_eRelativeLabelPosition;
/*
0: no tickmarks 1: inner tickmarks
@@ -174,14 +164,18 @@ struct AxisProperties
VLineProperties m_aLineProperties;
//methods:
- AxisProperties();
+
+ AxisProperties( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XAxis >& xAxisModel
+ , const ::com::sun::star::awt::Size& rReferenceSize );
AxisProperties( const AxisProperties& rAxisProperties );
- ~AxisProperties();
- void init();//init from model data (m_xAxisModel)
+ virtual ~AxisProperties();
+ virtual void init(bool bCartesian=false);//init from model data (m_xAxisModel)
private:
- TickmarkProperties makeTickmarkProperties( sal_Int32 nDepth ) const;
- sal_Int32 calcTickLengthForDepth( sal_Int32 nDepth, sal_Int32 nTickmarkStyle ) const;
+ AxisProperties();
+
+protected:
+ virtual TickmarkProperties makeTickmarkProperties( sal_Int32 nDepth ) const;
VLineProperties makeLinePropertiesForDepth( sal_Int32 nDepth ) const;
};
diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx
index 8125b4b497a7..ae0c9f72ddc7 100644
--- a/chart2/source/view/axes/VCartesianAxis.cxx
+++ b/chart2/source/view/axes/VCartesianAxis.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: VCartesianAxis.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: iha $ $Date: 2004-01-17 13:09:55 $
+ * last change: $Author: iha $ $Date: 2004-01-22 19:20:34 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -64,11 +64,11 @@
#include "CommonConverters.hxx"
#include "macros.hxx"
#include "ViewDefines.hxx"
-#include "TickmarkHelper.hxx"
#include "PropertyMapper.hxx"
#include "chartview/NumberFormatterWrapper.hxx"
#include "chartview/ObjectIdentifier.hxx"
#include "LabelPositionHelper.hxx"
+#include "DoubleRectangle.hxx"
#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XIDENTIFIABLE_HPP_
#include <drafts/com/sun/star/chart2/XIdentifiable.hpp>
@@ -105,451 +105,208 @@ using namespace ::com::sun::star;
using namespace ::drafts::com::sun::star::chart2;
using namespace ::rtl::math;
-LabelAlignment lcl_getLabelAlignment( const AxisProperties& rAxisProperties )
-{
- sal_Int16 nWritingMode( text::WritingMode2::LR_TB );//@todo get correct one
- bool bIsYAxis = rAxisProperties.m_bIsYAxis;
- bool bIsLeftOrBottomAxis = rAxisProperties.m_bIsLeftOrBottomAxis;
-
- bool bTop = !bIsYAxis && !bIsLeftOrBottomAxis;
- bool bLeft = true;
- switch( nWritingMode )
- {
- case text::WritingMode2::RL_TB:
- case text::WritingMode2::TB_RL:
- bLeft = !( bIsYAxis && !bIsLeftOrBottomAxis );
- case text::WritingMode2::TB_LR:
- default:
- bLeft = bIsYAxis && bIsLeftOrBottomAxis;
- }
-
- LabelAlignment aRet( LABEL_ALIGN_LEFT );
- if(bTop)
- {
- if(bLeft)
- aRet = LABEL_ALIGN_LEFT_TOP;
- else
- aRet = LABEL_ALIGN_RIGHT_TOP;
- }
- else
- {
- if(bLeft)
- aRet = LABEL_ALIGN_LEFT_BOTTOM;
- else
- aRet = LABEL_ALIGN_RIGHT_BOTTOM;
- }
- return aRet;
-}
-
-sal_Int32 lcl_getAxisScreenPosition( double fCrossOtherAxis
- , const PlottingPositionHelper& rPosHelper, bool bIsYAxis )
-{
- double fX = bIsYAxis ? fCrossOtherAxis : rPosHelper.getLogicMinX();
- double fY = bIsYAxis ? rPosHelper.getLogicMinY() : fCrossOtherAxis;
-
- rPosHelper.clipLogicValues( &fX,&fY,0 );
- rPosHelper.doLogicScaling( &fX,&fY,0 );
- drawing::Position3D aPos( fX, fY, 0);
-
- uno::Reference< XTransformation > xTransformation =
- rPosHelper.getTransformationLogicToScene();
- uno::Sequence< double > aSeq =
- xTransformation->transform( Position3DToSequence(aPos) );
-
- return static_cast<sal_Int32>(
- bIsYAxis ? aSeq[0] : aSeq[1] );
-}
-
-sal_Int32 lcl_getMainLineScreenPosition(
- const PlottingPositionHelper& rPosHelper
- , const AxisProperties& rAxisProperties )
-{
- double fMin = rAxisProperties.m_bIsYAxis ? rPosHelper.getLogicMinX() : rPosHelper.getLogicMinY();
- double fMax = rAxisProperties.m_bIsYAxis ? rPosHelper.getLogicMaxX() : rPosHelper.getLogicMaxY();
-
- double fCrossOtherAxis;
- if(rAxisProperties.m_pfMainLinePositionAtOtherAxis)
- fCrossOtherAxis = *rAxisProperties.m_pfMainLinePositionAtOtherAxis;
- else
- {
- bool bMinimumForLeftAxis = ( rAxisProperties.m_bIsYAxis && rPosHelper.isMathematicalOrientationY() )
- || ( !rAxisProperties.m_bIsYAxis && rPosHelper.isMathematicalOrientationX() );
- fCrossOtherAxis = ( bMinimumForLeftAxis && rAxisProperties.m_bIsLeftOrBottomAxis ) ? fMin : fMax;
- }
- sal_Int32 nRet = lcl_getAxisScreenPosition( fCrossOtherAxis, rPosHelper
- , rAxisProperties.m_bIsYAxis );
- return nRet;
-}
-
-bool lcl_getExtraLineScreenPosition(
- sal_Int32& rnExtraLineScreenPosition
- , const PlottingPositionHelper& rPosHelper
- , const AxisProperties& rAxisProperties )
-{
- if( !rAxisProperties.m_pfExrtaLinePositionAtOtherAxis )
- return false;
-
- double fMin = rAxisProperties.m_bIsYAxis ? rPosHelper.getLogicMinX() : rPosHelper.getLogicMinY();
- double fMax = rAxisProperties.m_bIsYAxis ? rPosHelper.getLogicMaxX() : rPosHelper.getLogicMaxY();
- if( *rAxisProperties.m_pfExrtaLinePositionAtOtherAxis <= fMin
- || *rAxisProperties.m_pfExrtaLinePositionAtOtherAxis >= fMax )
- return false;
- rnExtraLineScreenPosition = lcl_getAxisScreenPosition(
- *rAxisProperties.m_pfExrtaLinePositionAtOtherAxis
- , rPosHelper, rAxisProperties.m_bIsYAxis );
- return true;
-}
-
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-
-VAxis::VAxis( const AxisProperties& rAxisProperties
- , NumberFormatterWrapper* pNumberFormatterWrapper
- , sal_Int32 nDimensionCount )
- : VMeterBase( uno::Reference<XMeter>::query(rAxisProperties.m_xAxisModel)
- , nDimensionCount )
- , m_aAxisProperties( rAxisProperties )
- , m_pNumberFormatterWrapper( pNumberFormatterWrapper )
-{
- m_pPosHelper = new PlottingPositionHelper();
-}
-
-VAxis::~VAxis()
-{
- delete m_pPosHelper;
- m_pPosHelper = NULL;
-}
-
void lcl_correctRotation_Left( double& rfXCorrection, double& rfYCorrection
, double fAnglePositiveDegree, const awt::Size& aSize )
{
- //correct position for left y-axis with right top alignment
+ //correct label positions left of an axis with right centered alignment
double fAnglePi = fAnglePositiveDegree*F_PI/180.0;
if( fAnglePositiveDegree==0.0 )
{
- rfXCorrection = 0.0;
- rfYCorrection = -aSize.Height/2.0;
}
else if( fAnglePositiveDegree<= 90.0 )
{
- rfXCorrection = -aSize.Height*rtl::math::sin( fAnglePi );
- rfYCorrection = -aSize.Height*rtl::math::cos( fAnglePi )/2.0;
+ rfXCorrection = -aSize.Height*rtl::math::sin( fAnglePi )/2.0;
}
else if( fAnglePositiveDegree<= 180.0 )
{
- rfXCorrection = -aSize.Width *rtl::math::sin( fAnglePi - F_PI/2.0 )
- -aSize.Height*rtl::math::cos( fAnglePi - F_PI/2.0 );
- rfYCorrection = -aSize.Width *rtl::math::cos( fAnglePi - F_PI/2.0 )
- +aSize.Height*rtl::math::sin( fAnglePi - F_PI/2.0 )/2.0;
+ double beta = fAnglePi-F_PI/2.0;
+ rfXCorrection = -aSize.Width *rtl::math::sin( beta )
+ -aSize.Height *rtl::math::cos( beta )/2.0;
+ rfYCorrection = -aSize.Width *rtl::math::cos( beta );
}
else if( fAnglePositiveDegree<= 270.0 )
{
double beta = fAnglePi - F_PI;
- double gamma = 3*F_PI/2.0 - fAnglePi;
- rfXCorrection = -aSize.Width *rtl::math::cos( beta );
- rfYCorrection = +aSize.Height*rtl::math::sin( gamma )/2.0
- +aSize.Width *rtl::math::sin( beta );
+ rfXCorrection = -aSize.Width *rtl::math::cos( beta )
+ -aSize.Height*rtl::math::sin( beta )/2.0;
+ rfYCorrection = aSize.Width *rtl::math::sin( beta );
}
else
{
- rfXCorrection = 0.0;
- rfYCorrection = -aSize.Height*rtl::math::cos( fAnglePi )/2.0;
+ double beta = 2*F_PI - fAnglePi;
+ rfXCorrection = -aSize.Height*rtl::math::sin( beta )/2.0;
+
}
}
void lcl_correctRotation_Right( double& rfXCorrection, double& rfYCorrection
, double fAnglePositiveDegree, const awt::Size& aSize )
{
- //correct position for right y-axis with left top alignment
+ //correct label positions right of an axis with left centered alignment
double fAnglePi = fAnglePositiveDegree*F_PI/180.0;
- if( fAnglePositiveDegree==0.0 )
+ if( fAnglePositiveDegree== 0.0 )
{
- rfXCorrection = 0.0;
- rfYCorrection = -aSize.Height/2.0;
}
else if( fAnglePositiveDegree<= 90.0 )
{
- rfXCorrection = 0.0;
- rfYCorrection = -aSize.Height*rtl::math::cos( fAnglePi )/2.0;
+ rfXCorrection = aSize.Height*rtl::math::sin( fAnglePi )/2.0;
}
else if( fAnglePositiveDegree<= 180.0 )
{
double beta = F_PI - fAnglePi;
- double gamma = fAnglePi - F_PI/2.0;
- rfXCorrection = aSize.Width *rtl::math::cos( beta );
- rfYCorrection = +aSize.Height*rtl::math::sin( gamma )/2.0
- +aSize.Width *rtl::math::sin( beta );
+ rfXCorrection = aSize.Width *rtl::math::cos( beta )
+ + aSize.Height*rtl::math::sin( beta )/2.0;
+ rfYCorrection = aSize.Width *rtl::math::sin( beta );
}
else if( fAnglePositiveDegree<= 270.0 )
{
double beta = 3*F_PI/2.0 - fAnglePi;
rfXCorrection = aSize.Width *rtl::math::sin( beta )
- +aSize.Height*rtl::math::cos( beta );
- rfYCorrection = -aSize.Width *rtl::math::cos( beta )
- +aSize.Height*rtl::math::sin( beta )/2.0;
+ +aSize.Height*rtl::math::cos( beta )/2.0;
+ rfYCorrection = -aSize.Width *rtl::math::cos( beta );
}
else
{
- rfXCorrection = aSize.Height*rtl::math::sin( 2*F_PI - fAnglePi );
- rfYCorrection = -aSize.Height*rtl::math::cos( 2*F_PI - fAnglePi )/2.0;
+ rfXCorrection = aSize.Height*rtl::math::sin( 2*F_PI - fAnglePi )/2.0;
}
}
-void lcl_correctRotation_Bottom_Left( double& rfXCorrection, double& rfYCorrection
+
+void lcl_correctRotation_Top( double& rfXCorrection, double& rfYCorrection
, double fAnglePositiveDegree, const awt::Size& aSize )
{
- //correct position for bottom x-axis with left top alignment
+ //correct label positions on top of an axis with bottom centered alignment
double fAnglePi = fAnglePositiveDegree*F_PI/180.0;
- if( fAnglePositiveDegree==0.0 )
+ if( fAnglePositiveDegree== 0.0 )
{
- rfXCorrection = -aSize.Width/2.0;
- rfYCorrection = 0.0;
}
else if( fAnglePositiveDegree<= 90.0 )
{
- rfXCorrection = -aSize.Height*rtl::math::sin( fAnglePi )/2.0
- -aSize.Width *rtl::math::cos( fAnglePi );
- rfYCorrection = aSize.Width *rtl::math::sin( fAnglePi );
+ rfXCorrection = aSize.Width*rtl::math::cos( fAnglePi )/2.0
+ +aSize.Height*rtl::math::sin( fAnglePi )/2.0;
+ rfYCorrection = -aSize.Width*rtl::math::sin( fAnglePi )/2.0;
}
else if( fAnglePositiveDegree<= 180.0 )
{
- double beta = F_PI - fAnglePi;
- rfYCorrection = aSize.Width *rtl::math::sin( beta )
- +aSize.Height*rtl::math::cos( beta );
- rfXCorrection = aSize.Width *rtl::math::cos( beta )
- -aSize.Height*rtl::math::sin( beta )/2.0;
+ double beta = fAnglePi - F_PI/2.0;
+ rfYCorrection = -aSize.Width*rtl::math::cos( beta )/2.0
+ - aSize.Height*rtl::math::sin( beta );
+ rfXCorrection = - aSize.Width*rtl::math::sin( beta )/2.0
+ + aSize.Height*rtl::math::cos( beta )/2.0;
}
else if( fAnglePositiveDegree<= 270.0 )
{
- double beta = 3*F_PI/2.0 - fAnglePi;
- rfXCorrection = aSize.Height*rtl::math::cos( beta )/2.0;
- rfYCorrection = aSize.Height*rtl::math::sin( beta );
+ double beta = fAnglePi - F_PI;
+ rfXCorrection = +aSize.Width *rtl::math::cos( beta )/2.0
+ -aSize.Height *rtl::math::sin( beta )/2.0; ;
+ rfYCorrection = -aSize.Width *rtl::math::sin( beta )/2.0
+ -aSize.Height *rtl::math::cos( beta );
}
else
{
double beta = 2*F_PI - fAnglePi;
- rfXCorrection = aSize.Height*rtl::math::sin( beta )/2.0;
- rfYCorrection = 0.0;
+ rfXCorrection = -aSize.Width*rtl::math::cos( fAnglePi )/2.0
+ +aSize.Height*rtl::math::sin( fAnglePi )/2.0;
+ rfYCorrection = aSize.Width*rtl::math::sin( fAnglePi )/2.0;
}
}
-void lcl_correctRotation_Bottom_Right( double& rfXCorrection, double& rfYCorrection
+void lcl_correctRotation_Bottom( double& rfXCorrection, double& rfYCorrection
, double fAnglePositiveDegree, const awt::Size& aSize )
{
- //correct position for bottom x-axis with right top alignment
+ //correct label positions below of an axis with top centered alignment
double fAnglePi = fAnglePositiveDegree*F_PI/180.0;
if( fAnglePositiveDegree==0.0 )
{
- rfXCorrection = aSize.Width/2.0;
- rfYCorrection = 0.0;
}
else if( fAnglePositiveDegree<= 90.0 )
{
- rfXCorrection = -aSize.Height*rtl::math::sin( fAnglePi )/2.0;
- rfYCorrection = 0.0;
+ rfXCorrection = -aSize.Width *rtl::math::cos( fAnglePi )/2.0
+ -aSize.Height*rtl::math::sin( fAnglePi )/2.0;
+ rfYCorrection = aSize.Width*rtl::math::sin( fAnglePi )/2.0;
}
else if( fAnglePositiveDegree<= 180.0 )
{
- double beta = F_PI - fAnglePi;
- rfYCorrection = aSize.Height*rtl::math::cos( beta );
- rfXCorrection = -aSize.Height*rtl::math::sin( beta )/2.0;
+ double beta = fAnglePi-F_PI/2.0;
+ rfYCorrection = aSize.Width *rtl::math::cos( beta )/2.0
+ +aSize.Height*rtl::math::sin( beta );
+ rfXCorrection = aSize.Width *rtl::math::sin( beta )/2.0
+ -aSize.Height*rtl::math::cos( beta )/2.0;
}
else if( fAnglePositiveDegree<= 270.0 )
{
double beta = 3*F_PI/2.0 - fAnglePi;
- rfXCorrection = aSize.Height*rtl::math::cos( beta )/2.0
- -aSize.Width*rtl::math::sin( beta );
-
+ rfXCorrection = -aSize.Width *rtl::math::sin( beta )/2.0
+ +aSize.Height*rtl::math::cos( beta )/2.0;
rfYCorrection = aSize.Height*rtl::math::sin( beta )
- +aSize.Width*rtl::math::cos( beta );
+ +aSize.Width*rtl::math::cos( beta )/2.0;
}
else
{
double beta = 2*F_PI - fAnglePi;
rfXCorrection = aSize.Height*rtl::math::sin( beta )/2.0
- +aSize.Width*rtl::math::cos( beta );
- rfYCorrection = aSize.Width*rtl::math::sin( beta );
- }
-}
-
-void lcl_correctRotation_Top_Left( double& rfXCorrection, double& rfYCorrection
- , double fAnglePositiveDegree, const awt::Size& aSize )
-{
- //correct position for top x-axis with left top alignment
- double fAnglePi = fAnglePositiveDegree*F_PI/180.0;
- if( fAnglePositiveDegree==0.0 )
- {
- rfXCorrection = -aSize.Width/2.0;
- rfYCorrection = 0.0;
- }
- else if( fAnglePositiveDegree<= 90.0 )
- {
- rfXCorrection = +aSize.Height*rtl::math::sin( fAnglePi )/2.0;
- rfYCorrection = 0.0;
- }
- else if( fAnglePositiveDegree<= 180.0 )
- {
- double beta = F_PI - fAnglePi;
- rfYCorrection = -aSize.Height*rtl::math::cos( beta );
- rfXCorrection = aSize.Height*rtl::math::sin( beta )/2.0;
- }
- else if( fAnglePositiveDegree<= 270.0 )
- {
- double beta = 3*F_PI/2.0 - fAnglePi;
- rfXCorrection = -aSize.Height*rtl::math::cos( beta )/2.0
- +aSize.Width *rtl::math::sin( beta );
- rfYCorrection = -aSize.Width *rtl::math::cos( beta )
- -aSize.Height*rtl::math::sin( beta );
- }
- else
- {
- double beta = 2*F_PI - fAnglePi;
- rfXCorrection = - aSize.Width*rtl::math::cos( beta )
- - aSize.Height*rtl::math::sin( beta )/2.0;
- rfYCorrection = - aSize.Width*rtl::math::sin( beta );
- }
-}
-
-void lcl_correctRotation_Top_Right( double& rfXCorrection, double& rfYCorrection
- , double fAnglePositiveDegree, const awt::Size& aSize )
-{
- //correct position for top x-axis with right top alignment
- double fAnglePi = fAnglePositiveDegree*F_PI/180.0;
- if( fAnglePositiveDegree==0.0 )
- {
- rfXCorrection = aSize.Width/2.0;
- rfYCorrection = 0.0;
- }
- else if( fAnglePositiveDegree<= 90.0 )
- {
- rfXCorrection = aSize.Height*rtl::math::sin( fAnglePi )/2.0
- +aSize.Width*rtl::math::cos( fAnglePi );
- rfYCorrection = -aSize.Width*rtl::math::sin( fAnglePi );
- }
- else if( fAnglePositiveDegree<= 180.0 )
- {
- double beta = F_PI - fAnglePi;
- rfYCorrection = -aSize.Height*rtl::math::cos( beta )
- -aSize.Width*rtl::math::sin( beta );
- rfXCorrection = -aSize.Width*rtl::math::cos( beta )
- +aSize.Height*rtl::math::sin( beta )/2.0;
- }
- else if( fAnglePositiveDegree<= 270.0 )
- {
- double beta = 3*F_PI/2.0 - fAnglePi;
- rfXCorrection = -aSize.Height*rtl::math::cos( beta )/2.0;
- rfYCorrection = -aSize.Height*rtl::math::sin( beta );
- }
- else
- {
- double beta = 2*F_PI - fAnglePi;
- rfXCorrection = - aSize.Height*rtl::math::sin( beta )/2.0;
- rfYCorrection = - 0.0;
+ +aSize.Width*rtl::math::cos( beta )/2.0;
+ rfYCorrection = aSize.Width*rtl::math::sin( beta )/2.0;
}
}
-enum ShiftDirection { SHIFT_LEFT, SHIFT_TOP, SHIFT_RIGHT, SHIFT_BOTTOM };
-enum RotationCentre { ROTATE_LEFT_TOP, ROTATE_LEFT_BOTTOM, ROTATE_RIGHT_TOP, ROTATE_RIGHT_BOTTOM };
-
-ShiftDirection lcl_getLabelShiftDirection( const AxisProperties& rAxisProperties )
+void lcl_getPositionCorrectionForRotation(
+ double& rfXCorrection
+ , double& rfYCorrection
+ , LabelAlignment eLabelAlignment
+ , const double fRotationAngle
+ , const awt::Size& aSize )
{
- ShiftDirection aShiftDirection = SHIFT_RIGHT;
- if(rAxisProperties.m_bIsYAxis)
- {
- if(rAxisProperties.m_bIsLeftOrBottomAxis)
- aShiftDirection = SHIFT_LEFT;
- }
- else
- {
- if(rAxisProperties.m_bIsLeftOrBottomAxis)
- aShiftDirection = SHIFT_BOTTOM;
- else
- aShiftDirection = SHIFT_TOP;
- }
- return aShiftDirection;
-}
+ double fAnglePositiveDegree = fRotationAngle;
+ while(fAnglePositiveDegree<0.0)
+ fAnglePositiveDegree+=360.0;
-RotationCentre lcl_getLabelRotationCentre(
- const AxisProperties& rAxisProperties
- , const AxisLabelProperties& rAxisLabelProperties )
-{
- //indicate where the centre of the rotation lies (e.g. top left or bottom left corner of the text shape)
- RotationCentre aRotationCentre = ROTATE_LEFT_TOP;
+ switch(eLabelAlignment)
{
- LabelAlignment eLabelAlignment( lcl_getLabelAlignment( rAxisProperties ) );
- switch(eLabelAlignment)
- {
+ case LABEL_ALIGN_LEFT:
case LABEL_ALIGN_LEFT_TOP:
- aRotationCentre = ROTATE_RIGHT_BOTTOM;
- break;
case LABEL_ALIGN_LEFT_BOTTOM:
- aRotationCentre = ROTATE_RIGHT_TOP;
+ lcl_correctRotation_Left( rfXCorrection, rfYCorrection, fAnglePositiveDegree, aSize );
break;
+ case LABEL_ALIGN_RIGHT:
case LABEL_ALIGN_RIGHT_TOP:
- aRotationCentre = ROTATE_LEFT_BOTTOM;
- break;
case LABEL_ALIGN_RIGHT_BOTTOM:
- aRotationCentre = ROTATE_LEFT_TOP;
+ lcl_correctRotation_Right( rfXCorrection, rfYCorrection, fAnglePositiveDegree, aSize );
break;
- case LABEL_ALIGN_LEFT:
case LABEL_ALIGN_TOP:
- case LABEL_ALIGN_RIGHT:
+ lcl_correctRotation_Top( rfXCorrection, rfYCorrection, fAnglePositiveDegree, aSize );
+ break;
case LABEL_ALIGN_BOTTOM:
+ lcl_correctRotation_Bottom( rfXCorrection, rfYCorrection, fAnglePositiveDegree, aSize );
default: //LABEL_ALIGN_CENTER
- ROTATE_RIGHT_BOTTOM;
break;
- };
}
- return aRotationCentre;
}
-void lcl_getPositionCorrectionForRotation(
- double& rfXCorrection
- , double& rfYCorrection
- , const ShiftDirection& aShiftDirection
- , const RotationCentre& aRotationCentre
- , const double fRotationAngle
- , const awt::Size& aSize )
-{
- double fAnglePositiveDegree = fRotationAngle;
- while(fAnglePositiveDegree<0.0)
- fAnglePositiveDegree+=360.0;
-
- if( SHIFT_LEFT ==aShiftDirection )
- {
- DBG_ASSERT( ROTATE_RIGHT_TOP ==aRotationCentre, "it is assumed that rotation centre is at left top corner if labels are shifted to the right" );
-
- lcl_correctRotation_Left( rfXCorrection, rfYCorrection, fAnglePositiveDegree, aSize );
- }
- else if( SHIFT_RIGHT ==aShiftDirection )
- {
- DBG_ASSERT( ROTATE_LEFT_TOP ==aRotationCentre, "it is assumed that rotation centre is at left top corner if labels are shifted to the right" );
-
- lcl_correctRotation_Right( rfXCorrection, rfYCorrection, fAnglePositiveDegree, aSize );
- }
- else if( SHIFT_BOTTOM ==aShiftDirection )
- {
- DBG_ASSERT( ROTATE_LEFT_TOP ==aRotationCentre
- || ROTATE_RIGHT_TOP ==aRotationCentre
- , "it is assumed that rotation centre is at left or right top corner if labels are shifted to the bottom" );
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
- if( ROTATE_LEFT_TOP ==aRotationCentre )
- lcl_correctRotation_Bottom_Left( rfXCorrection, rfYCorrection, fAnglePositiveDegree, aSize );
- else
- lcl_correctRotation_Bottom_Right( rfXCorrection, rfYCorrection, fAnglePositiveDegree, aSize );
- }
- else if( SHIFT_TOP ==aShiftDirection )
- {
- DBG_ASSERT( ROTATE_LEFT_BOTTOM ==aRotationCentre
- || ROTATE_RIGHT_BOTTOM ==aRotationCentre
- , "it is assumed that rotation centre is at left or right bottom corner if labels are shifted to the top" );
+VCartesianAxis::VCartesianAxis( const AxisProperties& rAxisProperties
+ , NumberFormatterWrapper* pNumberFormatterWrapper
+ , sal_Int32 nDimensionCount
+ , PlottingPositionHelper* pPosHelper )//takes ownership
+ : VMeterBase( uno::Reference<XMeter>::query(rAxisProperties.m_xAxisModel)
+ , nDimensionCount )
+ , m_aAxisProperties( rAxisProperties )
+ , m_pNumberFormatterWrapper( pNumberFormatterWrapper )
+{
+ if( pPosHelper )
+ m_pPosHelper = pPosHelper;
+ else
+ m_pPosHelper = new PlottingPositionHelper();
+}
- if( ROTATE_LEFT_BOTTOM ==aRotationCentre )
- lcl_correctRotation_Top_Left( rfXCorrection, rfYCorrection, fAnglePositiveDegree, aSize );
- else
- lcl_correctRotation_Top_Right( rfXCorrection, rfYCorrection, fAnglePositiveDegree, aSize );
- }
+VCartesianAxis::~VCartesianAxis()
+{
+ delete m_pPosHelper;
+ m_pPosHelper = NULL;
}
+
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
@@ -571,18 +328,15 @@ uno::Reference< drawing::XShape > createSingleLabel(
uno::Reference< drawing::XShape > xShape2DText = ShapeFactory(xShapeFactory)
.createText( xTarget, aLabel, rPropNames, rPropValues, aATransformation );
//-------------
- //correctPositionForRotation()
+ //correctPositionForRotation
awt::Point aOldPos = xShape2DText->getPosition();
awt::Size aSize = xShape2DText->getSize();
- ShiftDirection aShiftDirection = lcl_getLabelShiftDirection( rAxisProperties );
- RotationCentre aRotationCentre = lcl_getLabelRotationCentre( rAxisProperties, rAxisLabelProperties );
-
double fYCorrection = 0.0;
double fXCorrection = 0.0;
lcl_getPositionCorrectionForRotation( fXCorrection, fYCorrection
- , aShiftDirection, aRotationCentre
+ , rAxisProperties.m_aLabelAlignment
, rAxisLabelProperties.fRotationAngleDegree, aSize );
xShape2DText->setPosition( awt::Point(
@@ -594,41 +348,22 @@ uno::Reference< drawing::XShape > createSingleLabel(
}
bool lcl_doesOverlap( const uno::Reference< drawing::XShape >& xShape
-, sal_Int32 nScreenTickValue, bool bCheckDirectionIsY )
+ , const Vector2D& rTickScreenPosition )
{
if(!xShape.is())
return false;
- awt::Size aSize = xShape->getSize();
- awt::Point aPos = xShape->getPosition();
-
- sal_Int32 nMin = bCheckDirectionIsY ? aPos.Y : aPos.X;
- sal_Int32 nMax = nMin + ( bCheckDirectionIsY ? aSize.Height : aSize.Width );
-
- return nMin <= nScreenTickValue && nScreenTickValue <= nMax;
+ DoublePoint aP(rTickScreenPosition.X(),rTickScreenPosition.Y());
+ DoubleRectangle aRect(xShape->getPosition(),xShape->getSize());
+ return aRect.isInside(aP);
}
bool doesOverlap( const uno::Reference< drawing::XShape >& xShape1
- , const uno::Reference< drawing::XShape >& xShape2
- , bool bCheckDirectionIsY )
+ , const uno::Reference< drawing::XShape >& xShape2 )
{
- awt::Size aSize1 = xShape1->getSize();
- awt::Point aPos1 = xShape1->getPosition();
-
- sal_Int32 nMin1 = bCheckDirectionIsY ? aPos1.Y : aPos1.X;
- sal_Int32 nMax1 = nMin1 + ( bCheckDirectionIsY ? aSize1.Height : aSize1.Width );
-
- awt::Size aSize2 = xShape2->getSize();
- awt::Point aPos2 = xShape2->getPosition();
-
- sal_Int32 nMin2 = bCheckDirectionIsY ? aPos2.Y : aPos2.X;
- sal_Int32 nMax2 = nMin2 + ( bCheckDirectionIsY ? aSize2.Height : aSize2.Width );
-
- if( nMax1 < nMin2 )
- return false;
- if( nMax2 < nMin1 )
- return false;
- return true;
+ DoubleRectangle aRect1(xShape1->getPosition(),xShape1->getSize());
+ DoubleRectangle aRect2(xShape2->getPosition(),xShape2->getSize());
+ return aRect1.isOverlap(aRect2);
}
void removeShapesAtWrongRythm( TickIter& rIter
@@ -736,14 +471,12 @@ TickInfo* LabelIterator::nextInfo()
return pTickInfo;
}
-sal_Int32 lcl_getStaggerDistance(
- LabelIterator& rIter
- , const ShiftDirection aShiftDirection )
+Vector2D lcl_getStaggerDistance( LabelIterator& rIter, const Vector2D& rStaggerDirection )
{
//calculates the height or width of the first line of labels
//thus the second line of labels needs to be shifted for that distance
- sal_Int32 nRet=0;
+ sal_Int32 nDistance=0;
uno::Reference< drawing::XShape > xShape2DText(NULL);
for( TickInfo* pTickInfo = rIter.firstInfo()
; pTickInfo
@@ -753,27 +486,18 @@ sal_Int32 lcl_getStaggerDistance(
DBG_ASSERT(xShape2DText.is(),"LabelIterator does not work correctly");
awt::Size aSize = xShape2DText->getSize();
- switch(aShiftDirection)
- {
- case SHIFT_TOP:
- nRet = ::std::max(nRet,aSize.Height); break;
- case SHIFT_BOTTOM:
- nRet = ::std::max(nRet,aSize.Height); break;
- case SHIFT_LEFT:
- nRet = ::std::max(nRet,aSize.Width); break;
- case SHIFT_RIGHT:
- nRet = ::std::max(nRet,aSize.Width); break;
- }
+ if(rStaggerDirection.X()>rStaggerDirection.Y())
+ nDistance = ::std::max(nDistance,aSize.Width);
+ else
+ nDistance = ::std::max(nDistance,aSize.Height);
}
- return nRet;
+ return rStaggerDirection*nDistance;
}
-void lcl_correctPositionForStaggering(
- LabelIterator& rIter
- , const ShiftDirection aShiftDirection
- , sal_Int32 nStaggerDistance
- )
+void lcl_correctPositionForStaggering( LabelIterator& rIter, const Vector2D& rStaggerDistance )
{
+ if(rStaggerDistance.GetLength()==0.0)
+ return;
uno::Reference< drawing::XShape > xShape2DText(NULL);
for( TickInfo* pTickInfo = rIter.firstInfo()
; pTickInfo
@@ -783,38 +507,33 @@ void lcl_correctPositionForStaggering(
DBG_ASSERT(xShape2DText.is(),"LabelIterator does not work correctly");
awt::Point aPos = xShape2DText->getPosition();
- switch(aShiftDirection)
- {
- case SHIFT_TOP:
- aPos.Y -= nStaggerDistance; break;
- case SHIFT_BOTTOM:
- aPos.Y += nStaggerDistance; break;
- case SHIFT_LEFT:
- aPos.X -= nStaggerDistance; break;
- case SHIFT_RIGHT:
- aPos.X += nStaggerDistance; break;
- }
+ aPos.X += static_cast<sal_Int32>(rStaggerDistance.X());
+ aPos.Y += static_cast<sal_Int32>(rStaggerDistance.Y());
xShape2DText->setPosition( aPos );
}
}
-bool createTextShapes( const uno::Reference< lang::XMultiServiceFactory >& xShapeFactory
- , const uno::Reference< drawing::XShapes >& xTarget
+bool VCartesianAxis::createTextShapes(
+ const uno::Reference< drawing::XShapes >& xTarget
, ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos
- , const ExplicitIncrementData& rIncrement
, AxisLabelProperties& rAxisLabelProperties
- , const AxisProperties& rAxisProperties
- , sal_Int32 nTextReferenceScreenPosition
- , const FixedNumberFormatter& rFixedNumberFormatter
- , const uno::Reference< XScaling >& xInverseScaling )
+ , TickmarkHelper_2D* pTickmarkHelper )
{
//returns true if the text shapes have been created succesfully
//otherwise false - in this case the AxisLabelProperties have changed
//and contain new instructions for the next try for text shape creation
- bool bOverlapCheckDirectionIsY = rAxisProperties.m_bIsYAxis;
+ uno::Reference< XScaling > xInverseScaling( NULL );
+ if( m_aScale.Scaling.is() )
+ xInverseScaling = m_aScale.Scaling->getInverseScaling();
+
+ FixedNumberFormatter aFixedNumberFormatter(
+ m_pNumberFormatterWrapper, rAxisLabelProperties.aNumberFormat );
+
+ Vector2D aTextToTickDistance( pTickmarkHelper->getDistanceTickToText( m_aAxisProperties ) );
+
//@todo: iterate through all tick depth wich should be labeled
- TickIter aIter( rAllTickInfos, rIncrement, 0, 0 );
+ TickIter aIter( rAllTickInfos, m_aIncrement, 0, 0 );
TickInfo* pPreviousVisibleTickInfo = NULL;
TickInfo* pPREPreviousVisibleTickInfo = NULL;
TickInfo* pLastVisibleNeighbourTickInfo = NULL;
@@ -843,12 +562,12 @@ bool createTextShapes( const uno::Reference< lang::XMultiServiceFactory >& xShap
tNameSequence aPropNames;
tAnySequence aPropValues;
- uno::Reference< beans::XPropertySet > xProps( rAxisProperties.m_xAxisModel, uno::UNO_QUERY );
+ uno::Reference< beans::XPropertySet > xProps( m_aAxisProperties.m_xAxisModel, uno::UNO_QUERY );
PropertyMapper::getTextLabelMultiPropertyLists( xProps, aPropNames, aPropValues, false
- , nLimitedSpaceForStaggering, rAxisProperties.m_bIsYAxis );
+ , nLimitedSpaceForStaggering, fabs(aTextToTickDistance.X()) > fabs(aTextToTickDistance.Y()) );
LabelPositionHelper::doDynamicFontResize( aPropValues, aPropNames, xProps
- , rAxisProperties.m_aReferenceSize );
- LabelPositionHelper::changeTextAdjustment( aPropValues, aPropNames, lcl_getLabelAlignment( rAxisProperties ) );
+ , m_aAxisProperties.m_aReferenceSize );
+ LabelPositionHelper::changeTextAdjustment( aPropValues, aPropNames, m_aAxisProperties.m_aLabelAlignment );
uno::Any* pColorAny = PropertyMapper::getValuePointer(aPropValues,aPropNames,C2U("CharColor"));
sal_Int32 nColor = Color( COL_AUTO ).GetColor();
@@ -876,12 +595,12 @@ bool createTextShapes( const uno::Reference< lang::XMultiServiceFactory >& xShap
//with the text of the last neighbour tickmark
if( pLastVisibleNeighbourTickInfo && !rAxisLabelProperties.bOverlapAllowed )
{
- if( lcl_doesOverlap( pLastVisibleNeighbourTickInfo->xTextShape, pTickInfo->nScreenTickValue, bOverlapCheckDirectionIsY ) )
+ if( lcl_doesOverlap( pLastVisibleNeighbourTickInfo->xTextShape, pTickInfo->aTickScreenPosition ) )
{
if( rAxisLabelProperties.bRhythmIsFix )
continue;
rAxisLabelProperties.nRhythm++;
- TickIter aRemoveIter( rAllTickInfos, rIncrement, 0, 0 );
+ TickIter aRemoveIter( rAllTickInfos, m_aIncrement, 0, 0 );
removeShapesAtWrongRythm( aRemoveIter, rAxisLabelProperties.nRhythm, nTick, xTarget );
return false;
}
@@ -891,31 +610,27 @@ bool createTextShapes( const uno::Reference< lang::XMultiServiceFactory >& xShap
bool bHasExtraColor=false;
sal_Int32 nExtraColor=0;
- rtl::OUString aLabel = rFixedNumberFormatter.getFormattedString( pTickInfo->fUnscaledTickValue, nExtraColor, bHasExtraColor );
+ rtl::OUString aLabel = aFixedNumberFormatter.getFormattedString( pTickInfo->fUnscaledTickValue, nExtraColor, bHasExtraColor );
if(pColorAny)
*pColorAny = uno::makeAny(bHasExtraColor?nExtraColor:nColor);
- awt::Point aAnchorScreenPosition2D;
- {//get anchor position
- sal_Int32 nAxisPos = nTextReferenceScreenPosition;
- sal_Int32 nTickPos = pTickInfo->nScreenTickValue;
- if( rAxisProperties.m_bIsYAxis )
- aAnchorScreenPosition2D = awt::Point(nAxisPos,nTickPos);
- else
- aAnchorScreenPosition2D = awt::Point(nTickPos,nAxisPos);
- }
+ Vector2D aTickScreenPos2D( pTickInfo->aTickScreenPosition );
+ aTickScreenPos2D += aTextToTickDistance;
+ awt::Point aAnchorScreenPosition2D(
+ static_cast<sal_Int32>(aTickScreenPos2D.X())
+ ,static_cast<sal_Int32>(aTickScreenPos2D.Y()));
//create single label
if(!pTickInfo->xTextShape.is())
- pTickInfo->xTextShape = createSingleLabel( xShapeFactory, xTarget
+ pTickInfo->xTextShape = createSingleLabel( m_xShapeFactory, xTarget
, aAnchorScreenPosition2D, aLabel
- , rAxisLabelProperties, rAxisProperties
+ , rAxisLabelProperties, m_aAxisProperties
, aPropNames, aPropValues );
//if NO OVERLAP -> remove overlapping shapes
if( pLastVisibleNeighbourTickInfo && !rAxisLabelProperties.bOverlapAllowed )
{
- if( doesOverlap( pLastVisibleNeighbourTickInfo->xTextShape, pTickInfo->xTextShape, bOverlapCheckDirectionIsY ) )
+ if( doesOverlap( pLastVisibleNeighbourTickInfo->xTextShape, pTickInfo->xTextShape ) )
{
if( rAxisLabelProperties.bRhythmIsFix )
{
@@ -924,7 +639,7 @@ bool createTextShapes( const uno::Reference< lang::XMultiServiceFactory >& xShap
continue;
}
rAxisLabelProperties.nRhythm++;
- TickIter aRemoveIter( rAllTickInfos, rIncrement, 0, 0 );
+ TickIter aRemoveIter( rAllTickInfos, m_aIncrement, 0, 0 );
removeShapesAtWrongRythm( aRemoveIter, rAxisLabelProperties.nRhythm, nTick, xTarget );
return false;
}
@@ -936,76 +651,77 @@ bool createTextShapes( const uno::Reference< lang::XMultiServiceFactory >& xShap
return true;
}
-sal_Int32 lcl_getTextReferenceScreenPosition( const ::std::vector<TickmarkProperties>& rTickmarkPropertiesList
- , bool bIsYAxis
- , bool bIsLeftOrBottomAxis
- , sal_Int32 nAxisPos )
+drawing::PointSequenceSequence lcl_makePointSequence( Vector2D& rStart, Vector2D& rEnd )
{
- sal_Int32 nRet = 0;
-
- bool bFindMin = (bIsYAxis && bIsLeftOrBottomAxis) || (!bIsYAxis && !bIsLeftOrBottomAxis);
- ::std::vector<TickmarkProperties>::const_iterator aIter = rTickmarkPropertiesList.begin();
- const ::std::vector<TickmarkProperties>::const_iterator aIterEnd = rTickmarkPropertiesList.end();
- for( ; aIter != aIterEnd; aIter++ )
- {
- if( ( bFindMin && (*aIter).RelativePos < nRet )
- ||
- ( !bFindMin && (*aIter).RelativePos > nRet )
- )
- {
- nRet = (*aIter).RelativePos;
- }
- }
- nRet+=nAxisPos;
-
- if(bFindMin)
- nRet-=AXIS2D_TICKLABELSPACING;
- else
- nRet+=AXIS2D_TICKLABELSPACING;
- return nRet;
+ drawing::PointSequenceSequence aPoints(1);
+ aPoints[0].realloc(2);
+ aPoints[0][0].X = static_cast<sal_Int32>(rStart.X());
+ aPoints[0][0].Y = static_cast<sal_Int32>(rStart.Y());
+ aPoints[0][1].X = static_cast<sal_Int32>(rEnd.X());
+ aPoints[0][1].Y = static_cast<sal_Int32>(rEnd.Y());
+ return aPoints;
}
-void addLine( drawing::PointSequenceSequence& rPoints, sal_Int32 nIndex
- , sal_Int32 nScreenTickValue, sal_Int32 nOrthogonalAxisScreenPosition
- , const TickmarkProperties& rTickmarkProperties, bool bIsYAxis )
+double VCartesianAxis::getLogicValueWhereMainLineCrossesOtherAxis() const
{
- sal_Int32 nStartX = bIsYAxis ? nOrthogonalAxisScreenPosition + rTickmarkProperties.RelativePos : nScreenTickValue;
- sal_Int32 nStartY = bIsYAxis ? nScreenTickValue : nOrthogonalAxisScreenPosition + rTickmarkProperties.RelativePos;
+ sal_Int32 nDimensionIndex = m_aAxisProperties.m_xAxisModel->getRepresentedDimension();
+ double fMin = (nDimensionIndex==1) ? m_pPosHelper->getLogicMinX() : m_pPosHelper->getLogicMinY();
+ double fMax = (nDimensionIndex==1) ? m_pPosHelper->getLogicMaxX() : m_pPosHelper->getLogicMaxY();
- sal_Int32 nEndX = nStartX;
- sal_Int32 nEndY = nStartY;
- if( bIsYAxis )
- nEndX += rTickmarkProperties.Length;
+ double fCrossesOtherAxis;
+ if(m_aAxisProperties.m_pfMainLinePositionAtOtherAxis)
+ fCrossesOtherAxis = *m_aAxisProperties.m_pfMainLinePositionAtOtherAxis;
else
- nEndY += rTickmarkProperties.Length;
-
- rPoints[nIndex].realloc(2);
- rPoints[nIndex][0].X = nStartX;
- rPoints[nIndex][0].Y = nStartY;
- rPoints[nIndex][1].X = nEndX;
- rPoints[nIndex][1].Y = nEndY;
+ {
+ bool bMinimumForLeftAxis = ( (nDimensionIndex==1) && m_pPosHelper->isMathematicalOrientationY() )
+ || ( (nDimensionIndex!=1) && m_pPosHelper->isMathematicalOrientationX() );
+ fCrossesOtherAxis = ( bMinimumForLeftAxis && m_aAxisProperties.m_bIsMainAxis ) ? fMin : fMax;
+ }
+ return fCrossesOtherAxis;
}
-
-void createPointSequenceForAxisMainLine( drawing::PointSequenceSequence& rPoints,
- bool bIsYAxis, sal_Int32 nOrthogonalPos, sal_Int32 nMin, sal_Int32 nMax )
+bool VCartesianAxis::getLogicValueWhereExtraLineCrossesOtherAxis( double& fCrossesOtherAxis ) const
{
- rPoints[0].realloc(2);
- rPoints[0][0].X = bIsYAxis ? nOrthogonalPos : nMin;
- rPoints[0][0].Y = bIsYAxis ? nMin : nOrthogonalPos;
- rPoints[0][1].X = bIsYAxis ? nOrthogonalPos : nMax;
- rPoints[0][1].Y = bIsYAxis ? nMax : nOrthogonalPos;
+ if( !m_aAxisProperties.m_pfExrtaLinePositionAtOtherAxis )
+ return false;
+ sal_Int32 nDimensionIndex = m_aAxisProperties.m_xAxisModel->getRepresentedDimension();
+ double fMin = (nDimensionIndex==1) ? m_pPosHelper->getLogicMinX() : m_pPosHelper->getLogicMinY();
+ double fMax = (nDimensionIndex==1) ? m_pPosHelper->getLogicMaxX() : m_pPosHelper->getLogicMaxY();
+ if( *m_aAxisProperties.m_pfExrtaLinePositionAtOtherAxis <= fMin
+ || *m_aAxisProperties.m_pfExrtaLinePositionAtOtherAxis >= fMax )
+ return false;
+ fCrossesOtherAxis = *m_aAxisProperties.m_pfExrtaLinePositionAtOtherAxis;
+ return true;
+}
+void VCartesianAxis::get2DAxisMainLine( Vector2D& rStart, Vector2D& rEnd, double fCrossesOtherAxis ) const
+{
+ sal_Int32 nDimensionIndex = m_aAxisProperties.m_xAxisModel->getRepresentedDimension();
+ double fXStart = (nDimensionIndex==1) ? fCrossesOtherAxis : m_pPosHelper->getLogicMinX();
+ double fYStart = (nDimensionIndex==1) ? m_pPosHelper->getLogicMinY() : fCrossesOtherAxis;
+ drawing::Position3D aSceneStart = m_pPosHelper->transformLogicToScene( fXStart, fYStart, 0, true );
+
+ double fXEnd = (nDimensionIndex==1) ? fCrossesOtherAxis : m_pPosHelper->getLogicMaxX();
+ double fYEnd = (nDimensionIndex==1) ? m_pPosHelper->getLogicMaxY() : fCrossesOtherAxis;
+ drawing::Position3D aSceneEnd = m_pPosHelper->transformLogicToScene( fXEnd, fYEnd, 0, true );
+
+ rStart.X() = aSceneStart.PositionX;
+ rStart.Y() = aSceneStart.PositionY;
+ rEnd.X() = aSceneEnd.PositionX;
+ rEnd.Y() = aSceneEnd.PositionY;
}
-void SAL_CALL VAxis::createShapes()
+void SAL_CALL VCartesianAxis::createShapes()
{
+ if(2!=m_nDimension) //@todo remove this restriction if 3D axes are available
+ return;
+
DBG_ASSERT(m_pShapeFactory&&m_xLogicTarget.is()&&m_xFinalTarget.is(),"Axis is not proper initialized");
if(!(m_pShapeFactory&&m_xLogicTarget.is()&&m_xFinalTarget.is()))
return;
- m_aAxisProperties.init();
- bool bIsYAxis = m_aAxisProperties.m_bIsYAxis;
- bool bIsLeftOrBottomAxis = m_aAxisProperties.m_bIsLeftOrBottomAxis;
- sal_Int32 nMainLineScreenPosition = lcl_getMainLineScreenPosition( *m_pPosHelper, m_aAxisProperties );
+ Vector2D aStart, aEnd;
+ this->get2DAxisMainLine( aStart, aEnd, this->getLogicValueWhereMainLineCrossesOtherAxis() );
+ std::auto_ptr< TickmarkHelper_2D > apTickmarkHelper(
+ new TickmarkHelper_2D( m_aScale, m_aIncrement, aStart, aEnd ) );
//-----------------------------------------
//create named group shape
@@ -1021,7 +737,6 @@ void SAL_CALL VAxis::createShapes()
//-----------------------------------------
//create all scaled tickmark values
- std::auto_ptr< TickmarkHelper > apTickmarkHelper( this->createTickmarkHelper() );
::std::vector< ::std::vector< TickInfo > > aAllTickInfos;
apTickmarkHelper->getAllTicks( aAllTickInfos );
@@ -1050,9 +765,8 @@ void SAL_CALL VAxis::createShapes()
{
if( !(*aTickIter).bPaintIt )
continue;
- addLine( aPoints, nN
- , (*aTickIter).nScreenTickValue, nMainLineScreenPosition
- , rTickmarkProperties, bIsYAxis);
+ apTickmarkHelper->addPointSequenceForTickLine( aPoints, nN, (*aTickIter).fScaledTickValue
+ , m_aAxisProperties.m_fInnerDirectionSign, rTickmarkProperties );
nN++;
}
aPoints.realloc(nN);
@@ -1069,10 +783,7 @@ void SAL_CALL VAxis::createShapes()
//it serves also as the handle shape for the axis selection
{
drawing::PointSequenceSequence aPoints(1);
- createPointSequenceForAxisMainLine( aPoints
- , bIsYAxis, nMainLineScreenPosition
- , aTickmarkHelper.getScreenValueForMinimum(), aTickmarkHelper.getScreenValueForMaximum() );
-
+ aTickmarkHelper.createPointSequenceForAxisMainLine( aPoints );
uno::Reference< drawing::XShape > xShape = m_pShapeFactory->createLine2D(
xGroupShape_Shapes, aPoints
, m_aAxisProperties.m_aLineProperties );
@@ -1081,17 +792,14 @@ void SAL_CALL VAxis::createShapes()
}
//-----------------------------------------
//create an additional line at NULL
- sal_Int32 nExtraLineScreenPosition;
- if( lcl_getExtraLineScreenPosition( nExtraLineScreenPosition, *m_pPosHelper, m_aAxisProperties ) )
+ double fExtraLineCrossesOtherAxis;
+ if( getLogicValueWhereExtraLineCrossesOtherAxis(fExtraLineCrossesOtherAxis) )
{
- drawing::PointSequenceSequence aPoints(1);
- createPointSequenceForAxisMainLine( aPoints
- , bIsYAxis, nExtraLineScreenPosition
- , aTickmarkHelper.getScreenValueForMinimum(), aTickmarkHelper.getScreenValueForMaximum() );
-
+ Vector2D aStart, aEnd;
+ this->get2DAxisMainLine( aStart, aEnd, fExtraLineCrossesOtherAxis );
+ drawing::PointSequenceSequence aPoints( lcl_makePointSequence(aStart,aEnd) );
uno::Reference< drawing::XShape > xShape = m_pShapeFactory->createLine2D(
- xGroupShape_Shapes, aPoints
- , m_aAxisProperties.m_aLineProperties );
+ xGroupShape_Shapes, aPoints, m_aAxisProperties.m_aLineProperties );
}
}
//-----------------------------------------
@@ -1100,22 +808,9 @@ void SAL_CALL VAxis::createShapes()
aAxisLabelProperties.init(m_aAxisProperties.m_xAxisModel);
if( aAxisLabelProperties.bDisplayLabels )
{
- FixedNumberFormatter aFixedNumberFormatter(
- m_pNumberFormatterWrapper, aAxisLabelProperties.aNumberFormat );
-
- uno::Reference< XScaling > xInverseScaling( NULL );
- if( m_aScale.Scaling.is() )
- xInverseScaling = m_aScale.Scaling->getInverseScaling();
-
- sal_Int32 nTextReferenceScreenPosition = lcl_getTextReferenceScreenPosition(
- m_aAxisProperties.m_aTickmarkPropertiesList
- , bIsYAxis, bIsLeftOrBottomAxis, nMainLineScreenPosition );
-
//create tick mark text shapes
- while( !createTextShapes( m_xShapeFactory, xGroupShape_Shapes, aAllTickInfos
- , m_aIncrement, aAxisLabelProperties, m_aAxisProperties
- , nTextReferenceScreenPosition
- , aFixedNumberFormatter, xInverseScaling
+ while( !createTextShapes( xGroupShape_Shapes, aAllTickInfos
+ , aAxisLabelProperties, apTickmarkHelper.get()
) )
{
};
@@ -1128,12 +823,12 @@ void SAL_CALL VAxis::createShapes()
LabelIterator aOuterIter( aAllTickInfos, m_aIncrement
, aAxisLabelProperties.eStaggering, false, 0, 0 );
- sal_Int32 nStaggerDistance = lcl_getStaggerDistance( aInnerIter
- , lcl_getLabelShiftDirection( m_aAxisProperties ) );
+ Vector2D aStaggerDirection( apTickmarkHelper->getDistanceTickToText( m_aAxisProperties ) );
+ aStaggerDirection.Normalize();
lcl_correctPositionForStaggering( aOuterIter
- , lcl_getLabelShiftDirection( m_aAxisProperties )
- , nStaggerDistance );
+ , lcl_getStaggerDistance( aInnerIter
+ , aStaggerDirection ) );
}
}
}
diff --git a/chart2/source/view/axes/VCartesianAxis.hxx b/chart2/source/view/axes/VCartesianAxis.hxx
index 8f29d974e0dd..0f9b4c79ec3c 100644
--- a/chart2/source/view/axes/VCartesianAxis.hxx
+++ b/chart2/source/view/axes/VCartesianAxis.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: VCartesianAxis.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: iha $ $Date: 2004-01-17 13:09:55 $
+ * last change: $Author: iha $ $Date: 2004-01-22 19:20:34 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -58,11 +58,17 @@
*
*
************************************************************************/
-#ifndef _CHART2_VAXIS_HXX
-#define _CHART2_VAXIS_HXX
+#ifndef _CHART2_VCARTESIANAXIS_HXX
+#define _CHART2_VCARTESIANAXIS_HXX
#include "VMeterBase.hxx"
#include "VAxisProperties.hxx"
+#include "TickmarkHelper.hxx"
+
+// header for class Vector2D
+#ifndef _VECTOR2D_HXX
+#include <tools/vector2d.hxx>
+#endif
//.............................................................................
namespace chart
@@ -75,17 +81,19 @@ namespace chart
class NumberFormatterWrapper;
-class VAxis : public VMeterBase
+class VCartesianAxis : public VMeterBase
{
//-------------------------------------------------------------------------
// public methods
//-------------------------------------------------------------------------
public:
- VAxis( const AxisProperties& rAxisProperties
+ VCartesianAxis( const AxisProperties& rAxisProperties
, NumberFormatterWrapper* pNumberFormatterWrapper
- , sal_Int32 nDimensionCount=2 );
+ , sal_Int32 nDimensionCount
+ , PlottingPositionHelper* pPosHelper = NULL //takes ownership
+ );
- virtual ~VAxis();
+ virtual ~VCartesianAxis();
//-------------------------------------------------------------------------
// partly chart2::XPlotter
@@ -99,6 +107,11 @@ public:
virtual void SAL_CALL createShapes();
//-------------------------------------------------------------------------
+ double getLogicValueWhereMainLineCrossesOtherAxis() const;
+ bool getLogicValueWhereExtraLineCrossesOtherAxis( double& fCrossesOtherAxis) const;
+ void get2DAxisMainLine( Vector2D& rStart, Vector2D& rEnd, double fCrossesOtherAxis ) const;
+
+ //-------------------------------------------------------------------------
//Layout interface for cartesian axes:
//the returned value describes the minimum size that is necessary
@@ -118,6 +131,14 @@ public:
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
+
+protected: //methods
+ bool createTextShapes( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::drawing::XShapes >& xTarget
+ , ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos
+ , AxisLabelProperties& rAxisLabelProperties
+ , TickmarkHelper_2D* pTickmarkHelper );
+
private: //member
AxisProperties m_aAxisProperties;
NumberFormatterWrapper* m_pNumberFormatterWrapper;
diff --git a/chart2/source/view/axes/VCartesianCoordinateSystem.cxx b/chart2/source/view/axes/VCartesianCoordinateSystem.cxx
index b9f1b897b245..135d1a8be602 100644
--- a/chart2/source/view/axes/VCartesianCoordinateSystem.cxx
+++ b/chart2/source/view/axes/VCartesianCoordinateSystem.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: VCartesianCoordinateSystem.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: iha $ $Date: 2004-01-17 13:09:56 $
+ * last change: $Author: iha $ $Date: 2004-01-22 19:20:34 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -62,6 +62,9 @@
#include "VCartesianGrid.hxx"
#include "VCartesianAxis.hxx"
+//for auto_ptr
+#include <memory>
+
//.............................................................................
namespace chart
{
@@ -108,23 +111,21 @@ void VCartesianCoordinateSystem::createAxesShapes( const awt::Size& rReferenceSi
for( nDim = 0; nDim < 3; nDim++ )
{
uno::Reference< XAxis > xAxis = this->getAxisByDimension(nDim);
- if(xAxis.is()
- &&2==nDimensionCount) //@todo remove this restriction if 3D axes are available
- {
- AxisProperties aAxisProperties;
- aAxisProperties.m_xAxisModel = xAxis;
- aAxisProperties.m_pfExrtaLinePositionAtOtherAxis =
- new double(nDim==1?fCoordinateOrigin[0]:fCoordinateOrigin[1]);
- aAxisProperties.m_aReferenceSize = rReferenceSize;
- //-------------------
- VAxis aAxis(aAxisProperties,pNumberFormatterWrapper);
- aAxis.setMeterData( m_aExplicitScales[nDim], m_aExplicitIncrements[nDim] );
- aAxis.init(m_xLogicTargetForAxes,m_xFinalTarget,m_xShapeFactory);
- if(2==nDimensionCount)
- aAxis.setTransformationSceneToScreen( m_aMatrixSceneToScreen );
- aAxis.setScales( m_aExplicitScales );
- aAxis.createShapes();
- }
+ if(!xAxis.is())
+ continue;
+ AxisProperties aAxisProperties(xAxis,rReferenceSize);
+ aAxisProperties.m_pfExrtaLinePositionAtOtherAxis =
+ new double(nDim==1?fCoordinateOrigin[0]:fCoordinateOrigin[1]);
+ aAxisProperties.m_bIsMainAxis = true;
+ aAxisProperties.init(true);
+ //-------------------
+ VCartesianAxis aAxis(aAxisProperties,pNumberFormatterWrapper,nDimensionCount);
+ aAxis.setMeterData( m_aExplicitScales[nDim], m_aExplicitIncrements[nDim] );
+ aAxis.init(m_xLogicTargetForAxes,m_xFinalTarget,m_xShapeFactory);
+ if(2==nDimensionCount)
+ aAxis.setTransformationSceneToScreen( m_aMatrixSceneToScreen );
+ aAxis.setScales( m_aExplicitScales );
+ aAxis.createShapes();
}
}
diff --git a/chart2/source/view/axes/VCartesianGrid.cxx b/chart2/source/view/axes/VCartesianGrid.cxx
index ecf83a51fbcf..4b238c13f4d3 100644
--- a/chart2/source/view/axes/VCartesianGrid.cxx
+++ b/chart2/source/view/axes/VCartesianGrid.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: VCartesianGrid.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: iha $ $Date: 2004-01-17 13:09:56 $
+ * last change: $Author: iha $ $Date: 2004-01-22 19:20:35 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -86,72 +86,93 @@ namespace chart
using namespace ::com::sun::star;
using namespace ::drafts::com::sun::star::chart2;
-VCartesianGrid::VCartesianGrid( const uno::Reference< XGrid >& xGrid, sal_Int32 nDimensionCount )
- : VMeterBase( uno::Reference<XMeter>::query(xGrid), nDimensionCount )
-{
- m_pPosHelper = new PlottingPositionHelper();
-}
-
-VCartesianGrid::~VCartesianGrid()
-{
- delete m_pPosHelper;
- m_pPosHelper = NULL;
-}
-
-//static
-void VCartesianGrid::fillLinePropertiesFromGridModel( ::std::vector<VLineProperties>& rLinePropertiesList
- , uno::Reference< beans::XPropertySet > xProps )
-{
- rLinePropertiesList.clear();
- VLineProperties aLineProperties;
- aLineProperties.initFromPropertySet( xProps );
- rLinePropertiesList.assign(2,aLineProperties);
-};
-
-void addLine2D( drawing::PointSequenceSequence& rPoints, sal_Int32 nIndex
- , bool bIsYGrid , sal_Int32 nScreenTickValue
- , sal_Int32 nOrthogonalStart, sal_Int32 nOrthogonalEnd
- )
-{
- rPoints[nIndex].realloc(2);
- rPoints[nIndex][0].X = bIsYGrid ? nOrthogonalStart : nScreenTickValue;
- rPoints[nIndex][0].Y = bIsYGrid ? nScreenTickValue : nOrthogonalStart;
- rPoints[nIndex][1].X = bIsYGrid ? nOrthogonalEnd : nScreenTickValue;
- rPoints[nIndex][1].Y = bIsYGrid ? nScreenTickValue : nOrthogonalEnd;
-}
-
struct GridLinePoints
{
uno::Sequence< double > P0;
uno::Sequence< double > P1;
uno::Sequence< double > P2;
- GridLinePoints( const uno::Sequence< double >& rMinEdgeSeq, const uno::Sequence< double >& rMaxEdgeSeq );
+ GridLinePoints( const PlottingPositionHelper* pPosHelper, sal_Int32 nDimensionIndex );
void update( double fScaledTickValue );
+
+ sal_Int32 m_nDimensionIndex;
};
-GridLinePoints::GridLinePoints( const uno::Sequence< double >& rMinEdgeSeq
- , const uno::Sequence< double >& rMaxEdgeSeq )
+GridLinePoints::GridLinePoints( const PlottingPositionHelper* pPosHelper, sal_Int32 nDimensionIndex )
+ : m_nDimensionIndex(nDimensionIndex)
{
- P0.realloc(3);
- P0[0]=rMinEdgeSeq[0];
- P0[1]=rMinEdgeSeq[1];
- P0[2]=rMaxEdgeSeq[2];
+ double MinX = pPosHelper->getLogicMinX();
+ double MinY = pPosHelper->getLogicMinY();
+ double MinZ = pPosHelper->getLogicMinZ();
+ double MaxX = pPosHelper->getLogicMaxX();
+ double MaxY = pPosHelper->getLogicMaxY();
+ double MaxZ = pPosHelper->getLogicMaxZ();
- P1.realloc(3);
- P1[0]=rMinEdgeSeq[0];
- P1[1]=rMaxEdgeSeq[1];
- P1[2]=rMinEdgeSeq[2];
+ pPosHelper->doLogicScaling( &MinX,&MinY,&MinZ );
+ pPosHelper->doLogicScaling( &MaxX,&MaxY,&MaxZ );
+
+ if(!pPosHelper->isMathematicalOrientationX())
+ {
+ double fHelp = MinX;
+ MinX = MaxX;
+ MaxX = fHelp;
+ }
+ if(!pPosHelper->isMathematicalOrientationY())
+ {
+ double fHelp = MinY;
+ MinY = MaxY;
+ MaxY = fHelp;
+ }
+ if(pPosHelper->isMathematicalOrientationZ())//z axis in draw is reverse to mathematical
+ {
+ double fHelp = MinZ;
+ MinZ = MaxZ;
+ MaxZ = fHelp;
+ }
+ P0.realloc(3);
+ P1.realloc(3);
P2.realloc(3);
- P2[0]=rMaxEdgeSeq[0];
- P2[1]=rMaxEdgeSeq[1];
- P2[2]=rMinEdgeSeq[2];
+
+ P0[0]=P1[0]=P2[0]=MinX;
+ P0[1]=P1[1]=P2[1]=MinY;
+ P0[2]=P1[2]=P2[2]=MinZ;
+
+ if(m_nDimensionIndex==0)
+ {
+ P0[1]=MaxY;
+ P2[2]=MaxZ;
+ }
+ else if(m_nDimensionIndex==1)
+ {
+ P0[0]=MaxX;
+ P2[2]=MaxZ;
+ }
+ else if(m_nDimensionIndex==2)
+ {
+ P0[0]=MaxX;
+ P2[1]=MaxY;
+ }
}
void GridLinePoints::update( double fScaledTickValue )
{
- P0[1] = P1[1] = P2[1] = fScaledTickValue;
+ P0[m_nDimensionIndex] = P1[m_nDimensionIndex] = P2[m_nDimensionIndex] = fScaledTickValue;
+}
+
+void addLine2D( drawing::PointSequenceSequence& rPoints, sal_Int32 nIndex
+ , const GridLinePoints& rScaledLogicPoints
+ , const uno::Reference< XTransformation > & xTransformation
+ )
+{
+ drawing::Position3D aPA = SequenceToPosition3D( xTransformation->transform( rScaledLogicPoints.P0 ) );
+ drawing::Position3D aPB = SequenceToPosition3D( xTransformation->transform( rScaledLogicPoints.P1 ) );
+
+ rPoints[nIndex].realloc(2);
+ rPoints[nIndex][0].X = static_cast<sal_Int32>(aPA.PositionX);
+ rPoints[nIndex][0].Y = static_cast<sal_Int32>(aPA.PositionY);
+ rPoints[nIndex][1].X = static_cast<sal_Int32>(aPB.PositionX);
+ rPoints[nIndex][1].Y = static_cast<sal_Int32>(aPB.PositionY);
}
void addLine3D( drawing::PolyPolygonShape3D& rPoints, sal_Int32 nIndex
@@ -166,6 +187,33 @@ void addLine3D( drawing::PolyPolygonShape3D& rPoints, sal_Int32 nIndex
AddPointToPoly( rPoints, aPoint, nIndex );
}
+//---------------------------------------------------------------------------------
+//---------------------------------------------------------------------------------
+//---------------------------------------------------------------------------------
+//---------------------------------------------------------------------------------
+
+VCartesianGrid::VCartesianGrid( const uno::Reference< XGrid >& xGrid, sal_Int32 nDimensionCount )
+ : VMeterBase( uno::Reference<XMeter>::query(xGrid), nDimensionCount )
+{
+ m_pPosHelper = new PlottingPositionHelper();
+}
+
+VCartesianGrid::~VCartesianGrid()
+{
+ delete m_pPosHelper;
+ m_pPosHelper = NULL;
+}
+
+//static
+void VCartesianGrid::fillLinePropertiesFromGridModel( ::std::vector<VLineProperties>& rLinePropertiesList
+ , uno::Reference< beans::XPropertySet > xProps )
+{
+ rLinePropertiesList.clear();
+ VLineProperties aLineProperties;
+ aLineProperties.initFromPropertySet( xProps );
+ rLinePropertiesList.assign(2,aLineProperties);
+};
+
void SAL_CALL VCartesianGrid::createShapes()
{
if( !m_xMeter.is())
@@ -210,13 +258,6 @@ void SAL_CALL VCartesianGrid::createShapes()
if(2==m_nDimension)
{
- uno::Sequence< double > aMinEdgeSeq, aMaxEdgeSeq;
- m_pPosHelper->getScreenValuesForMinimum( aMinEdgeSeq );
- m_pPosHelper->getScreenValuesForMaximum( aMaxEdgeSeq );
- sal_Int32 nOrthogonalDimensionIndex = nDimensionIndex==1 ? 0 : 1;
- sal_Int32 nOrthogonalScreenPositionStart=static_cast<sal_Int32>(aMinEdgeSeq[nOrthogonalDimensionIndex]);
- sal_Int32 nOrthogonalScreenPositionEnd =static_cast<sal_Int32>(aMaxEdgeSeq[nOrthogonalDimensionIndex]);
-
drawing::PointSequenceSequence aHandlesPoints(1);
sal_Int32 nLinePropertiesCount = aLinePropertiesList.size();
@@ -224,6 +265,8 @@ void SAL_CALL VCartesianGrid::createShapes()
; aDepthIter != aDepthEnd && nDepth < nLinePropertiesCount
; aDepthIter++, nDepth++ )
{
+ GridLinePoints aGridLinePoints( m_pPosHelper, nDimensionIndex );
+
sal_Int32 nPointCount = (*aDepthIter).size();
drawing::PointSequenceSequence aPoints(nPointCount);
@@ -234,8 +277,8 @@ void SAL_CALL VCartesianGrid::createShapes()
{
if( !(*aTickIter).bPaintIt )
continue;
- addLine2D( aPoints, nRealPointCount, 1==nDimensionIndex, (*aTickIter).nScreenTickValue
- , nOrthogonalScreenPositionStart, nOrthogonalScreenPositionEnd );
+ aGridLinePoints.update( (*aTickIter).fScaledTickValue );
+ addLine2D( aPoints, nRealPointCount, aGridLinePoints, m_pPosHelper->getTransformationLogicToScene() );
nRealPointCount++;
}
aPoints.realloc(nRealPointCount);
@@ -263,35 +306,13 @@ void SAL_CALL VCartesianGrid::createShapes()
; aDepthIter != aDepthEnd && nDepth < nLinePropertiesCount
; aDepthIter++, nDepth++ )
{
+ GridLinePoints aGridLinePoints( m_pPosHelper, nDimensionIndex );
+
sal_Int32 nPointCount = (*aDepthIter).size();
drawing::PolyPolygonShape3D aPoints;
aPoints.SequenceX.realloc(nPointCount);
aPoints.SequenceY.realloc(nPointCount);
aPoints.SequenceZ.realloc(nPointCount);
- uno::Sequence< double > aLogicMinEdge, aLogicMaxEdge;
- m_pPosHelper->getLogicMinimum( aLogicMinEdge );
- m_pPosHelper->getLogicMaximum( aLogicMaxEdge );
-
- if(!m_pPosHelper->isMathematicalOrientationX())
- {
- double fHelp = aLogicMinEdge[0];
- aLogicMinEdge[0] = aLogicMaxEdge[0];
- aLogicMaxEdge[0] = fHelp;
- }
- if(!m_pPosHelper->isMathematicalOrientationY())
- {
- double fHelp = aLogicMinEdge[1];
- aLogicMinEdge[1] = aLogicMaxEdge[1];
- aLogicMaxEdge[1] = fHelp;
- }
- if(m_pPosHelper->isMathematicalOrientationZ())//z axis in draw is reverse to mathematical
- {
- double fHelp = aLogicMinEdge[2];
- aLogicMinEdge[2] = aLogicMaxEdge[2];
- aLogicMaxEdge[2] = fHelp;
- }
-
- GridLinePoints aGridLinePoints( aLogicMinEdge, aLogicMaxEdge );
::std::vector< TickInfo >::const_iterator aTickIter = (*aDepthIter).begin();
const ::std::vector< TickInfo >::const_iterator aTickEnd = (*aDepthIter).end();
diff --git a/chart2/source/view/axes/VPolarAxis.cxx b/chart2/source/view/axes/VPolarAxis.cxx
index 833a61518126..d8fbcd866134 100644
--- a/chart2/source/view/axes/VPolarAxis.cxx
+++ b/chart2/source/view/axes/VPolarAxis.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: VPolarAxis.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: iha $ $Date: 2004-01-17 13:09:58 $
+ * last change: $Author: iha $ $Date: 2004-01-22 19:20:35 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -60,6 +60,7 @@
************************************************************************/
#include "VPolarAxis.hxx"
#include "VPolarGrid.hxx"
+#include "VCartesianAxis.hxx"
#include "PlottingPositionHelper.hxx"
#include "ShapeFactory.hxx"
#include "CommonConverters.hxx"
@@ -113,6 +114,7 @@ VPolarAxis::VPolarAxis( const AxisProperties& rAxisProperties
, m_aAxisProperties( rAxisProperties )
, m_pNumberFormatterWrapper( pNumberFormatterWrapper )
, m_pPosHelper( new PolarPlottingPositionHelper(false) )
+ , m_aIncrements()
{
PlotterBase::m_pPosHelper = m_pPosHelper;
}
@@ -123,6 +125,11 @@ VPolarAxis::~VPolarAxis()
m_pPosHelper = NULL;
}
+void VPolarAxis::setIncrements( const uno::Sequence< ExplicitIncrementData >& rIncrements )
+{
+ m_aIncrements = rIncrements;
+}
+
bool createTextShapes_ForAngleAxis( const uno::Reference< lang::XMultiServiceFactory >& xShapeFactory
, const uno::Reference< drawing::XShapes >& xTarget
, ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos
@@ -171,20 +178,6 @@ bool createTextShapes_ForAngleAxis( const uno::Reference< lang::XMultiServiceFac
//if NO OVERLAP -> don't create labels where the
//anchor position is the same as for the last label
//@todo
- /*
- if( pLastVisibleNeighbourTickInfo && !rAxisLabelProperties.bOverlapAllowed )
- {
- if( lcl_doesOverlap( pLastVisibleNeighbourTickInfo->xTextShape, pTickInfo->nScreenTickValue, bOverlapCheckDirectionIsY ) )
- {
- if( rAxisLabelProperties.bRhythmIsFix )
- continue;
- rAxisLabelProperties.nRhythm++;
- TickIter aRemoveIter( rAllTickInfos, rIncrement, 0, 0 );
- removeShapesAtWrongRythm( aRemoveIter, rAxisLabelProperties.nRhythm, nTick, xTarget );
- return false;
- }
- }
- */
if(!pTickInfo->xTextShape.is())
{
@@ -212,25 +205,6 @@ bool createTextShapes_ForAngleAxis( const uno::Reference< lang::XMultiServiceFac
//if NO OVERLAP -> remove overlapping shapes
//@todo
- /*
- if( pLastVisibleNeighbourTickInfo && !rAxisLabelProperties.bOverlapAllowed )
- {
- if( doesOverlap( pLastVisibleNeighbourTickInfo->xTextShape, pTickInfo->xTextShape, bOverlapCheckDirectionIsY ) )
- {
- if( rAxisLabelProperties.bRhythmIsFix )
- {
- xTarget->remove(pTickInfo->xTextShape);
- pTickInfo->xTextShape = NULL;
- continue;
- }
- rAxisLabelProperties.nRhythm++;
- TickIter aRemoveIter( rAllTickInfos, rIncrement, 0, 0 );
- removeShapesAtWrongRythm( aRemoveIter, rAxisLabelProperties.nRhythm, nTick, xTarget );
- return false;
- }
- }
- */
- //pLastVisibleNeighbourTickInfo = pTickInfo;
}
return true;
}
@@ -272,49 +246,40 @@ void VPolarAxis::create2DAngleAxis( const uno::Reference< drawing::XShapes >& xT
void VPolarAxis::create2DRadiusAxis( const uno::Reference< drawing::XShapes >& xTarget, ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos )
{
- /*
- sal_Int32 nTickmarkPropertiesCount = m_aAxisProperties.m_aTickmarkPropertiesList.size();
- for( sal_Int32 nDepth=0
- ; aDepthIter != aDepthEnd && nDepth < nTickmarkPropertiesCount
- ; aDepthIter++, nDepth++ )
- {
- const TickmarkProperties& rTickmarkProperties = m_aAxisProperties.m_aTickmarkPropertiesList[nDepth];
-
- sal_Int32 nPointCount = (*aDepthIter).size();
- drawing::PointSequenceSequence aPoints(nPointCount);
+ const ExplicitScaleData& rAngleScale = m_pPosHelper->getScales()[0];
+ const ExplicitIncrementData& rAngleIncrement = m_aIncrements[0];
- ::std::vector< TickInfo >::const_iterator aTickIter = (*aDepthIter).begin();
- const ::std::vector< TickInfo >::const_iterator aTickEnd = (*aDepthIter).end();
- sal_Int32 nN = 0;
- for( ; aTickIter != aTickEnd; aTickIter++ )
- {
- if( !(*aTickIter).bPaintIt )
- continue;
- //addLine( aPoints, nN
- // , (*aTickIter).nScreenTickValue, nMainLineScreenPosition
- // , rTickmarkProperties, bIsRadiusAxis);
+ ::std::vector< ::std::vector< TickInfo > > aAngleTickInfos;
+ TickmarkHelper aAngleTickmarkHelper( rAngleScale, rAngleIncrement );
+ aAngleTickmarkHelper.getAllTicks( aAngleTickInfos );
- nN++;
- }
- aPoints.realloc(nN);
- m_pShapeFactory->createLine2D( xGroupShape_Shapes, aPoints
- , rTickmarkProperties.aLineProperties );
- }
-
- //-----------------------------------------
- //create all scaled tickmark values
- std::auto_ptr< TickmarkHelper > apTickmarkHelper( this->createTickmarkHelper() );
- ::std::vector< ::std::vector< TickInfo > > aAllTickInfos;
- apTickmarkHelper->getAllTicks( aAllTickInfos );
+ uno::Reference< XScaling > xInverseScaling( NULL );
+ if( rAngleScale.Scaling.is() )
+ xInverseScaling = rAngleScale.Scaling->getInverseScaling();
- //-----------------------------------------
- //create tick mark line shapes
- ::std::vector< ::std::vector< TickInfo > >::iterator aDepthIter = aAllTickInfos.begin();
- const ::std::vector< ::std::vector< TickInfo > >::const_iterator aDepthEnd = aAllTickInfos.end();
+ AxisProperties aAxisProperties(m_aAxisProperties);
+ aAxisProperties.m_fInnerDirectionSign=0.0;
+ aAxisProperties.m_bLabelsOutside=true;
+ aAxisProperties.m_bIsMainAxis=false;
+ aAxisProperties.m_aLabelAlignment=LABEL_ALIGN_RIGHT;
+ aAxisProperties.init();
- if(aDepthIter == aDepthEnd)//no tickmarks at all
- return;
- */
+ sal_Int32 nTick = 0;
+ TickIter aIter( aAngleTickInfos, rAngleIncrement, 0, 0 );
+ for( TickInfo* pTickInfo = aIter.firstInfo()
+ ; pTickInfo; pTickInfo = aIter.nextInfo(), nTick++ )
+ {
+ pTickInfo->updateUnscaledValue( xInverseScaling );
+ aAxisProperties.m_pfMainLinePositionAtOtherAxis = &pTickInfo->fUnscaledTickValue;
+ //-------------------
+ VCartesianAxis aAxis(aAxisProperties,m_pNumberFormatterWrapper
+ ,2,new PolarPlottingPositionHelper(false));
+ aAxis.setMeterData( m_aScale, m_aIncrement );
+ aAxis.init(m_xLogicTarget,m_xFinalTarget,m_xShapeFactory);
+ aAxis.setTransformationSceneToScreen( Matrix4DToHomogenMatrix( m_aMatrixScreenToScene ) );
+ aAxis.setScales( m_pPosHelper->getScales() );
+ aAxis.createShapes();
+ }
}
void SAL_CALL VPolarAxis::createShapes()
@@ -323,8 +288,6 @@ void SAL_CALL VPolarAxis::createShapes()
if(!(m_pShapeFactory&&m_xLogicTarget.is()&&m_xFinalTarget.is()))
return;
- m_aAxisProperties.init();
-
//-----------------------------------------
//create named group shape
uno::Reference< XIdentifiable > xIdent( m_aAxisProperties.m_xAxisModel, uno::UNO_QUERY );
@@ -348,10 +311,11 @@ void SAL_CALL VPolarAxis::createShapes()
if(2==m_nDimension)
{
sal_Int32 nDimensionIndex = m_xMeter->getRepresentedDimension();
- if(nDimensionIndex==1)
- this->create2DRadiusAxis( xGroupShape_Shapes, aAllTickInfos );
- else
+ if(nDimensionIndex==0)
this->create2DAngleAxis( xGroupShape_Shapes, aAllTickInfos );
+ else if(nDimensionIndex==1)
+ this->create2DRadiusAxis( xGroupShape_Shapes, aAllTickInfos );
+
}
}
diff --git a/chart2/source/view/axes/VPolarAxis.hxx b/chart2/source/view/axes/VPolarAxis.hxx
index 1ee108bf3c80..b4620415094f 100644
--- a/chart2/source/view/axes/VPolarAxis.hxx
+++ b/chart2/source/view/axes/VPolarAxis.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: VPolarAxis.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: iha $ $Date: 2004-01-17 13:09:58 $
+ * last change: $Author: iha $ $Date: 2004-01-22 19:20:35 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -82,11 +82,14 @@ class VPolarAxis : public VMeterBase
public:
VPolarAxis( const AxisProperties& rAxisProperties
, NumberFormatterWrapper* pNumberFormatterWrapper
- , sal_Int32 nDimensionCount=2 );
+ , sal_Int32 nDimensionCount );
virtual ~VPolarAxis();
virtual void SAL_CALL createShapes();
+ void setIncrements( const ::com::sun::star::uno::Sequence<
+ ::drafts::com::sun::star::chart2::ExplicitIncrementData >& rIncrements );
+
private: //methods
void create2DAngleAxis( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget, ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos );
void create2DRadiusAxis( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget, ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos );
@@ -95,6 +98,8 @@ private: //member
AxisProperties m_aAxisProperties;
NumberFormatterWrapper* m_pNumberFormatterWrapper;
PolarPlottingPositionHelper* m_pPosHelper;
+ ::com::sun::star::uno::Sequence<
+ ::drafts::com::sun::star::chart2::ExplicitIncrementData > m_aIncrements;
};
//.............................................................................
diff --git a/chart2/source/view/axes/VPolarCoordinateSystem.cxx b/chart2/source/view/axes/VPolarCoordinateSystem.cxx
index 2d749df6f47b..30f478e740a7 100644
--- a/chart2/source/view/axes/VPolarCoordinateSystem.cxx
+++ b/chart2/source/view/axes/VPolarCoordinateSystem.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: VPolarCoordinateSystem.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: iha $ $Date: 2004-01-19 14:41:01 $
+ * last change: $Author: iha $ $Date: 2004-01-22 19:20:35 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -89,7 +89,6 @@ void VPolarCoordinateSystem::createGridShapes()
{
VPolarGrid aGrid(rGridList[nN],nDimensionCount);
aGrid.setIncrements( m_aExplicitIncrements );
-
aGrid.init(m_xLogicTargetForGrids,m_xFinalTarget,m_xShapeFactory);
if(2==nDimensionCount)
aGrid.setTransformationSceneToScreen( m_aMatrixSceneToScreen );
@@ -111,14 +110,13 @@ void VPolarCoordinateSystem::createAxesShapes( const awt::Size& rReferenceSize,
uno::Reference< XAxis > xAxis = this->getAxisByDimension(nDim);
if(!xAxis.is())
continue;
- AxisProperties aAxisProperties;
- aAxisProperties.m_xAxisModel = xAxis;
- aAxisProperties.m_aReferenceSize = rReferenceSize;
+ AxisProperties aAxisProperties(xAxis,rReferenceSize);
aAxisProperties.init();
//-------------------
- VPolarAxis aAxis(aAxisProperties,pNumberFormatterWrapper);
+ VPolarAxis aAxis(aAxisProperties,pNumberFormatterWrapper,nDimensionCount);
aAxis.setMeterData( m_aExplicitScales[nDim], m_aExplicitIncrements[nDim] );
aAxis.init(m_xLogicTargetForAxes,m_xFinalTarget,m_xShapeFactory);
+ aAxis.setIncrements( m_aExplicitIncrements );
if(2==nDimensionCount)
aAxis.setTransformationSceneToScreen( m_aMatrixSceneToScreen );
aAxis.setScales( m_aExplicitScales );
diff --git a/chart2/source/view/axes/VPolarGrid.cxx b/chart2/source/view/axes/VPolarGrid.cxx
index ea0b104ca9a5..a18ad0da149f 100644
--- a/chart2/source/view/axes/VPolarGrid.cxx
+++ b/chart2/source/view/axes/VPolarGrid.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: VPolarGrid.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: iha $ $Date: 2004-01-17 13:09:59 $
+ * last change: $Author: iha $ $Date: 2004-01-22 19:20:35 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -87,6 +87,7 @@ using namespace ::drafts::com::sun::star::chart2;
VPolarGrid::VPolarGrid( const uno::Reference< XGrid >& xGrid, sal_Int32 nDimensionCount )
: VMeterBase( uno::Reference<XMeter>::query(xGrid), nDimensionCount )
, m_pPosHelper( new PolarPlottingPositionHelper(false) )
+ , m_aIncrements()
{
PlotterBase::m_pPosHelper = m_pPosHelper;
}
@@ -104,11 +105,8 @@ void VPolarGrid::setIncrements( const uno::Sequence< ExplicitIncrementData >& rI
void VPolarGrid::getAllTickInfos( sal_Int32 nDimensionIndex, ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const
{
- TickmarkHelper_2D aTickmarkHelper(
- m_pPosHelper->getScales()[nDimensionIndex], m_aIncrements[nDimensionIndex]
- , m_aMatrixScreenToScene[nDimensionIndex][nDimensionIndex]
- , m_aMatrixScreenToScene[nDimensionIndex][3]
- );
+ TickmarkHelper aTickmarkHelper(
+ m_pPosHelper->getScales()[nDimensionIndex], m_aIncrements[nDimensionIndex] );
aTickmarkHelper.getAllTicks( rAllTickInfos );
}
@@ -132,7 +130,7 @@ void VPolarGrid::createLinePointSequence_ForAngleAxis(
; pTickInfo = aIter.nextInfo(), nTick++ )
{
if(nTick>=rPoints[0].getLength())
- rPoints[0].realloc(rPoints.getLength()+30);
+ rPoints[0].realloc(rPoints[0].getLength()+30);
pTickInfo->updateUnscaledValue( xInverseScaling );
double fLogicAngle = pTickInfo->fUnscaledTickValue;
@@ -215,10 +213,11 @@ void VPolarGrid::create2DRadiusGrid( const uno::Reference< drawing::XShapes >& x
, const ::std::vector<VLineProperties>& rLinePropertiesList )
{
const ExplicitScaleData& rRadiusScale = m_pPosHelper->getScales()[1];
- const ExplicitIncrementData& rRadiusIncrement = m_aIncrements[1];
- uno::Reference< XScaling > xInverseScaling( NULL );
+ const ExplicitScaleData& rAngleScale = m_pPosHelper->getScales()[0];
+ const ExplicitIncrementData& rAngleIncrement = m_aIncrements[0];
+ uno::Reference< XScaling > xInverseRadiusScaling( NULL );
if( rRadiusScale.Scaling.is() )
- xInverseScaling = rRadiusScale.Scaling->getInverseScaling();
+ xInverseRadiusScaling = rRadiusScale.Scaling->getInverseScaling();
sal_Int32 nLinePropertiesCount = rLinePropertiesList.size();
::std::vector< ::std::vector< TickInfo > >::iterator aDepthIter = rRadiusTickInfos.begin();
@@ -238,13 +237,13 @@ void VPolarGrid::create2DRadiusGrid( const uno::Reference< drawing::XShapes >& x
if( !rTickInfo.bPaintIt )
continue;
- rTickInfo.updateUnscaledValue( xInverseScaling );
+ rTickInfo.updateUnscaledValue( xInverseRadiusScaling );
double fLogicRadius = rTickInfo.fUnscaledTickValue;
double fLogicZ = -0.5;//as defined
drawing::PointSequenceSequence aPoints(1);
VPolarGrid::createLinePointSequence_ForAngleAxis( aPoints, rAngleTickInfos
- , rRadiusIncrement, rRadiusScale, m_pPosHelper, fLogicRadius, fLogicZ );
+ , rAngleIncrement, rAngleScale, m_pPosHelper, fLogicRadius, fLogicZ );
appendPointSequence( aAllPoints, aPoints );
}
diff --git a/chart2/source/view/charttypes/AreaChart.cxx b/chart2/source/view/charttypes/AreaChart.cxx
index 3333fb9921c0..a72bacbdb321 100644
--- a/chart2/source/view/charttypes/AreaChart.cxx
+++ b/chart2/source/view/charttypes/AreaChart.cxx
@@ -10,6 +10,7 @@
#include "Splines.hxx"
#include "ChartTypeHelper.hxx"
#include "LabelPositionHelper.hxx"
+#include "Clipping.hxx"
#ifndef _DRAFTS_COM_SUN_STAR_CHART2_SYMBOL_HPP_
#include <drafts/com/sun/star/chart2/Symbol.hpp>
diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx
index 2c908cfaeae7..cc779debaa1f 100644
--- a/chart2/source/view/charttypes/VSeriesPlotter.cxx
+++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx
@@ -8,6 +8,7 @@
#include "StatisticsHelper.hxx"
#include "PlottingPositionHelper.hxx"
#include "LabelPositionHelper.hxx"
+#include "Clipping.hxx"
//only for creation: @todo remove if all plotter are uno components and instanciated via servicefactory
#include "BarChart.hxx"
diff --git a/chart2/source/view/inc/Clipping.hxx b/chart2/source/view/inc/Clipping.hxx
index 46f17108d02f..51484398e937 100644
--- a/chart2/source/view/inc/Clipping.hxx
+++ b/chart2/source/view/inc/Clipping.hxx
@@ -1,6 +1,8 @@
#ifndef _CHART2_CLIPPING_HXX
#define _CHART2_CLIPPING_HXX
+#include "DoubleRectangle.hxx"
+
#ifndef _COM_SUN_STAR_DRAWING_POLYPOLYGONSHAPE3D_HPP_
#include <com/sun/star/drawing/PolyPolygonShape3D.hpp>
#endif
@@ -14,28 +16,6 @@ namespace chart
/**
*/
-struct DoublePoint
-{
- DoublePoint(double fX, double fY) : X(fX), Y(fY) {};
- DoublePoint() : X(0.0), Y(0.0) {};
- DoublePoint operator-( const DoublePoint& rP );
-
- double X;
- double Y;
-};
-
-struct DoubleRectangle
-{
-public:
- DoubleRectangle( double fLeft, double fTop, double fRight, double fBottom );
- bool isInside( const DoublePoint& rPoint ) const;
-
- double Left;
- double Top;
- double Right;
- double Bottom;
-};
-
class Clipping
{
/** This class uses the Liang-Biarsky parametric line-clipping algorithm as described in:
diff --git a/chart2/source/view/inc/PlottingPositionHelper.hxx b/chart2/source/view/inc/PlottingPositionHelper.hxx
index 189b560aa68f..f619142d330d 100644
--- a/chart2/source/view/inc/PlottingPositionHelper.hxx
+++ b/chart2/source/view/inc/PlottingPositionHelper.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: PlottingPositionHelper.hxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: iha $ $Date: 2004-01-17 13:10:03 $
+ * last change: $Author: iha $ $Date: 2004-01-22 19:20:38 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -61,7 +61,7 @@
#ifndef _CHART2_PLOTTINGPOSITIONHELPER_HXX
#define _CHART2_PLOTTINGPOSITIONHELPER_HXX
-#include "Clipping.hxx"
+#include "DoubleRectangle.hxx"
#ifndef _DRAFTS_COM_SUN_STAR_CHART2_EXPLICITSCALEDATA_HPP_
#include <drafts/com/sun/star/chart2/ExplicitScaleData.hpp>
@@ -113,6 +113,9 @@ public:
virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XTransformation >
getTransformationLogicToScene() const;
+ virtual ::com::sun::star::drawing::Position3D
+ transformLogicToScene( double fX, double fY, double fZ, bool bClip ) const;
+
inline double getLogicMinX() const;
inline double getLogicMinY() const;
inline double getLogicMinZ() const;
@@ -124,12 +127,6 @@ public:
inline bool isMathematicalOrientationY() const;
inline bool isMathematicalOrientationZ() const;
- void getLogicMinimum( ::com::sun::star::uno::Sequence< double >& rSeq ) const;
- void getLogicMaximum( ::com::sun::star::uno::Sequence< double >& rSeq ) const;
-
- void getScreenValuesForMinimum( ::com::sun::star::uno::Sequence< double >& rSeq ) const;
- void getScreenValuesForMaximum( ::com::sun::star::uno::Sequence< double >& rSeq ) const;
-
Rectangle getTransformedClipRect() const;
DoubleRectangle getTransformedClipDoubleRect() const;
@@ -163,6 +160,8 @@ public:
double getWidthAngleDegree( double& fStartLogicValueOnAngleAxis, double& fEndLogicValueOnAngleAxis ) const;
//
+ virtual ::com::sun::star::drawing::Position3D
+ transformLogicToScene( double fX, double fY, double fZ, bool bClip ) const;
::com::sun::star::drawing::Position3D
transformLogicToScene( double fLogicValueOnAngleAxis, double fLogicValueOnRadiusAxis, double fLogicZ ) const;
diff --git a/chart2/source/view/main/Clipping.cxx b/chart2/source/view/main/Clipping.cxx
index 943824eefd50..4d6c2b1fced6 100644
--- a/chart2/source/view/main/Clipping.cxx
+++ b/chart2/source/view/main/Clipping.cxx
@@ -15,51 +15,6 @@ using namespace ::com::sun::star;
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
-DoublePoint DoublePoint::operator-( const DoublePoint& rP )
-{
- DoublePoint aRet;
- aRet.X = this->X - rP.X;
- aRet.Y = this->Y - rP.Y;
- return aRet;
-}
-
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-
-DoubleRectangle::DoubleRectangle( double fLeft, double fTop, double fRight, double fBottom )
- : Left(fLeft), Top(fTop), Right(fRight), Bottom(fBottom)
-{
- //values grow to right
- //and grow to bottom
- if(Left>Right)
- {
- Right = fLeft;
- Left = fRight;
- }
- if(Top>Bottom)
- {
- Bottom = fTop;
- Top = fBottom;
- }
-}
-bool DoubleRectangle::isInside( const DoublePoint& rP ) const
-{
- if(rP.X<Left)
- return false;
- if(rP.X>Right)
- return false;
- if(rP.Y<Bottom)
- return false;
- if(rP.Y>Top)
- return false;
- return true;
-}
-
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-
namespace{
/** @descr This is a supporting function for lcl_clip2d. It computes a new parametric
value for an entering (dTE) or leaving (dTL) intersection point with one
diff --git a/chart2/source/view/main/PlottingPositionHelper.cxx b/chart2/source/view/main/PlottingPositionHelper.cxx
index a4618748cc27..5a20be6d3bf1 100644
--- a/chart2/source/view/main/PlottingPositionHelper.cxx
+++ b/chart2/source/view/main/PlottingPositionHelper.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: PlottingPositionHelper.cxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: iha $ $Date: 2004-01-17 13:10:07 $
+ * last change: $Author: iha $ $Date: 2004-01-22 19:20:40 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -153,47 +153,19 @@ uno::Reference< XTransformation > PlottingPositionHelper::getTransformationLogic
return m_xTransformationLogicToScene;
}
-void PlottingPositionHelper::getScreenValuesForMinimum( uno::Sequence< double >& rSeq ) const
+drawing::Position3D PlottingPositionHelper::transformLogicToScene(
+ double fX, double fY, double fZ, bool bClip ) const
{
- double fX = this->getLogicMinX();
- double fY = this->getLogicMinY();
- double fZ = this->getLogicMinZ();
-
- this->doLogicScaling( &fX,&fY,&fZ );
- drawing::Position3D aPos( fX, fY, fZ);
-
- uno::Reference< XTransformation > xTransformation =
- this->getTransformationLogicToScene();
- rSeq = xTransformation->transform( Position3DToSequence(aPos) );
-}
-
-void PlottingPositionHelper::getScreenValuesForMaximum( uno::Sequence< double >& rSeq ) const
-{
- double fX = this->getLogicMaxX();
- double fY = this->getLogicMaxY();
- double fZ = this->getLogicMaxZ();
-
+ if(bClip)
+ this->clipLogicValues( &fX,&fY,&fZ );
this->doLogicScaling( &fX,&fY,&fZ );
drawing::Position3D aPos( fX, fY, fZ);
uno::Reference< XTransformation > xTransformation =
- this->getTransformationLogicToScene();
- rSeq = xTransformation->transform( Position3DToSequence(aPos) );
-}
-
-void PlottingPositionHelper::getLogicMinimum( ::com::sun::star::uno::Sequence< double >& rSeq ) const
-{
- rSeq.realloc(3);
- rSeq[0] = this->getLogicMinX();
- rSeq[1] = this->getLogicMinY();
- rSeq[2] = this->getLogicMinZ();
-}
-void PlottingPositionHelper::getLogicMaximum( ::com::sun::star::uno::Sequence< double >& rSeq ) const
-{
- rSeq.realloc(3);
- rSeq[0] = this->getLogicMaxX();
- rSeq[1] = this->getLogicMaxY();
- rSeq[2] = this->getLogicMaxZ();
+ this->getTransformationLogicToScene();
+ uno::Sequence< double > aSeq =
+ xTransformation->transform( Position3DToSequence(aPos) );
+ return SequenceToPosition3D(aSeq);
}
Rectangle PlottingPositionHelper::getTransformedClipRect() const
@@ -401,6 +373,15 @@ double PolarPlottingPositionHelper::transformToRadius( double fLogicValueOnRadiu
return fScaledLogicRadiusValue;
}
+drawing::Position3D PolarPlottingPositionHelper::transformLogicToScene( double fX, double fY, double fZ, bool bClip ) const
+{
+ if(bClip)
+ this->clipLogicValues( &fX,&fY,&fZ );
+ double fLogicValueOnAngleAxis = m_bRadiusAxisMapsToFirstDimension ? fY : fX;
+ double fLogicValueOnRadiusAxis = m_bRadiusAxisMapsToFirstDimension ? fX : fY;
+ return this->transformLogicToScene( fLogicValueOnAngleAxis, fLogicValueOnRadiusAxis, fZ );
+}
+
drawing::Position3D PolarPlottingPositionHelper::transformLogicToScene( double fLogicValueOnAngleAxis, double fLogicValueOnRadiusAxis, double fLogicZ ) const
{
double fAngleDegree = this->transformToAngleDegree(fLogicValueOnAngleAxis);
diff --git a/chart2/source/view/main/makefile.mk b/chart2/source/view/main/makefile.mk
index 87a890778997..e2bdc3eb6322 100644
--- a/chart2/source/view/main/makefile.mk
+++ b/chart2/source/view/main/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.6 $
+# $Revision: 1.7 $
#
-# last change: $Author: iha $ $Date: 2004-01-17 13:10:08 $
+# last change: $Author: iha $ $Date: 2004-01-22 19:20:40 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -75,6 +75,7 @@ ENABLE_EXCEPTIONS= TRUE
#object files to build and link together to lib $(SLB)$/$(TARGET).lib
SLOFILES = \
+ $(SLO)$/DoubleRectangle.obj \
$(SLO)$/NumberFormatterWrapper.obj \
$(SLO)$/ObjectIdentifier.obj \
$(SLO)$/PropertyMapper.obj \