te::qt::widgets::Measure Class Reference

This class implements a concrete tool to measure operation (distance, area, and angle). More...

#include <Measure.h>

Inheritance diagram for te::qt::widgets::Measure:
te::qt::widgets::AbstractTool

Public Types

enum  MeasureType { Distance, Area, Angle }
 Defines the measure type measured by this tool. More...
 

Public Member Functions

virtual void setCursor (const QCursor &cursor)
 It sets the tool cursor. More...
 
Initializer Methods

Methods related to instantiation and destruction.

 Measure (MapDisplay *display, const MeasureType &measureType, const QCursor &cursor, QObject *parent=0)
 It constructs a measure tool associated with the given map display. More...
 
 ~Measure ()
 Destructor. More...
 
AbstractTool Methods

Methods related with tool behavior.

bool mousePressEvent (QMouseEvent *e)
 This event handler can be reimplemented in a concrete tool class to receive mouse press events for the watched object. More...
 
bool mouseMoveEvent (QMouseEvent *e)
 This event handler can be reimplemented in a concrete tool class to receive mouse move events for the watched object. More...
 
bool mouseReleaseEvent (QMouseEvent *e)
 This event handler can be reimplemented in a concrete tool class to receive mouse release events for the watched object. More...
 
bool mouseDoubleClickEvent (QMouseEvent *e)
 This event handler can be reimplemented in a concrete tool class to receive mouse double click events for the watched object. More...
 
AbstractTool Methods

Methods related with tool behavior.

virtual bool eventFilter (QObject *watched, QEvent *e)
 Filters events if this object has been installed as an event filter for the watched object. More...
 

Protected Attributes

QBrush m_brush
 The brush used to draw the path. More...
 
std::vector< te::gm::Coord2Dm_coords
 The coord list managed by the measure tool. More...
 
QCursor m_cursor
 The default tool cursor. More...
 
MapDisplaym_display
 The map display associated with the tool. More...
 
bool m_isFinished
 A flag that indicates if the operations was finished. More...
 
te::gm::Coord2D m_lastPos
 The last position captured on mouse move event. More...
 
MeasureType m_measureType
 The measure type. More...
 
QPen m_pen
 The pen used to draw the path. More...
 
std::string m_unit
 The unit symbol for the measure. More...
 

Private Slots

void onExtentChanged ()
 

Private Member Functions

double calculateAngle (te::gm::LineString *line) const
 
double calculateLength (te::gm::LineString *line) const
 
void clear ()
 
void drawGeometry ()
 
void drawLine (Canvas &canvas)
 
void drawPolygon (Canvas &canvas)
 
void drawText (Canvas &canvas, const std::string &text, te::gm::Point *p)
 

Detailed Description

This class implements a concrete tool to measure operation (distance, area, and angle).

Definition at line 66 of file Measure.h.

Member Enumeration Documentation

Defines the measure type measured by this tool.

Enumerator
Distance 

Distance.

Area 

Area.

Angle 

Angle.

Definition at line 77 of file Measure.h.

Constructor & Destructor Documentation

te::qt::widgets::Measure::Measure ( MapDisplay display,
const MeasureType measureType,
const QCursor &  cursor,
QObject *  parent = 0 
)

It constructs a measure tool associated with the given map display.

Parameters
displayThe map display associated with the tool.
parentThe tool's parent.
Note
The tool will NOT take the ownership of the given pointers.
te::qt::widgets::Measure::~Measure ( )

Destructor.

Member Function Documentation

double te::qt::widgets::Measure::calculateAngle ( te::gm::LineString line) const
private
double te::qt::widgets::Measure::calculateLength ( te::gm::LineString line) const
private
void te::qt::widgets::Measure::clear ( )
private
void te::qt::widgets::Measure::drawGeometry ( )
private
void te::qt::widgets::Measure::drawLine ( Canvas canvas)
private
void te::qt::widgets::Measure::drawPolygon ( Canvas canvas)
private
void te::qt::widgets::Measure::drawText ( Canvas canvas,
const std::string &  text,
te::gm::Point p 
)
private
virtual bool te::qt::widgets::AbstractTool::eventFilter ( QObject *  watched,
QEvent *  e 
)
virtualinherited

Filters events if this object has been installed as an event filter for the watched object.

Parameters
watchedThe watched object.
eventThe last event sent to watched object.
Note
In your reimplementation of this function, if you want to filter the event out, i.e. stop it being handled further, return true; otherwise return false.
Here, the default implementation looks for QMouseEvents and call the pure virutal methods defined on AbstractTool class, e.g. mousePressEvent().

Reimplemented in te::qt::widgets::ZoomKeyboard, and te::qt::widgets::ZoomWheel.

bool te::qt::widgets::Measure::mouseDoubleClickEvent ( QMouseEvent *  e)
virtual

This event handler can be reimplemented in a concrete tool class to receive mouse double click events for the watched object.

Parameters
eThe mouse event.
Returns
If you want to filter the event out, i.e. stop it being handled further, return true; otherwise return false.
Note
The AbstractTool will also receive mouse press and mouse release events in addition to the double click event. It is up to the developer to ensure that the application interprets these events correctly.

Reimplemented from te::qt::widgets::AbstractTool.

bool te::qt::widgets::Measure::mouseMoveEvent ( QMouseEvent *  e)
virtual

This event handler can be reimplemented in a concrete tool class to receive mouse move events for the watched object.

Parameters
eThe mouse event.
Returns
If you want to filter the event out, i.e. stop it being handled further, return true; otherwise return false.

Reimplemented from te::qt::widgets::AbstractTool.

bool te::qt::widgets::Measure::mousePressEvent ( QMouseEvent *  e)
virtual

This event handler can be reimplemented in a concrete tool class to receive mouse press events for the watched object.

Parameters
eThe mouse event.
Returns
If you want to filter the event out, i.e. stop it being handled further, return true; otherwise return false.

Reimplemented from te::qt::widgets::AbstractTool.

bool te::qt::widgets::Measure::mouseReleaseEvent ( QMouseEvent *  e)
virtual

This event handler can be reimplemented in a concrete tool class to receive mouse release events for the watched object.

Parameters
eThe mouse event.
Returns
If you want to filter the event out, i.e. stop it being handled further, return true; otherwise return false.

Reimplemented from te::qt::widgets::AbstractTool.

void te::qt::widgets::Measure::onExtentChanged ( )
privateslot
virtual void te::qt::widgets::AbstractTool::setCursor ( const QCursor &  cursor)
virtualinherited

It sets the tool cursor.

Parameters
cursorThe cursor that will be used during the tool operation.

Member Data Documentation

QBrush te::qt::widgets::Measure::m_brush
protected

The brush used to draw the path.

Definition at line 145 of file Measure.h.

std::vector<te::gm::Coord2D> te::qt::widgets::Measure::m_coords
protected

The coord list managed by the measure tool.

Definition at line 141 of file Measure.h.

QCursor te::qt::widgets::AbstractTool::m_cursor
protectedinherited

The default tool cursor.

Definition at line 161 of file AbstractTool.h.

MapDisplay* te::qt::widgets::AbstractTool::m_display
protectedinherited

The map display associated with the tool.

Definition at line 160 of file AbstractTool.h.

bool te::qt::widgets::Measure::m_isFinished
protected

A flag that indicates if the operations was finished.

Definition at line 146 of file Measure.h.

te::gm::Coord2D te::qt::widgets::Measure::m_lastPos
protected

The last position captured on mouse move event.

Definition at line 142 of file Measure.h.

MeasureType te::qt::widgets::Measure::m_measureType
protected

The measure type.

Definition at line 143 of file Measure.h.

QPen te::qt::widgets::Measure::m_pen
protected

The pen used to draw the path.

Definition at line 144 of file Measure.h.

std::string te::qt::widgets::Measure::m_unit
protected

The unit symbol for the measure.

Definition at line 147 of file Measure.h.


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