OpenFrames
CurveArtist.hpp
Go to the documentation of this file.
1 /***********************************
2  Copyright 2018 Ravishankar Mathur
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 
21 #ifndef _OF_CURVEARTIST_
22 #define _OF_CURVEARTIST_
23 
24 #include <OpenFrames/Export.h>
26 #include <osg/LineStipple>
27 #include <osg/LineWidth>
28 
29 namespace OpenFrames
30 {
40  class OF_EXPORT CurveArtist : public TrajectoryArtist
41  {
42  public:
43 
44  CurveArtist( const Trajectory *traj = NULL );
45 
46  // Copy constructor
47  CurveArtist( const CurveArtist &ca,
48  const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY );
49 
51  virtual Object* cloneType() const { return new CurveArtist(); }
52  virtual Object* clone(const osg::CopyOp& copyop) const { return new CurveArtist(*this,copyop); }
53  virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const CurveArtist*>(obj)!=NULL; }
54  virtual const char* libraryName() const { return "OpenFrames"; }
55  virtual const char* className() const { return "CurveArtist"; }
56 
58  virtual void setTrajectory(const Trajectory *traj);
59 
61  bool setXData(const Trajectory::DataSource &src);
62  bool setYData(const Trajectory::DataSource &src);
63  bool setZData(const Trajectory::DataSource &src);
64 
66  void setColor(float r, float g, float b);
67  void setWidth( float width );
68  void setPattern( GLint factor, GLushort pattern );
69 
71  virtual void drawImplementation(osg::RenderInfo& renderInfo) const;
72 
75  virtual void dataCleared(Trajectory* traj);
76  virtual void dataAdded(Trajectory* traj);
77 
78  protected:
79  virtual ~CurveArtist();
80 
82  virtual osg::BoundingBox computeBoundingBox() const;
83 
84  void verifyData() const;
85 
86  // Data sources for x, y, and z coordinates
87  Trajectory::DataSource _dataSource[3];
88 
90  osg::ref_ptr<osg::LineWidth> _lineWidth;
91  osg::ref_ptr<osg::LineStipple> _linePattern;
92  float _lineColor[3];
93 
94  mutable bool _dataValid; // If trajectory supports required data
95  mutable bool _dataZero; // If we are just drawing at the origin
96  };
97 
98 }
99 
100 #endif
This class draws Trajectory points connected by lines.
Definition: CurveArtist.hpp:40
virtual Object * cloneType() const
Definition: CurveArtist.hpp:51
Abstract class for Trajectory objects.
Definition: TrajectoryArtist.hpp:42
Definition: CoordinateAxes.hpp:29
Holds a collection of data vectors.
Definition: Trajectory.hpp:42
osg::ref_ptr< osg::LineWidth > _lineWidth
Definition: CurveArtist.hpp:90