05Robot 3.0

- Main Page
- Modules
- Classes
- Files

- File List
- File Members

ObjectManipulationWindow.h
Go to the documentation of this file.
1
7 #ifndef OBJECTMANIPULATIONWINDOW_H
8 #define OBJECTMANIPULATIONWINDOW_H
9
10 #include <QWidget>
11 #include "ui_ObjectManipulationWindow.h"
12 #include "Processor_ObjectExtraction.h"
13 #include <QVector3D>
14
15 #include <opencv2/opencv.hpp>
16 #include <opencv2/highgui/highgui.hpp>
17 #include <opencv2/imgproc/imgproc.hpp>
18
19 #include "mat_utils.h"
20
21 #include <QDebug>
22 #include <QMessageBox>
31 class ObjectManipulationWindow : public QWidget
32 {
33 Q_OBJECT
34 public:
38 enum interfaceLogEvents{manipulation_mode_selected, preview_mode_selected, move_up_selected, move_down_selected, move_left_selected, move_right_selected, rotate_right_selected, rotate_left_selected,zoom_in_selected, zoom_out_selected, zoom_rect_selected, cancel_action_selected, bin_button_selected, look_at_selected, robot_move_started, robot_move_finished, bin_button_toggled} ;
39 Q_ENUM(interfaceLogEvents)
43 Q_PROPERTY(int Interface_size READ interface_size WRITE set_interface_size DESIGNABLE true USER true)
44 Q_CLASSINFO("Interface_size", "minimum=20;maximum=300;singleStep=1;");
48 Q_PROPERTY(int Initial_rotation READ initial_rotation WRITE set_initial_rotation DESIGNABLE true USER true)
49 Q_CLASSINFO("Initial_rotation", "minimum=0;maximum=359;singleStep=1;");
53 Q_PROPERTY(int Rotation_step READ rotation_step WRITE set_rotation_step DESIGNABLE true USER true)
54 Q_CLASSINFO("Rotation_step", "minimum=90;maximum=270;singleStep=90;");
58 Q_PROPERTY(float View_scroll_step READ view_scroll_step WRITE set_view_scroll_step DESIGNABLE true USER true)
59 Q_CLASSINFO("View_scroll_step", "minimum=0.01;maximum=1;singleStep=0.01;");
63 Q_PROPERTY(float Zoom_in_out_factor READ zoom_in_out_factor WRITE set_zoom_in_out_factor DESIGNABLE true USER true)
64 Q_CLASSINFO("Zoom_in_out_factor", "minimum=0.01;maximum=10.0;singleStep=0.1;");
68 Q_PROPERTY(QString Bin_descriptors READ bin_descriptors WRITE set_bin_descriptors DESIGNABLE true USER true)
72 Q_PROPERTY(QString Image_file READ image_file WRITE set_image_file DESIGNABLE true USER true)
76 Q_PROPERTY(QString Object_list_file READ object_list_file WRITE set_object_list_file DESIGNABLE true USER true)
77
78 private:
82 struct bin_button {
86 bin_button() {}
92 bin_button(QString input);
96 QString to_string() const;
100 int id = -1;
104 float width = 1.0;
108 bool photo = false;
112 QString label;
116 QString icon;
120 QString color;
124 int capacity = -1;
128 int current_capacity = 1;
129 int state = 0;
130 };
131
132 public:
139 ObjectManipulationWindow(QWidget *parent = 0, Qt::WindowFlags flags = 0);
143 ~ObjectManipulationWindow();
147 int interface_size() const;
151 void set_interface_size(int interface_size_);
155 int initial_rotation() const;
159 void set_initial_rotation(int initial_rotation);
163 int rotation_step() const;
167 void set_rotation_step(int rotation_step);
171 float view_scroll_step() const;
175 void set_view_scroll_step(float view_scroll_step);
179 float zoom_in_out_factor() const;
183 void set_zoom_in_out_factor(float zoom_in_out_factor);
187 QString bin_descriptors() const;
191 void set_bin_descriptors(const QString &bin_descriptors);
195 QString image_file() const;
199 void set_image_file(const QString &image_file);
203 QString object_list_file() const;
207 void set_object_list_file(const QString &object_list_file);
211 void show_gestures_legend(int is_show);
212 private:
213 void generate_buttons();
214 cv::Mat get_object_image(cv::Size dst_size = cv::Size(0, 0), float angle = 0.0, float zoom = 0.0, float view_offset_x = 0.0, float view_offset_y = 0.0);
215
216 int m_show_complex_gestures_help;
217 int m_interface_size;
218 float m_rotation_step;
219 float m_initial_rotation;
220 float m_view_scroll_step;
221 float m_zoom_in_out_factor;
222 QString m_image_file;
223 QString m_object_list_file;
224
225 bool interface_active_ = true;
226
227 enum update_mode_t {
228 update_mode_live, update_mode_single, update_mode_pause
229 };
230
231 update_mode_t update_mode_ = update_mode_live;
232
233 Ui::ObjectManipulationWindow ui;
234 QVector<QPair<QVector2D, QToolButton*> > buttons_;
235
236 QButtonGroup bin_buttons_group_;
237 QVector<bin_button> bin_buttons_;
238
239 cv::Mat current_image_;
240 QVector<sObject> current_objects_;
241
242 void refresh();
243 void update_object_selection_view();
244 void redraw_object_selection_view() {
245 ui.graphicsView_preview->fitInView(ui.graphicsView_preview->scene()->sceneRect(), Qt::AspectRatioMode::KeepAspectRatio);
246 }
247 void update_object_manipulation_view();
248 void redraw_object_manipulation_view() {
249 ui.graphicsView_object->fitInView(ui.graphicsView_object->scene()->sceneRect(), Qt::AspectRatioMode::KeepAspectRatio);
250 }
251
252 /* current view */
253 int highlighted_object_ = -1;
254 int selected_object_ = -1;
255
256 //cv::Mat current_transformation_;
257 float current_zoom_ = 0.0;
258 float current_angle_ = 0.0;
259 float current_offset_x_ = 0.0;
260 float current_offset_y_ = 0.0;
261
262 cv::Size manipulation_preview_size_ = cv::Size(1600, 800);//cv::Size(1024, 768)
263
264 void reset_view() {
265 current_zoom_ = 0.0;
266 current_angle_ = m_initial_rotation;
267 current_offset_x_ = 0.0;
268 current_offset_y_ = 0.0;
269
270 update_object_manipulation_view();
271 }
272
273 QRectF target_view_rect_;
274
275
276 protected:
277 void resizeEvent(QResizeEvent *event);
278
279 private slots:
280 void new_object_data(cv::Mat image, QVector<sObject> objects);
281
282 public slots:
286 void on_stackedWidget_currentChanged(int /* index */) {
287 update_interface();
288 }
289
290 /* user interface */
291
295 void on_toolButton_refresh_clicked();
299 void on_toolButton_rotate_left_clicked();
303 void on_toolButton_rotate_right_clicked();
307 void on_toolButton_zoom_in_clicked();
311 void on_toolButton_zoom_out_clicked();
315 void on_toolButton_view_left_clicked();
319 void on_toolButton_view_right_clicked();
323 void on_toolButton_view_up_clicked();
327 void on_toolButton_view_down_clicked();
331 void on_toolButton_view_reset_clicked();
335 void on_toolButton_cancel_clicked();
339 void reset_buttons();
340
346 void zoom_rect_widget(QRect rectangle);
352 void look_at(QPointF point);
358 void zoom_rect(QRectF rectangle);
364 void zoom_rect_start(QPointF point);
370 void zoom_rect_stop(QPointF point);
374 void update_interface();
380 void bin_button_clicked(int button_i);
386 void preview_clicked(QPointF point);
392 void preview_mouse_moved(QPointF point);
396 void preview_mode();
400 void manipulation_mode();
404 void commandStarted();
408 void commandExecuted();
412 void robotEmergencyStopped();
413 public:
417 QGraphicsView* getPreviewWidget();
421 QGraphicsView* getManipulationWidget();
422 enum previev_types_t {preview_id=0, object_manipultion_id=1};
423 previev_types_t getPreviewId() {
424 return (previev_types_t)ui.stackedWidget->currentIndex();
425 }
426
427 signals:
431 void logEvent(ObjectManipulationWindow::interfaceLogEvents eventID, int selected_object, int param, QPointF point, QPointF size, float angle);
439 void pickObject(QVector3D pointInMeters, float object_height, float angle, int bin);
440
441 };
443 #endif // OBJECTMANIPULATIONWINDOW_H
ObjectManipulationWindow::Q_CLASSINFO
Q_CLASSINFO("Initial_rotation","minimum=0;maximum=359;singleStep=1;")
ObjectManipulationWindow::object_list_file
QString object_list_file() const
Gets object list file.
ObjectManipulationWindow::move_left_selected
Definition: ObjectManipulationWindow.h:38
ObjectManipulationWindow::robot_move_started
Definition: ObjectManipulationWindow.h:38
ObjectManipulationWindow::getPreviewWidget
QGraphicsView * getPreviewWidget()
returns preview QGraphicsView widget
ObjectManipulationWindow::preview_clicked
void preview_clicked(QPointF point)
Tries to select an object, if an object was under given coordinates switches to object manipulation m...
Processor_ObjectExtraction.h
ObjectManipulationWindow::View_scroll_step
float View_scroll_step
View scroll step (fraction of view window)
Definition: ObjectManipulationWindow.h:58
ObjectManipulationWindow::object_manipultion_id
Definition: ObjectManipulationWindow.h:422
ObjectManipulationWindow::interfaceLogEvents
interfaceLogEvents
Log event types.
Definition: ObjectManipulationWindow.h:38
ObjectManipulationWindow::preview_id
Definition: ObjectManipulationWindow.h:422
ObjectManipulationWindow::zoom_in_out_factor
float zoom_in_out_factor() const
Gets zoom in/out factor.
ObjectManipulationWindow::Rotation_step
int Rotation_step
Rotation step in degrees.
Definition: ObjectManipulationWindow.h:53
ObjectManipulationWindow::rotate_left_selected
Definition: ObjectManipulationWindow.h:38
ObjectManipulationWindow::on_toolButton_refresh_clicked
void on_toolButton_refresh_clicked()
Triggers single image preview update in paused mode.
ObjectManipulationWindow::manipulation_mode_selected
Definition: ObjectManipulationWindow.h:38
ObjectManipulationWindow::preview_mode_selected
Definition: ObjectManipulationWindow.h:38
ObjectManipulationWindow::commandStarted
void commandStarted()
Locks interface as robot starts performing trajectory.
ObjectManipulationWindow::zoom_rect
void zoom_rect(QRectF rectangle)
Sets current object manipulation viewport.
ObjectManipulationWindow::set_view_scroll_step
void set_view_scroll_step(float view_scroll_step)
Sets view scroll step in pixels.
ObjectManipulationWindow::Q_ENUM
Q_ENUM(interfaceLogEvents) Q_PROPERTY(int Interface_size READ interface_size WRITE set_interface_size DESIGNABLE true USER true) Q_CLASSINFO("Interface_size"
Base button size in pixels.
ObjectManipulationWindow::zoom_in_selected
Definition: ObjectManipulationWindow.h:38
ObjectManipulationWindow::update_interface
void update_interface()
Redraws current interface.
ObjectManipulationWindow::on_toolButton_rotate_left_clicked
void on_toolButton_rotate_left_clicked()
Rotates image counterclockwise.
ObjectManipulationWindow::set_zoom_in_out_factor
void set_zoom_in_out_factor(float zoom_in_out_factor)
Sets zoom in/out factor.
ObjectManipulationWindow::robotEmergencyStopped
void robotEmergencyStopped()
Locks interface when robot emergency signal is active.
ObjectManipulationWindow::pickObject
void pickObject(QVector3D pointInMeters, float object_height, float angle, int bin)
emited after clicking a bin button in object manipulation mode
ObjectManipulationWindow::Zoom_in_out_factor
float Zoom_in_out_factor
Zoom in/out factor.
Definition: ObjectManipulationWindow.h:63
ObjectManipulationWindow::manipulation_mode
void manipulation_mode()
Switches interface to object manipulation mode if an object was selected, pauses camera preview...
mat_utils.h
ObjectManipulationWindow::look_at_selected
Definition: ObjectManipulationWindow.h:38
ObjectManipulationWindow::on_toolButton_rotate_right_clicked
void on_toolButton_rotate_right_clicked()
Rotates image clockwise.
ObjectManipulationWindow::on_toolButton_view_up_clicked
void on_toolButton_view_up_clicked()
Moves current viewport up.
ObjectManipulationWindow::set_interface_size
void set_interface_size(int interface_size_)
Sets base button size in pixels.
ObjectManipulationWindow::logEvent
void logEvent(ObjectManipulationWindow::interfaceLogEvents eventID, int selected_object, int param, QPointF point, QPointF size, float angle)
emited on all manipulation events
ObjectManipulationWindow::Object_list_file
QString Object_list_file
Object list file.
Definition: ObjectManipulationWindow.h:76
ObjectManipulationWindow::set_image_file
void set_image_file(const QString &image_file)
Sets image file.
ObjectManipulationWindow::zoom_rect_stop
void zoom_rect_stop(QPointF point)
Ends setting current object manipulation viewport.
ObjectManipulationWindow::getManipulationWidget
QGraphicsView * getManipulationWidget()
returns object manipulaion QGraphicsView widget
ObjectManipulationWindow::Image_file
QString Image_file
Static image file to display, disables live camera input and switches to object manipulation mode...
Definition: ObjectManipulationWindow.h:72
ObjectManipulationWindow::rotation_step
int rotation_step() const
Gets rotation step in degrees.
ObjectManipulationWindow::look_at
void look_at(QPointF point)
Sets current viewport center.
ObjectManipulationWindow::move_right_selected
Definition: ObjectManipulationWindow.h:38
ObjectManipulationWindow::on_toolButton_view_right_clicked
void on_toolButton_view_right_clicked()
Moves current viewport right.
ObjectManipulationWindow::set_object_list_file
void set_object_list_file(const QString &object_list_file)
Sets object list file.
ObjectManipulationWindow::ObjectManipulationWindow
ObjectManipulationWindow(QWidget *parent=0, Qt::WindowFlags flags=0)
Default constructor, initializes object manipulation window.
ObjectManipulationWindow::move_up_selected
Definition: ObjectManipulationWindow.h:38
ObjectManipulationWindow::set_initial_rotation
void set_initial_rotation(int initial_rotation)
Sets initial rotation in degrees.
ObjectManipulationWindow::robot_move_finished
Definition: ObjectManipulationWindow.h:38
ObjectManipulationWindow::Initial_rotation
int Initial_rotation
Initial rotation in degrees units.
Definition: ObjectManipulationWindow.h:44
ObjectManipulationWindow::zoom_rect_selected
Definition: ObjectManipulationWindow.h:38
ObjectManipulationWindow::move_down_selected
Definition: ObjectManipulationWindow.h:38
ObjectManipulationWindow::reset_buttons
void reset_buttons()
Resets buttons capacity counters.
ObjectManipulationWindow::image_file
QString image_file() const
Gets image file.
ObjectManipulationWindow::bin_button_selected
Definition: ObjectManipulationWindow.h:38
ObjectManipulationWindow::show_gestures_legend
void show_gestures_legend(int is_show)
Shows help for complex gestures.
ObjectManipulationWindow::preview_mode
void preview_mode()
Switches interface to preview mode, resets all selections, turns on live camera preview.
ObjectManipulationWindow::on_toolButton_cancel_clicked
void on_toolButton_cancel_clicked()
Returns to preview mode.
ObjectManipulationWindow::preview_mouse_moved
void preview_mouse_moved(QPointF point)
Mouse movement over preview window slot, highlights underlying objects.
ObjectManipulationWindow::on_toolButton_zoom_out_clicked
void on_toolButton_zoom_out_clicked()
Zooms out image.
ObjectManipulationWindow::set_rotation_step
void set_rotation_step(int rotation_step)
Sets rotation step in degrees.
ObjectManipulationWindow::resizeEvent
void resizeEvent(QResizeEvent *event)
ObjectManipulationWindow::initial_rotation
int initial_rotation() const
Gets initial rotation in degrees.
ObjectManipulationWindow::on_toolButton_view_down_clicked
void on_toolButton_view_down_clicked()
Moves current viewport down.
ObjectManipulationWindow::bin_button_toggled
Definition: ObjectManipulationWindow.h:38
ObjectManipulationWindow::set_bin_descriptors
void set_bin_descriptors(const QString &bin_descriptors)
Sets bin descriptors.
ObjectManipulationWindow::bin_button_clicked
void bin_button_clicked(int button_i)
Performs action assigned to selected bin button.
ObjectManipulationWindow::zoom_rect_start
void zoom_rect_start(QPointF point)
Starts setting current object manipulation viewport.
ObjectManipulationWindow::maximum
maximum
Definition: ObjectManipulationWindow.h:44
ObjectManipulationWindow::interface_size
int interface_size() const
Gets base button size in pixels.
ObjectManipulationWindow::on_toolButton_view_left_clicked
void on_toolButton_view_left_clicked()
Moves current viewport left.
ObjectManipulationWindow::zoom_out_selected
Definition: ObjectManipulationWindow.h:38
ObjectManipulationWindow::previev_types_t
previev_types_t
Definition: ObjectManipulationWindow.h:422
ObjectManipulationWindow::~ObjectManipulationWindow
~ObjectManipulationWindow()
Default destructor, cleans up.
ObjectManipulationWindow::rotate_right_selected
Definition: ObjectManipulationWindow.h:38
ObjectManipulationWindow::view_scroll_step
float view_scroll_step() const
Gets view scroll step (fraction of view window)
ObjectManipulationWindow::singleStep
singleStep
Definition: ObjectManipulationWindow.h:44
ObjectManipulationWindow::bin_descriptors
QString bin_descriptors() const
Gets bin descriptors.
ObjectManipulationWindow::on_toolButton_zoom_in_clicked
void on_toolButton_zoom_in_clicked()
Zooms in image.
ObjectManipulationWindow::commandExecuted
void commandExecuted()
Unlocks interface after robot finishes performing trajectory.
ObjectManipulationWindow::Bin_descriptors
QString Bin_descriptors
Bin descriptors.
Definition: ObjectManipulationWindow.h:68
ObjectManipulationWindow
Object manipulation window.
Definition: ObjectManipulationWindow.h:31
ObjectManipulationWindow::minimum
minimum
Definition: ObjectManipulationWindow.h:44
ObjectManipulationWindow::zoom_rect_widget
void zoom_rect_widget(QRect rectangle)
Sets current object manipulation viewport.
ObjectManipulationWindow::getPreviewId
previev_types_t getPreviewId()
Definition: ObjectManipulationWindow.h:423
ObjectManipulationWindow::on_stackedWidget_currentChanged
void on_stackedWidget_currentChanged(int)
Triggers interface redraw.
Definition: ObjectManipulationWindow.h:286
ObjectManipulationWindow::cancel_action_selected
Definition: ObjectManipulationWindow.h:38
ObjectManipulationWindow::on_toolButton_view_reset_clicked
void on_toolButton_view_reset_clicked()
Resets viewport to fit current selected object.