diff --git a/src/widgets/movementwidget.h b/src/widgets/movementwidget.h --- a/src/widgets/movementwidget.h +++ b/src/widgets/movementwidget.h @@ -24,23 +24,69 @@ #include "atcorewidgets_export.h" /* Usage: * - * Create a instance of the movement widget. + * Create a instance of the movement widget. This widget will provide Basic Movement Controls. Create it with "showHomeAndDisableWidgets" false if your client provides its own actions for homing and disabling the motors. */ class ATCOREWIDGETS_EXPORT MovementWidget : public QWidget { Q_OBJECT public: - MovementWidget(QWidget *parent = nullptr); + /** + * @brief Create a Movement Widget + * @param showHomeAndDisableWidgets: set False to hide the Home and Disable Motors buttons [default = true] + * @param parent: Parent of this widget. + */ + MovementWidget(bool showHomeAndDisableWidgets = true, QWidget *parent = nullptr); signals: + /** + * @brief The Home All button was clicked. + * This should be connected to AtCore::home() + */ void homeAllPressed(); + + /** + * @brief The Home X button was clicked. + * This should be connected to AtCore::home(AtCore::X) + */ void homeXPressed(); + + /** + * @brief The Home Y button was clicked. + * This should be connected to AtCore::home(AtCore::Y) + */ void homeYPressed(); + + /** + * @brief The Home Z button was clicked. + * This should be connected to AtCore::home(AtCore::Z) + */ void homeZPressed(); + + /** + * @brief The Disable Motors button was clicked. + * This should be connected to AtCore::disableMotors(0) + */ + void disableMotorsPressed(); + + /** + * @brief An absoluteMove was requested + * This should be connected to AtCore::move(axis,value) + * @param axis: the axis to move + * @param value: where to move + */ void absoluteMove(const QLatin1Char &axis, const double &value); + + /** + * @brief A relativeMove was requested. + * This should connect to a function that does the following + * AtCore::setRelativePosition() + * AtCore::move(axis, value) + * AtCore::setAbsolutePosition() + * @param axis: the axis to move. + * @param value: the value to move it by. + */ void relativeMove(const QLatin1Char &axis, const double &value); - void disableMotorsPressed(); private: QComboBox *comboMoveAxis = nullptr; diff --git a/src/widgets/movementwidget.cpp b/src/widgets/movementwidget.cpp --- a/src/widgets/movementwidget.cpp +++ b/src/widgets/movementwidget.cpp @@ -22,37 +22,46 @@ #include "axiscontrol.h" #include "movementwidget.h" -MovementWidget::MovementWidget(QWidget *parent) : +MovementWidget::MovementWidget(bool showHomeAndDisableWidgets, QWidget *parent) : QWidget(parent) { auto mainLayout = new QVBoxLayout; auto hBoxLayout = new QHBoxLayout; - - auto newButton = new QPushButton(tr("Home All")); - hBoxLayout->addWidget(newButton); - connect(newButton, &QPushButton::clicked, [this] { - emit(homeAllPressed()); - }); - - newButton = new QPushButton(tr("Home X")); - hBoxLayout->addWidget(newButton); - connect(newButton, &QPushButton::clicked, [this] { - emit(homeXPressed()); - }); - - newButton = new QPushButton(tr("Home Y")); - hBoxLayout->addWidget(newButton); - connect(newButton, &QPushButton::clicked, [this] { - emit(homeYPressed()); - }); - - newButton = new QPushButton(tr("Home Z")); - hBoxLayout->addWidget(newButton); - connect(newButton, &QPushButton::clicked, [this] { - emit(homeZPressed()); - }); - mainLayout->addLayout(hBoxLayout); - + auto newButton = new QPushButton; + + if( showHomeAndDisableWidgets) { + newButton = new QPushButton(tr("Home All")); + hBoxLayout->addWidget(newButton); + connect(newButton, &QPushButton::clicked, [this] { + emit(homeAllPressed()); + }); + + newButton = new QPushButton(tr("Home X")); + hBoxLayout->addWidget(newButton); + connect(newButton, &QPushButton::clicked, [this] { + emit(homeXPressed()); + }); + + newButton = new QPushButton(tr("Home Y")); + hBoxLayout->addWidget(newButton); + connect(newButton, &QPushButton::clicked, [this] { + emit(homeYPressed()); + }); + + newButton = new QPushButton(tr("Home Z")); + hBoxLayout->addWidget(newButton); + connect(newButton, &QPushButton::clicked, [this] { + emit(homeZPressed()); + }); + mainLayout->addLayout(hBoxLayout); + + newButton = new QPushButton(tr("Disable Motors")); + mainLayout->addWidget(newButton); + connect(newButton, &QPushButton::clicked, [this] { + emit(disableMotorsPressed()); + }); + + } comboMoveAxis = new QComboBox; comboMoveAxis->addItem(tr("Move X Axis to")); comboMoveAxis->addItem(tr("Move Y Axis to")); @@ -81,12 +90,6 @@ hBoxLayout->addWidget(newButton); mainLayout->addLayout(hBoxLayout); - newButton = new QPushButton(tr("Disable Motors")); - mainLayout->addWidget(newButton); - connect(newButton, &QPushButton::clicked, [this] { - emit(disableMotorsPressed()); - }); - auto axisControl = new AxisControl; mainLayout->addWidget(axisControl); connect(axisControl, &AxisControl::clicked, this, &MovementWidget::relativeMove);