23 #include "../core/drawers/drawerbase.h"
24 #include "../core/system/eptexception.h"
25 #include "../core/math/mathtools.h"
42 : QGraphicsView(parent),
51 setRenderHints(QPainter::Antialiasing |
52 QPainter::SmoothPixmapTransform |
53 QPainter::HighQualityAntialiasing);
108 fitInView(
mScene.sceneRect());
109 QGraphicsView::showEvent(event);
126 fitInView(
mScene.sceneRect());
127 QGraphicsView::resizeEvent(event);
154 if (x1 < 0 || x1 > 1) {
return nullptr;}
155 if (y1 < 0 || y1 > 1) {
return nullptr;}
156 if (x2 < 0 || x2 > 1) {
return nullptr;}
157 if (y2 < 0 || y2 > 1) {
return nullptr;}
168 if (points.size() <= 1) {
173 size_t firstValidPointIndex = 0;
174 for (; firstValidPointIndex < points.size(); firstValidPointIndex++) {
175 if (points[firstValidPointIndex].x < 0 || points[firstValidPointIndex].x > 1) {
continue;}
176 if (points[firstValidPointIndex].y < 0 || points[firstValidPointIndex].y > 1) {
continue;}
177 path.moveTo(
convertRelToAbs(QPointF(points[firstValidPointIndex].x, points[firstValidPointIndex].y)));
180 for (
size_t i = firstValidPointIndex; i < points.size(); i++) {
181 if (points[i].x < 0 || points[i].x > 1) {
continue;}
182 if (points[i].y < 0 || points[i].y > 1) {
continue;}
195 if (x < 0 || x > 1) {
return nullptr;}
196 if (y < 0 || y > 1) {
return nullptr;}
197 if (x + w > 1) {
return nullptr;}
198 if (y + h > 1) {
return nullptr;}
216 pen = QPen(QBrush(Qt::black), 1);
219 pen = QPen(QBrush(Qt::black), 2);
222 pen = QPen(QBrush(QColor(220,220,220)), 1);
225 pen = QPen(QBrush(Qt::lightGray), 1);
228 pen = QPen(QBrush(Qt::lightGray), 2);
231 pen = QPen(QBrush(Qt::darkGray), 1);
234 pen = QPen(QBrush(Qt::darkGray), 2);
237 pen = QPen(QBrush(Qt::gray), 2);
240 pen = QPen(QBrush(Qt::darkGreen), 2);
243 pen = QPen(QBrush(Qt::cyan), 1);
246 pen = QPen(QBrush(Qt::cyan), 2);
249 pen = QPen(QBrush(QColor(0xff,0x66,0)), 2);
252 pen = QPen(QBrush(QColor(0xff,0,0xff)), 2);
255 pen = QPen(QBrush(QColor(0xff,0,0xff)), 1);
258 pen = QPen(QBrush(Qt::red), 1);
261 pen = QPen(QBrush(Qt::red), 2);
264 pen = QPen(QBrush(Qt::blue), 1);
267 pen = QPen(QBrush(Qt::transparent), 1);
271 pen.setCosmetic(cosmetic);
283 return QBrush(Qt::transparent);
285 return QBrush(Qt::lightGray);
287 return QBrush(Qt::red);
289 return QBrush(QColor(255,165,0));
291 return QBrush(Qt::green);
293 return QBrush(QColor(200,255,200));
295 return QBrush(Qt::blue);
Implementation class for the GraphicsItem in Qt.
QBrush getFill(FillTypes fill) const
Create a QBrush for the given value of FillTypes.
QGraphicsScene mScene
The QGraphicsScene.
virtual GraphicsItem * drawFilledRect(double x, double y, double w, double h, PenType pen, FillTypes fill) override
Abstract function: Draw a filled rectangle.
virtual void clear() override
Clear the scene.
QPen getPen(PenType penType, bool cosmetic=true) const
Get a QPen for the given value of PenTypes.
QPointF convertRelToAbs(const QPointF &p) const
Converting from relative to absolute coordinates.
void redraw(bool force=false)
Function to completely redraw the scene.
virtual GraphicsItem * drawChart(const std::vector< Point > &points, PenType pen) override
Abstract function: Draw a chart (polygon).
FillTypes
Available filling colors (e.g. to fill rectangles)
GraphicsViewAdapterForQt(QWidget *parent, DrawerBase *drawer, QRectF sceneRect)
Constructor.
GraphicItemsList & getGraphicItems()
Get the list of the graphic items.
virtual GraphicsItem * drawLine(double x1, double y1, double x2, double y2, PenType pen) override
Abstract function: Draw a line.
void setSceneRect(const QRectF &rect)
Setter function for the scene rectangle.
void resizeEvent(QResizeEvent *event) override
Resize the scene (reimplemented resize event).
QPointF convertAbsToRel(const QPointF &p) const
Converting from absolute to relative coordinates.
PenType
Available pen types for drawing.
void showEvent(QShowEvent *event) override
Show the scene (reimplemented show event).
Abstract base class for implementations rendering graphics.
Class for a single item in a graphics view.
QLineF convertRelToAbsLine(qreal x1, qreal y1, qreal x2, qreal y2) const
Converting of a line from relative to absolute coordinates.
QRectF mSceneRect
The scene rect.
virtual void clear()
Clear the graphics panel.
DrawerBase * mDrawer
The drawer of this GraphicsViewAdapterForQt.
Abstract base class for drawing 2d graphics.
~GraphicsViewAdapterForQt()
Destructor, removing all graphics items from the list.