#include "ScaleWidget.h"#include "../../../common/STLUtils.h"#include "../../../maptools/Utils.h"#include "../Utils.h"#include "MapDisplay.h"#include <QFont>#include <QIcon>#include <QMap>#include <QPainter>Go to the source code of this file.
Macros | |
| #define | SD_DG QObject::tr("Degrees") |
| #define | SD_FT QObject::tr("Feet") |
| #define | SD_KM QObject::tr("Kilometers") |
| #define | SD_MT QObject::tr("Meters") |
| #define | TD_DG "DEGREE" |
| #define | TD_FT "FEET" |
| #define | TD_KM "KILOMETRE" |
| Definitions. More... | |
| #define | TD_MT "METRE" |
Functions | |
| double | GetScale (const te::qt::widgets::MapDisplay &display, const QString &unit, const bool &printer) |
| Returns the scaling factor of the current visualized area in the display. More... | |
| void | GetScalesIcons (QMap< int, QIcon > &icons, QStringList &typesNames, const QPaintDevice *device, const QColor &color) |
| Returns icons and the respective names for the types of rulers that can be used to present the graphic scale. More... | |
Internally methods. | |
Methods used internally by the ScaleWidget objects. | |
| int | CalculateHeaderHeight (const QFont &font) |
| Returns the height needed to show the header section. More... | |
| int | CalculateScaleHeight (const QPaintDevice *device, const int &heightMM, const bool &printer) |
| Returns the height needed to show the ruler section. More... | |
| QString | GetScaleUnit (const std::string &displayUnit) |
| Returns the unit in the formatting being used. More... | |
| int | CalculateFooterHeight (const QFont &font, const bool &visible) |
| Returns the height needed to show the footer section. More... | |
| int | GetMinimumHeaderWidth (const QPaintDevice *device, const QFont &font, const std::vector< double > &intervals, const std::vector< double > &values, const bool &printer) |
| Returns the minimum width required to draw the header section. More... | |
| int | GetMinimumScaleWidth (const QPaintDevice *device, const std::vector< double > &intervals, const bool &printer) |
| Returns the minimum width required to draw the ruler section. More... | |
| int | GetMinimumFooterWidth (const QFont &font, const QString &unit, const int &factor) |
| Returns the minimum width required to draw the footer section. More... | |
| int | GetMinimumWidth (const QPaintDevice *device, const QFont &headerFont, const QFont &footerFont, const std::vector< double > &intervals, const std::vector< double > &values, const QString &unit, const int &factor, const bool &printer) |
| Returns the minimum width in pixels required by the widget. More... | |
| int | GetMinimumHeight (const QPaintDevice *device, const QFont &headerFont, const QFont &footerFont, const int &rulerHeightMM, const bool &numericScaleVisible, const bool &printer) |
| Returns the minimum height in pixels required by the widget. More... | |
| QSize | GetComponentSize (const QPaintDevice *device, const QFont &headerFont, const QFont &footerFont, const int &heightMM, const std::vector< double > &intervals, const std::vector< double > &values, const bool &printer, const bool &numericScaleVisible, const QString &unit, const int &factor) |
| Returns the minimum dimensions required to draw the widget. More... | |
| QPixmap * | GetDashedScale (const QPaintDevice *device, const int &heightMM, const std::vector< double > &intervals, const bool &beginsBlack, const QColor &color, const bool &printer) |
| Returns a pixmap with the ruler representation of the graphic scale. More... | |
| QPixmap * | GetDoubleDashedScale (const QPaintDevice *device, const int &heightMM, const std::vector< double > intervals, const bool &beginsBlack, const QColor &color, const bool &printer) |
| Returns a representation of two dashed scales one on top of the other with opposite begining intervals. More... | |
| QPixmap * | GetRulerScale (const QPaintDevice *device, const double &heightMM, const std::vector< double > &intervals, const QColor &color, const bool &printer) |
| Returns a ruler representation graphic scale. More... | |
| double | GetSweetGapValue (const double &factor) |
| Returns a rounded value of interval in unit measure. More... | |
| void | GetIntervals (const int &breaks, std::vector< double > &values, std::vector< double > &intervals, const int &unitsPerInterval, const double &factor) |
| Returns the calculated intervals in millimeters and in unit of measure. More... | |
| QPixmap * | MakeHeader (const QPaintDevice *device, const QFont &font, const QColor &color, const std::vector< double > &intervals, const std::vector< double > &values, const bool &showAllValues, const bool &printer, int &pixmapOffset, const bool &toLong) |
| Returns a pixmap with the header section of the graphic scale. More... | |
| QPixmap * | MakeFooter (const int &factor, const QString &unit, const QFont &font, const QColor &color) |
| Returns a pixmap with the footer section of the graphic scale. More... | |
| void | RepaintWidget (QPaintDevice *device, const QFont &headerFont, const QColor &headerColor, const bool &allHeaderVisible, const QColor &rulerColor, const std::vector< double > &intervals, const std::vector< double > &values, const int &heightMM, const bool &showNumericScale, const QFont &footerFont, const QColor &footerColor, const QString &unit, const double &factor, const bool &printer, const te::qt::widgets::ScaleWidget::ScaleTypes &type) |
| Repaints the widget. More... | |
| double | ToMeters (const std::string &fromUnit, const te::gm::Envelope &env, const int &srid) |
| Returns the width of env in meters. More... | |
| double | GetWidthInUnit (const QString &toUnit, const te::gm::Envelope &env, const int &srid) |
| Returns the width of the env, that is in meters, to the destination unit of measure. More... | |
| bool | CompareUnit (const QString &scaleUnit, const int &displaySRID) |
| Comparies the scale unit and the display unit and returns true if it is and false otherwise. More... | |
| #define SD_DG QObject::tr("Degrees") |
Definition at line 45 of file ScaleWidget.cpp.
Referenced by GetScaleUnit(), GetWidthInUnit(), and RepaintWidget().
| #define SD_FT QObject::tr("Feet") |
Definition at line 46 of file ScaleWidget.cpp.
Referenced by GetScaleUnit().
| #define SD_KM QObject::tr("Kilometers") |
Definition at line 43 of file ScaleWidget.cpp.
Referenced by GetScaleUnit(), and GetWidthInUnit().
| #define SD_MT QObject::tr("Meters") |
Definition at line 44 of file ScaleWidget.cpp.
Referenced by GetScaleUnit(), and GetWidthInUnit().
| #define TD_DG "DEGREE" |
Definition at line 41 of file ScaleWidget.cpp.
Referenced by GetScaleUnit(), and ToMeters().
| #define TD_FT "FEET" |
Definition at line 42 of file ScaleWidget.cpp.
| #define TD_KM "KILOMETRE" |
Definitions.
Definition at line 39 of file ScaleWidget.cpp.
Referenced by GetScaleUnit(), and ToMeters().
| #define TD_MT "METRE" |
Definition at line 40 of file ScaleWidget.cpp.
Referenced by GetScaleUnit(), and ToMeters().
Returns the height needed to show the footer section.
| font | The font to be used. |
| visible | True if the footer is visible and false otherwise. |
Definition at line 104 of file ScaleWidget.cpp.
Referenced by GetMinimumHeight().
| int CalculateHeaderHeight | ( | const QFont & | font | ) |
Returns the height needed to show the header section.
| font | The font to be used. |
Definition at line 58 of file ScaleWidget.cpp.
Referenced by GetMinimumHeight(), and MakeHeader().
| int CalculateScaleHeight | ( | const QPaintDevice * | device, |
| const int & | heightMM, | ||
| const bool & | printer | ||
| ) |
Returns the height needed to show the ruler section.
| device | Device to draw. |
| heightMM | The ruler height in millimeters. |
| printer | True if the device is a printer. |
Definition at line 72 of file ScaleWidget.cpp.
References te::qt::widgets::MillimetersToPixels().
Referenced by GetDashedScale(), GetMinimumHeight(), and GetRulerScale().
Comparies the scale unit and the display unit and returns true if it is and false otherwise.
| scaleUnit | The scale unit selected. |
| displaySRID | SRID being used in the display. |
Definition at line 775 of file ScaleWidget.cpp.
References te::common::Singleton< SpatialReferenceSystemManager >::getInstance(), and GetScaleUnit().
Referenced by GetScale().
| QSize GetComponentSize | ( | const QPaintDevice * | device, |
| const QFont & | headerFont, | ||
| const QFont & | footerFont, | ||
| const int & | heightMM, | ||
| const std::vector< double > & | intervals, | ||
| const std::vector< double > & | values, | ||
| const bool & | printer, | ||
| const bool & | numericScaleVisible, | ||
| const QString & | unit, | ||
| const int & | factor | ||
| ) |
Returns the minimum dimensions required to draw the widget.
| device | Device to draw. |
| headerFont | Font of the header section. |
| footerFont | Font of the footer section. |
| heightMM | The height of the ruler in millimeters. |
| intervals | Values of the intervals in millimeters. |
| values | Values fo the intervals in the unit of measure being used. |
| printer | True if the device is a printer. |
| numericScaleVisible | Visibility of the footer section. |
| unit | The unit fo mesaure being used. |
| factor | Scaling factor. |
Definition at line 233 of file ScaleWidget.cpp.
References GetMinimumHeight(), and GetMinimumWidth().
Referenced by te::qt::widgets::ScaleWidget::redoWidget().
| QPixmap* GetDashedScale | ( | const QPaintDevice * | device, |
| const int & | heightMM, | ||
| const std::vector< double > & | intervals, | ||
| const bool & | beginsBlack, | ||
| const QColor & | color, | ||
| const bool & | printer | ||
| ) |
Returns a pixmap with the ruler representation of the graphic scale.
| device | Device to draw. |
| heightMM | The height of the ruler in millimeters. |
| intervals | Values of the intervals in millimeters. |
| beginsBlack | True if the first interval must be colored, false otherwise. |
| color | The color to be used. |
| printer | True if the device is a printer. |
Definition at line 250 of file ScaleWidget.cpp.
References CalculateScaleHeight(), GetMinimumScaleWidth(), te::qt::widgets::MillimetersToPixels(), and p.
Referenced by GetDoubleDashedScale(), GetScalesIcons(), and RepaintWidget().
| QPixmap* GetDoubleDashedScale | ( | const QPaintDevice * | device, |
| const int & | heightMM, | ||
| const std::vector< double > | intervals, | ||
| const bool & | beginsBlack, | ||
| const QColor & | color, | ||
| const bool & | printer | ||
| ) |
Returns a representation of two dashed scales one on top of the other with opposite begining intervals.
| device | Device to draw. |
| heightMM | The height of the ruler in millimeters. |
| intervals | Values of the intervals in millimeters. |
| beginsBlack | True if the first interval must be colored, false otherwise. |
| color | The color to be used. |
| printer | True if the device is a printer. |
Definition at line 297 of file ScaleWidget.cpp.
References GetDashedScale(), and p.
Referenced by GetScalesIcons(), and RepaintWidget().
| void GetIntervals | ( | const int & | breaks, |
| std::vector< double > & | values, | ||
| std::vector< double > & | intervals, | ||
| const int & | unitsPerInterval, | ||
| const double & | factor | ||
| ) |
Returns the calculated intervals in millimeters and in unit of measure.
| breaks | Number of values that determines the intervals on the ruler. | |
| [out] | values | Values of the intervals in the current unit of measure. |
| [out] | intervals | Values of intervals in millimeters. |
| unitsPerInterval | Number of units of scaling will be used in intervals. | |
| factor | Scaling factor. |
Definition at line 430 of file ScaleWidget.cpp.
References GetSweetGapValue().
Referenced by te::qt::widgets::ScaleWidget::redoWidget().
Returns the minimum width required to draw the footer section.
| font | The font to be used. |
| unit | The unit of measure being used. |
| factor | Scaling factor. |
Definition at line 157 of file ScaleWidget.cpp.
Referenced by GetMinimumWidth().
| int GetMinimumHeaderWidth | ( | const QPaintDevice * | device, |
| const QFont & | font, | ||
| const std::vector< double > & | intervals, | ||
| const std::vector< double > & | values, | ||
| const bool & | printer | ||
| ) |
Returns the minimum width required to draw the header section.
| device | Device to draw. |
| font | The font to be used. |
| intervals | Intervals in millimeters. |
| values | Intervals in the selected unit of measure. |
| printer | True if the device is a printer. |
Definition at line 123 of file ScaleWidget.cpp.
References te::qt::widgets::MillimetersToPixels().
Referenced by GetMinimumWidth(), and MakeHeader().
| int GetMinimumHeight | ( | const QPaintDevice * | device, |
| const QFont & | headerFont, | ||
| const QFont & | footerFont, | ||
| const int & | rulerHeightMM, | ||
| const bool & | numericScaleVisible, | ||
| const bool & | printer | ||
| ) |
Returns the minimum height in pixels required by the widget.
| device | Device to draw. |
| headerFont | Font of the header section. |
| footerFont | Font of the footer section. |
| rulerHeightMM | The height of the ruler in millimeters. |
| numericScaleVisible | Visibility of the footer section. |
| printer | True if the device is a printer. |
Definition at line 202 of file ScaleWidget.cpp.
References CalculateFooterHeight(), CalculateHeaderHeight(), CalculateScaleHeight(), and te::qt::widgets::MillimetersToPixels().
Referenced by GetComponentSize().
| int GetMinimumScaleWidth | ( | const QPaintDevice * | device, |
| const std::vector< double > & | intervals, | ||
| const bool & | printer | ||
| ) |
Returns the minimum width required to draw the ruler section.
| device | Device to draw. |
| intervals | Intervals in millimeters. |
| printer | True if the device is a printer. |
Definition at line 143 of file ScaleWidget.cpp.
References te::qt::widgets::MillimetersToPixels().
Referenced by GetDashedScale(), and GetRulerScale().
| int GetMinimumWidth | ( | const QPaintDevice * | device, |
| const QFont & | headerFont, | ||
| const QFont & | footerFont, | ||
| const std::vector< double > & | intervals, | ||
| const std::vector< double > & | values, | ||
| const QString & | unit, | ||
| const int & | factor, | ||
| const bool & | printer | ||
| ) |
Returns the minimum width in pixels required by the widget.
| device | Device to draw. |
| headerFont | Font of the header section. |
| footerFont | Font of the footer section. |
| intervals | Values of the intervals in millimeters. |
| values | Values fo the intervals in the unit of measure being used. |
| unit | The unit fo mesaure being used. |
| factor | Scaling factor. |
| printer | True if the device is a printer. |
Definition at line 180 of file ScaleWidget.cpp.
References GetMinimumFooterWidth(), and GetMinimumHeaderWidth().
Referenced by GetComponentSize().
| QPixmap* GetRulerScale | ( | const QPaintDevice * | device, |
| const double & | heightMM, | ||
| const std::vector< double > & | intervals, | ||
| const QColor & | color, | ||
| const bool & | printer | ||
| ) |
Returns a ruler representation graphic scale.
| device | Device to draw. |
| heightMM | The height of the ruler in millimeters. |
| intervals | Values of the intervals in millimeters. |
| color | The color to be used. |
| printer | True if the device is a printer. |
Definition at line 332 of file ScaleWidget.cpp.
References CalculateScaleHeight(), GetMinimumScaleWidth(), te::qt::widgets::MillimetersToPixels(), and p.
Referenced by GetScalesIcons(), and RepaintWidget().
| double GetScale | ( | const te::qt::widgets::MapDisplay & | display, |
| const QString & | unit, | ||
| const bool & | printer | ||
| ) |
Returns the scaling factor of the current visualized area in the display.
| display | The display being used. |
| unit | Unit of measure to be used. |
| printer | True if the device is a printer. |
Definition at line 795 of file ScaleWidget.cpp.
References CompareUnit(), te::map::MapDisplay::getExtent(), te::map::MapDisplay::getSRID(), te::gm::Envelope::getWidth(), and GetWidthInUnit().
Referenced by te::qt::widgets::ScaleWidget::redoWidget(), and te::qt::widgets::ScaleWidget::updateScaleFactor().
| void GetScalesIcons | ( | QMap< int, QIcon > & | icons, |
| QStringList & | typesNames, | ||
| const QPaintDevice * | device, | ||
| const QColor & | color | ||
| ) |
Returns icons and the respective names for the types of rulers that can be used to present the graphic scale.
| [out] | icons | Generated icons. |
| [out] | typesNames | Generated names. |
| device | The device being used. | |
| color | The color of the ruler. |
Definition at line 811 of file ScaleWidget.cpp.
References te::qt::widgets::ScaleWidget::DASHED, te::qt::widgets::ScaleWidget::DASHED_BEGIN_BLACK, te::qt::widgets::ScaleWidget::DOUBLE_DASHED, te::qt::widgets::ScaleWidget::DOUBLE_DASHED_BEGIN_BLACK, GetDashedScale(), GetDoubleDashedScale(), GetRulerScale(), and te::qt::widgets::ScaleWidget::RULER.
Referenced by te::qt::widgets::ScalePropertyBrowser::ScalePropertyBrowser().
| QString GetScaleUnit | ( | const std::string & | displayUnit | ) |
Returns the unit in the formatting being used.
| displayUnit | Unit being used in the display. |
Definition at line 84 of file ScaleWidget.cpp.
References SD_DG, SD_FT, SD_KM, SD_MT, TD_DG, TD_KM, and TD_MT.
Referenced by CompareUnit(), GetWidthInUnit(), and te::qt::widgets::ScaleWidget::setUnit().
| double GetSweetGapValue | ( | const double & | factor | ) |
Returns a rounded value of interval in unit measure.
| factor | Scaling factor. |
Definition at line 376 of file ScaleWidget.cpp.
References dx.
Referenced by GetIntervals().
| double GetWidthInUnit | ( | const QString & | toUnit, |
| const te::gm::Envelope & | env, | ||
| const int & | srid | ||
| ) |
Returns the width of the env, that is in meters, to the destination unit of measure.
| toUnit | The destination unit of measure. |
| env | The bounding rectangle to be transformed. |
| srid | The identifier of the projection being used by the display. |
Definition at line 743 of file ScaleWidget.cpp.
References te::common::Singleton< SpatialReferenceSystemManager >::getInstance(), GetScaleUnit(), te::gm::Envelope::getWidth(), SD_DG, SD_KM, SD_MT, and ToMeters().
Referenced by GetScale().
| QPixmap* MakeFooter | ( | const int & | factor, |
| const QString & | unit, | ||
| const QFont & | font, | ||
| const QColor & | color | ||
| ) |
Returns a pixmap with the footer section of the graphic scale.
| factor | Scaling factor. |
| unit | Unit of measure being used. |
| font | Footer font. |
| color | Footer color. |
Definition at line 564 of file ScaleWidget.cpp.
References p.
Referenced by RepaintWidget().
| QPixmap* MakeHeader | ( | const QPaintDevice * | device, |
| const QFont & | font, | ||
| const QColor & | color, | ||
| const std::vector< double > & | intervals, | ||
| const std::vector< double > & | values, | ||
| const bool & | showAllValues, | ||
| const bool & | printer, | ||
| int & | pixmapOffset, | ||
| const bool & | toLong | ||
| ) |
Returns a pixmap with the header section of the graphic scale.
| device | Device to draw. | |
| font | Header font. | |
| color | Header color. | |
| intervals | Values of intervals in millimeters. | |
| values | Values of intervals in units of measure. | |
| showAllValues | True to show intermediary values ont the header section, false otherwise. | |
| printer | True if the device is a printer. | |
| [out] | pixmapOffset | Half of the width of the first value. This value is returned to be used to draw the ruler section in the correct position. |
| toLong | If the values of the header are long type values. (If unit is "Degrees" turn off this argument). |
Definition at line 464 of file ScaleWidget.cpp.
References CalculateHeaderHeight(), te::common::FreeContents(), GetMinimumHeaderWidth(), te::qt::widgets::MillimetersToPixels(), and p.
Referenced by RepaintWidget().
| void RepaintWidget | ( | QPaintDevice * | device, |
| const QFont & | headerFont, | ||
| const QColor & | headerColor, | ||
| const bool & | allHeaderVisible, | ||
| const QColor & | rulerColor, | ||
| const std::vector< double > & | intervals, | ||
| const std::vector< double > & | values, | ||
| const int & | heightMM, | ||
| const bool & | showNumericScale, | ||
| const QFont & | footerFont, | ||
| const QColor & | footerColor, | ||
| const QString & | unit, | ||
| const double & | factor, | ||
| const bool & | printer, | ||
| const te::qt::widgets::ScaleWidget::ScaleTypes & | type | ||
| ) |
Repaints the widget.
| device | Device to draw. |
| headerFont | Font of the header section. |
| headerColor | Color of the header section. |
| allHeaderVisible | True to show intermediary values ont the header section, false otherwise. |
| rulerColor | Color of the ruler section. |
| intervals | Values of intervals in millimeters. |
| values | Values of intervals in units of measure. |
| heightMM | Height of the ruler in millimeters. |
| showNumericScale | True to show the footer section, false otherwise. |
| footerFont | Font of the footer section. |
| footerColor | Color of the footer section. |
| unit | Unit of measure to be used. |
| factor | Scaling factor. |
| printer | True if the device is a printer. |
| type | The type of the ruler to be drawed. |
Definition at line 607 of file ScaleWidget.cpp.
References te::qt::widgets::ScaleWidget::CUSTOM, te::qt::widgets::ScaleWidget::DASHED, te::qt::widgets::ScaleWidget::DASHED_BEGIN_BLACK, te::qt::widgets::ScaleWidget::DOUBLE_DASHED, te::qt::widgets::ScaleWidget::DOUBLE_DASHED_BEGIN_BLACK, GetDashedScale(), GetDoubleDashedScale(), GetRulerScale(), MakeFooter(), MakeHeader(), te::qt::widgets::MillimetersToPixels(), p, te::qt::widgets::ScaleWidget::RULER, and SD_DG.
Referenced by te::qt::widgets::ScaleWidget::redoWidget().
| double ToMeters | ( | const std::string & | fromUnit, |
| const te::gm::Envelope & | env, | ||
| const int & | srid | ||
| ) |
Returns the width of env in meters.
| fromUnit | Unit of measure being used by the display. |
| env | The bounding rectangle to be transformed. |
| srid | The identifier of the projection being used by the display. |
Definition at line 697 of file ScaleWidget.cpp.
References te::gm::Envelope::getLowerLeftX(), te::gm::Envelope::getLowerLeftY(), te::gm::Envelope::getUpperRightX(), te::gm::Envelope::getUpperRightY(), te::gm::Envelope::getWidth(), te::map::GetWorldBoxInPlanar(), TD_DG, TD_KM, and TD_MT.
Referenced by GetWidthInUnit().