Fréchet View  1.6.0
A Tool for Exploring Fréchet Distance Algorithms
frechet::view::BaseView Class Reference

Detailed Description

base class for view widgets.

Each view widgets displays a QGraphicsScene (curves, or freespace diagram). It has controls for zooming, rotation, scrolling. Supports zooming with the mouse wheel and with gestures.

Author
Peter Schäfer

Definition at line 79 of file baseview.h.

#include <baseview.h>

Inherits QFrame.

Inherited by frechet::view::CurveView, and frechet::view::FreeSpaceView.

Public Slots

void zoomIn (int level=-1)
 zoom in; connected to the zomm controls More...
 
void zoomOut (int level=-1)
 connected to the zomm controls More...
 
virtual void saveSettings (QSettings &settings, QString group)
 store view settings to application prefs More...
 
virtual void restoreSettings (QSettings &settings, QString group)
 load view settings to application prefs More...
 
void flipVertical (bool flip)
 flip graphics scene vertically More...
 
void mouseMoveEvent (QMouseEvent *event)
 handles a mouse move event and detects mouse sensitve polygon segments More...
 
QPoint mapSceneToGlobal (QPointF p) const
 map scene coordinates to window coordinate More...
 

Public Member Functions

 BaseView (QWidget *parent=0, QString title="", bool showRotate=true)
 constructore with parent and title More...
 
QGraphicsView * view () const
 
virtual void segmentSelected (GraphicsHoverLineItem *item)
 called when the mouse hovers over a polygon segment; implemented by derived classes. More...
 

Protected Slots

void resetView ()
 reset zoom to default More...
 
void setResetButtonEnabled ()
 enabled reset button More...
 
void setupMatrix ()
 set up transformation matrix to account for zoom,rotate,scroll More...
 
void print ()
 print the contents of the graphics scene More...
 
void saveAs ()
 save the contents of the graphics scene to disk (as PDF, or SVG) More...
 
void rotateLeft (double angle=10)
 rotate the scene to the left More...
 
void rotateRight (double angle=10)
 rotate the scene to the right More...
 
int rotation () const
 
void setRotation (double angle)
 update rotation angle More...
 

Protected Member Functions

void resizeEvent (QResizeEvent *) override
 handles window resizes; adjusts controls to new window size More...
 
void saveAsPdf (QString file)
 save content of scene to a PDF file More...
 
void saveAsSvg (QString file)
 save content of scene to an SVG file More...
 
virtual void dropUnusedItems ()
 clean up graphics scene items after free-space is modified implemented by FreeSpaceView. More...
 
virtual void render (QPainter *painter, QRectF target=QRectF())
 render the scene into a QPainter used for printing and saving to disk More...
 
QMatrix baseMatrix ()
 

Static Protected Member Functions

static void setPenWidth (QGraphicsItem *item, double width)
 update the pen width of a graphics item More...
 
static void addLine (QPainterPath &ppath, const QLineF &line)
 add a line segment to a QPainterPath More...
 
static void addPolygon (QPainterPath &ppath, const QPolygonF &poly)
 add a polygon curve segment to a QPainterPath More...
 
static void addPoint (QPainterPath &ppath, const QPointF &point, double diameter=1.0)
 add a dot to a QPainterPath More...
 

Protected Attributes

QGraphicsView * graphicsView
 the embedded QGraphicsView More...
 
QGraphicsScene * scene
 scene that is displayed by graphicsView More...
 
bool isFlipped
 true if the scene should be flipped vertically More...
 
int zoomStepMouse
 zoom step for mouse wheel More...
 
int zoomStepDefault
 default zoom step More...
 
QToolButton * resetButton
 the reset button More...
 
QSlider * zoomSlider
 the slider control for zoom More...
 
QSlider * rotateSlider
 the slider control for rotate More...
 
GraphicsHoverLineItemselected_item
 the currently selected mouse sensitve polyon segment (or nullptr) More...
 

Static Protected Attributes

static const QPen PEN_SELECT
 pen for drawing selected polygon segment More...
 
static const int ROTATE_DEFAULT_VALUE = 0
 what this? More...
 
static const QStringList OUTPUT_FILTERS
 file name filters for save dialog More...
 

Friends

class GraphicsView
 

Constructor & Destructor Documentation

◆ BaseView()

BaseView::BaseView ( QWidget *  parent = 0,
QString  title = "",
bool  showRotate = true 
)

constructore with parent and title

Parameters
parentparent widget (optional)
titlewindow title (optional)
showRotateshow rotation control ?

Definition at line 170 of file baseview.cpp.

Member Function Documentation

◆ addLine()

void BaseView::addLine ( QPainterPath &  ppath,
const QLineF &  line 
)
staticprotected

add a line segment to a QPainterPath

Parameters
ppathpainter path
linea line segment

Definition at line 608 of file baseview.cpp.

◆ addPoint()

void BaseView::addPoint ( QPainterPath &  ppath,
const QPointF &  point,
double  diameter = 1.0 
)
staticprotected

add a dot to a QPainterPath

Parameters
ppathpainter path
pointlocation
diameterdiameter of dot

Definition at line 638 of file baseview.cpp.

◆ addPolygon()

void BaseView::addPolygon ( QPainterPath &  ppath,
const QPolygonF &  poly 
)
staticprotected

add a polygon curve segment to a QPainterPath

Parameters
ppathpainter path
polya polygon curve

Definition at line 622 of file baseview.cpp.

◆ baseMatrix()

QMatrix BaseView::baseMatrix ( )
protected
Returns
basic transformation matrix (takes care of zoom,rotate,scroll)

Definition at line 386 of file baseview.cpp.

◆ dropUnusedItems()

virtual void frechet::view::BaseView::dropUnusedItems ( )
inlineprotectedvirtual

clean up graphics scene items after free-space is modified implemented by FreeSpaceView.

Reimplemented in frechet::view::FreeSpaceView.

Definition at line 203 of file baseview.h.

◆ flipVertical

void BaseView::flipVertical ( bool  flip)
slot

flip graphics scene vertically

Parameters
fliptrue, if scene should be flipped

Definition at line 322 of file baseview.cpp.

◆ mapSceneToGlobal

QPoint BaseView::mapSceneToGlobal ( QPointF  p) const
slot

map scene coordinates to window coordinate

Parameters
pa point in graphics scene coordinates
Returns
the point in window coordinates

Definition at line 360 of file baseview.cpp.

◆ mouseMoveEvent

void BaseView::mouseMoveEvent ( QMouseEvent *  event)
slot

handles a mouse move event and detects mouse sensitve polygon segments

Parameters
eventa mouse event

Dispatch Mouse Hover Events

Note that QGraphicsScene can dispatch hover events, too. But it is quite unreliable with overlapping items, so we have to do it ourselves. Besides, we can influence the sensitivity.

Definition at line 334 of file baseview.cpp.

◆ print

void BaseView::print ( )
protectedslot

print the contents of the graphics scene

Definition at line 400 of file baseview.cpp.

◆ render()

void BaseView::render ( QPainter *  painter,
QRectF  target = QRectF() 
)
protectedvirtual

render the scene into a QPainter used for printing and saving to disk

Parameters
paintera graphics environment that saves data to disk, or sends it to a printer
targettarget frame, should enclose the scene

Definition at line 479 of file baseview.cpp.

◆ resetView

void BaseView::resetView ( )
protectedslot

reset zoom to default

Definition at line 307 of file baseview.cpp.

◆ resizeEvent()

void BaseView::resizeEvent ( QResizeEvent *  event)
overrideprotected

handles window resizes; adjusts controls to new window size

Definition at line 368 of file baseview.cpp.

◆ restoreSettings

void BaseView::restoreSettings ( QSettings &  settings,
QString  group 
)
virtualslot

load view settings to application prefs

Parameters
settingsapplication preferences container
groupsection in preferences

Reimplemented in frechet::view::CurveView.

Definition at line 533 of file baseview.cpp.

◆ rotateLeft

void BaseView::rotateLeft ( double  angle = 10)
protectedslot

rotate the scene to the left

Parameters
anglein degrees

Definition at line 556 of file baseview.cpp.

◆ rotateRight

void BaseView::rotateRight ( double  angle = 10)
protectedslot

rotate the scene to the right

Parameters
anglein degrees

Definition at line 561 of file baseview.cpp.

◆ rotation

int BaseView::rotation ( ) const
protectedslot
Returns
current rotation angle

Definition at line 566 of file baseview.cpp.

◆ saveAs

void BaseView::saveAs ( )
protectedslot

save the contents of the graphics scene to disk (as PDF, or SVG)

Definition at line 413 of file baseview.cpp.

◆ saveAsPdf()

void BaseView::saveAsPdf ( QString  file)
protected

save content of scene to a PDF file

Parameters
filename of pdf file

Definition at line 445 of file baseview.cpp.

◆ saveAsSvg()

void BaseView::saveAsSvg ( QString  file)
protected

save content of scene to an SVG file

Parameters
filename of svg file

Note: sadly, clipping seems not to work with QSvgGenerator. Also, the scene size is not accurate.

Definition at line 461 of file baseview.cpp.

◆ saveSettings

void BaseView::saveSettings ( QSettings &  settings,
QString  group 
)
virtualslot

store view settings to application prefs

Parameters
settingsapplication preferences container
groupsection in preferences

Reimplemented in frechet::view::CurveView.

Definition at line 512 of file baseview.cpp.

◆ segmentSelected()

virtual void frechet::view::BaseView::segmentSelected ( GraphicsHoverLineItem item)
inlinevirtual

called when the mouse hovers over a polygon segment; implemented by derived classes.

Parameters
itema mouse sensitive polygonal segement

Reimplemented in frechet::view::FreeSpaceView, and frechet::view::CurveView.

Definition at line 97 of file baseview.h.

◆ setPenWidth()

void BaseView::setPenWidth ( QGraphicsItem *  item,
double  width 
)
staticprotected

update the pen width of a graphics item

Parameters
itema graphics item
widthnew pen width

Definition at line 579 of file baseview.cpp.

◆ setResetButtonEnabled

void BaseView::setResetButtonEnabled ( )
protectedslot

enabled reset button

Definition at line 317 of file baseview.cpp.

◆ setRotation

void BaseView::setRotation ( double  angle)
protectedslot

update rotation angle

Parameters
anglein degrees

Definition at line 570 of file baseview.cpp.

◆ setupMatrix

void BaseView::setupMatrix ( )
protectedslot

set up transformation matrix to account for zoom,rotate,scroll

Definition at line 374 of file baseview.cpp.

◆ view()

QGraphicsView * BaseView::view ( ) const
Returns
the embedded QGraphicsView

Definition at line 302 of file baseview.cpp.

◆ zoomIn

void BaseView::zoomIn ( int  level = -1)
slot

zoom in; connected to the zomm controls

Parameters
levelzoom step (-1==default)

Definition at line 500 of file baseview.cpp.

◆ zoomOut

void BaseView::zoomOut ( int  level = -1)
slot

connected to the zomm controls

Parameters
levelzoom step (-1==default)

Definition at line 506 of file baseview.cpp.

Friends And Related Function Documentation

◆ GraphicsView

friend class GraphicsView
friend

Definition at line 165 of file baseview.h.

Member Data Documentation

◆ graphicsView

QGraphicsView* frechet::view::BaseView::graphicsView
protected

the embedded QGraphicsView

Definition at line 172 of file baseview.h.

◆ isFlipped

bool frechet::view::BaseView::isFlipped
protected

true if the scene should be flipped vertically

Definition at line 176 of file baseview.h.

◆ OUTPUT_FILTERS

const QStringList BaseView::OUTPUT_FILTERS
staticprotected
Initial value:
= QStringList()
<< "Portable Document Files (*.pdf)"
<< "Vector Graphics (*.svg)"
<< "Any files (*)"

file name filters for save dialog

Graphics scene can be stored as:

Definition at line 170 of file baseview.h.

◆ PEN_SELECT

const QPen BaseView::PEN_SELECT
staticprotected

pen for drawing selected polygon segment

Definition at line 163 of file baseview.h.

◆ resetButton

QToolButton* frechet::view::BaseView::resetButton
protected

the reset button

Definition at line 183 of file baseview.h.

◆ ROTATE_DEFAULT_VALUE

const int frechet::view::BaseView::ROTATE_DEFAULT_VALUE = 0
staticprotected

what this?

Definition at line 168 of file baseview.h.

◆ rotateSlider

QSlider* frechet::view::BaseView::rotateSlider
protected

the slider control for rotate

Definition at line 187 of file baseview.h.

◆ scene

QGraphicsScene* frechet::view::BaseView::scene
protected

scene that is displayed by graphicsView

Definition at line 174 of file baseview.h.

◆ selected_item

GraphicsHoverLineItem* frechet::view::BaseView::selected_item
protected

the currently selected mouse sensitve polyon segment (or nullptr)

Definition at line 189 of file baseview.h.

◆ zoomSlider

QSlider* frechet::view::BaseView::zoomSlider
protected

the slider control for zoom

Definition at line 185 of file baseview.h.

◆ zoomStepDefault

int frechet::view::BaseView::zoomStepDefault
protected

default zoom step

Definition at line 180 of file baseview.h.

◆ zoomStepMouse

int frechet::view::BaseView::zoomStepMouse
protected

zoom step for mouse wheel

Definition at line 178 of file baseview.h.


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