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

Graphics view. More...

#include <RGraphicsView.h>

Inheritance diagram for RGraphicsView:
RNonCopyable RGraphicsViewImage RGraphicsViewQt AutoZoomView

List of all members.

Public Types

enum  ColorMode { FullColor, GrayScale, BlackWhite }

Public Member Functions

void addTextLabel (const RTextLabel &textLabel)
void autoZoom (int margin=RDEFAULT_MIN1)
virtual void centerToBox (const RBox &box)
 Centers the view on the given box.
virtual void centerToPoint (const RVector &point)
 Centers the view on the given point.
void clearCaches ()
void clearTextLabels ()
QColor getBackgroundColor ()
virtual RBox getBox () const
REntity::Id getClosestEntity (const RVector &screenPosition, int range, bool includeLockedLayers=true)
 Finds the entity that is the closest to the given screen coordinate (in pixels).
RVector getClosestReferencePoint (const RVector &screenPosition, int range)
 Finds the reference point that is the closest to the given screen coordinate (in pixels).
RVector getClosestReferencePoint (REntity::Id entityId, const RVector &screenPosition)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
RGraphicsView::ColorMode getColorMode ()
RVector getCurrentStepOffset () const
double getCurrentStepScaleFactor () const
virtual QCursor getCursor ()
RDocumentgetDocument () const
RDocumentInterfacegetDocumentInterface ()
double getFactor (bool includeStepFactor=true) const
RGridgetGrid ()
virtual int getHeight () const =0
RVector getLastKnownMousePosition () const
int getMargin ()
virtual RVector getMaximum () const
virtual RVector getMinimum () const
RVector getOffset (bool includeStepOffset=true) const
RGraphicsScenegetScene ()
int getTextHeightThresholdOverride () const
QList< RTextLabelgetTextLabels ()
int getViewportNumber () const
virtual int getWidth () const =0
virtual void handleKeyPressEvent (QKeyEvent &event)
virtual void handleKeyReleaseEvent (QKeyEvent &event)
virtual void handleMouseDoubleClickEvent (RMouseEvent &event)
 This should be called by the mouse double click event handler of a higher level GUI toolkit.
virtual void handleMouseMoveEvent (RMouseEvent &event)
 This should be called by the mouse move event handler of a higher level GUI toolkit.
virtual void handleMousePressEvent (RMouseEvent &event)
 This should be called by the mouse press event handler of a higher level GUI toolkit.
virtual void handleMouseReleaseEvent (RMouseEvent &event)
 This should be called by the mouse release event handler of a higher level GUI toolkit.
virtual void handlePanGestureEvent (QPanGesture &gesture)
virtual void handlePinchGestureEvent (QPinchGesture &gesture)
virtual void handleSwipeGestureEvent (QSwipeGesture &gesture)
virtual void handleTabletEvent (RTabletEvent &event)
 This should be called by the tablet event handler of a higher level GUI toolkit.
virtual void handleTerminateEvent (RTerminateEvent &event)
virtual void handleWheelEvent (RWheelEvent &event)
 This should be called by the mouse wheel event handler of a higher level GUI toolkit.
virtual bool hasFocus ()=0
bool isGridVisible () const
bool isPathVisible (const RPainterPath &path) const
bool isPrinting () const
bool isPrintPreview () const
virtual QList< RVectormapCornersFromView () const
virtual double mapDistanceFromView (double d) const =0
 Maps the given view distance in pixels to a model distance.
virtual double mapDistanceToView (double d) const =0
 Maps the given model distance to a screen distance in pixels.
virtual RVector mapFromView (const RVector &v, double z=0.0) const =0
 Maps the given view coordinate in pixels to a model coordinate.
virtual RVector mapToView (const RVector &v) const =0
 Maps the given model coordinate to a view coordinate in pixels.
virtual RBox mapToView (const RBox &box) const
 Finds the entity that is the closest to the given screen coordinate (in pixels) and inside the current UCS (read floor).
virtual void paintGridLine (const RLine &)
virtual void paintGridPoint (const RVector &)
virtual void pan (const RVector &delta, bool regen=true)
 Pans (scrolls) by the given amount delta which is a vector in screen coordinates (pixels).
virtual void regenerate (bool force=false)=0
 Regenerates the view to show the visible parts of the underlying scene.
virtual void removeFocus ()=0
virtual void repaintView ()=0
 Repaints the view (widget, etc..).
void restoreViewport ()
 RGraphicsView (RGraphicsScene *scene=NULL)
 Copyright (c) 2011-2013 by Andrew Mustun.
void saveViewport ()
virtual void setBackgroundColor (const QColor &col)
void setColorMode (RGraphicsView::ColorMode cm)
void setCurrentStepOffset (const RVector &s)
void setCurrentStepScaleFactor (double f)
virtual void setCursor (Qt::CursorShape)
virtual void setCursor (const QCursor &)
void setDisplayOnlyCurrentUcs (bool on)
 If on is true, only the current UCS and the entities that are in its range are displayed.
void setFactor (double f, bool regen=true)
void setGrid (RGrid *g)
 Sets the current grid.
void setGridVisible (bool on)
void setMargin (int m)
void setNavigationAction (RAction *action)
 Sets an action object that is typically used to handle all navigation interaction (zooming, panning, ...).
void setOffset (const RVector &offset, bool regen=true)
void setPrinting (bool on)
void setPrintPointSize (const RVector &s)
void setPrintPreview (bool on)
virtual void setScene (RGraphicsScene *scene, bool regen=true)
void setTextHeightThresholdOverride (int v)
void setViewportNumber (int n)
virtual void simulateMouseMoveEvent ()
void startPan ()
void updateTextHeightThreshold ()
virtual void viewportChangeEvent ()
virtual void zoom (const RVector &center, double factor)
 Zooms in / out by the given factor towards / from the given center in scene coordinates.
void zoomIn ()
 Zooms in by factor 1.2.
void zoomIn (const RVector &center)
 Zooms in by factor 1.2.
void zoomOut ()
 Zooms out by factor 1.2.
void zoomOut (const RVector &center)
 Zooms out by factor 1.0/1.2.
void zoomPrevious ()
virtual void zoomTo (const RBox &window, int margin=0)
 Zooms the view in a way that the given window is visible and fills the view.
bool zoomToSelection ()
virtual ~RGraphicsView ()

Protected Attributes

bool autoScalePatterns
QColor backgroundColor
ColorMode colorMode
RVector currentStepOffset
double currentStepScaleFactor
 Current scale factor caused by a pinch gesture.
bool displayOnlyCurrentUcs
 True to only display entities within the horizontal slice that is defined by the current UCS.
double factor
 Scale factor from model coordinates to view coordinates.
RGridgrid
 Grid that is currently displayed by this view or NULL.
int gridVisible
RVector lastKnownModelPosition
RVector lastKnownViewPosition
int margin
RActionnavigationAction
 The navigation action of this view or NULL if no navigation action has been set.
RVector offset
 Offset of the zero point from the lower left corner of the view in model coordinates.
double previousFactor
RVector previousOffset
bool printing
RVector printPointSize
bool printPreview
RGraphicsScenescene
 The scene this view is attached to.
int textHeightThreshold
int textHeightThresholdOverride
QList< RTextLabeltextLabels
 Internal list of text labels that were added to this view.
int viewportNumber

Additional Inherited Members


Detailed Description

Graphics view.

A graphics view displays a (part of a) graphics scene.

Scriptable:
This class is wrapped for script environments.

Member Enumeration Documentation

Enumerator:
FullColor 
GrayScale 
BlackWhite 

Constructor & Destructor Documentation

RGraphicsView::RGraphicsView ( RGraphicsScene scene = NULL)

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.

RGraphicsView::~RGraphicsView ( )
virtual

Member Function Documentation

void RGraphicsView::addTextLabel ( const RTextLabel textLabel)
void RGraphicsView::autoZoom ( int  margin = RDEFAULT_MIN1)

Reimplemented in RGraphicsViewImage.

void RGraphicsView::centerToBox ( const RBox box)
virtual

Centers the view on the given box.

The view is updated.

Parameters:
boxBox to move into the center of the drawing in model coordinates.

Reimplemented in RGraphicsViewImage.

void RGraphicsView::centerToPoint ( const RVector point)
virtual

Centers the view on the given point.

The view is updated.

Parameters:
pointPoint to move into the center of the drawing in model coordinates.

Reimplemented in RGraphicsViewImage.

void RGraphicsView::clearCaches ( )
void RGraphicsView::clearTextLabels ( )
QColor RGraphicsView::getBackgroundColor ( )

Reimplemented in RGraphicsViewImage.

RBox RGraphicsView::getBox ( ) const
virtual

Reimplemented in RGraphicsViewImage.

REntity::Id RGraphicsView::getClosestEntity ( const RVector screenPosition,
int  range,
bool  includeLockedLayers = true 
)

Finds the entity that is the closest to the given screen coordinate (in pixels).

Parameters:
rangeMaximum distance in pixels.
Returns:
The closest entity or NULL.
RVector RGraphicsView::getClosestReferencePoint ( const RVector screenPosition,
int  range 
)

Finds the reference point that is the closest to the given screen coordinate (in pixels).

Parameters:
rangeMaximum distance in pixels.
Returns:
The closest referecene point in model coordiantes.
RVector RGraphicsView::getClosestReferencePoint ( REntity::Id  entityId,
const RVector screenPosition 
)

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

RGraphicsView::ColorMode RGraphicsView::getColorMode ( )
RVector RGraphicsView::getCurrentStepOffset ( ) const
inline
double RGraphicsView::getCurrentStepScaleFactor ( ) const
inline
virtual QCursor RGraphicsView::getCursor ( )
inlinevirtual

Reimplemented in RGraphicsViewQt.

RDocument * RGraphicsView::getDocument ( ) const
Returns:
Reference to the document that is visualized by this view.
RDocumentInterface * RGraphicsView::getDocumentInterface ( )
Returns:
Reference to the document interface.

Reimplemented in RGraphicsViewImage.

double RGraphicsView::getFactor ( bool  includeStepFactor = true) const

Reimplemented in RGraphicsViewImage.

RGrid* RGraphicsView::getGrid ( )
inline
Returns:
Current grid or NULL if no grid is set.

Reimplemented in RGraphicsViewImage.

virtual int RGraphicsView::getHeight ( ) const
pure virtual
Returns:
Height of the view in pixels.

Implemented in RGraphicsViewImage, and RGraphicsViewQt.

RVector RGraphicsView::getLastKnownMousePosition ( ) const
inline
int RGraphicsView::getMargin ( )
RVector RGraphicsView::getMaximum ( ) const
virtual
Returns:
The maximum coordinate that is currently visible in the view.
RVector RGraphicsView::getMinimum ( ) const
virtual
Returns:
The minimum coordinate that is currently visible in the view.
RVector RGraphicsView::getOffset ( bool  includeStepOffset = true) const

Reimplemented in RGraphicsViewImage.

RGraphicsScene * RGraphicsView::getScene ( )
Returns:
Reference to the graphics scene that is visualized by this view.

Reimplemented in RGraphicsViewImage.

int RGraphicsView::getTextHeightThresholdOverride ( ) const
inline

Reimplemented in RGraphicsViewImage.

QList< RTextLabel > RGraphicsView::getTextLabels ( )
int RGraphicsView::getViewportNumber ( ) const
inline

Reimplemented in RGraphicsViewImage.

virtual int RGraphicsView::getWidth ( ) const
pure virtual
Returns:
Width of the view in pixels.

Implemented in RGraphicsViewImage, and RGraphicsViewQt.

void RGraphicsView::handleKeyPressEvent ( QKeyEvent &  event)
virtual
void RGraphicsView::handleKeyReleaseEvent ( QKeyEvent &  event)
virtual
void RGraphicsView::handleMouseDoubleClickEvent ( RMouseEvent event)
virtual

This should be called by the mouse double click event handler of a higher level GUI toolkit.

Events are forwarded to the scene and the navigation action that is attached to this view.

void RGraphicsView::handleMouseMoveEvent ( RMouseEvent event)
virtual

This should be called by the mouse move event handler of a higher level GUI toolkit.

Events are forwarded to the scene and the navigation action that is attached to this view.

void RGraphicsView::handleMousePressEvent ( RMouseEvent event)
virtual

This should be called by the mouse press event handler of a higher level GUI toolkit.

Events are forwarded to the scene and the navigation action that is attached to this view.

void RGraphicsView::handleMouseReleaseEvent ( RMouseEvent event)
virtual

This should be called by the mouse release event handler of a higher level GUI toolkit.

Events are forwarded to the scene and the navigation action that is attached to this view.

void RGraphicsView::handlePanGestureEvent ( QPanGesture &  gesture)
virtual
void RGraphicsView::handlePinchGestureEvent ( QPinchGesture &  gesture)
virtual
void RGraphicsView::handleSwipeGestureEvent ( QSwipeGesture &  gesture)
virtual
void RGraphicsView::handleTabletEvent ( RTabletEvent event)
virtual

This should be called by the tablet event handler of a higher level GUI toolkit.

Events are forwarded to the scene and the navigation action that is attached to this view.

void RGraphicsView::handleTerminateEvent ( RTerminateEvent event)
virtual
void RGraphicsView::handleWheelEvent ( RWheelEvent event)
virtual

This should be called by the mouse wheel event handler of a higher level GUI toolkit.

Events are forwarded to the scene and the navigation action that is attached to this view.

virtual bool RGraphicsView::hasFocus ( )
pure virtual
Returns:
True if this view currently has the focus.

Implemented in RGraphicsViewImage, and RGraphicsViewQt.

bool RGraphicsView::isGridVisible ( ) const

Reimplemented in RGraphicsViewImage.

bool RGraphicsView::isPathVisible ( const RPainterPath path) const
bool RGraphicsView::isPrinting ( ) const

Reimplemented in RGraphicsViewImage.

bool RGraphicsView::isPrintPreview ( ) const

Reimplemented in RGraphicsViewImage.

QList< RVector > RGraphicsView::mapCornersFromView ( ) const
virtual
Returns:
Four vectors with the coordiantes of the four corners of the view mapped to scene coordiantes.
virtual double RGraphicsView::mapDistanceFromView ( double  d) const
pure virtual

Maps the given view distance in pixels to a model distance.

If the view projection is not orthogonal the result is undefined.

Implemented in RGraphicsViewImage.

virtual double RGraphicsView::mapDistanceToView ( double  d) const
pure virtual

Maps the given model distance to a screen distance in pixels.

If the view projection is not orthogonal the result is undefined.

Implemented in RGraphicsViewImage.

virtual RVector RGraphicsView::mapFromView ( const RVector v,
double  z = 0.0 
) const
pure virtual

Maps the given view coordinate in pixels to a model coordinate.

Parameters:
vview coordinate in pixels, v.z is always 0
zknown z coordinate in model units

Implemented in RGraphicsViewImage.

virtual RVector RGraphicsView::mapToView ( const RVector v) const
pure virtual

Maps the given model coordinate to a view coordinate in pixels.

Implemented in RGraphicsViewImage.

RBox RGraphicsView::mapToView ( const RBox box) const
virtual

Finds the entity that is the closest to the given screen coordinate (in pixels) and inside the current UCS (read floor).

Parameters:
rangeMaximum distance in pixels.
Returns:
The closest entity or NULL. Maps the given box (e.g. a 3d bounding box) to a 2d box in view coordinates (pixels).
virtual void RGraphicsView::paintGridLine ( const RLine )
inlinevirtual

Reimplemented in RGraphicsViewImage.

virtual void RGraphicsView::paintGridPoint ( const RVector )
inlinevirtual

Reimplemented in RGraphicsViewImage.

void RGraphicsView::pan ( const RVector delta,
bool  regen = true 
)
virtual

Pans (scrolls) by the given amount delta which is a vector in screen coordinates (pixels).

virtual void RGraphicsView::regenerate ( bool  force = false)
pure virtual

Regenerates the view to show the visible parts of the underlying scene.

This function is called after the entities have been modified or the view port changed after a zoom or pan or after the window has been resized.

Parameters:
forceTrue if scene has changed, don't use any optimizations, force regeneration.

Implemented in RGraphicsViewImage.

virtual void RGraphicsView::removeFocus ( )
pure virtual

Implemented in RGraphicsViewImage, and RGraphicsViewQt.

virtual void RGraphicsView::repaintView ( )
pure virtual

Repaints the view (widget, etc..).

This differs from regenerate in that it does not require the view to iterate through the scene elements. Instead for example a buffered bitmap might be drawn. This is for example called when the preview changes to restore the view before painting the preview on top of it.

Implemented in RGraphicsViewImage, and RGraphicsViewQt.

void RGraphicsView::restoreViewport ( )

Reimplemented in RGraphicsViewImage.

void RGraphicsView::saveViewport ( )

Reimplemented in RGraphicsViewImage.

void RGraphicsView::setBackgroundColor ( const QColor &  col)
virtual

Reimplemented in RGraphicsViewImage.

void RGraphicsView::setColorMode ( RGraphicsView::ColorMode  cm)

Reimplemented in RGraphicsViewImage.

void RGraphicsView::setCurrentStepOffset ( const RVector s)
inline
void RGraphicsView::setCurrentStepScaleFactor ( double  f)
inline
virtual void RGraphicsView::setCursor ( Qt::CursorShape  )
inlinevirtual

Reimplemented in RGraphicsViewQt.

virtual void RGraphicsView::setCursor ( const QCursor &  )
inlinevirtual

Reimplemented in RGraphicsViewQt.

void RGraphicsView::setDisplayOnlyCurrentUcs ( bool  on)

If on is true, only the current UCS and the entities that are in its range are displayed.

The range of a UCS is defined by the length of its axis vectors. This can be used to display only one floor in an architecture application.

void RGraphicsView::setFactor ( double  f,
bool  regen = true 
)

Reimplemented in RGraphicsViewImage.

void RGraphicsView::setGrid ( RGrid g)
inline

Sets the current grid.

This graphics view takes ownership of the grid. The previous grid is deleted. Setting the grid to NULL disables the grid.

Reimplemented in RGraphicsViewImage.

void RGraphicsView::setGridVisible ( bool  on)

Reimplemented in RGraphicsViewImage.

void RGraphicsView::setMargin ( int  m)

Reimplemented in RGraphicsViewImage.

void RGraphicsView::setNavigationAction ( RAction action)

Sets an action object that is typically used to handle all navigation interaction (zooming, panning, ...).

All events that are received by this view are first sent to the graphics scene and then to this action if they were not consumed yet.

Reimplemented in RGraphicsViewImage.

void RGraphicsView::setOffset ( const RVector offset,
bool  regen = true 
)

Reimplemented in RGraphicsViewImage.

void RGraphicsView::setPrinting ( bool  on)

Reimplemented in RGraphicsViewImage.

void RGraphicsView::setPrintPointSize ( const RVector s)

Reimplemented in RGraphicsViewImage.

void RGraphicsView::setPrintPreview ( bool  on)

Reimplemented in RGraphicsViewImage.

void RGraphicsView::setScene ( RGraphicsScene scene,
bool  regen = true 
)
virtual
void RGraphicsView::setTextHeightThresholdOverride ( int  v)
inline

Reimplemented in RGraphicsViewImage.

void RGraphicsView::setViewportNumber ( int  n)

Reimplemented in RGraphicsViewImage.

void RGraphicsView::simulateMouseMoveEvent ( )
virtual

Reimplemented in RGraphicsViewImage.

void RGraphicsView::startPan ( )
void RGraphicsView::updateTextHeightThreshold ( )
void RGraphicsView::viewportChangeEvent ( )
virtual

Reimplemented in RGraphicsViewQt.

void RGraphicsView::zoom ( const RVector center,
double  factor 
)
virtual

Zooms in / out by the given factor towards / from the given center in scene coordinates.

Reimplemented in RGraphicsViewImage.

void RGraphicsView::zoomIn ( )

Zooms in by factor 1.2.

The center point is at the center of the view.

void RGraphicsView::zoomIn ( const RVector center)

Zooms in by factor 1.2.

The given center point stays at the same position.

void RGraphicsView::zoomOut ( )

Zooms out by factor 1.2.

The center point is at the center of the view.

void RGraphicsView::zoomOut ( const RVector center)

Zooms out by factor 1.0/1.2.

The given center point stays at the same position.

void RGraphicsView::zoomPrevious ( )
void RGraphicsView::zoomTo ( const RBox window,
int  margin = 0 
)
virtual

Zooms the view in a way that the given window is visible and fills the view.

The view is updated.

Reimplemented in RGraphicsViewImage.

bool RGraphicsView::zoomToSelection ( )

Member Data Documentation

bool RGraphicsView::autoScalePatterns
protected
QColor RGraphicsView::backgroundColor
protected
ColorMode RGraphicsView::colorMode
protected
RVector RGraphicsView::currentStepOffset
protected
double RGraphicsView::currentStepScaleFactor
protected

Current scale factor caused by a pinch gesture.

bool RGraphicsView::displayOnlyCurrentUcs
protected

True to only display entities within the horizontal slice that is defined by the current UCS.

double RGraphicsView::factor
protected

Scale factor from model coordinates to view coordinates.

RGrid* RGraphicsView::grid
protected

Grid that is currently displayed by this view or NULL.

int RGraphicsView::gridVisible
mutableprotected
RVector RGraphicsView::lastKnownModelPosition
protected
RVector RGraphicsView::lastKnownViewPosition
protected
int RGraphicsView::margin
protected
RAction* RGraphicsView::navigationAction
protected

The navigation action of this view or NULL if no navigation action has been set.

RVector RGraphicsView::offset
protected

Offset of the zero point from the lower left corner of the view in model coordinates.

double RGraphicsView::previousFactor
protected
RVector RGraphicsView::previousOffset
protected
bool RGraphicsView::printing
protected
RVector RGraphicsView::printPointSize
protected
bool RGraphicsView::printPreview
protected
RGraphicsScene* RGraphicsView::scene
protected

The scene this view is attached to.

int RGraphicsView::textHeightThreshold
protected
int RGraphicsView::textHeightThresholdOverride
protected
QList<RTextLabel> RGraphicsView::textLabels
protected

Internal list of text labels that were added to this view.

int RGraphicsView::viewportNumber
protected

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