OpenFrames
MarkerArtist.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_MARKERARTIST_
22 #define _OF_MARKERARTIST_
23 
24 #include <OpenFrames/Export.h>
26 
27 namespace OpenFrames
28 {
39  class OF_EXPORT MarkerArtist : public TrajectoryArtist
40  {
41  public:
42 
45  {
46  START = 1, // Draw marker at start point.
47  INTERMEDIATE = 2, // Draw markers at intermediate points, excluding
48  // the start & end points.
49  END = 4 // Draw marker at end point.
50  };
51 
54  {
55  TIME = 1, // Draw markers at equally spaced time increments.
56  DISTANCE, // Draw markers at equally spaced distances, with distance
57  // being measured using DataSource as a point.
58  DATA // Draw markers at equally spaced data points.
59  };
60 
61  MarkerArtist( const Trajectory *traj = NULL );
62 
63  // Copy constructor
64  MarkerArtist( const MarkerArtist &ca,
65  const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY );
66 
68  virtual Object* cloneType() const { return new MarkerArtist(); }
69  virtual Object* clone(const osg::CopyOp& copyop) const { return new MarkerArtist(*this,copyop); }
70  virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const MarkerArtist*>(obj)!=NULL; }
71  virtual const char* libraryName() const { return "OpenFrames"; }
72  virtual const char* className() const { return "MarkerArtist"; }
73 
75  virtual void setTrajectory(const Trajectory *traj);
76 
78  bool setXData(const Trajectory::DataSource &src);
79  bool setYData(const Trajectory::DataSource &src);
80  bool setZData(const Trajectory::DataSource &src);
81 
83  void setMarkers( unsigned int markers );
84  void setMarkerColor( unsigned int markers, float r, float g, float b);
85  void setMarkerSize(unsigned int size); // Size in pixels
86  bool setMarkerImage( const std::string &fname );
87  bool setMarkerShader( const std::string &fname );
88 
91  void setAutoAttenuate(bool attenuate);
92  bool getAutoAttenuate() const;
93 
95  void setIntermediateType(IntermediateType type);
96 
98  void setIntermediateSpacing(double spacing);
99 
103  void setIntermediateDirection(DrawnMarkers direction);
104 
106  virtual void drawImplementation(osg::RenderInfo& renderInfo) const;
107 
109  virtual void dataCleared(Trajectory* traj);
110 
112  virtual void dataAdded(Trajectory* traj);
113 
115  void computeAttenuation();
116 
117  protected:
118  virtual ~MarkerArtist();
119 
121  virtual osg::BoundingBox computeBoundingBox() const;
122 
124  void verifyData() const;
125 
127  void resetMarkerShader();
128 
129  // Data sources for x, y, and z components
130  Trajectory::DataSource _dataSource[3];
131 
132  unsigned int _markers; // Which points to draw as markers
133 
134  IntermediateType _intermediateType; // Type of intermediate markers
135  double _intermediateSpacing; // Spacing for intermediate markers
136  DrawnMarkers _intermediateDirection; // Intermediate marker direction
137 
138  float _startColor[3]; // Starting marker color
139  float _endColor[3]; // Ending marker color
140  float _intermediateColor[3]; // Intermediate markers color
141 
142  mutable bool _dataValid; // If trajectory supports required data
143  mutable bool _dataZero; // If we're just drawing at the origin
144  mutable bool _shouldAttenuate; // Attenuation needs to be recomputed
145 
146  osg::ref_ptr<osg::Shader> _fragShader; // Marker fragment shader
147  };
148 
149 }
150 
151 #endif
DrawnMarkers
Definition: MarkerArtist.hpp:44
This class draws markers at trajectory points.
Definition: MarkerArtist.hpp:39
Abstract class for Trajectory objects.
Definition: TrajectoryArtist.hpp:42
Definition: CoordinateAxes.hpp:29
Holds a collection of data vectors.
Definition: Trajectory.hpp:42
IntermediateType
Definition: MarkerArtist.hpp:53
virtual Object * cloneType() const
Definition: MarkerArtist.hpp:68