Envision
A visual programming IDE for object-oriented languages
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | Friends
Visualization::Scene Class Reference
Inheritance diagram for Visualization::Scene:

Public Types

using ItemCategories = QFlags< ItemCategory >
 
enum  ItemCategory { NoItemCategory = 0x0 , CodeItemCategory = 0x1 , MenuItemCategory = 0x2 , SelectionItemCategory = 0x4 , CursorItemCategory = 0x8 }
 
using OnZoomHandler = std::function< void(qreal factor)>
 
using OnZoomHandlerRemove = std::function< void()>
 
using RefreshActionFunction = std::function< void(Scene *scene)>
 

Public Member Functions

 Scene ()
 
virtual ~Scene ()
 
int addOnZoomHandler (OnZoomHandler onZoomHandler, OnZoomHandlerRemove onZoomHandlerRemove)
 
OverlayGroupaddOverlayGroup (const QString &name)
 
void addPostEventAction (CustomSceneEvent::EventFunction function)
 
void addPostEventAction (QEvent *action)
 Adds an action to be executed after the current event. More...
 
void addRefreshActionFunction (RefreshActionFunction func)
 
void addTopLevelItem (Item *item, bool show=true)
 
void addTopLevelNode (Node *node, MajorMinorIndex index={})
 
QList< OverlayGroup * > allOverlayGroups () const
 
bool approximateUpdate ()
 
ViewcurrentPaintView () const
 
ViewItemcurrentViewItem ()
 Convenience method to get the manager's current view item. More...
 
virtual void customEvent (QEvent *event) override
 
ItemfocusItem () const
 Returns the focused item if it is an instance of Item* or the closest of its ancestors that is an Item*. More...
 
bool isCurrentMousePressAClick () const
 
bool isHiddenCategory (ItemCategory cat)
 
QPointF lastMouseHoverPosition () const
 
void listenToTreeManager (Model::TreeManager *manager)
 
CursormainCursor ()
 
qreal mainViewScalingFactor () const
 Returns the scaling factor applied by the main view associated of this item's scene. More...
 
void nodesUpdated (QSet< Node * > modifiedNodes, QSet< Node * > removedNodes)
 
OverlayGroupoverlayGroup (const QString &name)
 
qreal previousMainViewScalingFactor () const
 Returns the scaling factor used before the active one. More...
 
void removeAllOnZoomHandlers ()
 
void removeOnZoomHandler (int onZoomHandlerId)
 
void removeOverlay (Item *overlay, const QString &groupName={})
 
void removeOverlayGroup (const QString &name)
 
void removeOverlayGroup (OverlayGroup *group)
 
void removeOverlayOf (Item *itemWithOverlay, const QString &groupName={})
 
void removeTopLevelItem (Item *item)
 
ModelRendererrenderer ()
 
virtual SceneHandlerItemsceneHandlerItem ()
 
void scheduleUpdate ()
 
QList< Item * > selectedItems () const
 Returns a list of selected items. More...
 
void setApproximateUpdate (bool b)
 
void setHiddenItemCategories (ItemCategories hidden=NoItemCategory)
 
void setItemIsSensitiveToScale (Item *item, bool update)
 
void setMainCursor (Cursor *cursor)
 
void setMainViewScalingFactor (qreal factor)
 
void setRenderer (ModelRenderer *renderer)
 
const QList< Item * > & topLevelItems () const
 
void updateNow ()
 
ViewItemManagerviewItems () const
 

Static Public Member Functions

static QList< Scene * > & allScenes ()
 Returns all existing scenes. More...
 
static ModelRendererdefaultRenderer ()
 

Protected Member Functions

virtual bool event (QEvent *event) override
 
virtual void keyPressEvent (QKeyEvent *event) override
 
virtual void mouseDoubleClickEvent (QGraphicsSceneMouseEvent *mouseEvent) override
 
virtual void mouseMoveEvent (QGraphicsSceneMouseEvent *mouseEvent) override
 
virtual void mousePressEvent (QGraphicsSceneMouseEvent *mouseEvent) override
 
virtual void mouseReleaseEvent (QGraphicsSceneMouseEvent *mouseEvent) override
 

Private Types

typedef Model::Node Node
 

Private Member Functions

void computeSceneRect ()
 
QList< Item * > itemsThatShouldHaveASelection ()
 
void setCurrentPaintView (View *view)
 

Private Attributes

bool approximateUpdate_ {}
 
ViewcurrentPaintView_ {}
 
ItemCategories hiddenItemCategories_
 
bool inAnUpdate_ {}
 
bool inEventHandler_ {}
 
bool initialized_ {}
 
bool isCurrentMousePressAClick_ {}
 
QSet< Item * > itemsSensitiveToScale_
 
QPointF lastMouseHoverPosition_
 
QElapsedTimer lastMousePressTimer_ {}
 
CursormainCursor_ {}
 
bool mainCursorsJustSet_ {}
 
qreal mainViewScalingFactor_ {1.0}
 
bool mainViewScalingFactorChanged_ {false}
 
const int MAX_MILLISECONDS_FOR_A_CLICK = 500
 
bool needsUpdate_ {}
 
QHash< int, QPair< OnZoomHandler, OnZoomHandlerRemove > > onZoomHandlers_
 
QHash< QString, OverlayGroup * > overlayGroups_
 
QList< QEvent * > postEventActions_
 
qreal previousMainViewScalingFactor_ {mainViewScalingFactor_}
 
QList< RefreshActionFunctionrefreshActionFunctions_
 
ModelRendererrenderer_ {}
 
SceneHandlerItemsceneHandlerItem_ {}
 
QList< Item * > topLevelItems_
 
ViewItemManagerviewItemManager_ {}
 

Static Private Attributes

static int addOnZoomHandlerId_ = 0
 

Friends

class View
 
class ViewItemManager
 

Member Typedef Documentation

◆ ItemCategories

◆ Node

◆ OnZoomHandler

using Visualization::Scene::OnZoomHandler = std::function<void (qreal factor)>

◆ OnZoomHandlerRemove

using Visualization::Scene::OnZoomHandlerRemove = std::function<void ()>

◆ RefreshActionFunction

using Visualization::Scene::RefreshActionFunction = std::function<void (Scene* scene)>

Member Enumeration Documentation

◆ ItemCategory

Enumerator
NoItemCategory 
CodeItemCategory 
MenuItemCategory 
SelectionItemCategory 
CursorItemCategory 

Constructor & Destructor Documentation

◆ Scene()

Visualization::Scene::Scene ( )

◆ ~Scene()

Visualization::Scene::~Scene ( )
virtual

Member Function Documentation

◆ addOnZoomHandler()

int Visualization::Scene::addOnZoomHandler ( OnZoomHandler  onZoomHandler,
OnZoomHandlerRemove  onZoomHandlerRemove 
)

◆ addOverlayGroup()

OverlayGroup * Visualization::Scene::addOverlayGroup ( const QString &  name)

◆ addPostEventAction() [1/2]

void Visualization::Scene::addPostEventAction ( CustomSceneEvent::EventFunction  function)

◆ addPostEventAction() [2/2]

void Visualization::Scene::addPostEventAction ( QEvent *  action)

Adds an action to be executed after the current event.

This method can only be called while handling an event.

◆ addRefreshActionFunction()

void Visualization::Scene::addRefreshActionFunction ( RefreshActionFunction  func)
inline

◆ addTopLevelItem()

void Visualization::Scene::addTopLevelItem ( Item item,
bool  show = true 
)

◆ addTopLevelNode()

void Visualization::Scene::addTopLevelNode ( Node node,
MajorMinorIndex  index = {} 
)

◆ allOverlayGroups()

QList< OverlayGroup * > Visualization::Scene::allOverlayGroups ( ) const
inline

◆ allScenes()

QList< Scene * > & Visualization::Scene::allScenes ( )
static

Returns all existing scenes.

◆ approximateUpdate()

bool Visualization::Scene::approximateUpdate ( )
inline

◆ computeSceneRect()

void Visualization::Scene::computeSceneRect ( )
private

◆ currentPaintView()

View * Visualization::Scene::currentPaintView ( ) const
inline

◆ currentViewItem()

ViewItem * Visualization::Scene::currentViewItem ( )

Convenience method to get the manager's current view item.

◆ customEvent()

void Visualization::Scene::customEvent ( QEvent *  event)
overridevirtual

◆ defaultRenderer()

ModelRenderer * Visualization::Scene::defaultRenderer ( )
static

◆ event()

bool Visualization::Scene::event ( QEvent *  event)
overrideprotectedvirtual

◆ focusItem()

Item * Visualization::Scene::focusItem ( ) const

Returns the focused item if it is an instance of Item* or the closest of its ancestors that is an Item*.

This method hides QGraphicsScene::focusItem() const.

◆ isCurrentMousePressAClick()

bool Visualization::Scene::isCurrentMousePressAClick ( ) const
inline

◆ isHiddenCategory()

bool Visualization::Scene::isHiddenCategory ( ItemCategory  cat)
inline

◆ itemsThatShouldHaveASelection()

QList< Item * > Visualization::Scene::itemsThatShouldHaveASelection ( )
private

◆ keyPressEvent()

void Visualization::Scene::keyPressEvent ( QKeyEvent *  event)
overrideprotectedvirtual

◆ lastMouseHoverPosition()

QPointF Visualization::Scene::lastMouseHoverPosition ( ) const
inline

◆ listenToTreeManager()

void Visualization::Scene::listenToTreeManager ( Model::TreeManager manager)

◆ mainCursor()

Cursor * Visualization::Scene::mainCursor ( )
inline

◆ mainViewScalingFactor()

qreal Visualization::Scene::mainViewScalingFactor ( ) const
inline

Returns the scaling factor applied by the main view associated of this item's scene.

◆ mouseDoubleClickEvent()

void Visualization::Scene::mouseDoubleClickEvent ( QGraphicsSceneMouseEvent *  mouseEvent)
overrideprotectedvirtual

◆ mouseMoveEvent()

void Visualization::Scene::mouseMoveEvent ( QGraphicsSceneMouseEvent *  mouseEvent)
overrideprotectedvirtual

◆ mousePressEvent()

void Visualization::Scene::mousePressEvent ( QGraphicsSceneMouseEvent *  mouseEvent)
overrideprotectedvirtual

◆ mouseReleaseEvent()

void Visualization::Scene::mouseReleaseEvent ( QGraphicsSceneMouseEvent *  mouseEvent)
overrideprotectedvirtual

◆ nodesUpdated()

void Visualization::Scene::nodesUpdated ( QSet< Node * >  modifiedNodes,
QSet< Node * >  removedNodes 
)

◆ overlayGroup()

OverlayGroup * Visualization::Scene::overlayGroup ( const QString &  name)

◆ previousMainViewScalingFactor()

qreal Visualization::Scene::previousMainViewScalingFactor ( ) const
inline

Returns the scaling factor used before the active one.

◆ removeAllOnZoomHandlers()

void Visualization::Scene::removeAllOnZoomHandlers ( )

◆ removeOnZoomHandler()

void Visualization::Scene::removeOnZoomHandler ( int  onZoomHandlerId)

◆ removeOverlay()

void Visualization::Scene::removeOverlay ( Item overlay,
const QString &  groupName = {} 
)

◆ removeOverlayGroup() [1/2]

void Visualization::Scene::removeOverlayGroup ( const QString &  name)

◆ removeOverlayGroup() [2/2]

void Visualization::Scene::removeOverlayGroup ( OverlayGroup group)

◆ removeOverlayOf()

void Visualization::Scene::removeOverlayOf ( Item itemWithOverlay,
const QString &  groupName = {} 
)

◆ removeTopLevelItem()

void Visualization::Scene::removeTopLevelItem ( Item item)

◆ renderer()

ModelRenderer * Visualization::Scene::renderer ( )
inline

◆ sceneHandlerItem()

SceneHandlerItem * Visualization::Scene::sceneHandlerItem ( )
inlinevirtual

◆ scheduleUpdate()

void Visualization::Scene::scheduleUpdate ( )

◆ selectedItems()

QList< Item * > Visualization::Scene::selectedItems ( ) const

Returns a list of selected items.

Only items that derive from Item are returned. If an item is selected but does not derive from Item then its first Item ancestor will be returned in the list, if it is not already in the list.

This method hised QGraphicsScene::selectedItems() const

◆ setApproximateUpdate()

void Visualization::Scene::setApproximateUpdate ( bool  b)
inline

◆ setCurrentPaintView()

void Visualization::Scene::setCurrentPaintView ( View view)
private

◆ setHiddenItemCategories()

void Visualization::Scene::setHiddenItemCategories ( ItemCategories  hidden = NoItemCategory)
inline

◆ setItemIsSensitiveToScale()

void Visualization::Scene::setItemIsSensitiveToScale ( Item item,
bool  update 
)

◆ setMainCursor()

void Visualization::Scene::setMainCursor ( Cursor cursor)

◆ setMainViewScalingFactor()

void Visualization::Scene::setMainViewScalingFactor ( qreal  factor)

◆ setRenderer()

void Visualization::Scene::setRenderer ( ModelRenderer renderer)
inline

◆ topLevelItems()

const QList< Item * > & Visualization::Scene::topLevelItems ( ) const
inline

◆ updateNow()

void Visualization::Scene::updateNow ( )

◆ viewItems()

ViewItemManager * Visualization::Scene::viewItems ( ) const
inline

Friends And Related Function Documentation

◆ View

friend class View
friend

◆ ViewItemManager

friend class ViewItemManager
friend

Member Data Documentation

◆ addOnZoomHandlerId_

int Visualization::Scene::addOnZoomHandlerId_ = 0
staticprivate

◆ approximateUpdate_

bool Visualization::Scene::approximateUpdate_ {}
private

◆ currentPaintView_

View* Visualization::Scene::currentPaintView_ {}
private

◆ hiddenItemCategories_

ItemCategories Visualization::Scene::hiddenItemCategories_
private

◆ inAnUpdate_

bool Visualization::Scene::inAnUpdate_ {}
private

◆ inEventHandler_

bool Visualization::Scene::inEventHandler_ {}
private

◆ initialized_

bool Visualization::Scene::initialized_ {}
private

◆ isCurrentMousePressAClick_

bool Visualization::Scene::isCurrentMousePressAClick_ {}
private

◆ itemsSensitiveToScale_

QSet<Item*> Visualization::Scene::itemsSensitiveToScale_
private

◆ lastMouseHoverPosition_

QPointF Visualization::Scene::lastMouseHoverPosition_
private

◆ lastMousePressTimer_

QElapsedTimer Visualization::Scene::lastMousePressTimer_ {}
private

◆ mainCursor_

Cursor* Visualization::Scene::mainCursor_ {}
private

◆ mainCursorsJustSet_

bool Visualization::Scene::mainCursorsJustSet_ {}
private

◆ mainViewScalingFactor_

qreal Visualization::Scene::mainViewScalingFactor_ {1.0}
private

◆ mainViewScalingFactorChanged_

bool Visualization::Scene::mainViewScalingFactorChanged_ {false}
private

◆ MAX_MILLISECONDS_FOR_A_CLICK

const int Visualization::Scene::MAX_MILLISECONDS_FOR_A_CLICK = 500
private

◆ needsUpdate_

bool Visualization::Scene::needsUpdate_ {}
private

◆ onZoomHandlers_

QHash<int, QPair<OnZoomHandler, OnZoomHandlerRemove> > Visualization::Scene::onZoomHandlers_
private

◆ overlayGroups_

QHash<QString, OverlayGroup*> Visualization::Scene::overlayGroups_
private

◆ postEventActions_

QList<QEvent*> Visualization::Scene::postEventActions_
private

◆ previousMainViewScalingFactor_

qreal Visualization::Scene::previousMainViewScalingFactor_ {mainViewScalingFactor_}
private

◆ refreshActionFunctions_

QList<RefreshActionFunction> Visualization::Scene::refreshActionFunctions_
private

◆ renderer_

ModelRenderer* Visualization::Scene::renderer_ {}
private

◆ sceneHandlerItem_

SceneHandlerItem* Visualization::Scene::sceneHandlerItem_ {}
private

◆ topLevelItems_

QList<Item*> Visualization::Scene::topLevelItems_
private

◆ viewItemManager_

ViewItemManager* Visualization::Scene::viewItemManager_ {}
private