AGX Dynamics  2.37.2.0
GraphRenderer.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2024. 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 
78  Channels m_channels;
79  };
80 }
81 
82 #endif
AGXTERRAIN_EXPORT void clear()
#define AGXOSG_EXPORT
A class holding 4 dimensional vectors and providing basic arithmetic.
Definition: Vec4Template.h:34
osg::ref_ptr< osg::Group > m_parent
Definition: GraphRenderer.h:65
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
Class for managing the rendering of geometries, shapes, rigid bodies, constraints etc...
osg::ref_ptr< osg::Geode > geode
Definition: GraphRenderer.h:70
osg::ref_ptr< osg::Vec4Array > colors
Definition: GraphRenderer.h:73
void setRenderManager(agxRender::RenderManager *mgr)
Definition: GraphRenderer.h:58
The agxOSG namespace provides functionality for visualizing AGX simulations with OpenSceneGraph.
osg::ref_ptr< osg::Vec3Array > vertices
Definition: GraphRenderer.h:74
osg::ref_ptr< osg::Geometry > geometry
Definition: GraphRenderer.h:71
agxRender::RenderManager * m_mgr
Definition: GraphRenderer.h:66
osg::Node * getNode()
Definition: GraphRenderer.h:54
Abstract base class that acts as an interface and can render the data from a Graph.
Definition: Graph.h:45
agx::Vector< OSGChannel > Channels
Definition: GraphRenderer.h:77