QCAD
Open Source 2D CAD
RDocumentInterface Class Reference

Interface for interaction between a graphics document and a user. More...

#include <RDocumentInterface.h>

Public Types

enum  IoErrorCode {
  IoErrorNoError, IoErrorNoImporterFound, IoErrorZeroSize, IoErrorNotFound,
  IoErrorPermission, IoErrorGeneralImportError, IoErrorGeneralImportUrlError
}
 

Public Member Functions

void addAuxShapeToPreview (RShape &shape)
 Exports the given shape to the preview. More...
 
void addCoordinateListener (RCoordinateListener *l)
 Adds a listener for coordinate events. More...
 
void addDrawableToPreview (RGraphicsSceneDrawable &drawable)
 
void addEntityToPreview (REntity &entity)
 Adds the given entity to the preview of all scenes / view. More...
 
void addLayerListener (RLayerListener *l)
 
void addShapeToPreview (RShape &shape, const RColor &color, const QBrush &brush, RLineweight::Lineweight lineweight, Qt::PenStyle style, const QList< qreal > &dashValues=RDEFAULT_QLIST_QREAL)
 
int addTransactionListener (RTransactionListener *l)
 
void addZoomBoxToPreview (const RBox &box)
 Adds a box to the preview that represents a zoom box displayed while drawing a window to magnify an area. More...
 
RTransaction applyOperation (ROperation *operation)
 Applies the given operation to the document. More...
 
void autoZoom (int margin=RDEFAULT_MIN1)
 Auto zooms in the view that currently has the focus. More...
 
void beginPreview ()
 After calling this function, all exports go into the preview of the scene instead of the scene itself. More...
 
void clear (bool beforeLoad=false)
 Resets the document to its original, empty state. More...
 
void clearCaches ()
 Clears cached variables to ensure they are re-initialized before the next use. More...
 
void clearPreview ()
 Clears the preview of all scenes. More...
 
void clearProperties ()
 Notifies all property listeners that no properties are relevant at this point. More...
 
void clearSelection ()
 Clears the current selection and updates the scenes / views accordingly. More...
 
void commandEvent (RCommandEvent &event)
 
void commandEventPreview (RCommandEvent &event)
 
void coordinateEvent (RCoordinateEvent &event)
 
void coordinateEventPreview (RCoordinateEvent &event)
 
void deleteTerminatedActions ()
 Deletes all actions that have been terminated. More...
 
void deselectAll ()
 De-select all entities, for convenience. More...
 
int deselectEntities (const QSet< REntity::Id > &entityIds)
 Deselects the given entities and updates the scenes accordingly. More...
 
void deselectEntity (REntity::Id entityId)
 Deselects the given entity and updates the scenes accordingly. More...
 
void disableMouseTracking ()
 
void disableRegeneration ()
 
void disableUpdates ()
 
void enableMouseTracking ()
 
void enableRegeneration ()
 
void enableUpdates ()
 
void endPreview ()
 After calling this function, all exports go into the scene again and not the preview anymore. More...
 
QVariant eval (const QString &ext, const QString &script)
 
bool exportFile (const QString &fileName, const QString &fileVersion="", bool resetModified=true)
 
void flushRedo ()
 Flush redoable transactions. More...
 
void flushTransactions ()
 Flush transactions. More...
 
RAction::ClickMode getClickMode ()
 
REntity::Id getClosestEntity (const RVector &position, double range, double strictRange=RMAXDOUBLE, bool includeLockedLayers=true, bool selectedOnly=false)
 
REntity::Id getClosestEntity (RInputEvent &event)
 
QString getCorrectedFileName (const QString &fileName, const QString &fileVersion)
 
RActiongetCurrentAction ()
 
RColor getCurrentColor ()
 
RLinetype::Id getCurrentLinetypeId ()
 
RLinetypePattern getCurrentLinetypePattern ()
 
RLineweight::Lineweight getCurrentLineweight ()
 
RActiongetCurrentStatefulAction ()
 
RUcs getCurrentUcs ()
 
QString getCurrentUcsName ()
 
bool getCursorOverride () const
 
RVector getCursorPosition () const
 
RActiongetDefaultAction () const
 
RDocumentgetDocument ()
 
QList< RGraphicsScene * > getGraphicsScenes ()
 
RGraphicsScenegetGraphicsSceneWithFocus ()
 
RGraphicsViewgetGraphicsViewWithFocus ()
 
RGraphicsViewgetLastKnownViewWithFocus ()
 
RVector getLastPosition () const
 
bool getNotifyListeners () const
 
RVector getRelativeZero () const
 
RScriptHandlergetScriptHandler (const QString &extension)
 
RSnapgetSnap ()
 Gets the current snap object. More...
 
RSnapRestrictiongetSnapRestriction ()
 
RStoragegetStorage ()
 
bool hasCurrentAction () const
 
bool hasCurrentStatefulAction () const
 
bool hasSelection ()
 
void highlightEntity (REntity::Id entityId)
 
void highlightReferencePoint (const RRefPoint &position)
 Highlights the given reference point. More...
 
RDocumentInterface::IoErrorCode importFile (const QString &fileName, const QString &nameFilter="", bool notify=true)
 Imports the given file if there is a file importer registered for that file type. More...
 
RDocumentInterface::IoErrorCode importUrl (const QUrl &url, const QString &nameFilter="", bool notify=true)
 
bool isClipboard ()
 
bool isDeleting () const
 
bool isPreviewEmpty ()
 
bool isRelativeZeroLocked () const
 
bool isScriptRunning ()
 
bool isSnapLocked () const
 
bool isSuspended ()
 
void keepPreview ()
 Makes sure that the current preview survives one mouse move. More...
 
void keyPressEvent (QKeyEvent &event)
 
void keyReleaseEvent (QKeyEvent &event)
 
void killAllActions ()
 
void lockRelativeZero ()
 Locks the position of the relative zero point. More...
 
void lockSnap ()
 Locks the current snap function so it should not be changed automatically to auto snap. More...
 
void mouseDoubleClickEvent (RMouseEvent &event)
 Forwards the given mouse double click event to the current action. More...
 
void mouseMoveEvent (RMouseEvent &event)
 Forwards the given mouse move event to the current action. More...
 
void mousePressEvent (RMouseEvent &event)
 Forwards the given mouse press event to the current action. More...
 
void mouseReleaseEvent (RMouseEvent &event)
 Forwards the given mouse release event to the current action. More...
 
void notifyCoordinateListeners ()
 Notifies all coordinate listeners that the coordinate has changed to position. More...
 
void notifyLayerListeners (QList< RLayer::Id > &layerIds)
 Notifies local layer listeners only interested in layer events from this particular document. More...
 
void notifyTransactionListeners (RTransaction *t)
 Notifies local transaction listeners only interested in transaction events from this particular document. More...
 
void objectChangeEvent (RTransaction &transaction)
 Triggers an objectChangeEvent for every object in the given set. More...
 
void panGestureEvent (QPanGesture &gesture)
 Forwards the given gesture to the current action. More...
 
void pinchGestureEvent (QPinchGesture &gesture)
 Forwards the given gesture to the current action. More...
 
void previewOperation (ROperation *operation)
 Previews the given operation by applying the operation to a temporary document that is linked to the (read only) document. More...
 
void propertyChangeEvent (RPropertyEvent &event)
 Forwards the given event to the current action to signal that a property value has been changed. More...
 
void queueAction (RAction *action)
 
 RDocumentInterface (RDocument &document)
 
void redo ()
 Transaction based redo. More...
 
void regenerateScenes (bool undone=false)
 Regenerates all scenes attached to this document interface by exporting the document into them. More...
 
void regenerateScenes (QSet< REntity::Id > &entityIds, bool updateViews)
 Regenerates the given part of all scenes attached to this document interface by exporting the given list of entities into them. More...
 
void regenerateScenes (REntity::Id entityId, bool updateViews)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
void regenerateViews (bool force=false)
 Regenerates all views. More...
 
void regenerateViews (QSet< REntity::Id > &entityIds)
 
void registerScene (RGraphicsScene &scene)
 Registers a scene with this document interface. More...
 
void removeLayerListener (RLayerListener *l)
 
void removeTransactionListener (int key)
 
void removeTransactionListener (RTransactionListener *l)
 
void repaintViews ()
 Repaints all views. More...
 
RVector restrictOrtho (const RVector &position, const RVector &relativeZero, RS::OrthoMode mode=RS::Orthogonal)
 
void resume ()
 
void selectAll ()
 Selects all and updates the scenes / views accordingly. More...
 
void selectBoxXY (const RBox &box, bool add=false)
 
int selectEntities (const QSet< REntity::Id > &entityIds, bool add=false)
 Selects the given entities and updates the scenes accordingly. More...
 
void selectEntity (REntity::Id entityId, bool add=false)
 Selects the given entity and updates the scenes accordingly. More...
 
void setClickMode (RAction::ClickMode m)
 Sets the click mode of the current action to the given mode. More...
 
void setCurrentAction (RAction *action)
 Sets the current action. More...
 
void setCurrentBlock (const QString &blockName)
 Sets the current block based on the given block name. More...
 
void setCurrentBlock (const RBlock &block)
 Sets the current block that is in use for all views attached to this document interface. More...
 
void setCurrentBlock (RBlock::Id blockId)
 Sets the current block that is in use for all views attached to this document interface. More...
 
void setCurrentColor (const RColor &color)
 
void setCurrentLayer (const QString &layerName)
 Sets the current layer based on the given layer name. More...
 
void setCurrentLayer (const RLayer &layer)
 Sets the current Layer that is in use for all views attached to this document interface. More...
 
void setCurrentLayer (RLayer::Id layerId)
 
void setCurrentLinetype (RLinetype::Id ltId)
 
void setCurrentLinetypePattern (const RLinetypePattern &p)
 
void setCurrentLineweight (RLineweight::Lineweight lw)
 
void setCurrentUcs (const QString &ucsName)
 Sets the current UCS based on the given UCS name. More...
 
void setCurrentUcs (const RUcs &ucs)
 Sets the current UCS (user coordinate system) that is in use for all views attached to this document interface. More...
 
void setCurrentView (const QString &viewName)
 Sets the current view based on the given view name. More...
 
void setCurrentViewport (const RViewportEntity &viewport)
 
void setCursor (const QCursor &cursor, bool global=true)
 
void setCursorOverride (bool on)
 Force cursor to be shown. More...
 
void setCursorPosition (const RVector &p)
 
void setDefaultAction (RAction *action)
 Sets the action that is active if no other action is active. More...
 
void setLastKnownViewWithFocus (RGraphicsView *view)
 
void setNotifyListeners (bool on)
 
void setRelativeZero (const RVector &p)
 Sets the position of the relative zero point to p and updates the graphics views. More...
 
void setSnap (RSnap *snap)
 Sets the current snap object. More...
 
void setSnapRestriction (RSnapRestriction *snapRestriction)
 Sets the current snap restriction object. More...
 
void showPropertiesOf (REntity &entity)
 Notifies all property listeners that the properties of the given entity should be shown. More...
 
RVector snap (RMouseEvent &event, bool preview=false)
 Uses the current snap to snap the given position to a grid point, end point, etc. More...
 
void suspend ()
 
void swipeGestureEvent (QSwipeGesture &gesture)
 Forwards the given gesture to the current action. More...
 
void tabletEvent (RTabletEvent &event)
 Forwards the given tablet event to the current action. More...
 
void tagState (const QString &tag="")
 
void terminateCurrentAction ()
 
void terminateEvent (RTerminateEvent &event)
 
void toggleSnapLock ()
 Toggles snap lock. More...
 
void ucsSetEvent (const QString &ucsName)
 Called immediately after the user has activated a new UCS to be used as current UCS. More...
 
void undo ()
 Transaction based undo. More...
 
void undoToTag (const QString &tag="")
 Rollback to given transaction ID: More...
 
void unlockRelativeZero ()
 Unlocks the position of the relative zero point. More...
 
void unlockSnap ()
 Unlocks the current snap function so it should be changed automatically to auto snap whenever a new tool is started. More...
 
void unregisterScene (RGraphicsScene &scene)
 Unregisters a scene from this document interface. More...
 
void unsetCurrentViewport ()
 
void updateAllEntities ()
 Marks all entities with any kind of caching as dirty, so they are regenerated next time regenerate is called. More...
 
void updateSelectionStatus (QSet< REntity::Id > &entityIds, bool updateViews)
 
void updateSelectionStatus (REntity::Id entityId, bool updateViews)
 
void wheelEvent (RWheelEvent &event)
 Forwards the given mouse wheel event to the current action. More...
 
void zoomChangeEvent (RGraphicsView &view)
 Called if the zoom (factor, offset) changed in the given view. More...
 
void zoomIn ()
 Zooms in at the view that currently has the focus. More...
 
void zoomOut ()
 Zooms out at the view that currently has the focus. More...
 
void zoomPrevious ()
 Zooms to the previously visible viewport. More...
 
void zoomTo (const RBox &region, int margin=0)
 Zooms to the given region. More...
 
bool zoomToSelection ()
 
 ~RDocumentInterface ()
 

Static Public Member Functions

static void deleteClipboard ()
 
static RDocumentInterfacegetClipboard ()
 

Private Member Functions

void handleClickEvent (RAction &action, RMouseEvent &event)
 Helper function for mouseReleaseEvent. More...
 
void previewClickEvent (RAction &action, RMouseEvent &event)
 Helper function for mouseMoveEvent. More...
 

Private Attributes

bool allowRegeneration
 
bool allowUpdate
 
QList< RCoordinateListener * > coordinateListeners
 
QStack< RAction * > currentActions
 
RSnapcurrentSnap
 
RSnapRestrictioncurrentSnapRestriction
 
RUcs currentUcs
 
QString currentUcsName
 
bool cursorOverride
 
RVector cursorPosition
 
RActiondefaultAction
 
bool deleting
 
RDocumentdocument
 
bool keepPreviewOnce
 
RGraphicsViewlastKnownViewWithFocus
 
RVector lastPosition
 
QList< RLayerListener * > layerListeners
 
bool mouseTrackingEnabled
 
bool notifyGlobalListeners
 
QQueue< RAction * > queuedActions
 
RVector relativeZero
 
bool relativeZeroLocked
 
QList< RGraphicsScene * > scenes
 
QMap< QString, RScriptHandler * > scriptHandlers
 
bool snapLocked
 
bool suspended
 
QMap< QString, int > tags
 
QMap< int, RTransactionListener * > transactionListeners
 

Static Private Attributes

static RDocumentInterfaceclipboard = NULL
 Copyright (c) 2011-2018 by Andrew Mustun. More...
 

Detailed Description

Interface for interaction between a graphics document and a user.

Typically one document interface exists for every document that is open in an MDI application. The document interface owns and links the various scenes, views and the currently active action.

A document interface can own multiple graphics scenes, each of which can have multiple views attached to it. The views forward all user events (mouse moves, mouse clicks, etc.) to the document interface for processing. The document interface dispatches the events to the currently active action object.

Scriptable:\nThis class is available in script environments.\n

Member Enumeration Documentation

◆ IoErrorCode

Enumerator
IoErrorNoError 

No error occurred during import or export.

IoErrorNoImporterFound 

No suitable importer was found.

IoErrorZeroSize 

File size is zero bytes.

IoErrorNotFound 

File not found.

IoErrorPermission 

No permissions to read file.

IoErrorGeneralImportError 

General import error, i.e.

non of the errors above.

IoErrorGeneralImportUrlError 

General import error if an URL was given, i.e.

non of the errors above.

Constructor & Destructor Documentation

◆ RDocumentInterface()

RDocumentInterface::RDocumentInterface ( RDocument document)

◆ ~RDocumentInterface()

RDocumentInterface::~RDocumentInterface ( )

Member Function Documentation

◆ addAuxShapeToPreview()

void RDocumentInterface::addAuxShapeToPreview ( RShape shape)

Exports the given shape to the preview.

Todo:
Support other shapes.

◆ addCoordinateListener()

void RDocumentInterface::addCoordinateListener ( RCoordinateListener l)

Adds a listener for coordinate events.

This can for example be a document specific widget that displays the current coordinate, e.g. rulers.

◆ addDrawableToPreview()

void RDocumentInterface::addDrawableToPreview ( RGraphicsSceneDrawable drawable)

◆ addEntityToPreview()

void RDocumentInterface::addEntityToPreview ( REntity entity)

Adds the given entity to the preview of all scenes / view.

◆ addLayerListener()

void RDocumentInterface::addLayerListener ( RLayerListener l)

◆ addShapeToPreview()

void RDocumentInterface::addShapeToPreview ( RShape shape,
const RColor color,
const QBrush &  brush,
RLineweight::Lineweight  lineweight,
Qt::PenStyle  style,
const QList< qreal > &  dashValues = RDEFAULT_QLIST_QREAL 
)

◆ addTransactionListener()

int RDocumentInterface::addTransactionListener ( RTransactionListener l)

◆ addZoomBoxToPreview()

void RDocumentInterface::addZoomBoxToPreview ( const RBox box)

Adds a box to the preview that represents a zoom box displayed while drawing a window to magnify an area.

◆ applyOperation()

RTransaction RDocumentInterface::applyOperation ( ROperation operation)

Applies the given operation to the document.

The operation might for example do something with the current selection.

◆ autoZoom()

void RDocumentInterface::autoZoom ( int  margin = RDEFAULT_MIN1)

Auto zooms in the view that currently has the focus.

◆ beginPreview()

void RDocumentInterface::beginPreview ( )

After calling this function, all exports go into the preview of the scene instead of the scene itself.

See also
endPreview

◆ clear()

void RDocumentInterface::clear ( bool  beforeLoad = false)

Resets the document to its original, empty state.

◆ clearCaches()

void RDocumentInterface::clearCaches ( )

Clears cached variables to ensure they are re-initialized before the next use.

◆ clearPreview()

void RDocumentInterface::clearPreview ( )

Clears the preview of all scenes.

◆ clearProperties()

void RDocumentInterface::clearProperties ( )

Notifies all property listeners that no properties are relevant at this point.

This can for example clear the property editor and other property listeners.

◆ clearSelection()

void RDocumentInterface::clearSelection ( )

Clears the current selection and updates the scenes / views accordingly.

Todo:
refactor into operations

◆ commandEvent()

void RDocumentInterface::commandEvent ( RCommandEvent event)

◆ commandEventPreview()

void RDocumentInterface::commandEventPreview ( RCommandEvent event)

◆ coordinateEvent()

void RDocumentInterface::coordinateEvent ( RCoordinateEvent event)

◆ coordinateEventPreview()

void RDocumentInterface::coordinateEventPreview ( RCoordinateEvent event)

◆ deleteClipboard()

void RDocumentInterface::deleteClipboard ( )
static

◆ deleteTerminatedActions()

void RDocumentInterface::deleteTerminatedActions ( )

Deletes all actions that have been terminated.

◆ deselectAll()

void RDocumentInterface::deselectAll ( )

De-select all entities, for convenience.

See also
RDocumentInterface::clearSelection()

◆ deselectEntities()

int RDocumentInterface::deselectEntities ( const QSet< REntity::Id > &  entityIds)

Deselects the given entities and updates the scenes accordingly.

◆ deselectEntity()

void RDocumentInterface::deselectEntity ( REntity::Id  entityId)

Deselects the given entity and updates the scenes accordingly.

◆ disableMouseTracking()

void RDocumentInterface::disableMouseTracking ( )

◆ disableRegeneration()

void RDocumentInterface::disableRegeneration ( )

◆ disableUpdates()

void RDocumentInterface::disableUpdates ( )

◆ enableMouseTracking()

void RDocumentInterface::enableMouseTracking ( )

◆ enableRegeneration()

void RDocumentInterface::enableRegeneration ( )

◆ enableUpdates()

void RDocumentInterface::enableUpdates ( )

◆ endPreview()

void RDocumentInterface::endPreview ( )

After calling this function, all exports go into the scene again and not the preview anymore.

See also
beginPreview

◆ eval()

QVariant RDocumentInterface::eval ( const QString &  ext,
const QString &  script 
)

◆ exportFile()

bool RDocumentInterface::exportFile ( const QString &  fileName,
const QString &  fileVersion = "",
bool  resetModified = true 
)

◆ flushRedo()

void RDocumentInterface::flushRedo ( )

Flush redoable transactions.

◆ flushTransactions()

void RDocumentInterface::flushTransactions ( )

Flush transactions.

◆ getClickMode()

RAction::ClickMode RDocumentInterface::getClickMode ( )

◆ getClipboard()

RDocumentInterface & RDocumentInterface::getClipboard ( )
static

◆ getClosestEntity() [1/2]

REntity::Id RDocumentInterface::getClosestEntity ( const RVector position,
double  range,
double  strictRange = RMAXDOUBLE,
bool  includeLockedLayers = true,
bool  selectedOnly = false 
)
Returns
Entity closest to the given position within the given range.
Parameters
rangeMaximum range in drawing units.
strictRangeMaximum range from either end point of the entity. Zero to only return distances that are strictly orthogonal to the entity.
includeLockedLayersReturn entities on locked layers.
selectedOnlyOnly return selected entities.

◆ getClosestEntity() [2/2]

REntity::Id RDocumentInterface::getClosestEntity ( RInputEvent event)
Returns
ID of the entity that is the closest to the mouse cursor of the given event or -1 if no entity is within range.

The event is also used to determine the maximum distance from the cursor to the entity in the view in which the event originated.

◆ getCorrectedFileName()

QString RDocumentInterface::getCorrectedFileName ( const QString &  fileName,
const QString &  fileVersion 
)

◆ getCurrentAction()

RAction * RDocumentInterface::getCurrentAction ( )
Returns
Pointer to the current action or NULL. Used by script interfaces.

◆ getCurrentColor()

RColor RDocumentInterface::getCurrentColor ( )

◆ getCurrentLinetypeId()

RLinetype::Id RDocumentInterface::getCurrentLinetypeId ( )

◆ getCurrentLinetypePattern()

RLinetypePattern RDocumentInterface::getCurrentLinetypePattern ( )

◆ getCurrentLineweight()

RLineweight::Lineweight RDocumentInterface::getCurrentLineweight ( )

◆ getCurrentStatefulAction()

RAction * RDocumentInterface::getCurrentStatefulAction ( )
Returns
First stateful action in action stack. This is the action that will receive zoom change events.

◆ getCurrentUcs()

RUcs RDocumentInterface::getCurrentUcs ( )
Returns
The current UCS (user coordinate system).

◆ getCurrentUcsName()

QString RDocumentInterface::getCurrentUcsName ( )
Returns
The current UCS name.

◆ getCursorOverride()

bool RDocumentInterface::getCursorOverride ( ) const

◆ getCursorPosition()

RVector RDocumentInterface::getCursorPosition ( ) const
Returns
The last known mouse cursor position in model coordinates.

◆ getDefaultAction()

RAction * RDocumentInterface::getDefaultAction ( ) const

◆ getDocument()

RDocument & RDocumentInterface::getDocument ( )
Returns
Reference to underlying document.

◆ getGraphicsScenes()

QList< RGraphicsScene * > RDocumentInterface::getGraphicsScenes ( )
Returns
List of attached graphics scenes.

◆ getGraphicsSceneWithFocus()

RGraphicsScene * RDocumentInterface::getGraphicsSceneWithFocus ( )
Returns
The graphics scene that currently has the focus or the first attached scene or NULL if no scene is attached.

◆ getGraphicsViewWithFocus()

RGraphicsView * RDocumentInterface::getGraphicsViewWithFocus ( )
Returns
The graphics view that currently has the focus or the first attached view or NULL if no view is attached.

◆ getLastKnownViewWithFocus()

RGraphicsView * RDocumentInterface::getLastKnownViewWithFocus ( )

◆ getLastPosition()

RVector RDocumentInterface::getLastPosition ( ) const
Returns
The last used position, even if the relative zero is locked in one position.

◆ getNotifyListeners()

bool RDocumentInterface::getNotifyListeners ( ) const
inline

◆ getRelativeZero()

RVector RDocumentInterface::getRelativeZero ( ) const
Returns
The relative zero position in model coordinates.

◆ getScriptHandler()

RScriptHandler * RDocumentInterface::getScriptHandler ( const QString &  extension)

◆ getSnap()

RSnap * RDocumentInterface::getSnap ( )

Gets the current snap object.

◆ getSnapRestriction()

RSnapRestriction * RDocumentInterface::getSnapRestriction ( )

◆ getStorage()

RStorage & RDocumentInterface::getStorage ( )
Returns
Reference to underlying storage.

◆ handleClickEvent()

void RDocumentInterface::handleClickEvent ( RAction action,
RMouseEvent event 
)
private

Helper function for mouseReleaseEvent.

Triggers an appropriate higher level event for mouse clicks for the given action. The event type depends on the action's current ClickMode.

◆ hasCurrentAction()

bool RDocumentInterface::hasCurrentAction ( ) const
Returns
True if at least one action is active.

◆ hasCurrentStatefulAction()

bool RDocumentInterface::hasCurrentStatefulAction ( ) const
Returns
true if there are any stateful actions in the action stack.

◆ hasSelection()

bool RDocumentInterface::hasSelection ( )
Returns
True if the document has selected entities.

◆ highlightEntity()

void RDocumentInterface::highlightEntity ( REntity::Id  entityId)

◆ highlightReferencePoint()

void RDocumentInterface::highlightReferencePoint ( const RRefPoint position)

Highlights the given reference point.

◆ importFile()

RDocumentInterface::IoErrorCode RDocumentInterface::importFile ( const QString &  fileName,
const QString &  nameFilter = "",
bool  notify = true 
)

Imports the given file if there is a file importer registered for that file type.

◆ importUrl()

RDocumentInterface::IoErrorCode RDocumentInterface::importUrl ( const QUrl &  url,
const QString &  nameFilter = "",
bool  notify = true 
)

◆ isClipboard()

bool RDocumentInterface::isClipboard ( )
inline

◆ isDeleting()

bool RDocumentInterface::isDeleting ( ) const
inline

◆ isPreviewEmpty()

bool RDocumentInterface::isPreviewEmpty ( )
Returns
True if the previews of all scenes are empty. This is used to detect if the views needs to be redrawn after a mouse move event.

◆ isRelativeZeroLocked()

bool RDocumentInterface::isRelativeZeroLocked ( ) const
Returns
true if the position of the relative zero point is locked.

◆ isScriptRunning()

bool RDocumentInterface::isScriptRunning ( )

◆ isSnapLocked()

bool RDocumentInterface::isSnapLocked ( ) const
Returns
True if snap is locked and should never be changed automatically.

◆ isSuspended()

bool RDocumentInterface::isSuspended ( )
inline

◆ keepPreview()

void RDocumentInterface::keepPreview ( )

Makes sure that the current preview survives one mouse move.

◆ keyPressEvent()

void RDocumentInterface::keyPressEvent ( QKeyEvent &  event)

◆ keyReleaseEvent()

void RDocumentInterface::keyReleaseEvent ( QKeyEvent &  event)

◆ killAllActions()

void RDocumentInterface::killAllActions ( )

◆ lockRelativeZero()

void RDocumentInterface::lockRelativeZero ( )

Locks the position of the relative zero point.

◆ lockSnap()

void RDocumentInterface::lockSnap ( )

Locks the current snap function so it should not be changed automatically to auto snap.

◆ mouseDoubleClickEvent()

void RDocumentInterface::mouseDoubleClickEvent ( RMouseEvent event)

Forwards the given mouse double click event to the current action.

◆ mouseMoveEvent()

void RDocumentInterface::mouseMoveEvent ( RMouseEvent event)

Forwards the given mouse move event to the current action.

◆ mousePressEvent()

void RDocumentInterface::mousePressEvent ( RMouseEvent event)

Forwards the given mouse press event to the current action.

◆ mouseReleaseEvent()

void RDocumentInterface::mouseReleaseEvent ( RMouseEvent event)

Forwards the given mouse release event to the current action.

◆ notifyCoordinateListeners()

void RDocumentInterface::notifyCoordinateListeners ( )

Notifies all coordinate listeners that the coordinate has changed to position.

◆ notifyLayerListeners()

void RDocumentInterface::notifyLayerListeners ( QList< RLayer::Id > &  layerIds)

Notifies local layer listeners only interested in layer events from this particular document.

Used for layer lists other than the global one (e.g. in preferences).

◆ notifyTransactionListeners()

void RDocumentInterface::notifyTransactionListeners ( RTransaction t)

Notifies local transaction listeners only interested in transaction events from this particular document.

◆ objectChangeEvent()

void RDocumentInterface::objectChangeEvent ( RTransaction transaction)

Triggers an objectChangeEvent for every object in the given set.

◆ panGestureEvent()

void RDocumentInterface::panGestureEvent ( QPanGesture &  gesture)

Forwards the given gesture to the current action.

◆ pinchGestureEvent()

void RDocumentInterface::pinchGestureEvent ( QPinchGesture &  gesture)

Forwards the given gesture to the current action.

◆ previewClickEvent()

void RDocumentInterface::previewClickEvent ( RAction action,
RMouseEvent event 
)
private

Helper function for mouseMoveEvent.

Triggers an appropriate preview event for the given action and the current click mode the action is in.

◆ previewOperation()

void RDocumentInterface::previewOperation ( ROperation operation)

Previews the given operation by applying the operation to a temporary document that is linked to the (read only) document.

◆ propertyChangeEvent()

void RDocumentInterface::propertyChangeEvent ( RPropertyEvent event)

Forwards the given event to the current action to signal that a property value has been changed.

◆ queueAction()

void RDocumentInterface::queueAction ( RAction action)

◆ redo()

void RDocumentInterface::redo ( )

Transaction based redo.

◆ regenerateScenes() [1/3]

void RDocumentInterface::regenerateScenes ( bool  undone = false)

Regenerates all scenes attached to this document interface by exporting the document into them.

◆ regenerateScenes() [2/3]

void RDocumentInterface::regenerateScenes ( QSet< REntity::Id > &  entityIds,
bool  updateViews 
)

Regenerates the given part of all scenes attached to this document interface by exporting the given list of entities into them.

◆ regenerateScenes() [3/3]

void RDocumentInterface::regenerateScenes ( REntity::Id  entityId,
bool  updateViews 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ regenerateViews() [1/2]

void RDocumentInterface::regenerateViews ( bool  force = false)

Regenerates all views.

◆ regenerateViews() [2/2]

void RDocumentInterface::regenerateViews ( QSet< REntity::Id > &  entityIds)

◆ registerScene()

void RDocumentInterface::registerScene ( RGraphicsScene scene)

Registers a scene with this document interface.

◆ removeLayerListener()

void RDocumentInterface::removeLayerListener ( RLayerListener l)

◆ removeTransactionListener() [1/2]

void RDocumentInterface::removeTransactionListener ( int  key)

◆ removeTransactionListener() [2/2]

void RDocumentInterface::removeTransactionListener ( RTransactionListener l)

◆ repaintViews()

void RDocumentInterface::repaintViews ( )

Repaints all views.

◆ restrictOrtho()

RVector RDocumentInterface::restrictOrtho ( const RVector position,
const RVector relativeZero,
RS::OrthoMode  mode = RS::Orthogonal 
)

◆ resume()

void RDocumentInterface::resume ( )

◆ selectAll()

void RDocumentInterface::selectAll ( )

Selects all and updates the scenes / views accordingly.

◆ selectBoxXY()

void RDocumentInterface::selectBoxXY ( const RBox box,
bool  add = false 
)

◆ selectEntities()

int RDocumentInterface::selectEntities ( const QSet< REntity::Id > &  entityIds,
bool  add = false 
)

Selects the given entities and updates the scenes accordingly.

Parameters
addTrue to add to the current selection, false otherwise.

◆ selectEntity()

void RDocumentInterface::selectEntity ( REntity::Id  entityId,
bool  add = false 
)

Selects the given entity and updates the scenes accordingly.

Parameters
addTrue to add to the current selection, false otherwise.
Todo:
refactor into operations

◆ setClickMode()

void RDocumentInterface::setClickMode ( RAction::ClickMode  m)

Sets the click mode of the current action to the given mode.

See also
ClickMode

◆ setCurrentAction()

void RDocumentInterface::setCurrentAction ( RAction action)

Sets the current action.

This action will receive all events until it finishes.

◆ setCurrentBlock() [1/3]

void RDocumentInterface::setCurrentBlock ( const QString &  blockName)

Sets the current block based on the given block name.

◆ setCurrentBlock() [2/3]

void RDocumentInterface::setCurrentBlock ( const RBlock block)

Sets the current block that is in use for all views attached to this document interface.

◆ setCurrentBlock() [3/3]

void RDocumentInterface::setCurrentBlock ( RBlock::Id  blockId)

Sets the current block that is in use for all views attached to this document interface.

◆ setCurrentColor()

void RDocumentInterface::setCurrentColor ( const RColor color)

◆ setCurrentLayer() [1/3]

void RDocumentInterface::setCurrentLayer ( const QString &  layerName)

Sets the current layer based on the given layer name.

◆ setCurrentLayer() [2/3]

void RDocumentInterface::setCurrentLayer ( const RLayer layer)

Sets the current Layer that is in use for all views attached to this document interface.

◆ setCurrentLayer() [3/3]

void RDocumentInterface::setCurrentLayer ( RLayer::Id  layerId)

◆ setCurrentLinetype()

void RDocumentInterface::setCurrentLinetype ( RLinetype::Id  ltId)

◆ setCurrentLinetypePattern()

void RDocumentInterface::setCurrentLinetypePattern ( const RLinetypePattern p)

◆ setCurrentLineweight()

void RDocumentInterface::setCurrentLineweight ( RLineweight::Lineweight  lw)

◆ setCurrentUcs() [1/2]

void RDocumentInterface::setCurrentUcs ( const QString &  ucsName)

Sets the current UCS based on the given UCS name.

Todo:
refactor to store current UCS in document / storage like layer

◆ setCurrentUcs() [2/2]

void RDocumentInterface::setCurrentUcs ( const RUcs ucs)

Sets the current UCS (user coordinate system) that is in use for all views attached to this document interface.

◆ setCurrentView()

void RDocumentInterface::setCurrentView ( const QString &  viewName)

Sets the current view based on the given view name.

◆ setCurrentViewport()

void RDocumentInterface::setCurrentViewport ( const RViewportEntity viewport)

◆ setCursor()

void RDocumentInterface::setCursor ( const QCursor &  cursor,
bool  global = true 
)

◆ setCursorOverride()

void RDocumentInterface::setCursorOverride ( bool  on)

Force cursor to be shown.

Used for e.g. snap to intersection manual where we want to show the cursor even though we are in entity picking mode.

◆ setCursorPosition()

void RDocumentInterface::setCursorPosition ( const RVector p)

◆ setDefaultAction()

void RDocumentInterface::setDefaultAction ( RAction action)

Sets the action that is active if no other action is active.

◆ setLastKnownViewWithFocus()

void RDocumentInterface::setLastKnownViewWithFocus ( RGraphicsView view)

◆ setNotifyListeners()

void RDocumentInterface::setNotifyListeners ( bool  on)
inline

◆ setRelativeZero()

void RDocumentInterface::setRelativeZero ( const RVector p)

Sets the position of the relative zero point to p and updates the graphics views.

If the relative zero position is locked it is not moved.

◆ setSnap()

void RDocumentInterface::setSnap ( RSnap snap)

Sets the current snap object.

The document interface takes ownership of the object.

◆ setSnapRestriction()

void RDocumentInterface::setSnapRestriction ( RSnapRestriction snapRestriction)

Sets the current snap restriction object.

The document interface takes ownership of the object.

◆ showPropertiesOf()

void RDocumentInterface::showPropertiesOf ( REntity entity)

Notifies all property listeners that the properties of the given entity should be shown.

◆ snap()

RVector RDocumentInterface::snap ( RMouseEvent event,
bool  preview = false 
)

Uses the current snap to snap the given position to a grid point, end point, etc.

Returns
Coordinate to which was snapped.

◆ suspend()

void RDocumentInterface::suspend ( )

◆ swipeGestureEvent()

void RDocumentInterface::swipeGestureEvent ( QSwipeGesture &  gesture)

Forwards the given gesture to the current action.

◆ tabletEvent()

void RDocumentInterface::tabletEvent ( RTabletEvent event)

Forwards the given tablet event to the current action.

◆ tagState()

void RDocumentInterface::tagState ( const QString &  tag = "")

◆ terminateCurrentAction()

void RDocumentInterface::terminateCurrentAction ( )

◆ terminateEvent()

void RDocumentInterface::terminateEvent ( RTerminateEvent event)

◆ toggleSnapLock()

void RDocumentInterface::toggleSnapLock ( )

Toggles snap lock.

◆ ucsSetEvent()

void RDocumentInterface::ucsSetEvent ( const QString &  ucsName)

Called immediately after the user has activated a new UCS to be used as current UCS.

◆ undo()

void RDocumentInterface::undo ( )

Transaction based undo.

◆ undoToTag()

void RDocumentInterface::undoToTag ( const QString &  tag = "")

Rollback to given transaction ID:

◆ unlockRelativeZero()

void RDocumentInterface::unlockRelativeZero ( )

Unlocks the position of the relative zero point.

◆ unlockSnap()

void RDocumentInterface::unlockSnap ( )

Unlocks the current snap function so it should be changed automatically to auto snap whenever a new tool is started.

◆ unregisterScene()

void RDocumentInterface::unregisterScene ( RGraphicsScene scene)

Unregisters a scene from this document interface.

◆ unsetCurrentViewport()

void RDocumentInterface::unsetCurrentViewport ( )

◆ updateAllEntities()

void RDocumentInterface::updateAllEntities ( )

Marks all entities with any kind of caching as dirty, so they are regenerated next time regenerate is called.

◆ updateSelectionStatus() [1/2]

void RDocumentInterface::updateSelectionStatus ( QSet< REntity::Id > &  entityIds,
bool  updateViews 
)

◆ updateSelectionStatus() [2/2]

void RDocumentInterface::updateSelectionStatus ( REntity::Id  entityId,
bool  updateViews 
)

◆ wheelEvent()

void RDocumentInterface::wheelEvent ( RWheelEvent event)

Forwards the given mouse wheel event to the current action.

◆ zoomChangeEvent()

void RDocumentInterface::zoomChangeEvent ( RGraphicsView view)

Called if the zoom (factor, offset) changed in the given view.

◆ zoomIn()

void RDocumentInterface::zoomIn ( )

Zooms in at the view that currently has the focus.

◆ zoomOut()

void RDocumentInterface::zoomOut ( )

Zooms out at the view that currently has the focus.

◆ zoomPrevious()

void RDocumentInterface::zoomPrevious ( )

Zooms to the previously visible viewport.

◆ zoomTo()

void RDocumentInterface::zoomTo ( const RBox region,
int  margin = 0 
)

Zooms to the given region.

◆ zoomToSelection()

bool RDocumentInterface::zoomToSelection ( )

Member Data Documentation

◆ allowRegeneration

bool RDocumentInterface::allowRegeneration
private

◆ allowUpdate

bool RDocumentInterface::allowUpdate
private

◆ clipboard

RDocumentInterface * RDocumentInterface::clipboard = NULL
staticprivate

Copyright (c) 2011-2018 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.

◆ coordinateListeners

QList<RCoordinateListener*> RDocumentInterface::coordinateListeners
private

◆ currentActions

QStack<RAction*> RDocumentInterface::currentActions
private

◆ currentSnap

RSnap* RDocumentInterface::currentSnap
private

◆ currentSnapRestriction

RSnapRestriction* RDocumentInterface::currentSnapRestriction
private

◆ currentUcs

RUcs RDocumentInterface::currentUcs
private

◆ currentUcsName

QString RDocumentInterface::currentUcsName
private

◆ cursorOverride

bool RDocumentInterface::cursorOverride
private

◆ cursorPosition

RVector RDocumentInterface::cursorPosition
private

◆ defaultAction

RAction* RDocumentInterface::defaultAction
private

◆ deleting

bool RDocumentInterface::deleting
private

◆ document

RDocument& RDocumentInterface::document
private

◆ keepPreviewOnce

bool RDocumentInterface::keepPreviewOnce
private

◆ lastKnownViewWithFocus

RGraphicsView* RDocumentInterface::lastKnownViewWithFocus
private

◆ lastPosition

RVector RDocumentInterface::lastPosition
private

◆ layerListeners

QList<RLayerListener*> RDocumentInterface::layerListeners
private

◆ mouseTrackingEnabled

bool RDocumentInterface::mouseTrackingEnabled
private

◆ notifyGlobalListeners

bool RDocumentInterface::notifyGlobalListeners
private

◆ queuedActions

QQueue<RAction*> RDocumentInterface::queuedActions
private

◆ relativeZero

RVector RDocumentInterface::relativeZero
private

◆ relativeZeroLocked

bool RDocumentInterface::relativeZeroLocked
private

◆ scenes

QList<RGraphicsScene*> RDocumentInterface::scenes
private

◆ scriptHandlers

QMap<QString, RScriptHandler*> RDocumentInterface::scriptHandlers
private

◆ snapLocked

bool RDocumentInterface::snapLocked
private

◆ suspended

bool RDocumentInterface::suspended
private

◆ tags

QMap<QString, int> RDocumentInterface::tags
private

◆ transactionListeners

QMap<int, RTransactionListener*> RDocumentInterface::transactionListeners
private

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