LCOV - code coverage report
Current view: top level - chart2/source/view/inc - GL3DBarChart.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 1 0.0 %
Date: 2014-11-03 Functions: 0 2 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             : #ifndef INCLUDED_CHART2_SOURCE_VIEW_INC_GL3DBARCHART_HXX
      11             : #define INCLUDED_CHART2_SOURCE_VIEW_INC_GL3DBARCHART_HXX
      12             : 
      13             : #include <GL3DPlotterBase.hxx>
      14             : 
      15             : #include <vector>
      16             : #include <boost/ptr_container/ptr_vector.hpp>
      17             : #include "VDataSeries.hxx"
      18             : 
      19             : #include <glm/glm.hpp>
      20             : 
      21             : #include <vcl/timer.hxx>
      22             : #include <vcl/openglwin.hxx>
      23             : 
      24             : #include <rtl/ref.hxx>
      25             : #include <salhelper/thread.hxx>
      26             : #include <osl/conditn.hxx>
      27             : 
      28             : namespace chart {
      29             : 
      30             : class ExplicitCategoriesProvider;
      31             : 
      32             : namespace opengl3D {
      33             : 
      34             : class Renderable3DObject;
      35             : class OpenGL3DRenderer;
      36             : class TextCache;
      37             : class Camera;
      38             : 
      39             : }
      40             : 
      41             : enum RenderEventType
      42             : {
      43             :     EVENT_NONE,
      44             :     EVENT_CLICK,
      45             :     EVENT_MOVE_TO_DEFAULT,
      46             :     EVENT_DRAG_LEFT,
      47             :     EVENT_DRAG_RIGHT,
      48             :     EVENT_SCROLL,
      49             :     EVENT_SHOW_SCROLL,
      50             :     EVENT_SHOW_SELECT,
      51             :     EVENT_AUTO_FLY,
      52             :     EVENT_DIE,
      53             :     EVENT_SELECTBAR_UPDEDATE
      54             : };
      55             : 
      56             : class RenderThread;
      57             : class RenderOneFrameThread;
      58             : class RenderAnimationThread;
      59             : 
      60             : class GL3DBarChart : public GL3DPlotterBase, public IRenderer
      61             : {
      62             :     friend class RenderThread;
      63             :     friend class RenderOneFrameThread;
      64             :     friend class RenderAnimationThread;
      65             :     friend class RenderBenchMarkThread;
      66             : public:
      67             :     GL3DBarChart(
      68             :         const css::uno::Reference<css::chart2::XChartType>& xChartType,
      69             :         OpenGLWindow* pContext);
      70             : 
      71             :     virtual ~GL3DBarChart();
      72             : 
      73             :     virtual void create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSeries,
      74             :         ExplicitCategoriesProvider& rCatProvider) SAL_OVERRIDE;
      75             : 
      76             :     virtual void render() SAL_OVERRIDE;
      77             : 
      78             :     /// Render one frame of the 3D bar chart.
      79             :     void renderFrame();
      80             : 
      81             :     virtual void update() SAL_OVERRIDE;
      82             : 
      83             :     /// Draw to the framebuffer context, and provide the ID of the bar that the user has clicked.
      84             :     sal_uInt32 barIdAtPosition(const Point& rPos);
      85             :     virtual void clickedAt(const Point& rPos, sal_uInt16 nButtons) SAL_OVERRIDE;
      86             : 
      87             :     virtual void mouseDragMove(const Point& rStartPos, const Point& rEndPos, sal_uInt16 nButtons) SAL_OVERRIDE;
      88             :     virtual void scroll(long nDelta) SAL_OVERRIDE;
      89             :     virtual void contextDestroyed() SAL_OVERRIDE;
      90             : 
      91             :     void setOpenGLWindow(OpenGLWindow* pWindow);
      92             : 
      93             : private:
      94             : 
      95             :     void spawnRenderThread(RenderThread *pThread);
      96             :     void joinRenderThread();
      97             :     void moveToCorner();
      98             :     void moveToDefault();
      99             :     glm::vec3 getCornerPosition(sal_Int8 nCornerId);
     100             :     void updateTimer();
     101             :     void updateScreenText();
     102             :     void updateRenderFPS();
     103             :     void updateDataUpdateFPS();
     104             :     DECL_LINK(UpdateTimerHdl, void*);
     105             :     int calcTimeInterval(TimeValue &startTime, TimeValue &endTime);
     106             :     float addScreenTextShape(OUString &nStr, glm::vec2 aLeftOrRightTop, float nTextHeight, bool bLeftTopFlag = true,
     107             :                                   const glm::vec4& rColor = glm::vec4(0.0f, 1.0f, 1.0f, 0.0f),
     108             :                                   const glm::vec3& rPos = glm::vec3(0.0f, 0.0f, 0.0f),
     109             :                                   sal_uInt32 nEvent = 0);
     110             :     void recordBarHistory(sal_uInt32 &nBarID, float &nVal);
     111             :     void updateClickEvent();
     112             :     void calcDistance(std::vector<sal_uInt32> &vectorNearest);
     113             :     float calcScrollDistance(const glm::mat4 &mvp, const glm::vec3& rPos);
     114             :     void initDistanceHeap(std::vector<sal_uInt32> &vectorNearest);
     115             :     void keepHeap(std::vector<sal_uInt32> &vectorNearest, int index);
     116             :     void swapVector(int i, int j, std::vector<sal_uInt32> &vectorNearest);
     117             :     void getNearestBars(std::vector<sal_uInt32> &vectorNearest);
     118             :     void updateScroll();
     119             :     void processAutoFly(sal_uInt32 nId, sal_uInt32 nColor);
     120             :     void getNeighborBarID(sal_uInt32 nSelectBarId, sal_uInt32 *pNeighborBarId);
     121             :     void addMovementScreenText(sal_uInt32 nBarId);
     122             :     css::uno::Reference<css::chart2::XChartType> mxChartType;
     123             :     boost::ptr_vector<opengl3D::Renderable3DObject> maShapes;
     124             : 
     125             :     boost::scoped_ptr<opengl3D::OpenGL3DRenderer> mpRenderer;
     126             :     OpenGLWindow* mpWindow;
     127             : 
     128             :     opengl3D::Camera* mpCamera;
     129             :     bool mbValidContext;
     130             : 
     131             :     boost::scoped_ptr<opengl3D::TextCache> mpTextCache;
     132             : 
     133             :     glm::vec3 maCameraPosition;
     134             :     glm::vec3 maCameraDirection;
     135             : 
     136             :     glm::vec3 maDefaultCameraPosition;
     137             :     glm::vec3 maDefaultCameraDirection;
     138             : 
     139             :     glm::vec3 maStepDirection;
     140             :     float mnMaxX;
     141             :     float mnMaxY;
     142             :     float mnDistance;
     143             :     /**
     144             :      * 0 = corner at (0,0,0);
     145             :      * numbering counter clockwise
     146             :      */
     147             :     sal_Int8 mnCornerId;
     148             : 
     149             :     std::vector<OUString> maCategories;
     150             :     std::vector<OUString> maSeriesNames;
     151           0 :     struct BarInformation
     152             :     {
     153             :         glm::vec3 maPos;
     154             :         float mnVal;
     155             :         sal_Int32 mnIndex;
     156             :         sal_Int32 mnSeriesIndex;
     157             : 
     158             :         BarInformation(const glm::vec3& rPos, float nVal,
     159             :                 sal_Int32 nIndex, sal_Int32 nSeriesIndex);
     160             :     };
     161             : 
     162             :     std::map<sal_uInt32, const BarInformation> maBarMap;
     163             :     bool mbNeedsNewRender;
     164             :     bool mbCameraInit;
     165             : 
     166             :     osl::Mutex maMutex;
     167             :     rtl::Reference<RenderThread> mpRenderThread;
     168             :     bool mbRenderDie;
     169             :     ::osl::Condition maClickCond;
     170             :     RenderEventType maRenderEvent;
     171             :     RenderEventType maPreRenderEvent;
     172             :     sal_uInt32 mnSelectBarId;
     173             :     sal_uInt32 mnPreSelectBarId;
     174             :     Point maClickPos;
     175             :     sal_uInt32 miScrollRate;
     176             :     bool mbScrollFlg;
     177             :     Timer maTimer;
     178             :     bool mbScreenTextNewRender;
     179             :     boost::ptr_vector<opengl3D::Renderable3DObject> maScreenTextShapes;
     180             :     OUString maFPS;
     181             :     OUString maDataUpdateFPS;
     182             :     sal_uInt32 miFrameCount;
     183             :     sal_uInt32 miDataUpdateCounter;
     184             :     TimeValue maFPSRenderStartTime;
     185             :     TimeValue maFPSRenderEndTime;
     186             :     TimeValue maDataUpdateStartTime;
     187             :     TimeValue maDataUpdateEndTime;
     188             :     std::map<sal_uInt32, std::list<float> > maBarHistory;
     189             :     std::vector<sal_uInt32> maVectorNearest;
     190             :     std::map<sal_uInt32, float> maDistanceMap;
     191             :     std::map<sal_uInt32, sal_uInt32> maBarColorMap;
     192             :     int mnColorRate;
     193             :     bool mbBenchMarkMode;
     194             :     sal_uInt32 mnHistoryCounter;
     195             :     sal_uInt32 mnBarsInRow;
     196             :     bool mbAutoFly;
     197             :     sal_Int32 mnUpdateBarId;
     198             : 
     199             :     // these form a pair:
     200             :     // main thread sets condition 1 and waits until it can take the mutex
     201             :     // render thread checks condition 1 before taking the mutex and waits in case it
     202             :     // is set until condition 2 is set
     203             :     //
     204             :     // only necessary for the benchmark mode
     205             :     osl::Condition maCond1;
     206             :     osl::Condition maCond2;
     207             : };
     208             : 
     209             : }
     210             : 
     211             : #endif
     212             : 
     213             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10