33 int f = 0; |
33 int f = 0; |
34 |
34 |
35 formLayout->setWidget(f++, QFormLayout::LabelRole, new QLabel("Buttons:", centralwidget)); |
35 formLayout->setWidget(f++, QFormLayout::LabelRole, new QLabel("Buttons:", centralwidget)); |
36 std::vector<QString> buttonLabels = {"0", "1"}; |
36 std::vector<QString> buttonLabels = {"0", "1"}; |
37 |
37 |
38 for (QString b : buttonLabels) { |
38 for (int i = 0; i < buttonLabels.size(); i++) { |
39 QCheckBox* button = new QCheckBox(centralwidget); |
39 QCheckBox* button = new QCheckBox(centralwidget); |
40 buttons.push_back(button); |
40 buttons.push_back(button); |
41 formLayout->setWidget(f, QFormLayout::LabelRole, new QLabel(b, centralwidget)); |
41 formLayout->setWidget(f, QFormLayout::LabelRole, new QLabel(buttonLabels[i], centralwidget)); |
42 formLayout->setWidget(f++, QFormLayout::FieldRole, button); |
42 formLayout->setWidget(f++, QFormLayout::FieldRole, button); |
|
43 connect(button, &QCheckBox::stateChanged, [ i, this ](int state) { |
|
44 emit buttonEvent({i, state == Qt::CheckState::Checked}); |
|
45 }); |
43 } |
46 } |
44 |
47 |
45 std::vector<QString> axisLabels = {"X", "Y", "Z"}; |
48 std::vector<QString> axisLabels = {"X", "Y", "Z"}; |
46 |
49 |
47 formLayout->setWidget(f++, QFormLayout::LabelRole, new QLabel("Motion:", centralwidget)); |
50 formLayout->setWidget(f++, QFormLayout::LabelRole, new QLabel("Motion:", centralwidget)); |
48 for (QString a : axisLabels) { |
51 for (QString a : axisLabels) { |
49 QSlider* slider = createSlider(centralwidget); |
52 QSlider* slider = createSlider(centralwidget); |
50 motions.push_back(slider); |
53 motions.push_back(slider); |
51 formLayout->setWidget(f, QFormLayout::LabelRole, new QLabel(a, centralwidget)); |
54 formLayout->setWidget(f, QFormLayout::LabelRole, new QLabel(a, centralwidget)); |
52 formLayout->setWidget(f++, QFormLayout::FieldRole, slider); |
55 formLayout->setWidget(f++, QFormLayout::FieldRole, slider); |
|
56 connect(slider, &QSlider::valueChanged, this, &SimulatorWindow::sendMotionEvent); |
53 } |
57 } |
54 |
58 |
55 |
59 |
56 formLayout->setWidget(f++, QFormLayout::LabelRole, new QLabel("Rotation:", centralwidget)); |
60 formLayout->setWidget(f++, QFormLayout::LabelRole, new QLabel("Rotation:", centralwidget)); |
57 for (QString a : axisLabels) { |
61 for (QString a : axisLabels) { |
58 QSlider* slider = createSlider(centralwidget); |
62 QSlider* slider = createSlider(centralwidget); |
59 rotations.push_back(slider); |
63 rotations.push_back(slider); |
60 formLayout->setWidget(f, QFormLayout::LabelRole, new QLabel(a, centralwidget)); |
64 formLayout->setWidget(f, QFormLayout::LabelRole, new QLabel(a, centralwidget)); |
61 formLayout->setWidget(f++, QFormLayout::FieldRole, slider); |
65 formLayout->setWidget(f++, QFormLayout::FieldRole, slider); |
|
66 connect(slider, &QSlider::valueChanged, this, &SimulatorWindow::sendMotionEvent); |
62 } |
67 } |
63 |
68 |
64 formLayout->setWidget(f++, QFormLayout::LabelRole, new QLabel("Actions:", centralwidget)); |
69 formLayout->setWidget(f++, QFormLayout::LabelRole, new QLabel("Actions:", centralwidget)); |
65 centerButton = new QPushButton("Center all", centralwidget); |
70 centerButton = new QPushButton("Center all", centralwidget); |
66 connect(centerButton, &QPushButton::clicked, this, &SimulatorWindow::centerAll); |
71 connect(centerButton, &QPushButton::clicked, this, &SimulatorWindow::centerAll); |