trikRuntime
sensorsWidget.h
Go to the documentation of this file.
1 /* Copyright 2014 Roman Kurbatov
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/qglobal.h>
18 
19 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
20  #include <QtGui/QWidget>
21  #include <QtGui/QVBoxLayout>
22 #else
23  #include <QtWidgets/QWidget>
24  #include <QtWidgets/QVBoxLayout>
25 #endif
26 
27 #include <QtCore/QTimer>
28 #include <QtCore/QVector>
29 
30 #include "trikGuiDialog.h"
31 
32 namespace trikControl {
33 class BrickInterface;
34 }
35 
36 namespace trikGui {
37 
38 class AbstractIndicator;
39 
42 {
43  Q_OBJECT
44 
45 public:
46  enum class SensorType {
47  analogOrDigitalSensor
48  , encoder
49  , gyroscope
50  , accelerometer
51  };
52 
54  explicit SensorsWidget(trikControl::BrickInterface &brick, const QStringList &ports
55  , SensorType sensorType, QWidget *parent = 0);
56 
57  ~SensorsWidget() override;
58 
59  int exec() override;
60 
61  void renewFocus() override;
62 
63 protected:
64  void exit() override;
65 
66  void goHome() override;
67 
68 private:
69  AbstractIndicator *produceIndicator(const QString &port, SensorType sensorType);
70 
72  QVBoxLayout mLayout;
73  QVector<AbstractIndicator *> mIndicators; // Has ownership.
74  const int mInterval;
75  QTimer mTimer;
76 };
77 
78 }
static const int port
Definition: trikCommunicatorTest.cpp:24
Base class for all trikGui dialog widgets.
Definition: trikGuiDialog.h:24
SensorType
Definition: sensorsWidget.h:46
Base class for a widget that can show some reading from sensor, encoder and so on.
Definition: abstractIndicator.h:24
Definition: abstractIndicator.h:21
Widget that shows current readings of selected sensors.
Definition: sensorsWidget.h:41
Definition: trikCommunicator.h:27
Interface representing TRIK controller board and devices installed on it, also provides access to per...
Definition: brickInterface.h:46