cherish
Public Member Functions | Protected Member Functions | List of all members
entity::Polygon Class Reference

Geometry class that defines opacity polygons drawn by a user. The creation and usage of this class must be followed after certain steps. Usually, this class API is created with event handler in mind, i.e., it is assumed the user first dtaws the polygon borders (thus a polygon phantom is created), and then the phantom must be re-defined as am opaque polygon. For example: More...

#include <Polygon.h>

Inheritance diagram for entity::Polygon:
entity::ShaderedEntity2D entity::Entity2D

Public Member Functions

 Polygon ()
 
 Polygon (const Polygon &copy, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
 
void removeLastPoint ()
 
virtual bool redefineToShape (osg::MatrixTransform *t=0)
 
bool isPolygon () const
 
virtual void appendPoint (const float u, const float v)
 
cher::ENTITY_TYPE getEntityType () const
 
virtual ProgramPolygongetProgram () const
 
- Public Member Functions inherited from entity::ShaderedEntity2D
 ShaderedEntity2D (unsigned int drawing, osg::Geometry::AttributeBinding binding, const std::string &name, const osg::Vec4f &color)
 
 ShaderedEntity2D (const entity::ShaderedEntity2D &copy, const osg::CopyOp &copyop)
 
virtual void initializeProgram (ProgramEntity2D *p, unsigned int mode=GL_LINE_STRIP)
 
virtual bool copyFrom (const entity::ShaderedEntity2D *copy)
 
virtual void appendPoint (const float u, const float v, osg::Vec4f color)
 
virtual osg::Vec2f getPoint (unsigned int i) const
 
virtual osg::Vec3f getPoint3 (unsigned int i) const
 
int getNumPoints () const
 
virtual void moveDelta (double du, double dv)
 
virtual void scale (double scaleX, double scaleY, osg::Vec3f center)
 
virtual void scale (double scale, osg::Vec3f center)
 
virtual void rotate (double theta, osg::Vec3f center)
 
void setLines (osg::DrawArrays *lines)
 
const osg::DrawArrays * getLines () const
 
void setColor (const osg::Vec4f &color)
 
const osg::Vec4f & getColor () const
 
void setSelected (float alpha)
 
void setUnselected (float alpha)
 
void setIsShadered (bool shadered)
 
bool getIsShadered () const
 
virtual void setProgram (ProgramEntity2D *p)
 
- Public Member Functions inherited from entity::Entity2D
 Entity2D (const Entity2D &copy, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
 

Protected Member Functions

bool redefineToShader (osg::MatrixTransform *t)
 

Additional Inherited Members

- Protected Attributes inherited from entity::ShaderedEntity2D
osg::ref_ptr< osg::DrawArrays > m_lines
 
osg::observer_ptr< ProgramEntity2Dm_program
 
bool m_isShadered
 
osg::Vec4f m_colorNormal
 
osg::Vec4f m_colorSelected
 

Detailed Description

Geometry class that defines opacity polygons drawn by a user. The creation and usage of this class must be followed after certain steps. Usually, this class API is created with event handler in mind, i.e., it is assumed the user first dtaws the polygon borders (thus a polygon phantom is created), and then the phantom must be re-defined as am opaque polygon. For example:

// start from creating an empty Polygon, always
// initialize the shader program
phantom->initializeProgram(p); // e.g., Canvas::getProgramPolygon
// as user draws, add mouse coordinates, in an event loop:
phantom->addPoint(u,v);
// after user is finished, re-define the outer path to the opaque polygon type:
phantom->redefineToShape();

The below example provides details on how to copy/clone a polygon that is already present on the scene graph:

// create empty polygon
// copy data points from another polygon
copy->copyFrom(phantom);
// re-define to the polygon type

Constructor & Destructor Documentation

§ Polygon() [1/2]

entity::Polygon::Polygon ( )

Constructor that creates an empty polygon.

§ Polygon() [2/2]

entity::Polygon::Polygon ( const Polygon copy,
const osg::CopyOp &  copyop = osg::CopyOp::SHALLOW_COPY 
)

Copy constructor, only used for serialization; not to be used otherwise.

Member Function Documentation

§ getEntityType()

cher::ENTITY_TYPE entity::Polygon::getEntityType ( ) const
virtual

A re-defined method of entity::Entity2D to obtain entity type.

Returns
entity type

Implements entity::ShaderedEntity2D.

§ isPolygon()

bool entity::Polygon::isPolygon ( ) const
Returns
whether the geometry is of polygon type

§ redefineToShader()

bool entity::Polygon::redefineToShader ( osg::MatrixTransform *  t)
protectedvirtual

A method to tune the look of the entity with shader effects.

Implements entity::ShaderedEntity2D.

§ redefineToShape()

bool entity::Polygon::redefineToShape ( osg::MatrixTransform *  t = 0)
virtual

A method changes the geometry from line adjacency to polygon type thus allowing opacity of a region. It should be called on completion of polygon draw (e.g., when phantom last point is very clone to its first point) from event handler.

Returns
true upon success.

Implements entity::ShaderedEntity2D.

§ removeLastPoint()

void entity::Polygon::removeLastPoint ( )

A method to remove the last point from the polygon.


The documentation for this class was generated from the following files: