|
mkRPG
|
The MapPainter class that can paint a Map using a QPainter. More...
#include <mappainter.h>
Public Types | |
| enum | Element { Nothing = 0, CellBackground = 1, Grid = 2, CellSelection = 4, CellHighlighting = 8, Objects = 16, All = 31 } |
| The Element enum discribes the different elements that can be render. More... | |
Signals | |
| void | mapSizeChanged (QSize) |
| void | viewCenterChanged (QPoint) |
Public Member Functions | |
| MapPainter (QObject *parent=0) | |
| MapPainter (Map *m, QObject *parent=0) | |
| void | setPaintedElement (Element e, bool painted=true) |
| void | setPaintedElements (Element e) |
| void | setMap (Map *m) |
| void | paint (QPainter &p) |
| const QImage & | render () |
| RlCoords | viewCenter () const |
| void | setViewCenter (RlCoords relativeCenter) |
| void | setViewCenter (double relativeCenterX, double relativeCenterY) |
| void | setViewCenterQuiet (double x, double y) |
| double | scale () const |
| void | setScale (double scale) |
| void | setScaleDomain (double scaleMin, double scaleMax) |
| bool | setHighlightedCell (const ClCoords &p) |
| bool | setHighlightedCell (int i, int j) |
| QPoint | highlightedCell () const |
| bool | hasHighlightedCell () const |
| bool | isCell (const ClCoords &c) const |
| void | resize (QSize s) |
| void | resize (int wi, int he) |
| QSize | size () const |
| void | zoom (double factor, QPointF fixedPoint) |
| QPair< bool, bool > | move (PxCoords delta, QPointF center) |
| QSize | virtualSize () const |
| PxCoords | ptToPxl (PtCoords p) const |
| PtCoords | pxlToPt (PxCoords p) const |
| PtCoords | cooToPt (ClCoords p) const |
| ClCoords | ptToCoo (PtCoords p) const |
| PxCoords | cooToPxl (ClCoords p) const |
| ClCoords | pxlToCoo (PxCoords p) const |
| PtCoords | indToPt (int i, int j) const |
| const QColor & | selectedCellColor () const |
| const QColor & | preSelectedCellColor () const |
| void | setSelectedCellColor (const QColor &c) |
| void | setPreSelectedCellColor (const QColor &c) |
The MapPainter class that can paint a Map using a QPainter.
The class take charge of the different ratios of the map rendering and the area in which it will be rendered.
To ensure a type checking security about the different types of coordinates that are used, four different types that inherit from QPointF are used : RlCoords, ClCoords, PtCoords and PxCoords
| enum MapPainter::Element |
The Element enum discribes the different elements that can be render.
This includes both map's objects and user interaction and editing elements.
Element value can be used as flags using the operators operator| "|", operator| "&", operator| "^".
| Nothing |
Represent no elements |
| CellBackground |
The bacground associated to the cell type |
| Grid |
A thin grid that separate cells |
| CellSelection |
Graphical information about the selection state |
| CellHighlighting |
Graphical visualisation of the cells the mouse is over |
| Objects |
The objects that lay on the cells |
| All |
Represent all elements |
| MapPainter::MapPainter | ( | QObject * | parent = 0 | ) |
Constructs a new MapPainter with a default size of (42,42).
| MapPainter::MapPainter | ( | Map * | m, |
| QObject * | parent = 0 |
||
| ) |
Constructs a new MapPainter with a default size of (42,42), and loads the map m.
| PtCoords MapPainter::cooToPt | ( | ClCoords | p | ) | const |
Converts cells indice to virtual point coordinates
| PxCoords MapPainter::cooToPxl | ( | ClCoords | p | ) | const |
| bool MapPainter::hasHighlightedCell | ( | ) | const |
Returns true if a cell is highligthed.
| QPoint MapPainter::highlightedCell | ( | ) | const |
Returns the integer index of the cell the is highlighted.
| PtCoords MapPainter::indToPt | ( | int | i, |
| int | j | ||
| ) | const |
Converts to coordinates
| bool MapPainter::isCell | ( | const ClCoords & | c | ) | const |
Returns true if the coordinate c correspond to a cell.
| void MapPainter::mapSizeChanged | ( | QSize | ) | [signal] |
| QPair< bool, bool > MapPainter::move | ( | PxCoords | delta, |
| QPointF | center | ||
| ) |
Change the center position from the given center and a pixel difference.
The return value indicate if the expected center was valid (regarding x or y coordinate).
| void MapPainter::paint | ( | QPainter & | p | ) |
Draws the map in the QPaintDevice.
| const QColor & MapPainter::preSelectedCellColor | ( | ) | const |
Returns the color of the filter that is applied to pre-selected cells.
| ClCoords MapPainter::ptToCoo | ( | PtCoords | p | ) | const |
Converts virtual point to cell indice
| PxCoords MapPainter::ptToPxl | ( | PtCoords | p | ) | const |
Converts virtual point to real pixel coordinates
| ClCoords MapPainter::pxlToCoo | ( | PxCoords | p | ) | const |
| PtCoords MapPainter::pxlToPt | ( | PxCoords | p | ) | const |
Converts real pixel to virtual point coordinates
| const QImage & MapPainter::render | ( | ) |
Provides a QImage with a view of the map.
| void MapPainter::resize | ( | QSize | s | ) |
Change the size of the view, ie the rectangle in which the map will be render.
| void MapPainter::resize | ( | int | wi, |
| int | he | ||
| ) |
This is an overload function, see resize
| double MapPainter::scale | ( | ) | const |
Returns the current scale of the view.
| const QColor & MapPainter::selectedCellColor | ( | ) | const |
Returns the color of the filter that is applied to selected cells.
| bool MapPainter::setHighlightedCell | ( | const ClCoords & | p | ) |
Sets the highligthed cell to the one at the ClCoords p
| bool MapPainter::setHighlightedCell | ( | int | i, |
| int | j | ||
| ) |
This is an overload function, see setViewCenter.
| void MapPainter::setMap | ( | Map * | m | ) |
Loads the map, computing the new size of the view area.
| void MapPainter::setPaintedElement | ( | MapPainter::Element | e, |
| bool | painted = true |
||
| ) |
Enables or disables the render of an element.
| void MapPainter::setPaintedElements | ( | Element | e | ) |
Sets the rendered elements.
| void MapPainter::setPreSelectedCellColor | ( | const QColor & | c | ) |
Sets the color of the filter that is applied to pre-selected cells.
| void MapPainter::setScale | ( | double | scale | ) |
Sets the current view scale. This closest value in the scale domain will be used.
| void MapPainter::setScaleDomain | ( | double | scaleMin, |
| double | scaleMax | ||
| ) |
| void MapPainter::setSelectedCellColor | ( | const QColor & | c | ) |
Sets the color of the filter that is applied to selected cells.
| void MapPainter::setViewCenter | ( | RlCoords | relativeCenter | ) |
Change the view center, using relative coordinates.
If the new center is invalid (the view exceed the map area), the closest valid center is used.
| void MapPainter::setViewCenter | ( | double | relativeCenterX, |
| double | relativeCenterY | ||
| ) |
This is an overload function, see setViewCenter.
| void MapPainter::setViewCenterQuiet | ( | double | x, |
| double | y | ||
| ) |
does the same as setViewCenter, without emitting the signal viewCenterChanged to avoid event loop.
| QSize MapPainter::size | ( | ) | const |
| RlCoords MapPainter::viewCenter | ( | ) | const |
Return the relative coordinates of the current view center.
| void MapPainter::viewCenterChanged | ( | QPoint | ) | [signal] |
This signal is emitted when the center of the map change.
It appends mainly during moving on the view and zooming.
| QSize MapPainter::virtualSize | ( | ) | const |
Computes the total size of the image of the map
| void MapPainter::zoom | ( | double | factor, |
| QPointF | fixedPoint | ||
| ) |
Multiplying the scale of the view by factor, trying to leave the point center at the same position.
1.7.6.1