AGX Dynamics 2.42.1.1
Loading...
Searching...
No Matches
GraphRenderer.h
Go to the documentation of this file.
1/*
2Copyright 2007-2025. 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#pragma once
18
20#include <agxOSG/export.h>
21#include <agxRender/Graph.h>
22
23#include <agx/PushDisableWarnings.h> // Disabling warnings. Include agx/PopDisableWarnings.h below!
24#include <osg/Group>
25#include <osg/Geometry>
26#include <osg/Geode>
27#include <osg/Array>
28#include <agx/PopDisableWarnings.h> // End of disabled warnings.
29
30namespace agxOSG
31{
34 {
35 public:
37
38 void drawText( const agx::Vec2& pos, const agx::String& str);
39 void setColor( const agx::Vec4& color );
40 void drawLine( const agx::Vec2& p1, const agx::Vec2& p2 ) const;
41 void preDraw();
42 void postDraw();
43 void addChannel();
45 size_t getNumChannels() const;
46
47 virtual void setEnable( bool flag );
48
49 void drawData( size_t channelIndex, const agxRender::Graph::DataVector& data );
50
51 osg::Node *getNode( ) { return m_parent; }
52
53 void clear();
54
55 void setRenderManager( agxRender::RenderManager *mgr ) { m_mgr= mgr; }
56
57 protected:
58
59 virtual ~GraphRenderer();
60 void updateLineGeometry( size_t channelIndex, const agxRender::Graph::DataVector& data );
61
62 osg::ref_ptr<osg::Group> m_parent;
65
66 struct OSGChannel {
67 osg::ref_ptr<osg::Geode> geode;
68 osg::ref_ptr<osg::Geometry> geometry;
69 osg::DrawArrays* primitiveSet;
70 osg::ref_ptr<osg::Vec4Array> colors;
71 osg::ref_ptr<osg::Vec3Array> vertices;
72 };
73
76 };
77}
78
#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()
Definition: GraphRenderer.h:51
void drawLine(const agx::Vec2 &p1, const agx::Vec2 &p2) const
Draw a line from p1 to p2.
void setRenderManager(agxRender::RenderManager *mgr)
Definition: GraphRenderer.h:55
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
Definition: GraphRenderer.h:63
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
Definition: GraphRenderer.h:74
void setColor(const agx::Vec4 &color)
void addChannel()
Setup structures/data for another data channel.
osg::ref_ptr< osg::Group > m_parent
Definition: GraphRenderer.h:62
Abstract base class that acts as an interface and can render the data from a Graph.
Definition: Graph.h:45
Class for managing the rendering of geometries, shapes, rigid bodies, constraints etc.
A class holding 4 dimensional vectors and providing basic arithmetic.
Definition: Vec4Template.h:35
The agxOSG namespace provides functionality for visualizing AGX simulations with OpenSceneGraph.
osg::ref_ptr< osg::Vec4Array > colors
Definition: GraphRenderer.h:70
osg::ref_ptr< osg::Vec3Array > vertices
Definition: GraphRenderer.h:71
osg::ref_ptr< osg::Geometry > geometry
Definition: GraphRenderer.h:68
osg::ref_ptr< osg::Geode > geode
Definition: GraphRenderer.h:67