Legend

Search for usage in LXR

#include <legend.h>

Public Types

enum  LEGEND_ORIENTATION { LO_HORIZONTAL , LO_VERTICAL }
 
enum  LEGEND_POSITION {
  LP_UPPER_LEFT , LP_UPPER_RIGHT , LP_LOWER_LEFT , LP_LOWER_RIGHT ,
  LP_FLOATING
}
 
enum  LEGEND_TYPE {
  LT_FULL , LT_SCALE_MAGNITUDES , LT_SCALE_ONLY , LT_MAGNITUDES_ONLY ,
  LT_SYMBOLS_ONLY
}
 

Public Member Functions

 Legend (LEGEND_ORIENTATION orientation=LO_HORIZONTAL, LEGEND_POSITION pos=LP_FLOATING)
 
 ~Legend ()
 
QSize calculateSize ()
 
QColor getBgColor () const
 
int getBRectHeight () const
 
int getBRectWidth () const
 
bool getDrawFrame () const
 
QPoint getFloatingPosition () const
 
QFont getFont () const
 
int getMaxHScalePixels () const
 
int getMaxVScalePixels () const
 
LEGEND_ORIENTATION getOrientation () const
 
LEGEND_POSITION getPosition () const
 
int getSymbolSize () const
 
LEGEND_TYPE getType () const
 
int getXSymbolSpacing () const
 
int getYSymbolSpacing () const
 
void paintLegend (QPaintDevice *pd)
 
void paintLegend (QPaintDevice *pd, LEGEND_TYPE type, LEGEND_POSITION pos)
 
void paintLegend (SkyQPainter *painter)
 
void paintLegend (SkyQPainter *painter, LEGEND_TYPE type, LEGEND_POSITION pos)
 
void setBgColor (const QColor &color)
 
void setBRectHeight (int height)
 
void setBRectWidth (int width)
 
void setDrawFrame (bool draw)
 
void setFloatingPosition (QPoint pos)
 
void setFont (const QFont &font)
 
void setMaxHScalePixels (int pixels)
 
void setMaxVScalePixels (int pixels)
 
void setOrientation (LEGEND_ORIENTATION orientation)
 
void setPosition (LEGEND_POSITION pos)
 
void setSymbolSize (int size)
 
void setType (LEGEND_TYPE type)
 
void setXSymbolSpacing (int spacing)
 
void setYSymbolSpacing (int spacing)
 
 Legend (const Legend &o)
 
Legendoperator= (const Legend &o) noexcept
 

Detailed Description

Legend class is used for painting legends on class inheriting QPaintDevice.

Its methods enable changing settings of legend such as legend type (scale only/full legend), symbol size, sizes for symbol description's bounding rectangles, symbol spacing etc. Typical use of this class would be to create instance of Legend class, set all properties using appropriate methods and paint it by calling paintLegend() method, passing QPaintDevice or QPainter subclass (useful eg. with QSvgGenerator class, which can't be painted by two QPainter classes).

Author
Rafał Kułaga

Definition at line 32 of file legend.h.

Member Enumeration Documentation

◆ LEGEND_ORIENTATION

Legend orientation enumeration.

Definition at line 50 of file legend.h.

◆ LEGEND_POSITION

Legend position enumeration.

Definition at line 59 of file legend.h.

◆ LEGEND_TYPE

Legend type enumeration.

Definition at line 38 of file legend.h.

Constructor & Destructor Documentation

◆ Legend() [1/2]

Legend::Legend ( LEGEND_ORIENTATION orientation = LO_HORIZONTAL,
LEGEND_POSITION pos = LP_FLOATING )
explicit

Constructor.

Parameters
orientationLegend orientation.
posLegend position.

Definition at line 28 of file legend.cpp.

◆ Legend() [2/2]

Legend::Legend ( const Legend & o)
explicit

copy constructor

Note
This class needs to be explicitly copied because of the m_Painter pointer

Definition at line 577 of file legend.cpp.

◆ ~Legend()

Legend::~Legend ( )

Destructor.

Definition at line 38 of file legend.cpp.

Member Function Documentation

◆ calculateSize()

QSize Legend::calculateSize ( )

Calculates size of legend that will be painted using current settings.

Returns
Size of legend.

Definition at line 46 of file legend.cpp.

◆ getBgColor()

QColor Legend::getBgColor ( ) const
inline

Get background color.

Returns
Current background color.

Definition at line 166 of file legend.h.

◆ getBRectHeight()

int Legend::getBRectHeight ( ) const
inline

Get symbol description's bounding rectangle height.

Returns
Current bounding rectangle height.

Definition at line 130 of file legend.h.

◆ getBRectWidth()

int Legend::getBRectWidth ( ) const
inline

Get symbol description's bounding rectangle width.

Returns
Current bounding rectangle width.

Definition at line 124 of file legend.h.

◆ getDrawFrame()

bool Legend::getDrawFrame ( ) const
inline

Check if frame around legend is drawn.

Returns
True if frame is drawn.

Definition at line 172 of file legend.h.

◆ getFloatingPosition()

QPoint Legend::getFloatingPosition ( ) const
inline

Get position of the floating legend.

Returns
Current position of the floating legend.

Definition at line 112 of file legend.h.

◆ getFont()

QFont Legend::getFont ( ) const
inline

Get font.

Returns
Current font.

Definition at line 160 of file legend.h.

◆ getMaxHScalePixels()

int Legend::getMaxHScalePixels ( ) const
inline

Get maximal horizontal scale size in pixels.

Returns
Current maximal horizontal scale size in pixels.

Definition at line 136 of file legend.h.

◆ getMaxVScalePixels()

int Legend::getMaxVScalePixels ( ) const
inline

Get maximal vertical scale size in pixels.

Current maximal vertical scale size in pixels.

Definition at line 142 of file legend.h.

◆ getOrientation()

LEGEND_ORIENTATION Legend::getOrientation ( ) const
inline

Get legend orientation.

Returns
Current legend orientation value.

Definition at line 100 of file legend.h.

◆ getPosition()

LEGEND_POSITION Legend::getPosition ( ) const
inline

Get legend position.

Returns
Current legend position value.

Definition at line 106 of file legend.h.

◆ getSymbolSize()

int Legend::getSymbolSize ( ) const
inline

Get symbol size.

Returns
Current symbol size value.

Definition at line 118 of file legend.h.

◆ getType()

LEGEND_TYPE Legend::getType ( ) const
inline

Get legend type.

Returns
Current legend type value.

Definition at line 94 of file legend.h.

◆ getXSymbolSpacing()

int Legend::getXSymbolSpacing ( ) const
inline

Get symbol image X spacing.

Returns
Current symbol image X spacing.

Definition at line 148 of file legend.h.

◆ getYSymbolSpacing()

int Legend::getYSymbolSpacing ( ) const
inline

Get symbol image Y spacing.

Returns
Current symbol image Y spacing.

Definition at line 154 of file legend.h.

◆ operator=()

Legend & Legend::operator= ( const Legend & o)
noexcept

Definition at line 587 of file legend.cpp.

◆ paintLegend() [1/4]

void Legend::paintLegend ( QPaintDevice * pd)

Paint legend on passed QPaintDevice at selected position.

Parameters
pdQPaintDevice on which legend will be painted.

Definition at line 154 of file legend.cpp.

◆ paintLegend() [2/4]

void Legend::paintLegend ( QPaintDevice * pd,
LEGEND_TYPE type,
LEGEND_POSITION pos )

Paint legend on passed QPaintDevice at selected position.

Parameters
pdQPaintDevice on which legend will be painted.
typethe legend type.
posLEGEND_POSITION enum value.

Definition at line 306 of file legend.cpp.

◆ paintLegend() [3/4]

void Legend::paintLegend ( SkyQPainter * painter)

Paint legend using passed SkyQPainter.

This method is used to enable painting on QPaintDevice subclasses that can't be painted by multiple QPainter subclasses (e.g. QSvgGenerator).

Parameters
painterthat will be used to paint legend.
Note
Passed SkyQPainter should be already set up to paint at specific QPaintDevice subclass and should be initialized by its begin() method. After legend is painted, SkyQPainter instance will not be finished, so it's necessary to call end() method manually.

Definition at line 170 of file legend.cpp.

◆ paintLegend() [4/4]

void Legend::paintLegend ( SkyQPainter * painter,
LEGEND_TYPE type,
LEGEND_POSITION pos )

Paint legend using passed SkyQPainter.

This method is used to enable painting on QPaintDevice subclasses that can't be painted by multiple QPainter subclasses (eg. QSvgGenerator).

Parameters
painterthat will be used to paint legend.
typethe legend type.
posLEGEND_POSITION enum value.
Note
Passed SkyQPainter should be already set up to paint at specific QPaintDevice subclass and should be initialized by its begin() method. After legend is painted, SkyQPainter instance will not be finished, so it's necessary to call end() method manually.

Definition at line 320 of file legend.cpp.

◆ setBgColor()

void Legend::setBgColor ( const QColor & color)
inline

Set background color.

Parameters
colorNew background color.

Definition at line 250 of file legend.h.

◆ setBRectHeight()

void Legend::setBRectHeight ( int height)
inline

Set symbol description's bounding rectangle height.

Parameters
heightNew bounding rectangle height.

Definition at line 214 of file legend.h.

◆ setBRectWidth()

void Legend::setBRectWidth ( int width)
inline

Set symbol description's bounding rectangle width.

Parameters
widthNew bounding rectangle width.

Definition at line 208 of file legend.h.

◆ setDrawFrame()

void Legend::setDrawFrame ( bool draw)
inline

Set if frame is drawn.

Parameters
drawTrue if frame should be drawn.

Definition at line 256 of file legend.h.

◆ setFloatingPosition()

void Legend::setFloatingPosition ( QPoint pos)
inline

Set floating legend position.

Parameters
posNew floating legend position.

Definition at line 196 of file legend.h.

◆ setFont()

void Legend::setFont ( const QFont & font)
inline

Set font.

Parameters
fontNew font.

Definition at line 244 of file legend.h.

◆ setMaxHScalePixels()

void Legend::setMaxHScalePixels ( int pixels)
inline

Set maximal horizontal scale size in pixels.

Parameters
pixelsNew maximal horizontal scale size in pixels.

Definition at line 220 of file legend.h.

◆ setMaxVScalePixels()

void Legend::setMaxVScalePixels ( int pixels)
inline

Set maximal vertical scale size in pixels.

Parameters
pixelsNew maximal vertical scale size in pixels.

Definition at line 226 of file legend.h.

◆ setOrientation()

void Legend::setOrientation ( LEGEND_ORIENTATION orientation)
inline

Set legend orientation.

Parameters
orientationNew legend orientation.

Definition at line 184 of file legend.h.

◆ setPosition()

void Legend::setPosition ( LEGEND_POSITION pos)
inline

Set legend position.

Parameters
posNew legend position enumeration value.

Definition at line 190 of file legend.h.

◆ setSymbolSize()

void Legend::setSymbolSize ( int size)
inline

Set symbol size.

Parameters
sizeNew symbol size.

Definition at line 202 of file legend.h.

◆ setType()

void Legend::setType ( LEGEND_TYPE type)
inline

Set legend type.

Parameters
typeNew legend type.

Definition at line 178 of file legend.h.

◆ setXSymbolSpacing()

void Legend::setXSymbolSpacing ( int spacing)
inline

Set symbol X spacing in pixels.

Parameters
spacingNew symbol X spacing in pixels.

Definition at line 232 of file legend.h.

◆ setYSymbolSpacing()

void Legend::setYSymbolSpacing ( int spacing)
inline

Set symbol Y spacing in pixels.

Parameters
spacingNew symbol Y spacing in pixels.

Definition at line 238 of file legend.h.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 3 2025 11:47:16 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.