AGXDynamics  2.35.0.3
GraphRenderer.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #ifndef AGXOSG_GRAPHRENDERER_H
18 #define AGXOSG_GRAPHRENDERER_H
19 
21 #include <agxOSG/export.h>
22 #include <agxRender/Graph.h>
23 
24 #include <agx/PushDisableWarnings.h> // Disabling warnings. Include agx/PopDisableWarnings.h below!
25 #include <osg/Group>
26 #include <osg/Geometry>
27 #include <osg/Geode>
28 #include <osg/Array>
29 #include <agx/PopDisableWarnings.h> // End of disabled warnings.
30 
31 namespace agxOSG
32 {
33  class RenderProxyFactory;
34 
37  {
38  public:
39  GraphRenderer( agxRender::RenderManager* renderManager );
40 
41  void drawText( const agx::Vec2& pos, const agx::String& str);
42  void setColor( const agx::Vec4& color );
43  void drawLine( const agx::Vec2& p1, const agx::Vec2& p2 ) const;
44  void preDraw();
45  void postDraw();
46  void addChannel();
47  void removeChannel();
48  size_t getNumChannels() const;
49 
50  virtual void setEnable( bool flag );
51 
52  void drawData( size_t channelIndex, const agxRender::Graph::DataVector& data );
53 
54  osg::Node *getNode( ) { return m_parent; }
55 
56  void clear();
57 
58  void setRenderManager( agxRender::RenderManager *mgr ) { m_mgr= mgr; }
59 
60  protected:
61 
62  virtual ~GraphRenderer();
63  void updateLineGeometry( size_t channelIndex, const agxRender::Graph::DataVector& data );
64 
65  osg::ref_ptr<osg::Group> m_parent;
68 
69  struct OSGChannel {
70  osg::ref_ptr<osg::Geode> geode;
71  osg::ref_ptr<osg::Geometry> geometry;
72  osg::DrawArrays* primitiveSet;
73  osg::ref_ptr<osg::Vec4Array> colors;
74  osg::ref_ptr<osg::Vec3Array> vertices;
75  };
76 
79  };
80 }
81 
82 #endif
agxOSG::GraphRenderer::OSGChannel::geode
osg::ref_ptr< osg::Geode > geode
Definition: GraphRenderer.h:70
agxOSG::GraphRenderer::OSGChannel::vertices
osg::ref_ptr< osg::Vec3Array > vertices
Definition: GraphRenderer.h:74
agx::Vector< agx::Vec2 >
agxRender::RenderManager
Class for managing the rendering of geometries, shapes, rigid bodies, constraints etc.
Definition: RenderManager.h:106
agxOSG::GraphRenderer::m_parent
osg::ref_ptr< osg::Group > m_parent
Definition: GraphRenderer.h:65
agxOSG::GraphRenderer::OSGChannel::colors
osg::ref_ptr< osg::Vec4Array > colors
Definition: GraphRenderer.h:73
agxOSG::GraphRenderer::m_currentColor
agx::Vec4 m_currentColor
Definition: GraphRenderer.h:67
agxOSG::GraphRenderer
Definition: GraphRenderer.h:36
agx::Vec4T
A class holding 4 dimensional vectors and providing basic arithmetic.
Definition: Vec4Template.h:34
agxOSG::GraphRenderer::OSGChannel::primitiveSet
osg::DrawArrays * primitiveSet
Definition: GraphRenderer.h:72
agxRender::Graph::GraphRenderer
Abstract base class that acts as an interface and can render the data from a Graph.
Definition: Graph.h:45
agxOSG::GraphRenderer::setRenderManager
void setRenderManager(agxRender::RenderManager *mgr)
Definition: GraphRenderer.h:58
agxOSG
The agxOSG namespace provides functionality for visualizing AGX simulations with OpenSceneGraph.
PushDisableWarnings.h
agx::Vec2T
Definition: Vec2Template.h:30
RenderManager.h
AGX_DECLARE_POINTER_TYPES
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
agxOSG::GraphRenderer::getNode
osg::Node * getNode()
Definition: GraphRenderer.h:54
Graph.h
agxOSG::GraphRenderer::m_channels
Channels m_channels
Definition: GraphRenderer.h:78
agxOSG::GraphRenderer::m_mgr
agxRender::RenderManager * m_mgr
Definition: GraphRenderer.h:66
export.h
agxOSG::GraphRenderer::OSGChannel::geometry
osg::ref_ptr< osg::Geometry > geometry
Definition: GraphRenderer.h:71
agx::AgXString< std::string >
agxOSG::GraphRenderer::Channels
agx::Vector< OSGChannel > Channels
Definition: GraphRenderer.h:77
agxTerrain::Profiler::clear
AGXTERRAIN_EXPORT void clear()
agxOSG::GraphRenderer::OSGChannel
Definition: GraphRenderer.h:69
AGXOSG_EXPORT
#define AGXOSG_EXPORT
PopDisableWarnings.h