LCOV - code coverage report
Current view: top level - chart2/source/view/charttypes - GL3DBarChart.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 35 0.0 %
Date: 2014-04-11 Functions: 0 4 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  */
       9             : 
      10             : #include <GL3DBarChart.hxx>
      11             : 
      12             : #include <GL/glew.h>
      13             : 
      14             : #include <glm/glm.hpp>
      15             : #include <glm/gtx/transform.hpp>
      16             : 
      17             : #include "3DChartObjects.hxx"
      18             : 
      19             : namespace chart {
      20             : 
      21           0 : GL3DBarChart::GL3DBarChart(const std::vector<VDataSeries*>& rDataSeries):
      22             :     maDataSeries(rDataSeries),
      23           0 :     mxContext(new opengl3D::temporary::TemporaryContext())
      24             : {
      25           0 : }
      26             : 
      27           0 : GL3DBarChart::~GL3DBarChart()
      28             : {
      29           0 : }
      30             : 
      31           0 : void GL3DBarChart::create3DShapes()
      32             : {
      33           0 :     const float nBarSizeX = 10;
      34           0 :     const float nBarSizeY = 10;
      35           0 :     const float nBarDistanceX = nBarSizeX / 2;
      36           0 :     const float nBarDistanceY = nBarSizeY / 2;
      37             : 
      38           0 :     maShapes.clear();
      39           0 :     maShapes.push_back(new opengl3D::Camera());
      40           0 :     sal_Int32 nSeriesIndex = 0;
      41           0 :     sal_uInt32 nId = 1;
      42           0 :     for(std::vector<VDataSeries*>::const_iterator itr = maDataSeries.begin(),
      43           0 :             itrEnd = maDataSeries.end(); itr != itrEnd; ++itr)
      44             :     {
      45           0 :         VDataSeries* pDataSeries = *itr;
      46           0 :         sal_Int32 nPointCount = pDataSeries->getTotalPointCount();
      47           0 :         for(sal_Int32 nIndex = 0; nIndex < nPointCount; ++nIndex)
      48             :         {
      49           0 :             float nVal = pDataSeries->getYValue(nIndex);
      50           0 :             float nXPos = nIndex * (nBarSizeX + nBarDistanceX);
      51           0 :             float nYPos = nSeriesIndex * (nBarSizeY + nBarDistanceY);
      52             : 
      53           0 :             glm::mat4 aBarPosition;
      54           0 :             glm::scale(aBarPosition, nBarSizeX, nBarSizeY, nVal);
      55           0 :             glm::translate(aBarPosition, nXPos, nYPos, nVal/2);
      56             : 
      57           0 :             maShapes.push_back(new opengl3D::Bar(aBarPosition, nId++));
      58             :         }
      59             : 
      60           0 :         ++nSeriesIndex;
      61             :     }
      62           0 : }
      63             : 
      64           0 : void GL3DBarChart::render()
      65             : {
      66           0 :     mxContext->init();
      67           0 :     for(boost::ptr_vector<opengl3D::Renderable3DObject>::iterator itr = maShapes.begin(),
      68           0 :             itrEnd = maShapes.end(); itr != itrEnd; ++itr)
      69             :     {
      70           0 :         itr->render();
      71             :     }
      72           0 :     mxContext->render();
      73           0 : }
      74             : 
      75             : }
      76             : 
      77             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10