mainWindow.cpp
Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 
00035 
00039 
00040 #include <algorithm>
00041 #include <pcl/apps/point_cloud_editor/mainWindow.h>
00042 #include <pcl/apps/point_cloud_editor/cloudEditorWidget.h>
00043 #include <pcl/apps/point_cloud_editor/localTypes.h>
00044 
00045 MainWindow::MainWindow () :
00046   window_width_(WINDOW_WIDTH), window_height_(WINDOW_HEIGHT)
00047 {
00048   initWindow();
00049 }
00050 
00051 MainWindow::MainWindow (int argc, char **argv) :
00052 window_width_(WINDOW_WIDTH), window_height_(WINDOW_HEIGHT)
00053 {
00054   initWindow();
00055   if (argc > 1)
00056     cloud_editor_widget_->loadFile(argv[1]);
00057 }
00058 
00059 MainWindow::~MainWindow()
00060 {
00061 
00062 }
00063 
00064 void
00065 MainWindow::about ()
00066 {
00067   QMessageBox::about(this, tr("Point Cloud Editor"),
00068     tr("PCL 3D Editor\n\nAuthors: \n  Matthew Hielsberg (hielsber@tamu.edu) and\n"
00069        "  Yue Li (yli@cse.tamu.edu)\n  Texas A&M University\n\n"
00070        "This software was written as part of a collaboration with the "
00071        "University of South Carolina, Interdisciplinary Mathematics Institute."));
00072 }
00073 
00074 void
00075 MainWindow::help ()
00076 {
00077   QMessageBox::about(this, tr("Point Cloud Editor"),
00078                      tr("View Mode\n"
00079                         "  Drag:\t\tRotate about origin\n"
00080                         "  Alt Drag:\t\tTranslate Z\n"
00081                         "  Ctrl Drag:\t\tPan\n"
00082                         "  Shift Drag:\t\tZoom\n"
00083                         "\n"
00084                         "Selection Transform Mode\n"
00085                         "  Drag:\t\tRotate about centeroid\n"
00086                         "  Alt Drag:\t\tTranslate Z\n"
00087                         "  Ctrl Drag:\t\tPan\n"
00088                         "\n"
00089                         "Mouse Picking\n"
00090                         "  Left Click:\t\tSelect Point\n"
00091                         "  Ctrl Left Click:\tDeselect Point\n"
00092                         "  Shift Left Click:\tAppend to Selection\n"
00093                         "\n"
00094                         "2D Picking (Rubberband)\n"
00095                         "  Drag:\t\tSelect Region\n"
00096                         "  Ctrl Drag:\t\tDeselect Region\n"
00097                         "  Shift Drag:\t\tAppend to Selection\n"
00098                         "\n"
00099                         "Shortcut Keys\n"
00100                         "  1:\t\tColor Points White\n"
00101                         "  2:\t\tUse ColorWheel X\n"
00102                         "  3:\t\tUse ColorWheel Y\n"
00103                         "  4:\t\tUse ColorWheel Z\n"
00104                         "  5:\t\tUse RGB Color\n"
00105                         "  Ctrl C:\t\tCopy Selection\n"
00106                         "  Ctrl X:\t\tCut Selection\n"
00107                         "  Ctrl V:\t\tPaste Selection\n"
00108                         "  Ctrl Z:\t\tUndo\n"
00109                         "  V:\t\tView Mode\n"
00110                         "  T:\t\tSelection Transform Mode\n"
00111                         "  E:\t\tPoint Selection Mode\n"
00112                         "  S:\t\t2D Selection Mode\n"
00113                         "  Del:\t\tDelete Selection\n"
00114                         "  +:\t\tIncrease Point Size\n"
00115                         "  -:\t\tDecrease Point Size\n"
00116                         "  Ctrl +:\t\tInc. Selection Point Size\n"
00117                         "  Ctrl -:\t\tDec. Selection Point Size\n"
00118                         "  Esc:\t\tCancel Selection\n"
00119                         ));
00120 }
00121 
00122 void
00123 MainWindow::initWindow ()
00124 {
00125   cloud_editor_widget_ = new CloudEditorWidget(this);
00126   cloud_editor_widget_->setAttribute(Qt::WA_DeleteOnClose);
00127   setCentralWidget(cloud_editor_widget_);
00128   createActions();
00129   createMenus();
00130   createToolBars();
00131   setWindowTitle(tr("PCL 3D Editor (TAMU)"));
00132   resize(window_width_, window_height_);
00133 }
00134 
00135 void
00136 MainWindow::createActions ()
00137 {
00138   action_group_ = new QActionGroup(this);
00139 
00140   QString icon_path(":/");
00141 
00142   open_action_ = new QAction(QIcon(icon_path+"open.png"),tr("Open..."),this);
00143   open_action_ -> setShortcut(tr("Ctrl+O"));
00144   connect(open_action_, SIGNAL(triggered()), cloud_editor_widget_,
00145           SLOT(load()));
00146 
00147   save_action_ = new QAction(QIcon(icon_path+"save.png"), tr("Save as.."),
00148                              this);
00149   save_action_ -> setShortcut(tr("Ctrl+S"));
00150   connect(save_action_,SIGNAL(triggered()),cloud_editor_widget_,SLOT(save()));
00151 
00152   exit_action_ = new QAction(tr("Exit..."), this);
00153   exit_action_ -> setShortcut(tr("Ctrl+Q"));
00154   connect(exit_action_, SIGNAL(triggered()), this, SLOT(close()));
00155 
00156   about_action_ = new QAction(tr("About"), this);
00157   connect(about_action_, SIGNAL(triggered()), this, SLOT(about()));
00158 
00159   help_action_ = new QAction(tr("Keyboard/Mouse Control"), this);
00160   connect(help_action_, SIGNAL(triggered()), this, SLOT(help()));
00161 
00162   copy_action_ = new QAction(QIcon(icon_path+"copy.png"), tr("Copy"),
00163                              action_group_);
00164   copy_action_ -> setShortcut(tr("Ctrl+C"));
00165   connect(copy_action_, SIGNAL(triggered()), cloud_editor_widget_,
00166           SLOT(copy()));
00167   copy_action_->setCheckable(false);
00168 
00169   delete_action_ = new QAction(QIcon(icon_path+"delete.png"), tr("Delete"),
00170                                action_group_);
00171   delete_action_ -> setShortcut(tr("D"));
00172   connect(delete_action_, SIGNAL(triggered()), cloud_editor_widget_,
00173           SLOT(remove()));
00174   delete_action_->setCheckable(false);
00175 
00176   cut_action_ = new QAction(QIcon(icon_path+"cut.png"), tr("Cut"),
00177                             action_group_);
00178   cut_action_ -> setShortcut(tr("Ctrl+X"));
00179   connect(cut_action_, SIGNAL(triggered()), cloud_editor_widget_,SLOT(cut()));
00180   cut_action_ -> setCheckable(false);
00181 
00182   paste_action_ = new QAction(QIcon(icon_path+"paste.png"), tr("Paste"),
00183                               action_group_);
00184   paste_action_ -> setShortcut(tr("Ctrl+V"));
00185   connect(paste_action_, SIGNAL(triggered()), cloud_editor_widget_,
00186           SLOT(paste()));
00187   paste_action_ -> setCheckable(false);
00188 
00189   toggle_blend_action_ = new QAction(tr("Outline Points"), this);
00190   connect(toggle_blend_action_, SIGNAL(triggered()), cloud_editor_widget_,
00191           SLOT(toggleBlendMode()));
00192   toggle_blend_action_->setCheckable(true);
00193   toggle_blend_action_->setChecked(false);
00194 
00195   view_action_ = new QAction(QIcon(icon_path+"view.png"), tr("View"),
00196                              action_group_);
00197   view_action_ -> setShortcut(tr("V"));
00198   connect(view_action_, SIGNAL(triggered()), cloud_editor_widget_,
00199           SLOT(view()));
00200   view_action_->setCheckable(true);
00201   view_action_->setChecked(true);
00202 
00203   undo_action_ = new QAction(QIcon(icon_path+"undo.png"),
00204                                    tr("Undo"), action_group_);
00205   undo_action_ -> setShortcut(tr("Ctrl+Z"));
00206   connect(undo_action_, SIGNAL(triggered()), cloud_editor_widget_,
00207           SLOT(undo()));
00208   undo_action_->setCheckable(false);
00209 
00210   transform_action_ = new QAction(QIcon(icon_path+"move.png"),
00211                                   tr("Transform Selection"), action_group_);
00212   transform_action_ -> setShortcut(tr("T"));
00213   connect(transform_action_, SIGNAL(triggered()), cloud_editor_widget_,
00214           SLOT(transform()));
00215   transform_action_->setCheckable(true);
00216 
00217 
00218   denoise_action_ = new QAction(tr("Denoise"), this);
00219   connect(denoise_action_, SIGNAL(triggered()), cloud_editor_widget_,
00220           SLOT(denoise()));
00221 
00222   select_action_ = new QAction(QIcon(icon_path+"click.png"),
00223                                tr("Point Selection"), action_group_);
00224   select_action_->setShortcut(tr("E"));
00225   connect(select_action_, SIGNAL(triggered()), cloud_editor_widget_,
00226           SLOT(select1D()));
00227   select_action_->setCheckable(true);
00228 
00229   invert_select_action_ = new QAction(QIcon(icon_path+"invert.png"),
00230                                       tr("Invert Selection"), action_group_);
00231   connect(invert_select_action_, SIGNAL(triggered()), cloud_editor_widget_,
00232           SLOT(invertSelect()));
00233   invert_select_action_->setCheckable(false);
00234 
00235   select_2D_action_ = new QAction(QIcon(icon_path+"select.png"),
00236                                   tr("Rubberband Selection"), action_group_);
00237   select_2D_action_->setShortcut(tr("S"));
00238   connect(select_2D_action_, SIGNAL(triggered()), cloud_editor_widget_,
00239           SLOT(select2D()));
00240   select_2D_action_->setCheckable(true);
00241 
00242   //select_3D_action_ = new QAction(QIcon(icon_path+"cube.png"),
00243   //                                tr("3D Selection"), action_group_);
00244   //select_3D_action_->setShortcut(tr("A"));
00245   //connect(select_3D_action_, SIGNAL(triggered()), cloud_editor_widget_,
00246   //        SLOT(select3D()));
00247   //select_3D_action_->setCheckable(true);
00248 
00249   show_stat_action_ = new QAction(QIcon(icon_path+"info.png"),
00250                       tr("Show statistics"), action_group_);
00251   connect(show_stat_action_, SIGNAL(triggered()), cloud_editor_widget_,
00252           SLOT(showStat()));
00253   show_stat_action_->setCheckable(false);
00254 }
00255 
00256 void
00257 MainWindow::createMenus ()
00258 {
00259   file_menu_ = new QMenu(tr("&File"), this);
00260   file_menu_ -> setAttribute(Qt::WA_DeleteOnClose);
00261   file_menu_ -> addAction(open_action_);
00262   file_menu_ -> addSeparator();
00263   file_menu_ -> addAction(save_action_);
00264   file_menu_ -> addSeparator();
00265   file_menu_ -> addAction(exit_action_);
00266 
00267   edit_menu_ = new QMenu(tr("&Edit"), this);
00268   edit_menu_ -> setAttribute(Qt::WA_DeleteOnClose);
00269   edit_menu_ -> addAction(undo_action_);
00270   edit_menu_ -> addSeparator();
00271   edit_menu_ -> addAction(cut_action_);
00272   edit_menu_ -> addAction(copy_action_);
00273   edit_menu_ -> addAction(paste_action_);
00274   edit_menu_ -> addAction(delete_action_);
00275   edit_menu_ -> addSeparator();
00276   edit_menu_ -> addAction(transform_action_);
00277 
00278   select_menu_ = new QMenu(tr("&Select"), this);
00279   select_menu_ -> setAttribute(Qt::WA_DeleteOnClose);
00280   select_menu_ -> addAction(select_action_);
00281   select_menu_ -> addAction(select_2D_action_);
00282   //select_menu_ -> addAction(select_3D_action_);
00283 
00284   display_menu_ = new QMenu(tr("&Display"), this);
00285   display_menu_ -> setAttribute(Qt::WA_DeleteOnClose);
00286   display_menu_ -> addAction(toggle_blend_action_);
00287 
00288   view_menu_ = new QMenu(tr("&View"), this);
00289   view_menu_ -> setAttribute(Qt::WA_DeleteOnClose);
00290   view_menu_ -> addAction(view_action_);
00291   view_menu_ -> addAction(show_stat_action_);
00292 
00293   tool_menu_ = new QMenu(tr("&Algorithm"), this);
00294   tool_menu_ -> setAttribute(Qt::WA_DeleteOnClose);
00295   tool_menu_ -> addAction(denoise_action_);
00296 
00297   help_menu_ = new QMenu(tr("&Help"), this);
00298   help_menu_ -> setAttribute(Qt::WA_DeleteOnClose);
00299   help_menu_ -> addAction(about_action_);
00300   help_menu_ -> addAction(help_action_);
00301 
00302   menuBar() -> addMenu(file_menu_);
00303   menuBar() -> addMenu(edit_menu_);
00304   menuBar() -> addMenu(select_menu_);
00305   menuBar() -> addMenu(display_menu_);
00306   menuBar() -> addMenu(tool_menu_);
00307   menuBar() -> addMenu(help_menu_);
00308 }
00309 
00310 void
00311 MainWindow::createToolBars ()
00312 {
00313   createSpinBoxes();
00314   createSliders();
00315   view_tool_bar_ = addToolBar(tr("File"));
00316   view_tool_bar_ -> addAction(open_action_);
00317   view_tool_bar_ -> addAction(save_action_);
00318   view_tool_bar_ = addToolBar(tr("View"));
00319   view_tool_bar_ -> addAction(view_action_);
00320   view_tool_bar_ -> addAction(select_action_);
00321   view_tool_bar_ -> addAction(select_2D_action_);
00322   //view_tool_bar_ -> addAction(select_3D_action_);
00323   view_tool_bar_ -> addAction(invert_select_action_);
00324   QLabel *ptSizeLabel = new QLabel(tr("Point Size:"));
00325   ptSizeLabel -> setAttribute(Qt::WA_DeleteOnClose);
00326   view_tool_bar_ -> addWidget(ptSizeLabel);
00327   view_tool_bar_ -> addWidget(point_size_spin_box_);
00328   QLabel *selectedPtSizeLabel = new QLabel(tr("Selected Point Size:"));
00329   selectedPtSizeLabel -> setAttribute(Qt::WA_DeleteOnClose);
00330   view_tool_bar_ -> addWidget(selectedPtSizeLabel);
00331   view_tool_bar_ -> addWidget(selected_point_size_spin_box_);
00332   edit_tool_bar_ = addToolBar(tr("Edit"));
00333   edit_tool_bar_ -> addAction(undo_action_);
00334   edit_tool_bar_ -> addAction(copy_action_);
00335   edit_tool_bar_ -> addAction(cut_action_);
00336   edit_tool_bar_ -> addAction(delete_action_);
00337   edit_tool_bar_ -> addAction(paste_action_);
00338   edit_tool_bar_ -> addAction(transform_action_);
00339   edit_tool_bar_ -> addAction(show_stat_action_);
00340 }
00341 
00342 void
00343 MainWindow::increaseSpinBoxValue()
00344 {
00345   point_size_spin_box_ -> setValue(point_size_spin_box_->value() + 1);
00346 }
00347 
00348 void
00349 MainWindow::decreaseSpinBoxValue()
00350 {
00351   point_size_spin_box_ -> setValue(point_size_spin_box_->value() - 1);
00352 }
00353 
00354 int
00355 MainWindow::getSpinBoxValue()
00356 {
00357   return (point_size_spin_box_->value());
00358 }
00359 
00360 void
00361 MainWindow::increaseSelectedSpinBoxValue()
00362 {
00363   selected_point_size_spin_box_ -> setValue(selected_point_size_spin_box_->value() + 1);
00364 }
00365 
00366 void
00367 MainWindow::decreaseSelectedSpinBoxValue()
00368 {
00369   selected_point_size_spin_box_ -> setValue(selected_point_size_spin_box_->value() - 1);
00370 }
00371 
00372 int
00373 MainWindow::getSelectedSpinBoxValue()
00374 {
00375   return (selected_point_size_spin_box_->value());
00376 }
00377 
00378 void
00379 MainWindow::createSpinBoxes ()
00380 {
00381   point_size_spin_box_ = new QSpinBox;
00382   point_size_spin_box_ -> setAttribute(Qt::WA_DeleteOnClose);
00383   point_size_spin_box_ -> setRange(1, 20);
00384   point_size_spin_box_ -> setSingleStep(1);
00385   point_size_spin_box_ -> setValue(2);
00386   connect(point_size_spin_box_, SIGNAL(valueChanged(int)),
00387           cloud_editor_widget_, SLOT(setPointSize(int)));
00388   selected_point_size_spin_box_ = new QSpinBox;
00389   selected_point_size_spin_box_ -> setAttribute(Qt::WA_DeleteOnClose);
00390   selected_point_size_spin_box_ -> setRange(1, 20);
00391   selected_point_size_spin_box_ -> setSingleStep(1);
00392   selected_point_size_spin_box_ -> setValue(4);
00393   connect(selected_point_size_spin_box_, SIGNAL(valueChanged(int)),
00394           cloud_editor_widget_, SLOT(setSelectedPointSize(int)));
00395 }
00396 
00397 void
00398 MainWindow::createSliders ()
00399 {
00400   move_speed_slider_ = new QSlider(Qt::Horizontal);
00401   move_speed_slider_ -> setAttribute(Qt::WA_DeleteOnClose);
00402   move_speed_slider_ -> setFocusPolicy(Qt::StrongFocus);
00403   move_speed_slider_ -> setTickPosition(QSlider::TicksBothSides);
00404   move_speed_slider_ -> setTickInterval(10);
00405   move_speed_slider_ -> setSingleStep(1);
00406 }


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:25:22