All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
te::layout::Scene Class Reference

Class representing the scene. This scene is child of QGraphicsScene, part of Graphics View Framework. The scene is not drawn, but the items that are inserted into it. She is responsible for managing items QGraphicsItem and know when and how to redrawing them. The scene has a coordinate system that is, by default, the same for all items that are inserted. The coordinate system of this representation is millimeters and your point 0.0 is in the bottom left(Cartesian coordinate system). The default settings of the layout module are in the object Context (singleton). More...

#include <Scene.h>

Inheritance diagram for te::layout::Scene:
te::layout::AbstractScene

Public Slots

virtual void onChangeZoomFactor (double currentFactor)
 It is called immediately when the zoom factor is changed in the Context. More...
 

Signals

void addItemFinalized ()
 Issued after insertion of an item in the scene. More...
 
void deleteFinalized (std::vector< std::string > names)
 Issued after deleting an item in the scene. More...
 

Public Member Functions

virtual bool addItemStackWithoutScene (QGraphicsItem *item)
 
virtual void addUndoStack (QUndoCommand *command)
 Method that insert command Undo/Redo of type AddCommand in the Undo/Redo stack. More...
 
virtual bool buildTemplate (VisualizationArea *vzArea, EnumType *type, std::string fileName)
 Method that import a template and build all objects. Ex.: JSON. More...
 
virtual void calculateSceneMeasures (double widthMM, double heightMM)
 Method that resets the scene and calculates again. More...
 
virtual QGraphicsItem * createItem (const te::gm::Coord2D &coord)
 Method that create a graphic object and place it in the scene. A name and a position is added. A command Undo/Redo of type AddCommand is created. More...
 
virtual QGraphicsItemGroup * createItemGroup (const QList< QGraphicsItem * > &items)
 Groups objects and creates a QGraphicsItemGroup object. A command Undo/Redo of type AddCommand is created. More...
 
virtual
te::layout::MovingItemGroup
createMovingItemGroup (const QList< QGraphicsItem * > &items)
 
virtual void deleteItems ()
 Method that deletes all selected items in the scene. More...
 
virtual void destroyItemGroup (QGraphicsItemGroup *group)
 Method that delete object grouping, but the individual objects continue to exist. More...
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 Reimplemented from QGraphicsScene. More...
 
virtual void exportItemsToImage (std::string dir)
 Saves each item in the scene as image. Ex .: .png. More...
 
virtual bool exportPropertiesToTemplate (EnumType *type, std::string fileName)
 Method that exports all the objects in the scene to a template. Ex.: JSON. More...
 
virtual AlignItemsgetAlignItems ()
 Method that returns the object responsible for aligning objects in the scene. More...
 
virtual PrintScenegetPrintScene ()
 Method that returns the object responsible for printing the scene. More...
 
virtual te::gm::Envelope getSceneBox ()
 Method that return the scene box. More...
 
virtual QUndoStack * getUndoStack ()
 Method that return stack of Undo/Redo. More...
 
virtual int getUndoStackLimit ()
 Method that returns the size limit of the stack Undo/Redo. More...
 
virtual std::vector
< te::layout::Properties * > 
importTemplateToProperties (EnumType *type, std::string fileName)
 Method that imports a template and turns it into properties. Ex.: JSON. More...
 
virtual void init (double screenWMM, double screenHMM)
 Method that starts the scene and configures. Calculates the transformation matrix of the scene and calculates the ratio of the size of the scene with the paper size. More...
 
virtual void insertItem (ItemObserver *item)
 Method that inserts a graphic object in the scene. Inverts the matrix of the object if necessary, ex.: TextItem. More...
 
virtual void insertItem (QGraphicsItem *item)
 Method that inserts a graphic object in the scene. Inverts the matrix of the object if necessary, ex.: TextItem. More...
 
virtual void redrawItems ()
 
virtual void redrawSelectionMap ()
 Redraws the Layer of the selected map. More...
 
virtual bool removeItemStackWithoutScene (QGraphicsItem *item)
 
virtual void removeSelectedItems ()
 Method that removes all selected items in the scene and creates a Command to Undo/Redo of type DeleteCommand. The item is removed from the scene, but is not deleted. More...
 
virtual void reset ()
 Method that clears the scene and the stack of Undo/Redo. More...
 
 Scene (QObject *object=(QObject *) 0)
 Constructor. More...
 
 Scene (AlignItems *align, PrintScene *print, QObject *object=0)
 Constructor. The ownership of objects passed via parameter becomes the scene. More...
 
virtual QTransform sceneTransform ()
 Method that returns the matrix transformation scene. More...
 
virtual void selectItem (std::string name)
 Select an item an item by name. More...
 
virtual void selectItem (QGraphicsItem *item)
 Select specified item. More...
 
virtual void selectItems (std::vector< std::string > names)
 Select items by name. More...
 
virtual void selectItems (QList< QGraphicsItem * > items)
 Select items. More...
 
virtual void setUndoStackLimit (int limit)
 Method that limits the size of the stack of Undo/Redo. More...
 
virtual void updateSelectedItemsPositions ()
 
virtual ~Scene ()
 Destructor. More...
 

Protected Member Functions

virtual void calculateMatrixViewScene ()
 Method that calculates the transformation matrix of the scene. This matrix will be set in each QGraphicsView class that watches this scene. More...
 
virtual void calculateWindow (double wMM, double hMM)
 Method that calculates the ratio of the size of the scene with the paper size. This calculation is necessary so that the paper always is centered in the scene. More...
 
virtual std::vector
< te::layout::Properties * > 
getItemsProperties ()
 Method that returns a list of the properties of all the graphic objects in the scene. More...
 

Protected Attributes

AlignItemsm_align
 object responsible for aligning objects in the scene. More...
 
QColor m_backgroundColor
 background color that is applied to each observer(QGraphicsView) of the scene. More...
 
te::gm::Envelope m_box
 scene box. More...
 
QList< QGraphicsItem * > m_itemStackWithoutScene
 Items that are not included in any scene. More...
 
QTransform m_matrix
 transformation matrix of the scene. More...
 
bool m_moveWatched
 
std::map< QGraphicsItem
*, QPointF > 
m_moveWatches
 
PrintScenem_print
 object responsible for printing the scene. More...
 
QUndoStack * m_undoStack
 Undo/Redo stack. More...
 
int m_undoStackLimit
 Undo/Redo limit size. More...
 

Detailed Description

Class representing the scene. This scene is child of QGraphicsScene, part of Graphics View Framework. The scene is not drawn, but the items that are inserted into it. She is responsible for managing items QGraphicsItem and know when and how to redrawing them. The scene has a coordinate system that is, by default, the same for all items that are inserted. The coordinate system of this representation is millimeters and your point 0.0 is in the bottom left(Cartesian coordinate system). The default settings of the layout module are in the object Context (singleton).

See also
te::layout::AbstractScene

Definition at line 80 of file Scene.h.

Constructor & Destructor Documentation

te::layout::Scene::Scene ( QObject *  object = (QObject*)0)

Constructor.

Definition at line 61 of file Scene.cpp.

References m_backgroundColor, and m_undoStack.

te::layout::Scene::Scene ( AlignItems align,
PrintScene print,
QObject *  object = 0 
)

Constructor. The ownership of objects passed via parameter becomes the scene.

Parameters
alignapplying the alignment of one or more objects
printprinting the entire content or part of the scene

Definition at line 74 of file Scene.cpp.

te::layout::Scene::~Scene ( )
virtual

Destructor.

Definition at line 84 of file Scene.cpp.

Member Function Documentation

void te::layout::Scene::addItemFinalized ( )
signal

Issued after insertion of an item in the scene.

bool te::layout::Scene::addItemStackWithoutScene ( QGraphicsItem *  item)
virtual

Definition at line 810 of file Scene.cpp.

Referenced by te::layout::DeleteCommand::redo(), and te::layout::AddCommand::undo().

void te::layout::Scene::addUndoStack ( QUndoCommand *  command)
virtual

Method that insert command Undo/Redo of type AddCommand in the Undo/Redo stack.

Parameters
commandcommand

Definition at line 313 of file Scene.cpp.

Referenced by te::layout::MenuBuilder::changePropertyValue(), te::layout::TextItem::resetEdit(), te::layout::PropertiesOutside::sendPropertyToSelectedItem(), and te::layout::PropertiesOutside::sendPropertyToSelectedItems().

bool te::layout::Scene::buildTemplate ( VisualizationArea vzArea,
EnumType type,
std::string  fileName 
)
virtual

Method that import a template and build all objects. Ex.: JSON.

Parameters
typetype of template. Ex .: JSON type
fileNameFull path where the template is saved.
Returns
true if exported, false otherwise

Definition at line 545 of file Scene.cpp.

References te::layout::VisualizationArea::changeBoxArea(), te::layout::Context::getAbstractBuildGraphicsItem(), te::common::Singleton< Context >::getInstance(), and te::layout::BuildGraphicsItem::rebuildItem().

Referenced by te::layout::View::importTemplate().

void te::layout::Scene::calculateMatrixViewScene ( )
protectedvirtual

Method that calculates the transformation matrix of the scene. This matrix will be set in each QGraphicsView class that watches this scene.

Implements te::layout::AbstractScene.

Definition at line 196 of file Scene.cpp.

References te::layout::Context::getDpiX(), and te::common::Singleton< Context >::getInstance().

void te::layout::Scene::calculateSceneMeasures ( double  widthMM,
double  heightMM 
)
virtual

Method that resets the scene and calculates again.

Parameters
widthMMwidth of physical screen in millimeters
heightMMheight of physical screen in millimeters

Definition at line 441 of file Scene.cpp.

void te::layout::Scene::calculateWindow ( double  wMM,
double  hMM 
)
protectedvirtual

Method that calculates the ratio of the size of the scene with the paper size. This calculation is necessary so that the paper always is centered in the scene.

Parameters
wMMwidth of physical screen in millimeters
hMMheight of physical screen in millimeters

Implements te::layout::AbstractScene.

Definition at line 213 of file Scene.cpp.

References te::common::Singleton< Context >::getInstance(), te::layout::Context::getPaperConfig(), and te::layout::PaperConfig::getPaperSize().

QGraphicsItem * te::layout::Scene::createItem ( const te::gm::Coord2D coord)
virtual

Method that create a graphic object and place it in the scene. A name and a position is added. A command Undo/Redo of type AddCommand is created.

Parameters
coordCoordinated where the item is located. The coordinate should be the same scene coordinates system

Definition at line 408 of file Scene.cpp.

References te::layout::BuildGraphicsItem::createItem(), te::layout::Context::getAbstractBuildGraphicsItem(), te::layout::Enums::getEnumModeType(), te::common::Singleton< Context >::getInstance(), te::common::Singleton< Enums >::getInstance(), te::layout::Context::getMode(), te::layout::EnumModeType::getModeNone(), te::layout::ItemObserver::isCanChangeGraphicOrder(), and te::layout::Context::setMode().

Referenced by te::layout::ItemUtils::createLegendChildItemFromLegend(), and te::layout::ItemUtils::createTextItemFromObject().

QGraphicsItemGroup * te::layout::Scene::createItemGroup ( const QList< QGraphicsItem * > &  items)
virtual
void te::layout::Scene::deleteFinalized ( std::vector< std::string >  names)
signal

Issued after deleting an item in the scene.

Parameters
namesnames of items removed
void te::layout::Scene::deleteItems ( )
virtual

Method that deletes all selected items in the scene.

Definition at line 256 of file Scene.cpp.

References te::layout::ItemObserver::getModel(), and te::layout::Observable::getName().

void te::layout::Scene::destroyItemGroup ( QGraphicsItemGroup *  group)
virtual

Method that delete object grouping, but the individual objects continue to exist.

Parameters
grouplist of objects

Definition at line 375 of file Scene.cpp.

Referenced by te::layout::View::destroyItemGroup(), and te::layout::View::mouseReleaseEvent().

bool te::layout::Scene::eventFilter ( QObject *  watched,
QEvent *  event 
)
virtual

Reimplemented from QGraphicsScene.

Definition at line 642 of file Scene.cpp.

void te::layout::Scene::exportItemsToImage ( std::string  dir)
virtual
bool te::layout::Scene::exportPropertiesToTemplate ( EnumType type,
std::string  fileName 
)
virtual

Method that exports all the objects in the scene to a template. Ex.: JSON.

Parameters
typetype of template. Ex .: JSON type
fileNameFull path where the template is saved.
Returns
true if exported, false otherwise

Definition at line 463 of file Scene.cpp.

References te::layout::AbstractTemplate::exportTemplate(), and te::layout::TemplateEditor::getTemplate().

Referenced by te::layout::View::exportProperties().

te::layout::AlignItems * te::layout::Scene::getAlignItems ( )
virtual

Method that returns the object responsible for aligning objects in the scene.

Returns
align object

Definition at line 458 of file Scene.cpp.

Referenced by te::layout::View::outsideAreaChangeContext().

std::vector< te::layout::Properties * > te::layout::Scene::getItemsProperties ( )
protectedvirtual

Method that returns a list of the properties of all the graphic objects in the scene.

Returns
list of properties

Definition at line 510 of file Scene.cpp.

References te::layout::ItemObserver::getModel(), te::layout::Observable::getProperties(), and te::layout::ItemObserver::isPrintable().

te::layout::PrintScene * te::layout::Scene::getPrintScene ( )
virtual

Method that returns the object responsible for printing the scene.

Returns
print object

Definition at line 453 of file Scene.cpp.

Referenced by te::layout::View::exportToPDF(), and te::layout::View::print().

te::gm::Envelope te::layout::AbstractScene::getSceneBox ( )
virtualinherited
QUndoStack * te::layout::Scene::getUndoStack ( )
virtual

Method that return stack of Undo/Redo.

Returns
stack

Definition at line 328 of file Scene.cpp.

Referenced by te::layout::ToolbarOutside::createUndoToolButton(), and te::layout::MoveCommand::redo().

int te::layout::Scene::getUndoStackLimit ( )
virtual

Method that returns the size limit of the stack Undo/Redo.

Returns
limit

Definition at line 323 of file Scene.cpp.

std::vector< te::layout::Properties * > te::layout::Scene::importTemplateToProperties ( EnumType type,
std::string  fileName 
)
virtual

Method that imports a template and turns it into properties. Ex.: JSON.

Parameters
typetype of template. Ex .: JSON type
fileNameFull path where the template is saved
Returns
true list of properties, false list of empty properties

Definition at line 489 of file Scene.cpp.

References te::layout::TemplateEditor::getTemplate(), and te::layout::AbstractTemplate::importTemplate().

void te::layout::Scene::init ( double  screenWMM,
double  screenHMM 
)
virtual

Method that starts the scene and configures. Calculates the transformation matrix of the scene and calculates the ratio of the size of the scene with the paper size.

Parameters
screenWMMwidth of physical screen in millimeters
screenHMMheight of physical screen in millimeters

Implements te::layout::AbstractScene.

Definition at line 177 of file Scene.cpp.

References te::common::Singleton< Context >::getInstance(), and te::layout::Context::getPaperConfig().

Referenced by te::layout::View::config().

void te::layout::Scene::insertItem ( ItemObserver item)
virtual

Method that inserts a graphic object in the scene. Inverts the matrix of the object if necessary, ex.: TextItem.

Parameters
itemgraphic object

Implements te::layout::AbstractScene.

Definition at line 116 of file Scene.cpp.

Referenced by te::layout::AddCommand::redo(), and te::layout::DeleteCommand::undo().

void te::layout::Scene::insertItem ( QGraphicsItem *  item)
virtual

Method that inserts a graphic object in the scene. Inverts the matrix of the object if necessary, ex.: TextItem.

Parameters
itemgraphic object

Definition at line 128 of file Scene.cpp.

References te::layout::ItemObserver::isInvertedMatrix(), and te::layout::ItemObserver::refresh().

void te::layout::Scene::onChangeZoomFactor ( double  currentFactor)
virtualslot

It is called immediately when the zoom factor is changed in the Context.

Parameters
currentZoomFactorcurrent zoom factor of the layout module

Definition at line 794 of file Scene.cpp.

References te::layout::ItemObserver::changeZoomFactor().

Referenced by te::layout::PrintScene::printPaper().

void te::layout::Scene::redrawItems ( )
virtual
void te::layout::Scene::redrawSelectionMap ( )
virtual

Redraws the Layer of the selected map.

Definition at line 578 of file Scene.cpp.

References te::layout::ItemObserver::redraw().

Referenced by te::layout::View::outsideAreaChangeContext().

bool te::layout::Scene::removeItemStackWithoutScene ( QGraphicsItem *  item)
virtual

Definition at line 832 of file Scene.cpp.

Referenced by te::layout::AddCommand::redo(), and te::layout::DeleteCommand::undo().

void te::layout::Scene::removeSelectedItems ( )
virtual

Method that removes all selected items in the scene and creates a Command to Undo/Redo of type DeleteCommand. The item is removed from the scene, but is not deleted.

Definition at line 284 of file Scene.cpp.

References te::layout::ItemObserver::getModel(), and te::layout::Observable::getName().

Referenced by te::layout::View::keyPressEvent(), and te::layout::View::outsideAreaChangeContext().

void te::layout::Scene::reset ( )
virtual

Method that clears the scene and the stack of Undo/Redo.

Definition at line 534 of file Scene.cpp.

Referenced by te::layout::View::onChangeConfig(), and te::layout::View::outsideAreaChangeContext().

QTransform te::layout::Scene::sceneTransform ( )
virtual

Method that returns the matrix transformation scene.

Returns
transformation matrix

Definition at line 251 of file Scene.cpp.

Referenced by te::layout::View::config(), te::layout::View::resetView(), and te::layout::View::zoomPercentage().

void te::layout::Scene::selectItem ( std::string  name)
virtual

Select an item an item by name.

Parameters
namegraphic object name

Definition at line 707 of file Scene.cpp.

References te::layout::ItemObserver::getModel(), and te::layout::Observable::getName().

Referenced by te::layout::View::onSelectionItem().

void te::layout::Scene::selectItem ( QGraphicsItem *  item)
virtual

Select specified item.

Parameters
iteminstance of QGraphicsItem

Definition at line 735 of file Scene.cpp.

void te::layout::Scene::selectItems ( std::vector< std::string >  names)
virtual

Select items by name.

Parameters
namesvector with object names

Definition at line 743 of file Scene.cpp.

Referenced by te::layout::View::mouseReleaseEvent().

void te::layout::Scene::selectItems ( QList< QGraphicsItem * >  items)
virtual

Select items.

Parameters
itemsvector with QGraphicsItems

Definition at line 751 of file Scene.cpp.

void te::layout::Scene::setUndoStackLimit ( int  limit)
virtual

Method that limits the size of the stack of Undo/Redo.

Parameters
limitlimit

Definition at line 318 of file Scene.cpp.

void te::layout::Scene::updateSelectedItemsPositions ( )
virtual

Definition at line 778 of file Scene.cpp.

References te::layout::ItemObserver::refresh().

Referenced by te::layout::View::mouseReleaseEvent().

Member Data Documentation

AlignItems* te::layout::Scene::m_align
protected

object responsible for aligning objects in the scene.

Definition at line 372 of file Scene.h.

QColor te::layout::Scene::m_backgroundColor
protected

background color that is applied to each observer(QGraphicsView) of the scene.

Definition at line 369 of file Scene.h.

Referenced by Scene().

te::gm::Envelope te::layout::AbstractScene::m_box
protectedinherited

scene box.

Definition at line 101 of file AbstractScene.h.

QList<QGraphicsItem*> te::layout::Scene::m_itemStackWithoutScene
protected

Items that are not included in any scene.

Definition at line 376 of file Scene.h.

QTransform te::layout::Scene::m_matrix
protected

transformation matrix of the scene.

Definition at line 368 of file Scene.h.

bool te::layout::Scene::m_moveWatched
protected

Definition at line 374 of file Scene.h.

std::map<QGraphicsItem*, QPointF> te::layout::Scene::m_moveWatches
protected

Definition at line 375 of file Scene.h.

PrintScene* te::layout::Scene::m_print
protected

object responsible for printing the scene.

Definition at line 373 of file Scene.h.

QUndoStack* te::layout::Scene::m_undoStack
protected

Undo/Redo stack.

Definition at line 370 of file Scene.h.

Referenced by Scene().

int te::layout::Scene::m_undoStackLimit
protected

Undo/Redo limit size.

Definition at line 371 of file Scene.h.


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