trikRuntime
graphicsWidget.h
Go to the documentation of this file.
1 /* Copyright 2014 Kogutich Denis, Smirnov Mikhail, CyberTech Labs Ltd.
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License. */
14 
15 #pragma once
16 
17 #include <QtCore/QList>
18 #include <QtCore/QPoint>
19 #include <QtCore/QRect>
20 #include <QtGui/QColor>
21 
23 #include "shapes/shape.h"
24 
25 namespace trikControl {
26 
29 {
30  Q_OBJECT
31 public:
34 
36  void showCommand();
37 
39  void hideCommand();
40 
42  void setPainterColor(const QColor &color);
43 
45  void setPainterWidth(int penWidth);
46 
48  void deleteAllItems();
49 
51  void deleteLabels();
52 
56  void drawPoint(int x, int y);
57 
63  void drawLine(int x1, int y1, int x2, int y2);
64 
71  void drawRect(int x, int y, int width, int height, bool filled = false);
72 
79  void drawEllipse(int x, int y, int width, int height, bool filled = false);
80 
88  void drawArc(int x, int y, int width, int height, int startAngle, int spanAngle);
89 
91  void addLabel(const QString &text, int x, int y);
92 
94  void setPixmap(const QPixmap &picture);
95 
96 private:
98  virtual void paintEvent(QPaintEvent *paintEvent);
99 
100  void addShape(Shape *shape);
101 
103  QHash<QPair<int, int>, QPair<QColor, QString>> mLabels;
104 
105  QList<Shape *> mElements;
106 
107  QPixmap mPicture;
108 
110  QColor mCurrentPenColor;
111 
113  int mCurrentPenWidth;
114 
116  QScopedPointer<QFontMetrics> mFontMetrics;
117 };
118 
119 }
~GraphicsWidget()
Definition: graphicsWidget.cpp:37
GraphicsWidget()
Definition: graphicsWidget.cpp:29
Class of graphic widget.
Definition: graphicsWidget.h:28
Interface for widget on which Brick draws its graphics. Can notify when it shows or hides itself...
Definition: displayWidgetInterface.h:30
void drawPoint(int x, int y)
Draw point on the widget.
Definition: graphicsWidget.cpp:106
void addLabel(const QString &text, int x, int y)
Prints text at given coordinates.
Definition: graphicsWidget.cpp:139
Base class for elements that can be drawn on display.
Definition: shape.h:22
void drawEllipse(int x, int y, int width, int height, bool filled=false)
Draw ellipse.
Definition: graphicsWidget.cpp:121
void deleteAllItems()
Delete all items.
Definition: graphicsWidget.cpp:83
void drawRect(int x, int y, int width, int height, bool filled=false)
Draw rect on the widget.
Definition: graphicsWidget.cpp:116
void drawArc(int x, int y, int width, int height, int startAngle, int spanAngle)
Draw arc on the widget.
Definition: graphicsWidget.cpp:126
void drawLine(int x1, int y1, int x2, int y2)
Draw line on the widget.
Definition: graphicsWidget.cpp:111
Definition: trikCommunicator.h:27
void setPixmap(const QPixmap &picture)
Sets pixmap which will be drawn instead of other elements.
Definition: graphicsWidget.cpp:144
void showCommand()
Show this GraphicsWidget.
Definition: graphicsWidget.cpp:42
void setPainterWidth(int penWidth)
Set painter width.
Definition: graphicsWidget.cpp:101
void setPainterColor(const QColor &color)
Set painter color.
Definition: graphicsWidget.cpp:96
void deleteLabels()
Delets only text labels.
Definition: graphicsWidget.cpp:91
void hideCommand()
Hide this GraphicsWidget.
Definition: graphicsWidget.cpp:48
var x
Definition: file-test.js:2
var y
Definition: file-test.js:5