OGS
|
A 2D cartesian grid as a QGraphicsItem.
A 2D cartesian grid as a QGraphicsItem. The size of the grid cells is constant but can be anisotroph.
Definition at line 26 of file QGraphicsGrid.h.
#include <QGraphicsGrid.h>
Public Member Functions | |
QGraphicsGrid (QRectF rect, int xCells, int yCells, QGraphicsItem *parent=nullptr) | |
QGraphicsGrid (int x, int y, int width, int height, int xCells, int yCells, QGraphicsItem *parent=nullptr) | |
QGraphicsGrid (QRectF rect, int xCells, int yCells, bool ticks, QPen pen, QGraphicsItem *parent=nullptr) | |
QGraphicsGrid (int x, int y, int width, int height, int xCells, int yCells, bool ticks, QPen pen, QGraphicsItem *parent=nullptr) | |
~QGraphicsGrid () override | |
QRectF | boundingRect () const override |
Returns the bounding rectangle of the grid. | |
void | paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override |
Paints the grid. | |
void | setNumberOfXCells (int xCells) |
Sets the number of cells in x direction. | |
void | setNumberOfYCells (int yCells) |
Sets the number of cells in y direction. | |
void | setRect (QRectF rect) |
void | setRect (int x, int y, int width, int height) |
Sets the bounding rectangle of the grid. | |
Private Member Functions | |
void | initDefaultPens () |
Defines the default pens. | |
Private Attributes | |
QPen | _inside |
QPen | _outside |
QRectF | _bounds |
int | _numberOfXCells |
int | _numberOfYCells |
bool | _showTicks |
QGraphicsGrid::QGraphicsGrid | ( | QRectF | rect, |
int | xCells, | ||
int | yCells, | ||
QGraphicsItem * | parent = nullptr ) |
Creates a grid using a QRectF object and a default pen and no ticks.
rect | A rectangle specifying the size of the grid. |
xCells | The number of grid cells in x-direction. |
yCells | The number of grid cells in y-direction. |
parent | The parent QGraphicsItem. |
Definition at line 26 of file QGraphicsGrid.cpp.
References _bounds, _numberOfXCells, _numberOfYCells, _showTicks, and initDefaultPens().
QGraphicsGrid::QGraphicsGrid | ( | int | x, |
int | y, | ||
int | width, | ||
int | height, | ||
int | xCells, | ||
int | yCells, | ||
QGraphicsItem * | parent = nullptr ) |
Creates a grid by specifying its bounding rectangle using a default pen and no ticks.
x | X-coordinate for the lower left corner of the bounding rectangle for the grid. |
y | Y-coordinate for the lower left corner of the bounding rectangle for the grid. |
width | Width of the bounding rectangle. |
height | Height of the bounding rectangle. |
xCells | The number of grid cells in x-direction. |
yCells | The number of grid cells in y-direction. |
parent | The parent QGraphicsItem. |
Definition at line 47 of file QGraphicsGrid.cpp.
References _bounds, _numberOfXCells, _numberOfYCells, _showTicks, and initDefaultPens().
QGraphicsGrid::QGraphicsGrid | ( | QRectF | rect, |
int | xCells, | ||
int | yCells, | ||
bool | ticks, | ||
QPen | pen, | ||
QGraphicsItem * | parent = nullptr ) |
Creates a grid using a QRectF object and a default pen and no ticks.
rect | A rectangle specifying the size of the grid. |
xCells | The number of grid cells in x-direction. |
yCells | The number of grid cells in y-direction. |
ticks | Specifies if ticks are displayed for the grid. |
pen | The pen for drawing the grid. |
parent | The parent QGraphicsItem. |
Definition at line 73 of file QGraphicsGrid.cpp.
References _bounds, _inside, _numberOfXCells, _numberOfYCells, _outside, and _showTicks.
QGraphicsGrid::QGraphicsGrid | ( | int | x, |
int | y, | ||
int | width, | ||
int | height, | ||
int | xCells, | ||
int | yCells, | ||
bool | ticks, | ||
QPen | pen, | ||
QGraphicsItem * | parent = nullptr ) |
Creates a grid by specifying its bounding rectangle using a default pen and no ticks.
x | X-coordinate for the lower left corner of the bounding rectangle for the grid. |
y | Y-coordinate for the lower left corner of the bounding rectangle for the grid. |
width | Width of the bounding rectangle. |
height | Height of the bounding rectangle. |
xCells | The number of grid cells in x-direction. |
yCells | The number of grid cells in y-direction. |
ticks | Specifies if ticks are displayed for the grid. |
pen | The pen for drawing the grid. |
parent | The parent QGraphicsItem. |
Definition at line 108 of file QGraphicsGrid.cpp.
References _bounds, _inside, _numberOfXCells, _numberOfYCells, _outside, and _showTicks.
|
overridedefault |
|
override |
Returns the bounding rectangle of the grid.
Definition at line 138 of file QGraphicsGrid.cpp.
References _bounds.
|
private |
Defines the default pens.
Definition at line 144 of file QGraphicsGrid.cpp.
References _inside, and _outside.
Referenced by QGraphicsGrid(), and QGraphicsGrid().
|
override |
Paints the grid.
Definition at line 155 of file QGraphicsGrid.cpp.
References _bounds, _inside, _numberOfXCells, _numberOfYCells, _outside, and _showTicks.
void QGraphicsGrid::setNumberOfXCells | ( | int | xCells | ) |
Sets the number of cells in x direction.
Definition at line 228 of file QGraphicsGrid.cpp.
References _numberOfXCells.
void QGraphicsGrid::setNumberOfYCells | ( | int | yCells | ) |
Sets the number of cells in y direction.
Definition at line 234 of file QGraphicsGrid.cpp.
References _numberOfYCells.
void QGraphicsGrid::setRect | ( | int | x, |
int | y, | ||
int | width, | ||
int | height ) |
Sets the bounding rectangle of the grid.
Definition at line 240 of file QGraphicsGrid.cpp.
References _bounds.
void QGraphicsGrid::setRect | ( | QRectF | rect | ) |
|
private |
Definition at line 71 of file QGraphicsGrid.h.
Referenced by QGraphicsGrid(), QGraphicsGrid(), QGraphicsGrid(), QGraphicsGrid(), boundingRect(), paint(), and setRect().
|
private |
Definition at line 69 of file QGraphicsGrid.h.
Referenced by QGraphicsGrid(), QGraphicsGrid(), initDefaultPens(), and paint().
|
private |
Definition at line 72 of file QGraphicsGrid.h.
Referenced by QGraphicsGrid(), QGraphicsGrid(), QGraphicsGrid(), QGraphicsGrid(), paint(), and setNumberOfXCells().
|
private |
Definition at line 73 of file QGraphicsGrid.h.
Referenced by QGraphicsGrid(), QGraphicsGrid(), QGraphicsGrid(), QGraphicsGrid(), paint(), and setNumberOfYCells().
|
private |
Definition at line 70 of file QGraphicsGrid.h.
Referenced by QGraphicsGrid(), QGraphicsGrid(), initDefaultPens(), and paint().
|
private |
Definition at line 74 of file QGraphicsGrid.h.
Referenced by QGraphicsGrid(), QGraphicsGrid(), QGraphicsGrid(), QGraphicsGrid(), and paint().