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 00040 00041 #include <pcl/apps/point_cloud_editor/pasteCommand.h> 00042 #include <pcl/apps/point_cloud_editor/cloud.h> 00043 #include <pcl/apps/point_cloud_editor/copyBuffer.h> 00044 #include <pcl/apps/point_cloud_editor/selection.h> 00045 00046 PasteCommand::PasteCommand (ConstCopyBufferPtr copy_buffer_ptr, 00047 SelectionPtr selection_ptr, 00048 CloudPtr cloud_ptr) 00049 : copy_buffer_ptr_(copy_buffer_ptr), selection_ptr_(selection_ptr), 00050 cloud_ptr_(cloud_ptr) 00051 { 00052 } 00053 00054 void 00055 PasteCommand::execute() 00056 { 00057 if (!cloud_ptr_) 00058 return; 00059 // record the previous cloud size 00060 prev_cloud_size_ = cloud_ptr_->size(); 00061 00062 // paste and update cloud status 00063 cloud_ptr_->append(copy_buffer_ptr_->get()); 00064 00065 // make the appended cloud be selected 00066 selection_ptr_ -> clear(); 00067 selection_ptr_ -> addIndexRange(prev_cloud_size_, 00068 cloud_ptr_->size() - prev_cloud_size_); 00069 // notify the cloud that the selection has changed 00070 cloud_ptr_ -> setSelection(selection_ptr_); 00071 } 00072 00073 void 00074 PasteCommand::undo() 00075 { 00076 if (!cloud_ptr_) 00077 return; 00078 selection_ptr_->removeIndexRange(prev_cloud_size_, cloud_ptr_->size()-prev_cloud_size_); 00079 cloud_ptr_->resize(prev_cloud_size_); 00080 }