QCAD
Open Source 2D CAD
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RGraphicsScene Class Reference

Abstract base class for all graphics scenes. More...

#include <RGraphicsScene.h>

Inheritance diagram for RGraphicsScene:
RExporter RGraphicsSceneQt

List of all members.

Public Member Functions

virtual void beginPreview ()
virtual void clear ()
 Clears (resets) the scene contents.
virtual void clearPreview ()
 Clears the preview.
virtual void dump ()
virtual void endPreview ()
virtual void exportCurrentEntity (bool preview=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.
RDocumentInterfacegetDocumentInterface ()
QList< RGraphicsView * > getGraphicsViews ()
RVector getHighlightedReferencePoint ()
QMultiMap< REntity::Id, RVector > & 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.
virtual void highlightEntity (REntity &entity)=0
 Highlights the given entity.
virtual void highlightReferencePoint (const RVector &position)
 Highlights the reference point at the given position.
virtual bool isPreviewEmpty ()
virtual void regenerate (bool undone=false)
 Regenerates this scene from the entity data by exporting the whole document into it.
virtual void regenerate (QSet< REntity::Id > &affectedEntities, bool updateViews)
 Regenerates part of this scene from the entity data by exporting the given entities into it.
virtual void regenerateViews (bool force=false)
 Regenerates all views attached to this scene.
virtual void registerView (RGraphicsView *view, bool regen=true)
 Registers a view with this scene.
virtual void repaintViews ()
 Repaints all views attached to this scene.
 RGraphicsScene (RDocumentInterface &documentInterface)
 Copyright (c) 2011-2013 by Andrew Mustun.
virtual void setCursor (const QCursor &cursor)
virtual void unexportEntity (REntity::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< REntity::Id > &affectedEntities, bool updateViews)
 Updates the selection status of the given entities.
virtual ~RGraphicsScene ()
- Public Member Functions inherited from RExporter
virtual void endEntity ()
virtual void endExport ()
 Called at the end of a completed export.
virtual void exportArc (const RArc &arc, double offset=RNANDOUBLE)
virtual void exportArcSegment (const RArc &arc)
virtual void exportBlock (RBlock &)
virtual void exportBlock (RBlock::Id blockId)
virtual void exportBlocks ()
virtual void exportBoundingBoxPaths (const QList< RPainterPath > &paths)
virtual void exportBox (const RBox &box)
 Exports the surfaces of the given box.
virtual void exportCircle (const RCircle &circle)
 Exports a circle with the current attributes.
virtual bool exportDocument ()
 Exports the visual representation of all objects (including entities) of the document->
virtual void exportDocumentSetting (const QString &, const QVariant &)
virtual void exportEllipse (const REllipse &ellipse, double offset=RNANDOUBLE)
 Exports an ellipse with the current attributes.
virtual void exportEntities (bool allBlocks=true, bool undone=false)
virtual void exportEntities (const RBox &box)
 Exports the visual representation of all entities that are completely or partly inside the given area.
virtual void exportEntities (QSet< REntity::Id > &entityIds, bool allBlocks=true)
 Calls exportEntity() for all given entities.
virtual void exportEntity (REntity &e, bool preview=false, bool allBlocks=true)
 Sets the current entity to the given entity and calls exportEntity().
virtual void exportEntity (REntity::Id entityId, bool allBlocks=true)
 Calls exportEntity(REntity*) for the entity with the given ID.
virtual void exportExplodable (const RExplodable &explodable, double offset=RNANDOUBLE)
virtual void exportImage (const RImageData &image)
virtual void exportLayer (RLayer &)
virtual void exportLayer (RLayer::Id layerId)
virtual void exportLayers ()
virtual void exportLine (const RLine &line, double offset=RNANDOUBLE)
 Exports a line with the current attributes.
virtual void exportLineSegment (const RLine &line)=0
 Exports a line segment (a line without pattern).
virtual void exportLinetype (RLinetype &)
virtual void exportLinetypes ()
virtual void exportPainterPaths (const QList< RPainterPath > &paths)
virtual void exportPainterPathSource (const RPainterPathSource &pathSource)
virtual void exportPoint (const RPoint &point)=0
 Exports a point with the current attributes.
virtual void exportPolyline (const RPolyline &polyline, double offset=RNANDOUBLE)
virtual void exportQuad (const RVector &p1, const RVector &p2, const RVector &p3, const RVector &p4)
 Exports a quadrilateral with the current attributes.
virtual void exportRectangle (const RVector &p1, const RVector &p2)
 Exports a rectangle with the current attributes.
virtual void exportShape (QSharedPointer< RShape > shape)
 Exports the given shapes as part of the geometry of the current entity.
virtual void exportShapes (const QList< QSharedPointer< RShape > > &shapes)
 Exports the given shapes as part of the geometry of the current entity.
virtual void exportSpline (const RSpline &spline, double offset=RNANDOUBLE)
virtual void exportTriangle (const RTriangle &triangle)=0
 Exports a triangle with the current attributes.
virtual void exportVerticalQuad (const RVector &p1, const RVector &p2, double height)
 Exports a vertical quadrilateral with the two given base points and the given height.
virtual void exportView (RView &)
virtual void exportView (RView::Id viewId)
virtual void exportViews ()
virtual REntitygetBlockRefOrEntity ()
virtual QBrush getBrush (const RPainterPath &path)
virtual QBrush getBrush ()
RDocumentgetDocument () const
 
bool getDraftMode () const
virtual REntitygetEntity ()
 Sets the current export color for entities.
virtual const REntitygetEntity () const
QStack< REntity * > getEntityStack ()
QString getErrorMessage () const
RLinetypePattern getLinetypePattern ()
virtual double getPatternFactor ()
double getPatternOffset (double length, const RLinetypePattern &pattern)
double getPatternOffset (double length, const RLinetypePattern &pattern, int index, double *gap=NULL)
virtual QPen getPen (const RPainterPath &path)
virtual QPen getPen ()
double getPixelSizeHint () const
RS::ProjectionRenderingHint getProjectionRenderingHint ()
bool getScreenBasedLinetypes () const
virtual bool isEntitySelected ()
bool isVisualExporter () const
 RExporter ()
 RExporter (RDocument &document, RMessageHandler *messageHandler=NULL, RProgressHandler *progressHandler=NULL)
void setBlockSource (RDocument *bs)
virtual void setBrush (const QBrush &brush)
virtual void setBrushStyle (Qt::BrushStyle brushStyle)
virtual void setColor (float r, float g, float b, float a=1.0f)
 Sets the current export color in RGB and Alpha.
virtual void setColor (const RColor &color)
virtual void setDashPattern (const QVector< qreal > &dashes)
void setDraftMode (bool on)
virtual void setEntityAttributes ()
void setLayerSource (RDocument *ls)
virtual void setLinetypeId (RLinetype::Id ltId)
virtual void setLinetypePattern (const RLinetypePattern &ltPattern)
virtual void setLineweight (RLineweight::Lineweight weight)
virtual void setPen (const QPen &pen)
 Sets the current pen (currentPen).
void setPixelSizeHint (double v)
void setProjectionRenderingHint (RS::ProjectionRenderingHint p)
 Sets a rendering hint for the current projection used for exports.
void setScreenBasedLinetypes (bool on)
virtual void setStyle (Qt::PenStyle penStyle)
void setVisualExporter (bool on)
virtual void startEntity (bool)
virtual void startExport ()
 Called to start a new, complete export.
void toggleDraftMode ()
void toggleScreenBasedLinetypes ()
virtual ~RExporter ()

Protected Member Functions

virtual void exportReferencePoints ()
 Adds the reference points of the entity that is currently being exported to the internal referencePoints map.

Protected Attributes

RDocumentInterfacedocumentInterface
bool exportToPreview
RVector highlightedReferencePoint
bool previewIsEmpty
QMultiMap< REntity::Id, RVectorreferencePoints
 Internal map of reference points for every selected entity in the scene.
QList< RGraphicsView * > views
- Protected Attributes inherited from RExporter
QStack< RBlockReferenceEntity * > blockRefStack
RDocumentblockSource
QBrush currentBrush
RLayercurrentLayer
RLinetypePattern currentLinetypePattern
QPen currentPen
RDocumentdocument
bool draftMode
QStack< REntity * > entityStack
QString errorMessage
RDocumentlayerSource
double pixelSizeHint
bool screenBasedLinetypes
bool visualExporter

Private Attributes

bool deleting

Friends

QDebug operator<< (QDebug dbg, RGraphicsScene &gs)
 Called when a view changes its draft mode status or a new view is added.

Detailed Description

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 elements, ...).

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 wrapped for script environments.

Constructor & Destructor Documentation

RGraphicsScene::RGraphicsScene ( RDocumentInterface documentInterface)

Copyright (c) 2011-2013 by Andrew Mustun.

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.

RGraphicsScene::~RGraphicsScene ( )
virtual

Member Function Documentation

void RGraphicsScene::beginPreview ( )
virtual
void RGraphicsScene::clear ( )
virtual

Clears (resets) the scene contents.

Reimplemented in RGraphicsSceneQt.

void RGraphicsScene::clearPreview ( )
virtual

Clears the preview.

Reimplemented in RGraphicsSceneQt.

virtual void RGraphicsScene::dump ( )
inlinevirtual

Reimplemented in RGraphicsSceneQt.

void RGraphicsScene::endPreview ( )
virtual
void RGraphicsScene::exportCurrentEntity ( bool  preview = 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 RExporter.

virtual bool RGraphicsScene::exportDocumentSettings ( )
inlinevirtual

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

Reimplemented from RExporter.

void RGraphicsScene::exportReferencePoints ( )
protectedvirtual

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

RDocumentInterface & RGraphicsScene::getDocumentInterface ( )
Returns:
Document interface this scene is attached to.
QList< RGraphicsView * > RGraphicsScene::getGraphicsViews ( )
Returns:
List of all views that are attached to this scene.
RVector RGraphicsScene::getHighlightedReferencePoint ( )
QMultiMap<REntity::Id, RVector>& RGraphicsScene::getReferencePoints ( )
inline
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.

virtual void RGraphicsScene::highlightEntity ( REntity entity)
pure virtual

Highlights the given entity.

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

Implemented in RGraphicsSceneQt.

void RGraphicsScene::highlightReferencePoint ( const RVector position)
virtual

Highlights the reference point at the given position.

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

bool RGraphicsScene::isPreviewEmpty ( )
virtual
void RGraphicsScene::regenerate ( bool  undone = 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.

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

Regenerates part of this scene from the entity data by exporting the given entities into it.

This is called if the scene changes only partly and the entities that are affected by the update are known.

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

Regenerates all views attached to this scene.

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

Registers a view with this scene.

void RGraphicsScene::repaintViews ( )
virtual

Repaints all views attached to this scene.

void RGraphicsScene::setCursor ( const QCursor &  cursor)
virtual
void RGraphicsScene::unexportEntity ( REntity::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 RExporter.

Reimplemented in RGraphicsSceneQt.

void RGraphicsScene::unregisterView ( RGraphicsView view)
virtual

Removes the given view from this scene.

void RGraphicsScene::updateSelectionStatus ( QSet< REntity::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 RGraphicsSceneQt.


Friends And Related Function Documentation

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

Called when a view changes its draft mode status or a new view is added.

   \par Non-Scriptable:

This function is not available in script environments.

Updates internal information about availability of draft / normal mode. Stream operator for QDebug


Member Data Documentation

bool RGraphicsScene::deleting
private
RDocumentInterface& RGraphicsScene::documentInterface
protected
bool RGraphicsScene::exportToPreview
protected
RVector RGraphicsScene::highlightedReferencePoint
protected
bool RGraphicsScene::previewIsEmpty
protected
QMultiMap<REntity::Id, RVector> RGraphicsScene::referencePoints
protected

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

Used for drawing reference points. TODO: store selection status of reference points.

QList<RGraphicsView*> RGraphicsScene::views
protected

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