te::qt::widgets::ScaleWidget Class Reference

A widget that shows the graphic scale associated with a display. More...

#include <ScaleWidget.h>

Inheritance diagram for te::qt::widgets::ScaleWidget:
QFrame

Public Types

enum  ScaleTypes {
  RULER, DASHED, DASHED_BEGIN_BLACK, DOUBLE_DASHED,
  DOUBLE_DASHED_BEGIN_BLACK, CUSTOM
}
 Defines the different types of rulers we can use to present the graphical scale. More...
 

Public Slots

Public slots.

Methods to update the internal attributes of the class, using the signal-slot mechanism of QT.

void setInteractionHandle (const bool &state)
 Enable / disable the interaction mode. More...
 
void updateScaleFactor ()
 Updates the scale values. More...
 
void setHeaderColor (const QColor &color)
 Changes the color of the header. More...
 
void setRulerColor (const QColor &color)
 Changes the color of the ruler. More...
 
void setFooterColor (const QColor &color)
 Changes the color of the footer. More...
 
void setBackgroundColor (const QColor &color)
 Changes the color of the background. More...
 
void setHeaderFont (const QFont &font)
 Changes the font of the header. More...
 
void setFooterFont (const QFont &font)
 Changes the font of the footer. More...
 
void setUnit (const QString &unit)
 Sets the unit of measure to be used by the graphic scale. More...
 
void setScaleType (const int &type)
 Sets the type of ruler to be presented. More...
 
void setNumericScaleVisble (const bool &visible)
 Enable / disable the visibility of the footer or the numeric scale. More...
 
void setAllHeaderVisible (const bool &visible)
 Enable / disable intermediary values of the header. More...
 
void setUnitsPerGap (const int &units)
 Changes the number of units to used per interval. More...
 
void setRulerHeightMM (const int &hMM)
 Updates the heightness of the ruler. More...
 
void setNumberOfIntervals (const int &v)
 Updates the number of intervals of the ruler. More...
 

Signals

Signals

Signals emmited by the widget.

void aboutToBeclosed ()
 

Public Member Functions

Constructor and destructor methods.

Methods related to instantiation and destruction.

 ScaleWidget (MapDisplay *parent, const bool &interactive=false)
 Constructor. More...
 
 ~ScaleWidget ()
 Destuctor. More...
 
Public methods

Methods to access the internal attributes of the class.

bool getInteractionHandle () const
 Returns the value of the interaction mode. More...
 
QColor getHeaderColor () const
 Returns the value of the color of the header. More...
 
QColor getRulerColor () const
 Returns the value of the color of the ruler. More...
 
QColor getFooterColor () const
 Returns the value of the color of the footer. More...
 
QFont getHeaderFont () const
 Returns the value of the font of the header. More...
 
QFont getFooterFont () const
 Returns the value of the font of the footer. More...
 
QString getUnit () const
 Returns the unit being used to present the graphic scale. More...
 
int getScaleType () const
 Returns the ruler type being used. More...
 
bool getNumericScaleIsVisible () const
 Returns the visibility of the footer section. More...
 
bool getAllHeaderIsVisible () const
 Returns the visibilty of the intermediary values on the header section. More...
 
int getUnitsPerGap () const
 Returns the number of units used in each gap. More...
 
int getRulerHeightMM () const
 Returns the lenght of the ruler in millimeters. More...
 
int getNumberOfIntervals () const
 Returns the number of intervals being used by ruler. More...
 
void updateScalePosition ()
 Changes the current position of the widget, centralizing it in the display. More...
 
void setUnit (const int &SRID)
 Sets the unit using SRID. More...
 

Protected Member Functions

Protected methods

Methods used internally by the object.

void redoWidget ()
 Recalculates and redraw the graphic scale based on the values of its internal attributes. More...
 
void paintEvent (QPaintEvent *event)
 Reimplementation of the QFrame method. More...
 
void closeEvent (QCloseEvent *event)
 Reimplementation of the QFrame method. More...
 

Protected Attributes

QColor m_bckGrd
 Background color. More...
 
QPixmap * m_bckGround
 Background pixmap. More...
 
MapDisplaym_display
 Pointer to the display where to present the widget. More...
 
double m_factor
 Factor of scaling being used. More...
 
QColor m_footerColor
 Color of the footer section. More...
 
QFont m_footerFont
 Font of the footer section. More...
 
bool m_headerAllVisible
 Flag do enabling / disabling of the intermediary values of the header. More...
 
QColor m_headerColor
 Color of the header section. More...
 
QFont m_headerFont
 Font of the header section. More...
 
bool m_interactionEnabled
 Flag for enabling / disabling the interactive mode. More...
 
std::vector< double > m_intervals
 Values of the intervals in millimeters. More...
 
int m_numberOfIntervals
 Number of intervals of the ruler. More...
 
QColor m_rulerColor
 Color of the ruler section. More...
 
int m_rulerHeightMM
 Height of the ruler in millimeters. More...
 
bool m_showNumericScale
 Flag for enabling / disabling visibility of the footer section. More...
 
ScaleTypes m_type
 Type of the ruler to be presented. More...
 
QString m_unit
 Unit of measure being used. More...
 
int m_unitsPerGap
 Number of units to be used by each interval. More...
 
std::vector< double > m_values
 Values of the intervals in the selected unit of measure. More...
 

Detailed Description

A widget that shows the graphic scale associated with a display.

The widget shows the graphic scale being used by some display. You can change some attributes for a customized presentation. Divided in sections you can set the following attributes:

  1. The unit to be showed.
  2. Header:
    • Font.
    • Color.
    • Visibility of the intermediary values.
  3. Ruler:
    • Color.
    • Units per interval.
    • Number of intervals.
    • Height in millimeters.
    • Type of ruler for presentation pourposes.
  4. Footer:
    • Font.
    • Color.
    • Visibility

The object is divided into three sections: header, ruler and footer. The header shows the values of each interval on the ruler. Ruler is the picture of the ruler itself, and the footer shows the numeric scale showing the scale factor and the unit of measure being used.

Definition at line 99 of file ScaleWidget.h.

Member Enumeration Documentation

Defines the different types of rulers we can use to present the graphical scale.

Enumerator
RULER 

As a ruler.

DASHED 

Alternated rectangles and alternated colors, beginning with a white one.

DASHED_BEGIN_BLACK 

Alternated rectangles and alternated colors, beginning with a colored one.

DOUBLE_DASHED 

Alternated rectangles and alternated colors, beginning with a white one, whith two rulers.

DOUBLE_DASHED_BEGIN_BLACK 

Alternated rectangles and alternated colors, beginning with a colored one, whith two rulers.

CUSTOM 

Customized.

Definition at line 108 of file ScaleWidget.h.

Constructor & Destructor Documentation

te::qt::widgets::ScaleWidget::ScaleWidget ( MapDisplay parent,
const bool interactive = false 
)

Constructor.

Parameters
parentThe display over what the scale will reflect.
interactiveTurn on / off interaction mode. If /a true you will can change the scale position on the display.

Definition at line 858 of file ScaleWidget.cpp.

References m_footerFont, m_headerFont, m_interactionEnabled, and setInteractionHandle().

te::qt::widgets::ScaleWidget::~ScaleWidget ( )

Destuctor.

Definition at line 885 of file ScaleWidget.cpp.

References m_bckGround.

Member Function Documentation

void te::qt::widgets::ScaleWidget::aboutToBeclosed ( )
signal

Signal emmited when the widget is about to be closed.

Referenced by closeEvent().

void te::qt::widgets::ScaleWidget::closeEvent ( QCloseEvent *  event)
protected

Reimplementation of the QFrame method.

Parameters
eventThe event generated.

Definition at line 1129 of file ScaleWidget.cpp.

References aboutToBeclosed().

bool te::qt::widgets::ScaleWidget::getAllHeaderIsVisible ( ) const

Returns the visibilty of the intermediary values on the header section.

Returns
Visibilty of the intermediary values on the header section.

Definition at line 936 of file ScaleWidget.cpp.

References m_headerAllVisible.

Referenced by te::qt::widgets::ScalePropertyBrowser::ScalePropertyBrowser().

QColor te::qt::widgets::ScaleWidget::getFooterColor ( ) const

Returns the value of the color of the footer.

Returns
Value of the color of the footer.

Definition at line 905 of file ScaleWidget.cpp.

References m_footerColor.

Referenced by te::qt::widgets::ScalePropertyBrowser::ScalePropertyBrowser().

QFont te::qt::widgets::ScaleWidget::getFooterFont ( ) const

Returns the value of the font of the footer.

Returns
Value of the font of the footer.

Definition at line 915 of file ScaleWidget.cpp.

References m_footerFont.

Referenced by te::qt::widgets::ScalePropertyBrowser::ScalePropertyBrowser().

QColor te::qt::widgets::ScaleWidget::getHeaderColor ( ) const

Returns the value of the color of the header.

Returns
Value of the color of the header.

Definition at line 895 of file ScaleWidget.cpp.

References m_headerColor.

Referenced by te::qt::widgets::ScalePropertyBrowser::ScalePropertyBrowser().

QFont te::qt::widgets::ScaleWidget::getHeaderFont ( ) const

Returns the value of the font of the header.

Returns
Value of the font of the header.

Definition at line 910 of file ScaleWidget.cpp.

References m_headerFont.

Referenced by te::qt::widgets::ScalePropertyBrowser::ScalePropertyBrowser().

bool te::qt::widgets::ScaleWidget::getInteractionHandle ( ) const

Returns the value of the interaction mode.

Returns
Value of the interaction mode.

Definition at line 890 of file ScaleWidget.cpp.

References m_interactionEnabled.

int te::qt::widgets::ScaleWidget::getNumberOfIntervals ( ) const

Returns the number of intervals being used by ruler.

Returns
Number of intervals being used by ruler.

Definition at line 951 of file ScaleWidget.cpp.

References m_numberOfIntervals.

Referenced by te::qt::widgets::ScalePropertyBrowser::ScalePropertyBrowser().

bool te::qt::widgets::ScaleWidget::getNumericScaleIsVisible ( ) const

Returns the visibility of the footer section.

Returns
Visibility of the footer section.

Definition at line 931 of file ScaleWidget.cpp.

References m_showNumericScale.

Referenced by te::qt::widgets::ScalePropertyBrowser::ScalePropertyBrowser().

QColor te::qt::widgets::ScaleWidget::getRulerColor ( ) const

Returns the value of the color of the ruler.

Returns
Value of the color of the ruler.

Definition at line 900 of file ScaleWidget.cpp.

References m_rulerColor.

Referenced by te::qt::widgets::ScalePropertyBrowser::ScalePropertyBrowser().

int te::qt::widgets::ScaleWidget::getRulerHeightMM ( ) const

Returns the lenght of the ruler in millimeters.

Returns
Lenght of the ruler in millimeters.

Definition at line 946 of file ScaleWidget.cpp.

References m_rulerHeightMM.

Referenced by te::qt::widgets::ScalePropertyBrowser::ScalePropertyBrowser().

int te::qt::widgets::ScaleWidget::getScaleType ( ) const

Returns the ruler type being used.

Returns
Ruler type being used.

Definition at line 926 of file ScaleWidget.cpp.

References m_type.

Referenced by te::qt::widgets::ScalePropertyBrowser::ScalePropertyBrowser().

QString te::qt::widgets::ScaleWidget::getUnit ( ) const

Returns the unit being used to present the graphic scale.

Returns
Unit being used to present the graphic scale.

Definition at line 921 of file ScaleWidget.cpp.

References m_unit.

Referenced by te::qt::widgets::ScalePropertyBrowser::ScalePropertyBrowser().

int te::qt::widgets::ScaleWidget::getUnitsPerGap ( ) const

Returns the number of units used in each gap.

Returns
Number of units used in each gap.

Definition at line 941 of file ScaleWidget.cpp.

References m_unitsPerGap.

Referenced by te::qt::widgets::ScalePropertyBrowser::ScalePropertyBrowser().

void te::qt::widgets::ScaleWidget::paintEvent ( QPaintEvent *  event)
protected

Reimplementation of the QFrame method.

Parameters
eventThe event generated.

Definition at line 1120 of file ScaleWidget.cpp.

References m_bckGround, and p.

void te::qt::widgets::ScaleWidget::setAllHeaderVisible ( const bool visible)
slot

Enable / disable intermediary values of the header.

The first and last elements are alaways visible. But the intermediary values can be hidden / showed.

Parameters
visibleTrue if the intermediary values must be showed and false otherwise.

Definition at line 1067 of file ScaleWidget.cpp.

References m_headerAllVisible, and redoWidget().

void te::qt::widgets::ScaleWidget::setBackgroundColor ( const QColor &  color)
slot

Changes the color of the background.

The initial background color is set to transparent.

Parameters
colorThe new color to be used.

Definition at line 1025 of file ScaleWidget.cpp.

References m_bckGrd, and redoWidget().

Referenced by te::qt::widgets::MapDisplay::showGraphicScale().

void te::qt::widgets::ScaleWidget::setFooterColor ( const QColor &  color)
slot

Changes the color of the footer.

Parameters
colorThe new color to be used.

Definition at line 1017 of file ScaleWidget.cpp.

References m_footerColor, and redoWidget().

void te::qt::widgets::ScaleWidget::setFooterFont ( const QFont &  font)
slot

Changes the font of the footer.

Parameters
fontThe new font to be used.

Definition at line 1039 of file ScaleWidget.cpp.

References m_footerFont, and redoWidget().

void te::qt::widgets::ScaleWidget::setHeaderColor ( const QColor &  color)
slot

Changes the color of the header.

Parameters
colorThe new color to be used.

Definition at line 1003 of file ScaleWidget.cpp.

References m_headerColor, and redoWidget().

void te::qt::widgets::ScaleWidget::setHeaderFont ( const QFont &  font)
slot

Changes the font of the header.

Parameters
fontThe new font to be used.

Definition at line 1032 of file ScaleWidget.cpp.

References m_headerFont, and redoWidget().

void te::qt::widgets::ScaleWidget::setInteractionHandle ( const bool state)
slot

Enable / disable the interaction mode.

If enabled the user can change the scale position on the MapDisplay.

Parameters
stateTrue for enabling of the interaction mode, false to disable it.

Definition at line 987 of file ScaleWidget.cpp.

References m_interactionEnabled, and redoWidget().

Referenced by ScaleWidget().

void te::qt::widgets::ScaleWidget::setNumberOfIntervals ( const int v)
slot

Updates the number of intervals of the ruler.

Parameters
vNumber of intervals of the ruler.

Definition at line 1088 of file ScaleWidget.cpp.

References m_numberOfIntervals, and redoWidget().

void te::qt::widgets::ScaleWidget::setNumericScaleVisble ( const bool visible)
slot

Enable / disable the visibility of the footer or the numeric scale.

Parameters
visibleThe new visibility of the footer section.

Definition at line 1060 of file ScaleWidget.cpp.

References m_showNumericScale, and redoWidget().

void te::qt::widgets::ScaleWidget::setRulerColor ( const QColor &  color)
slot

Changes the color of the ruler.

Parameters
colorThe new color to be used.

Definition at line 1010 of file ScaleWidget.cpp.

References m_rulerColor, and redoWidget().

void te::qt::widgets::ScaleWidget::setRulerHeightMM ( const int hMM)
slot

Updates the heightness of the ruler.

Parameters
hMMThe new height of the ruler in millimeters.
Note
The hMM parameter must be a value of a measure in millimeters.

Definition at line 1081 of file ScaleWidget.cpp.

References m_rulerHeightMM, and redoWidget().

void te::qt::widgets::ScaleWidget::setScaleType ( const int type)
slot

Sets the type of ruler to be presented.

See the definition of ScaleTypes enumeration to see details.

Parameters
typeThe new type of ruler to be presented.

Definition at line 1053 of file ScaleWidget.cpp.

References m_type, and redoWidget().

void te::qt::widgets::ScaleWidget::setUnit ( const int SRID)

Sets the unit using SRID.

Parameters
SRIDThe display SRID.

Definition at line 977 of file ScaleWidget.cpp.

References te::common::Singleton< SpatialReferenceSystemManager >::getInstance(), and GetScaleUnit().

Referenced by te::qt::widgets::MapDisplay::showGraphicScale().

void te::qt::widgets::ScaleWidget::setUnit ( const QString &  unit)
slot

Sets the unit of measure to be used by the graphic scale.

Available units of measure:

  • Meters.
  • Kilometers.
  • Feet.
  • Degrees.
Parameters
unitThe new unit of measure to be used.

Definition at line 1046 of file ScaleWidget.cpp.

References m_unit, and redoWidget().

void te::qt::widgets::ScaleWidget::setUnitsPerGap ( const int units)
slot

Changes the number of units to used per interval.

\ An unit is a value greater then measure corresponding to 1cm that is a better value to be presented. For example, if the display shows a data in a scale 1 : 2924mt, in the ruler we should use intervals of 3000mt, then each unit represents 3000mts.

Parameters
unitsNumber of units to be used in each interval.

Definition at line 1074 of file ScaleWidget.cpp.

References m_unitsPerGap, and redoWidget().

void te::qt::widgets::ScaleWidget::updateScaleFactor ( )
slot

Updates the scale values.

This method must be called when the visualized area changes on the display, to the ScaleWidget be adjusted to the new visualized area.

Definition at line 996 of file ScaleWidget.cpp.

References GetScale(), m_display, m_factor, m_unit, and redoWidget().

Referenced by te::qt::widgets::MultiThreadMapDisplay::setExtent(), te::qt::widgets::MapDisplay::setExtent(), and te::qt::widgets::MapDisplay::setScale().

void te::qt::widgets::ScaleWidget::updateScalePosition ( )

Changes the current position of the widget, centralizing it in the display.

Definition at line 956 of file ScaleWidget.cpp.

References m_display, m_interactionEnabled, and te::qt::widgets::MillimetersToPixels().

Referenced by redoWidget(), te::qt::widgets::MapDisplay::resizeEvent(), and te::qt::widgets::MapDisplay::showGraphicScale().

Member Data Documentation

QColor te::qt::widgets::ScaleWidget::m_bckGrd
protected

Background color.

Definition at line 406 of file ScaleWidget.h.

Referenced by redoWidget(), and setBackgroundColor().

QPixmap* te::qt::widgets::ScaleWidget::m_bckGround
protected

Background pixmap.

Definition at line 396 of file ScaleWidget.h.

Referenced by paintEvent(), redoWidget(), and ~ScaleWidget().

MapDisplay* te::qt::widgets::ScaleWidget::m_display
protected

Pointer to the display where to present the widget.

Definition at line 408 of file ScaleWidget.h.

Referenced by redoWidget(), updateScaleFactor(), and updateScalePosition().

double te::qt::widgets::ScaleWidget::m_factor
protected

Factor of scaling being used.

Definition at line 399 of file ScaleWidget.h.

Referenced by redoWidget(), and updateScaleFactor().

QColor te::qt::widgets::ScaleWidget::m_footerColor
protected

Color of the footer section.

Definition at line 413 of file ScaleWidget.h.

Referenced by getFooterColor(), redoWidget(), and setFooterColor().

QFont te::qt::widgets::ScaleWidget::m_footerFont
protected

Font of the footer section.

Definition at line 397 of file ScaleWidget.h.

Referenced by getFooterFont(), redoWidget(), ScaleWidget(), and setFooterFont().

bool te::qt::widgets::ScaleWidget::m_headerAllVisible
protected

Flag do enabling / disabling of the intermediary values of the header.

Definition at line 411 of file ScaleWidget.h.

Referenced by getAllHeaderIsVisible(), redoWidget(), and setAllHeaderVisible().

QColor te::qt::widgets::ScaleWidget::m_headerColor
protected

Color of the header section.

Definition at line 409 of file ScaleWidget.h.

Referenced by getHeaderColor(), redoWidget(), and setHeaderColor().

QFont te::qt::widgets::ScaleWidget::m_headerFont
protected

Font of the header section.

Definition at line 410 of file ScaleWidget.h.

Referenced by getHeaderFont(), redoWidget(), ScaleWidget(), and setHeaderFont().

bool te::qt::widgets::ScaleWidget::m_interactionEnabled
protected

Flag for enabling / disabling the interactive mode.

Definition at line 407 of file ScaleWidget.h.

Referenced by getInteractionHandle(), redoWidget(), ScaleWidget(), setInteractionHandle(), and updateScalePosition().

std::vector<double> te::qt::widgets::ScaleWidget::m_intervals
protected

Values of the intervals in millimeters.

Definition at line 401 of file ScaleWidget.h.

Referenced by redoWidget().

int te::qt::widgets::ScaleWidget::m_numberOfIntervals
protected

Number of intervals of the ruler.

Definition at line 403 of file ScaleWidget.h.

Referenced by getNumberOfIntervals(), redoWidget(), and setNumberOfIntervals().

QColor te::qt::widgets::ScaleWidget::m_rulerColor
protected

Color of the ruler section.

Definition at line 405 of file ScaleWidget.h.

Referenced by getRulerColor(), redoWidget(), and setRulerColor().

int te::qt::widgets::ScaleWidget::m_rulerHeightMM
protected

Height of the ruler in millimeters.

Definition at line 414 of file ScaleWidget.h.

Referenced by getRulerHeightMM(), redoWidget(), and setRulerHeightMM().

bool te::qt::widgets::ScaleWidget::m_showNumericScale
protected

Flag for enabling / disabling visibility of the footer section.

Definition at line 398 of file ScaleWidget.h.

Referenced by getNumericScaleIsVisible(), redoWidget(), and setNumericScaleVisble().

ScaleTypes te::qt::widgets::ScaleWidget::m_type
protected

Type of the ruler to be presented.

Definition at line 404 of file ScaleWidget.h.

Referenced by getScaleType(), redoWidget(), and setScaleType().

QString te::qt::widgets::ScaleWidget::m_unit
protected

Unit of measure being used.

Definition at line 400 of file ScaleWidget.h.

Referenced by getUnit(), redoWidget(), setUnit(), and updateScaleFactor().

int te::qt::widgets::ScaleWidget::m_unitsPerGap
protected

Number of units to be used by each interval.

Definition at line 412 of file ScaleWidget.h.

Referenced by getUnitsPerGap(), redoWidget(), and setUnitsPerGap().

std::vector<double> te::qt::widgets::ScaleWidget::m_values
protected

Values of the intervals in the selected unit of measure.

Definition at line 402 of file ScaleWidget.h.

Referenced by redoWidget().


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