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

#include <Canvas.h>

Inheritance diagram for entity::Canvas:
osg::ProtectedGroup

Public Member Functions

 Canvas (const Canvas &cnv, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
 
virtual void initializeTools ()
 
virtual void initializeSG ()
 
virtual void initializeStateMachine ()
 
virtual void initializeMasks ()
 
osg::Matrix getMatrixInverse () const
 
osg::Matrix getMatrix () const
 
osg::Vec3f getCenter3D () const
 
ProgramStrokegetProgramStroke () const
 
ProgramPolygongetProgramPolygon () const
 
ProgramLineSegmentgetProgramLineSegment () const
 
void setMatrixTranslation (const osg::Matrix &T)
 
const osg::Matrix & getMatrixTranslation () const
 
void setTransform (osg::MatrixTransform *t)
 
const osg::MatrixTransform * getTransform () const
 
osg::MatrixTransform * getTransform ()
 
void setSwitch (osg::Switch *sw)
 
const osg::Switch * getSwitch () const
 
void setGroupData (osg::Group *group)
 
const osg::Group * getGroupData () const
 
void setGeodeStrokes (osg::Geode *geode)
 
const osg::Geode * getGeodeStrokes () const
 
void setGeodePhotos (osg::Geode *geode)
 
const osg::Geode * getGeodePhotos () const
 
void setGeodePolygons (osg::Geode *geode)
 
const osg::Geode * getGeodePolygons () const
 
void setGeodeLineSegments (osg::Geode *geode)
 
const osg::Geode * getGeodeLineSegments () const
 
void setCenter (const osg::Vec3f &center)
 
const osg::Vec3f & getCenter () const
 
void setNormal (const osg::Vec3f &normal)
 
const osg::Vec3f & getNormal () const
 
void setColor (const osg::Vec4f &color, const osg::Vec4f &colorIntersection=cher::CANVAS_CLR_PREVIOUS)
 
const osg::Vec4f & getColor () const
 
void setVisibilityFrameInternal (bool vis)
 
bool getVisibilityFrameInternal () const
 
bool getVisibilityAll () const
 
void setVisibilityAll (bool vis)
 
osg::Vec3f getGlobalAxisU () const
 
osg::Vec3f getGlobalAxisV () const
 
const osg::Geometry * getGeometryPickable () const
 
void translate (const osg::Matrix &mt)
 
void rotate (const osg::Matrix &mr, const osg::Vec3f &c3d_new)
 
void unselectAll ()
 
void unselectEntities ()
 
void selectAllEntities ()
 
void setStrokeCurrent (entity::Stroke *stroke)
 
void setStrokeCurrent (bool current)
 
entity::StrokegetStrokeCurrent () const
 
void setPolygonCurrent (entity::Polygon *poly)
 
void setPolygonCurrent (bool current)
 
entity::PolygongetPolygonCurrent () const
 
void setEntityCurrent (entity::ShaderedEntity2D *entity)
 
void setEntityCurrent (bool current)
 
template<typename EntityType >
EntityType * getEntityCurrent () const
 
void addEntitySelected (entity::Entity2D *entity)
 
void removeEntitySelected (entity::Entity2D *entity)
 
const std::vector< Entity2D * > & getEntitiesSelected () const
 
int getEntitiesSelectedSize () const
 
bool isEntitiesSelected () const
 
osg::Vec3f getEntitiesSelectedCenter3D () const
 
osg::Vec3f getEntitiesSelectedCenter2D () const
 
osg::Vec3f getCenter2D () const
 
osg::Vec3f getBoundingBoxCenter3D () const
 
osg::Vec3f getBoundingBoxCenter2D () const
 
osg::BoundingBox getBoundingBox () const
 
void moveEntities (std::vector< Entity2D *> &entities, double du, double dv)
 
void moveEntitiesSelected (double du, double dv)
 
void scaleEntities (std::vector< Entity2D *> &entities, double sx, double sy, osg::Vec3f center)
 
void scaleEntitiesSelected (double sx, double sy)
 
void rotateEntities (std::vector< entity::Entity2D *> entities, double theta, osg::Vec3f center)
 
void rotateEntitiesSelected (double theta)
 
void updateFrame (entity::Canvas *against=0)
 
const osg::Vec3Array * getFrameVertices () const
 
bool detachFrame ()
 
bool attachFrame ()
 
osg::Group * attachMeshGroup ()
 
bool disattachMeshGroup (osg::Group *group)
 
bool addToMeshGroup (osg::Group *group, osg::Node *mesh)
 
void setModeEdit (bool on)
 
void setFrameEditable (bool on)
 
bool getModeEdit () const
 
osg::Plane getPlane () const
 
entity::Canvasclone () const
 
entity::Canvasseparate ()
 
const entity::FrameToolgetToolFrame () const
 
unsigned int getNumEntities () const
 
unsigned int getNumPhotos () const
 
unsigned int getNumStrokes () const
 
unsigned int getNumPolygons () const
 
unsigned int getNumLineSegments () const
 
entity::PhotogetPhoto (int row) const
 
entity::StrokegetStroke (int i) const
 
entity::PolygongetPolygon (int i) const
 
entity::LineSegmentgetLineSegment (int i) const
 
entity::Entity2DgetEntity (unsigned int i) const
 
bool addEntity (entity::Entity2D *entity)
 
bool removeEntity (entity::Entity2D *entity)
 
bool containsEntity (entity::Entity2D *entity) const
 
void initializeProgramStroke ()
 
void initializeProgramPolygon ()
 
void initializeProgramLineSegment ()
 
- Public Member Functions inherited from osg::ProtectedGroup
 ProtectedGroup (const ProtectedGroup &group, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
 

Protected Member Functions

void setVisibilityFrame (bool vis)
 
bool getVisibilityFrame () const
 
bool getVisibilityData () const
 
void setVisibilityData (bool vis)
 
void updateTransforms ()
 
void resetTransforms ()
 
void setVertices (const osg::Vec3f &center, float szX, float szY, float szCr, float szAx)
 
void setVerticesDefault (const osg::Vec3f &center)
 
void setIntersection (entity::Canvas *against=0)
 

Detailed Description

Class description

Member Function Documentation

§ addEntity()

bool entity::Canvas::addEntity ( entity::Entity2D entity)

Method to add an entity to the canvas.

Parameters
entityis a pointer on the entity,
Returns
true if operation was successfull, false otherwise.

§ addEntitySelected()

void entity::Canvas::addEntitySelected ( entity::Entity2D entity)
Parameters
entityis entity to add to entity::SelectedGroup.

§ addToMeshGroup()

bool entity::Canvas::addToMeshGroup ( osg::Group *  group,
osg::Node *  mesh 
)

A method to add a stroke mesh to the selected mesh group as a child. Only to be used to prepare the user scene for exporting.

Parameters
groupis the mesh group which is already a child of a group data,
meshis the stroke mesh which will be added as a child to the group.
Returns
true if mesh was added sucessfully.

§ attachFrame()

bool entity::Canvas::attachFrame ( )

A method which is called when performing RootScene::writeScenetoFile to attach the frame tools back. The memory for tools is not freed since it is managed by a smart pointer (osg::ref_ptr).

See also
detachFrame

§ attachMeshGroup()

osg::Group * entity::Canvas::attachMeshGroup ( )

A method to be used only before calling on scene export function. It adds to the group data a new child - mesh group where all the stroke's meshes will be kept for export purposes.

Returns
pointer on the added mesh group.

§ clone()

entity::Canvas * entity::Canvas::clone ( ) const

Methor to perform a clone operation of canvas. It creates a new canvas that does not belong to the scene graph.

See also
separate()

§ containsEntity()

bool entity::Canvas::containsEntity ( entity::Entity2D entity) const
Parameters
entityis the pointer on entity,
Returns
true if the canvas contains given entity, false otherwise.

§ detachFrame()

bool entity::Canvas::detachFrame ( )

A method which is called when performing RootScene::writeScenetoFile to temporarly detach the frame tools. The memory for tools is not freed since it is managed by a smart pointer (osg::ref_ptr).

See also
detachFrame

§ disattachMeshGroup()

bool entity::Canvas::disattachMeshGroup ( osg::Group *  group)

A methog to be used only after calling on scene export function. It removed the mesh group as a child of group data, thus deleting the whole structure.

Returns
true if deletion was successfull.

§ getBoundingBox()

osg::BoundingBox entity::Canvas::getBoundingBox ( ) const
Returns
a bounding box of the whole canvas.

§ getBoundingBoxCenter2D()

osg::Vec3f entity::Canvas::getBoundingBoxCenter2D ( ) const
Returns
local 2D center which is calculated based on bounding box of the whole canvas.

§ getBoundingBoxCenter3D()

osg::Vec3f entity::Canvas::getBoundingBoxCenter3D ( ) const
Returns
global 3D mean center of canvas; used as a default rotation point when rotating the canvas.

§ getCenter()

const osg::Vec3f & entity::Canvas::getCenter ( ) const
Returns
virtual canvas' 3D center.
See also
getCenter2D()

§ getCenter2D()

osg::Vec3f entity::Canvas::getCenter2D ( ) const
Returns
local 2D center of canvas.
See also
getCenter()

§ getCenter3D()

osg::Vec3f entity::Canvas::getCenter3D ( ) const

§ getColor()

const osg::Vec4f & entity::Canvas::getColor ( ) const
Returns
color of canvas frame.
See also
setColor

§ getEntitiesSelected()

const std::vector< entity::Entity2D *> & entity::Canvas::getEntitiesSelected ( ) const
Returns
vector of pointers on selected entities within the canvas.

§ getEntitiesSelectedCenter2D()

osg::Vec3f entity::Canvas::getEntitiesSelectedCenter2D ( ) const
Returns
local 2D center of SelectedGroup.

§ getEntitiesSelectedCenter3D()

osg::Vec3f entity::Canvas::getEntitiesSelectedCenter3D ( ) const
Returns
global 3D center of SelectedGroup. If the group is empty, returns global 3D canvas center.

§ getEntitiesSelectedSize()

int entity::Canvas::getEntitiesSelectedSize ( ) const
Returns
a number of selelcted entities within the canvas.

§ getEntity()

entity::Entity2D * entity::Canvas::getEntity ( unsigned int  i) const

Method to iterate throught all the entities: both strokes and photos

Parameters
iis the index of desired entity
Returns
const pointer on entity.

§ getFrameVertices()

const osg::Vec3Array * entity::Canvas::getFrameVertices ( ) const
Returns
4 coordinates of canvas frame vertices.

§ getGeometryPickable()

const osg::Geometry * entity::Canvas::getGeometryPickable ( ) const
Returns
a pointer on a pickage geometry, to be used from EventHandler.

§ getGlobalAxisU()

osg::Vec3f entity::Canvas::getGlobalAxisU ( ) const

V | |____ U / normal

Returns
direction of U axis in global space.
See also
getGlobalAxisV()

§ getGlobalAxisV()

osg::Vec3f entity::Canvas::getGlobalAxisV ( ) const

V | |____ U / normal

Returns
direction of V axis in global space.
See also
getGlobalAxisU()

§ getMatrix()

osg::Matrix entity::Canvas::getMatrix ( ) const
Returns
model matrix of the canvas, i.e., local to global matrix.

§ getMatrixInverse()

osg::Matrix entity::Canvas::getMatrixInverse ( ) const
Returns
an inverse of model matrix of the canvas, i.e., a global to local matrix.

§ getModeEdit()

bool entity::Canvas::getModeEdit ( ) const
Returns
canvas edit mode.
See also
setModeEdit()

§ getNumEntities()

unsigned int entity::Canvas::getNumEntities ( ) const
Returns
total number of entities like strokes and photos that canvas contains.

§ getNumPhotos()

unsigned int entity::Canvas::getNumPhotos ( ) const
Returns
total number of photos that canvas contains.

§ getNumPolygons()

unsigned int entity::Canvas::getNumPolygons ( ) const
Returns
total number of polygons that canvas contains

§ getNumStrokes()

unsigned int entity::Canvas::getNumStrokes ( ) const
Returns
total number of strokes that canvas contains.

§ getPhoto()

entity::Photo * entity::Canvas::getPhoto ( int  row) const
Returns
pointer on a photo with the given index.

§ getPlane()

osg::Plane entity::Canvas::getPlane ( ) const
Returns
plane equation based on canvas center and normal

§ getPolygon()

entity::Polygon * entity::Canvas::getPolygon ( int  i) const
Returns
non-const pointer on a polygon with the given index

§ getPolygonCurrent()

entity::Polygon * entity::Canvas::getPolygonCurrent ( ) const
Returns
a pointer on current polygon, editable, for example, to append a point to the polygon.

§ getStroke()

entity::Stroke * entity::Canvas::getStroke ( int  i) const
Returns
pointer on a stroke with the given index

§ getStrokeCurrent()

entity::Stroke * entity::Canvas::getStrokeCurrent ( ) const
Returns
a pointer on current stroke, editable, for example, to append a point to the stroke.

§ getToolFrame()

const entity::FrameTool * entity::Canvas::getToolFrame ( ) const
Returns
pointer on FrameTool of canvas

§ getVisibilityAll()

bool entity::Canvas::getVisibilityAll ( ) const
Returns
canvas content visibility flag.
See also
setVisibilityAll().

§ getVisibilityFrameInternal()

bool entity::Canvas::getVisibilityFrameInternal ( ) const
Returns
tool frame visibility.
See also
setVisibilityFrameInternal().

§ initializeMasks()

void entity::Canvas::initializeMasks ( )
virtual

Method is called automatically from initializeSG(), or must be called when reading scene from file.

§ initializeSG()

void entity::Canvas::initializeSG ( )
virtual

Method to initialize canvases' geometrical properties. Must be called each time a canvas is allocated.

§ initializeStateMachine()

void entity::Canvas::initializeStateMachine ( )
virtual

Method is called automatically from initializeSG() to initialize OpenGL state machine or when reading scene from file.

§ initializeTools()

void entity::Canvas::initializeTools ( )
virtual

Method is either called automatically when running initializeSG or when reading scene from file.

§ isEntitiesSelected()

bool entity::Canvas::isEntitiesSelected ( ) const
Returns
true if there are any entitie in SelectedGroup, false if the group is empty.

§ moveEntities()

void entity::Canvas::moveEntities ( std::vector< Entity2D *> &  entities,
double  du,
double  dv 
)
Parameters
entitiesis the vector of entities to move,
duis delta-u local 2D coordinate,
dvis delta-V local 2D coordinate.
See also
moveEntitiesSelected()

§ moveEntitiesSelected()

void entity::Canvas::moveEntitiesSelected ( double  du,
double  dv 
)
Parameters
duis delta-u local 2D coordinate,
dvis delta-V local 2D coordinate.
See also
moveEntitiesSelected().
moveEntities()

§ removeEntity()

bool entity::Canvas::removeEntity ( entity::Entity2D entity)

Method to remove an entity from the canvas.

Parameters
entityis a pointer on the entity,
Returns
true if operation was successfull, false otherwise.

§ removeEntitySelected()

void entity::Canvas::removeEntitySelected ( entity::Entity2D entity)
Parameters
entityis entity to substract from entity::SelectedGroup.

§ rotate()

void entity::Canvas::rotate ( const osg::Matrix &  mr,
const osg::Vec3f &  c3d_new 
)

A method to rotate canvas parameters.

Parameters
mris the rotation matrix,
c3d_newis the point in 3D global space aroung which the rotation is performed.

§ rotateEntities()

void entity::Canvas::rotateEntities ( std::vector< entity::Entity2D *>  entities,
double  theta,
osg::Vec3f  center 
)
Parameters
entitiesis the vector of entities to rotate,
thetais angle of rotation,
centerthe rotation local 2D center
See also
rotateEntitiesSelected()

§ rotateEntitiesSelected()

void entity::Canvas::rotateEntitiesSelected ( double  theta)
Parameters
thetais angle of rotation.
See also
rotateEntities()

§ scaleEntities()

void entity::Canvas::scaleEntities ( std::vector< Entity2D *> &  entities,
double  sx,
double  sy,
osg::Vec3f  center 
)
Parameters
entitiesis the vector of entities to scale,
sxis scale along X axis,
syis scale along Y axis,
centeris 2D center along which the scaling is performed.
See also
scaleEntitiesSelected()

§ scaleEntitiesSelected()

void entity::Canvas::scaleEntitiesSelected ( double  sx,
double  sy 
)
Parameters
sxis scale along X axis,
syis scale along Y axis,
See also
scaleEntities()

§ selectAllEntities()

void entity::Canvas::selectAllEntities ( )

Method that adds all the entities of current canvas to entity::SelectedGroup.

See also
unselectEntities()

§ separate()

entity::Canvas * entity::Canvas::separate ( )

Method to clone the canvas with inclusion of selected entities into the new canvas. A created canvas does not belong the scene graph.

See also
clone()

§ setColor()

void entity::Canvas::setColor ( const osg::Vec4f &  color,
const osg::Vec4f &  colorIntersection = cher::CANVAS_CLR_PREVIOUS 
)

A method to set up canvas frame color.

See also
getColor

§ setFrameEditable()

void entity::Canvas::setFrameEditable ( bool  on)

Method to change canvas frame appereance to the editable frame.

Parameters
onis true when the canvas is about to be edited, false otherwise.
See also
setModeEdit().

§ setModeEdit()

void entity::Canvas::setModeEdit ( bool  on)

Method to switch the normal canvas mode to edit mode, used for editing canvas position and rotation.

Parameters
onis true when the canvas is in the process of editing, and false otherwise.
See also
setFrameEditable().

§ setPolygonCurrent() [1/2]

void entity::Canvas::setPolygonCurrent ( entity::Polygon poly)
Parameters
polyis the polygon to mark as current, i.e., for a continious editing and point addition.

§ setPolygonCurrent() [2/2]

void entity::Canvas::setPolygonCurrent ( bool  current)
Parameters
currentis a boolean variable; if false then an observer point on current polygon turns NULL.

§ setStrokeCurrent() [1/2]

void entity::Canvas::setStrokeCurrent ( entity::Stroke stroke)
Parameters
strokeis the stroke to mark as current, i.e., for a continious editing and point addition.

§ setStrokeCurrent() [2/2]

void entity::Canvas::setStrokeCurrent ( bool  current)
Parameters
currentis a boolean variable; if false then an observer point on current stroke turns NULL.

§ setVisibilityAll()

void entity::Canvas::setVisibilityAll ( bool  vis)

A method to set up canvas content visibility (groupData and frameTool).

Parameters
visis true for visible and false for invisible.

§ setVisibilityFrameInternal()

void entity::Canvas::setVisibilityFrameInternal ( bool  vis)

A method to set up tool frame visibility.

Parameters
visis true for visible and false for invisible

§ translate()

void entity::Canvas::translate ( const osg::Matrix &  mt)

A method to translate canvas parameters.

Parameters
mtis the translation matrix.

§ unselectAll()

void entity::Canvas::unselectAll ( )

Convinience method that is normally used before changing a canvas status, e.g. from current to previous. It deselects SelectedGroup, as well as current stroke.

§ unselectEntities()

void entity::Canvas::unselectEntities ( )

Method that removes all entities from entity::SelectedGroup.

See also
selectAllEntities()

§ updateFrame()

void entity::Canvas::updateFrame ( entity::Canvas against = 0)

Method to re-calculate frame's geometry and plane center transform based on canvas content location.

Parameters
againstis a Canvas against which an intersection is calculated. Normally it is UserScene::m_canvasPrevious.

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