Skip to content

RGraphicsScene

Class in Core Module
Header: #include <src/core/RGraphicsScene.h>
Inherits: RExporter
Inherited by: RGraphicsSceneQt

Abstract base class for all graphics scenes.

A graphics scene is an exporter that exports entities into something that can be shown in a view (painter paths, triangles, OpenGL lists, …).

Graphics scenes store a map of reference points of all entities that are currently selected. This information is stored at the scene level and not at the document interface level because a scene that shows for example a wall from the side may show different reference points than a scene that shows the same wall from the top.

graphics views.

Scriptable: This class is available in script environments.

RGraphicsScene(RDocumentInterface &documentInterface)
virtual ~RGraphicsScene()
virtual void addPathToPreview(RObject::Id entityId, RPainterPath &pp)
virtual void addToPreview(RObject::Id entityId, QList< RGraphicsSceneDrawable > &drawables)
virtual void addToPreview(RObject::Id entityId, RGraphicsSceneDrawable &drawable)
void beginNoColorMode()
virtual void beginPreview()
virtual void clear()
Clears (resets) the scene contents.
virtual void clearPreview()
Clears the preview.
int countReferencePoints() const
virtual void dump()
void endNoColorMode()
virtual void endPreview()
virtual void exportCurrentEntity(bool preview=false, bool forceSelected=false)
The default implementation calls the REntity::exportEntity() function of the entity.
virtual bool exportDocumentSettings()
Override for performance reasons, we don’t need settings to be exported for graphics scenes.
RDocumentInterface & getDocumentInterface()
QList< RGraphicsView * > getGraphicsViews() const
RRefPoint getHighlightedReferencePoint()
bool getNoColorMode() const
QMap< RObject::Id, QList< RRefPoint > > & getReferencePoints()
void handleKeyPressEvent(QKeyEvent &event)
void handleKeyReleaseEvent(QKeyEvent &event)
void handleMouseDoubleClickEvent(RMouseEvent &event)
Forwards the given mouse event to the document interface.
void handleMouseMoveEvent(RMouseEvent &event)
Forwards the given mouse event to the document interface.
void handleMousePressEvent(RMouseEvent &event)
Forwards the given mouse event to the document interface.
void handleMouseReleaseEvent(RMouseEvent &event)
Forwards the given mouse event to the document interface.
void handlePanGestureEvent(QPanGesture &gesture)
Forwards the given gesture to the document interface.
void handlePinchGestureEvent(QPinchGesture &gesture)
Forwards the given gesture to the document interface.
void handleSwipeGestureEvent(QSwipeGesture &gesture)
Forwards the given gesture to the document interface.
void handleTabletEvent(RTabletEvent &event)
Forwards the given tablet event to the document interface.
void handleTerminateEvent(RTerminateEvent &event)
void handleWheelEvent(RWheelEvent &event)
Forwards the given mouse event to the document interface.
bool hasHadViews() const
bool hasSelectedReferencePoints() const
virtual void highlightEntity(REntity &entity)=0 = 0
Highlights the given entity.
virtual void highlightReferencePoint(const RRefPoint &position)
Highlights the reference point at the given position.
virtual bool isPreviewEmpty()
virtual void regenerate(bool undone=false, bool invisible=false)
Regenerates this scene from the entity data by exporting the whole document into it.
virtual void regenerate(QSet< RObject::Id > &affectedEntities, bool updateViews)
virtual void regenerateViews(bool force=false)
Regenerates all views attached to this scene.
virtual void regenerateViews(QSet< RObject::Id > &affectedEntities)
virtual void registerView(RGraphicsView *view, bool regen=true)
Registers a view with this scene.
virtual void repaintViews()
Repaints all views attached to this scene.
virtual void selectReferencePoints(const RBox &box, bool add)
virtual void setCursor(const QCursor &cursor)
virtual void translateEntities(QSet< RObject::Id > &affectedEntities, const RVector &offset)
Translates the graphical representation of the given entities by the given offset.
virtual void unexportEntity(RObject::Id entityId)
This is called for entities for which an export was requested but which cannot be instantiated because they either do not exist (anymore) in the DB or they are currently undone.
virtual void unregisterView(RGraphicsView *view)
Removes the given view from this scene.
virtual void updateSelectionStatus(QSet< RObject::Id > &affectedEntities, bool updateViews)
Updates the selection status of the given entities.
static bool isHighlightEnabled(const REntity &entity)
virtual void exportReferencePoints()
Adds the reference points of the entity that is currently being exported to the internal referencePoints map.
bool colorMode
RDocumentInterface & documentInterface
bool exportToPreview
RRefPoint highlightedReferencePoint
bool previewIsEmpty
QMap< RObject::Id, QList< RRefPoint > > referencePoints
Internal map of reference points for every selected entity in the scene.
QList< RGraphicsView * > views
bool deleting
bool hadViews
QDebug operator<<(QDebug dbg, RGraphicsScene &gs)
Stream operator for QDebug.

RGraphicsScene::RGraphicsScene(RDocumentInterface &documentInterface)

All rights reserved.

This file is part of the QCAD project.

QCAD is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

QCAD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with QCAD.

virtual RGraphicsScene::~RGraphicsScene()

virtual

virtual void RGraphicsScene::addPathToPreview(RObject::Id entityId, RPainterPath &pp)

virtual inline

Reimplemented in addPathToPreview.

virtual void RGraphicsScene::addToPreview(RObject::Id entityId, QList< RGraphicsSceneDrawable > &drawables)

virtual inline

Reimplemented in addToPreview.

virtual void RGraphicsScene::addToPreview(RObject::Id entityId, RGraphicsSceneDrawable &drawable)

virtual inline

Reimplemented in addToPreview.

void RGraphicsScene::beginNoColorMode()

inline

virtual void RGraphicsScene::beginPreview()

virtual

virtual void RGraphicsScene::clear()

virtual

Clears (resets) the scene contents.

Reimplemented in clear.

virtual void RGraphicsScene::clearPreview()

virtual

Clears the preview.

Reimplemented in clearPreview.

int RGraphicsScene::countReferencePoints() const

const

virtual void RGraphicsScene::dump()

virtual inline

Reimplemented in dump.

void RGraphicsScene::endNoColorMode()

inline

virtual void RGraphicsScene::endPreview()

virtual

virtual void RGraphicsScene::exportCurrentEntity(bool preview=false, bool forceSelected=false)

virtual

The default implementation calls the REntity::exportEntity() function of the entity.

This method may use the currentEntity stack to access the entity that is currently being exported. Exporters can choose to reimplement this function to export an entity in a target platform specific manner (e.g. to optimize things for a specific platform).

Reimplemented from exportCurrentEntity.

virtual bool RGraphicsScene::exportDocumentSettings()

virtual inline

Override for performance reasons, we don’t need settings to be exported for graphics scenes.

Reimplemented from exportDocumentSettings.

RDocumentInterface & RGraphicsScene::getDocumentInterface()

Returns: Document interface this scene is attached to.

QList< RGraphicsView * > RGraphicsScene::getGraphicsViews() const

const

Returns: List of all views that are attached to this scene.

RRefPoint RGraphicsScene::getHighlightedReferencePoint()

bool RGraphicsScene::getNoColorMode() const

inline const

QMap< RObject::Id, QList< RRefPoint > > & RGraphicsScene::getReferencePoints()

inline

Non-Scriptable: This function is not available in script environments.

void RGraphicsScene::handleKeyPressEvent(QKeyEvent &event)

void RGraphicsScene::handleKeyReleaseEvent(QKeyEvent &event)

void RGraphicsScene::handleMouseDoubleClickEvent(RMouseEvent &event)

Forwards the given mouse event to the document interface.

void RGraphicsScene::handleMouseMoveEvent(RMouseEvent &event)

Forwards the given mouse event to the document interface.

void RGraphicsScene::handleMousePressEvent(RMouseEvent &event)

Forwards the given mouse event to the document interface.

void RGraphicsScene::handleMouseReleaseEvent(RMouseEvent &event)

Forwards the given mouse event to the document interface.

void RGraphicsScene::handlePanGestureEvent(QPanGesture &gesture)

Forwards the given gesture to the document interface.

void RGraphicsScene::handlePinchGestureEvent(QPinchGesture &gesture)

Forwards the given gesture to the document interface.

void RGraphicsScene::handleSwipeGestureEvent(QSwipeGesture &gesture)

Forwards the given gesture to the document interface.

void RGraphicsScene::handleTabletEvent(RTabletEvent &event)

Forwards the given tablet event to the document interface.

void RGraphicsScene::handleTerminateEvent(RTerminateEvent &event)

void RGraphicsScene::handleWheelEvent(RWheelEvent &event)

Forwards the given mouse event to the document interface.

bool RGraphicsScene::hasHadViews() const

inline const

Returns: True if at least one view has been registered with this scene since it was created. Together with an empty list of views this means that all views of this scene have been deleted and the scene is not used anymore.

See also: RDocumentInterface::deleteScenesWithoutViews

bool RGraphicsScene::hasSelectedReferencePoints() const

const

virtual void RGraphicsScene::highlightEntity(REntity &entity)=0 = 0

pure virtual

Highlights the given entity.

This is typically used to highlight entities when the mouse hovers over them.

Reimplemented in highlightEntity.

virtual void RGraphicsScene::highlightReferencePoint(const RRefPoint &position)

virtual

Highlights the reference point at the given position.

This is typically used to highlight reference point when the mouse hovers over them.

virtual bool RGraphicsScene::isPreviewEmpty()

virtual

virtual void RGraphicsScene::regenerate(bool undone=false, bool invisible=false)

virtual

Regenerates this scene from the entity data by exporting the whole document into it.

This can for example regenerate all painter paths or all triangles of the scene. This is called if the scene changes fundamentally or when the entities that are affected by an update are not known.

virtual void RGraphicsScene::regenerate(QSet< RObject::Id > &affectedEntities, bool updateViews)

virtual

virtual void RGraphicsScene::regenerateViews(bool force=false)

virtual

Regenerates all views attached to this scene.

virtual void RGraphicsScene::regenerateViews(QSet< RObject::Id > &affectedEntities)

virtual

virtual void RGraphicsScene::registerView(RGraphicsView *view, bool regen=true)

virtual

Registers a view with this scene.

virtual void RGraphicsScene::repaintViews()

virtual

Repaints all views attached to this scene.

virtual void RGraphicsScene::selectReferencePoints(const RBox &box, bool add)

virtual

virtual void RGraphicsScene::setCursor(const QCursor &cursor)

virtual

virtual void RGraphicsScene::translateEntities(QSet< RObject::Id > &affectedEntities, const RVector &offset)

virtual

Translates the graphical representation of the given entities by the given offset.

The default implementation regenerates the entities. Scenes that cache the graphical representation of entities may override this for performance reasons.

The default implementation exports the entities again (regenerate).

Reimplemented in translateEntities.

virtual void RGraphicsScene::unexportEntity(RObject::Id entityId)

virtual

This is called for entities for which an export was requested but which cannot be instantiated because they either do not exist (anymore) in the DB or they are currently undone.

Reimplemented from unexportEntity.

Reimplemented in unexportEntity.

virtual void RGraphicsScene::unregisterView(RGraphicsView *view)

virtual

Removes the given view from this scene.

virtual void RGraphicsScene::updateSelectionStatus(QSet< RObject::Id > &affectedEntities, bool updateViews)

virtual

Updates the selection status of the given entities.

The default implementation exports the entities again. May be overridden for performance reasons.

Reimplemented in updateSelectionStatus.

static bool RGraphicsScene::isHighlightEnabled(const REntity &entity)

static

Returns: True if the given entity is highlighted when the mouse hovers over it according to the preferences: images and hatches only if enabled (GraphicsView/HighlightImage, GraphicsView/HighlightHatch, default off). Used by the implementations of highlightEntity, which may ignore it (e.g. scenes that highlight entities with a halo).

virtual void RGraphicsScene::exportReferencePoints()

virtual protected

Adds the reference points of the entity that is currently being exported to the internal referencePoints map.

bool RGraphicsScene::colorMode

protected

RDocumentInterface& RGraphicsScene::documentInterface

protected

bool RGraphicsScene::exportToPreview

protected

RRefPoint RGraphicsScene::highlightedReferencePoint

protected

bool RGraphicsScene::previewIsEmpty

protected

QMap<RObject::Id, QList<RRefPoint> > RGraphicsScene::referencePoints

protected

Internal map of reference points for every selected entity in the scene.

Used for drawing reference points.

QList<RGraphicsView*> RGraphicsScene::views

protected

bool RGraphicsScene::deleting

private

bool RGraphicsScene::hadViews

private

QDebug operator<<(QDebug dbg, RGraphicsScene &gs)

Stream operator for QDebug.

Non-Scriptable: This function is not available in script environments.