OsgVectorFieldRepresentation.h
Go to the documentation of this file.
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013, SimQuest Solutions Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 #ifndef SURGSIM_GRAPHICS_OSGVECTORFIELDREPRESENTATION_H
17 #define SURGSIM_GRAPHICS_OSGVECTORFIELDREPRESENTATION_H
18 
21 
22 #include <osg/Array>
23 #include <osg/Geometry>
24 #include <osg/LineWidth>
25 #include <osg/Point>
26 
27 namespace SurgSim
28 {
29 namespace Graphics
30 {
31 
32 #if defined(_MSC_VER)
33 #pragma warning(push)
34 #pragma warning(disable:4250)
35 #endif
36 
39 {
40 public:
43  explicit OsgVectorFieldRepresentation(const std::string& name);
46 
49  virtual std::shared_ptr< SurgSim::Graphics::VectorField > getVectorField() const override;
50 
53  virtual void setLineWidth(double width) override;
56  virtual double getLineWidth() const override;
57 
60  virtual void setScale(double scale) override;
63  virtual double getScale() const override;
64 
67  virtual void setPointSize(double size);
70  virtual double getPointSize() const;
71 
74  virtual void doUpdate(double dt) override;
75 
76 private:
79  std::shared_ptr<SurgSim::Graphics::VectorField> m_vectorField;
80 
82  osg::ref_ptr<osg::Vec3Array> m_vertexData;
83 
85  osg::ref_ptr<osg::Geometry> m_lineGeometry;
87  osg::ref_ptr<osg::Geometry> m_pointGeometry;
88 
90  osg::ref_ptr<osg::DrawArrays> m_drawArrays;
92  osg::ref_ptr<osg::DrawElementsUInt> m_drawPoints;
93 
95  osg::ref_ptr<osg::LineWidth> m_line;
97  osg::ref_ptr<osg::Point> m_point;
98 
100  osg::ref_ptr<osg::Vec4Array> m_colors;
101 
103  double m_scale;
104 };
105 
106 #if defined(_MSC_VER)
107 #pragma warning(pop)
108 #endif
109 
110 }; // Graphics
111 }; // SurgSim
112 
113 #endif // SURGSIM_GRAPHICS_OSGVECTORFIELDREPRESENTATION_H
virtual double getScale() const override
Gets the scale applied to all vectors.
Definition: OsgVectorFieldRepresentation.cpp:157
osg::ref_ptr< osg::Point > m_point
OSG::Point for representing vector starting point.
Definition: OsgVectorFieldRepresentation.h:97
Definition: DriveElementFromInputBehavior.cpp:27
OSG vector field representation, implements a VectorFieldRepresenation using OSG. ...
Definition: OsgVectorFieldRepresentation.h:38
Graphic representation of a vector field Each point/location, i.e.
Definition: VectorFieldRepresentation.h:29
osg::ref_ptr< osg::Vec4Array > m_colors
OSG::Vec4Array to hold color for each vector.
Definition: OsgVectorFieldRepresentation.h:100
virtual void setLineWidth(double width) override
Sets vector line width.
Definition: OsgVectorFieldRepresentation.cpp:142
osg::ref_ptr< osg::Vec3Array > m_vertexData
OSG vertex data structure.
Definition: OsgVectorFieldRepresentation.h:82
osg::ref_ptr< osg::LineWidth > m_line
OSG::LineWidth for representing vector.
Definition: OsgVectorFieldRepresentation.h:95
virtual void setScale(double scale) override
Sets the scale to be applied to all vectors.
Definition: OsgVectorFieldRepresentation.cpp:152
string(TOUPPER ${DEVICE}DEVICE_UPPER_CASE) option(BUILD_DEVICE_ $
Definition: CMakeLists.txt:35
virtual void doUpdate(double dt) override
Executes the update operation.
Definition: OsgVectorFieldRepresentation.cpp:73
osg::ref_ptr< osg::DrawElementsUInt > m_drawPoints
An OSG::DrawElementUInt object specifying how vector starting points will be drawn.
Definition: OsgVectorFieldRepresentation.h:92
virtual void setPointSize(double size)
Sets the size of point indicating the starting of vector.
Definition: OsgVectorFieldRepresentation.cpp:162
osg::ref_ptr< osg::Geometry > m_pointGeometry
OSG::Geometry node holding OSG representation of vector starting points.
Definition: OsgVectorFieldRepresentation.h:87
virtual double getPointSize() const
Gets the size of starting point of a vector.
Definition: OsgVectorFieldRepresentation.cpp:167
double m_scale
A scale to scale the length of vector.
Definition: OsgVectorFieldRepresentation.h:103
std::shared_ptr< SurgSim::Graphics::VectorField > m_vectorField
Vector Field holds a list of vertices/points (X,Y,Z) in 3D space Each point is associated with a vect...
Definition: OsgVectorFieldRepresentation.h:79
OsgVectorFieldRepresentation(const std::string &name)
Constructor.
Definition: OsgVectorFieldRepresentation.cpp:32
~OsgVectorFieldRepresentation()
Destructor.
Definition: OsgVectorFieldRepresentation.cpp:69
virtual double getLineWidth() const override
Gets line width.
Definition: OsgVectorFieldRepresentation.cpp:147
osg::ref_ptr< osg::DrawArrays > m_drawArrays
An OSG::DrawArrays object specifying how vectors will be drawn.
Definition: OsgVectorFieldRepresentation.h:90
osg::ref_ptr< osg::Geometry > m_lineGeometry
OSG::Geometry node holding OSG representation of vectors.
Definition: OsgVectorFieldRepresentation.h:85
Base OSG implementation of a graphics representation.
Definition: OsgRepresentation.h:42
virtual std::shared_ptr< SurgSim::Graphics::VectorField > getVectorField() const override
Gets the vector field.
Definition: OsgVectorFieldRepresentation.cpp:137