1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 #ifndef _CHART2_VCOORDINATESYSTEM_HXX 24 #define _CHART2_VCOORDINATESYSTEM_HXX 25 26 #include "MinimumAndMaximumSupplier.hxx" 27 #include "ScaleAutomatism.hxx" 28 #include "ThreeDHelper.hxx" 29 #include "ExplicitCategoriesProvider.hxx" 30 #include "chartview/ExplicitScaleValues.hxx" 31 32 #include <com/sun/star/chart2/XCoordinateSystem.hpp> 33 #include "comphelper/implementationreference.hxx" 34 #include <com/sun/star/awt/Rectangle.hpp> 35 #include <com/sun/star/drawing/HomogenMatrix.hpp> 36 #include <com/sun/star/drawing/XShapes.hpp> 37 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 38 #include <com/sun/star/util/XNumberFormatsSupplier.hpp> 39 40 #include<map> 41 #include <vector> 42 #include <boost/shared_ptr.hpp> 43 44 //............................................................................. 45 namespace chart 46 { 47 //............................................................................. 48 49 //----------------------------------------------------------------------------- 50 /** 51 */ 52 class VAxisBase; 53 class VCoordinateSystem 54 { 55 public: 56 virtual ~VCoordinateSystem(); 57 58 static VCoordinateSystem* createCoordinateSystem( const ::com::sun::star::uno::Reference< 59 ::com::sun::star::chart2::XCoordinateSystem >& xCooSysModel ); 60 61 virtual void initPlottingTargets( 62 const ::com::sun::star::uno::Reference< 63 ::com::sun::star::drawing::XShapes >& xLogicTarget 64 , const ::com::sun::star::uno::Reference< 65 ::com::sun::star::drawing::XShapes >& xFinalTarget 66 , const ::com::sun::star::uno::Reference< 67 ::com::sun::star::lang::XMultiServiceFactory >& xFactory 68 , ::com::sun::star::uno::Reference< 69 ::com::sun::star::drawing::XShapes >& xLogicTargetForSeriesBehindAxis ) 70 throw (::com::sun::star::uno::RuntimeException); 71 72 void setParticle( const rtl::OUString& rCooSysParticle ); 73 74 virtual void setTransformationSceneToScreen( const ::com::sun::star::drawing::HomogenMatrix& rMatrix ); 75 ::com::sun::star::drawing::HomogenMatrix getTransformationSceneToScreen(); 76 77 //better performance for big data 78 virtual ::com::sun::star::uno::Sequence< sal_Int32 > getCoordinateSystemResolution( const ::com::sun::star::awt::Size& rPageSize 79 , const ::com::sun::star::awt::Size& rPageResolution ); 80 81 ExplicitScaleData getExplicitScale( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const; 82 ExplicitIncrementData getExplicitIncrement( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const; 83 84 void setExplicitCategoriesProvider( ExplicitCategoriesProvider* /*takes ownership*/ ); 85 ExplicitCategoriesProvider* getExplicitCategoriesProvider(); 86 87 // returns a coplete scale set for a given dimension and index; for example if nDimensionIndex==1 and nAxisIndex==2 you get returned the secondary x axis, main y axis and main z axis 88 ::std::vector< ExplicitScaleData > getExplicitScales( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const; 89 // returns a coplete increment set for a given dimension and index; for example if nDimensionIndex==1 and nAxisIndex==2 you get returned the secondary x axis, main y axis and main z axis 90 ::std::vector< ExplicitIncrementData > getExplicitIncrements( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const; 91 92 void addMinimumAndMaximumSupplier( MinimumAndMaximumSupplier* pMinimumAndMaximumSupplier ); 93 bool hasMinimumAndMaximumSupplier( MinimumAndMaximumSupplier* pMinimumAndMaximumSupplier ); 94 void clearMinimumAndMaximumSupplierList(); 95 96 void prepareScaleAutomatismForDimensionAndIndex( ScaleAutomatism& rScaleAutomatism, sal_Int32 nDimIndex, sal_Int32 nAxisIndex ); 97 98 void setExplicitScaleAndIncrement( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex 99 , const ExplicitScaleData& rExplicitScale 100 , const ExplicitIncrementData& rExplicitIncrement ); 101 102 void set3DWallPositions( CuboidPlanePosition eLeftWallPos, CuboidPlanePosition eBackWallPos, CuboidPlanePosition eBottomPos ); 103 104 ::com::sun::star::uno::Reference< 105 ::com::sun::star::chart2::XCoordinateSystem > 106 getModel() const; 107 108 virtual void createVAxisList( 109 const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > & xNumberFormatsSupplier 110 , const ::com::sun::star::awt::Size& rFontReferenceSize 111 , const ::com::sun::star::awt::Rectangle& rMaximumSpaceForLabels ); 112 113 virtual void initVAxisInList(); 114 virtual void updateScalesAndIncrementsOnAxes(); 115 116 virtual void createMaximumAxesLabels(); 117 virtual void createAxesLabels(); 118 virtual void updatePositions(); 119 virtual void createAxesShapes(); 120 121 virtual void createGridShapes(); 122 123 virtual bool getPropertySwapXAndYAxis() const; 124 125 sal_Int32 getMaximumAxisIndexByDimension( sal_Int32 nDimensionIndex ) const; 126 127 virtual bool needSeriesNamesForAxis() const; 128 void setSeriesNamesForAxis( const ::com::sun::star::uno::Sequence< rtl::OUString >& rSeriesNames ); 129 130 protected: //methods 131 VCoordinateSystem( const ::com::sun::star::uno::Reference< 132 ::com::sun::star::chart2::XCoordinateSystem >& xCooSys ); 133 134 ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis > 135 getAxisByDimension( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const; 136 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > > 137 getGridListFromAxis( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >& xAxis ); 138 139 VAxisBase* getVAxis( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ); 140 141 rtl::OUString createCIDForAxis( const ::com::sun::star::uno::Reference< 142 ::com::sun::star::chart2::XAxis >& xAxis 143 , sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ); 144 rtl::OUString createCIDForGrid( const ::com::sun::star::uno::Reference< 145 ::com::sun::star::chart2::XAxis >& xAxis 146 , sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ); 147 148 sal_Int32 getNumberFormatKeyForAxis( const ::com::sun::star::uno::Reference< 149 ::com::sun::star::chart2::XAxis >& xAxis 150 , const ::com::sun::star::uno::Reference< 151 ::com::sun::star::util::XNumberFormatsSupplier >& xNumberFormatsSupplier ); 152 153 private: //methods 154 void impl_adjustDimension( sal_Int32& rDimensionIndex ) const; 155 void impl_adjustDimensionAndIndex( sal_Int32& rDimensionIndex, sal_Int32& rAxisIndex ) const; 156 157 protected: //member 158 ::com::sun::star::uno::Reference< 159 ::com::sun::star::chart2::XCoordinateSystem > m_xCooSysModel; 160 161 rtl::OUString m_aCooSysParticle; 162 163 typedef std::pair< sal_Int32, sal_Int32 > tFullAxisIndex; //first index is the dimension, second index is the axis index that indicates whether this is a main or secondary axis 164 165 // 166 ::com::sun::star::uno::Reference< 167 ::com::sun::star::drawing::XShapes > m_xLogicTargetForGrids; 168 ::com::sun::star::uno::Reference< 169 ::com::sun::star::drawing::XShapes > m_xLogicTargetForAxes; 170 ::com::sun::star::uno::Reference< 171 ::com::sun::star::drawing::XShapes > m_xFinalTarget; 172 ::com::sun::star::uno::Reference< 173 ::com::sun::star::lang::XMultiServiceFactory> m_xShapeFactory; 174 ::com::sun::star::drawing::HomogenMatrix m_aMatrixSceneToScreen; 175 176 CuboidPlanePosition m_eLeftWallPos; 177 CuboidPlanePosition m_eBackWallPos; 178 CuboidPlanePosition m_eBottomPos; 179 180 // 181 MergedMinimumAndMaximumSupplier m_aMergedMinimumAndMaximumSupplier; //this is used only for autoscaling purpose 182 183 ::com::sun::star::uno::Sequence< rtl::OUString > m_aSeriesNamesForZAxis; 184 185 typedef std::map< tFullAxisIndex, ::boost::shared_ptr< VAxisBase > > tVAxisMap; 186 187 tVAxisMap m_aAxisMap; 188 189 private: 190 std::vector< ExplicitScaleData > m_aExplicitScales; 191 std::vector< ExplicitIncrementData > m_aExplicitIncrements; 192 193 typedef std::map< tFullAxisIndex, ExplicitScaleData > tFullExplicitScaleMap; 194 typedef std::map< tFullAxisIndex, ExplicitIncrementData > tFullExplicitIncrementMap; 195 196 tFullExplicitScaleMap m_aSecondaryExplicitScales; 197 tFullExplicitIncrementMap m_aSecondaryExplicitIncrements; 198 199 ::std::auto_ptr< ExplicitCategoriesProvider > m_apExplicitCategoriesProvider; 200 }; 201 202 //............................................................................. 203 } //namespace chart 204 //............................................................................. 205 #endif 206