OpenFrames
SegmentArtist.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_SEGMENTARTIST_
22 #define _OF_SEGMENTARTIST_
23 
24 #include <OpenFrames/Export.h>
26 #include <osg/LineStipple>
27 #include <osg/LineWidth>
28 
29 namespace OpenFrames
30 {
34 class OF_EXPORT SegmentArtist : public TrajectoryArtist
35 {
36  public:
37  SegmentArtist( const Trajectory *traj = NULL );
38 
39  // Copy constructor
40  SegmentArtist( const SegmentArtist &ca,
41  const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY );
42 
44  virtual Object* cloneType() const { return new SegmentArtist(); }
45  virtual Object* clone(const osg::CopyOp& copyop) const { return new SegmentArtist(*this,copyop); }
46  virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const SegmentArtist*>(obj)!=NULL; }
47  virtual const char* libraryName() const { return "OpenFrames"; }
48  virtual const char* className() const { return "SegmentArtist"; }
49 
51  virtual void setTrajectory(const Trajectory *traj);
52 
54  bool setStartXData(const Trajectory::DataSource &src);
55  bool setEndXData( const Trajectory::DataSource &src);
56  bool setStartYData(const Trajectory::DataSource &src);
57  bool setEndYData( const Trajectory::DataSource &src);
58  bool setStartZData(const Trajectory::DataSource &src);
59  bool setEndZData( const Trajectory::DataSource &src);
60 
62  void setStride(unsigned int stride);
63  inline unsigned int getStride() const { return _stride; }
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 ~SegmentArtist();
80 
82  virtual osg::BoundingBox computeBoundingBox() const;
83 
84  void verifyData() const;
85 
86  Trajectory::DataSource _startSource[3]; // Data sources for starting point
87  Trajectory::DataSource _endSource[3]; // Data sources for ending point
88 
89  unsigned int _stride; // Minimum offset between sucessive drawn points
90 
92  osg::ref_ptr<osg::LineWidth> _lineWidth;
93  osg::ref_ptr<osg::LineStipple> _linePattern;
94  float _lineColor[3];
95 
96  mutable bool _dataValid; // If trajectory supports required data
97  mutable bool _startDataZero;
98  mutable bool _endDataZero;
99  };
100 
101 }
102 
103 #endif
Abstract class for Trajectory objects.
Definition: TrajectoryArtist.hpp:42
Definition: SegmentArtist.hpp:34
Definition: CoordinateAxes.hpp:29
virtual Object * cloneType() const
Definition: SegmentArtist.hpp:44
Holds a collection of data vectors.
Definition: Trajectory.hpp:42
osg::ref_ptr< osg::LineWidth > _lineWidth
Definition: SegmentArtist.hpp:92