chart2/source/controller/dialogs/tp_DataSource.cxx | 23 +++- chart2/source/controller/dialogs/tp_DataSource.hrc | 2 chart2/source/controller/dialogs/tp_DataSource.hxx | 7 + chart2/source/controller/dialogs/tp_DataSource.src | 16 ++- chart2/source/view/charttypes/BubbleChart.cxx | 9 + chart2/source/view/inc/VDataSeries.hxx | 7 + chart2/source/view/main/OpenGLRender.cxx | 99 +++++++++++++++++++++ chart2/source/view/main/OpenGLRender.hxx | 14 ++ chart2/source/view/main/VDataSeries.cxx | 27 +++++ 9 files changed, 190 insertions(+), 14 deletions(-)
New commits: commit b9970db1ca75a5f06a4d32fdb92f17927b63ea25 Author: Markus Mohrhard <[email protected]> Date: Sat Jan 4 08:16:08 2014 +0100 first step for mapped properties Only FillColor in bubble charts is supported right now. Change-Id: If6ad0220c15e06a9a57c554f6243fd9908b2651b diff --git a/chart2/source/controller/dialogs/tp_DataSource.cxx b/chart2/source/controller/dialogs/tp_DataSource.cxx index c0232ae..87cd872 100644 --- a/chart2/source/controller/dialogs/tp_DataSource.cxx +++ b/chart2/source/controller/dialogs/tp_DataSource.cxx @@ -212,13 +212,10 @@ void lcl_increaseHeightOfControl( Control & rControl, long nYOffset ) namespace chart { -DataSourceTabPage::DataSourceTabPage( - Window * pParent, - DialogModel & rDialogModel, - ChartTypeTemplateProvider* pTemplateProvider, - Dialog * pParentDialog, - bool bHideDescription /* = false */ ) : - ::svt::OWizardPage( pParent, SchResId( TP_DATA_SOURCE )), +DataSourceTabPage::DataSourceTabPage( Window * pParent, + DialogModel & rDialogModel, ChartTypeTemplateProvider* pTemplateProvider, + Dialog * pParentDialog, bool bHideDescription /* = false */ ) : + ::svt::OWizardPage( pParent, SchResId( TP_DATA_SOURCE )), m_aFT_CAPTION ( this, SchResId( FT_CAPTION_FOR_WIZARD )), m_aFT_SERIES ( this, SchResId( FT_SERIES )), @@ -236,6 +233,7 @@ DataSourceTabPage::DataSourceTabPage( m_aFT_DATALABELS ( this, SchResId( FT_DATALABELS )), m_aEDT_CATEGORIES ( this, SchResId( EDT_CATEGORIES )), m_aIMB_RANGE_CAT ( this, SchResId( IMB_RANGE_CAT )), + m_aBtn_AddMapping ( this, SchResId( BTN_ADDMAPPING )), m_pTemplateProvider( pTemplateProvider ), m_rDialogModel( rDialogModel ), @@ -319,6 +317,9 @@ DataSourceTabPage::DataSourceTabPage( m_aEDT_RANGE.SetStyle( m_aEDT_RANGE.GetStyle() | WB_FORCECTRLBACKGROUND ); m_aEDT_CATEGORIES.SetStyle( m_aEDT_CATEGORIES.GetStyle() | WB_FORCECTRLBACKGROUND ); + // mapped properties + m_aBtn_AddMapping.SetClickHdl( LINK( this, DataSourceTabPage, AddMappingHdl )); + // set symbol font for arrows // note: StarSymbol is substituted to OpenSymbol for OOo Font aSymbolFont( m_aBTN_UP.GetFont()); @@ -824,6 +825,14 @@ IMPL_LINK( DataSourceTabPage, RangeUpdateDataHdl, Edit*, pEdit ) return 0; } +IMPL_LINK_NOARG( DataSourceTabPage, AddMappingHdl ) +{ + OUString aNewMappingName = "FillColor"; + m_aLB_ROLE.InsertEntry( lcl_GetRoleLBEntry( aNewMappingName, OUString())); + + return 0; +} + void DataSourceTabPage::listeningFinished( const OUString & rNewRange ) { diff --git a/chart2/source/controller/dialogs/tp_DataSource.hrc b/chart2/source/controller/dialogs/tp_DataSource.hrc index 2ac81ce..83f70af 100644 --- a/chart2/source/controller/dialogs/tp_DataSource.hrc +++ b/chart2/source/controller/dialogs/tp_DataSource.hrc @@ -41,4 +41,6 @@ #define BTN_UP 140 #define BTN_DOWN 150 +#define BTN_ADDMAPPING 160 + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/dialogs/tp_DataSource.hxx b/chart2/source/controller/dialogs/tp_DataSource.hxx index bb74276..6324b49 100644 --- a/chart2/source/controller/dialogs/tp_DataSource.hxx +++ b/chart2/source/controller/dialogs/tp_DataSource.hxx @@ -90,6 +90,7 @@ protected: DECL_LINK( RangeUpdateDataHdl, Edit* ); DECL_LINK( UpButtonClickedHdl, void* ); DECL_LINK( DownButtonClickedHdl, void* ); + DECL_LINK( AddMappingHdl, void* ); // ____ RangeSelectionListenerParent ____ virtual void listeningFinished( const OUString & rNewRange ); @@ -110,8 +111,8 @@ protected: ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XRangeSelectionListener > getSelectionRangeListener(); - /** @return </sal_True>, if the edit field contains a valid range entry. if no - XCellRangesAccess can be obtained, </sal_True> is returned. + /** @return </sal_True>, if the edit field contains a valid range entry. If no + XCellRangesAccess can be obtained, </sal_False> is returned. */ bool isRangeFieldContentValid( Edit & rEdit ); @@ -145,6 +146,8 @@ private: RangeEdit m_aEDT_CATEGORIES; RangeSelectionButton m_aIMB_RANGE_CAT; + PushButton m_aBtn_AddMapping; + OUString m_aFixedTextRange; ChartTypeTemplateProvider * m_pTemplateProvider; diff --git a/chart2/source/controller/dialogs/tp_DataSource.src b/chart2/source/controller/dialogs/tp_DataSource.src index da12954..008b4ab5 100644 --- a/chart2/source/controller/dialogs/tp_DataSource.src +++ b/chart2/source/controller/dialogs/tp_DataSource.src @@ -97,7 +97,7 @@ TabPage TP_DATA_SOURCE FixedText FT_CATEGORIES { - Pos = MAP_APPFONT ( 82 , 107 ); + Pos = MAP_APPFONT ( 82 , 104 ); Size = MAP_APPFONT ( 160 , 8 ); Text [ en-US ] = "~Categories"; @@ -105,7 +105,7 @@ TabPage TP_DATA_SOURCE FixedText FT_DATALABELS { - Pos = MAP_APPFONT ( 82 , 107 ); + Pos = MAP_APPFONT ( 82 , 104 ); Size = MAP_APPFONT ( 160 , 8 ); Text [ en-US ] = "Data ~labels" ; @@ -116,14 +116,14 @@ TabPage TP_DATA_SOURCE HelpID = "chart2:Edit:TP_DATA_SOURCE:EDT_CATEGORIES"; Border = TRUE; TabStop = TRUE; - Pos = MAP_APPFONT ( 82 , 117 ); + Pos = MAP_APPFONT ( 82 , 114 ); Size = MAP_APPFONT ( 144 , 12 ); }; ImageButton IMB_RANGE_CAT { HelpID = "chart2:ImageButton:TP_DATA_SOURCE:IMB_RANGE_CAT"; TabStop = TRUE; - Pos = MAP_APPFONT ( 228 , 116 ); + Pos = MAP_APPFONT ( 228 , 113 ); Size = MAP_APPFONT ( 14 , 14 ); }; @@ -169,6 +169,14 @@ TabPage TP_DATA_SOURCE Pos = MAP_APPFONT ( 64 , 121 ); Size = MAP_APPFONT ( 14 , 14 ); }; + PushButton BTN_ADDMAPPING + { + TabStop = TRUE; + Pos = MAP_APPFONT( 82, 130 ); + Size = MAP_APPFONT( 54, 14 ); + + Text [ en-US ] = "Add property mapping"; + }; }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/view/charttypes/BubbleChart.cxx b/chart2/source/view/charttypes/BubbleChart.cxx index 1db4d83..a2e5dca 100644 --- a/chart2/source/view/charttypes/BubbleChart.cxx +++ b/chart2/source/view/charttypes/BubbleChart.cxx @@ -248,6 +248,8 @@ void BubbleChart::createShapes() if(!pSeries) continue; + bool bHasFillColorMapping = pSeries->hasPropertyMapping("FillColor"); + uno::Reference< drawing::XShapes > xSeriesGroupShape_Shapes = getSeriesGroupShape(*aSeriesIter, xSeriesTarget); sal_Int32 nAttachedAxisIndex = pSeries->getAttachedAxisIndex(); @@ -319,6 +321,13 @@ void BubbleChart::createShapes() , pSeries->getPropertiesOfPoint( nIndex ) , PropertyMapper::getPropertyNameMapForFilledSeriesProperties() ); + if(bHasFillColorMapping) + { + uno::Reference< beans::XPropertySet > xProps( xShape, uno::UNO_QUERY_THROW ); + xProps->setPropertyValue("FillColor", uno::makeAny(static_cast<sal_Int32>( + pSeries->getValueByProperty(nIndex, "FillColor")))); + } + m_pShapeFactory->setShapeName( xShape, "MarkHandles" ); //create data point label diff --git a/chart2/source/view/inc/VDataSeries.hxx b/chart2/source/view/inc/VDataSeries.hxx index 7989b3e..ab48afe 100644 --- a/chart2/source/view/inc/VDataSeries.hxx +++ b/chart2/source/view/inc/VDataSeries.hxx @@ -36,6 +36,7 @@ #include <vector> #include <boost/noncopyable.hpp> #include <boost/scoped_ptr.hpp> +#include <boost/ptr_container/ptr_map.hpp> namespace chart { @@ -93,6 +94,10 @@ public: double getMinimumofAllDifferentYValues( sal_Int32 index ) const; double getMaximumofAllDifferentYValues( sal_Int32 index ) const; + double getValueByProperty( sal_Int32 index, const OUString& rPropName ) const; + + bool hasPropertyMapping( const OUString& rPropName ) const; + ::com::sun::star::uno::Sequence< double > getAllX() const; ::com::sun::star::uno::Sequence< double > getAllY() const; @@ -214,6 +219,8 @@ private: //member VDataSequence* m_pValueSequenceForDataLabelNumberFormatDetection; + boost::ptr_map<OUString, VDataSequence> maPropertyMap; + mutable double m_fXMeanValue; mutable double m_fYMeanValue; diff --git a/chart2/source/view/main/VDataSeries.cxx b/chart2/source/view/main/VDataSeries.cxx index 52b510f..dad92a8 100644 --- a/chart2/source/view/main/VDataSeries.cxx +++ b/chart2/source/view/main/VDataSeries.cxx @@ -226,6 +226,12 @@ VDataSeries::VDataSeries( const uno::Reference< XDataSeries >& xDataSeries ) m_aValues_Y_Last.init( xDataSequence ); else if (aRole == "values-size") m_aValues_Bubble_Size.init( xDataSequence ); + else + { + VDataSequence* pSequence = new VDataSequence(); + pSequence->init( xDataSequence ); + maPropertyMap.insert(aRole, pSequence); + } } catch( const uno::Exception& e ) { @@ -1082,6 +1088,27 @@ VDataSeries* VDataSeries::createCopyForTimeBased() const return pNew; } +double VDataSeries::getValueByProperty( sal_Int32 nIndex, const OUString& rPropName ) const +{ + boost::ptr_map<OUString, VDataSequence>::const_iterator itr = + maPropertyMap.find(rPropName); + if(itr == maPropertyMap.end()) + { + double fNan; + ::rtl::math::setNan( & fNan ); + return fNan; + } + + // TODO:moggi handle time based charting + const VDataSequence* pData = itr->second; + return pData->getValue(nIndex); +} + +bool VDataSeries::hasPropertyMapping(const OUString& rPropName ) const +{ + return maPropertyMap.find(rPropName) != maPropertyMap.end(); +} + } //namespace chart /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit ea624e22884d07717bd6cf147b2c5e4bf183058e Author: Peilin <[email protected]> Date: Fri Jan 3 17:30:42 2014 +0800 add GL area rendering Change-Id: Ide31ee7d32b417138de9d66f8f566d1027060222 diff --git a/chart2/source/view/main/OpenGLRender.cxx b/chart2/source/view/main/OpenGLRender.cxx index 2d5f209..5d5b2cc 100644 --- a/chart2/source/view/main/OpenGLRender.cxx +++ b/chart2/source/view/main/OpenGLRender.cxx @@ -1520,5 +1520,104 @@ int OpenGLRender::CreateBMPHeaderRGBA(sal_uInt8 *bmpHeader, int xsize, int ysize return 0; } +int OpenGLRender::ProcessArea2D(uno::Reference< drawing::XShape > &xShape) +{ + //get point from shape + uno::Reference< beans::XPropertySet > xProp( xShape, uno::UNO_QUERY ); + com::sun::star::uno::Sequence<drawing::PointSequence> pointss; + com::sun::star::uno::Any value = xProp->getPropertyValue(UNO_NAME_POLYPOLYGON); + value >>= pointss; + int pointsscount = pointss.getLength(); + + uno::Any co = xProp->getPropertyValue(UNO_NAME_FILLCOLOR); + long *colorvalue = (long*)co.getValue(); + SetColor(*colorvalue); + for(int i = 0; i < pointsscount; i++) + { + com::sun::star::uno::Sequence<com::sun::star::awt::Point> points = pointss[i]; + int pointscount = points.getLength(); + for(int j = 0; j < pointscount; j++) + { + com::sun::star::awt::Point p = points[j]; + SetArea2DShapePoint((float)p.X, (float)p.Y, pointscount); + } + } + //render the shape + RenderArea2DShape(); + m_fZStep += 0.01f; + return 0; +} +int OpenGLRender::SetArea2DShapePoint(float x, float y, int listLength) +{ + if (!m_Area2DPointList.pointBuf) + { + //a new point buffer should be alloc, we should push the old buffer first + m_Area2DPointList.bufLen = listLength * sizeof(float) * 3; + m_Area2DPointList.pointBuf = (float *)malloc(m_Area2DPointList.bufLen); + } + float actualX = (x / OPENGL_SCALE_VALUE) - ((float)m_iWidth / 2); + float actualY = (y / OPENGL_SCALE_VALUE) - ((float)m_iHeight / 2); + m_Area2DPointList.pointBuf[m_iPointNum++] = actualX; + m_Area2DPointList.pointBuf[m_iPointNum++] = actualY; + m_Area2DPointList.pointBuf[m_iPointNum++] = m_fZStep; + m_fPicLeft = actualX < m_fPicLeft ? actualX : m_fPicLeft; + + m_fPicRight = actualX > m_fPicRight ? actualX : m_fPicRight; + + m_fPicBottom = actualY < m_fPicBottom ? actualY : m_fPicBottom; + + m_fPicTop = actualY > m_fPicTop ? actualY : m_fPicTop; + + if (m_iPointNum == (listLength * 3)) + { + m_Area2DShapePointList.push_back(m_Area2DPointList); + m_Area2DPointList.pointBuf = NULL; + m_iPointNum = 0; + } + return 0; +} +int OpenGLRender::RenderArea2DShape() +{ + glDisable(GL_MULTISAMPLE); + int listNum = m_Area2DShapePointList.size(); + cout << "listNum = " << listNum << endl; + PosVecf3 trans = {0.0f, 0.0f, 0.0f}; + PosVecf3 angle = {0.0f, 0.0f, 0.0f}; + PosVecf3 scale = {1.0f, 1.0f, 1.0f}; + MoveModelf(trans, angle, scale); + m_MVP = m_Projection * m_View * m_Model; + for (int i = 0; i < listNum; i++) + { + Area2DPointList &pointList = m_Area2DShapePointList.front(); + //fill vertex buffer + glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer); + glBufferData(GL_ARRAY_BUFFER, pointList.bufLen, pointList.pointBuf, GL_STATIC_DRAW); + // Use our shader + glUseProgram(m_CommonProID); + + glUniform4fv(m_2DColorID, 1, &m_2DColor[0]); + + glUniformMatrix4fv(m_MatrixID, 1, GL_FALSE, &m_MVP[0][0]); + + // 1rst attribute buffer : vertices + glEnableVertexAttribArray(m_2DVertexID); + glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer); + glVertexAttribPointer( + m_2DVertexID, // attribute. No particular reason for 0, but must match the layout in the shader. + 3, // size + GL_FLOAT, // type + GL_FALSE, // normalized? + 0, // stride + (void*)0 // array buffer offset + ); + glDrawArrays(GL_POLYGON, 0, pointList.bufLen / sizeof(float) / 3); // 12*3 indices starting at 0 -> 12 triangles + glDisableVertexAttribArray(m_2DVertexID); + glUseProgram(0); + m_Area2DShapePointList.pop_front(); + free(pointList.pointBuf); + } + glEnable(GL_MULTISAMPLE); + return 0; +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/view/main/OpenGLRender.hxx b/chart2/source/view/main/OpenGLRender.hxx index ce353b7..88adfe9 100644 --- a/chart2/source/view/main/OpenGLRender.hxx +++ b/chart2/source/view/main/OpenGLRender.hxx @@ -109,7 +109,11 @@ typedef struct TextInfo double rotation; float vertex[8]; }TextInfo; - +typedef struct Area2DPointList +{ + float *pointBuf; + int bufLen; +}Area2DPointList; /// Holds the information of our new child window struct GLWindow { @@ -179,6 +183,11 @@ public: int CreateTextTexture(::rtl::OUString textValue, sal_uInt32 color, const Font& rFont, awt::Point aPos, awt::Size aSize, long rotation); int RenderTextShape(); + + int SetArea2DShapePoint(float x, float y, int listLength); + int ProcessArea2D(com::sun::star::uno::Reference< + com::sun::star::drawing::XShape > &xShape); + int RenderArea2DShape(); private: GLint LoadShaders(const char *vertexShader,const char *fragmentShader); int CreateTextureObj(int width, int height); @@ -317,6 +326,9 @@ private: GLuint m_TextTexCoordBuf; GLint m_TextTexID; + Area2DPointList m_Area2DPointList; + list <Area2DPointList> m_Area2DShapePointList; + }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
