/usr/include/OpenLayer/LineStrip.hpp is in libopenlayer-dev 2.1-2.1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | #ifndef OL_LINE_STRIP_HPP
#define OL_LINE_STRIP_HPP
#include "Shape.hpp"
#include "Vec2D.hpp"
#include "Placement.hpp"
#include "Line.hpp"
#include "RawLineStrip.hpp"
#include "Declspec.hpp"
#include <list>
namespace ol {
class Bitmap;
// A series of lines clued together //
class OL_LIB_DECLSPEC LineStrip : public Shape {
public:
LineStrip( float lineWidth = 1.0, const Bitmap *texture = 0 )
: Shape( lineWidth ), texture( texture ) {}
template< class std_container >
LineStrip( const std_container &vertices, float lineWidth = 1.0, const Bitmap *texture = 0 );
virtual ~LineStrip() {}
// Draw the line strip filled with a color //
inline void Draw( const Rgba &color ) const {
#ifdef OL_NO_STATE_CHANGE
GLboolean texturesEnabled;
glGetBooleanv( GL_TEXTURE_2D, &texturesEnabled );
#endif
glDisable( GL_TEXTURE_2D );
color.Select();
ExecDraw();
#ifdef OL_NO_STATE_CHANGE
if( texturesEnabled )
glEnable( GL_TEXTURE_2D );
#endif
}
void DrawOutline( const Rgba &color ) const {
#ifdef OL_NO_STATE_CHANGE
GLboolean texturesEnabled;
glGetBooleanv( GL_TEXTURE_2D, &texturesEnabled );
#endif
glDisable( GL_TEXTURE_2D );
color.Select();
ExecDraw();
#ifdef OL_NO_STATE_CHANGE
if( texturesEnabled )
glEnable( GL_TEXTURE_2D );
#endif
}
// Draw the line strip with a gradient //
virtual void Draw( const Rgba &startColor, const Rgba &endColor ) const;
// Moves the line strip by the specified amount //
virtual void MoveBy( const Vec2D &amount ) {
placement.MoveBy( amount );
}
virtual void MoveTo( const Vec2D &position ) {
this->placement.SetPosition( position );
}
inline void SetPlacement( const Placement &placement ) {
this->placement = placement;
}
virtual void TransformBy( const Placement &placement ) {
this->placement += placement;
}
inline const Placement &GetPlacement() const {
return placement;
}
// Sets the filler texture of the line strip //
inline void SetTexture( const Bitmap &texture ) {
this->texture = &texture;
}
// Disables the filler texture //
inline void DisableTexture() {
texture = 0;
}
// Add a vertex to the end of the line strip //
inline void AddToEnd( Vec2D vertex ) {
data.AddToEnd( vertex );
}
// Add a vertex to the beginning of the line strip //
inline void AddToBegin( Vec2D vertex ) {
data.AddToBegin( vertex );
}
// Delete the first vertex of the line strip //
inline void DeleteFirst() {
data.DeleteFirst();
}
// Delete the first last of the line strip //
inline void DeleteLast() {
data.DeleteLast();
}
// Returns the specified vertex //
Vec2D GetVertex( unsigned int index ) const;
// Returns the specified segment //
inline Line GetSegment( int index ) const {
return Line( GetVertex( index ), GetVertex( index+1 ));
}
// Returns the number of vertices //
inline int GetNumOfVertices() const {
return data.GetVertices().size();
}
const std::list< Vec2D > &GetVertices() const {
return data.GetVertices();
}
virtual std::string ToString() const;
// The following functions could be derived from Set/GetPlacement
inline void SetRotationAngle( float angle ) {
placement.SetRotation( angle );
}
inline float GetRotationAngle() {
return placement.GetRotation();
}
virtual void RotateBy( float angle ) {
placement.RotateBy( angle );
}
// Collision routines
inline bool Collides( const LineStrip &other, const Placement &thisPlacement,
const Placement &otherPlacement ) const {
return DoCollisionTest( other, thisPlacement, otherPlacement, false ).IsCollision();
}
inline Collision GetCollision( const LineStrip &other, const Placement &thisPlacement,
const Placement &otherPlacement ) const {
return DoCollisionTest( other, thisPlacement, otherPlacement, true );
}
inline Collision GetCollision( const Line &other, const Placement &thisPlacement,
const Placement &otherPlacement ) const {
return DoCollisionTest( other, thisPlacement, otherPlacement, true );
}
private:
Collision DoCollisionTest( const LineStrip &other, const Placement &thisPlacement,
const Placement &otherPlacement, bool getResults = true ) const;
Collision DoCollisionTest( const Line &other, const Placement &thisPlacement,
const Placement &otherPlacement, bool getResults = true ) const;
// Draws the line strip with the specified color //
void ExecDraw() const;
// Draws the line strip with the specified color //
void ExecDrawOutline() const {
ExecDraw();
}
// Raw line strip rendering function //
void Render( const Rgba *color1, const Rgba *color2 ) const;
RawLineStrip< std::list< Vec2D >, std::list< float > > data;
Placement placement;
const Bitmap *texture;
};
// TEMPLATES //
template< class std_container >
LineStrip::
LineStrip( const std_container &theVertices, float lineWidth, const Bitmap *texture )
: Shape( lineWidth ), texture( texture ) {
for( typename std_container::const_iterator iter = theVertices.begin(); iter != theVertices.end(); iter++ ) {
AddToEnd( *iter );
}
}
}
#endif // OL_LINE_STRIP_HPP
|