AGX Dynamics 2.38.0.2
Loading...
Searching...
No Matches
GraphRenderer.h
Go to the documentation of this file.
1/*
2Copyright 2007-2024. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx 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
31namespace agxOSG
32{
33 class RenderProxyFactory;
34
37 {
38 public:
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();
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
#define AGX_DECLARE_POINTER_TYPES(type)
Definition Referenced.h:254
#define AGXOSG_EXPORT
void preDraw()
If the rendering of this graph requires some pre-state to be set (orthographic projection etc) this c...
void postDraw()
If the rendering of this graph requires some cleanup to be done it can be done in this method.
osg::Node * getNode()
void drawLine(const agx::Vec2 &p1, const agx::Vec2 &p2) const
Draw a line from p1 to p2.
void setRenderManager(agxRender::RenderManager *mgr)
void updateLineGeometry(size_t channelIndex, const agxRender::Graph::DataVector &data)
void drawData(size_t channelIndex, const agxRender::Graph::DataVector &data)
Update the line geometry for a specified channel given the data (points)
agxRender::RenderManager * m_mgr
GraphRenderer(agxRender::RenderManager *renderManager)
size_t getNumChannels() const
void clear()
Destruction of any data for this graph.
void drawText(const agx::Vec2 &pos, const agx::String &str)
void removeChannel()
Tear down data for the last added channel.
virtual void setEnable(bool flag)
Implement functionality for enabling/disabling the rendering of this graph.
agx::Vector< OSGChannel > Channels
void setColor(const agx::Vec4 &color)
void addChannel()
Setup structures/data for another data channel.
osg::ref_ptr< osg::Group > m_parent
Abstract base class that acts as an interface and can render the data from a Graph.
Definition Graph.h:46
Class for managing the rendering of geometries, shapes, rigid bodies, constraints etc.
A class holding 4 dimensional vectors and providing basic arithmetic.
The agxOSG namespace provides functionality for visualizing AGX simulations with OpenSceneGraph.
osg::ref_ptr< osg::Vec4Array > colors
osg::ref_ptr< osg::Vec3Array > vertices
osg::ref_ptr< osg::Geometry > geometry
osg::ref_ptr< osg::Geode > geode