LCOV - code coverage report
Current view: top level - eq - view.h (source / functions) Hit Total Coverage
Test: Equalizer Lines: 3 3 100.0 %
Date: 2017-12-16 05:07:20 Functions: 3 3 100.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2008-2017, Stefan Eilemann <eile@equalizergraphics.com>
       3             :  *                          Daniel Nachbaur <danielnachbaur@gmail.com>
       4             :  *
       5             :  * This library is free software; you can redistribute it and/or modify it under
       6             :  * the terms of the GNU Lesser General Public License version 2.1 as published
       7             :  * by the Free Software Foundation.
       8             :  *
       9             :  * This library is distributed in the hope that it will be useful, but WITHOUT
      10             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      11             :  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      12             :  * details.
      13             :  *
      14             :  * You should have received a copy of the GNU Lesser General Public License
      15             :  * along with this library; if not, write to the Free Software Foundation, Inc.,
      16             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      17             :  */
      18             : 
      19             : #ifndef EQ_VIEW_H
      20             : #define EQ_VIEW_H
      21             : 
      22             : #include <eq/api.h>
      23             : #include <eq/frame.h>         // enum
      24             : #include <eq/types.h>         // member
      25             : #include <eq/visitorResult.h> // enum
      26             : 
      27             : #include <eq/fabric/view.h>     // base class
      28             : #include <eq/fabric/viewport.h> // member
      29             : 
      30             : namespace eq
      31             : {
      32             : namespace detail
      33             : {
      34             : class View;
      35             : }
      36             : 
      37             : /**
      38             :  * A View is a 2D area of a Layout. It is a view of the application's data on a
      39             :  * model, in the sense used by the MVC pattern. It can be a scene, viewing mode,
      40             :  * viewing position, or any other representation of the application's data.
      41             :  *
      42             :  * @warning Never commit a View. Equalizer does take care of this to correctly
      43             :  *          associate view version with rendering frames.
      44             :  * @sa fabric::View
      45             :  */
      46             : class View : public fabric::View<Layout, View, Observer>
      47             : {
      48             : public:
      49             :     /** Construct a new view. @version 1.0 */
      50             :     EQ_API explicit View(Layout* parent);
      51             : 
      52             :     /** Destruct this view. @version 1.0 */
      53             :     EQ_API virtual ~View();
      54             : 
      55             :     /** @name Data Access. */
      56             :     //@{
      57             :     /**
      58             :      * @return the parent pipe of this view, 0 for non-render client views.
      59             :      * @version 1.1.2
      60             :      */
      61          23 :     Pipe* getPipe() { return _pipe; }
      62             :     /**
      63             :      * @return the parent pipe of this view, 0 for non-render client views.
      64             :      * @version 1.1.2
      65             :      */
      66             :     EQ_API const Pipe* getPipe() const { return _pipe; }
      67             :     /** @return the config of this view. @version 1.0 */
      68             :     EQ_API Config* getConfig();
      69             : 
      70             :     /** @return the config of this view. @version 1.0 */
      71             :     EQ_API const Config* getConfig() const;
      72             : 
      73             :     /** @return the Server of this view. @version 1.0 */
      74             :     EQ_API ServerPtr getServer();
      75             :     //@}
      76             : 
      77             :     /** @name Operations */
      78             :     //@{
      79             :     /**
      80             :      * Handle a received (view) event.
      81             :      *
      82             :      * The task of this method is to update the view as necessary. It is
      83             :      * called by Config::handleEvent on the application main thread for all
      84             :      * view events. Thread safe.
      85             :      *
      86             :      * @param type the event type.
      87             :      * @param event the received view event.
      88             :      * @return true when the event was handled, false if not.
      89             :      * @version 1.0
      90             :      */
      91             :     EQ_API virtual bool handleEvent(EventType type, const SizeEvent& event);
      92             : 
      93             :     /**
      94             :      * Callback function called during eq::Config::handleEvents() after
      95             :      * capturing a complete screenshot.
      96             :      *
      97             :      * @version 2.1
      98             :      */
      99             :     using ScreenshotFunc = std::function<void(uint32_t, const Image&)>;
     100             : 
     101             :     /**
     102             :      * Enable recording of given buffers for screenshot feature.
     103             :      *
     104             :      * @param buffers bitmask of buffers to capture in screenshot image
     105             :      * @param func callback function with frame number and screenshot image
     106             :      * @version 2.1
     107             :      */
     108             :     EQ_API void enableScreenshot(Frame::Buffer buffers,
     109             :                                  const ScreenshotFunc& func);
     110             : 
     111             :     /** Stop recording of screenshots. @version 2.1 */
     112             :     EQ_API void disableScreenshot();
     113             : 
     114             :     /** @internal */
     115             :     bool handleEvent(EventICommand& command);
     116             : 
     117             :     /** @internal */
     118             :     void sendScreenshotEvent(const Viewport& viewport,
     119             :                              const uint32_t frameNumber, const Image& image);
     120             :     //@}
     121             : 
     122             : protected:
     123             :     /**
     124             :      * @name Callbacks
     125             :      *
     126             :      * Callbacks are called by Equalizer during rendering to execute various
     127             :      * actions from the application main thread before sending the corresponding
     128             :      * command to the server.
     129             :      */
     130             :     //@{
     131             :     /** Initialize this view. @version 1.11 */
     132           7 :     virtual bool configInit() { return true; }
     133             :     friend class detail::InitVisitor;
     134             : 
     135             :     /** Exit this view. @version 1.11 */
     136           7 :     virtual bool configExit() { return true; }
     137             :     friend class detail::ExitVisitor;
     138             :     //@}
     139             : 
     140             :     /** @internal */
     141             :     EQ_API virtual void deserialize(co::DataIStream& is,
     142             :                                     const uint64_t dirtyBits);
     143             : 
     144             :     /** @return the initial frustum value of this view. */
     145             :     EQ_API const Frustum& getBaseFrustum() const;
     146             : 
     147             :     /** @internal trigger deletion for render-client views. */
     148             :     EQ_API virtual void detach();
     149             : 
     150             : private:
     151             :     detail::View* const _impl;
     152             : 
     153             :     bool _handleScreenshot(EventICommand& command);
     154             : 
     155             :     Pipe* _pipe; // for render-client views
     156             :     friend class Pipe;
     157             : };
     158             : }
     159             : 
     160             : #endif // EQ_VIEW_H

Generated by: LCOV version 1.11