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

Generated by: LCOV version 1.11