cherish
Public Slots | Signals | Public Member Functions | Protected Member Functions | Friends | List of all members
entity::UserScene Class Reference

The UserScene class contains scene graph that was created by user, including the construction tools. More...

#include <UserScene.h>

Inheritance diagram for entity::UserScene:
osg::ProtectedGroup

Public Slots

void onItemChanged (QTreeWidgetItem *item, int column)
 
void onClicked (const QModelIndex &index)
 
void onRightClicked (const QModelIndex &index)
 

Signals

void sendRequestUpdate ()
 
void canvasAdded (const std::string &name)
 
void photoAdded (const std::string &name, int idxCanvas)
 
void canvasRemoved (int row)
 
void photoRemoved (int rowCanvas, int rowPhoto)
 
void canvasSelectedColor (int row, int color)
 
void canvasVisibilitySet (int row, bool visibility)
 
void requestSceneToolStatus (bool &visibility)
 
void requestCanvasCreate (const osg::Vec3f &eye, const osg::Vec3f &center, const osg::Vec3f &up)
 

Public Member Functions

 UserScene ()
 
 UserScene (const UserScene &scene, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
 
 META_Node (entity, UserScene) void initializeSG()
 
void setGroupCanvases (osg::Group *group)
 
const osg::Group * getGroupCanvases () const
 
void setBookmarks (entity::Bookmarks *group)
 
const entity::BookmarksgetBookmarks () const
 
entity::BookmarksgetBookmarksModel () const
 
void setIdCanvas (unsigned int id)
 
unsigned int getIdCanvas () const
 
void setIdPhoto (unsigned int id)
 
unsigned int getIdPhoto () const
 
void setIdBookmark (unsigned int id)
 
unsigned int getIdBookmark () const
 
void setFilePath (const std::string &name)
 
const std::string & getFilePath () const
 
bool isSetFilePath () const
 
void addCanvas (QUndoStack *stack, const osg::Matrix &R, const osg::Matrix &T)
 
void addCanvas (QUndoStack *stack, const osg::Vec3f &normal, const osg::Vec3f &center)
 
void addCanvas (QUndoStack *stack, const osg::Matrix &R, const osg::Matrix &T, const std::string &name)
 
void addStroke (QUndoStack *stack, float u, float v, cher::EVENT event)
 
void addPolygon (QUndoStack *stack, float u, float v, cher::EVENT event)
 
void addLineSegment (QUndoStack *stack, float u, float v, cher::EVENT event)
 
void addPhoto (QUndoStack *stack, const std::string &fname)
 
void addBookmark (BookmarkWidget *widget, const osg::Vec3d &eye, const osg::Vec3d &center, const osg::Vec3d &up, const double &fov)
 
void updateBookmark (BookmarkWidget *widget, int row)
 
void deleteBookmark (BookmarkWidget *widget, const QModelIndex &index)
 
void eraseStroke (QUndoStack *stack, entity::Stroke *stroke, int first, int last, cher::EVENT event)
 
entity::CanvasgetCanvas (unsigned int id)
 
entity::CanvasgetCanvas (const std::string &name)
 
int getStrokeLevel () const
 
int getCanvasLevel () const
 
int getPhotoLevel () const
 
bool setCanvasCurrent (entity::Canvas *cnv)
 
bool setCanvasPrevious (entity::Canvas *cnv)
 
void setCanvasesButCurrent (bool enabled)
 
void setAllCanvases (bool enabled)
 
bool getCanvasesButCurrent () const
 
entity::CanvasgetCanvasCurrent () const
 
entity::CanvasgetCanvasPrevious () const
 
int getCanvasIndex (entity::Canvas *canvas) const
 
int getPhotoIndex (entity::Photo *photo, entity::Canvas *canvas) const
 
entity::CanvasgetCanvasFromIndex (int row)
 
entity::PhotogetPhoto (entity::Canvas *canvas, int row)
 
int getNumCanvases () const
 
int getNumPhotos (entity::Canvas *canvas) const
 
int getNumPhotos ()
 
int getNumPhotosTill (entity::Canvas *canvas)
 
void editCanvasOffset (QUndoStack *stack, const osg::Vec3f &translate, cher::EVENT event)
 
void editCanvasRotate (QUndoStack *stack, const osg::Quat &rotation, const osg::Vec3f &center3d, cher::EVENT event)
 
void editCanvasClone (QUndoStack *stack, const osg::Vec3f &translate, cher::EVENT event)
 
void editCanvasSeparate (QUndoStack *stack, const osg::Vec3f &translate, cher::EVENT event)
 
void editCanvasDelete (QUndoStack *stack, entity::Canvas *canvas)
 
void editPhotoDelete (QUndoStack *stack, entity::Photo *photo, entity::Canvas *canvas)
 
void editPhotoPush (QUndoStack *stack, entity::Photo *photo, entity::Canvas *source, entity::Canvas *destination)
 
void editPhotoTransparency (entity::Photo *photo, entity::Canvas *canvas, float t)
 
void editPolygonDelete (QUndoStack *stack, entity::Polygon *poly, entity::Canvas *canvas)
 
void editStrokesPush (QUndoStack *stack, osg::Camera *camera)
 
void editStrokesMove (QUndoStack *stack, double u, double v, cher::EVENT event)
 
void editStrokesScale (QUndoStack *stack, double u, double v, cher::EVENT event)
 
void editStrokesRotate (QUndoStack *stack, double u, double v, cher::EVENT event)
 
void editStrokeDelete (QUndoStack *stack, entity::Stroke *stroke)
 
void editEntity2DDelete (QUndoStack *stack, entity::Entity2D *entity)
 
void editSelectedEntitiesDelete (QUndoStack *stack)
 
bool isEntityCurrent () const
 
bool isEmptyScene () const
 
bool clearUserData ()
 
void updateWidgets ()
 
void resetModel (CanvasPhotoWidget *widget)
 
- Public Member Functions inherited from osg::ProtectedGroup
 ProtectedGroup (const ProtectedGroup &group, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
 

Protected Member Functions

std::string getCanvasName ()
 
std::string getPhotoName ()
 
std::string getBookmarkName ()
 
std::string getEntityName (const std::string &name, unsigned int id) const
 
void strokeStart ()
 
void strokeAppend (float u, float v)
 
void strokeFinish (QUndoStack *stack)
 
bool strokeValid () const
 
void polygonStart ()
 
void polygonAppend (float u, float v, QUndoStack *stack)
 
void polygonEdit (float u, float v)
 
void polygonFinish (QUndoStack *stack)
 
bool polygonValid () const
 
void linesegmentStart ()
 
void linesegmentAppend (float u, float v, QUndoStack *stack)
 
void linesegmentEdit (float u, float v)
 
void linesegmentFinish (QUndoStack *stack)
 
bool linesegmentValid () const
 
void entitiesMoveStart (double u, double v)
 
void entitiesMoveAppend (double u, double v)
 
void entitiesMoveFinish (QUndoStack *stack)
 
bool entitiesSelectedValid () const
 
void entitiesScaleStart (double u, double v)
 
void entitiesScaleAppend (double u, double v)
 
void entitiesScaleFinish (QUndoStack *stack)
 
void entitiesRotateStart (double u, double v)
 
void entitiesRotateAppend (double u, double v)
 
void entitiesRotateFinish (QUndoStack *stack)
 
void eraseStart (entity::Stroke *stroke, osg::Vec3d &hit)
 
void eraseAppend (entity::Stroke *stroke, osg::Vec3d &hit)
 
void eraseFinish (QUndoStack *stack, entity::Stroke *stroke)
 
bool eraseValid (entity::Stroke *stroke) const
 
void canvasOffsetStart ()
 
void canvasOffsetAppend (const osg::Vec3f &t)
 
void canvasOffsetFinish (QUndoStack *stack)
 
bool canvasEditValid () const
 
void canvasCloneStart ()
 
void canvasCloneAppend (const osg::Vec3f &t)
 
void canvasCloneFinish (QUndoStack *stack)
 
bool canvasCloneValid () const
 
void canvasSeparateStart ()
 
void canvasSeparateAppend (const osg::Vec3f &t)
 
void canvasSeparateFinish (QUndoStack *stack)
 
void canvasRotateStart ()
 
void canvasRotateAppend (const osg::Quat &r, const osg::Vec3f &center3d)
 
void canvasRotateFinish (QUndoStack *stack)
 
bool addCanvas (entity::Canvas *canvas)
 
bool removeCanvas (entity::Canvas *canvas)
 
bool addEntity (entity::Canvas *canvas, entity::Entity2D *entity)
 
bool removeEntity (entity::Canvas *canvas, entity::Entity2D *entity)
 

Friends

class ::fur::AddCanvasCommand
 
class ::fur::AddPhotoCommand
 
class ::fur::EditCanvasDeleteCommand
 
class ::fur::AddCanvasSeparationCommand
 
class ::fur::EditPhotoDeleteCommand
 
class ::fur::EditEntityDeleteCommand
 
class ::fur::AddStrokeCommand
 
class ::fur::AddPolygonCommand
 
class ::fur::AddEntityCommand
 
class ::fur::AddLineSegmentCommand
 
class ::fur::EditStrokesPushCommand
 
class ::fur::EditStrokeDeleteCommand
 
class ::fur::EditPasteCommand
 
class ::fur::EditCutCommand
 
class ::fur::EditPhotoPushCommand
 
class ::fur::EditSelectedEntitiesDeleteCommand
 

Detailed Description

The UserScene class contains scene graph that was created by user, including the construction tools.

The children of the UserScene are the canvases. One of the children is the Bookmarks group. The class also contains observer pointers to the current, previous and clone canvases. Normally, the clone canvas is NULL pointer, unless the user is in the process of creating a canvas by clonning or separation procedures.

The Bookmarks child can be put at any position as a child, but it's the only child. It is inserted when the user creates the first bookmark of the scene. Here is an example of possible user scene structure:

UserScene -> groupCanvas -> Canvas0      [previous]
          |             |-> Canvas1
          |             |-> Canvas2      [current]
          |             |-> ... (other canvases)
          |-> groupBookmarks -> SceneState0  [ bookmark0 ] -> SVMData
                            |-> SceneState1  [ bookmark1 ]

The UserScene inherits osg::Group and QObject. The osg::Group is necessary for a scene graph representation, while QObject allows for signal and slots functionality. Most of the signal and slots are connected with MainWindow. The inheritance sequence is important: multiple inheritance requires QObject to be first. For more details on this, see: http://www.setnode.com/blog/qt-staticmetaobject-is-not-a-member-of/

Constructor & Destructor Documentation

§ UserScene() [1/2]

entity::UserScene::UserScene ( )

Default constructor. This is the constructor to use within the application.

§ UserScene() [2/2]

entity::UserScene::UserScene ( const UserScene scene,
const osg::CopyOp &  copyop = osg::CopyOp::SHALLOW_COPY 
)

Copy constructor which is required for OSG serialiazation functionality. It should never be used as-is within the application.

Parameters
sceneis the scene to copy
copyopis the copy method, i.e. shallow vs. deep copy

Member Function Documentation

§ addBookmark()

void entity::UserScene::addBookmark ( BookmarkWidget widget,
const osg::Vec3d &  eye,
const osg::Vec3d &  center,
const osg::Vec3d &  up,
const double &  fov 
)

Creates and adds a bookmark to the Bookmarks group and the corresponding BookmarkWidget by asigning to it an automatic name.

Parameters
widgetis the BookmarkWidget which is connected to the Bookmarks data structure
eyeis the vector of camera eye to add as a bookmark
centeris the vector of camera center to add as a bookmark
upis the vector of camera up to add as a bookmark
fovis the camera's projection matrix FOV

§ addCanvas() [1/3]

void entity::UserScene::addCanvas ( QUndoStack *  stack,
const osg::Matrix &  R,
const osg::Matrix &  T 
)

Creates and adds a Canvas as a child to the UserScene through undo/redo framework by assigning it an automatic name.

Parameters
stackis the undo/redo stack where the fur::AddCanvasCommand will be pushed to
Ris the rotation matrix of the new canvas
Tis the transtaltion matrix of the new canvas

§ addCanvas() [2/3]

void entity::UserScene::addCanvas ( QUndoStack *  stack,
const osg::Vec3f &  normal,
const osg::Vec3f &  center 
)

Creates and adds a Canvas as a child to the UserScene through undo/redo framework by asigning it an automatic name.

Parameters
stackis the undo/redo stack where the fur::AddCanvasCommand will be pushed to
normalis the normal of the new canvas
centeris the center location of the new canvas

§ addCanvas() [3/3]

void entity::UserScene::addCanvas ( QUndoStack *  stack,
const osg::Matrix &  R,
const osg::Matrix &  T,
const std::string &  name 
)

Creates and adds a Canvas as a child to the UserScene through undo/redo framework. This method is normally called by UserScene::addCanvas(QUndoStack*, const osg::Matrix&, const osg::Matrix&).

Parameters
stackis the undo/redo stack where the fur::AddCanvasCommand will be pushed to
Ris the rotation matrix of the new canvas
Tis the transtaltion matrix of the new canvas
nameis the canvas name

§ addLineSegment()

void entity::UserScene::addLineSegment ( QUndoStack *  stack,
float  u,
float  v,
cher::EVENT  event 
)

Add a point to a current line segment of the current canvas through undo/redo framework.

Parameters
stackis the undo/redo stack where the commend will be pushed to,
uis the local canvas U-coordinate of the segment,
vis the local canvas V-coordinate of the segment,
eventis the current mouse state: click, move or release.
See also
addStroke().

§ addPhoto()

void entity::UserScene::addPhoto ( QUndoStack *  stack,
const std::string &  fname 
)

Creates and adds a photo to a current canvas through undo/redo framework by asigning to it an automatic name.

Parameters
stackis the undo/redo stack where the fur::AddPhotoCommand will be pushed to
fnameis the photo file path from where it is loaded

§ addPolygon()

void entity::UserScene::addPolygon ( QUndoStack *  stack,
float  u,
float  v,
cher::EVENT  event 
)

Adds a point to a current polygon of the current canvas through undo/redo framework.

Parameters
stackis the undo/redo stack where the fur::AddStrokeCommand will be pushed to
uis the local canvas U-coordinate of the stroke point [u, v] to append to Canvas::m_strokeCurrent
vis the local canvas V-coordinate of the stroke point [u, v] to append to Canvas::m_strokeCurrent
eventis the current mouse state: click, drag or release
See also
addStroke()

§ addStroke()

void entity::UserScene::addStroke ( QUndoStack *  stack,
float  u,
float  v,
cher::EVENT  event 
)

Adds a point to a current stroke of the current canvas through undo/redo framework. If there is no current stroke exists, it creates it.

Parameters
stackis the undo/redo stack where the fur::AddStrokeCommand will be pushed to
uis the local canvas U-coordinate of the stroke point [u, v] to append to Canvas::m_strokeCurrent
vis the local canvas V-coordinate of the stroke point [u, v] to append to Canvas::m_strokeCurrent
eventis the current mouse state: click, drag or release
See also
addPolygon()

§ canvasAdded

void entity::UserScene::canvasAdded ( const std::string &  name)
signal

A signal which is connected with CanvasPhotoWidget::onCanvasAdded() to request to add a canvas item to the widget

§ canvasRemoved

void entity::UserScene::canvasRemoved ( int  row)
signal

A signal which is connected with CanvasPhotoWidget::onCanvasRemoved() to request to remove a canvas item from the widget

§ canvasSelectedColor

void entity::UserScene::canvasSelectedColor ( int  row,
int  color 
)
signal

A signal which is connected with CanvasPhotoWidget::onCanvasSelectedColor() to request to update color indications for a certain canvas, e.g., when switching the canvas status from normal to current, or from current to previous.

§ canvasVisibilitySet

void entity::UserScene::canvasVisibilitySet ( int  row,
bool  visibility 
)
signal

A signal which is connected with CanvasPhotoWidget and is called from RootScene when the scene is loaded from file. It is to provide a back feedback from scene to the widget and it triggers the setting of the visibility icon ("open" or "closed" eye) which is related to the corresponding canvas.

Parameters
rowis the sequential canvas index as it is in the canvas-photo widget
visibilityis the boolean variable indicating whether the canvas is visible on the scene (true) or not (false). This value also corresponds to Canvas::getVisibilityData().

§ clearUserData()

bool entity::UserScene::clearUserData ( )

A method to clear all the user data from scene graph: canvases, bookmarks and their contents.

Returns
Whether the operation was successfull (true) or not (false).

§ deleteBookmark()

void entity::UserScene::deleteBookmark ( BookmarkWidget widget,
const QModelIndex &  index 
)

Deletes the bookmark from Bookmarks data strucure as well as BookmarkWidget.

Parameters
widgetis the BookmarkWidget which is connected to the Bookmarks data structure
indexis the bookmark id number

§ editCanvasClone()

void entity::UserScene::editCanvasClone ( QUndoStack *  stack,
const osg::Vec3f &  translate,
cher::EVENT  event 
)

The method is to create a new canvas by clonning a current canvas and then translating the newly created canvas along its normal. While in the clonning mode, three mouse modes make different states of creation:

  • click performs an actual clone
  • drag allows user to chose the new position of the cloned canvas
  • release fixes the position and pushes the cloned canvas to undo/redo stack
Parameters
stackis the command stack for undo/redo framework
translateis the 3D difference vector which indicates translation along the canvas normal from previous canvas position
eventis to indicate a mouse state: clicked, dragged or released
See also
canvasCloneStart(), canvasCloneAppend(), canvasCloneFinish()
editCanvasSeparate()

§ editCanvasDelete()

void entity::UserScene::editCanvasDelete ( QUndoStack *  stack,
entity::Canvas canvas 
)
Parameters
stackis the command stack for undo/redo framework
canvasis the canvas to delete from UserScene

§ editCanvasOffset()

void entity::UserScene::editCanvasOffset ( QUndoStack *  stack,
const osg::Vec3f &  translate,
cher::EVENT  event 
)

The method is to edit the canvas 3D position, offset in particular. The offset is defined as a non-zero distance along the canvas normal in either positive or negative direction.

Parameters
stackis the command stack for undo/redo framework
translateis the 3D difference vector which indicates translation along the canvas normal from previous canvas position
eventis to indicate a mouse state: clicked, dragged or released
See also
canvasOffsetStart(), canvasOffsetAppend(), canvasOffsetFinish()

§ editCanvasRotate()

void entity::UserScene::editCanvasRotate ( QUndoStack *  stack,
const osg::Quat &  rotation,
const osg::Vec3f &  center3d,
cher::EVENT  event 
)

The method is to edit the canvas 3D position, by means of rotation. The rotation is defined as a quat which was performed along either local U or local V Canvas axis.

Parameters
stackis the command stack for undo/redo framework
rotationis the quat which indicates rotation from the previous canvas position
center3dis a 3D global point along which the rotation is performed (as of v0.4.0 this value is represented by a Canvas::m_center and is fixed)
eventis to indicate a mouse state: clicked, dragged or released
See also
canvasRotateStart(), canvasRotateAppend(), canvasRotateFinish()

§ editCanvasSeparate()

void entity::UserScene::editCanvasSeparate ( QUndoStack *  stack,
const osg::Vec3f &  translate,
cher::EVENT  event 
)

Similar to editCanvasClone(), the method creates a new canvas by performing separation (not clonning). By separation it is meant a cut and paste of selected strokes into the new Canvas. While in the separation mode, three mouse modes make different states of separation:

  • click to perform an actual separation
  • drag to position the newly created canvas in 3D space
  • release to fix the canvas position and to push the separation operation into undo/redo stack
Parameters
stackis the command stack for undo/redo framework
translateis the 3D difference vector which indicates translation along the canvas normal
eventis to indicate a mouse state: clicked, dragged or released
See also
canvasSeparateStart(), canvasSeparateAppend(), canvasSeparateFinish()
editCanvasClone()

§ editPhotoDelete()

void entity::UserScene::editPhotoDelete ( QUndoStack *  stack,
entity::Photo photo,
entity::Canvas canvas 
)
Parameters
stackis the command stack for undo/redo framework
photois the photo to delete
canvasis the canvas from which the photo will be deleted

§ editPhotoPush()

void entity::UserScene::editPhotoPush ( QUndoStack *  stack,
entity::Photo photo,
entity::Canvas source,
entity::Canvas destination 
)

The method is to transfer a photo from one canvas to another. As of v0.4.0 it is in development and advised not to be used for time being; have to fix the syncronization with CanvasPhotoWidget

Parameters
stackis the command stack for undo/redo framework
photois the photo to move
sourceis the canvas from where the photo will be removed
destinationis the canvas to where to photo will be moved

§ editPhotoTransparency()

void entity::UserScene::editPhotoTransparency ( entity::Photo photo,
entity::Canvas canvas,
float  t 
)

This method changes transparency level within scene graph and across bookmarks' scene states.

Parameters
photois the photo to edit
canvasis the canvas to which the photo belongs to
tis the new transparency level, in range from 0 to 1.

§ editPolygonDelete()

void entity::UserScene::editPolygonDelete ( QUndoStack *  stack,
entity::Polygon poly,
entity::Canvas canvas 
)

A method to remove polygon from the canvas and write this operarion onto undo/redo framework.

§ editSelectedEntitiesDelete()

void entity::UserScene::editSelectedEntitiesDelete ( QUndoStack *  stack)

A method to delete all the entities of the current canvas that are being selected.

§ editStrokeDelete()

void entity::UserScene::editStrokeDelete ( QUndoStack *  stack,
entity::Stroke stroke 
)

The method is to delete a specified stroke.

Parameters
stackis the command stack for undo/redo framework
strokeis a stroke to delete from scene

§ editStrokesMove()

void entity::UserScene::editStrokesMove ( QUndoStack *  stack,
double  u,
double  v,
cher::EVENT  event 
)

The method is to perform a movement of a set of strokes within a canvas. That is, it can be considered as a 2D local move.

Parameters
stackis the command stack for undo/redo framework
uis the local U coordinate where the center of strokes [u, v] will be moved to
vis the local V coordinate where the center of strokes [u, v] will be moved to
eventis to indicate a mouse state: clicked, dragged or released
See also
editStrokesRotate(), editStrokesScale()

§ editStrokesPush()

void entity::UserScene::editStrokesPush ( QUndoStack *  stack,
osg::Camera *  camera 
)

The method is to transfer a set of strokes from current canvas to previous. The transfer is projective, i.e. under given camera view the whole sketching image does not change, although the set of strokes now belongs to the previous canvas.

Parameters
stackis the command stack for undo/redo framework
camerais the camera pointer that contains current camera parameters (eye, center, up)

§ editStrokesRotate()

void entity::UserScene::editStrokesRotate ( QUndoStack *  stack,
double  u,
double  v,
cher::EVENT  event 
)

The method is to perform a rotation of a set of strokes within a canvas. That is, it can be considered as a 2D local rotation.

Parameters
stackis the command stack for undo/redo framework
uis the local U coordinate where the local axis [u, v] will be rotated to
vis the local V coordinate where local axis [u, v] will be rotated to
eventis to indicate a mouse state: clicked, dragged or released
See also
editStrokesMove(), editStrokesScale()

§ editStrokesScale()

void entity::UserScene::editStrokesScale ( QUndoStack *  stack,
double  u,
double  v,
cher::EVENT  event 
)

The method is to perform a uniform scaling of a set of strokes within a canvas.

Parameters
stackis the command stack for undo/redo framework
uis the local U coordinate where the bounding box point [u, v] will be moved to
vis the local V coordinate where the bounding box point [u, v] will be moved to
eventis to indicate a mouse state: clicked, dragged or released
See also
editStrokesMove(),
editStrokesRotate()

§ eraseStroke()

void entity::UserScene::eraseStroke ( QUndoStack *  stack,
entity::Stroke stroke,
int  first,
int  last,
cher::EVENT  event 
)

This method is in development and must not be used as it is now (v0.4.0). The main idea is to erase some points from a stroke (eraser functionality)

Parameters
stack
strokeis the stroke from which to erase
firstis the first index of interval of points to remove
lastis the last index of interval of points to remove
eventis event for pressed, dragged or released

§ getCanvas() [1/2]

entity::Canvas * entity::UserScene::getCanvas ( unsigned int  id)

Gets a pointer to a Canvas based on UserScene child index. This method is useful when, for example, we need to iterate through all the canvases of UserScene.

for (int i=0; i<scene->getNumCanvases(); ++i){
entity::Canvas* canvas = scene->getCanvas(i);
// do stuff with canvas
}
Parameters
idis the UserScene child index_sequence
Returns
a pointer on Canvas under the given index

§ getCanvas() [2/2]

entity::Canvas * entity::UserScene::getCanvas ( const std::string &  name)

Gets a pointer to a Canvas based on name match. Use with caution: in case if there are two or more canvases with the same name, it will return the first found child which name matches the given string.

Parameters
nameis the name to match
Returns
a pointer on a first found child with the matched name, or NULL if no such child is found.

§ getCanvasCurrent()

entity::Canvas * entity::UserScene::getCanvasCurrent ( ) const
Returns
A pointer on current canvas, editable.

§ getCanvasesButCurrent()

bool entity::UserScene::getCanvasesButCurrent ( ) const
Returns
The state of traversal masks of all the canvases except the current. True indicates the traversal masks are on (traversal is performed), false indicated the traversal masks are off.
See also
setCanvasesButCurrent(),
EventHandler::setMode()

§ getCanvasFromIndex()

entity::Canvas * entity::UserScene::getCanvasFromIndex ( int  row)

A method to return a Canvas pointer given sequential index within CanvasPhotoWidget. Returns a child of UserScene as a Canvas with given sequential index, taking Bookmarks group into consideration.

Parameters
rowis the sequential index as is in CanvasPhotoWidget
Returns
Canvas pointer of the index.
See also
getCanvasIndex()

§ getCanvasIndex()

int entity::UserScene::getCanvasIndex ( entity::Canvas canvas) const

A method to return a sequential index of Canvas pointer. Normally, the index is aligned with child index of UserScene, however, it is not always the case since one of the children is Bookmarks group. The method is frequently used when we need to obtain the index number to deal with CanvasPhotoWidget entries. Example of methods that use it are: setting canvas as current / previous; model resetting, adding new canvas and photo addition and removal.

Parameters
canvasis the pointer on Canvas
Returns
index of the Canvas as is in CanvasPhotoWidget
See also
getCanvasFromIndex()

§ getCanvasLevel()

int entity::UserScene::getCanvasLevel ( ) const

Returns a level of Canvas within the whole scene graph, starting from the RootScene. It is used from EventHandler when using intersectors. The return value is defined manually, therefore it is important to keep them updated in case if scene graph is dramatically re-designed. The level for the Canvas is defined:

RootScene -> UserScene -> UserScene::m_groupCanvases -> Canvas

   [1]        [2]                [3]                     [4]
Returns
a deepness level of Canvas from the RootScene.

§ getCanvasPrevious()

entity::Canvas * entity::UserScene::getCanvasPrevious ( ) const
Returns
A pointer on previous canvas, editable.

§ getNumCanvases()

int entity::UserScene::getNumCanvases ( ) const
Returns
the number of canvases on the scene

§ getNumPhotos() [1/2]

int entity::UserScene::getNumPhotos ( entity::Canvas canvas) const
Returns
the number of photos within the given Canvas

§ getNumPhotos() [2/2]

int entity::UserScene::getNumPhotos ( )
Returns
the number of total photos within the scene

§ getNumPhotosTill()

int entity::UserScene::getNumPhotosTill ( entity::Canvas canvas)
Returns
the total number of photos that contain all the canvases before the given one

§ getPhoto()

entity::Photo * entity::UserScene::getPhoto ( entity::Canvas canvas,
int  row 
)

A method to return a Photo pointer given sequential index within a Canvas. Returns a child of Canvas with given sequential index.

Parameters
canvasis the Canvas which is a parent of requested Photo
rowis the sequential index as is in CanvasPhotoWidget
Returns
Photo pointer of the index.
See also
getPhotoIndex()

§ getPhotoIndex()

int entity::UserScene::getPhotoIndex ( entity::Photo photo,
entity::Canvas canvas 
) const

Similar to getCanvasIndex(), the method is to return a sequential index of a photo as it is in CanvasPhotoWidget. It iterates through all the children of Canvas and compares them to the Photo pointer. Whenever the child is of type Photo, the index value increases. When the pointers match, the result index is returned.

Parameters
photois a Photo of which index we want to obtain
canvasis a Canvas that contains the photo
Returns
index of the given Photo within the given Canvas as is in CanvasPhotoWidget.
See also
getPhoto()

§ getPhotoLevel()

int entity::UserScene::getPhotoLevel ( ) const

Returns a level of Photo within the whole scene graph, starting from the RootScene. It is used from EventHandler when using intersectors. The return value is defined manually, therefore it is important to keep them updated in case if scene graph is dramatically re-designed. The level for the Photo is defined:

RootScene -> UserScene ->UserScene::m_groupCanvases -> Canvas -> Canvas::m_transform -> Canvas::m_switch -> Canvas::m_geodeData -> Photo

   [1]        [2]                    [3]                [4]               [5]                   [6]              [7]                 [8]

To simplify, a relative deepness is used, i.e.,

.

Returns
a deepness level of Photo from the RootScene.

§ getStrokeLevel()

int entity::UserScene::getStrokeLevel ( ) const

Returns a level of Stroke within the whole scene graph, starting from the RootScene. It is used from EventHandler when using intersectors. The return value is defined manually, therefore it is important to keep them updated in case if scene graph is dramatically re-designed. The level for the Stroke is defined:

RootScene -> UserScene -> UserScene::m_groupCanvases -> Canvas -> Canvas::m_transform -> Canvas::m_switch -> Canvas::m_geodeData -> Stroke

   [1]        [2]                [3]                     [4]            [5]                     [6]              [7]                 [8]

To simplify, a relative deepness is used, i.e.,

.

Returns
a deepness level of Stroke from the RootScene.

§ isEmptyScene()

bool entity::UserScene::isEmptyScene ( ) const
Returns
A boolean value telling whether the scene is empty (true) or not (false)

§ isEntityCurrent()

bool entity::UserScene::isEntityCurrent ( ) const
Returns
whether there are any observer pointers that are not NULL

§ isSetFilePath()

entity::UserScene::isSetFilePath ( ) const
Returns
Bool value indicating whether the file path was set or not

§ META_Node()

entity::UserScene::META_Node ( entity  ,
UserScene   
)

A method to initialized a scene graph of UserScene. Normally, it should be called after the ctor, e.g., from RootScene ctor.

§ onClicked

void entity::UserScene::onClicked ( const QModelIndex &  index)
slot

A slot which is called when the user performed a canvas left-click selection from a tree widget. Based on what item was selected, the slots changes the corresponding canvas status to current. This slot is connected with CanvasPhotoWidget::clicked().

§ onItemChanged

void entity::UserScene::onItemChanged ( QTreeWidgetItem *  item,
int  column 
)
slot

A slot which is called when the canvas name was edited from CanvasPhotoWidget. Based on the edited item, the slot edits the name of the corresponding canvas. This slot is connected to CanvasPhotoWidget::itemChanged()

§ onRightClicked

void entity::UserScene::onRightClicked ( const QModelIndex &  index)
slot

A slot which is called when the user performed a canvas right-click selection from a tree widget. Based on what item was selected, the slots changes the corresponding canvas status to previous. This slot is connected with CanvasPhotoWidget::rightClicked().

§ photoAdded

void entity::UserScene::photoAdded ( const std::string &  name,
int  idxCanvas 
)
signal

A signal which is connected with CanvasPhotoWidget::onPhotoAdded() to request to add a photo item to the widget

§ photoRemoved

void entity::UserScene::photoRemoved ( int  rowCanvas,
int  rowPhoto 
)
signal

A signal which is connected with CanvasPhotoWidget::onPhotoRemoved() to request to remove a photo item from the widget

§ requestCanvasCreate

void entity::UserScene::requestCanvasCreate ( const osg::Vec3f &  eye,
const osg::Vec3f &  center,
const osg::Vec3f &  up 
)
signal

A signal to be emitter whenever user finishes editing camera position.

§ requestSceneToolStatus

void entity::UserScene::requestSceneToolStatus ( bool &  visibility)
signal

A signal to be emitted on addition of new canvas to the scene. It requests tool's status of MainWindow, and turns the internal frame on or off depending on the result.

Parameters
visibilityis a boolean flag which indicated whether the tools are on (true) of off (false).

§ resetModel()

void entity::UserScene::resetModel ( CanvasPhotoWidget widget)

A method to reset Canvas and Photo data within the corresponding widget, as well as its model. It updates the widget with the new UserScene. This method is called when a file was open. The main principle is that it traverses the scene graph and adds the found Canvas entities to the CanvasPhotoWidget.

Parameters
widgetis the CanvasPhotoWidget to update

§ sendRequestUpdate

void entity::UserScene::sendRequestUpdate ( )
signal

A signal which is connected with MainWindow::onRequestUpdate() to request for GLWidget update.

§ setAllCanvases()

void entity::UserScene::setAllCanvases ( bool  enabled)

A method to set the traversal masks for all the canvases.

Parameters
enabledis a flag to indicate whether all the canvases will be available for selection (intersectors) or not.

§ setCanvasCurrent()

bool entity::UserScene::setCanvasCurrent ( entity::Canvas cnv)

Sets given Canvas as a current. This sets the variable UserScene::m_canvasCurrent to pointer of given Canvas. The current status also means change of Canvas frame color. When the frame color changes, the function emits a signal which is connected to CanvasPhotoWidget to mark the corresponding Canvas as selected in widget UI. Most of the time this method is called by either CanvasPhotoWidget, EventHandler methods or undo/redo framework classes (e.g. Add*Command and Edit*Command).

Parameters
cnvis the Canvas to set as current
Returns
The bool parameter which indicates the success of current status change (also checks for validity of pointers).

§ setCanvasesButCurrent()

void entity::UserScene::setCanvasesButCurrent ( bool  enabled)

Sets the traversal mask so that all the canvases (except current) are either traversible or not, depending on the input parameter. This function would be called from EventHandler when we want to exclude all the canvases but current from ray casting and intersection search (or enable the traversal mask back).

An example for turning the traversal off: selection of 2D entities within the current canvas (in this case we do not want the contents of other canvases to mix in with the intersection results). An example for turning the traversal masks on: 3D selection of Canvas by clicking on its pickable.

Parameters
enabledis a boolean variable which indicates whether we want to set the traversal to on (true) or off (false).
See also
EventHandler::setMode()

§ setCanvasPrevious()

bool entity::UserScene::setCanvasPrevious ( entity::Canvas cnv)

Sets given Canvas as previous. This sets the variable UserScene::m_canvasPrevious to pointer of given Canvas. The previous status also means change of Canvas frame color. When the frame color changes, the function emits a signal which is connected to CanvasPhotoWidget to mark the corresponding Canvas as selected in widget UI. Most of the time this method will be called automatically by UserScene::setCanvasCurrent(), although there are few cases when it is called by other means, e.g., from CanvasPhotoWidget when user sets previous status by right mouse click.

Parameters
cnvis the Canvas to set as previous
Returns
The bool parameter which indicates the success of current status change (also checks for validity of pointers).

§ updateBookmark()

void entity::UserScene::updateBookmark ( BookmarkWidget widget,
int  row 
)

Updates the screenshot of the bookmark within the BookmarkWidget.

Parameters
widgetis the BookmarkWidget which is connected to the Bookmarks data structure
rowis the id number of the bookmark in a bookmark widget and Bookmarks data structure

§ updateWidgets()

void entity::UserScene::updateWidgets ( )

A method which connects UserScene with MainWindow (and/or GLWidget). Its main purpose is to request for GLWidget::update() method to renew the viewport.


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