trikRuntime
sensorLever.h
Go to the documentation of this file.
1 /* Copyright 2016 Mikhail Kita
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 #include <QtWidgets/QWidget>
20 #include <QtWidgets/QHBoxLayout>
21 #include <QtWidgets/QLabel>
22 #include <QtWidgets/QProgressBar>
23 
24 #include <QtCore/QString>
25 
26 namespace trikGui {
27 
29 class SensorLever : public QWidget
30 {
31  Q_OBJECT
32 
33 public:
37  explicit SensorLever(const QString &port, QWidget *parent = 0);
38 
40  int distance() const;
41 
43  bool isGreater() const;
44 
45 protected:
46  void keyPressEvent(QKeyEvent *event) override;
47 
48  void paintEvent(QPaintEvent *) override;
49 
50 private slots:
53  void setDistance(int distance);
54 
56  void changeSign();
57 
58 private:
59  bool mIsGreater;
60  const int mMaxDistance;
61  const int mMinDistance;
62  const int mDistanceStep;
63  int mDistance;
64 
65  QHBoxLayout mLayout;
66  QLabel mNameLabel;
67  QProgressBar mDistanceBar;
68  QLabel mSignLabel;
69 };
70 
71 }
SensorLever(const QString &port, QWidget *parent=0)
Constructor.
Definition: sensorLever.cpp:25
static const int port
Definition: trikCommunicatorTest.cpp:24
void keyPressEvent(QKeyEvent *event) override
Definition: sensorLever.cpp:59
Widget that allows to set distance value of a sensor.
Definition: sensorLever.h:29
bool isGreater() const
Returns sign of command.
Definition: sensorLever.cpp:114
Definition: abstractIndicator.h:21
int distance() const
Returns distance value of this lever.
Definition: sensorLever.cpp:109
void paintEvent(QPaintEvent *) override
Definition: sensorLever.cpp:80