3 from distutils.version
import LooseVersion
5 from threading
import Lock
7 import python_qt_binding
8 import python_qt_binding.QtCore
as QtCore
9 from python_qt_binding.QtCore
import QEvent
10 from python_qt_binding.QtCore
import Qt
11 from python_qt_binding.QtCore
import QTimer
12 from python_qt_binding.QtCore
import qWarning
13 from python_qt_binding.QtCore
import Slot
14 from python_qt_binding.QtGui
import QBrush
15 from python_qt_binding.QtGui
import QColor
16 from python_qt_binding.QtGui
import QFont
17 from python_qt_binding.QtGui
import QIcon
18 from python_qt_binding.QtGui
import QPainter
19 from python_qt_binding.QtGui
import QPen
23 from std_msgs.msg
import Bool, Time
25 if LooseVersion(python_qt_binding.QT_BINDING_VERSION).version[0] >= 5:
26 from python_qt_binding.QtWidgets
import QAction
27 from python_qt_binding.QtWidgets
import QMenu
28 from python_qt_binding.QtWidgets
import QWidget
31 from python_qt_binding.QtGui
import QAction
32 from python_qt_binding.QtGui
import QMenu
33 from python_qt_binding.QtGui
import QWidget
38 super(DRCEnvironmentViewer, self).
__init__(context)
39 self.setObjectName(
"DRCEnvironmentViewer")
41 context.add_widget(self.
_widget)
47 _OK_COLOR = QColor(
"#18FFFF")
48 _DISABLED_COLOR = QColor(
"#BDBDBD")
49 _BLACKOUT_COLOR = QColor(
"#F44336")
53 super(DRCEnvironmentViewerWidget, self).
__init__()
60 "/drc_2015_environment/is_disabled",
63 "/drc_2015_environment/is_blackout",
66 "/drc_2015_environment/next_whiteout_time",
69 self._update_plot_timer.timeout.connect(self.
redraw)
70 self._update_plot_timer.start(1000 / 15)
97 radius = min(rect.width(), rect.height()) - 50
98 qp.setFont(QFont(
'Helvetica', 100))
99 qp.setPen(QPen(QBrush(QColor(255, 255, 255)), 20))
103 qp.drawText(rect, QtCore.Qt.AlignCenter, self.
_FROWN)
106 qp.drawText(rect, QtCore.Qt.AlignCenter, self.
_FROWN)
111 time_ratio = time_diff / (
113 qp.setFont(QFont(
'Helvetica', 30))
115 0, rect.height() - 150, rect.width(), 150,
116 QtCore.Qt.AlignCenter,
"%.1f sec" % time_diff)
119 rad = int(math.fmod(time_ratio * 360 + 90*16, 360) * 16)
121 (rect.width() - radius) / 2,
122 (rect.height() - radius) / 2, radius, radius, 90*16,
126 qp.drawText(rect, QtCore.Qt.AlignCenter, self.
_SMILEY)
def __init__(self, context)