OGS
QGraphicsGrid.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#pragma once
5
6#include <QGraphicsItem>
7#include <QPen>
8
15class QGraphicsGrid : public QGraphicsItem
16{
17public:
18 QGraphicsGrid(QRectF rect,
19 int xCells,
20 int yCells,
21 QGraphicsItem* parent = nullptr);
22 QGraphicsGrid(int x,
23 int y,
24 int width,
25 int height,
26 int xCells,
27 int yCells,
28 QGraphicsItem* parent = nullptr);
29 QGraphicsGrid(QRectF rect,
30 int xCells,
31 int yCells,
32 bool ticks,
33 QPen pen,
34 QGraphicsItem* parent = nullptr);
35 QGraphicsGrid(int x,
36 int y,
37 int width,
38 int height,
39 int xCells,
40 int yCells,
41 bool ticks,
42 QPen pen,
43 QGraphicsItem* parent = nullptr);
44 ~QGraphicsGrid() override;
45
46 QRectF boundingRect() const override;
47 void paint(QPainter* painter,
48 const QStyleOptionGraphicsItem* option,
49 QWidget* widget) override;
50 void setNumberOfXCells(int xCells);
51 void setNumberOfYCells(int yCells);
52 void setRect(QRectF rect);
53 void setRect(int x, int y, int width, int height);
54
55private:
56 void initDefaultPens();
57
58 QPen _inside;
60 QRectF _bounds;
64};
void setRect(QRectF rect)
void setNumberOfYCells(int yCells)
Sets the number of cells in y direction.
~QGraphicsGrid() override
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 initDefaultPens()
Defines the default pens.
QRectF boundingRect() const override
Returns the bounding rectangle of the grid.
QGraphicsGrid(QRectF rect, int xCells, int yCells, QGraphicsItem *parent=nullptr)