diff --git a/.dev/whitelist.txt b/.dev/whitelist.txt index 70185112ef6..52ba06c8beb 100644 --- a/.dev/whitelist.txt +++ b/.dev/whitelist.txt @@ -1,3 +1,20 @@ +apps/cloud_composer/include/pcl/apps/cloud_composer +apps/cloud_composer/src/point_selectors +apps/cloud_composer/src/tool_interface +apps/cloud_composer/tools +apps/cloud_composer/src/cloud_composer.cpp +apps/cloud_composer/src/cloud_viewer.cpp +apps/cloud_composer/src/commands.cpp +apps/cloud_composer/src/item_inspector.cpp +apps/cloud_composer/src/items/cloud_composer_item.cpp +apps/cloud_composer/src/items/fpfh_item.cpp +apps/cloud_composer/src/main.cpp +apps/cloud_composer/src/merge_selection.cpp +apps/cloud_composer/src/properties_model.cpp +apps/cloud_composer/src/signal_multiplexer.cpp +apps/cloud_composer/src/toolbox_model.cpp +apps/cloud_composer/src/transform_clouds.cpp +apps/cloud_composer/src/work_queue.cpp apps/3d_rec_framework apps/in_hand_scanner apps/include diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_browser.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_browser.h index c5e8c7d691b..973ca0015e1 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_browser.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_browser.h @@ -42,40 +42,35 @@ class QItemSelectionModel; -namespace pcl -{ - namespace cloud_composer - { - /** \brief View class for displaying project composition - * \author Jeremie Papon - * \ingroup cloud_composer - */ - class ProjectModel; - class CloudBrowser : public QTreeView - { - Q_OBJECT - public: - CloudBrowser (QWidget* parent = nullptr); - - void - setModel (QAbstractItemModel* new_model) override; - - private: - ProjectModel* current_project_model_; - - }; - - class BackgroundDelegate : public QStyledItemDelegate - { - public: - explicit - BackgroundDelegate (QObject *parent = nullptr) - : QStyledItemDelegate(parent) {} - - void - paint (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; - - }; - - } -} +namespace pcl { +namespace cloud_composer { +/** \brief View class for displaying project composition + * \author Jeremie Papon + * \ingroup cloud_composer + */ +class ProjectModel; +class CloudBrowser : public QTreeView { + Q_OBJECT +public: + CloudBrowser(QWidget* parent = nullptr); + + void + setModel(QAbstractItemModel* new_model) override; + +private: + ProjectModel* current_project_model_; +}; + +class BackgroundDelegate : public QStyledItemDelegate { +public: + explicit BackgroundDelegate(QObject* parent = nullptr) : QStyledItemDelegate(parent) + {} + + void + paint(QPainter* painter, + const QStyleOptionViewItem& option, + const QModelIndex& index) const override; +}; + +} // namespace cloud_composer +} // namespace pcl diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_composer.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_composer.h index 9fbfdcc5b17..1da2fb7158a 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_composer.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_composer.h @@ -37,7 +37,7 @@ #pragma once -//PCL +// PCL #include #include @@ -45,125 +45,122 @@ class QTreeView; -namespace pcl -{ - namespace cloud_composer - { - class ProjectModel; - class CloudViewer; - class CloudCommand; - class ToolFactory; - class ToolBoxModel; - class SignalMultiplexer; - - /** \brief MainWindow of cloud_composer application - * \author Jeremie Papon - * \ingroup cloud_composer - * The following member objects are defined in the ui file and can be manipulated: - * * cloud_viewer_ is the view which contains the PCLVisualizer & QVTKWidget - * * cloud_browser_ is the tree view in the left dock - * * item_inspector_ is the details view in the left dock - * * tool_box_view_ is the tool box in right dock - * * tool_parameter_view_ shows adjustable parameters for currently selected tool - * * undo_view_ is the undo stack view in the right dock - */ - class ComposerMainWindow : public QMainWindow, private Ui::ComposerMainWindow - { - Q_OBJECT - public: - explicit ComposerMainWindow (QWidget *parent = nullptr); - ~ComposerMainWindow (); - - Q_SIGNALS: - /** \brief Signal emitted when the active project is switched - ie a different project tab is selected */ - void - activeProjectChanged (ProjectModel* new_model, ProjectModel* previous_model); - - /** \brief This signal tells the current project to insert a cloud using a file dialog box */ - void - insertNewCloudFromFile (); - - /** \brief This signal tells the current project to insert a cloud from and RGB and Depth image using a file dialog box */ - void - insertNewCloudFromRGBandDepth (); - - /** \brief This signal tells the current project to save currently selected cloud to file */ - void - saveSelectedCloudToFile (); - - public Q_SLOTS: - //Slots for File Menu Actions - void - on_action_new_project__triggered (/*QString name = "unsaved project"*/); - void - on_action_open_cloud_as_new_project__triggered (); - void - on_action_open_project__triggered (); - void - on_action_save_project__triggered (); - void - on_action_save_project_as__triggered (); - void - on_action_save_selected_cloud__triggered (); - void - on_action_exit__triggered (); - - //Slots for Edit Menu Actions - void - on_action_insert_from_file__triggered (); - void - on_action_insert_from_openNi_source__triggered (); - void - on_action_insert_from_rgb_depth__triggered (); - - - - void - setCurrentModel (ProjectModel* model); - - void - setMouseStyleAction (interactor_styles::INTERACTOR_STYLES selected_style); - - void - enqueueToolAction (AbstractTool* tool); - - private: - void - connectFileActions (); - void - connectEditActions (); - - void - connectViewActions (); - - void - initializeCloudBrowser (); - void - initializeCloudViewer (); - void - initializeItemInspector (); - - void - initializeToolBox (); - void - initializePlugins (); - - - /** \brief Pointer to the model which is currently being viewed */ - ProjectModel* current_model_; - QItemSelectionModel* current_selection_model_; - - QMap name_model_map_; - - QUndoGroup *undo_group_; - - QItemSelectionModel* tool_selection_model_; - ToolBoxModel* tool_box_model_; - - SignalMultiplexer* multiplexer_; - - QActionGroup* mouse_style_group_; - }; - - } -} +namespace pcl { +namespace cloud_composer { +class ProjectModel; +class CloudViewer; +class CloudCommand; +class ToolFactory; +class ToolBoxModel; +class SignalMultiplexer; + +/** \brief MainWindow of cloud_composer application + * \author Jeremie Papon + * \ingroup cloud_composer + * The following member objects are defined in the ui file and can be manipulated: + * * cloud_viewer_ is the view which contains the PCLVisualizer & QVTKWidget + * * cloud_browser_ is the tree view in the left dock + * * item_inspector_ is the details view in the left dock + * * tool_box_view_ is the tool box in right dock + * * tool_parameter_view_ shows adjustable parameters for currently selected tool + * * undo_view_ is the undo stack view in the right dock + */ +class ComposerMainWindow : public QMainWindow, private Ui::ComposerMainWindow { + Q_OBJECT +public: + explicit ComposerMainWindow(QWidget* parent = nullptr); + ~ComposerMainWindow(); + +Q_SIGNALS: + /** \brief Signal emitted when the active project is switched - ie a different project + * tab is selected */ + void + activeProjectChanged(ProjectModel* new_model, ProjectModel* previous_model); + + /** \brief This signal tells the current project to insert a cloud using a file dialog + * box */ + void + insertNewCloudFromFile(); + + /** \brief This signal tells the current project to insert a cloud from and RGB and + * Depth image using a file dialog box */ + void + insertNewCloudFromRGBandDepth(); + + /** \brief This signal tells the current project to save currently selected cloud to + * file */ + void + saveSelectedCloudToFile(); + +public Q_SLOTS: + // Slots for File Menu Actions + void on_action_new_project__triggered(/*QString name = "unsaved project"*/); + void + on_action_open_cloud_as_new_project__triggered(); + void + on_action_open_project__triggered(); + void + on_action_save_project__triggered(); + void + on_action_save_project_as__triggered(); + void + on_action_save_selected_cloud__triggered(); + void + on_action_exit__triggered(); + + // Slots for Edit Menu Actions + void + on_action_insert_from_file__triggered(); + void + on_action_insert_from_openNi_source__triggered(); + void + on_action_insert_from_rgb_depth__triggered(); + + void + setCurrentModel(ProjectModel* model); + + void + setMouseStyleAction(interactor_styles::INTERACTOR_STYLES selected_style); + + void + enqueueToolAction(AbstractTool* tool); + +private: + void + connectFileActions(); + void + connectEditActions(); + + void + connectViewActions(); + + void + initializeCloudBrowser(); + void + initializeCloudViewer(); + void + initializeItemInspector(); + + void + initializeToolBox(); + void + initializePlugins(); + + /** \brief Pointer to the model which is currently being viewed */ + ProjectModel* current_model_; + QItemSelectionModel* current_selection_model_; + + QMap name_model_map_; + + QUndoGroup* undo_group_; + + QItemSelectionModel* tool_selection_model_; + ToolBoxModel* tool_box_model_; + + SignalMultiplexer* multiplexer_; + + QActionGroup* mouse_style_group_; +}; + +} // namespace cloud_composer +} // namespace pcl diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_view.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_view.h index 27780fa5ebf..09723d2beff 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_view.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_view.h @@ -37,130 +37,138 @@ #pragma once -#include - -#include - +#include #include #include -#include +#include -#include -#include #include +#include +#include +#include #include class QItemSelection; class QStandardItem; -namespace pcl -{ - namespace cloud_composer +namespace pcl { +namespace cloud_composer { +class ProjectModel; +/** \brief View class for displaying ProjectModel data using PCLVisualizer + * \author Jeremie Papon + * \ingroup cloud_composer + */ +class CloudView : public QWidget { + Q_OBJECT + +public: + CloudView(QWidget* parent = nullptr); + CloudView(const CloudView& to_copy); + CloudView(ProjectModel* model, QWidget* parent = nullptr); + + void + setModel(ProjectModel* new_model); + + ProjectModel* + getModel() const + { + return model_; + } + + PCLQVTKWidget* + getQVTK() const + { + return qvtk_; + } + + pcl::visualization::PCLVisualizer::Ptr + getPCLVisualizer() const { - class ProjectModel; - /** \brief View class for displaying ProjectModel data using PCLVisualizer - * \author Jeremie Papon - * \ingroup cloud_composer - */ - class CloudView : public QWidget - { - Q_OBJECT - - public: - CloudView (QWidget* parent = nullptr); - CloudView (const CloudView& to_copy); - CloudView (ProjectModel* model, QWidget* parent = nullptr); - - void - setModel (ProjectModel* new_model); - - ProjectModel* - getModel () const { return model_; } - - PCLQVTKWidget* - getQVTK() const { return qvtk_; } - - pcl::visualization::PCLVisualizer::Ptr - getPCLVisualizer () const { return vis_; } - - void - setAxisVisibility (bool visible); - - void - setInteractorStyle (interactor_styles::INTERACTOR_STYLES style); - public Q_SLOTS: - void - refresh (); - - /** \brief Slot called when the item selected in cloud browser changes */ - void - selectedItemChanged (const QItemSelection & selected, const QItemSelection & deselected); - - /** \brief Slot called when the data in model changes */ - void - dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight ); - - protected Q_SLOTS: - /** \brief Slot called when an item in the model changes - * \param topLeft - * \param bottomRight - */ - void - itemChanged (QStandardItem* item); - - /** \brief Slot called when rows inserted to model - * \param start Start of new rows (inclusive) - * \param end End of new rows (inclusive) - */ - void - rowsInserted (const QModelIndex& parent, int start, int end); - - void - rowsAboutToBeRemoved (const QModelIndex& parent, int start, int end); - - void - selectionCompleted (vtkObject* caller, unsigned long event_id, void* client_data, void* call_data); - - void - manipulationCompleted (vtkObject* caller, unsigned long event_id, void* client_data, void* call_data); - - protected: - void - paintEvent (QPaintEvent* event) override; - void - resizeEvent (QResizeEvent* event) override; - // void scrollContentsBy (int dx, int dy); - - - - private: - void - connectSignalsAndSlots (); - - /** \brief Internal function for setting up the style_switch_ */ - void - initializeInteractorSwitch (); - - void - addOrientationMarkerWidgetAxes (); - void - removeOrientationMarkerWidgetAxes (); - - pcl::visualization::PCLVisualizer::Ptr vis_; - ProjectModel* model_; - - PCLQVTKWidget* qvtk_; - - vtkSmartPointer style_switch_; - - vtkSmartPointer axes_widget_; - vtkSmartPointer axes_; - - /** \brief Manages VTK events by connecting them to QT slots */ - vtkSmartPointer connections_; - }; + return vis_; } -} -Q_DECLARE_METATYPE (pcl::cloud_composer::CloudView); + void + setAxisVisibility(bool visible); + + void + setInteractorStyle(interactor_styles::INTERACTOR_STYLES style); +public Q_SLOTS: + void + refresh(); + + /** \brief Slot called when the item selected in cloud browser changes */ + void + selectedItemChanged(const QItemSelection& selected, const QItemSelection& deselected); + + /** \brief Slot called when the data in model changes */ + void + dataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight); + +protected Q_SLOTS: + /** \brief Slot called when an item in the model changes + * \param topLeft + * \param bottomRight + */ + void + itemChanged(QStandardItem* item); + + /** \brief Slot called when rows inserted to model + * \param start Start of new rows (inclusive) + * \param end End of new rows (inclusive) + */ + void + rowsInserted(const QModelIndex& parent, int start, int end); + + void + rowsAboutToBeRemoved(const QModelIndex& parent, int start, int end); + + void + selectionCompleted(vtkObject* caller, + unsigned long event_id, + void* client_data, + void* call_data); + + void + manipulationCompleted(vtkObject* caller, + unsigned long event_id, + void* client_data, + void* call_data); + +protected: + void + paintEvent(QPaintEvent* event) override; + void + resizeEvent(QResizeEvent* event) override; + // void scrollContentsBy (int dx, int dy); + +private: + void + connectSignalsAndSlots(); + + /** \brief Internal function for setting up the style_switch_ */ + void + initializeInteractorSwitch(); + + void + addOrientationMarkerWidgetAxes(); + void + removeOrientationMarkerWidgetAxes(); + + pcl::visualization::PCLVisualizer::Ptr vis_; + ProjectModel* model_; + + PCLQVTKWidget* qvtk_; + + vtkSmartPointer style_switch_; + + vtkSmartPointer axes_widget_; + vtkSmartPointer axes_; + + /** \brief Manages VTK events by connecting them to QT slots */ + vtkSmartPointer connections_; +}; +} // namespace cloud_composer +} // namespace pcl + +Q_DECLARE_METATYPE(pcl::cloud_composer::CloudView); diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_viewer.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_viewer.h index df10dc1f09f..3e6489fc5f2 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_viewer.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_viewer.h @@ -37,48 +37,44 @@ #pragma once +#include +#include +#include + #include -#include -#include -#include +namespace pcl { +namespace cloud_composer { + +/** \brief Tabbed widget for containing CloudView widgets + * \author Jeremie Papon + * \ingroup cloud_composer + */ +class CloudViewer : public QTabWidget { + Q_OBJECT + +public: + CloudViewer(QWidget* parent = nullptr); + ProjectModel* + getModel() const; + +public Q_SLOTS: + void + addModel(ProjectModel* new_model); -namespace pcl -{ - namespace cloud_composer - { - - /** \brief Tabbed widget for containing CloudView widgets - * \author Jeremie Papon - * \ingroup cloud_composer - */ - class CloudViewer : public QTabWidget - { - Q_OBJECT + void + modelChanged(int index); - public: - - CloudViewer (QWidget* parent = nullptr); - ProjectModel* getModel () const; + void + addNewProject(ProjectModel* new_model); - public Q_SLOTS: - void - addModel (ProjectModel* new_model); - - void - modelChanged (int index); - - void - addNewProject (ProjectModel* new_model); - - Q_SIGNALS: - void - newModelSelected (ProjectModel *new_model); +Q_SIGNALS: + void + newModelSelected(ProjectModel* new_model); - private: - - pcl::visualization::PCLVisualizer::Ptr vis_; - QMap model_view_map_; - }; - } -} +private: + pcl::visualization::PCLVisualizer::Ptr vis_; + QMap model_view_map_; +}; +} // namespace cloud_composer +} // namespace pcl diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/commands.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/commands.h index 5186af6a8d3..e47c399b2e2 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/commands.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/commands.h @@ -41,180 +41,171 @@ #include -namespace pcl -{ - namespace cloud_composer +namespace pcl { +namespace cloud_composer { +class AbstractTool; +class ProjectModel; +struct OutputPair { + QList input_items_; + QList output_items_; +}; + +class CloudCommand : public QUndoCommand { +public: + CloudCommand(ConstItemList input_data, QUndoCommand* parent = nullptr); + + ~CloudCommand(); + + virtual bool + runCommand(AbstractTool* tool) = 0; + + void + undo() override = 0; + + void + redo() override = 0; + + // QList + // executeToolOnTemplateCloud (AbstractTool* tool, ConstItemList &input_data); + + void + setProjectModel(ProjectModel* model); + + inline void + setInputData(ConstItemList input_data) + { + original_data_ = std::move(input_data); + } + +protected: + /** \brief Removes the original item(s) from the model and replaces with the + * replacement(s) Replacements are only inserted once, original items must have same + * parent This stores the removed items in removed_items_ + */ + bool + replaceOriginalWithNew(const QList& originals, + const QList& new_items); + + /** \brief This removes new_items from the model and restores originals */ + bool + restoreOriginalRemoveNew(const QList& originals, + const QList& new_items); + + ConstItemList original_data_; + + QMap removed_to_parent_map_; + QList output_data_; + ProjectModel* project_model_; + + /** \brief This determines if we delete original items or not on destruction + * If the command is being deleted because stack is at limit, then we want + * to only delete the originals, since the command is staying for good (new items + * shouldn't be deleted) On the other hand, if we destruct after an undo, then we want + * to delete the new items (but not the originals) + */ + bool last_was_undo_; + + /** \brief This is used to check if a templated version of a tool can be used + * For this to return true, all items must be clouds, and must have the same template + * type + */ + bool + canUseTemplates(ConstItemList& input_data); + + bool can_use_templates_; + int template_type_; +}; + +class ModifyItemCommand : public CloudCommand { +public: + ModifyItemCommand(ConstItemList input_data, QUndoCommand* parent = nullptr); + + bool + runCommand(AbstractTool* tool) override; + + void + undo() override; + + void + redo() override; + +private: +}; + +class NewItemCloudCommand : public CloudCommand { +public: + NewItemCloudCommand(ConstItemList input_data, QUndoCommand* parent = nullptr); + + bool + runCommand(AbstractTool* tool) override; + + void + undo() override; + + void + redo() override; +}; + +class SplitCloudCommand : public CloudCommand { +public: + SplitCloudCommand(ConstItemList input_data, QUndoCommand* parent = nullptr); + + bool + runCommand(AbstractTool* tool) override; + + void + undo() override; + + void + redo() override; + +private: +}; + +class DeleteItemCommand : public CloudCommand { +public: + DeleteItemCommand(ConstItemList input_data, QUndoCommand* parent = nullptr); + + bool + runCommand(AbstractTool* tool) override; + + void + undo() override; + + void + redo() override; + +private: +}; + +class MergeCloudCommand : public CloudCommand { +public: + /** \brief Construct for a merge command + * \param[in] input_data Input list of CloudItem s from the project model which will + * be merged \param[in] temporary_clouds Input list of CloudItems which + */ + MergeCloudCommand(ConstItemList input_data, QUndoCommand* parent = nullptr); + + bool + runCommand(AbstractTool* tool) override; + + void + undo() override; + + void + redo() override; + + inline void + setSelectedIndicesMap( + const QMap& selected_item_index_map) { - class AbstractTool; - class ProjectModel; - struct OutputPair - { - QList input_items_; - QList output_items_; - }; - - - - class CloudCommand : public QUndoCommand - { - public: - CloudCommand (ConstItemList input_data, QUndoCommand* parent = nullptr); - - - ~CloudCommand (); - - virtual bool - runCommand (AbstractTool* tool) = 0; - - void - undo () override = 0; - - void - redo () override = 0; - - //QList - // executeToolOnTemplateCloud (AbstractTool* tool, ConstItemList &input_data); - - void - setProjectModel (ProjectModel* model); - - inline void - setInputData (ConstItemList input_data) - { - original_data_ = std::move(input_data); - } - protected: - /** \brief Removes the original item(s) from the model and replaces with the replacement(s) - * Replacements are only inserted once, original items must have same parent - * This stores the removed items in removed_items_ - */ - bool - replaceOriginalWithNew (const QList & originals, const QList & new_items); - - /** \brief This removes new_items from the model and restores originals */ - bool - restoreOriginalRemoveNew (const QList & originals, const QList & new_items); - - ConstItemList original_data_; - - QMap removed_to_parent_map_; - QList output_data_; - ProjectModel* project_model_; - - /** \brief This determines if we delete original items or not on destruction - * If the command is being deleted because stack is at limit, then we want - * to only delete the originals, since the command is staying for good (new items shouldn't be deleted) - * On the other hand, if we destruct after an undo, then we want to delete the new items (but not the originals) - */ - bool last_was_undo_; - - /** \brief This is used to check if a templated version of a tool can be used - * For this to return true, all items must be clouds, and must have the same template type - */ - bool - canUseTemplates (ConstItemList &input_data); - - bool can_use_templates_; - int template_type_; - }; - - class ModifyItemCommand : public CloudCommand - { - public: - ModifyItemCommand (ConstItemList input_data, QUndoCommand* parent = nullptr); - - bool - runCommand (AbstractTool* tool) override; - - void - undo () override; - - void - redo () override; - private: - - - - }; - - class NewItemCloudCommand : public CloudCommand - { - public: - NewItemCloudCommand (ConstItemList input_data, QUndoCommand* parent = nullptr); - - bool - runCommand (AbstractTool* tool) override; - - void - undo () override; - - void - redo () override; - - }; - - - class SplitCloudCommand : public CloudCommand - { - public: - SplitCloudCommand (ConstItemList input_data, QUndoCommand* parent = nullptr); - - bool - runCommand (AbstractTool* tool) override; - - void - undo () override; - - void - redo () override; - private: - - }; - - class DeleteItemCommand : public CloudCommand - { - public: - DeleteItemCommand (ConstItemList input_data, QUndoCommand* parent = nullptr); - - bool - runCommand (AbstractTool* tool) override; - - void - undo () override; - - void - redo () override; - private: - }; - - class MergeCloudCommand : public CloudCommand - { - public: - /** \brief Construct for a merge command - * \param[in] input_data Input list of CloudItem s from the project model which will be merged - * \param[in] temporary_clouds Input list of CloudItems which - */ - MergeCloudCommand (ConstItemList input_data, QUndoCommand* parent = nullptr); - - bool - runCommand (AbstractTool* tool) override; - - void - undo () override; - - void - redo () override; - - inline void - setSelectedIndicesMap( const QMap & selected_item_index_map) - { - selected_item_index_map_ = selected_item_index_map; - } - - private: - QMap selected_item_index_map_; - }; + selected_item_index_map_ = selected_item_index_map; } -} -Q_DECLARE_METATYPE (ConstItemList); +private: + QMap selected_item_index_map_; +}; +} // namespace cloud_composer +} // namespace pcl + +Q_DECLARE_METATYPE(ConstItemList); diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/cloud_item.hpp b/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/cloud_item.hpp index 6689967c065..6c78b82d46f 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/cloud_item.hpp +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/cloud_item.hpp @@ -1,4 +1,4 @@ - /* +/* * Software License Agreement (BSD License) * * Point Cloud Library (PCL) - www.pointclouds.org @@ -39,45 +39,48 @@ #define IMPL_CLOUD_ITEM_H_ #include -#include // for pcl::make_shared -#include #include +#include // for pcl::make_shared +#include -template void -pcl::cloud_composer::CloudItem::printNumPoints () const +template +void +pcl::cloud_composer::CloudItem::printNumPoints() const { - QVariant variant = this->data (ItemDataRole::CLOUD_TEMPLATED); + QVariant variant = this->data(ItemDataRole::CLOUD_TEMPLATED); typename PointCloud::Ptr cloud; - if ( variant.canConvert ::Ptr> () ) - { - cloud = variant.value ::Ptr> (); + if (variant.canConvert::Ptr>()) { + cloud = variant.value::Ptr>(); } - else - { - qWarning () << "Attempted to cast to template type which does not exist in this item!"; + else { + qWarning() + << "Attempted to cast to template type which does not exist in this item!"; return; } - qDebug () << "CLOUD HAS WIDTH = "<< cloud->width; - + qDebug() << "CLOUD HAS WIDTH = " << cloud->width; } - - -template pcl::cloud_composer::CloudItem* -pcl::cloud_composer::CloudItem::createCloudItemFromTemplate (const QString& name, typename PointCloud::Ptr cloud_ptr) +template +pcl::cloud_composer::CloudItem* +pcl::cloud_composer::CloudItem::createCloudItemFromTemplate( + const QString& name, typename PointCloud::Ptr cloud_ptr) { - pcl::PCLPointCloud2::Ptr cloud_blob = pcl::make_shared (); - toPCLPointCloud2 (*cloud_ptr, *cloud_blob); - CloudItem* cloud_item = new CloudItem ( name, cloud_blob, Eigen::Vector4f (), Eigen::Quaternionf (), false); - cloud_item->setData (QVariant::fromValue(cloud_ptr), ItemDataRole::CLOUD_TEMPLATED); - cloud_item->setPointType (); + pcl::PCLPointCloud2::Ptr cloud_blob = pcl::make_shared(); + toPCLPointCloud2(*cloud_ptr, *cloud_blob); + CloudItem* cloud_item = + new CloudItem(name, cloud_blob, Eigen::Vector4f(), Eigen::Quaternionf(), false); + cloud_item->setData(QVariant::fromValue(cloud_ptr), ItemDataRole::CLOUD_TEMPLATED); + cloud_item->setPointType(); return cloud_item; } +#define PCL_INSTANTIATE_createCloudItemFromTemplate(T) \ + template pcl::cloud_composer::CloudItem* \ + pcl::cloud_composer::CloudItem::createCloudItemFromTemplate( \ + const QString, typename PointCloud::Ptr); -#define PCL_INSTANTIATE_createCloudItemFromTemplate(T) template pcl::cloud_composer::CloudItem* pcl::cloud_composer::CloudItem::createCloudItemFromTemplate(const QString, typename PointCloud::Ptr); - -#define PCL_INSTANTIATE_printNumPoints(T) template void pcl::cloud_composer::CloudItem::getNumPoints(); +#define PCL_INSTANTIATE_printNumPoints(T) \ + template void pcl::cloud_composer::CloudItem::getNumPoints(); #endif diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/merge_selection.hpp b/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/merge_selection.hpp index 9574b738433..bb913d2581e 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/merge_selection.hpp +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/merge_selection.hpp @@ -1,4 +1,4 @@ - /* +/* * Software License Agreement (BSD License) * * Point Cloud Library (PCL) - www.pointclouds.org @@ -38,81 +38,85 @@ #ifndef IMPL_MERGE_SELECTION_H_ #define IMPL_MERGE_SELECTION_H_ +#include #include +#include #include -#include -template QList -pcl::cloud_composer::MergeSelection::performTemplatedAction (const QList & input_data) +template +QList +pcl::cloud_composer::MergeSelection::performTemplatedAction( + const QList& input_data) { - QList output; - - foreach (const CloudComposerItem* input_item, input_data) - { - QVariant variant = input_item->data (ItemDataRole::CLOUD_TEMPLATED); - if ( ! variant.canConvert ::Ptr> () ) - { - qWarning () << "Attempted to cast to template type which does not exist in this item! (input list)"; + QList output; + + foreach (const CloudComposerItem* input_item, input_data) { + QVariant variant = input_item->data(ItemDataRole::CLOUD_TEMPLATED); + if (!variant.canConvert::Ptr>()) { + qWarning() << "Attempted to cast to template type which does not exist in this " + "item! (input list)"; return output; } } - foreach (const CloudItem* input_item, selected_item_index_map_.keys ()) - { - QVariant variant = input_item->data (ItemDataRole::CLOUD_TEMPLATED); - if ( ! variant.canConvert ::Ptr> () ) - { - qWarning () << "Attempted to cast to template type which does not exist in this item! (selected list)"; + foreach (const CloudItem* input_item, selected_item_index_map_.keys()) { + QVariant variant = input_item->data(ItemDataRole::CLOUD_TEMPLATED); + if (!variant.canConvert::Ptr>()) { + qWarning() << "Attempted to cast to template type which does not exist in this " + "item! (selected list)"; return output; } - } + } pcl::ExtractIndices filter; - typename PointCloud::Ptr merged_cloud (new PointCloud); + typename PointCloud::Ptr merged_cloud(new PointCloud); + + foreach (const CloudItem* input_cloud_item, selected_item_index_map_.keys()) { + input_cloud_item->printNumPoints(); + // If this cloud hasn't been completely selected + if (!input_data.contains(input_cloud_item)) { + typename PointCloud::Ptr input_cloud = + input_cloud_item->data(ItemDataRole::CLOUD_TEMPLATED) + .value::Ptr>(); + qDebug() << "Extracting " + << selected_item_index_map_.value(input_cloud_item)->indices.size() + << " points out of " << input_cloud->width; + filter.setInputCloud(input_cloud); + filter.setIndices(selected_item_index_map_.value(input_cloud_item)); + typename PointCloud::Ptr original_minus_indices(new PointCloud); + filter.setNegative(true); + filter.filter(*original_minus_indices); + filter.setNegative(false); + typename PointCloud::Ptr selected_points(new PointCloud); + filter.filter(*selected_points); + + qDebug() << "Original minus indices is " << original_minus_indices->width; - foreach (const CloudItem* input_cloud_item, selected_item_index_map_.keys ()) - { - input_cloud_item->printNumPoints (); - //If this cloud hasn't been completely selected - if (!input_data.contains (input_cloud_item)) - { - typename PointCloud::Ptr input_cloud = input_cloud_item->data (ItemDataRole::CLOUD_TEMPLATED).value ::Ptr> (); - qDebug () << "Extracting "<indices.size() << " points out of "<width; - filter.setInputCloud (input_cloud); - filter.setIndices (selected_item_index_map_.value (input_cloud_item)); - typename PointCloud::Ptr original_minus_indices (new PointCloud); - filter.setNegative (true); - filter.filter (*original_minus_indices); - filter.setNegative (false); - typename PointCloud::Ptr selected_points (new PointCloud); - filter.filter (*selected_points); - - qDebug () << "Original minus indices is "<width; - - CloudItem* new_cloud_item = CloudItem::createCloudItemFromTemplate(input_cloud_item->text (),original_minus_indices); - - output.append (new_cloud_item); + CloudItem* new_cloud_item = CloudItem::createCloudItemFromTemplate( + input_cloud_item->text(), original_minus_indices); + + output.append(new_cloud_item); *merged_cloud += *selected_points; } - //Append the input item to the original list - //input_data.append (input_cloud_item); + // Append the input item to the original list + // input_data.append (input_cloud_item); } - //Just concatenate for all fully selected clouds - foreach (const CloudComposerItem* input_item, input_data) - { - typename PointCloud::Ptr input_cloud = input_item->data (ItemDataRole::CLOUD_TEMPLATED).value ::Ptr> (); + // Just concatenate for all fully selected clouds + foreach (const CloudComposerItem* input_item, input_data) { + typename PointCloud::Ptr input_cloud = + input_item->data(ItemDataRole::CLOUD_TEMPLATED) + .value::Ptr>(); *merged_cloud += *input_cloud; } - CloudItem* cloud_item = CloudItem::createCloudItemFromTemplate("Cloud from Selection",merged_cloud); - - output.append (cloud_item); - - return output; - -} + CloudItem* cloud_item = CloudItem::createCloudItemFromTemplate( + "Cloud from Selection", merged_cloud); + output.append(cloud_item); -#define PCL_INSTANTIATE_performTemplatedAction(T) template void pcl::cloud_composer::MergeSelection::performTemplatedAction (QList ); - + return output; +} +#define PCL_INSTANTIATE_performTemplatedAction(T) \ + template void pcl::cloud_composer::MergeSelection::performTemplatedAction( \ + QList); -#endif //IMPL_MERGE_SELECTION_H_ +#endif // IMPL_MERGE_SELECTION_H_ diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/transform_clouds.hpp b/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/transform_clouds.hpp index 92574aec769..5fce284b5ab 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/transform_clouds.hpp +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/transform_clouds.hpp @@ -1,4 +1,4 @@ - /* +/* * Software License Agreement (BSD License) * * Point Cloud Library (PCL) - www.pointclouds.org @@ -38,61 +38,61 @@ #ifndef IMPL_TRANSFORM_CLOUDS_HPP_ #define IMPL_TRANSFORM_CLOUDS_HPP_ -#include #include -#include +#include #include +#include -template QList -pcl::cloud_composer::TransformClouds::performTemplatedAction (const QList & input_data) +template +QList +pcl::cloud_composer::TransformClouds::performTemplatedAction( + const QList& input_data) { - QList output; - - foreach (const CloudComposerItem* input_item, input_data) - { - QVariant variant = input_item->data (ItemDataRole::CLOUD_TEMPLATED); - if ( ! variant.canConvert ::Ptr> () ) - { - qWarning () << "Attempted to cast to template type which does not exist in this item! (input list)"; + QList output; + + foreach (const CloudComposerItem* input_item, input_data) { + QVariant variant = input_item->data(ItemDataRole::CLOUD_TEMPLATED); + if (!variant.canConvert::Ptr>()) { + qWarning() << "Attempted to cast to template type which does not exist in this " + "item! (input list)"; return output; } - if (!transform_map_.contains ("AllSelectedClouds") && !transform_map_.contains (input_item->getId ())) - { - qCritical () << "No transform found for id "<getId ()<<" in TransformClouds::performTemplatedAction"; + if (!transform_map_.contains("AllSelectedClouds") && + !transform_map_.contains(input_item->getId())) { + qCritical() << "No transform found for id " << input_item->getId() + << " in TransformClouds::performTemplatedAction"; return output; } } - - foreach (const CloudComposerItem* input_item, input_data) - { - qDebug () << "Transforming cloud "<getId (); - QVariant variant = input_item->data (ItemDataRole::CLOUD_TEMPLATED); - typename PointCloud ::Ptr input_cloud = variant.value ::Ptr> (); - + + foreach (const CloudComposerItem* input_item, input_data) { + qDebug() << "Transforming cloud " << input_item->getId(); + QVariant variant = input_item->data(ItemDataRole::CLOUD_TEMPLATED); + typename PointCloud::Ptr input_cloud = + variant.value::Ptr>(); + Eigen::Matrix4f transform; - if (transform_map_.contains ("AllSelectedClouds")) - pcl::visualization::PCLVisualizer::convertToEigenMatrix (transform_map_.value ("AllSelectedClouds"), transform); + if (transform_map_.contains("AllSelectedClouds")) + pcl::visualization::PCLVisualizer::convertToEigenMatrix( + transform_map_.value("AllSelectedClouds"), transform); else - pcl::visualization::PCLVisualizer::convertToEigenMatrix (transform_map_.value (input_item->getId ()), transform); - - typename PointCloud::Ptr transformed_cloud (new PointCloud); - - transformPointCloud (*input_cloud, *transformed_cloud, transform); - CloudItem* new_cloud_item = CloudItem::createCloudItemFromTemplate(input_item->text (),transformed_cloud); - - output.append (new_cloud_item); - } + pcl::visualization::PCLVisualizer::convertToEigenMatrix( + transform_map_.value(input_item->getId()), transform); + + typename PointCloud::Ptr transformed_cloud(new PointCloud); - + transformPointCloud(*input_cloud, *transformed_cloud, transform); + CloudItem* new_cloud_item = CloudItem::createCloudItemFromTemplate( + input_item->text(), transformed_cloud); + output.append(new_cloud_item); + } return output; - } +#define PCL_INSTANTIATE_performTemplatedAction(T) \ + template void pcl::cloud_composer::TransformClouds::performTemplatedAction( \ + QList); -#define PCL_INSTANTIATE_performTemplatedAction(T) template void pcl::cloud_composer::TransformClouds::performTemplatedAction (QList ); - - - -#endif //IMPL_TRANSFORM_CLOUDS_HPP_ +#endif // IMPL_TRANSFORM_CLOUDS_HPP_ diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/item_inspector.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/item_inspector.h index dcf7f78cc42..f03ab1e812b 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/item_inspector.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/item_inspector.h @@ -37,65 +37,58 @@ #pragma once -#include - #include #include +#include + class QItemSelectionModel; class QTreeView; -namespace pcl -{ - namespace cloud_composer - { - /** \brief View class for displaying properties of an item - * \author Jeremie Papon - * \ingroup cloud_composer - */ - class ItemInspector : public QTabWidget - { - Q_OBJECT - public: - ItemInspector (QWidget* parent = nullptr); - - public Q_SLOTS: - void - setModel (ProjectModel* new_model); - void - selectionChanged (const QModelIndex ¤t, const QModelIndex &previous); - void - itemChanged (QStandardItem* item); - - - - private: - void - createItemWidgets (); - /** \brief Stores the state of the current tree view in item_treestate_map_ */ - void - storeTreeState (); - /** \brief Restores the state of \param model 's view from item_treestate_map_ */ - void - restoreTreeState (); - /** \brief Removes the extra tabs the item might have */ - void - removeTabs (); - /** \brief Refreshes the data shown in the current displayed view widget */ - void - updateView (); - - //! The tree object used to display/edit parameters - QTreeView* parameter_view_; - - - ProjectModel* current_project_model_; - PropertiesModel* current_item_properties_model_; - const QItemSelectionModel *current_selection_model_; - QMap itemtype_widget_map; - QMap > item_treestate_map_; - }; - - - } -} +namespace pcl { +namespace cloud_composer { +/** \brief View class for displaying properties of an item + * \author Jeremie Papon + * \ingroup cloud_composer + */ +class ItemInspector : public QTabWidget { + Q_OBJECT +public: + ItemInspector(QWidget* parent = nullptr); + +public Q_SLOTS: + void + setModel(ProjectModel* new_model); + void + selectionChanged(const QModelIndex& current, const QModelIndex& previous); + void + itemChanged(QStandardItem* item); + +private: + void + createItemWidgets(); + /** \brief Stores the state of the current tree view in item_treestate_map_ */ + void + storeTreeState(); + /** \brief Restores the state of \param model 's view from item_treestate_map_ */ + void + restoreTreeState(); + /** \brief Removes the extra tabs the item might have */ + void + removeTabs(); + /** \brief Refreshes the data shown in the current displayed view widget */ + void + updateView(); + + //! The tree object used to display/edit parameters + QTreeView* parameter_view_; + + ProjectModel* current_project_model_; + PropertiesModel* current_item_properties_model_; + const QItemSelectionModel* current_selection_model_; + QMap itemtype_widget_map; + QMap> item_treestate_map_; +}; + +} // namespace cloud_composer +} // namespace pcl diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/items/cloud_composer_item.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/items/cloud_composer_item.h index 07f9bc10355..422f8e3d512 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/items/cloud_composer_item.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/items/cloud_composer_item.h @@ -37,128 +37,133 @@ #pragma once -#include -#include #include +#include +#include + +static QStringList ITEM_TYPES_STRINGS(QStringList() << "Cloud Composer Item" + << "Cloud Item" + << "Normals Item" + << "FPFH Item"); -static QStringList ITEM_TYPES_STRINGS(QStringList() - << "Cloud Composer Item" - << "Cloud Item" - << "Normals Item" - << "FPFH Item" - ); +namespace pcl { +namespace cloud_composer { +class PropertiesModel; +namespace ItemDataRole { +enum { + PROPERTIES = Qt::UserRole, + ITEM_ID, + CLOUD_BLOB, + CLOUD_TEMPLATED, + GEOMETRY_HANDLER, + COLOR_HANDLER, + ORIGIN, + ORIENTATION, + KD_TREE_SEARCH +}; +}; +class CloudComposerItem : public QStandardItem { +public: + enum ItemType { + CLOUD_COMPOSER_ITEM = QStandardItem::UserType, + CLOUD_ITEM, + NORMALS_ITEM, + FPFH_ITEM + }; + + CloudComposerItem(const QString& name = "default item"); + CloudComposerItem(const CloudComposerItem& to_copy); + ~CloudComposerItem(); + + inline int + type() const override + { + return CLOUD_COMPOSER_ITEM; + } -namespace pcl -{ - namespace cloud_composer + /** \brief Convenience function to get Item's ID String */ + inline QString + getId() const { - class PropertiesModel; - namespace ItemDataRole - { - enum - { - PROPERTIES = Qt::UserRole, - ITEM_ID, - CLOUD_BLOB, - CLOUD_TEMPLATED, - GEOMETRY_HANDLER, - COLOR_HANDLER, - ORIGIN, - ORIENTATION, - KD_TREE_SEARCH - }; - }; - class CloudComposerItem : public QStandardItem - { - public: - - - enum ItemType - { - CLOUD_COMPOSER_ITEM = QStandardItem::UserType, - CLOUD_ITEM, - NORMALS_ITEM, - FPFH_ITEM - }; - - CloudComposerItem (const QString& name = "default item"); - CloudComposerItem (const CloudComposerItem& to_copy); - ~CloudComposerItem (); - - inline int - type () const override { return CLOUD_COMPOSER_ITEM; } - - /** \brief Convenience function to get Item's ID String */ - inline QString - getId () const { return data (ItemDataRole::ITEM_ID).toString (); } - - /** \brief Convenience function to get Item's Property Pointer */ - inline PropertiesModel* - getPropertiesModel () const { return properties_; } - - /** \brief Returns all children of item type type*/ - QList - getChildren (ItemType type) const; - - void - addChild (CloudComposerItem* item_arg); - - CloudComposerItem* - clone () const override; - - // /** \brief Convenience function which pulls out a cloud Ptr of type CloudPtrT */ - // template - // CloudPtrT - // getCloudPtr () const; - - /** \brief Paint View function - reimplement in item subclass if it can be displayed in PCLVisualizer*/ - virtual void - paintView (pcl::visualization::PCLVisualizer::Ptr vis) const; - - /** \brief Remove from View function - reimplement in item subclass if it can be displayed in PCLVisualizer*/ - virtual void - removeFromView (pcl::visualization::PCLVisualizer::Ptr vis) const; - - /** \brief Inspector additional tabs paint function - reimplement in item subclass if item has additional tabs to show in Inspector*/ - virtual QMap - getInspectorTabs (); - - /** \brief The property model calls this when a property changes */ - inline void - propertyChanged () - { - emitDataChanged (); - } - - virtual bool - isSanitized () const { return false; } - protected: - - /** \brief Model for storing the properties of the item - pointer kept for convenience */ - PropertiesModel* properties_; - - }; - - - - /** \brief Templated helper class for converting QVariant to/from pointer classes */ - template class VPtr - { - public: - static T* asPtr (const QVariant& v) - { - return (static_cast (v.value ())); - } - - static QVariant asQVariant (T* ptr) - { - return (QVariant::fromValue (static_cast(ptr))); - } - }; - + return data(ItemDataRole::ITEM_ID).toString(); } -} -using ConstItemList = QList; + /** \brief Convenience function to get Item's Property Pointer */ + inline PropertiesModel* + getPropertiesModel() const + { + return properties_; + } + + /** \brief Returns all children of item type type*/ + QList + getChildren(ItemType type) const; + + void + addChild(CloudComposerItem* item_arg); + + CloudComposerItem* + clone() const override; + + // /** \brief Convenience function which pulls out a cloud Ptr of type CloudPtrT */ + // template + // CloudPtrT + // getCloudPtr () const; + + /** \brief Paint View function - reimplement in item subclass if it can be displayed + * in PCLVisualizer*/ + virtual void + paintView(pcl::visualization::PCLVisualizer::Ptr vis) const; + + /** \brief Remove from View function - reimplement in item subclass if it can be + * displayed in PCLVisualizer*/ + virtual void + removeFromView(pcl::visualization::PCLVisualizer::Ptr vis) const; + + /** \brief Inspector additional tabs paint function - reimplement in item subclass if + * item has additional tabs to show in Inspector*/ + virtual QMap + getInspectorTabs(); + + /** \brief The property model calls this when a property changes */ + inline void + propertyChanged() + { + emitDataChanged(); + } + + virtual bool + isSanitized() const + { + return false; + } + +protected: + /** \brief Model for storing the properties of the item - pointer kept for convenience + */ + PropertiesModel* properties_; +}; + +/** \brief Templated helper class for converting QVariant to/from pointer classes */ +template +class VPtr { +public: + static T* + asPtr(const QVariant& v) + { + return (static_cast(v.value())); + } + + static QVariant + asQVariant(T* ptr) + { + return (QVariant::fromValue(static_cast(ptr))); + } +}; + +} // namespace cloud_composer +} // namespace pcl + +using ConstItemList = QList; -Q_DECLARE_METATYPE (pcl::cloud_composer::CloudComposerItem); +Q_DECLARE_METATYPE(pcl::cloud_composer::CloudComposerItem); diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/items/cloud_item.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/items/cloud_item.h index aabf5aab381..8e4a6a4b2f5 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/items/cloud_item.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/items/cloud_item.h @@ -37,162 +37,171 @@ #pragma once -#include - #include - -#include -#include -#include -#include -#include #include -#include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include -//Typedefs to make things sane -using GeometryHandler = pcl::visualization::PointCloudGeometryHandler; +// Typedefs to make things sane +using GeometryHandler = + pcl::visualization::PointCloudGeometryHandler; using ColorHandler = pcl::visualization::PointCloudColorHandler; -namespace pcl -{ - namespace cloud_composer +namespace pcl { +namespace cloud_composer { +namespace PointTypeFlags { +enum PointType { + NONE = 0, + XYZ = (1 << 0), + RGB = (1 << 1), + RGBA = (1 << 2), + NORMAL = (1 << 3), + HSV = (1 << 4), + AXIS = (1 << 5), +}; +} +class CloudItem : public CloudComposerItem { +public: + // This is needed because we have members which are Vector4f and Quaternionf + PCL_MAKE_ALIGNED_OPERATOR_NEW + + CloudItem(const QString name, + const pcl::PCLPointCloud2::Ptr& cloud_ptr, + const Eigen::Vector4f& origin = Eigen::Vector4f(), + const Eigen::Quaternionf& orientation = Eigen::Quaternionf(), + bool make_templated_cloud = true); + + CloudItem(const CloudItem& to_copy); + + /** \brief This creates a CloudItem from a templated cloud type */ + template + static CloudItem* + createCloudItemFromTemplate(const QString& name, + typename PointCloud::Ptr cloud_ptr); + + /** \brief virtual data getter which calls QStandardItem::data; used to create + * template cloud if not created yet WARNING : This function modifies "this" - it sets + * up the templated type if you request one when it doesn't exist yet! It had to + * remain const because it is virtual, and we need to keep run-time polymorphism + */ + QVariant + data(int role = Qt::UserRole + 1) const override; + + /** \brief Virtual data setter which calls QStandardItem::data; used to ensure that + * template_cloud_set_ is set when a templated cloud is added */ + void + setData(const QVariant& value, int role = Qt::UserRole + 1) override; + + inline int + type() const override { - namespace PointTypeFlags - { - enum PointType - { - NONE = 0, - XYZ = (1 << 0), - RGB = (1 << 1), - RGBA = (1 << 2), - NORMAL = (1 << 3), - HSV = (1 << 4), - AXIS = (1 << 5), - }; - } - class CloudItem : public CloudComposerItem - { - public: - - //This is needed because we have members which are Vector4f and Quaternionf - PCL_MAKE_ALIGNED_OPERATOR_NEW - - CloudItem (const QString name, - const pcl::PCLPointCloud2::Ptr& cloud_ptr, - const Eigen::Vector4f& origin = Eigen::Vector4f (), - const Eigen::Quaternionf& orientation = Eigen::Quaternionf (), - bool make_templated_cloud = true); - - CloudItem (const CloudItem& to_copy); - - /** \brief This creates a CloudItem from a templated cloud type */ - template - static CloudItem* - createCloudItemFromTemplate (const QString& name, typename PointCloud::Ptr cloud_ptr); - - /** \brief virtual data getter which calls QStandardItem::data; used to create template cloud if not created yet - * WARNING : This function modifies "this" - it sets up the templated type if you request one when it doesn't exist yet! - * It had to remain const because it is virtual, and we need to keep run-time polymorphism - */ - QVariant - data (int role = Qt::UserRole +1) const override; - - /** \brief Virtual data setter which calls QStandardItem::data; used to ensure that template_cloud_set_ is set - * when a templated cloud is added */ - void - setData ( const QVariant & value, int role = Qt::UserRole + 1 ) override; - - inline int - type () const override { return CLOUD_ITEM; } - - CloudItem* - clone () const override; - - /** \brief Paint View function - puts this cloud item into a PCLVisualizer object*/ - void - paintView (pcl::visualization::PCLVisualizer::Ptr vis) const override; - - /** \brief Remove from View function - removes this cloud from a PCLVisualizer object*/ - void - removeFromView (pcl::visualization::PCLVisualizer::Ptr vis) const override; - - /** \brief Initializes and stores a templated PointCloud object with point type matching the blob */ - void - setTemplateCloudFromBlob (); - - int - getPointType () const { return point_type_; } - - template void - printNumPoints () const; - - bool - isSanitized () const override { return is_sanitized_; } - private: - - //These are just stored for convenience - pcl::PCLPointCloud2::Ptr cloud_blob_ptr_; - ColorHandler::ConstPtr color_handler_; - GeometryHandler::ConstPtr geometry_handler_; - - //We keep actual local copies of these. - Eigen::Vector4f origin_; - Eigen::Quaternionf orientation_; - - bool template_cloud_set_; - - //Internal Storage of the templated type of this cloud - int point_type_; - - bool - checkIfFinite (); - - bool is_sanitized_; - - //Helper functions which set the point_type_ based on the current point type - template inline void - setPointType () - { - qCritical () << "CloudItem::setPointType for type with no specialization"; - point_type_ = PointTypeFlags::NONE; - } - - }; - - template <> inline void - CloudItem::setPointType () - { - point_type_ = PointTypeFlags::XYZ; - } - template <> inline void - CloudItem::setPointType () - { - point_type_ = PointTypeFlags::XYZ | PointTypeFlags::RGB; - } - template <> inline void - CloudItem::setPointType () - { - point_type_ = PointTypeFlags::XYZ | PointTypeFlags::RGBA; - } - - + return CLOUD_ITEM; } + + CloudItem* + clone() const override; + + /** \brief Paint View function - puts this cloud item into a PCLVisualizer object*/ + void + paintView(pcl::visualization::PCLVisualizer::Ptr vis) const override; + + /** \brief Remove from View function - removes this cloud from a PCLVisualizer + * object*/ + void + removeFromView(pcl::visualization::PCLVisualizer::Ptr vis) const override; + + /** \brief Initializes and stores a templated PointCloud object with point type + * matching the blob */ + void + setTemplateCloudFromBlob(); + + int + getPointType() const + { + return point_type_; + } + + template + void + printNumPoints() const; + + bool + isSanitized() const override + { + return is_sanitized_; + } + +private: + // These are just stored for convenience + pcl::PCLPointCloud2::Ptr cloud_blob_ptr_; + ColorHandler::ConstPtr color_handler_; + GeometryHandler::ConstPtr geometry_handler_; + + // We keep actual local copies of these. + Eigen::Vector4f origin_; + Eigen::Quaternionf orientation_; + + bool template_cloud_set_; + + // Internal Storage of the templated type of this cloud + int point_type_; + + bool + checkIfFinite(); + + bool is_sanitized_; + + // Helper functions which set the point_type_ based on the current point type + template + inline void + setPointType() + { + qCritical() << "CloudItem::setPointType for type with no specialization"; + point_type_ = PointTypeFlags::NONE; + } +}; + +template <> +inline void +CloudItem::setPointType() +{ + point_type_ = PointTypeFlags::XYZ; +} +template <> +inline void +CloudItem::setPointType() +{ + point_type_ = PointTypeFlags::XYZ | PointTypeFlags::RGB; } +template <> +inline void +CloudItem::setPointType() +{ + point_type_ = PointTypeFlags::XYZ | PointTypeFlags::RGBA; +} + +} // namespace cloud_composer +} // namespace pcl -//Add PointCloud types to QT MetaType System -Q_DECLARE_METATYPE (pcl::PCLPointCloud2::ConstPtr); -Q_DECLARE_METATYPE (GeometryHandler::ConstPtr); -Q_DECLARE_METATYPE (ColorHandler::ConstPtr); -Q_DECLARE_METATYPE (Eigen::Vector4f); -Q_DECLARE_METATYPE (Eigen::Quaternionf); +// Add PointCloud types to QT MetaType System +Q_DECLARE_METATYPE(pcl::PCLPointCloud2::ConstPtr); +Q_DECLARE_METATYPE(GeometryHandler::ConstPtr); +Q_DECLARE_METATYPE(ColorHandler::ConstPtr); +Q_DECLARE_METATYPE(Eigen::Vector4f); +Q_DECLARE_METATYPE(Eigen::Quaternionf); -Q_DECLARE_METATYPE (pcl::search::KdTree::Ptr); -Q_DECLARE_METATYPE (pcl::search::KdTree::Ptr); -Q_DECLARE_METATYPE (pcl::search::KdTree::Ptr); +Q_DECLARE_METATYPE(pcl::search::KdTree::Ptr); +Q_DECLARE_METATYPE(pcl::search::KdTree::Ptr); +Q_DECLARE_METATYPE(pcl::search::KdTree::Ptr); -Q_DECLARE_METATYPE (pcl::PointCloud ::Ptr); -Q_DECLARE_METATYPE (pcl::PointCloud ::Ptr); -Q_DECLARE_METATYPE (pcl::PointCloud ::Ptr); +Q_DECLARE_METATYPE(pcl::PointCloud::Ptr); +Q_DECLARE_METATYPE(pcl::PointCloud::Ptr); +Q_DECLARE_METATYPE(pcl::PointCloud::Ptr); diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/items/fpfh_item.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/items/fpfh_item.h index 5a634272a8a..e1241504fa1 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/items/fpfh_item.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/items/fpfh_item.h @@ -37,47 +37,45 @@ #pragma once -#include -#include - #include -#include +#include #include +#include +#include + +namespace pcl { +namespace cloud_composer { + +class FPFHItem : public CloudComposerItem { +public: + FPFHItem(QString name, + const pcl::PointCloud::Ptr& fpfh_ptr, + double radius); + FPFHItem(const FPFHItem& to_copy); -namespace pcl -{ - namespace cloud_composer + inline int + type() const override { - - class FPFHItem : public CloudComposerItem - { - public: + return FPFH_ITEM; + } - FPFHItem (QString name, - const pcl::PointCloud::Ptr& fpfh_ptr, - double radius); - FPFHItem (const FPFHItem& to_copy); - - inline int - type () const override { return FPFH_ITEM; } + FPFHItem* + clone() const override; - FPFHItem* - clone () const override; - - /** \brief Inspector additional tabs paint function - get the histogram plot widget*/ - QMap - getInspectorTabs () override; - - private: - pcl::PointCloud::Ptr fpfh_ptr_; - double radius_; - pcl::visualization::PCLPlotter::Ptr plot_; - PCLQVTKWidget* qvtk_; - QWidget *hist_page_; - }; + /** \brief Inspector additional tabs paint function - get the histogram plot widget*/ + QMap + getInspectorTabs() override; - } -} +private: + pcl::PointCloud::Ptr fpfh_ptr_; + double radius_; + pcl::visualization::PCLPlotter::Ptr plot_; + PCLQVTKWidget* qvtk_; + QWidget* hist_page_; +}; + +} // namespace cloud_composer +} // namespace pcl -Q_DECLARE_METATYPE (pcl::PointCloud::Ptr); -Q_DECLARE_METATYPE (pcl::PointCloud::ConstPtr); +Q_DECLARE_METATYPE(pcl::PointCloud::Ptr); +Q_DECLARE_METATYPE(pcl::PointCloud::ConstPtr); diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/items/normals_item.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/items/normals_item.h index 73c687bd298..40fb5c3cfdc 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/items/normals_item.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/items/normals_item.h @@ -37,47 +37,43 @@ #pragma once -#include +#include #include +#include -#include +namespace pcl { +namespace cloud_composer { + +class NormalsItem : public CloudComposerItem { +public: + NormalsItem(QString name, + const pcl::PointCloud::Ptr& normals_ptr, + double radius); + NormalsItem(const NormalsItem& to_copy); -namespace pcl -{ - namespace cloud_composer + inline int + type() const override { - - class NormalsItem : public CloudComposerItem - { - public: + return NORMALS_ITEM; + } - NormalsItem (QString name, - const pcl::PointCloud::Ptr& normals_ptr, - double radius); - NormalsItem (const NormalsItem& to_copy); - - inline int - type () const override { return NORMALS_ITEM; } + NormalsItem* + clone() const override; - NormalsItem* - clone () const override; - - void - paintView (pcl::visualization::PCLVisualizer::Ptr vis) const override; - - /** \brief Remove from View function - removes the normal cloud from a PCLVisualizer object*/ - void - removeFromView (pcl::visualization::PCLVisualizer::Ptr vis) const override; - - private: - pcl::PointCloud::Ptr normals_ptr_; + void + paintView(pcl::visualization::PCLVisualizer::Ptr vis) const override; - }; - - - - } -} + /** \brief Remove from View function - removes the normal cloud from a PCLVisualizer + * object*/ + void + removeFromView(pcl::visualization::PCLVisualizer::Ptr vis) const override; + +private: + pcl::PointCloud::Ptr normals_ptr_; +}; + +} // namespace cloud_composer +} // namespace pcl -Q_DECLARE_METATYPE (pcl::PointCloud::Ptr); -Q_DECLARE_METATYPE (pcl::PointCloud::ConstPtr); +Q_DECLARE_METATYPE(pcl::PointCloud::Ptr); +Q_DECLARE_METATYPE(pcl::PointCloud::ConstPtr); diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/merge_selection.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/merge_selection.h index af3d7afa95f..0e4181c3bcd 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/merge_selection.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/merge_selection.h @@ -39,31 +39,38 @@ #include -namespace pcl -{ - namespace cloud_composer +namespace pcl { +namespace cloud_composer { +class MergeSelection : public MergeCloudTool { + Q_OBJECT +public: + MergeSelection( + QMap selected_item_index_map, + QObject* parent = nullptr); + + QList + performAction(QList input_data, + PointTypeFlags::PointType type = PointTypeFlags::NONE) override; + + inline QString + getToolName() const override { - class MergeSelection : public MergeCloudTool - { - Q_OBJECT - public: - MergeSelection (QMap selected_item_index_map, QObject* parent = nullptr); - - QList - performAction (QList input_data, PointTypeFlags::PointType type = PointTypeFlags::NONE) override; - - inline QString - getToolName () const override { return "Merge Selection Tool";} - - QList - getSelectedItems () { return selected_item_index_map_.keys ();} - - template QList - performTemplatedAction (const QList & input_data); - - private: - QMap selected_item_index_map_; - }; + return "Merge Selection Tool"; + } + QList + getSelectedItems() + { + return selected_item_index_map_.keys(); } -} + + template + QList + performTemplatedAction(const QList& input_data); + +private: + QMap selected_item_index_map_; +}; + +} // namespace cloud_composer +} // namespace pcl diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/click_trackball_interactor_style.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/click_trackball_interactor_style.h index 2477b33b525..7bb9d3fac7c 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/click_trackball_interactor_style.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/click_trackball_interactor_style.h @@ -41,73 +41,83 @@ #include -namespace pcl -{ - namespace cloud_composer +namespace pcl { +namespace cloud_composer { + +class ClickTrackballStyleInteractor : public vtkInteractorStyleTrackballActor { +public: + static ClickTrackballStyleInteractor* + New(); + vtkTypeMacro(ClickTrackballStyleInteractor, vtkInteractorStyleTrackballActor); + + ClickTrackballStyleInteractor(); + + /** \brief Pass a pointer to the actor map + * \param[in] actors the actor map that will be used with this style + */ + inline void + setCloudActorMap(const pcl::visualization::CloudActorMapPtr& actors) + { + actors_ = actors; + } + + /** \brief Get the cloud actor map pointer. */ + inline pcl::visualization::CloudActorMapPtr + getCloudActorMap() const + { + return (actors_); + } + + /** \brief Pass a set of renderers to the interactor style. + * \param[in] rens the vtkRendererCollection to use + */ + void + setRendererCollection(vtkSmartPointer& rens) + { + renderers_ = rens; + } + + /** \brief Function called on left mouse button release, ie, end of rectangular drag + */ + void + OnLeftButtonDown() override; + + /** \brief Function called on left mouse button release, ie, end of rectangular drag + */ + void + OnLeftButtonUp() override; + + void + OnRightButtonDown() override; + + void + OnRightButtonUp() override; + + /** \brief Event emitted once a valid selection has been made */ + int manipulation_complete_event_; + + inline void + setProjectModel(ProjectModel* model) { - - class ClickTrackballStyleInteractor : public vtkInteractorStyleTrackballActor - { - public: - static ClickTrackballStyleInteractor* New(); - vtkTypeMacro(ClickTrackballStyleInteractor,vtkInteractorStyleTrackballActor); - - ClickTrackballStyleInteractor (); - - /** \brief Pass a pointer to the actor map - * \param[in] actors the actor map that will be used with this style - */ - inline void - setCloudActorMap (const pcl::visualization::CloudActorMapPtr &actors) { actors_ = actors; } - - /** \brief Get the cloud actor map pointer. */ - inline pcl::visualization::CloudActorMapPtr - getCloudActorMap () const { return (actors_); } - - /** \brief Pass a set of renderers to the interactor style. - * \param[in] rens the vtkRendererCollection to use - */ - void - setRendererCollection (vtkSmartPointer &rens) { renderers_ = rens; } - - /** \brief Function called on left mouse button release, ie, end of rectangular drag */ - void - OnLeftButtonDown () override; - - /** \brief Function called on left mouse button release, ie, end of rectangular drag */ - void - OnLeftButtonUp () override; - - void - OnRightButtonDown () override; - - void - OnRightButtonUp () override; - - /** \brief Event emitted once a valid selection has been made */ - int manipulation_complete_event_; - - inline void - setProjectModel (ProjectModel* model) { model_ = model; } - private: - - - /** \brief Actor map stored internally. */ - pcl::visualization::CloudActorMapPtr actors_; - - /** \brief Collection of vtkRenderers stored internally. */ - vtkSmartPointer renderers_; - - /** \brief Internal Pointer to Project Model */ - ProjectModel* model_; - - vtkSmartPointer start_matrix_; - vtkSmartPointer end_matrix_; - - vtkSmartPointer transform_; - - }; - + model_ = model; } - -} + +private: + /** \brief Actor map stored internally. */ + pcl::visualization::CloudActorMapPtr actors_; + + /** \brief Collection of vtkRenderers stored internally. */ + vtkSmartPointer renderers_; + + /** \brief Internal Pointer to Project Model */ + ProjectModel* model_; + + vtkSmartPointer start_matrix_; + vtkSmartPointer end_matrix_; + + vtkSmartPointer transform_; +}; + +} // namespace cloud_composer + +} // namespace pcl diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/interactor_style_switch.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/interactor_style_switch.h index 1f4fcd17544..f7905862197 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/interactor_style_switch.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/interactor_style_switch.h @@ -37,118 +37,122 @@ #pragma once -#include - -#include #include #include +#include #include -#include +#include + #include -#include -#include #include -#include #include +#include +#include +#include +#include class QVTKWidget; -namespace pcl -{ - namespace cloud_composer +namespace pcl { +namespace cloud_composer { +namespace interactor_styles { +enum INTERACTOR_STYLES { + PCL_VISUALIZER = 0, + RECTANGULAR_FRUSTUM, + SELECTED_TRACKBALL, + CLICK_TRACKBALL +}; +} +namespace interactor_events { +enum { + SELECTION_COMPLETE_EVENT = vtkCommand::UserEvent + 1, + MANIPULATION_COMPLETE_EVENT +}; +}; + +class RectangularFrustumSelector; +class SelectedTrackballStyleInteractor; +class ClickTrackballStyleInteractor; +class ProjectModel; + +class InteractorStyleSwitch : public vtkInteractorStyle { +public: + static InteractorStyleSwitch* + New(); + vtkTypeMacro(InteractorStyleSwitch, vtkInteractorStyle); + + InteractorStyleSwitch(); + + void + SetInteractor(vtkRenderWindowInteractor* iren) override; + + vtkGetObjectMacro(current_style_, vtkInteractorStyle); + + void + initializeInteractorStyles(pcl::visualization::PCLVisualizer::Ptr vis, + ProjectModel* model); + + inline void + setQVTKWidget(QVTKWidget* qvtk) { - namespace interactor_styles - { - enum INTERACTOR_STYLES - { - PCL_VISUALIZER = 0, - RECTANGULAR_FRUSTUM, - SELECTED_TRACKBALL, - CLICK_TRACKBALL - }; - } - namespace interactor_events - { - enum - { - SELECTION_COMPLETE_EVENT = vtkCommand::UserEvent + 1, - MANIPULATION_COMPLETE_EVENT - }; - }; - - class RectangularFrustumSelector; - class SelectedTrackballStyleInteractor; - class ClickTrackballStyleInteractor; - class ProjectModel; - - class InteractorStyleSwitch : public vtkInteractorStyle - { - public: - static InteractorStyleSwitch *New(); - vtkTypeMacro(InteractorStyleSwitch, vtkInteractorStyle); - - InteractorStyleSwitch(); - - void - SetInteractor(vtkRenderWindowInteractor *iren) override; - - vtkGetObjectMacro(current_style_, vtkInteractorStyle); - - void - initializeInteractorStyles (pcl::visualization::PCLVisualizer::Ptr vis, ProjectModel* model); - - inline void - setQVTKWidget (QVTKWidget* qvtk) { qvtk_ = qvtk; } - - void - setCurrentInteractorStyle (interactor_styles::INTERACTOR_STYLES interactor_style); - - // vtkSmartPointer - // getPCLVisInteractorStyle () { return pcl_vis_style_; } - - inline vtkSmartPointer - getInteractorStyle (const interactor_styles::INTERACTOR_STYLES interactor_style) const - { return name_to_style_map_.value (interactor_style); } - - - void SetDefaultRenderer(vtkRenderer*) override; - - void SetCurrentRenderer(vtkRenderer*) override; - - void - OnLeave () override; - - protected: - void - setCurrentStyle(); - - QMap > name_to_style_map_; - - - vtkRenderWindowInteractor* render_window_interactor_; - vtkSmartPointer rens_; - - vtkInteractorStyle* current_style_; - vtkSmartPointer pcl_vis_style_; - vtkSmartPointer rectangular_frustum_selector_; - - vtkSmartPointer selected_trackball_interactor_style_; - - vtkSmartPointer click_trackball_interactor_style_; - vtkSmartPointer area_picker_; - vtkSmartPointer point_picker_; - - /** \brief Internal pointer to QVTKWidget that this Switch works with */ - QVTKWidget* qvtk_; - /** \brief Internal pointer to PCLVisualizer that this Switch works with */ - pcl::visualization::PCLVisualizer::Ptr vis_; - private: - InteractorStyleSwitch(const InteractorStyleSwitch&); // Not implemented. - void operator=(const InteractorStyleSwitch&); // Not implemented. - ProjectModel* project_model_; - }; - + qvtk_ = qvtk; } - -} + + void + setCurrentInteractorStyle(interactor_styles::INTERACTOR_STYLES interactor_style); + + // vtkSmartPointer + // getPCLVisInteractorStyle () { return pcl_vis_style_; } + + inline vtkSmartPointer + getInteractorStyle(const interactor_styles::INTERACTOR_STYLES interactor_style) const + { + return name_to_style_map_.value(interactor_style); + } + + void + SetDefaultRenderer(vtkRenderer*) override; + + void + SetCurrentRenderer(vtkRenderer*) override; + + void + OnLeave() override; + +protected: + void + setCurrentStyle(); + + QMap> + name_to_style_map_; + + vtkRenderWindowInteractor* render_window_interactor_; + vtkSmartPointer rens_; + + vtkInteractorStyle* current_style_; + vtkSmartPointer pcl_vis_style_; + vtkSmartPointer rectangular_frustum_selector_; + + vtkSmartPointer + selected_trackball_interactor_style_; + + vtkSmartPointer click_trackball_interactor_style_; + vtkSmartPointer area_picker_; + vtkSmartPointer point_picker_; + + /** \brief Internal pointer to QVTKWidget that this Switch works with */ + QVTKWidget* qvtk_; + /** \brief Internal pointer to PCLVisualizer that this Switch works with */ + pcl::visualization::PCLVisualizer::Ptr vis_; + +private: + InteractorStyleSwitch(const InteractorStyleSwitch&); // Not implemented. + void + operator=(const InteractorStyleSwitch&); // Not implemented. + ProjectModel* project_model_; +}; + +} // namespace cloud_composer + +} // namespace pcl diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/manipulation_event.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/manipulation_event.h index 73efe79c25d..af1f09e875a 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/manipulation_event.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/manipulation_event.h @@ -39,35 +39,36 @@ #include -namespace pcl -{ - namespace cloud_composer +namespace pcl { +namespace cloud_composer { + +class ManipulationEvent { + +public: + ManipulationEvent() {} + + void + addManipulation(const QString& id, + const vtkSmartPointer& start, + const vtkSmartPointer& end); + + inline QMap> + getStartMap() const + { + return id_start_map_; + } + + inline QMap> + getEndMap() const { - - - class ManipulationEvent - { - - public: - ManipulationEvent () - {} - - void - addManipulation (const QString& id, const vtkSmartPointer& start, const vtkSmartPointer& end); - - inline QMap > - getStartMap () const { return id_start_map_;} - - inline QMap > - getEndMap () const { return id_end_map_;} - - - private: - QMap > id_start_map_; - QMap > id_end_map_; - - }; - + return id_end_map_; } - -} + +private: + QMap> id_start_map_; + QMap> id_end_map_; +}; + +} // namespace cloud_composer + +} // namespace pcl diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/rectangular_frustum_selector.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/rectangular_frustum_selector.h index bed9b5d570a..6ad55d6eb95 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/rectangular_frustum_selector.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/rectangular_frustum_selector.h @@ -39,55 +39,62 @@ #include -#include -#include #include +#include +#include -namespace pcl -{ - namespace cloud_composer - { - - class RectangularFrustumSelector : public vtkInteractorStyleRubberBandPick - { - public: - static RectangularFrustumSelector* New(); - vtkTypeMacro(RectangularFrustumSelector,vtkInteractorStyleRubberBandPick); - - RectangularFrustumSelector (); - - /** \brief Pass a pointer to the actor map - * \param[in] actors the actor map that will be used with this style - */ - inline void - setCloudActorMap (const pcl::visualization::CloudActorMapPtr &actors) { actors_ = actors; } +namespace pcl { +namespace cloud_composer { - /** \brief Get the cloud actor map pointer. */ - inline pcl::visualization::CloudActorMapPtr - getCloudActorMap () const { return (actors_); } +class RectangularFrustumSelector : public vtkInteractorStyleRubberBandPick { +public: + static RectangularFrustumSelector* + New(); + vtkTypeMacro(RectangularFrustumSelector, vtkInteractorStyleRubberBandPick); - /** \brief Pass a set of renderers to the interactor style. - * \param[in] rens the vtkRendererCollection to use - */ - void - setRendererCollection (vtkSmartPointer &rens) { renderers_ = rens; } + RectangularFrustumSelector(); - /** \brief Function called on left mouse button release, ie, end of rectangular drag */ - void - OnLeftButtonUp () override; + /** \brief Pass a pointer to the actor map + * \param[in] actors the actor map that will be used with this style + */ + inline void + setCloudActorMap(const pcl::visualization::CloudActorMapPtr& actors) + { + actors_ = actors; + } - /** \brief Event emitted once a valid selection has been made */ - int selection_complete_event_; - private: + /** \brief Get the cloud actor map pointer. */ + inline pcl::visualization::CloudActorMapPtr + getCloudActorMap() const + { + return (actors_); + } - - /** \brief Actor map stored internally. */ - pcl::visualization::CloudActorMapPtr actors_; - - /** \brief Collection of vtkRenderers stored internally. */ - vtkSmartPointer renderers_; - }; - + /** \brief Pass a set of renderers to the interactor style. + * \param[in] rens the vtkRendererCollection to use + */ + void + setRendererCollection(vtkSmartPointer& rens) + { + renderers_ = rens; } - -} + + /** \brief Function called on left mouse button release, ie, end of rectangular drag + */ + void + OnLeftButtonUp() override; + + /** \brief Event emitted once a valid selection has been made */ + int selection_complete_event_; + +private: + /** \brief Actor map stored internally. */ + pcl::visualization::CloudActorMapPtr actors_; + + /** \brief Collection of vtkRenderers stored internally. */ + vtkSmartPointer renderers_; +}; + +} // namespace cloud_composer + +} // namespace pcl diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/selected_trackball_interactor_style.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/selected_trackball_interactor_style.h index 3a9a20b32bc..9133b19e2b5 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/selected_trackball_interactor_style.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/selected_trackball_interactor_style.h @@ -38,85 +38,94 @@ #include #include -#include #include +#include + +namespace pcl { +namespace cloud_composer { + +class SelectedTrackballStyleInteractor : public vtkInteractorStyleTrackballActor { +public: + static SelectedTrackballStyleInteractor* + New(); + vtkTypeMacro(SelectedTrackballStyleInteractor, vtkInteractorStyleTrackballActor); + + SelectedTrackballStyleInteractor(); + + /** \brief Pass a pointer to the actor map + * \param[in] actors the actor map that will be used with this style + */ + inline void + setCloudActorMap(const pcl::visualization::CloudActorMapPtr& actors) + { + actors_ = actors; + } + + /** \brief Get the cloud actor map pointer. */ + inline pcl::visualization::CloudActorMapPtr + getCloudActorMap() const + { + return (actors_); + } -namespace pcl -{ - namespace cloud_composer + /** \brief Pass a set of renderers to the interactor style. + * \param[in] rens the vtkRendererCollection to use + */ + void + setRendererCollection(vtkSmartPointer& rens) { - - class SelectedTrackballStyleInteractor : public vtkInteractorStyleTrackballActor - { - public: - static SelectedTrackballStyleInteractor* New(); - vtkTypeMacro(SelectedTrackballStyleInteractor,vtkInteractorStyleTrackballActor); - - SelectedTrackballStyleInteractor (); - - /** \brief Pass a pointer to the actor map - * \param[in] actors the actor map that will be used with this style - */ - inline void - setCloudActorMap (const pcl::visualization::CloudActorMapPtr &actors) { actors_ = actors; } - - /** \brief Get the cloud actor map pointer. */ - inline pcl::visualization::CloudActorMapPtr - getCloudActorMap () const { return (actors_); } - - /** \brief Pass a set of renderers to the interactor style. - * \param[in] rens the vtkRendererCollection to use - */ - void - setRendererCollection (vtkSmartPointer &rens) { renderers_ = rens; } - - /** \brief Function called on left mouse button click, ie, beginning of trackball */ - void - OnLeftButtonDown () override; - - void - OnRightButtonDown () override; - - /** \brief Function called on left mouse button release, ie, end of trackball*/ - void - OnLeftButtonUp () override; - - void - OnRightButtonUp () override; - - void - Rotate() override; - void - Spin() override; - void - Pan() override; - void - UniformScale() override; - - /** \brief Event emitted once a valid selection has been made */ - int manipulation_complete_event_; - - inline void - setProjectModel (ProjectModel* model) { model_ = model; } - private: - - void - setSelectedActors (); - - /** \brief Actor map stored internally. */ - pcl::visualization::CloudActorMapPtr actors_; - - /** \brief Collection of vtkRenderers stored internally. */ - vtkSmartPointer renderers_; - - /** \brief Internal Pointer to Project Model */ - ProjectModel* model_; - - QMap > start_matrix_map_; - QMap selected_actors_map_; - - }; - + renderers_ = rens; } - -} + + /** \brief Function called on left mouse button click, ie, beginning of trackball */ + void + OnLeftButtonDown() override; + + void + OnRightButtonDown() override; + + /** \brief Function called on left mouse button release, ie, end of trackball*/ + void + OnLeftButtonUp() override; + + void + OnRightButtonUp() override; + + void + Rotate() override; + void + Spin() override; + void + Pan() override; + void + UniformScale() override; + + /** \brief Event emitted once a valid selection has been made */ + int manipulation_complete_event_; + + inline void + setProjectModel(ProjectModel* model) + { + model_ = model; + } + +private: + void + setSelectedActors(); + + /** \brief Actor map stored internally. */ + pcl::visualization::CloudActorMapPtr actors_; + + /** \brief Collection of vtkRenderers stored internally. */ + vtkSmartPointer renderers_; + + /** \brief Internal Pointer to Project Model */ + ProjectModel* model_; + + QMap> start_matrix_map_; + QMap selected_actors_map_; +}; + +} // namespace cloud_composer + +} // namespace pcl diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/selection_event.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/selection_event.h index 0e40fcb5e24..e32d819afae 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/selection_event.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/selection_event.h @@ -39,57 +39,68 @@ #include -#include -#include #include #include +#include #include +#include + +namespace pcl { +namespace cloud_composer { +class RectangularFrustumSelector; + +class SelectionEvent { + +public: + SelectionEvent(vtkSmartPointer selected_points, + vtkSmartPointer selected_actor, + vtkSmartPointer selected_mapper, + QMap id_selected_map, + vtkRenderer* renderer) + : selected_points_(std::move(selected_points)) + , selected_actor_(std::move(selected_actor)) + , selected_mapper_(std::move(selected_mapper)) + , id_selected_data_map_(std::move(id_selected_map)) + , renderer_(renderer) + {} + + ~SelectionEvent(); + + inline vtkIdType + getNumPoints() const + { + return selected_points_->GetNumberOfPoints(); + } -namespace pcl -{ - namespace cloud_composer + vtkSmartPointer + getPolyData() const { - class RectangularFrustumSelector; - - class SelectionEvent - { - - public: - SelectionEvent (vtkSmartPointer selected_points, vtkSmartPointer selected_actor, vtkSmartPointer selected_mapper, QMap < QString, vtkPolyData* > id_selected_map, vtkRenderer* renderer) - : selected_points_ (std::move(selected_points)) - , selected_actor_ (std::move(selected_actor)) - , selected_mapper_ (std::move(selected_mapper)) - , id_selected_data_map_ (std::move(id_selected_map)) - , renderer_ (renderer) - {} - - ~SelectionEvent (); - - inline vtkIdType - getNumPoints () const { return selected_points_->GetNumberOfPoints (); } - - vtkSmartPointer - getPolyData () const { return selected_points_; } - - vtkSmartPointer - getMapper () const { return selected_mapper_; } - - vtkSmartPointer - getActor () const { return selected_actor_; } - - void - findIndicesInItem (CloudItem* cloud_item, const pcl::PointIndices::Ptr& indices); - - private: - - vtkSmartPointer selected_points_; - vtkSmartPointer selected_actor_; - vtkSmartPointer selected_mapper_; - QMap < QString, vtkPolyData* > id_selected_data_map_; - vtkRenderer* renderer_; - - }; - + return selected_points_; } - -} + + vtkSmartPointer + getMapper() const + { + return selected_mapper_; + } + + vtkSmartPointer + getActor() const + { + return selected_actor_; + } + + void + findIndicesInItem(CloudItem* cloud_item, const pcl::PointIndices::Ptr& indices); + +private: + vtkSmartPointer selected_points_; + vtkSmartPointer selected_actor_; + vtkSmartPointer selected_mapper_; + QMap id_selected_data_map_; + vtkRenderer* renderer_; +}; + +} // namespace cloud_composer + +} // namespace pcl diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/project_model.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/project_model.h index d4b30999923..5394e2f1ec5 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/project_model.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/project_model.h @@ -37,175 +37,179 @@ #pragma once -#include -#include - -#include - #include -#include -#include #include +#include +#include +#include #include +#include +#include + class QItemSelection; class QItemSelectionModel; -namespace pcl -{ - namespace cloud_composer +namespace pcl { +namespace cloud_composer { +class CloudCommand; +class AbstractTool; +class WorkQueue; +class CloudComposerItem; +class CloudView; +class InteractorStyleSwitch; + +class ProjectModel : public QStandardItemModel { + Q_OBJECT + +public: + ProjectModel(QObject* parent = nullptr); + ProjectModel(const ProjectModel& to_copy); + ~ProjectModel(); + + ProjectModel(QString project_name, QObject* parent = nullptr); + + inline const QString + getName() + { + return horizontalHeaderItem(0)->text(); + } + + inline QUndoStack* + getUndoStack() { - class CloudCommand; - class AbstractTool; - class WorkQueue; - class CloudComposerItem; - class CloudView; - class InteractorStyleSwitch; - - class ProjectModel : public QStandardItemModel - { - Q_OBJECT - - public: - ProjectModel (QObject *parent = nullptr); - ProjectModel (const ProjectModel& to_copy); - ~ProjectModel (); - - ProjectModel (QString project_name, QObject *parent = nullptr); - - inline const QString - getName () { return horizontalHeaderItem (0)->text (); } - - inline QUndoStack* - getUndoStack () { return undo_stack_; } - - /** \brief Sets the name of the project using the horizontalHeaderItem */ - void - setName (const QString& new_name); - - /** \brief Returns the selection model which is used for this project */ - inline QItemSelectionModel* - getSelectionModel () - { - return selection_model_; - } - - - - /** \brief Takes tool object issues signal to work queue to take control of it */ - void - enqueueToolAction (AbstractTool* tool); - - /** \brief Helper function which inserts the item into this model and makes connections for properties */ - void - insertNewCloudComposerItem (CloudComposerItem* new_item, QStandardItem* parent_item); - - /** \brief Sets the CloudView that this project is rendering in */ - void - setCloudView (CloudView* view); - - /** \brief This sets the selection for points which have been selected in the QVTKWindow */ - void - setPointSelection (const std::shared_ptr& selected_event); - - /** \brief This is invoked to perform the manipulations specified on the model */ - void - manipulateClouds (const std::shared_ptr& manip_event); - public Q_SLOTS: - void - commandCompleted (CloudCommand* command); - - void - clearSelection (); - - void - deleteSelectedItems (); - - /** \brief Loads from file and inserts a new pointcloud into the model */ - void - insertNewCloudFromFile (); - - /** \brief Loads from rgb and depth file and inserts a new pointcloud into the model */ - void - insertNewCloudFromRGBandDepth (); - - /** \brief Opens a file dialog and saves selected cloud to file */ - void - saveSelectedCloudToFile (); - - /** \brief This emits all the state signals, which updates the GUI action button status (enabled/disabled)" */ - void - emitAllStateSignals (); - - /** \brief This sets whether the CloudView for this project shows axes */ - void - setAxisVisibility (bool visible); - - /** \brief Slot called when the mouse style selected in the GUI changes */ - void - mouseStyleChanged (QAction* new_style_action); - - /** \brief Slot Called whenever the item selection_model_ changes */ - void - itemSelectionChanged ( const QItemSelection &, const QItemSelection &); - - /** \brief Creates a new cloud from the selected items and points */ - void - createNewCloudFromSelection (); - - /** \brief Selects all items in the model */ - void - selectAllItems (QStandardItem* item = nullptr ); - Q_SIGNALS: - void - enqueueNewAction (AbstractTool* tool, ConstItemList data); - - /** \brief Catch-all signal emitted whenever the model changes */ - void - modelChanged (); - - void - axisVisible (const bool axis_visible); - - void - deleteAvailable (bool can_delete); - - void - newCloudFromSelectionAvailable (bool can_create); - - void - mouseStyleState (interactor_styles::INTERACTOR_STYLES); - - private: - /** \brief Checks to see if selection contains only CloudItem s */ - bool - onlyCloudItemsSelected (); - - QItemSelectionModel* selection_model_; - QMap name_to_type_map_; - QUndoStack* undo_stack_; - WorkQueue* work_queue_; - QThread* work_thread_; - CloudView* cloud_view_; - - /** \brief Stores last directory used in file read/write operations */ - QDir last_directory_; - - //Variables for toggle action status - bool axis_visible_; - QMap selected_style_map_; - /** \brief Internal helper function for updating map */ - void - setSelectedStyle (interactor_styles::INTERACTOR_STYLES style); - - /** \brief Internal pointer storing the last selection event arriving from vtk */ - std::shared_ptr selection_event_; - /** \brief Map which stores which cloud items and indices were selected in the selection_event_ */ - QMap selected_item_index_map_; - }; + return undo_stack_; } -} -Q_DECLARE_METATYPE (pcl::cloud_composer::ProjectModel); -Q_DECLARE_METATYPE (pcl::cloud_composer::interactor_styles::INTERACTOR_STYLES); + /** \brief Sets the name of the project using the horizontalHeaderItem */ + void + setName(const QString& new_name); + + /** \brief Returns the selection model which is used for this project */ + inline QItemSelectionModel* + getSelectionModel() + { + return selection_model_; + } + + /** \brief Takes tool object issues signal to work queue to take control of it */ + void + enqueueToolAction(AbstractTool* tool); + + /** \brief Helper function which inserts the item into this model and makes + * connections for properties */ + void + insertNewCloudComposerItem(CloudComposerItem* new_item, QStandardItem* parent_item); + + /** \brief Sets the CloudView that this project is rendering in */ + void + setCloudView(CloudView* view); + + /** \brief This sets the selection for points which have been selected in the + * QVTKWindow */ + void + setPointSelection(const std::shared_ptr& selected_event); + + /** \brief This is invoked to perform the manipulations specified on the model */ + void + manipulateClouds(const std::shared_ptr& manip_event); +public Q_SLOTS: + void + commandCompleted(CloudCommand* command); + + void + clearSelection(); + + void + deleteSelectedItems(); + + /** \brief Loads from file and inserts a new pointcloud into the model */ + void + insertNewCloudFromFile(); + + /** \brief Loads from rgb and depth file and inserts a new pointcloud into the model + */ + void + insertNewCloudFromRGBandDepth(); + + /** \brief Opens a file dialog and saves selected cloud to file */ + void + saveSelectedCloudToFile(); + + /** \brief This emits all the state signals, which updates the GUI action button + * status (enabled/disabled)" */ + void + emitAllStateSignals(); + + /** \brief This sets whether the CloudView for this project shows axes */ + void + setAxisVisibility(bool visible); + + /** \brief Slot called when the mouse style selected in the GUI changes */ + void + mouseStyleChanged(QAction* new_style_action); + + /** \brief Slot Called whenever the item selection_model_ changes */ + void + itemSelectionChanged(const QItemSelection&, const QItemSelection&); + + /** \brief Creates a new cloud from the selected items and points */ + void + createNewCloudFromSelection(); + + /** \brief Selects all items in the model */ + void + selectAllItems(QStandardItem* item = nullptr); +Q_SIGNALS: + void + enqueueNewAction(AbstractTool* tool, ConstItemList data); + + /** \brief Catch-all signal emitted whenever the model changes */ + void + modelChanged(); + + void + axisVisible(const bool axis_visible); + + void + deleteAvailable(bool can_delete); + + void + newCloudFromSelectionAvailable(bool can_create); + + void mouseStyleState(interactor_styles::INTERACTOR_STYLES); + +private: + /** \brief Checks to see if selection contains only CloudItem s */ + bool + onlyCloudItemsSelected(); + + QItemSelectionModel* selection_model_; + QMap name_to_type_map_; + QUndoStack* undo_stack_; + WorkQueue* work_queue_; + QThread* work_thread_; + CloudView* cloud_view_; + + /** \brief Stores last directory used in file read/write operations */ + QDir last_directory_; + + // Variables for toggle action status + bool axis_visible_; + QMap selected_style_map_; + /** \brief Internal helper function for updating map */ + void + setSelectedStyle(interactor_styles::INTERACTOR_STYLES style); + + /** \brief Internal pointer storing the last selection event arriving from vtk */ + std::shared_ptr selection_event_; + /** \brief Map which stores which cloud items and indices were selected in the + * selection_event_ */ + QMap selected_item_index_map_; +}; +} // namespace cloud_composer +} // namespace pcl + +Q_DECLARE_METATYPE(pcl::cloud_composer::ProjectModel); +Q_DECLARE_METATYPE(pcl::cloud_composer::interactor_styles::INTERACTOR_STYLES); diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/properties_model.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/properties_model.h index 57460d14062..a4747ca42a5 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/properties_model.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/properties_model.h @@ -39,52 +39,50 @@ #include -namespace pcl -{ - namespace cloud_composer - { - class CloudComposerItem; - class PropertiesModel : public QStandardItemModel - { - Q_OBJECT - public: - - /** \brief Constructor used for tool parameters */ - PropertiesModel (QObject *parent = nullptr); - /** \brief Constructor used for item parameters */ - PropertiesModel (CloudComposerItem* parent_item, QObject *parent = nullptr); - PropertiesModel (const PropertiesModel& to_copy); - - /** \brief Helper function for adding a new property */ - void - addProperty (const QString& prop_name, const QVariant& value, const Qt::ItemFlags flags = Qt::ItemIsSelectable, const QString& category = ""); - - /** \brief Helper function for adding a new property category */ - void - addCategory (const QString& category_name); - - /** \brief Helper function to get a property */ - QVariant - getProperty (const QString& prop_name) const; - - void - copyProperties (const PropertiesModel* to_copy); - - public Q_SLOTS: - void - propertyChanged (QStandardItem* property_item); - - Q_SIGNALS: - void - propertyChanged (const QStandardItem* property_item, const CloudComposerItem* parent_item_); - - - private: - CloudComposerItem* parent_item_; - - }; - } -} +namespace pcl { +namespace cloud_composer { +class CloudComposerItem; +class PropertiesModel : public QStandardItemModel { + Q_OBJECT +public: + /** \brief Constructor used for tool parameters */ + PropertiesModel(QObject* parent = nullptr); + /** \brief Constructor used for item parameters */ + PropertiesModel(CloudComposerItem* parent_item, QObject* parent = nullptr); + PropertiesModel(const PropertiesModel& to_copy); -Q_DECLARE_METATYPE (pcl::cloud_composer::PropertiesModel); -Q_DECLARE_METATYPE (pcl::cloud_composer::PropertiesModel*); + /** \brief Helper function for adding a new property */ + void + addProperty(const QString& prop_name, + const QVariant& value, + const Qt::ItemFlags flags = Qt::ItemIsSelectable, + const QString& category = ""); + + /** \brief Helper function for adding a new property category */ + void + addCategory(const QString& category_name); + + /** \brief Helper function to get a property */ + QVariant + getProperty(const QString& prop_name) const; + + void + copyProperties(const PropertiesModel* to_copy); + +public Q_SLOTS: + void + propertyChanged(QStandardItem* property_item); + +Q_SIGNALS: + void + propertyChanged(const QStandardItem* property_item, + const CloudComposerItem* parent_item_); + +private: + CloudComposerItem* parent_item_; +}; +} // namespace cloud_composer +} // namespace pcl + +Q_DECLARE_METATYPE(pcl::cloud_composer::PropertiesModel); +Q_DECLARE_METATYPE(pcl::cloud_composer::PropertiesModel*); diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/signal_multiplexer.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/signal_multiplexer.h index c8a5224f524..4e27838b25a 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/signal_multiplexer.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/signal_multiplexer.h @@ -1,12 +1,12 @@ /* * Software License Agreement (BSD License) * - * + * * Class to multiplex signal and slot connections. Qt 3 code from: * http://doc.trolltech.com/qq/qq08-action-multiplexer.html. * Converted to Qt 4 by a.somers@rathenau.nl. - * Modified for use in cloud_composer by jpapon@gmail.com - * + * Modified for use in cloud_composer by jpapon@gmail.com + * * Point Cloud Library (PCL) - www.pointclouds.org * * All rights reserved. @@ -46,106 +46,105 @@ #include #include -namespace pcl -{ - namespace cloud_composer +namespace pcl { +namespace cloud_composer { +class SignalMultiplexer : public QObject { + Q_OBJECT + +public: + SignalMultiplexer(QObject* parent = nullptr); + + /** + Use this connect function instead of QObject::connect() to connect + an actions activation signal to the receiving, multiplexed object. + + @param sender the sending action or object + @param signal the signal in the sender object that is connected to + @param slot the slot in the receiving object that is set through @ref + setCurrentObject that the signal should be connected to. + + @see connect(const char *signal, QObject *receiver, const char *slot) + @see disconnect(QObject *sender, const char *signal, const char *slot) + */ + void + connect(QObject* sender, const char* signal, const char* slot); + + /** + Disconnects a signal connection from a sending object to a multiplexed + receiving object. + @see connect(const char *signal, QObject *receiver, const char *slot) + */ + bool + disconnect(QObject* sender, const char* signal, const char* slot); + + /** + Use this connect function instead of QObject::connect() to connect + a multiplexed object's (status) signal to an action object's slot. + + @param signal the signal in the multiplexed sender object that is set through + @ref setCurrentObject that the connection should be from + @param receiver the receiving action or object + @param slot the slot in the receiving object + + @see connect(QObject *sender, const char *signal, const char *slot) + @see disconnect(const char *signal, QObject *receiver, const char *slot) + */ + void + connect(const char* signal, QObject* receiver, const char* slot); + + /** + Disconnects a signal from a multiplexed object to a receiving (action) + object. + @see connect(const char *signal, QObject *receiver, const char *slot) + */ + bool + disconnect(const char* signal, QObject* receiver, const char* slot); + + /** + @returns the object the connections are currently made with. + */ + QObject* + currentObject() const { - class SignalMultiplexer : public QObject - { - Q_OBJECT - - public: - SignalMultiplexer(QObject *parent = nullptr); - - /** - Use this connect function instead of QObject::connect() to connect - an actions activation signal to the receiving, multiplexed object. - - @param sender the sending action or object - @param signal the signal in the sender object that is connected to - @param slot the slot in the receiving object that is set through @ref - setCurrentObject that the signal should be connected to. - - @see connect(const char *signal, QObject *receiver, const char *slot) - @see disconnect(QObject *sender, const char *signal, const char *slot) - */ - void - connect (QObject *sender, const char *signal, const char *slot); - - /** - Disconnects a signal connection from a sending object to a multiplexed - receiving object. - @see connect(const char *signal, QObject *receiver, const char *slot) - */ - bool - disconnect (QObject *sender, const char *signal, const char *slot); - - /** - Use this connect function instead of QObject::connect() to connect - a multiplexed object's (status) signal to an action object's slot. - - @param signal the signal in the multiplexed sender object that is set through - @ref setCurrentObject that the connection should be from - @param receiver the receiving action or object - @param slot the slot in the receiving object - - @see connect(QObject *sender, const char *signal, const char *slot) - @see disconnect(const char *signal, QObject *receiver, const char *slot) - */ - void - connect (const char *signal, QObject *receiver, const char *slot); - - /** - Disconnects a signal from a multiplexed object to a receiving (action) - object. - @see connect(const char *signal, QObject *receiver, const char *slot) - */ - bool - disconnect (const char *signal, QObject *receiver, const char *slot); - - /** - @returns the object the connections are currently made with. - */ - QObject - *currentObject () const { return object; } - - public Q_SLOTS: - /** - Sets the current object the signals that are managed by the - SignalMultiplexer instance should be connected to. Any connections - of these signals to the previous object will be disconnected. - After the connections are hooked to the new object, the - @ref currentObjectChanged signal will be emitted. - - @param newObject the new object that the signals should be connected to - */ - void - setCurrentObject (QObject *newObject); - - Q_SIGNALS: - /** - Emitted when a new object is set to receive the signals managed by - this SignalMultiplexer instance. - */ - void - currentObjectChanged (QObject* newObject); - - private: - struct Connection - { - QPointer sender; - QPointer receiver; - const char *signal; - const char *slot; - }; - - void - connect (const Connection &conn); - void - disconnect (const Connection &conn); - - QPointer object; - QList connections; - }; + return object; } -} + +public Q_SLOTS: + /** + Sets the current object the signals that are managed by the + SignalMultiplexer instance should be connected to. Any connections + of these signals to the previous object will be disconnected. + After the connections are hooked to the new object, the + @ref currentObjectChanged signal will be emitted. + + @param newObject the new object that the signals should be connected to + */ + void + setCurrentObject(QObject* newObject); + +Q_SIGNALS: + /** + Emitted when a new object is set to receive the signals managed by + this SignalMultiplexer instance. + */ + void + currentObjectChanged(QObject* newObject); + +private: + struct Connection { + QPointer sender; + QPointer receiver; + const char* signal; + const char* slot; + }; + + void + connect(const Connection& conn); + void + disconnect(const Connection& conn); + + QPointer object; + QList connections; +}; +} // namespace cloud_composer +} // namespace pcl diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/tool_interface/abstract_tool.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/tool_interface/abstract_tool.h index 1eb18eaf1a0..30bd06080c9 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/tool_interface/abstract_tool.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/tool_interface/abstract_tool.h @@ -43,137 +43,145 @@ #include -namespace pcl -{ - namespace cloud_composer +namespace pcl { +namespace cloud_composer { + +class AbstractTool : public QObject { + Q_OBJECT +public: + AbstractTool(PropertiesModel* parameter_model, QObject* parent); + + ~AbstractTool() { qDebug() << "Tool Destructed"; } + + /** \brief Function called which does work in plugin + * \param data input_data from the model - const for good reason + * Returned list will become the output, replacing input_data in the model - you must + * deep copy the input_data, since undo works by switching back and forth + */ + virtual QList + performAction(QList input_data, + PointTypeFlags::PointType type = PointTypeFlags::NONE) = 0; + + virtual CloudCommand* + createCommand(QList input_data) = 0; + + QString + getActionText() const + { + return action_text_; + } + + void + setActionText(const QString& text) + { + action_text_ = text; + } + + virtual QString + getToolName() const = 0; + +protected: + PropertiesModel* parameter_model_; + +private: + QString action_text_; +}; + +class ModifyItemTool : public AbstractTool { + Q_OBJECT +public: + ModifyItemTool(PropertiesModel* parameter_model, QObject* parent) + : AbstractTool(parameter_model, parent) + {} + + QList + performAction(QList input_data, + PointTypeFlags::PointType type = PointTypeFlags::NONE) override = 0; + + inline CloudCommand* + createCommand(QList input_data) override { - - - class AbstractTool : public QObject - { - Q_OBJECT - public: - - AbstractTool (PropertiesModel* parameter_model, QObject* parent); - - ~AbstractTool () { qDebug() << "Tool Destructed"; } - - /** \brief Function called which does work in plugin - * \param data input_data from the model - const for good reason - * Returned list will become the output, replacing input_data in the model - you must deep copy - * the input_data, since undo works by switching back and forth - */ - virtual QList - performAction (QList input_data, PointTypeFlags::PointType type = PointTypeFlags::NONE) = 0; - - virtual CloudCommand* - createCommand (QList input_data) = 0; - - QString - getActionText () const {return action_text_;} - - void - setActionText (const QString& text) { action_text_ = text; } - - virtual QString - getToolName () const = 0; - - protected: - - PropertiesModel* parameter_model_; - - private: - QString action_text_; - - }; - - class ModifyItemTool : public AbstractTool - { - Q_OBJECT - public: - ModifyItemTool (PropertiesModel* parameter_model, QObject* parent) - : AbstractTool (parameter_model, parent) - {} - - QList - performAction (QList input_data, PointTypeFlags::PointType type = PointTypeFlags::NONE) override = 0; - - inline CloudCommand* - createCommand (QList input_data) override - { - return new ModifyItemCommand (input_data); - } - - inline QString - getToolName () const override { return "ModifyItemTool";} - - }; - - class NewItemTool : public AbstractTool - { - Q_OBJECT - public: - NewItemTool (PropertiesModel* parameter_model, QObject* parent) - : AbstractTool (parameter_model, parent) - {} - - QList - performAction (QList input_data, PointTypeFlags::PointType type = PointTypeFlags::NONE) override = 0; - - inline CloudCommand* - createCommand (QList input_data) override - { - return new NewItemCloudCommand (input_data); - } - - inline QString - getToolName () const override { return "NewItemTool";} - - }; - - class SplitItemTool : public AbstractTool - { - Q_OBJECT - public: - SplitItemTool (PropertiesModel* parameter_model, QObject* parent) - : AbstractTool (parameter_model, parent) - {} - - QList - performAction (QList input_data, PointTypeFlags::PointType type = PointTypeFlags::NONE) override = 0; - - inline CloudCommand* - createCommand (QList input_data) override - { - return new SplitCloudCommand (input_data); - } - - inline QString - getToolName () const override { return "SplitItemTool";} - - }; - - class MergeCloudTool : public AbstractTool - { - Q_OBJECT - public: - MergeCloudTool (PropertiesModel* parameter_model, QObject* parent) - : AbstractTool (parameter_model, parent) - {} - - QList - performAction (QList input_data, PointTypeFlags::PointType type = PointTypeFlags::NONE) override = 0; - - inline CloudCommand* - createCommand (QList input_data) override - { - return new MergeCloudCommand (input_data); - } - - inline QString - getToolName () const override { return "MergeCloudTool";} - - }; + return new ModifyItemCommand(input_data); + } + inline QString + getToolName() const override + { + return "ModifyItemTool"; } -} +}; + +class NewItemTool : public AbstractTool { + Q_OBJECT +public: + NewItemTool(PropertiesModel* parameter_model, QObject* parent) + : AbstractTool(parameter_model, parent) + {} + + QList + performAction(QList input_data, + PointTypeFlags::PointType type = PointTypeFlags::NONE) override = 0; + + inline CloudCommand* + createCommand(QList input_data) override + { + return new NewItemCloudCommand(input_data); + } + + inline QString + getToolName() const override + { + return "NewItemTool"; + } +}; + +class SplitItemTool : public AbstractTool { + Q_OBJECT +public: + SplitItemTool(PropertiesModel* parameter_model, QObject* parent) + : AbstractTool(parameter_model, parent) + {} + + QList + performAction(QList input_data, + PointTypeFlags::PointType type = PointTypeFlags::NONE) override = 0; + + inline CloudCommand* + createCommand(QList input_data) override + { + return new SplitCloudCommand(input_data); + } + + inline QString + getToolName() const override + { + return "SplitItemTool"; + } +}; + +class MergeCloudTool : public AbstractTool { + Q_OBJECT +public: + MergeCloudTool(PropertiesModel* parameter_model, QObject* parent) + : AbstractTool(parameter_model, parent) + {} + + QList + performAction(QList input_data, + PointTypeFlags::PointType type = PointTypeFlags::NONE) override = 0; + + inline CloudCommand* + createCommand(QList input_data) override + { + return new MergeCloudCommand(input_data); + } + + inline QString + getToolName() const override + { + return "MergeCloudTool"; + } +}; + +} // namespace cloud_composer +} // namespace pcl diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/tool_interface/tool_factory.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/tool_interface/tool_factory.h index 65781efadcd..a8a7a242fdb 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/tool_interface/tool_factory.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/tool_interface/tool_factory.h @@ -41,55 +41,52 @@ class QAction; -namespace pcl -{ - namespace cloud_composer - { - - - class AbstractTool; - class AbstractCommand; - class PropertiesModel; - - class ToolFactory - { - public: - virtual AbstractTool* - createTool (PropertiesModel* parameter_model = nullptr, QObject* parent = nullptr) = 0; - - virtual PropertiesModel* - createToolParameterModel (QObject* parent) = 0; - - virtual QString - getPluginName () const = 0; - - virtual QString - getToolGroupName () const = 0; - - virtual QString - getIconName () const = 0; - - /** \brief Reimplement this function to return the proper number if tool requires more than one input item */ - inline virtual int - getNumInputItems () const - { - return 1; - } - - /** \brief Returns a list of allowed input item types. Implement in tools so GUI can prevent impossible actions */ - virtual CloudComposerItem::ItemType - getInputItemType () const = 0; - - /** \brief Returns a list of required input children. Implement in tools so GUI can prevent impossible actions */ - virtual QList - getRequiredInputChildrenTypes () const = 0; - - }; +namespace pcl { +namespace cloud_composer { + +class AbstractTool; +class AbstractCommand; +class PropertiesModel; + +class ToolFactory { +public: + virtual AbstractTool* + createTool(PropertiesModel* parameter_model = nullptr, QObject* parent = nullptr) = 0; + + virtual PropertiesModel* + createToolParameterModel(QObject* parent) = 0; + + virtual QString + getPluginName() const = 0; + + virtual QString + getToolGroupName() const = 0; + virtual QString + getIconName() const = 0; + + /** \brief Reimplement this function to return the proper number if tool requires more + * than one input item */ + inline virtual int + getNumInputItems() const + { + return 1; } -} -Q_DECLARE_METATYPE (pcl::cloud_composer::ToolFactory*); + /** \brief Returns a list of allowed input item types. Implement in tools so GUI can + * prevent impossible actions */ + virtual CloudComposerItem::ItemType + getInputItemType() const = 0; + + /** \brief Returns a list of required input children. Implement in tools so GUI can + * prevent impossible actions */ + virtual QList + getRequiredInputChildrenTypes() const = 0; +}; + +} // namespace cloud_composer +} // namespace pcl + +Q_DECLARE_METATYPE(pcl::cloud_composer::ToolFactory*); -Q_DECLARE_INTERFACE(pcl::cloud_composer::ToolFactory, - "cloud_composer.ToolFactory/1.0") +Q_DECLARE_INTERFACE(pcl::cloud_composer::ToolFactory, "cloud_composer.ToolFactory/1.0") diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/toolbox_model.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/toolbox_model.h index 0121b56be5d..f109c8d93a9 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/toolbox_model.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/toolbox_model.h @@ -44,8 +44,7 @@ class QItemSelection; class QItemSelectionModel; class QTreeView; -enum TOOLBOX_ROLES -{ +enum TOOLBOX_ROLES { FACTORY = Qt::UserRole, PARAMETER_MODEL, ALLOWED_INPUT_ITEM_TYPES, @@ -53,71 +52,72 @@ enum TOOLBOX_ROLES }; class QTreeView; -namespace pcl -{ - namespace cloud_composer - { - - class CloudCommand; - class AbstractTool; - class ToolFactory; - class ProjectModel; - - class ToolBoxModel : public QStandardItemModel - { - Q_OBJECT - - public: - ToolBoxModel (QTreeView* tool_view = nullptr, QTreeView* parameter_view = nullptr, QObject *parent = nullptr); - ToolBoxModel (const ToolBoxModel& to_copy); - - void - addTool (ToolFactory* tool_factory); - - void - setSelectionModel (QItemSelectionModel* selection_model); - - /** \brief Enables/Disables Tools based on currently selected items from model */ - void - updateEnabledTools (const QItemSelection& current_selection); - - void - enableAllTools (); - - public Q_SLOTS: - void - activeProjectChanged (ProjectModel* new_model, ProjectModel* previous_model); - - void - selectedToolChanged (const QModelIndex & current, const QModelIndex & previous); - - void - toolAction (); - - /** \brief This slot is called when the selection in cloud browser changes. Updates enabling of tools */ - void - selectedItemChanged ( const QItemSelection & selected, const QItemSelection & deselected ); - - /** \brief This slot is called whenever the current project model emits layoutChanged, and calls updateEnabledTools */ - void - modelChanged (); - Q_SIGNALS: - void - enqueueToolAction (AbstractTool* tool); - - private: - QStandardItem* - addToolGroup (const QString& tool_group_name); - - QTreeView* tool_view_; - QTreeView* parameter_view_; - QItemSelectionModel* selection_model_; - QSet tool_items; - - ProjectModel* project_model_; - }; - } -} - -Q_DECLARE_METATYPE (pcl::cloud_composer::ToolBoxModel); -Q_DECLARE_METATYPE (QStandardItemModel*); +namespace pcl { +namespace cloud_composer { + +class CloudCommand; +class AbstractTool; +class ToolFactory; +class ProjectModel; + +class ToolBoxModel : public QStandardItemModel { + Q_OBJECT + +public: + ToolBoxModel(QTreeView* tool_view = nullptr, + QTreeView* parameter_view = nullptr, + QObject* parent = nullptr); + ToolBoxModel(const ToolBoxModel& to_copy); + + void + addTool(ToolFactory* tool_factory); + + void + setSelectionModel(QItemSelectionModel* selection_model); + + /** \brief Enables/Disables Tools based on currently selected items from model */ + void + updateEnabledTools(const QItemSelection& current_selection); + + void + enableAllTools(); + +public Q_SLOTS: + void + activeProjectChanged(ProjectModel* new_model, ProjectModel* previous_model); + + void + selectedToolChanged(const QModelIndex& current, const QModelIndex& previous); + + void + toolAction(); + + /** \brief This slot is called when the selection in cloud browser changes. Updates + * enabling of tools */ + void + selectedItemChanged(const QItemSelection& selected, const QItemSelection& deselected); + + /** \brief This slot is called whenever the current project model emits layoutChanged, + * and calls updateEnabledTools */ + void + modelChanged(); +Q_SIGNALS: + void + enqueueToolAction(AbstractTool* tool); + +private: + QStandardItem* + addToolGroup(const QString& tool_group_name); + + QTreeView* tool_view_; + QTreeView* parameter_view_; + QItemSelectionModel* selection_model_; + QSet tool_items; + + ProjectModel* project_model_; +}; +} // namespace cloud_composer +} // namespace pcl + +Q_DECLARE_METATYPE(pcl::cloud_composer::ToolBoxModel); +Q_DECLARE_METATYPE(QStandardItemModel*); diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/euclidean_clustering.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/euclidean_clustering.h index 9a9e82d75ec..c97be097638 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/euclidean_clustering.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/euclidean_clustering.h @@ -40,62 +40,68 @@ #include #include -namespace pcl -{ - namespace cloud_composer +namespace pcl { +namespace cloud_composer { +class EuclideanClusteringTool : public SplitItemTool { + Q_OBJECT +public: + EuclideanClusteringTool(PropertiesModel* parameter_model, QObject* parent); + + QList + performAction(QList input_data, + PointTypeFlags::PointType type = PointTypeFlags::NONE) override; + + inline QString + getToolName() const override + { + return "Euclidean Clustering Tool"; + } +}; + +class EuclideanClusteringToolFactory : public QObject, public ToolFactory { + Q_OBJECT + Q_INTERFACES(pcl::cloud_composer::ToolFactory) + Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") +public: + SplitItemTool* + createTool(PropertiesModel* parameter_model, QObject* parent = nullptr) override + { + return new EuclideanClusteringTool(parameter_model, parent); + } + + PropertiesModel* + createToolParameterModel(QObject* parent) override; + + inline QString + getPluginName() const override { - class EuclideanClusteringTool : public SplitItemTool - { - Q_OBJECT - public: - EuclideanClusteringTool (PropertiesModel* parameter_model, QObject* parent); - - QList - performAction (QList input_data, PointTypeFlags::PointType type = PointTypeFlags::NONE) override; - - inline QString - getToolName () const override { return "Euclidean Clustering Tool";} - }; + return "Euclidean Clustering"; + } - - class EuclideanClusteringToolFactory : public QObject, public ToolFactory - { - Q_OBJECT - Q_INTERFACES (pcl::cloud_composer::ToolFactory) - Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") - public: - SplitItemTool* - createTool (PropertiesModel* parameter_model, QObject* parent = nullptr) override - { - return new EuclideanClusteringTool(parameter_model, parent); - } - - PropertiesModel* - createToolParameterModel (QObject* parent) override; - - inline QString - getPluginName () const override { return "Euclidean Clustering";} - - inline QString - getToolGroupName () const override { return "Segmentation";} - - inline QString - getIconName () const override { return ":/euclidean_clustering.png"; } - - inline CloudComposerItem::ItemType - getInputItemType () const override - { - return CloudComposerItem::CLOUD_ITEM; - } - - inline QList - getRequiredInputChildrenTypes () const override - { - return QList (); - } - }; + inline QString + getToolGroupName() const override + { + return "Segmentation"; + } + inline QString + getIconName() const override + { + return ":/euclidean_clustering.png"; + } + inline CloudComposerItem::ItemType + getInputItemType() const override + { + return CloudComposerItem::CLOUD_ITEM; + } + inline QList + getRequiredInputChildrenTypes() const override + { + return QList(); } -} +}; + +} // namespace cloud_composer +} // namespace pcl diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/fpfh_estimation.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/fpfh_estimation.h index 10287e4c1aa..35210217fb9 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/fpfh_estimation.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/fpfh_estimation.h @@ -40,64 +40,70 @@ #include #include -namespace pcl -{ - namespace cloud_composer +namespace pcl { +namespace cloud_composer { + +class FPFHEstimationTool : public NewItemTool { + Q_OBJECT +public: + FPFHEstimationTool(PropertiesModel* parameter_model, QObject* parent); + + QList + performAction(QList input_data, + PointTypeFlags::PointType type = PointTypeFlags::NONE) override; + + inline QString + getToolName() const override { - - class FPFHEstimationTool : public NewItemTool - { - Q_OBJECT - public: - FPFHEstimationTool (PropertiesModel* parameter_model, QObject* parent); - - QList - performAction (QList input_data, PointTypeFlags::PointType type = PointTypeFlags::NONE) override; - - inline QString - getToolName () const override { return "FPFH Estimation Tool";} - }; + return "FPFH Estimation Tool"; + } +}; - - class FPFHEstimationToolFactory : public QObject, public ToolFactory - { - Q_OBJECT - Q_INTERFACES (pcl::cloud_composer::ToolFactory) - Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") - public: - NewItemTool* - createTool (PropertiesModel* parameter_model, QObject* parent = nullptr) override - { - return new FPFHEstimationTool(parameter_model, parent); - } - - PropertiesModel* - createToolParameterModel (QObject* parent) override; - - inline QString - getPluginName () const override { return "FPFH Estimation";} - - QString - getToolGroupName () const override { return "Feature Estimation";} - - QString - getIconName () const override { return ":/fpfh_estimation.png"; } - - inline CloudComposerItem::ItemType - getInputItemType () const override - { - return CloudComposerItem::CLOUD_ITEM; - } - - inline QList - getRequiredInputChildrenTypes () const override - { - QList input_types; - return (input_types << CloudComposerItem::NORMALS_ITEM); - } - }; +class FPFHEstimationToolFactory : public QObject, public ToolFactory { + Q_OBJECT + Q_INTERFACES(pcl::cloud_composer::ToolFactory) + Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") +public: + NewItemTool* + createTool(PropertiesModel* parameter_model, QObject* parent = nullptr) override + { + return new FPFHEstimationTool(parameter_model, parent); + } + PropertiesModel* + createToolParameterModel(QObject* parent) override; + inline QString + getPluginName() const override + { + return "FPFH Estimation"; + } + QString + getToolGroupName() const override + { + return "Feature Estimation"; } -} + + QString + getIconName() const override + { + return ":/fpfh_estimation.png"; + } + + inline CloudComposerItem::ItemType + getInputItemType() const override + { + return CloudComposerItem::CLOUD_ITEM; + } + + inline QList + getRequiredInputChildrenTypes() const override + { + QList input_types; + return (input_types << CloudComposerItem::NORMALS_ITEM); + } +}; + +} // namespace cloud_composer +} // namespace pcl diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/organized_segmentation.hpp b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/organized_segmentation.hpp index 708ea1f34b1..a200e83c857 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/organized_segmentation.hpp +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/organized_segmentation.hpp @@ -38,144 +38,160 @@ #ifndef IMPL_ORGANIZED_SEGMENTATION_HPP_ #define IMPL_ORGANIZED_SEGMENTATION_HPP_ -#include #include #include -#include // for pcl::make_shared -#include - -#include -#include -#include -#include +#include +#include #include #include +#include #include +#include +#include +#include +#include // for pcl::make_shared +#include - -template QList -pcl::cloud_composer::OrganizedSegmentationTool::performTemplatedAction (const QList & input_data) +template +QList +pcl::cloud_composer::OrganizedSegmentationTool::performTemplatedAction( + const QList& input_data) { - QList output; - - foreach (const CloudComposerItem* input_item, input_data) - { - QVariant variant = input_item->data (ItemDataRole::CLOUD_TEMPLATED); - if ( ! variant.canConvert ::Ptr> () ) - { - qWarning () << "Attempted to cast to template type which does not exist in this item! (input list)"; + QList output; + + foreach (const CloudComposerItem* input_item, input_data) { + QVariant variant = input_item->data(ItemDataRole::CLOUD_TEMPLATED); + if (!variant.canConvert::Ptr>()) { + qWarning() << "Attempted to cast to template type which does not exist in this " + "item! (input list)"; return output; } - typename PointCloud ::Ptr input_cloud = variant.value ::Ptr> (); - if ( ! input_cloud->isOrganized ()) - { - qCritical () << "Organized Segmentation requires an organized cloud!"; + typename PointCloud::Ptr input_cloud = + variant.value::Ptr>(); + if (!input_cloud->isOrganized()) { + qCritical() << "Organized Segmentation requires an organized cloud!"; return output; } } - int min_inliers = parameter_model_->getProperty ("Min Inliers").toInt (); - int min_plane_size = parameter_model_->getProperty ("Min Plane Size").toInt (); - double angular_threshold = parameter_model_->getProperty ("Angular Threshold").toDouble (); - double distance_threshold = parameter_model_->getProperty ("Distance Threshold").toDouble (); - double cluster_distance_threshold = parameter_model_->getProperty ("Cluster Dist. Thresh.").toDouble (); - int min_cluster_size = parameter_model_->getProperty ("Min Cluster Size").toInt (); - - foreach (const CloudComposerItem* input_item, input_data) - { - QList normals_list = input_item->getChildren (CloudComposerItem::NORMALS_ITEM); - //Get the normals cloud, we just use the first normals that were found if there are more than one - pcl::PointCloud::ConstPtr input_normals = normals_list.value(0)->data(ItemDataRole::CLOUD_TEMPLATED).value ::ConstPtr> (); - - QVariant variant = input_item->data (ItemDataRole::CLOUD_TEMPLATED); - typename PointCloud ::Ptr input_cloud = variant.value ::Ptr> (); + int min_inliers = parameter_model_->getProperty("Min Inliers").toInt(); + int min_plane_size = parameter_model_->getProperty("Min Plane Size").toInt(); + double angular_threshold = + parameter_model_->getProperty("Angular Threshold").toDouble(); + double distance_threshold = + parameter_model_->getProperty("Distance Threshold").toDouble(); + double cluster_distance_threshold = + parameter_model_->getProperty("Cluster Dist. Thresh.").toDouble(); + int min_cluster_size = parameter_model_->getProperty("Min Cluster Size").toInt(); + + foreach (const CloudComposerItem* input_item, input_data) { + QList normals_list = + input_item->getChildren(CloudComposerItem::NORMALS_ITEM); + // Get the normals cloud, we just use the first normals that were found if there are + // more than one + pcl::PointCloud::ConstPtr input_normals = + normals_list.value(0) + ->data(ItemDataRole::CLOUD_TEMPLATED) + .value::ConstPtr>(); + + QVariant variant = input_item->data(ItemDataRole::CLOUD_TEMPLATED); + typename PointCloud::Ptr input_cloud = + variant.value::Ptr>(); pcl::OrganizedMultiPlaneSegmentation mps; - mps.setMinInliers (min_inliers); - mps.setAngularThreshold (pcl::deg2rad (angular_threshold)); // convert to radians - mps.setDistanceThreshold (distance_threshold); - mps.setInputNormals (input_normals); - mps.setInputCloud (input_cloud); - std::vector, Eigen::aligned_allocator > > regions; + mps.setMinInliers(min_inliers); + mps.setAngularThreshold(pcl::deg2rad(angular_threshold)); // convert to radians + mps.setDistanceThreshold(distance_threshold); + mps.setInputNormals(input_normals); + mps.setInputCloud(input_cloud); + std::vector, + Eigen::aligned_allocator>> + regions; std::vector model_coefficients; std::vector inlier_indices; - pcl::PointCloud::Ptr labels (new pcl::PointCloud); + pcl::PointCloud::Ptr labels(new pcl::PointCloud); std::vector label_indices; std::vector boundary_indices; - mps.segmentAndRefine (regions, model_coefficients, inlier_indices, labels, label_indices, boundary_indices); - - auto plane_labels = pcl::make_shared > (); - for (std::size_t i = 0; i < label_indices.size (); ++i) - if (label_indices[i].indices.size () > (std::size_t) min_plane_size) - plane_labels->insert (i); + mps.segmentAndRefine(regions, + model_coefficients, + inlier_indices, + labels, + label_indices, + boundary_indices); + + auto plane_labels = pcl::make_shared>(); + for (std::size_t i = 0; i < label_indices.size(); ++i) + if (label_indices[i].indices.size() > (std::size_t)min_plane_size) + plane_labels->insert(i); typename PointCloud::CloudVectorType clusters; - typename EuclideanClusterComparator::Ptr euclidean_cluster_comparator(new EuclideanClusterComparator); - euclidean_cluster_comparator->setInputCloud (input_cloud); - euclidean_cluster_comparator->setLabels (labels); - euclidean_cluster_comparator->setExcludeLabels (plane_labels); - euclidean_cluster_comparator->setDistanceThreshold (cluster_distance_threshold, false); + typename EuclideanClusterComparator::Ptr + euclidean_cluster_comparator( + new EuclideanClusterComparator); + euclidean_cluster_comparator->setInputCloud(input_cloud); + euclidean_cluster_comparator->setLabels(labels); + euclidean_cluster_comparator->setExcludeLabels(plane_labels); + euclidean_cluster_comparator->setDistanceThreshold(cluster_distance_threshold, + false); pcl::PointCloud euclidean_labels; std::vector euclidean_label_indices; - pcl::OrganizedConnectedComponentSegmentation euclidean_segmentation (euclidean_cluster_comparator); - euclidean_segmentation.setInputCloud (input_cloud); - euclidean_segmentation.segment (euclidean_labels, euclidean_label_indices); - - pcl::IndicesPtr extracted_indices (new pcl::Indices ()); - for (std::size_t i = 0; i < euclidean_label_indices.size (); i++) - { - if (euclidean_label_indices[i].indices.size () >= (std::size_t) min_cluster_size) - { - typename PointCloud::Ptr cluster (new PointCloud); - pcl::copyPointCloud (*input_cloud,euclidean_label_indices[i].indices,*cluster); - qDebug () << "Found cluster with size " << cluster->width; - QString name = input_item->text () + tr ("- Clstr %1").arg (i); - CloudItem* new_cloud_item = CloudItem::createCloudItemFromTemplate(name,cluster); - output.append (new_cloud_item); - extracted_indices->insert (extracted_indices->end (), euclidean_label_indices[i].indices.begin (), euclidean_label_indices[i].indices.end ()); + pcl::OrganizedConnectedComponentSegmentation + euclidean_segmentation(euclidean_cluster_comparator); + euclidean_segmentation.setInputCloud(input_cloud); + euclidean_segmentation.segment(euclidean_labels, euclidean_label_indices); + + pcl::IndicesPtr extracted_indices(new pcl::Indices()); + for (std::size_t i = 0; i < euclidean_label_indices.size(); i++) { + if (euclidean_label_indices[i].indices.size() >= (std::size_t)min_cluster_size) { + typename PointCloud::Ptr cluster(new PointCloud); + pcl::copyPointCloud(*input_cloud, euclidean_label_indices[i].indices, *cluster); + qDebug() << "Found cluster with size " << cluster->width; + QString name = input_item->text() + tr("- Clstr %1").arg(i); + CloudItem* new_cloud_item = + CloudItem::createCloudItemFromTemplate(name, cluster); + output.append(new_cloud_item); + extracted_indices->insert(extracted_indices->end(), + euclidean_label_indices[i].indices.begin(), + euclidean_label_indices[i].indices.end()); } } - for (std::size_t i = 0; i < label_indices.size (); i++) - { - if (label_indices[i].indices.size () >= (std::size_t) min_plane_size) - { - typename PointCloud::Ptr plane (new PointCloud); - pcl::copyPointCloud (*input_cloud,label_indices[i].indices,*plane); - qDebug () << "Found plane with size " << plane->width; - QString name = input_item->text () + tr ("- Plane %1").arg (i); - CloudItem* new_cloud_item = CloudItem::createCloudItemFromTemplate(name,plane); - output.append (new_cloud_item); - extracted_indices->insert (extracted_indices->end (), label_indices[i].indices.begin (), label_indices[i].indices.end ()); - + for (std::size_t i = 0; i < label_indices.size(); i++) { + if (label_indices[i].indices.size() >= (std::size_t)min_plane_size) { + typename PointCloud::Ptr plane(new PointCloud); + pcl::copyPointCloud(*input_cloud, label_indices[i].indices, *plane); + qDebug() << "Found plane with size " << plane->width; + QString name = input_item->text() + tr("- Plane %1").arg(i); + CloudItem* new_cloud_item = + CloudItem::createCloudItemFromTemplate(name, plane); + output.append(new_cloud_item); + extracted_indices->insert(extracted_indices->end(), + label_indices[i].indices.begin(), + label_indices[i].indices.end()); } } - typename PointCloud::Ptr leftovers (new PointCloud); - if (extracted_indices->empty ()) - pcl::copyPointCloud (*input_cloud,*leftovers); - else - { + typename PointCloud::Ptr leftovers(new PointCloud); + if (extracted_indices->empty()) + pcl::copyPointCloud(*input_cloud, *leftovers); + else { pcl::ExtractIndices filter; - filter.setInputCloud (input_cloud); - filter.setIndices (extracted_indices); - filter.setNegative (true); - filter.filter (*leftovers); + filter.setInputCloud(input_cloud); + filter.setIndices(extracted_indices); + filter.setNegative(true); + filter.filter(*leftovers); } - CloudItem* leftover_cloud_item = CloudItem::createCloudItemFromTemplate(input_item->text(),leftovers); - output.append (leftover_cloud_item); + CloudItem* leftover_cloud_item = + CloudItem::createCloudItemFromTemplate(input_item->text(), leftovers); + output.append(leftover_cloud_item); } - - - return output; - } +#define PCL_INSTANTIATE_performTemplatedAction(T) \ + template void \ + pcl::cloud_composer::OrganizedSegmentationTool::performTemplatedAction( \ + QList); -#define PCL_INSTANTIATE_performTemplatedAction(T) template void pcl::cloud_composer::OrganizedSegmentationTool::performTemplatedAction (QList ); - - - -#endif //IMPL_TRANSFORM_CLOUDS_HPP_ +#endif // IMPL_TRANSFORM_CLOUDS_HPP_ diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/supervoxels.hpp b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/supervoxels.hpp index 2d83912fdc2..4222f215ec2 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/supervoxels.hpp +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/supervoxels.hpp @@ -1,124 +1,117 @@ /* -* Software License Agreement (BSD License) -* -* Point Cloud Library (PCL) - www.pointclouds.org -* Copyright (c) 2012, Jeremie Papon. -* -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions -* are met: -* -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above -* copyright notice, this list of conditions and the following -* disclaimer in the documentation and/or other materials provided -* with the distribution. -* * Neither the name of Willow Garage, Inc. nor the names of its -* contributors may be used to endorse or promote products derived -* from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -* POSSIBILITY OF SUCH DAMAGE. -* -*/ + * Software License Agreement (BSD License) + * + * Point Cloud Library (PCL) - www.pointclouds.org + * Copyright (c) 2012, Jeremie Papon. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of Willow Garage, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ #ifndef IMPL_SUPERVOXELS_HPP_ #define IMPL_SUPERVOXELS_HPP_ -#include #include #include +#include +#include #include #include -#include - -template QList -pcl::cloud_composer::SupervoxelsTool::performTemplatedAction (const QList & input_data) +template +QList +pcl::cloud_composer::SupervoxelsTool::performTemplatedAction( + const QList& input_data) { - QList output; - - foreach (const CloudComposerItem* input_item, input_data) - { - // if ( !input_item->isSanitized () ) - // { - // qCritical () << "SupervoxelsTool requires sanitized input!"; - // return output; - // } - QVariant variant = input_item->data (ItemDataRole::CLOUD_TEMPLATED); - if ( ! variant.canConvert ::Ptr> () ) - { - qWarning () << "Attempted to cast to template type which does not exist in this item! (input list)"; + QList output; + + foreach (const CloudComposerItem* input_item, input_data) { + // if ( !input_item->isSanitized () ) + // { + // qCritical () << "SupervoxelsTool requires sanitized input!"; + // return output; + // } + QVariant variant = input_item->data(ItemDataRole::CLOUD_TEMPLATED); + if (!variant.canConvert::Ptr>()) { + qWarning() << "Attempted to cast to template type which does not exist in this " + "item! (input list)"; return output; } - typename PointCloud ::Ptr input_cloud = variant.value ::Ptr> (); - //TODO: Check if Voxelized - -} - + typename PointCloud::Ptr input_cloud = + variant.value::Ptr>(); + // TODO: Check if Voxelized + } + + foreach (const CloudComposerItem* input_item, input_data) { + QVariant variant = input_item->data(ItemDataRole::CLOUD_TEMPLATED); + typename PointCloud::Ptr input_cloud = + variant.value::Ptr>(); + + float resolution = parameter_model_->getProperty("Resolution").toFloat(); + qDebug() << "Octree resolution = " << resolution; + float seed_resolution = parameter_model_->getProperty("Seed Resolution").toFloat(); + qDebug() << "Seed resolution = " << seed_resolution; + + float rgb_weight = parameter_model_->getProperty("RGB Weight").toFloat(); + float normal_weight = parameter_model_->getProperty("Normals Weight").toFloat(); + float spatial_weight = parameter_model_->getProperty("Spatial Weight").toFloat(); + + pcl::SupervoxelClustering super(resolution, seed_resolution); + super.setInputCloud(input_cloud); + super.setColorImportance(rgb_weight); + super.setSpatialImportance(spatial_weight); + super.setNormalImportance(normal_weight); + std::map::Ptr> supervoxel_clusters; + super.extract(supervoxel_clusters); + + std::map::Ptr> + refined_supervoxel_clusters; + super.refineSupervoxels(3, refined_supervoxel_clusters); - foreach (const CloudComposerItem* input_item, input_data) - { - QVariant variant = input_item->data (ItemDataRole::CLOUD_TEMPLATED); - typename PointCloud ::Ptr input_cloud = variant.value ::Ptr> (); - - float resolution = parameter_model_->getProperty("Resolution").toFloat (); - qDebug () << "Octree resolution = "<getProperty("Seed Resolution").toFloat (); - qDebug () << "Seed resolution = "<getProperty("RGB Weight").toFloat (); - float normal_weight = parameter_model_->getProperty("Normals Weight").toFloat (); - float spatial_weight = parameter_model_->getProperty("Spatial Weight").toFloat (); - - - pcl::SupervoxelClustering super (resolution, seed_resolution); - super.setInputCloud (input_cloud); - super.setColorImportance (rgb_weight); - super.setSpatialImportance (spatial_weight); - super.setNormalImportance (normal_weight); - std::map ::Ptr > supervoxel_clusters; - super.extract (supervoxel_clusters); - - std::map ::Ptr > refined_supervoxel_clusters; - super.refineSupervoxels (3, refined_supervoxel_clusters); - auto label_segments = super.getLabeledVoxelCloud(); auto color_segments = pcl::make_shared>(); pcl::copyPointCloud(*label_segments, *color_segments); for (size_t i = 0; i < label_segments->size(); ++i) - color_segments->at(i).rgba = GlasbeyLUT::at(label_segments->at(i).label % GlasbeyLUT::size()).rgba; - CloudItem* cloud_item_out = CloudItem::createCloudItemFromTemplate(input_item->text(), color_segments); - - output.append (cloud_item_out); - + color_segments->at(i).rgba = + GlasbeyLUT::at(label_segments->at(i).label % GlasbeyLUT::size()).rgba; + CloudItem* cloud_item_out = CloudItem::createCloudItemFromTemplate( + input_item->text(), color_segments); + + output.append(cloud_item_out); } - - - - + return output; - } +#define PCL_INSTANTIATE_performTemplatedAction(T) \ + template void pcl::cloud_composer::SupervoxelsTool::performTemplatedAction( \ + QList); - - -#define PCL_INSTANTIATE_performTemplatedAction(T) template void pcl::cloud_composer::SupervoxelsTool::performTemplatedAction (QList ); - - - -#endif //IMPL_SUPERVOXELS_HPP_ +#endif // IMPL_SUPERVOXELS_HPP_ diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/normal_estimation.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/normal_estimation.h index b5091cc009a..cd27fbee0cc 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/normal_estimation.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/normal_estimation.h @@ -40,62 +40,68 @@ #include #include -namespace pcl -{ - namespace cloud_composer +namespace pcl { +namespace cloud_composer { +class NormalEstimationTool : public NewItemTool { + Q_OBJECT +public: + NormalEstimationTool(PropertiesModel* parameter_model, QObject* parent); + + QList + performAction(QList input_data, + PointTypeFlags::PointType type = PointTypeFlags::NONE) override; + + inline QString + getToolName() const override + { + return "Normal Estimation Tool"; + } +}; + +class NormalEstimationToolFactory : public QObject, public ToolFactory { + Q_OBJECT + Q_INTERFACES(pcl::cloud_composer::ToolFactory) + Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") +public: + NewItemTool* + createTool(PropertiesModel* parameter_model, QObject* parent = nullptr) override + { + return new NormalEstimationTool(parameter_model, parent); + } + + PropertiesModel* + createToolParameterModel(QObject* parent) override; + + inline QString + getPluginName() const override { - class NormalEstimationTool : public NewItemTool - { - Q_OBJECT - public: - NormalEstimationTool (PropertiesModel* parameter_model, QObject* parent); - - QList - performAction (QList input_data, PointTypeFlags::PointType type = PointTypeFlags::NONE) override; - - inline QString - getToolName () const override { return "Normal Estimation Tool";} - }; + return "Normal Estimation"; + } - - class NormalEstimationToolFactory : public QObject, public ToolFactory - { - Q_OBJECT - Q_INTERFACES (pcl::cloud_composer::ToolFactory) - Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") - public: - NewItemTool* - createTool (PropertiesModel* parameter_model, QObject* parent = nullptr) override - { - return new NormalEstimationTool(parameter_model, parent); - } - - PropertiesModel* - createToolParameterModel (QObject* parent) override; - - inline QString - getPluginName () const override { return "Normal Estimation";} - - QString - getToolGroupName () const override { return "Feature Estimation";} - - QString - getIconName () const override { return ":/normal_estimation.png"; } - - inline CloudComposerItem::ItemType - getInputItemType () const override - { - return CloudComposerItem::CLOUD_ITEM; - } - - inline QList - getRequiredInputChildrenTypes () const override - { - return QList (); - } - }; + QString + getToolGroupName() const override + { + return "Feature Estimation"; + } + QString + getIconName() const override + { + return ":/normal_estimation.png"; + } + inline CloudComposerItem::ItemType + getInputItemType() const override + { + return CloudComposerItem::CLOUD_ITEM; + } + inline QList + getRequiredInputChildrenTypes() const override + { + return QList(); } -} +}; + +} // namespace cloud_composer +} // namespace pcl diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/organized_segmentation.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/organized_segmentation.h index a35d946d2ba..41aaf9e4fd7 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/organized_segmentation.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/organized_segmentation.h @@ -1,106 +1,112 @@ - /* - * Software License Agreement (BSD License) - * - * Point Cloud Library (PCL) - www.pointclouds.org - * Copyright (c) 2012, Jeremie Papon. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of Willow Garage, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - +/* + * Software License Agreement (BSD License) + * + * Point Cloud Library (PCL) - www.pointclouds.org + * Copyright (c) 2012, Jeremie Papon. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of Willow Garage, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ + #pragma once - - #include - #include - - - namespace pcl - { - namespace cloud_composer - { - class OrganizedSegmentationTool : public SplitItemTool - { - Q_OBJECT - public: - OrganizedSegmentationTool (PropertiesModel* parameter_model, QObject* parent); - - QList - performAction (QList input_data, PointTypeFlags::PointType type = PointTypeFlags::NONE) override; - - template QList - performTemplatedAction (const QList & input_data); - - inline QString - getToolName () const override { return "Organized Segmentation Tool";} - }; - - - class OrganizedSegmentationToolFactory : public QObject, public ToolFactory - { - Q_OBJECT - Q_INTERFACES (pcl::cloud_composer::ToolFactory) - Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") - public: - SplitItemTool* - createTool (PropertiesModel* parameter_model, QObject* parent = nullptr) override - { - return new OrganizedSegmentationTool(parameter_model, parent); - } - - PropertiesModel* - createToolParameterModel (QObject* parent) override; - - inline QString - getPluginName () const override { return "Organized Segmentation";} - - inline QString - getToolGroupName () const override { return "Segmentation";} - - inline QString - getIconName () const override { return ":/organized_segmentation.png"; } - - inline CloudComposerItem::ItemType - getInputItemType () const override - { - return CloudComposerItem::CLOUD_ITEM; - } - - inline QList - getRequiredInputChildrenTypes () const override - { - QList input_types; - return (input_types << CloudComposerItem::NORMALS_ITEM); - } - }; - - - - } - } + +#include +#include + +namespace pcl { +namespace cloud_composer { +class OrganizedSegmentationTool : public SplitItemTool { + Q_OBJECT +public: + OrganizedSegmentationTool(PropertiesModel* parameter_model, QObject* parent); + + QList + performAction(QList input_data, + PointTypeFlags::PointType type = PointTypeFlags::NONE) override; + + template + QList + performTemplatedAction(const QList& input_data); + + inline QString + getToolName() const override + { + return "Organized Segmentation Tool"; + } +}; + +class OrganizedSegmentationToolFactory : public QObject, public ToolFactory { + Q_OBJECT + Q_INTERFACES(pcl::cloud_composer::ToolFactory) + Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") +public: + SplitItemTool* + createTool(PropertiesModel* parameter_model, QObject* parent = nullptr) override + { + return new OrganizedSegmentationTool(parameter_model, parent); + } + + PropertiesModel* + createToolParameterModel(QObject* parent) override; + + inline QString + getPluginName() const override + { + return "Organized Segmentation"; + } + + inline QString + getToolGroupName() const override + { + return "Segmentation"; + } + + inline QString + getIconName() const override + { + return ":/organized_segmentation.png"; + } + + inline CloudComposerItem::ItemType + getInputItemType() const override + { + return CloudComposerItem::CLOUD_ITEM; + } + + inline QList + getRequiredInputChildrenTypes() const override + { + QList input_types; + return (input_types << CloudComposerItem::NORMALS_ITEM); + } +}; + +} // namespace cloud_composer +} // namespace pcl diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/sanitize_cloud.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/sanitize_cloud.h index f1c54653917..2a8e33ccc94 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/sanitize_cloud.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/sanitize_cloud.h @@ -40,62 +40,68 @@ #include #include -namespace pcl -{ - namespace cloud_composer +namespace pcl { +namespace cloud_composer { +class SanitizeCloudTool : public ModifyItemTool { + Q_OBJECT +public: + SanitizeCloudTool(PropertiesModel* parameter_model, QObject* parent); + + QList + performAction(QList input_data, + PointTypeFlags::PointType type = PointTypeFlags::NONE) override; + + inline QString + getToolName() const override + { + return "Sanitize Cloud Tool"; + } +}; + +class SanitizeCloudToolFactory : public QObject, public ToolFactory { + Q_OBJECT + Q_INTERFACES(pcl::cloud_composer::ToolFactory) + Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") +public: + ModifyItemTool* + createTool(PropertiesModel* parameter_model, QObject* parent = nullptr) override + { + return new SanitizeCloudTool(parameter_model, parent); + } + + PropertiesModel* + createToolParameterModel(QObject* parent) override; + + inline QString + getPluginName() const override + { + return "Sanitize Cloud"; + } + + QString + getToolGroupName() const override + { + return "Filters"; + } + + QString + getIconName() const override { - class SanitizeCloudTool : public ModifyItemTool - { - Q_OBJECT - public: - SanitizeCloudTool (PropertiesModel* parameter_model, QObject* parent); - - QList - performAction (QList input_data, PointTypeFlags::PointType type = PointTypeFlags::NONE) override; - - inline QString - getToolName () const override { return "Sanitize Cloud Tool";} - }; - - - class SanitizeCloudToolFactory : public QObject, public ToolFactory - { - Q_OBJECT - Q_INTERFACES (pcl::cloud_composer::ToolFactory) - Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") - public: - ModifyItemTool* - createTool (PropertiesModel* parameter_model, QObject* parent = nullptr) override - { - return new SanitizeCloudTool(parameter_model, parent); - } - - PropertiesModel* - createToolParameterModel (QObject* parent) override; - - inline QString - getPluginName () const override { return "Sanitize Cloud";} - - QString - getToolGroupName () const override { return "Filters";} - - QString - getIconName () const override { return ":/sanitize_cloud.png"; } - - inline CloudComposerItem::ItemType - getInputItemType () const override - { - return CloudComposerItem::CLOUD_ITEM; - } - - inline QList - getRequiredInputChildrenTypes () const override - { - return QList (); - } - }; - - - - } + return ":/sanitize_cloud.png"; } + + inline CloudComposerItem::ItemType + getInputItemType() const override + { + return CloudComposerItem::CLOUD_ITEM; + } + + inline QList + getRequiredInputChildrenTypes() const override + { + return QList(); + } +}; + +} // namespace cloud_composer +} // namespace pcl diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/statistical_outlier_removal.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/statistical_outlier_removal.h index 86ce2cbebbd..092edb0634f 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/statistical_outlier_removal.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/statistical_outlier_removal.h @@ -40,63 +40,68 @@ #include #include +namespace pcl { +namespace cloud_composer { +class StatisticalOutlierRemovalTool : public ModifyItemTool { + Q_OBJECT +public: + StatisticalOutlierRemovalTool(PropertiesModel* parameter_model, QObject* parent); -namespace pcl -{ - namespace cloud_composer + QList + performAction(QList input_data, + PointTypeFlags::PointType type = PointTypeFlags::NONE) override; + + inline QString + getToolName() const override { - class StatisticalOutlierRemovalTool : public ModifyItemTool - { - Q_OBJECT - public: - StatisticalOutlierRemovalTool (PropertiesModel* parameter_model, QObject* parent); - - QList - performAction (QList input_data, PointTypeFlags::PointType type = PointTypeFlags::NONE) override; - - inline QString - getToolName () const override { return "Statistical Outlier Removal Tool";} - }; + return "Statistical Outlier Removal Tool"; + } +}; - - class StatisticalOutlierRemovalToolFactory : public QObject, public ToolFactory - { - Q_OBJECT - Q_INTERFACES (pcl::cloud_composer::ToolFactory) - Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") - public: - ModifyItemTool* - createTool (PropertiesModel* parameter_model, QObject* parent = nullptr) override - { - return new StatisticalOutlierRemovalTool(parameter_model, parent); - } - - PropertiesModel* - createToolParameterModel (QObject* parent) override; - - inline QString - getPluginName () const override { return "Statistical Outlier Removal";} - - QString - getToolGroupName () const override { return "Filters";} - - QString - getIconName () const override { return ":/statistical_outlier_removal.png"; } - - inline CloudComposerItem::ItemType - getInputItemType () const override - { - return CloudComposerItem::CLOUD_ITEM; - } - - inline QList - getRequiredInputChildrenTypes () const override - { - return QList (); - } - }; +class StatisticalOutlierRemovalToolFactory : public QObject, public ToolFactory { + Q_OBJECT + Q_INTERFACES(pcl::cloud_composer::ToolFactory) + Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") +public: + ModifyItemTool* + createTool(PropertiesModel* parameter_model, QObject* parent = nullptr) override + { + return new StatisticalOutlierRemovalTool(parameter_model, parent); + } + PropertiesModel* + createToolParameterModel(QObject* parent) override; + inline QString + getPluginName() const override + { + return "Statistical Outlier Removal"; + } + QString + getToolGroupName() const override + { + return "Filters"; } -} + + QString + getIconName() const override + { + return ":/statistical_outlier_removal.png"; + } + + inline CloudComposerItem::ItemType + getInputItemType() const override + { + return CloudComposerItem::CLOUD_ITEM; + } + + inline QList + getRequiredInputChildrenTypes() const override + { + return QList(); + } +}; + +} // namespace cloud_composer +} // namespace pcl diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/supervoxels.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/supervoxels.h index 39c6ea6656c..1383a599a18 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/supervoxels.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/supervoxels.h @@ -1,108 +1,112 @@ - /* - * Software License Agreement (BSD License) - * - * Point Cloud Library (PCL) - www.pointclouds.org - * Copyright (c) 2012, Jeremie Papon. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of Willow Garage, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - +/* + * Software License Agreement (BSD License) + * + * Point Cloud Library (PCL) - www.pointclouds.org + * Copyright (c) 2012, Jeremie Papon. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of Willow Garage, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ + #pragma once - - #include - #include - - - namespace pcl - { - namespace cloud_composer - { - class SupervoxelsTool : public SplitItemTool - { - Q_OBJECT - public: - SupervoxelsTool (PropertiesModel* parameter_model, QObject* parent); - - QList - performAction (QList input_data, PointTypeFlags::PointType type = PointTypeFlags::NONE) override; - - template QList - performTemplatedAction (const QList & input_data); - - inline QString - getToolName () const override { return "Voxel Superpixels Tool";} - - - }; - - - class SupervoxelsToolFactory : public QObject, public ToolFactory - { - Q_OBJECT - Q_INTERFACES (pcl::cloud_composer::ToolFactory) - Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") - public: - SplitItemTool* - createTool (PropertiesModel* parameter_model, QObject* parent = nullptr) override - { - return new SupervoxelsTool(parameter_model, parent); - } - - PropertiesModel* - createToolParameterModel (QObject* parent) override; - - inline QString - getPluginName () const override { return "Supervoxels";} - - inline QString - getToolGroupName () const override { return "Segmentation";} - - inline QString - getIconName () const override { return ":/supervoxels.png"; } - - inline CloudComposerItem::ItemType - getInputItemType () const override - { - return CloudComposerItem::CLOUD_ITEM; - } - - inline QList - getRequiredInputChildrenTypes () const override - { - QList input_types; - return input_types; - } - }; - - - - } - } + +#include +#include + +namespace pcl { +namespace cloud_composer { +class SupervoxelsTool : public SplitItemTool { + Q_OBJECT +public: + SupervoxelsTool(PropertiesModel* parameter_model, QObject* parent); + + QList + performAction(QList input_data, + PointTypeFlags::PointType type = PointTypeFlags::NONE) override; + + template + QList + performTemplatedAction(const QList& input_data); + + inline QString + getToolName() const override + { + return "Voxel Superpixels Tool"; + } +}; + +class SupervoxelsToolFactory : public QObject, public ToolFactory { + Q_OBJECT + Q_INTERFACES(pcl::cloud_composer::ToolFactory) + Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") +public: + SplitItemTool* + createTool(PropertiesModel* parameter_model, QObject* parent = nullptr) override + { + return new SupervoxelsTool(parameter_model, parent); + } + + PropertiesModel* + createToolParameterModel(QObject* parent) override; + + inline QString + getPluginName() const override + { + return "Supervoxels"; + } + + inline QString + getToolGroupName() const override + { + return "Segmentation"; + } + + inline QString + getIconName() const override + { + return ":/supervoxels.png"; + } + + inline CloudComposerItem::ItemType + getInputItemType() const override + { + return CloudComposerItem::CLOUD_ITEM; + } + + inline QList + getRequiredInputChildrenTypes() const override + { + QList input_types; + return input_types; + } +}; + +} // namespace cloud_composer +} // namespace pcl diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/voxel_grid_downsample.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/voxel_grid_downsample.h index 85499ca89b6..8672be64672 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/voxel_grid_downsample.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/voxel_grid_downsample.h @@ -40,62 +40,68 @@ #include #include -namespace pcl -{ - namespace cloud_composer +namespace pcl { +namespace cloud_composer { +class VoxelGridDownsampleTool : public ModifyItemTool { + Q_OBJECT +public: + VoxelGridDownsampleTool(PropertiesModel* parameter_model, QObject* parent); + + QList + performAction(QList input_data, + PointTypeFlags::PointType type = PointTypeFlags::NONE) override; + + inline QString + getToolName() const override + { + return "Voxel Grid Downsample Tool"; + } +}; + +class VoxelGridDownsampleToolFactory : public QObject, public ToolFactory { + Q_OBJECT + Q_INTERFACES(pcl::cloud_composer::ToolFactory) + Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") +public: + ModifyItemTool* + createTool(PropertiesModel* parameter_model, QObject* parent = nullptr) override + { + return new VoxelGridDownsampleTool(parameter_model, parent); + } + + PropertiesModel* + createToolParameterModel(QObject* parent) override; + + inline QString + getPluginName() const override { - class VoxelGridDownsampleTool : public ModifyItemTool - { - Q_OBJECT - public: - VoxelGridDownsampleTool (PropertiesModel* parameter_model, QObject* parent); - - QList - performAction (QList input_data, PointTypeFlags::PointType type = PointTypeFlags::NONE) override; - - inline QString - getToolName () const override { return "Voxel Grid Downsample Tool";} - }; + return "Voxel Grid Downsample"; + } - - class VoxelGridDownsampleToolFactory : public QObject, public ToolFactory - { - Q_OBJECT - Q_INTERFACES (pcl::cloud_composer::ToolFactory) - Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") - public: - ModifyItemTool* - createTool (PropertiesModel* parameter_model, QObject* parent = nullptr) override - { - return new VoxelGridDownsampleTool(parameter_model, parent); - } - - PropertiesModel* - createToolParameterModel (QObject* parent) override; - - inline QString - getPluginName () const override { return "Voxel Grid Downsample";} - - QString - getToolGroupName () const override { return "Filters";} - - QString - getIconName () const override { return ":/voxel_grid_downsample.png"; } - - inline CloudComposerItem::ItemType - getInputItemType () const override - { - return CloudComposerItem::CLOUD_ITEM; - } - - inline QList - getRequiredInputChildrenTypes () const override - { - return QList (); - } - }; + QString + getToolGroupName() const override + { + return "Filters"; + } + QString + getIconName() const override + { + return ":/voxel_grid_downsample.png"; + } + inline CloudComposerItem::ItemType + getInputItemType() const override + { + return CloudComposerItem::CLOUD_ITEM; + } + inline QList + getRequiredInputChildrenTypes() const override + { + return QList(); } -} +}; + +} // namespace cloud_composer +} // namespace pcl diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/transform_clouds.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/transform_clouds.h index e2215296d35..e647b9f0da3 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/transform_clouds.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/transform_clouds.h @@ -39,28 +39,31 @@ #include -namespace pcl -{ - namespace cloud_composer - { - class TransformClouds : public ModifyItemTool - { - Q_OBJECT - public: - TransformClouds (QMap > transform_map, QObject* parent = nullptr); - - QList - performAction (QList input_data, PointTypeFlags::PointType type = PointTypeFlags::NONE) override; - - inline QString - getToolName () const override { return "Transform Clouds Tool";} - - template QList - performTemplatedAction (const QList & input_data); - - private: - QMap > transform_map_; - }; +namespace pcl { +namespace cloud_composer { +class TransformClouds : public ModifyItemTool { + Q_OBJECT +public: + TransformClouds(QMap> transform_map, + QObject* parent = nullptr); + + QList + performAction(QList input_data, + PointTypeFlags::PointType type = PointTypeFlags::NONE) override; + inline QString + getToolName() const override + { + return "Transform Clouds Tool"; } -} + + template + QList + performTemplatedAction(const QList& input_data); + +private: + QMap> transform_map_; +}; + +} // namespace cloud_composer +} // namespace pcl diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/work_queue.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/work_queue.h index 95652a67029..fb6227ca82c 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/work_queue.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/work_queue.h @@ -37,47 +37,42 @@ #pragma once +#include + #include -#include +namespace pcl { +namespace cloud_composer { +class AbstractTool; +class CloudComposerItem; + +struct ActionPair { + CloudCommand* command; + AbstractTool* tool; +}; + +class WorkQueue : public QObject { + Q_OBJECT +public: + WorkQueue(QObject* parent = nullptr); +public Q_SLOTS: + void + enqueueNewAction(AbstractTool* new_tool, ConstItemList input_data); + + void + actionFinished(ActionPair finished_action); + + void + checkQueue(); +Q_SIGNALS: + void + commandProgress(QString command_text, double progress); -namespace pcl -{ - namespace cloud_composer - { - class AbstractTool; - class CloudComposerItem; - - struct ActionPair - { - CloudCommand* command; - AbstractTool* tool; - }; - - class WorkQueue : public QObject - { - Q_OBJECT - public: - WorkQueue (QObject* parent = nullptr); - public Q_SLOTS: - void - enqueueNewAction (AbstractTool* new_tool, ConstItemList input_data); - - void - actionFinished (ActionPair finished_action); - - void - checkQueue (); - Q_SIGNALS: - void - commandProgress (QString command_text, double progress); + void + commandComplete(CloudCommand* completed_command); - void - commandComplete (CloudCommand* completed_command); - - private: - QQueue work_queue_; - - }; - } -} +private: + QQueue work_queue_; +}; +} // namespace cloud_composer +} // namespace pcl diff --git a/apps/cloud_composer/src/cloud_composer.cpp b/apps/cloud_composer/src/cloud_composer.cpp index 1302b59819c..1c551d4db3d 100644 --- a/apps/cloud_composer/src/cloud_composer.cpp +++ b/apps/cloud_composer/src/cloud_composer.cpp @@ -1,14 +1,14 @@ #include -#include -#include #include -#include +#include #include -#include +#include +#include +#include +#include #include +#include #include -#include -#include #include #include @@ -16,215 +16,233 @@ #include ///////////////////////////////////////////////////////////// -pcl::cloud_composer::ComposerMainWindow::ComposerMainWindow (QWidget *parent) - : QMainWindow (parent) +pcl::cloud_composer::ComposerMainWindow::ComposerMainWindow(QWidget* parent) +: QMainWindow(parent) { - setupUi (this); - - this->setCorner (Qt::BottomLeftCorner, Qt::LeftDockWidgetArea); - this->setCorner (Qt::BottomRightCorner, Qt::RightDockWidgetArea); - - //Register types in Qt - qRegisterMetaType ("PCLPointCloud2Ptr"); - qRegisterMetaType ("GeometryHandlerConstPtr"); - qRegisterMetaType ("ColorHandlerConstPtr"); - qRegisterMetaType ("EigenVector4f"); - qRegisterMetaType ("EigenQuaternionf"); - qRegisterMetaType ("ProjectModel"); - qRegisterMetaType ("CloudView"); - qRegisterMetaType ("ConstComposerItemList"); - + setupUi(this); + + this->setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea); + this->setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea); + + // Register types in Qt + qRegisterMetaType("PCLPointCloud2Ptr"); + qRegisterMetaType("GeometryHandlerConstPtr"); + qRegisterMetaType("ColorHandlerConstPtr"); + qRegisterMetaType("EigenVector4f"); + qRegisterMetaType("EigenQuaternionf"); + qRegisterMetaType("ProjectModel"); + qRegisterMetaType("CloudView"); + qRegisterMetaType("ConstComposerItemList"); + current_model_ = nullptr; - - multiplexer_ = new SignalMultiplexer (this); - - initializeCloudBrowser (); - initializeCloudViewer (); - initializeItemInspector (); - initializeToolBox (); - initializePlugins (); - - undo_group_ = new QUndoGroup (this); - undo_view_->setGroup (undo_group_); - - //Auto connect signals and slots - // QMetaObject::connectSlotsByName(this); - connectFileActions (); - connectEditActions (); - connectViewActions (); - + + multiplexer_ = new SignalMultiplexer(this); + + initializeCloudBrowser(); + initializeCloudViewer(); + initializeItemInspector(); + initializeToolBox(); + initializePlugins(); + + undo_group_ = new QUndoGroup(this); + undo_view_->setGroup(undo_group_); + + // Auto connect signals and slots + // QMetaObject::connectSlotsByName(this); + connectFileActions(); + connectEditActions(); + connectViewActions(); } -pcl::cloud_composer::ComposerMainWindow::~ComposerMainWindow () +pcl::cloud_composer::ComposerMainWindow::~ComposerMainWindow() { - foreach (ProjectModel* to_delete, name_model_map_.values ()) - to_delete->deleteLater (); + foreach (ProjectModel* to_delete, name_model_map_.values()) + to_delete->deleteLater(); } void -pcl::cloud_composer::ComposerMainWindow::connectFileActions () -{ - - -} +pcl::cloud_composer::ComposerMainWindow::connectFileActions() +{} void -pcl::cloud_composer::ComposerMainWindow::connectEditActions () +pcl::cloud_composer::ComposerMainWindow::connectEditActions() { - //Replace the actions in the menu with undo actions created using the undo group - QAction* action_temp = undo_group_->createUndoAction (this); - action_temp->setShortcut (action_undo_->shortcut ()); - menuEdit->insertAction (action_redo_, action_temp); - menuEdit->removeAction (action_undo_); + // Replace the actions in the menu with undo actions created using the undo group + QAction* action_temp = undo_group_->createUndoAction(this); + action_temp->setShortcut(action_undo_->shortcut()); + menuEdit->insertAction(action_redo_, action_temp); + menuEdit->removeAction(action_undo_); action_undo_ = action_temp; - - action_temp = undo_group_->createRedoAction (this); - action_temp->setShortcut (action_redo_->shortcut ()); - menuEdit->insertAction (action_redo_, action_temp); - menuEdit->removeAction (action_redo_); + + action_temp = undo_group_->createRedoAction(this); + action_temp->setShortcut(action_redo_->shortcut()); + menuEdit->insertAction(action_redo_, action_temp); + menuEdit->removeAction(action_redo_); action_redo_ = action_temp; - - multiplexer_->connect (action_clear_selection_, SIGNAL (triggered ()), SLOT (clearSelection ())); - - multiplexer_->connect (action_delete_, SIGNAL (triggered ()), SLOT (deleteSelectedItems ())); - multiplexer_->connect (SIGNAL (deleteAvailable (bool)), action_delete_, SLOT (setEnabled (bool))); - - multiplexer_->connect (this, SIGNAL (insertNewCloudFromFile()), SLOT (insertNewCloudFromFile())); - multiplexer_->connect (this, SIGNAL (insertNewCloudFromRGBandDepth()), SLOT (insertNewCloudFromRGBandDepth())); - multiplexer_->connect (this, SIGNAL (saveSelectedCloudToFile()), SLOT (saveSelectedCloudToFile())); - - - mouse_style_group_ = new QActionGroup (this); - mouse_style_group_->addAction (action_trackball_camera_style_); - mouse_style_group_->addAction (action_manipulate_clicked_); - mouse_style_group_->addAction (action_manipulate_selected_); - mouse_style_group_->addAction (action_rectangular_frustum_select_); - mouse_style_group_->setExclusive (true); - multiplexer_->connect (mouse_style_group_, SIGNAL (triggered (QAction*)), SLOT (mouseStyleChanged (QAction*))); - multiplexer_->connect(SIGNAL (mouseStyleState (interactor_styles::INTERACTOR_STYLES)), this, SLOT(setMouseStyleAction(interactor_styles::INTERACTOR_STYLES))); - action_trackball_camera_style_->setData (QVariant::fromValue (interactor_styles::PCL_VISUALIZER)); - action_rectangular_frustum_select_->setData (QVariant::fromValue (interactor_styles::RECTANGULAR_FRUSTUM)); - action_manipulate_selected_->setData (QVariant::fromValue (interactor_styles::SELECTED_TRACKBALL)); - action_manipulate_clicked_->setData (QVariant::fromValue (interactor_styles::CLICK_TRACKBALL)); - //multiplexer_->connect (action_manipulate_selected_, SIGNAL (triggered ()), SLOT (selectedTrackballInteractorStyle ())); - - - multiplexer_->connect (action_new_cloud_from_selection_, SIGNAL (triggered ()), SLOT (createNewCloudFromSelection ())); - multiplexer_->connect (SIGNAL (newCloudFromSelectionAvailable (bool)), action_new_cloud_from_selection_, SLOT (setEnabled (bool))); - - multiplexer_->connect (action_select_all_, SIGNAL (triggered ()), SLOT (selectAllItems ())); + + multiplexer_->connect( + action_clear_selection_, SIGNAL(triggered()), SLOT(clearSelection())); + + multiplexer_->connect( + action_delete_, SIGNAL(triggered()), SLOT(deleteSelectedItems())); + multiplexer_->connect( + SIGNAL(deleteAvailable(bool)), action_delete_, SLOT(setEnabled(bool))); + + multiplexer_->connect( + this, SIGNAL(insertNewCloudFromFile()), SLOT(insertNewCloudFromFile())); + multiplexer_->connect(this, + SIGNAL(insertNewCloudFromRGBandDepth()), + SLOT(insertNewCloudFromRGBandDepth())); + multiplexer_->connect( + this, SIGNAL(saveSelectedCloudToFile()), SLOT(saveSelectedCloudToFile())); + + mouse_style_group_ = new QActionGroup(this); + mouse_style_group_->addAction(action_trackball_camera_style_); + mouse_style_group_->addAction(action_manipulate_clicked_); + mouse_style_group_->addAction(action_manipulate_selected_); + mouse_style_group_->addAction(action_rectangular_frustum_select_); + mouse_style_group_->setExclusive(true); + multiplexer_->connect(mouse_style_group_, + SIGNAL(triggered(QAction*)), + SLOT(mouseStyleChanged(QAction*))); + multiplexer_->connect( + SIGNAL(mouseStyleState(interactor_styles::INTERACTOR_STYLES)), + this, + SLOT(setMouseStyleAction(interactor_styles::INTERACTOR_STYLES))); + action_trackball_camera_style_->setData( + QVariant::fromValue(interactor_styles::PCL_VISUALIZER)); + action_rectangular_frustum_select_->setData( + QVariant::fromValue(interactor_styles::RECTANGULAR_FRUSTUM)); + action_manipulate_selected_->setData( + QVariant::fromValue(interactor_styles::SELECTED_TRACKBALL)); + action_manipulate_clicked_->setData( + QVariant::fromValue(interactor_styles::CLICK_TRACKBALL)); + // multiplexer_->connect (action_manipulate_selected_, SIGNAL (triggered ()), SLOT + // (selectedTrackballInteractorStyle ())); + + multiplexer_->connect(action_new_cloud_from_selection_, + SIGNAL(triggered()), + SLOT(createNewCloudFromSelection())); + multiplexer_->connect(SIGNAL(newCloudFromSelectionAvailable(bool)), + action_new_cloud_from_selection_, + SLOT(setEnabled(bool))); + + multiplexer_->connect( + action_select_all_, SIGNAL(triggered()), SLOT(selectAllItems())); } void -pcl::cloud_composer::ComposerMainWindow::setMouseStyleAction (interactor_styles::INTERACTOR_STYLES selected_style) +pcl::cloud_composer::ComposerMainWindow::setMouseStyleAction( + interactor_styles::INTERACTOR_STYLES selected_style) { - action_trackball_camera_style_->setChecked (false); - action_rectangular_frustum_select_->setChecked (false); - action_manipulate_selected_->setChecked (false); - action_manipulate_clicked_->setChecked (false); - - switch (selected_style) - { - case interactor_styles::PCL_VISUALIZER : - action_trackball_camera_style_->setChecked (true); - break; - case interactor_styles::CLICK_TRACKBALL : - action_manipulate_clicked_->setChecked (true); - break; - case interactor_styles::RECTANGULAR_FRUSTUM : - action_rectangular_frustum_select_->setChecked (true); - break; - case interactor_styles::SELECTED_TRACKBALL : - action_manipulate_selected_->setChecked (true); - break; - default : - action_trackball_camera_style_->setChecked (true); - + action_trackball_camera_style_->setChecked(false); + action_rectangular_frustum_select_->setChecked(false); + action_manipulate_selected_->setChecked(false); + action_manipulate_clicked_->setChecked(false); + + switch (selected_style) { + case interactor_styles::PCL_VISUALIZER: + action_trackball_camera_style_->setChecked(true); + break; + case interactor_styles::CLICK_TRACKBALL: + action_manipulate_clicked_->setChecked(true); + break; + case interactor_styles::RECTANGULAR_FRUSTUM: + action_rectangular_frustum_select_->setChecked(true); + break; + case interactor_styles::SELECTED_TRACKBALL: + action_manipulate_selected_->setChecked(true); + break; + default: + action_trackball_camera_style_->setChecked(true); } } void -pcl::cloud_composer::ComposerMainWindow::connectViewActions () +pcl::cloud_composer::ComposerMainWindow::connectViewActions() { - multiplexer_->connect (action_show_axes_, SIGNAL (toggled (bool)), SLOT (setAxisVisibility (bool))); - multiplexer_->connect (SIGNAL (axisVisible (bool)), action_show_axes_, SLOT (setChecked (bool))); - + multiplexer_->connect( + action_show_axes_, SIGNAL(toggled(bool)), SLOT(setAxisVisibility(bool))); + multiplexer_->connect( + SIGNAL(axisVisible(bool)), action_show_axes_, SLOT(setChecked(bool))); } void -pcl::cloud_composer::ComposerMainWindow::initializeCloudBrowser () +pcl::cloud_composer::ComposerMainWindow::initializeCloudBrowser() { - cloud_browser_->setSelectionMode (QAbstractItemView::ExtendedSelection); - + cloud_browser_->setSelectionMode(QAbstractItemView::ExtendedSelection); + cloud_browser_->setStyleSheet("selection-background-color: red;"); - } void -pcl::cloud_composer::ComposerMainWindow::initializeCloudViewer () +pcl::cloud_composer::ComposerMainWindow::initializeCloudViewer() { - //Signal emitted when user selects new tab (ie different project) in the viewer - connect (cloud_viewer_, SIGNAL (newModelSelected (ProjectModel*)), - this, SLOT (setCurrentModel (ProjectModel*))); - + // Signal emitted when user selects new tab (ie different project) in the viewer + connect(cloud_viewer_, + SIGNAL(newModelSelected(ProjectModel*)), + this, + SLOT(setCurrentModel(ProjectModel*))); } void -pcl::cloud_composer::ComposerMainWindow::initializeItemInspector () -{ - -} +pcl::cloud_composer::ComposerMainWindow::initializeItemInspector() +{} void -pcl::cloud_composer::ComposerMainWindow::initializeToolBox () +pcl::cloud_composer::ComposerMainWindow::initializeToolBox() { - tool_box_model_ = new ToolBoxModel (tool_box_view_, tool_parameter_view_,this); - tool_selection_model_ = new QItemSelectionModel (tool_box_model_); - tool_box_model_->setSelectionModel (tool_selection_model_); - - tool_box_view_->setModel (tool_box_model_); - tool_box_view_->setSelectionModel (tool_selection_model_); - tool_box_view_->setIconSize (QSize (32,32)); - tool_box_view_->setIndentation (10); - - connect ( tool_selection_model_, SIGNAL (currentChanged (const QModelIndex&, const QModelIndex&)), - tool_box_model_, SLOT (selectedToolChanged (const QModelIndex&, const QModelIndex&))); - - connect ( tool_box_model_, SIGNAL (enqueueToolAction (AbstractTool*)), - this, SLOT (enqueueToolAction (AbstractTool*))); - - connect (this, SIGNAL (activeProjectChanged (ProjectModel*,ProjectModel*)), - tool_box_model_, SLOT (activeProjectChanged (ProjectModel*,ProjectModel*))); - - //TODO : Remove this, tools should have a better way of being run - connect ( action_run_tool_, SIGNAL (clicked ()), - tool_box_model_, SLOT (toolAction ())); - //tool_box_view_->setStyleSheet("branch:has-siblings:!adjoins-item:image none"); - // tool_box_view_->setStyleSheet("branch:!has-children:!has-siblings:adjoins-item:image: none"); - - + tool_box_model_ = new ToolBoxModel(tool_box_view_, tool_parameter_view_, this); + tool_selection_model_ = new QItemSelectionModel(tool_box_model_); + tool_box_model_->setSelectionModel(tool_selection_model_); + + tool_box_view_->setModel(tool_box_model_); + tool_box_view_->setSelectionModel(tool_selection_model_); + tool_box_view_->setIconSize(QSize(32, 32)); + tool_box_view_->setIndentation(10); + + connect(tool_selection_model_, + SIGNAL(currentChanged(const QModelIndex&, const QModelIndex&)), + tool_box_model_, + SLOT(selectedToolChanged(const QModelIndex&, const QModelIndex&))); + + connect(tool_box_model_, + SIGNAL(enqueueToolAction(AbstractTool*)), + this, + SLOT(enqueueToolAction(AbstractTool*))); + + connect(this, + SIGNAL(activeProjectChanged(ProjectModel*, ProjectModel*)), + tool_box_model_, + SLOT(activeProjectChanged(ProjectModel*, ProjectModel*))); + + // TODO : Remove this, tools should have a better way of being run + connect(action_run_tool_, SIGNAL(clicked()), tool_box_model_, SLOT(toolAction())); + // tool_box_view_->setStyleSheet("branch:has-siblings:!adjoins-item:image none"); + // tool_box_view_->setStyleSheet("branch:!has-children:!has-siblings:adjoins-item:image: + // none"); } - -void -pcl::cloud_composer::ComposerMainWindow::initializePlugins () +void +pcl::cloud_composer::ComposerMainWindow::initializePlugins() { - QDir plugin_dir = QCoreApplication::applicationDirPath (); - qDebug() << plugin_dir.path ()<< " "< (plugin); + QObject* plugin = loader.instance(); + ToolFactory* tool_factory = qobject_cast(plugin); if (tool_factory) { - qWarning () << "Loaded " << tool_factory->getPluginName (); - //Create the action button for this tool - tool_box_model_->addTool (tool_factory); - + qWarning() << "Loaded " << tool_factory->getPluginName(); + // Create the action button for this tool + tool_box_model_->addTool(tool_factory); } - else{ - qDebug() << "Could not load " << plugin_dir.relativeFilePath (filename); - qDebug() << loader.errorString (); + else { + qDebug() << "Could not load " << plugin_dir.relativeFilePath(filename); + qDebug() << loader.errorString(); } - } } - - -void -pcl::cloud_composer::ComposerMainWindow::setCurrentModel (ProjectModel* model) +void +pcl::cloud_composer::ComposerMainWindow::setCurrentModel(ProjectModel* model) { - emit activeProjectChanged (model, current_model_); + emit activeProjectChanged(model, current_model_); current_model_ = model; - //qDebug () << "Setting cloud browser model"; - cloud_browser_->setModel (current_model_); - //qDebug () << "Setting cloud browser selection model"; - cloud_browser_->setSelectionModel (current_model_->getSelectionModel ()); - //qDebug () << "Item inspector setting model"; - item_inspector_->setModel (current_model_); - //qDebug () << "Setting active stack in undo group"; - undo_group_->setActiveStack (current_model_->getUndoStack ()); - - multiplexer_->setCurrentObject (current_model_); + // qDebug () << "Setting cloud browser model"; + cloud_browser_->setModel(current_model_); + // qDebug () << "Setting cloud browser selection model"; + cloud_browser_->setSelectionModel(current_model_->getSelectionModel()); + // qDebug () << "Item inspector setting model"; + item_inspector_->setModel(current_model_); + // qDebug () << "Setting active stack in undo group"; + undo_group_->setActiveStack(current_model_->getUndoStack()); + + multiplexer_->setCurrentObject(current_model_); } void -pcl::cloud_composer::ComposerMainWindow::enqueueToolAction (AbstractTool* tool) +pcl::cloud_composer::ComposerMainWindow::enqueueToolAction(AbstractTool* tool) { if (current_model_) - current_model_->enqueueToolAction (tool); + current_model_->enqueueToolAction(tool); else - QMessageBox::warning (this, "No Project Open!", "Cannot use tool, no project is open!"); + QMessageBox::warning( + this, "No Project Open!", "Cannot use tool, no project is open!"); } ///////// FILE MENU SLOTS /////////// -void -pcl::cloud_composer::ComposerMainWindow::on_action_new_project__triggered (/*QString name*/) +void pcl::cloud_composer::ComposerMainWindow::on_action_new_project__triggered( + /*QString name*/) { QString name("unsaved project"); - qDebug () << "Creating New Project"; - ProjectModel* new_project_model = new ProjectModel (this); + qDebug() << "Creating New Project"; + ProjectModel* new_project_model = new ProjectModel(this); // Check if we have a project with this name already, append int if so - if (name_model_map_.contains (name)) - { + if (name_model_map_.contains(name)) { int k = 2; - while (name_model_map_.contains (name + tr ("-%1").arg (k))) + while (name_model_map_.contains(name + tr("-%1").arg(k))) ++k; - name += tr ("-%1").arg (k); + name += tr("-%1").arg(k); } - //qDebug () << "Setting name"; - new_project_model->setName (name); - //qDebug () << "Inserting into map"; - name_model_map_.insert (name,new_project_model); - //qDebug () << "Adding to undo group"; - undo_group_->addStack (new_project_model->getUndoStack ()); - //qDebug () << "Setting current model"; - cloud_viewer_->addNewProject (new_project_model); - - setCurrentModel (new_project_model); - //qDebug () << "Project " <setName(name); + // qDebug () << "Inserting into map"; + name_model_map_.insert(name, new_project_model); + // qDebug () << "Adding to undo group"; + undo_group_->addStack(new_project_model->getUndoStack()); + // qDebug () << "Setting current model"; + cloud_viewer_->addNewProject(new_project_model); + + setCurrentModel(new_project_model); + // qDebug () << "Project " <trigger (); - - emit insertNewCloudFromFile (); + action_new_project_->trigger(); + + emit insertNewCloudFromFile(); } void -pcl::cloud_composer::ComposerMainWindow::on_action_insert_from_rgb_depth__triggered () +pcl::cloud_composer::ComposerMainWindow::on_action_insert_from_rgb_depth__triggered() { if (!current_model_) - action_new_project_->trigger (); - - emit insertNewCloudFromRGBandDepth (); -} + action_new_project_->trigger(); + emit insertNewCloudFromRGBandDepth(); +} void -pcl::cloud_composer::ComposerMainWindow::on_action_insert_from_openNi_source__triggered () +pcl::cloud_composer::ComposerMainWindow:: + on_action_insert_from_openNi_source__triggered() { - qDebug () << "Inserting cloud from OpenNi Source..."; + qDebug() << "Inserting cloud from OpenNi Source..."; } - - - diff --git a/apps/cloud_composer/src/cloud_viewer.cpp b/apps/cloud_composer/src/cloud_viewer.cpp index f47c1c053ae..1479ef25847 100644 --- a/apps/cloud_composer/src/cloud_viewer.cpp +++ b/apps/cloud_composer/src/cloud_viewer.cpp @@ -1,66 +1,62 @@ +#include #include #include -#include #include -pcl::cloud_composer::CloudViewer::CloudViewer (QWidget* parent) - : QTabWidget (parent) +pcl::cloud_composer::CloudViewer::CloudViewer(QWidget* parent) : QTabWidget(parent) { - connect (this, SIGNAL (currentChanged (int)), - this, SLOT (modelChanged (int))); + connect(this, SIGNAL(currentChanged(int)), this, SLOT(modelChanged(int))); } void -pcl::cloud_composer::CloudViewer::addModel (ProjectModel* new_model) +pcl::cloud_composer::CloudViewer::addModel(ProjectModel* new_model) { - CloudView* new_view = new CloudView (new_model); - connect (new_model->getSelectionModel (), SIGNAL (selectionChanged (QItemSelection,QItemSelection)), - new_view, SLOT (selectedItemChanged (QItemSelection,QItemSelection))); - new_model->setCloudView (new_view); - - QStandardItem* title = new_model->horizontalHeaderItem (0); - this->addTab (new_view, title->text ()); - - model_view_map_.insert (new_model,new_view); - - setCurrentWidget (model_view_map_.value (new_model)); - //Refresh the view - new_view->refresh (); + CloudView* new_view = new CloudView(new_model); + connect(new_model->getSelectionModel(), + SIGNAL(selectionChanged(QItemSelection, QItemSelection)), + new_view, + SLOT(selectedItemChanged(QItemSelection, QItemSelection))); + new_model->setCloudView(new_view); + + QStandardItem* title = new_model->horizontalHeaderItem(0); + this->addTab(new_view, title->text()); + model_view_map_.insert(new_model, new_view); + + setCurrentWidget(model_view_map_.value(new_model)); + // Refresh the view + new_view->refresh(); } - + pcl::cloud_composer::ProjectModel* -pcl::cloud_composer::CloudViewer::getModel () const +pcl::cloud_composer::CloudViewer::getModel() const { if (this->count() == 0) return nullptr; - return dynamic_cast (currentWidget ())->getModel (); + return dynamic_cast(currentWidget())->getModel(); } void -pcl::cloud_composer::CloudViewer::addNewProject (ProjectModel* new_model) +pcl::cloud_composer::CloudViewer::addNewProject(ProjectModel* new_model) { - //If we're already there, abort - if (new_model == getModel ()) + // If we're already there, abort + if (new_model == getModel()) return; - //Check whether we've seen the model yet - if ( !model_view_map_.contains (new_model)) - { - addModel (new_model); + // Check whether we've seen the model yet + if (!model_view_map_.contains(new_model)) { + addModel(new_model); } - else - { - setCurrentWidget (model_view_map_.value (new_model)); - //Refresh the view - model_view_map_.value (new_model)->refresh (); + else { + setCurrentWidget(model_view_map_.value(new_model)); + // Refresh the view + model_view_map_.value(new_model)->refresh(); } } void -pcl::cloud_composer::CloudViewer::modelChanged (int) +pcl::cloud_composer::CloudViewer::modelChanged(int) { - emit newModelSelected (getModel ()); + emit newModelSelected(getModel()); } - diff --git a/apps/cloud_composer/src/commands.cpp b/apps/cloud_composer/src/commands.cpp index c8a0b9730d0..03ff9c15659 100644 --- a/apps/cloud_composer/src/commands.cpp +++ b/apps/cloud_composer/src/commands.cpp @@ -1,38 +1,32 @@ #include -#include -#include #include +#include +#include -pcl::cloud_composer::CloudCommand::CloudCommand (QList input_data, QUndoCommand* parent) - : QUndoCommand (parent) - , original_data_ (std::move(input_data)) - , can_use_templates_(false) - , template_type_ (-1) -{ - -} +pcl::cloud_composer::CloudCommand::CloudCommand( + QList input_data, QUndoCommand* parent) +: QUndoCommand(parent) +, original_data_(std::move(input_data)) +, can_use_templates_(false) +, template_type_(-1) +{} -pcl::cloud_composer::CloudCommand::~CloudCommand () +pcl::cloud_composer::CloudCommand::~CloudCommand() { - qDebug () << "Command Destructor"; - //If we have removed items, we delete them - if (!last_was_undo_) - { - qDebug () << "Last was redo, removing original items "; - QList items_to_remove = removed_to_parent_map_.keys (); - foreach (QStandardItem* to_remove, items_to_remove) - { - delete to_remove; + qDebug() << "Command Destructor"; + // If we have removed items, we delete them + if (!last_was_undo_) { + qDebug() << "Last was redo, removing original items "; + QList items_to_remove = removed_to_parent_map_.keys(); + foreach (QStandardItem* to_remove, items_to_remove) { + delete to_remove; } } - else - { - qDebug () << "Last was undo, removing new items"; - foreach (OutputPair output_pair, output_data_) - { - QList new_items = output_pair.output_items_; - foreach (CloudComposerItem* item, new_items) - { + else { + qDebug() << "Last was undo, removing new items"; + foreach (OutputPair output_pair, output_data_) { + QList new_items = output_pair.output_items_; + foreach (CloudComposerItem* item, new_items) { delete item; } } @@ -41,44 +35,43 @@ pcl::cloud_composer::CloudCommand::~CloudCommand () ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void -pcl::cloud_composer::CloudCommand::setProjectModel (ProjectModel* model) +pcl::cloud_composer::CloudCommand::setProjectModel(ProjectModel* model) { project_model_ = model; } bool -pcl::cloud_composer::CloudCommand::canUseTemplates (ConstItemList &input_data) +pcl::cloud_composer::CloudCommand::canUseTemplates(ConstItemList& input_data) { - //Make sure the input list isn't empty - if (input_data.empty ()) - { - qCritical () << "Cannot call a templated tool on an empty input in CloudCommand::executeToolOnTemplateCloud!"; + // Make sure the input list isn't empty + if (input_data.empty()) { + qCritical() << "Cannot call a templated tool on an empty input in " + "CloudCommand::executeToolOnTemplateCloud!"; template_type_ = -2; return false; } - //Make sure all input items are clouds - QList cloud_items; - foreach (const CloudComposerItem* item, input_data) - { - const CloudItem* cloud_item = dynamic_cast (item); + // Make sure all input items are clouds + QList cloud_items; + foreach (const CloudComposerItem* item, input_data) { + const CloudItem* cloud_item = dynamic_cast(item); if (cloud_item) - cloud_items.append (cloud_item); + cloud_items.append(cloud_item); } - if (cloud_items.size () != input_data.size ()) - { - qCritical () << "All input items are not clouds in CloudCommand::executeToolOnTemplateCloud!"; + if (cloud_items.size() != input_data.size()) { + qCritical() << "All input items are not clouds in " + "CloudCommand::executeToolOnTemplateCloud!"; template_type_ = -3; return false; } - + // Now make sure all input clouds have the same templated type - int type = cloud_items.value (0)->getPointType (); - foreach (const CloudItem* cloud_item, cloud_items) - { - if (cloud_item->getPointType () != type) - { - qCritical () << "All input point cloud template types in CloudCommand::executeToolOnTemplateCloud are not the same!"; - qCritical () << cloud_item->text () << "'s type does not match "<type (); + int type = cloud_items.value(0)->getPointType(); + foreach (const CloudItem* cloud_item, cloud_items) { + if (cloud_item->getPointType() != type) { + qCritical() << "All input point cloud template types in " + "CloudCommand::executeToolOnTemplateCloud are not the same!"; + qCritical() << cloud_item->text() << "'s type does not match " + << cloud_items.value(0)->type(); template_type_ = -3; return false; } @@ -89,111 +82,114 @@ pcl::cloud_composer::CloudCommand::canUseTemplates (ConstItemList &input_data) } /* -QList -pcl::cloud_composer::CloudCommand::executeToolOnTemplateCloud (AbstractTool* tool, ConstItemList &input_data) +QList +pcl::cloud_composer::CloudCommand::executeToolOnTemplateCloud (AbstractTool* tool, +ConstItemList &input_data) { QList output; // If can_use_templates_ is false and type is -1 we haven't checked if we can yet if (!can_use_templates_ && template_type_ == -1) this->canUseTemplates (input_data); - - + + //If this is true now, we can go ahead and run it if (can_use_templates_ && template_type_ >= 0) { - output = tool->performAction( input_data, static_cast (template_type_)); + output = tool->performAction( input_data, static_cast +(template_type_)); } else { - qDebug () << "Tried CloudCommand::executeToolOnTemplateCloud but input data was not templated clouds!"; + qDebug () << "Tried CloudCommand::executeToolOnTemplateCloud but input data was not +templated clouds!"; } return output; - + } */ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -bool -pcl::cloud_composer::CloudCommand::replaceOriginalWithNew (const QList & originals, const QList & new_items) -{ - //Find the input item's parent - if (originals.empty ()) - { - qCritical () << "No items to replace specified!"; +bool +pcl::cloud_composer::CloudCommand::replaceOriginalWithNew( + const QList& originals, + const QList& new_items) +{ + // Find the input item's parent + if (originals.empty()) { + qCritical() << "No items to replace specified!"; return false; } - - QStandardItem* parent_item = originals.value(0)->parent (); - //Verify that all items have same parent - foreach (const CloudComposerItem* item, originals) - { - if (item->parent () != parent_item) - { - qCritical () << "All original items must have same parent!"; + + QStandardItem* parent_item = originals.value(0)->parent(); + // Verify that all items have same parent + foreach (const CloudComposerItem* item, originals) { + if (item->parent() != parent_item) { + qCritical() << "All original items must have same parent!"; return false; } } // If parent is 0, it's parent is invisiblerootitem (That's how Qt defines it... boo!) if (parent_item == nullptr) - parent_item = project_model_->invisibleRootItem (); - - //Now remove all the originals - foreach (const CloudComposerItem* item, originals) - { - QPersistentModelIndex original_index = QPersistentModelIndex(project_model_->indexFromItem (item)); - if (!original_index.isValid ()) - { - qCritical () << "Index of item to replace is not valid!"; + parent_item = project_model_->invisibleRootItem(); + + // Now remove all the originals + foreach (const CloudComposerItem* item, originals) { + QPersistentModelIndex original_index = + QPersistentModelIndex(project_model_->indexFromItem(item)); + if (!original_index.isValid()) { + qCritical() << "Index of item to replace is not valid!"; return false; } - QList removed_items = parent_item->takeRow (original_index.row ()); - removed_to_parent_map_.insert (removed_items.value(0),parent_item); + QList removed_items = parent_item->takeRow(original_index.row()); + removed_to_parent_map_.insert(removed_items.value(0), parent_item); } - //Insert the new items below the parent item' - foreach (CloudComposerItem* item, new_items) - { - parent_item->appendRow (item); + // Insert the new items below the parent item' + foreach (CloudComposerItem* item, new_items) { + parent_item->appendRow(item); } return true; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -bool -pcl::cloud_composer::CloudCommand::restoreOriginalRemoveNew (const QList & originals, const QList & new_items) -{ - - //Now remove all the new items - foreach (CloudComposerItem* item, new_items) - { - QStandardItem* parent_item = item->parent (); - // If parent is 0, it's parent is invisiblerootitem (That's how Qt defines it... boo!) +bool +pcl::cloud_composer::CloudCommand::restoreOriginalRemoveNew( + const QList& originals, + const QList& new_items) +{ + + // Now remove all the new items + foreach (CloudComposerItem* item, new_items) { + QStandardItem* parent_item = item->parent(); + // If parent is 0, it's parent is invisiblerootitem (That's how Qt defines it... + // boo!) if (parent_item == nullptr) - parent_item = project_model_->invisibleRootItem (); - QPersistentModelIndex to_remove_index = QPersistentModelIndex(project_model_->indexFromItem (item)); - if (!to_remove_index.isValid ()) - { - qCritical () << "Index of item to remove while restoring originals not valid"; + parent_item = project_model_->invisibleRootItem(); + QPersistentModelIndex to_remove_index = + QPersistentModelIndex(project_model_->indexFromItem(item)); + if (!to_remove_index.isValid()) { + qCritical() << "Index of item to remove while restoring originals not valid"; return false; } - //Take them, they're still stored so we don't worry about them - QList removed = parent_item->takeRow (to_remove_index.row ()); - } - //Restore the original items - foreach (const CloudComposerItem* item, originals) - { - //Point iterator to the correct spot - // Find doesn't modify parameter so it should accept a const pointer, but it can't be because it is templated to the map type - // So we hack to get around this with a const cast - const auto& itr = removed_to_parent_map_.find (const_cast (item)); - QStandardItem* parent = itr.value (); - QStandardItem* original = itr.key (); - parent->appendRow (original); - int num = removed_to_parent_map_.remove (original); + // Take them, they're still stored so we don't worry about them + QList removed = parent_item->takeRow(to_remove_index.row()); + } + // Restore the original items + foreach (const CloudComposerItem* item, originals) { + // Point iterator to the correct spot + // Find doesn't modify parameter so it should accept a const pointer, but it can't + // be because it is templated to the map type So we hack to get around this with a + // const cast + const auto& itr = removed_to_parent_map_.find(const_cast(item)); + QStandardItem* parent = itr.value(); + QStandardItem* original = itr.key(); + parent->appendRow(original); + int num = removed_to_parent_map_.remove(original); if (num > 1) - qCritical () << "More than one item with same pointer in removed_to_parent_map_, this is undefined behavior"; - else if (num == 0) - qCritical () << "Could not find key in map to remove, not good!"; + qCritical() << "More than one item with same pointer in removed_to_parent_map_, " + "this is undefined behavior"; + else if (num == 0) + qCritical() << "Could not find key in map to remove, not good!"; } return true; @@ -202,44 +198,42 @@ pcl::cloud_composer::CloudCommand::restoreOriginalRemoveNew (const QList input_data, QUndoCommand* parent) - : CloudCommand (std::move(input_data), parent) -{ - -} +pcl::cloud_composer::ModifyItemCommand::ModifyItemCommand( + QList input_data, QUndoCommand* parent) +: CloudCommand(std::move(input_data), parent) +{} bool -pcl::cloud_composer::ModifyItemCommand::runCommand (AbstractTool* tool) +pcl::cloud_composer::ModifyItemCommand::runCommand(AbstractTool* tool) { - this->setText (tool->getToolName ()); - //For modify item cloud command, each selected item should be processed separately + this->setText(tool->getToolName()); + // For modify item cloud command, each selected item should be processed separately int num_items_returned = 0; - foreach (const CloudComposerItem *item, original_data_) - { - QList input_list; - input_list.append (item); - QList output; + foreach (const CloudComposerItem* item, original_data_) { + QList input_list; + input_list.append(item); + QList output; if (canUseTemplates(input_list)) - output = tool->performAction (input_list, static_cast (template_type_)); + output = tool->performAction( + input_list, static_cast(template_type_)); else - output = tool->performAction (input_list); - if (output.empty ()) - qWarning () << "Warning: Tool " << tool->getToolName () << "returned no item in a ModifyItemCommand"; - else - { + output = tool->performAction(input_list); + if (output.empty()) + qWarning() << "Warning: Tool " << tool->getToolName() + << "returned no item in a ModifyItemCommand"; + else { OutputPair output_pair = {input_list, output}; - output_data_.append (output_pair); + output_data_.append(output_pair); num_items_returned++; } - if (output.size () > 1) - { - qCritical () << "Tool " << tool->getToolName () << "returned multiple items in a ModifyCloudCommand"; + if (output.size() > 1) { + qCritical() << "Tool " << tool->getToolName() + << "returned multiple items in a ModifyCloudCommand"; } - } - if (num_items_returned != original_data_.size ()) - { - qDebug () << "Modify Item command generated "< input_data, QUndoCommand* parent) - : CloudCommand (std::move(input_data), parent) -{ - -} +pcl::cloud_composer::NewItemCloudCommand::NewItemCloudCommand( + QList input_data, QUndoCommand* parent) +: CloudCommand(std::move(input_data), parent) +{} bool -pcl::cloud_composer::NewItemCloudCommand::runCommand (AbstractTool* tool) +pcl::cloud_composer::NewItemCloudCommand::runCommand(AbstractTool* tool) { - this->setText (tool->getToolName ()); - //For new item cloud command, each selected item should be processed separately - //e.g. calculate normals for every selected cloud + this->setText(tool->getToolName()); + // For new item cloud command, each selected item should be processed separately + // e.g. calculate normals for every selected cloud int num_new_items = 0; - foreach (const CloudComposerItem *item, original_data_) - { - QList input_list; - input_list.append (item); - QList output; + foreach (const CloudComposerItem* item, original_data_) { + QList input_list; + input_list.append(item); + QList output; if (canUseTemplates(input_list)) - output = tool->performAction (input_list, static_cast (template_type_)); + output = tool->performAction( + input_list, static_cast(template_type_)); else - output = tool->performAction (input_list); - if (output.empty ()) - qWarning () << "Warning: Tool " << tool->getToolName () << "returned no item in a NewItemCloudCommand"; - else - { + output = tool->performAction(input_list); + if (output.empty()) + qWarning() << "Warning: Tool " << tool->getToolName() + << "returned no item in a NewItemCloudCommand"; + else { OutputPair output_pair = {input_list, output}; - output_data_.append (output_pair); - num_new_items += output.size (); + output_data_.append(output_pair); + num_new_items += output.size(); } - } - if (num_new_items > 0) - { - qDebug () << "New Item command generated "< 0) { + qDebug() << "New Item command generated " << num_new_items << " new items"; return true; } - qWarning () << "New Item command generated no new items!"; + qWarning() << "New Item command generated no new items!"; return false; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void -pcl::cloud_composer::NewItemCloudCommand::undo () +pcl::cloud_composer::NewItemCloudCommand::undo() { last_was_undo_ = true; - qDebug () << "Undo in NewItemCloudCommand"; - foreach (OutputPair output_pair, output_data_) - { - //Each pair can only have one input item, so get it - const CloudComposerItem* const_input_item = output_pair.input_items_.value (0); - QList output_items = output_pair.output_items_; - //Find the input_item index in the project_model_ - QModelIndex input_index = project_model_->indexFromItem (const_input_item); - if (!input_index.isValid ()) - { - qCritical () << "Index of input cloud item is no longer valid, cannot undo NewItemCloudCommand"; + qDebug() << "Undo in NewItemCloudCommand"; + foreach (OutputPair output_pair, output_data_) { + // Each pair can only have one input item, so get it + const CloudComposerItem* const_input_item = output_pair.input_items_.value(0); + QList output_items = output_pair.output_items_; + // Find the input_item index in the project_model_ + QModelIndex input_index = project_model_->indexFromItem(const_input_item); + if (!input_index.isValid()) { + qCritical() << "Index of input cloud item is no longer valid, cannot undo " + "NewItemCloudCommand"; return; } - //Get a copy of the input item we can modify - QStandardItem* item_to_change = project_model_->itemFromIndex (input_index); - //Remove the items we added - foreach (CloudComposerItem* output_item, output_items) - { - QModelIndex output_index = project_model_->indexFromItem (output_item); - item_to_change->takeRow (output_index.row ()); + // Get a copy of the input item we can modify + QStandardItem* item_to_change = project_model_->itemFromIndex(input_index); + // Remove the items we added + foreach (CloudComposerItem* output_item, output_items) { + QModelIndex output_index = project_model_->indexFromItem(output_item); + item_to_change->takeRow(output_index.row()); } - } } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void -pcl::cloud_composer::NewItemCloudCommand::redo () +pcl::cloud_composer::NewItemCloudCommand::redo() { last_was_undo_ = false; - qDebug () << "Redo in NewItemCloudCommand - output data size="< output_items = output_pair.output_items_; - //Find the input_item index in the project_model_ - QPersistentModelIndex input_index = QPersistentModelIndex(project_model_->indexFromItem (const_input_item)); - if (!input_index.isValid ()) - { - qCritical () << "Index of input cloud item is no longer valid upon command completion!"; + qDebug() << "Redo in NewItemCloudCommand - output data size=" << output_data_.size(); + foreach (OutputPair output_pair, output_data_) { + // Each pair can only have one input item, so get it + const CloudComposerItem* const_input_item = output_pair.input_items_.value(0); + QList output_items = output_pair.output_items_; + // Find the input_item index in the project_model_ + QPersistentModelIndex input_index = + QPersistentModelIndex(project_model_->indexFromItem(const_input_item)); + if (!input_index.isValid()) { + qCritical() + << "Index of input cloud item is no longer valid upon command completion!"; return; } - //Get a copy of the input item we can modify - QStandardItem* input_item = (project_model_->itemFromIndex (input_index)); - //Append the output items to the input item - foreach (CloudComposerItem* output_item, output_items) - { - input_item->appendRow (output_item); + // Get a copy of the input item we can modify + QStandardItem* input_item = (project_model_->itemFromIndex(input_index)); + // Append the output items to the input item + foreach (CloudComposerItem* output_item, output_items) { + input_item->appendRow(output_item); } } } - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////// Split CLOUD COMMAND /////////////////////////////////////////////////////////////////////////// +//////////// Split CLOUD COMMAND +////////////////////////////////////////////////////////////////////////////// -pcl::cloud_composer::SplitCloudCommand::SplitCloudCommand (QList input_data, QUndoCommand* parent) - : CloudCommand (std::move(input_data), parent) -{ - -} +pcl::cloud_composer::SplitCloudCommand::SplitCloudCommand( + QList input_data, QUndoCommand* parent) +: CloudCommand(std::move(input_data), parent) +{} bool -pcl::cloud_composer::SplitCloudCommand::runCommand (AbstractTool* tool) +pcl::cloud_composer::SplitCloudCommand::runCommand(AbstractTool* tool) { - this->setText (tool->getToolName ()); - //For split cloud command, each selected item should be processed separately - //e.g. calculate normals for every selected cloud + this->setText(tool->getToolName()); + // For split cloud command, each selected item should be processed separately + // e.g. calculate normals for every selected cloud int num_new_items = 0; - foreach (const CloudComposerItem *item, original_data_) - { - //Check to see if this is a cloud - QList input_list; - input_list.append (item); - QList output; + foreach (const CloudComposerItem* item, original_data_) { + // Check to see if this is a cloud + QList input_list; + input_list.append(item); + QList output; if (canUseTemplates(input_list)) - output = tool->performAction (input_list, static_cast (template_type_)); + output = tool->performAction( + input_list, static_cast(template_type_)); else - output = tool->performAction (input_list); - if (output.empty ()) - qWarning () << "Warning: Tool " << tool->getToolName () << "returned no item in a SplitCloudCommand"; - else - { - qDebug () << "Split command returned "<performAction(input_list); + if (output.empty()) + qWarning() << "Warning: Tool " << tool->getToolName() + << "returned no item in a SplitCloudCommand"; + else { + qDebug() << "Split command returned " << output.size() << " items"; OutputPair output_pair = {input_list, output}; - output_data_.append (output_pair); - num_new_items += output.size (); + output_data_.append(output_pair); + num_new_items += output.size(); } } - if (num_new_items > 0) - { - qDebug () << "Split Item command generated "< 0) { + qDebug() << "Split Item command generated " << num_new_items << " new items"; return true; } - qWarning () << "Split Item command generated no new items!"; + qWarning() << "Split Item command generated no new items!"; return false; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void -pcl::cloud_composer::SplitCloudCommand::undo () +pcl::cloud_composer::SplitCloudCommand::undo() { last_was_undo_ = true; - qDebug () << "Undo in SplitItemCloudCommand"; - foreach (OutputPair output_pair, output_data_) - { - if (!restoreOriginalRemoveNew (output_pair.input_items_, output_pair.output_items_)) - qCritical () << "Failed to restore old cloud in SplitCloudCommand::undo!"; + qDebug() << "Undo in SplitItemCloudCommand"; + foreach (OutputPair output_pair, output_data_) { + if (!restoreOriginalRemoveNew(output_pair.input_items_, output_pair.output_items_)) + qCritical() << "Failed to restore old cloud in SplitCloudCommand::undo!"; } - } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void -pcl::cloud_composer::SplitCloudCommand::redo () +pcl::cloud_composer::SplitCloudCommand::redo() { last_was_undo_ = false; - qDebug () << "Redo in SplitItemCloudCommand - output data size="< input_data, QUndoCommand* parent) - : CloudCommand (std::move(input_data), parent) -{ - -} +pcl::cloud_composer::DeleteItemCommand::DeleteItemCommand( + QList input_data, QUndoCommand* parent) +: CloudCommand(std::move(input_data), parent) +{} bool -pcl::cloud_composer::DeleteItemCommand::runCommand (AbstractTool*) +pcl::cloud_composer::DeleteItemCommand::runCommand(AbstractTool*) { - - //For delete item command, each selected item should be processed separately - //e.g. delete every selected item - foreach (const CloudComposerItem *item, original_data_) - { - QList output; - QList to_delete; - to_delete.append (item); + + // For delete item command, each selected item should be processed separately + // e.g. delete every selected item + foreach (const CloudComposerItem* item, original_data_) { + QList output; + QList to_delete; + to_delete.append(item); OutputPair output_pair = {to_delete, output}; - output_data_.append (output_pair); - this->setText ("Delete "+item->text ()); + output_data_.append(output_pair); + this->setText("Delete " + item->text()); } - if (!original_data_.empty ()) - this->setText ("Delete multiple items"); + if (!original_data_.empty()) + this->setText("Delete multiple items"); return true; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void -pcl::cloud_composer::DeleteItemCommand::undo () +pcl::cloud_composer::DeleteItemCommand::undo() { last_was_undo_ = true; - //Add the original items back into the model - foreach (OutputPair output_pair, output_data_) - { - if (!restoreOriginalRemoveNew (output_pair.input_items_, output_pair.output_items_)) - qCritical () << "Failed to restore items in DeleteItemCommand::undo!"; + // Add the original items back into the model + foreach (OutputPair output_pair, output_data_) { + if (!restoreOriginalRemoveNew(output_pair.input_items_, output_pair.output_items_)) + qCritical() << "Failed to restore items in DeleteItemCommand::undo!"; } } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void -pcl::cloud_composer::DeleteItemCommand::redo () +pcl::cloud_composer::DeleteItemCommand::redo() { last_was_undo_ = false; - qDebug () << "Redo in DeleteItemCommand - num items to delete="< output_items; + // In merge command, input clouds will be combined, so send them to tool together + QList output_items; if (canUseTemplates(original_data_)) - output_items = tool->performAction (original_data_, static_cast (template_type_)); + output_items = tool->performAction( + original_data_, static_cast(template_type_)); else - output_items = tool->performAction (original_data_); - MergeSelection* merge_selection = dynamic_cast (tool); - // If this is a merge selection we need to put the partially selected items into the original data list too! - // We didn't send them before because merge selection already knows about them (and needs to tree input list differently from selected items) - if (merge_selection) - { - QList selected_items = merge_selection->getSelectedItems(); + output_items = tool->performAction(original_data_); + MergeSelection* merge_selection = dynamic_cast(tool); + // If this is a merge selection we need to put the partially selected items into the + // original data list too! We didn't send them before because merge selection already + // knows about them (and needs to tree input list differently from selected items) + if (merge_selection) { + QList selected_items = merge_selection->getSelectedItems(); foreach (const CloudItem* item, selected_items) - original_data_.append (item); + original_data_.append(item); } OutputPair output_pair = {original_data_, output_items}; - output_data_.append (output_pair); - - if (output_items.empty ()) - { - qWarning () << "Warning: Tool " << tool->getToolName () << "returned no item in a MergeCloudCommand"; + output_data_.append(output_pair); + + if (output_items.empty()) { + qWarning() << "Warning: Tool " << tool->getToolName() + << "returned no item in a MergeCloudCommand"; return false; } - - this->setText ("Merge Clouds"); + + this->setText("Merge Clouds"); return true; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void -pcl::cloud_composer::MergeCloudCommand::undo () +pcl::cloud_composer::MergeCloudCommand::undo() { last_was_undo_ = true; - //Add the original items back into the model - foreach (OutputPair output_pair, output_data_) - { - if (!restoreOriginalRemoveNew (output_pair.input_items_, output_pair.output_items_)) - qCritical () << "Failed to restore original clouds in MergeCloudCommand::undo!"; + // Add the original items back into the model + foreach (OutputPair output_pair, output_data_) { + if (!restoreOriginalRemoveNew(output_pair.input_items_, output_pair.output_items_)) + qCritical() << "Failed to restore original clouds in MergeCloudCommand::undo!"; } } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void -pcl::cloud_composer::MergeCloudCommand::redo () +pcl::cloud_composer::MergeCloudCommand::redo() { - qDebug () << "Redo in MergeCloudCommand "; + qDebug() << "Redo in MergeCloudCommand "; last_was_undo_ = false; - //There is only one output_pair, but that's ok - foreach (OutputPair output_pair, output_data_) - { - //Replace the input with the output for this pair - // This works because all input clouds must have same parent, the root item (clouds must be on top level) - if (! replaceOriginalWithNew (output_pair.input_items_, output_pair.output_items_)) - qCritical () << "Removal of items failed in MergeCloudCommand::redo"; - + // There is only one output_pair, but that's ok + foreach (OutputPair output_pair, output_data_) { + // Replace the input with the output for this pair + // This works because all input clouds must have same parent, the root item (clouds + // must be on top level) + if (!replaceOriginalWithNew(output_pair.input_items_, output_pair.output_items_)) + qCritical() << "Removal of items failed in MergeCloudCommand::redo"; } } - diff --git a/apps/cloud_composer/src/item_inspector.cpp b/apps/cloud_composer/src/item_inspector.cpp index c32914f26ce..5851c6da7b2 100644 --- a/apps/cloud_composer/src/item_inspector.cpp +++ b/apps/cloud_composer/src/item_inspector.cpp @@ -3,133 +3,121 @@ #include -pcl::cloud_composer::ItemInspector::ItemInspector (QWidget* parent) - : QTabWidget(parent) +pcl::cloud_composer::ItemInspector::ItemInspector(QWidget* parent) : QTabWidget(parent) { current_item_properties_model_ = nullptr; current_project_model_ = nullptr; current_selection_model_ = nullptr; - - parameter_view_ = new QTreeView (); - addTab (parameter_view_, "Parameters"); - + parameter_view_ = new QTreeView(); + addTab(parameter_view_, "Parameters"); } void -pcl::cloud_composer::ItemInspector::setModel (ProjectModel* new_model) +pcl::cloud_composer::ItemInspector::setModel(ProjectModel* new_model) { // DISABLED: JUST KEEP TREES ALWAYS EXPANDED - //If we have a model loaded, save its tree state - //if (current_item_properties_model_) - // storeTreeState (); - QItemSelectionModel* new_selection_model = new_model->getSelectionModel (); + // If we have a model loaded, save its tree state + // if (current_item_properties_model_) + // storeTreeState (); + QItemSelectionModel* new_selection_model = new_model->getSelectionModel(); current_project_model_ = new_model; - - if (current_selection_model_) - { - disconnect (current_selection_model_, SIGNAL (currentChanged (const QModelIndex, const QModelIndex)), - this, SLOT (selectionChanged (const QModelIndex, const QModelIndex))); - removeTabs (); - + + if (current_selection_model_) { + disconnect(current_selection_model_, + SIGNAL(currentChanged(const QModelIndex, const QModelIndex)), + this, + SLOT(selectionChanged(const QModelIndex, const QModelIndex))); + removeTabs(); } current_selection_model_ = new_selection_model; - connect (current_selection_model_, SIGNAL (currentChanged (const QModelIndex, const QModelIndex)), - this, SLOT (selectionChanged (const QModelIndex,const QModelIndex))); - - updateView (); - + connect(current_selection_model_, + SIGNAL(currentChanged(const QModelIndex, const QModelIndex)), + this, + SLOT(selectionChanged(const QModelIndex, const QModelIndex))); + + updateView(); } void -pcl::cloud_composer::ItemInspector::selectionChanged (const QModelIndex &, const QModelIndex &) +pcl::cloud_composer::ItemInspector::selectionChanged(const QModelIndex&, + const QModelIndex&) { - //If we have a model loaded, save its tree state - // if (current_item_properties_model_) - // storeTreeState (); + // If we have a model loaded, save its tree state + // if (current_item_properties_model_) + // storeTreeState (); if (current_project_model_) - updateView (); - + updateView(); } void -pcl::cloud_composer::ItemInspector::storeTreeState () +pcl::cloud_composer::ItemInspector::storeTreeState() { - QList expanded_list; - int row_count = current_item_properties_model_->rowCount (); - for (int i = 0; i < row_count ; ++i) - { - QModelIndex index = current_item_properties_model_->index (i, 0); - if (parameter_view_->isExpanded (index)) - { - expanded_list << QPersistentModelIndex (index); + QList expanded_list; + int row_count = current_item_properties_model_->rowCount(); + for (int i = 0; i < row_count; ++i) { + QModelIndex index = current_item_properties_model_->index(i, 0); + if (parameter_view_->isExpanded(index)) { + expanded_list << QPersistentModelIndex(index); } } // save list - item_treestate_map_.insert (current_item_properties_model_, expanded_list); + item_treestate_map_.insert(current_item_properties_model_, expanded_list); } void -pcl::cloud_composer::ItemInspector::restoreTreeState () +pcl::cloud_composer::ItemInspector::restoreTreeState() { - if (item_treestate_map_.contains (current_item_properties_model_)) - { - parameter_view_->setUpdatesEnabled (false); - - foreach (QPersistentModelIndex item_index, item_treestate_map_.value (current_item_properties_model_)) - { - if (item_index.isValid ()) - parameter_view_->setExpanded (item_index, true); + if (item_treestate_map_.contains(current_item_properties_model_)) { + parameter_view_->setUpdatesEnabled(false); + + foreach (QPersistentModelIndex item_index, + item_treestate_map_.value(current_item_properties_model_)) { + if (item_index.isValid()) + parameter_view_->setExpanded(item_index, true); } - parameter_view_->setUpdatesEnabled (true); + parameter_view_->setUpdatesEnabled(true); } - } -void -pcl::cloud_composer::ItemInspector::itemChanged (QStandardItem *) -{ - - -} +void +pcl::cloud_composer::ItemInspector::itemChanged(QStandardItem*) +{} void -pcl::cloud_composer::ItemInspector::removeTabs () +pcl::cloud_composer::ItemInspector::removeTabs() { - clear (); - addTab (parameter_view_, "Parameters"); + clear(); + addTab(parameter_view_, "Parameters"); } void -pcl::cloud_composer::ItemInspector::updateView () +pcl::cloud_composer::ItemInspector::updateView() { current_item_properties_model_ = nullptr; - QModelIndex current_item = current_selection_model_->currentIndex (); + QModelIndex current_item = current_selection_model_->currentIndex(); const QStandardItemModel* model = nullptr; CloudComposerItem* cloud_item = nullptr; - if (current_item.isValid ()) - model = dynamic_cast (current_item.model ()); - - if (model) - { - cloud_item = dynamic_cast (model->itemFromIndex (current_item)); - if (cloud_item) - { - current_item_properties_model_ = cloud_item->data (ItemDataRole::PROPERTIES).value (); - //Display any additional graphical data if this item has any - QMap tabs = cloud_item->getInspectorTabs (); - foreach (QString tab_name, tabs.keys ()) - { - addTab (tabs.value (tab_name), tab_name); - tabs.value (tab_name)->show (); + if (current_item.isValid()) + model = dynamic_cast(current_item.model()); + + if (model) { + cloud_item = dynamic_cast(model->itemFromIndex(current_item)); + if (cloud_item) { + current_item_properties_model_ = + cloud_item->data(ItemDataRole::PROPERTIES).value(); + // Display any additional graphical data if this item has any + QMap tabs = cloud_item->getInspectorTabs(); + foreach (QString tab_name, tabs.keys()) { + addTab(tabs.value(tab_name), tab_name); + tabs.value(tab_name)->show(); } } } - - - parameter_view_->setModel (current_item_properties_model_); - parameter_view_->resizeColumnToContents (0); + + parameter_view_->setModel(current_item_properties_model_); + parameter_view_->resizeColumnToContents(0); // restoreTreeState (); - parameter_view_->expandAll (); + parameter_view_->expandAll(); } diff --git a/apps/cloud_composer/src/items/cloud_composer_item.cpp b/apps/cloud_composer/src/items/cloud_composer_item.cpp index 2d5c786f7c5..a87d5a2dba3 100644 --- a/apps/cloud_composer/src/items/cloud_composer_item.cpp +++ b/apps/cloud_composer/src/items/cloud_composer_item.cpp @@ -2,74 +2,74 @@ #include -pcl::cloud_composer::CloudComposerItem::CloudComposerItem (const QString& name) - : QStandardItem(name) +pcl::cloud_composer::CloudComposerItem::CloudComposerItem(const QString& name) +: QStandardItem(name) { - //Set up the properties, store pointer locally for convenience - properties_ = new PropertiesModel (this); - - QString item_id = name + QString ("%1").arg ((long)this); - - - this->setData (QVariant::fromValue (properties_), ItemDataRole::PROPERTIES); - this->setData (QVariant (item_id), ItemDataRole::ITEM_ID); - - this->setForeground (QBrush (Qt::black)); + // Set up the properties, store pointer locally for convenience + properties_ = new PropertiesModel(this); + + QString item_id = name + QString("%1").arg((long)this); + + this->setData(QVariant::fromValue(properties_), ItemDataRole::PROPERTIES); + this->setData(QVariant(item_id), ItemDataRole::ITEM_ID); + + this->setForeground(QBrush(Qt::black)); } -pcl::cloud_composer::CloudComposerItem::~CloudComposerItem () +pcl::cloud_composer::CloudComposerItem::~CloudComposerItem() { - properties_->deleteLater (); + properties_->deleteLater(); } pcl::cloud_composer::CloudComposerItem* -pcl::cloud_composer::CloudComposerItem::clone () const +pcl::cloud_composer::CloudComposerItem::clone() const { - CloudComposerItem* new_item = new CloudComposerItem (this->text ()); - - PropertiesModel* new_item_properties = new_item->getPropertiesModel (); - new_item_properties->copyProperties (properties_); - - return new_item; + CloudComposerItem* new_item = new CloudComposerItem(this->text()); + + PropertiesModel* new_item_properties = new_item->getPropertiesModel(); + new_item_properties->copyProperties(properties_); + + return new_item; } -QList -pcl::cloud_composer::CloudComposerItem::getChildren (CloudComposerItem::ItemType type) const +QList +pcl::cloud_composer::CloudComposerItem::getChildren( + CloudComposerItem::ItemType type) const { - QList items; - for (int i = 0; i < this->rowCount (); ++i) - { - if ( this->child (i)->type () == type ) - { - items.append (dynamic_cast (this->child (i))); + QList items; + for (int i = 0; i < this->rowCount(); ++i) { + if (this->child(i)->type() == type) { + items.append(dynamic_cast(this->child(i))); } } - + return items; } -void -pcl::cloud_composer::CloudComposerItem::addChild (CloudComposerItem *item_arg) +void +pcl::cloud_composer::CloudComposerItem::addChild(CloudComposerItem* item_arg) { - this->appendRow (item_arg); + this->appendRow(item_arg); } void -pcl::cloud_composer::CloudComposerItem::paintView (pcl::visualization::PCLVisualizer::Ptr) const +pcl::cloud_composer::CloudComposerItem::paintView( + pcl::visualization::PCLVisualizer::Ptr) const { - qDebug () << "Paint View in Cloud Composer Item - doing nothing"; + qDebug() << "Paint View in Cloud Composer Item - doing nothing"; } void -pcl::cloud_composer::CloudComposerItem::removeFromView (pcl::visualization::PCLVisualizer::Ptr) const +pcl::cloud_composer::CloudComposerItem::removeFromView( + pcl::visualization::PCLVisualizer::Ptr) const { - qDebug () << "Remove from View in Cloud Composer Item - doing nothing"; + qDebug() << "Remove from View in Cloud Composer Item - doing nothing"; } -QMap -pcl::cloud_composer::CloudComposerItem::getInspectorTabs () +QMap +pcl::cloud_composer::CloudComposerItem::getInspectorTabs() { - return QMap (); + return QMap(); } /* @@ -78,15 +78,13 @@ CloudPtrT pcl::cloud_composer::CloudComposerItem::getCloudPtr () const { QVariant cloud_variant = this->data (CLOUD); - // Get Extract the pointer from the cloud contained in this item, if the type can't be converted, default-constructed value is returned - CloudPtrT ptr; - if (cloud_variant.canConvert ()) - ptr = cloud_variant.value (); + // Get Extract the pointer from the cloud contained in this item, if the type can't be +converted, default-constructed value is returned CloudPtrT ptr; if +(cloud_variant.canConvert ()) ptr = cloud_variant.value (); else - qCritical () << "Requested Cloud of incorrect type from "<text ()<<" correct type is "<text ()<<" correct +type is "< -#include #include -pcl::cloud_composer::FPFHItem::FPFHItem (QString name, const pcl::PointCloud::Ptr& fpfh_ptr, double radius) - : CloudComposerItem (std::move(name)) - , fpfh_ptr_ (fpfh_ptr) - , radius_ (radius) +#include + +pcl::cloud_composer::FPFHItem::FPFHItem( + QString name, + const pcl::PointCloud::Ptr& fpfh_ptr, + double radius) +: CloudComposerItem(std::move(name)), fpfh_ptr_(fpfh_ptr), radius_(radius) { pcl::PointCloud::ConstPtr fpfh_const = fpfh_ptr; - this->setData (QVariant::fromValue (fpfh_const), ItemDataRole::CLOUD_TEMPLATED); - properties_->addCategory ("Core Properties"); - properties_->addProperty ("Radius", QVariant (radius_), Qt::ItemIsEnabled, "Core Properties"); + this->setData(QVariant::fromValue(fpfh_const), ItemDataRole::CLOUD_TEMPLATED); + properties_->addCategory("Core Properties"); + properties_->addProperty( + "Radius", QVariant(radius_), Qt::ItemIsEnabled, "Core Properties"); } pcl::cloud_composer::FPFHItem* -pcl::cloud_composer::FPFHItem::clone () const +pcl::cloud_composer::FPFHItem::clone() const { - pcl::PointCloud::Ptr fpfh_copy (new pcl::PointCloud (*fpfh_ptr_)); - FPFHItem* new_item = new FPFHItem (this->text (), fpfh_copy, radius_); - - PropertiesModel* new_item_properties = new_item->getPropertiesModel (); - new_item_properties->copyProperties (properties_); - - return new_item; + pcl::PointCloud::Ptr fpfh_copy( + new pcl::PointCloud(*fpfh_ptr_)); + FPFHItem* new_item = new FPFHItem(this->text(), fpfh_copy, radius_); + + PropertiesModel* new_item_properties = new_item->getPropertiesModel(); + new_item_properties->copyProperties(properties_); + + return new_item; } -QMap -pcl::cloud_composer::FPFHItem::getInspectorTabs () -{ - //Create the plotter and QVTKWidget if it doesn't exist - if (!plot_) - { - plot_.reset (new pcl::visualization::PCLPlotter); +QMap +pcl::cloud_composer::FPFHItem::getInspectorTabs() +{ + // Create the plotter and QVTKWidget if it doesn't exist + if (!plot_) { + plot_.reset(new pcl::visualization::PCLPlotter); qvtk_ = new PCLQVTKWidget(); - hist_page_ = new QWidget (); - QGridLayout *mainLayout = new QGridLayout (hist_page_); - mainLayout-> addWidget (qvtk_,0,0); + hist_page_ = new QWidget(); + QGridLayout* mainLayout = new QGridLayout(hist_page_); + mainLayout->addWidget(qvtk_, 0, 0); } - //Plot the histogram - plot_->addFeatureHistogram (*fpfh_ptr_, fpfh_ptr_->width, data(ItemDataRole::ITEM_ID).toString().toStdString ()); - //Set the render window of the QVTK widget, update + // Plot the histogram + plot_->addFeatureHistogram(*fpfh_ptr_, + fpfh_ptr_->width, + data(ItemDataRole::ITEM_ID).toString().toStdString()); + // Set the render window of the QVTK widget, update plot_->setViewInteractor(getInteractorCompat(*qvtk_)); setRenderWindowCompat(*qvtk_, *(plot_->getRenderWindow())); #if VTK_MAJOR_VERSION > 8 @@ -50,12 +55,9 @@ pcl::cloud_composer::FPFHItem::getInspectorTabs () #else qvtk_->update(); #endif // VTK_MAJOR_VERSION > 8 - qvtk_->show (); - - - QMap tabs; - tabs.insert ("Histogram",hist_page_); + qvtk_->show(); + + QMap tabs; + tabs.insert("Histogram", hist_page_); return tabs; } - - diff --git a/apps/cloud_composer/src/main.cpp b/apps/cloud_composer/src/main.cpp index 939bad15e72..d16a6f6a146 100644 --- a/apps/cloud_composer/src/main.cpp +++ b/apps/cloud_composer/src/main.cpp @@ -2,12 +2,12 @@ /////////// MAIN //////////////////// int -main (int argc, char ** argv) +main(int argc, char** argv) { // Initialize QT - QApplication app (argc, argv); - + QApplication app(argc, argv); + pcl::cloud_composer::ComposerMainWindow cc; - cc.show (); - return (QApplication::exec ()); + cc.show(); + return (QApplication::exec()); } diff --git a/apps/cloud_composer/src/merge_selection.cpp b/apps/cloud_composer/src/merge_selection.cpp index 63b670f2985..9999d9c67dc 100644 --- a/apps/cloud_composer/src/merge_selection.cpp +++ b/apps/cloud_composer/src/merge_selection.cpp @@ -1,112 +1,110 @@ -#include +#include #include - +#include #include -#include // for pcl::make_shared -#include #include -#include - -pcl::cloud_composer::MergeSelection::MergeSelection (QMap selected_item_index_map, QObject* parent) - : MergeCloudTool (nullptr, parent) - , selected_item_index_map_ (std::move(selected_item_index_map)) -{ +#include // for pcl::make_shared +#include -} +pcl::cloud_composer::MergeSelection::MergeSelection( + QMap selected_item_index_map, + QObject* parent) +: MergeCloudTool(nullptr, parent) +, selected_item_index_map_(std::move(selected_item_index_map)) +{} -QList -pcl::cloud_composer::MergeSelection::performAction (ConstItemList input_data, PointTypeFlags::PointType type) +QList +pcl::cloud_composer::MergeSelection::performAction(ConstItemList input_data, + PointTypeFlags::PointType type) { - if (type != PointTypeFlags::NONE) - { - switch ((std::uint8_t) type) - { - case (PointTypeFlags::XYZ): - return this->performTemplatedAction (input_data); - case (PointTypeFlags::XYZ | PointTypeFlags::RGB): - return this->performTemplatedAction (input_data); - case (PointTypeFlags::XYZ | PointTypeFlags::RGBA): - return this->performTemplatedAction (input_data); + if (type != PointTypeFlags::NONE) { + switch ((std::uint8_t)type) { + case (PointTypeFlags::XYZ): + return this->performTemplatedAction(input_data); + case (PointTypeFlags::XYZ | PointTypeFlags::RGB): + return this->performTemplatedAction(input_data); + case (PointTypeFlags::XYZ | PointTypeFlags::RGBA): + return this->performTemplatedAction(input_data); } } - QList output; + QList output; // Check input data length - if ( input_data.empty () && selected_item_index_map_.isEmpty() ) - { - qCritical () << "Empty input in MergeSelection!"; + if (input_data.empty() && selected_item_index_map_.isEmpty()) { + qCritical() << "Empty input in MergeSelection!"; return output; } - //Make sure all input items are cloud items - foreach (const CloudComposerItem* input_item, input_data) - { - if (input_item->type () != CloudComposerItem::CLOUD_ITEM ) - { - qCritical () << "Input in MergeSelection not valid, contained non-CloudItem input"; + // Make sure all input items are cloud items + foreach (const CloudComposerItem* input_item, input_data) { + if (input_item->type() != CloudComposerItem::CLOUD_ITEM) { + qCritical() << "Input in MergeSelection not valid, contained non-CloudItem input"; return output; } } pcl::ExtractIndices filter; - pcl::PCLPointCloud2::Ptr merged_cloud (new pcl::PCLPointCloud2); - //To Save the pose of the first original item + pcl::PCLPointCloud2::Ptr merged_cloud(new pcl::PCLPointCloud2); + // To Save the pose of the first original item Eigen::Vector4f source_origin; Eigen::Quaternionf source_orientation; bool pose_found = false; - foreach (const CloudItem* input_cloud_item, selected_item_index_map_.keys ()) - { - //If this cloud hasn't been completely selected - if (!input_data.contains (input_cloud_item)) - { - pcl::PCLPointCloud2::ConstPtr input_cloud = input_cloud_item->data (ItemDataRole::CLOUD_BLOB).value (); - qDebug () << "Extracting "<indices.size() << " points out of "<width; - filter.setInputCloud (input_cloud); - filter.setIndices (selected_item_index_map_.value (input_cloud_item)); - pcl::PCLPointCloud2::Ptr original_minus_indices = pcl::make_shared (); - filter.setNegative (true); - filter.filter (*original_minus_indices); - filter.setNegative (false); - pcl::PCLPointCloud2::Ptr selected_points (new pcl::PCLPointCloud2); - filter.filter (*selected_points); + foreach (const CloudItem* input_cloud_item, selected_item_index_map_.keys()) { + // If this cloud hasn't been completely selected + if (!input_data.contains(input_cloud_item)) { + pcl::PCLPointCloud2::ConstPtr input_cloud = + input_cloud_item->data(ItemDataRole::CLOUD_BLOB) + .value(); + qDebug() << "Extracting " + << selected_item_index_map_.value(input_cloud_item)->indices.size() + << " points out of " << input_cloud->width; + filter.setInputCloud(input_cloud); + filter.setIndices(selected_item_index_map_.value(input_cloud_item)); + pcl::PCLPointCloud2::Ptr original_minus_indices = + pcl::make_shared(); + filter.setNegative(true); + filter.filter(*original_minus_indices); + filter.setNegative(false); + pcl::PCLPointCloud2::Ptr selected_points(new pcl::PCLPointCloud2); + filter.filter(*selected_points); - qDebug () << "Original minus indices is "<width; + qDebug() << "Original minus indices is " << original_minus_indices->width; - if (!pose_found) - { - source_origin = input_cloud_item->data (ItemDataRole::ORIGIN).value (); - source_orientation = input_cloud_item->data (ItemDataRole::ORIENTATION).value (); + if (!pose_found) { + source_origin = + input_cloud_item->data(ItemDataRole::ORIGIN).value(); + source_orientation = input_cloud_item->data(ItemDataRole::ORIENTATION) + .value(); pose_found = true; } - CloudItem* new_cloud_item = new CloudItem (input_cloud_item->text () - , original_minus_indices - , source_origin - , source_orientation); - output.append (new_cloud_item); - pcl::PCLPointCloud2::Ptr temp_cloud = pcl::make_shared (); - concatenate (*merged_cloud, *selected_points, *temp_cloud); + CloudItem* new_cloud_item = new CloudItem(input_cloud_item->text(), + original_minus_indices, + source_origin, + source_orientation); + output.append(new_cloud_item); + pcl::PCLPointCloud2::Ptr temp_cloud = pcl::make_shared(); + concatenate(*merged_cloud, *selected_points, *temp_cloud); merged_cloud = temp_cloud; } - //Append the input item to the original list - //input_data.append (input_cloud_item); + // Append the input item to the original list + // input_data.append (input_cloud_item); } - //Just concatenate for all fully selected clouds - foreach (const CloudComposerItem* input_item, input_data) - { - pcl::PCLPointCloud2::ConstPtr input_cloud = input_item->data (ItemDataRole::CLOUD_BLOB).value (); + // Just concatenate for all fully selected clouds + foreach (const CloudComposerItem* input_item, input_data) { + pcl::PCLPointCloud2::ConstPtr input_cloud = + input_item->data(ItemDataRole::CLOUD_BLOB) + .value(); - pcl::PCLPointCloud2::Ptr temp_cloud = pcl::make_shared (); - concatenate (*merged_cloud, *input_cloud, *temp_cloud); + pcl::PCLPointCloud2::Ptr temp_cloud = pcl::make_shared(); + concatenate(*merged_cloud, *input_cloud, *temp_cloud); merged_cloud = temp_cloud; } - CloudItem* cloud_item = new CloudItem ("Cloud from Selection" - , merged_cloud - , source_origin - , source_orientation); + CloudItem* cloud_item = new CloudItem( + "Cloud from Selection", merged_cloud, source_origin, source_orientation); - output.append (cloud_item); + output.append(cloud_item); return output; } diff --git a/apps/cloud_composer/src/point_selectors/click_trackball_interactor_style.cpp b/apps/cloud_composer/src/point_selectors/click_trackball_interactor_style.cpp index 791e0218ad6..96971e09ef2 100644 --- a/apps/cloud_composer/src/point_selectors/click_trackball_interactor_style.cpp +++ b/apps/cloud_composer/src/point_selectors/click_trackball_interactor_style.cpp @@ -4,117 +4,105 @@ #include - #include // For vtkStandardNewMacro #include -namespace pcl -{ - namespace cloud_composer - { - vtkStandardNewMacro(ClickTrackballStyleInteractor); - } +namespace pcl { +namespace cloud_composer { +vtkStandardNewMacro(ClickTrackballStyleInteractor); } +} // namespace pcl -pcl::cloud_composer::ClickTrackballStyleInteractor::ClickTrackballStyleInteractor () +pcl::cloud_composer::ClickTrackballStyleInteractor::ClickTrackballStyleInteractor() { manipulation_complete_event_ = interactor_events::MANIPULATION_COMPLETE_EVENT; - start_matrix_= vtkSmartPointer::New (); - end_matrix_ = vtkSmartPointer::New (); - transform_ = vtkSmartPointer::New (); + start_matrix_ = vtkSmartPointer::New(); + end_matrix_ = vtkSmartPointer::New(); + transform_ = vtkSmartPointer::New(); } void -pcl::cloud_composer::ClickTrackballStyleInteractor::OnLeftButtonDown () +pcl::cloud_composer::ClickTrackballStyleInteractor::OnLeftButtonDown() { vtkInteractorStyleTrackballActor::OnLeftButtonDown(); - + vtkActor* selected_actor = vtkActor::SafeDownCast(this->InteractionProp); if (selected_actor) - selected_actor->GetMatrix (start_matrix_); - + selected_actor->GetMatrix(start_matrix_); } void -pcl::cloud_composer::ClickTrackballStyleInteractor::OnRightButtonDown () +pcl::cloud_composer::ClickTrackballStyleInteractor::OnRightButtonDown() { vtkInteractorStyleTrackballActor::OnRightButtonDown(); - + vtkActor* selected_actor = vtkActor::SafeDownCast(this->InteractionProp); if (selected_actor) - selected_actor->GetMatrix (start_matrix_); - + selected_actor->GetMatrix(start_matrix_); } void -pcl::cloud_composer::ClickTrackballStyleInteractor::OnLeftButtonUp () +pcl::cloud_composer::ClickTrackballStyleInteractor::OnLeftButtonUp() { vtkInteractorStyleTrackballActor::OnLeftButtonUp(); - vtkSmartPointer selected_actor = vtkActor::SafeDownCast(this->InteractionProp); - if (selected_actor) - { - //Fetch the actor we manipulated - - selected_actor->GetMatrix (end_matrix_); + vtkSmartPointer selected_actor = + vtkActor::SafeDownCast(this->InteractionProp); + if (selected_actor) { + // Fetch the actor we manipulated + + selected_actor->GetMatrix(end_matrix_); // Find the id of the actor we manipulated - pcl::visualization::CloudActorMap::const_iterator end = actors_->end (); + pcl::visualization::CloudActorMap::const_iterator end = actors_->end(); QString manipulated_id; - for( pcl::visualization::CloudActorMap::const_iterator itr = actors_->begin (); itr != end; ++itr) - { - //qDebug () << "Id = "<first); - if ( (itr->second).actor == selected_actor) - { - manipulated_id = (QString::fromStdString (itr->first)); - + for (pcl::visualization::CloudActorMap::const_iterator itr = actors_->begin(); + itr != end; + ++itr) { + // qDebug () << "Id = "<first); + if ((itr->second).actor == selected_actor) { + manipulated_id = (QString::fromStdString(itr->first)); } } - if ( !manipulated_id.isEmpty() ) - { - ManipulationEvent* manip_event = new ManipulationEvent (); - manip_event->addManipulation (manipulated_id, start_matrix_, end_matrix_); - this->InvokeEvent (this->manipulation_complete_event_, manip_event); + if (!manipulated_id.isEmpty()) { + ManipulationEvent* manip_event = new ManipulationEvent(); + manip_event->addManipulation(manipulated_id, start_matrix_, end_matrix_); + this->InvokeEvent(this->manipulation_complete_event_, manip_event); } - else - { - qWarning () << "Could not find actor which matches manipulated actor in ClickTrackballStyleInteractor::OnLeftButtonUp!!!"; + else { + qWarning() << "Could not find actor which matches manipulated actor in " + "ClickTrackballStyleInteractor::OnLeftButtonUp!!!"; } } } void -pcl::cloud_composer::ClickTrackballStyleInteractor::OnRightButtonUp () +pcl::cloud_composer::ClickTrackballStyleInteractor::OnRightButtonUp() { vtkInteractorStyleTrackballActor::OnRightButtonUp(); - vtkSmartPointer selected_actor = vtkActor::SafeDownCast(this->InteractionProp); - if (selected_actor) - { - //Fetch the actor we manipulated - - selected_actor->GetMatrix (end_matrix_); + vtkSmartPointer selected_actor = + vtkActor::SafeDownCast(this->InteractionProp); + if (selected_actor) { + // Fetch the actor we manipulated + + selected_actor->GetMatrix(end_matrix_); // Find the id of the actor we manipulated - pcl::visualization::CloudActorMap::const_iterator end = actors_->end (); + pcl::visualization::CloudActorMap::const_iterator end = actors_->end(); QString manipulated_id; - for( pcl::visualization::CloudActorMap::const_iterator itr = actors_->begin (); itr != end; ++itr) - { - //qDebug () << "Id = "<first); - if ( (itr->second).actor == selected_actor) - { - manipulated_id = (QString::fromStdString (itr->first)); - + for (pcl::visualization::CloudActorMap::const_iterator itr = actors_->begin(); + itr != end; + ++itr) { + // qDebug () << "Id = "<first); + if ((itr->second).actor == selected_actor) { + manipulated_id = (QString::fromStdString(itr->first)); } } - if ( !manipulated_id.isEmpty() ) - { - ManipulationEvent* manip_event = new ManipulationEvent (); - manip_event->addManipulation (manipulated_id, start_matrix_, end_matrix_); - this->InvokeEvent (this->manipulation_complete_event_, manip_event); + if (!manipulated_id.isEmpty()) { + ManipulationEvent* manip_event = new ManipulationEvent(); + manip_event->addManipulation(manipulated_id, start_matrix_, end_matrix_); + this->InvokeEvent(this->manipulation_complete_event_, manip_event); } - else - { - qWarning () << "Could not find actor which matches manipulated actor in ClickTrackballStyleInteractor::OnRightButtonUp!!!"; + else { + qWarning() << "Could not find actor which matches manipulated actor in " + "ClickTrackballStyleInteractor::OnRightButtonUp!!!"; } } - } - - diff --git a/apps/cloud_composer/src/point_selectors/interactor_style_switch.cpp b/apps/cloud_composer/src/point_selectors/interactor_style_switch.cpp index 3744a244a32..a04d2d45a27 100644 --- a/apps/cloud_composer/src/point_selectors/interactor_style_switch.cpp +++ b/apps/cloud_composer/src/point_selectors/interactor_style_switch.cpp @@ -1,7 +1,7 @@ +#include #include #include #include -#include #include #include @@ -9,118 +9,113 @@ #include #include -namespace pcl -{ - namespace cloud_composer - { - vtkStandardNewMacro(InteractorStyleSwitch); - } +namespace pcl { +namespace cloud_composer { +vtkStandardNewMacro(InteractorStyleSwitch); } +} // namespace pcl -pcl::cloud_composer::InteractorStyleSwitch::InteractorStyleSwitch () +pcl::cloud_composer::InteractorStyleSwitch::InteractorStyleSwitch() { - pcl_vis_style_ = vtkSmartPointer::New (); - name_to_style_map_.insert (interactor_styles::PCL_VISUALIZER, pcl_vis_style_); - - rectangular_frustum_selector_ = vtkSmartPointer::New (); - name_to_style_map_.insert (interactor_styles::RECTANGULAR_FRUSTUM, rectangular_frustum_selector_); - - selected_trackball_interactor_style_ = vtkSmartPointer ::New (); - name_to_style_map_.insert (interactor_styles::SELECTED_TRACKBALL, selected_trackball_interactor_style_); - - click_trackball_interactor_style_ = vtkSmartPointer ::New (); - name_to_style_map_.insert (interactor_styles::CLICK_TRACKBALL, click_trackball_interactor_style_); - + pcl_vis_style_ = + vtkSmartPointer::New(); + name_to_style_map_.insert(interactor_styles::PCL_VISUALIZER, pcl_vis_style_); + + rectangular_frustum_selector_ = vtkSmartPointer::New(); + name_to_style_map_.insert(interactor_styles::RECTANGULAR_FRUSTUM, + rectangular_frustum_selector_); + + selected_trackball_interactor_style_ = + vtkSmartPointer::New(); + name_to_style_map_.insert(interactor_styles::SELECTED_TRACKBALL, + selected_trackball_interactor_style_); + + click_trackball_interactor_style_ = + vtkSmartPointer::New(); + name_to_style_map_.insert(interactor_styles::CLICK_TRACKBALL, + click_trackball_interactor_style_); + area_picker_ = vtkSmartPointer::New(); - point_picker_ = vtkSmartPointer::New (); - + point_picker_ = vtkSmartPointer::New(); + current_style_ = nullptr; - } void -pcl::cloud_composer::InteractorStyleSwitch::initializeInteractorStyles (pcl::visualization::PCLVisualizer::Ptr vis, ProjectModel* model) +pcl::cloud_composer::InteractorStyleSwitch::initializeInteractorStyles( + pcl::visualization::PCLVisualizer::Ptr vis, ProjectModel* model) { - qDebug () << "Initializing Interactor Styles"; + qDebug() << "Initializing Interactor Styles"; vis_ = std::move(vis); project_model_ = model; - - pcl_vis_style_->Initialize (); - rens_ = vis_->getRendererCollection (); - pcl_vis_style_->setRendererCollection (rens_); - pcl_vis_style_->setCloudActorMap (vis_->getCloudActorMap ()); - - rectangular_frustum_selector_->setCloudActorMap (vis_->getCloudActorMap ()); - - selected_trackball_interactor_style_->setCloudActorMap (vis_->getCloudActorMap ()); - selected_trackball_interactor_style_->setProjectModel (project_model_); - - click_trackball_interactor_style_->setCloudActorMap (vis_->getCloudActorMap ()); - click_trackball_interactor_style_->setProjectModel (project_model_); + + pcl_vis_style_->Initialize(); + rens_ = vis_->getRendererCollection(); + pcl_vis_style_->setRendererCollection(rens_); + pcl_vis_style_->setCloudActorMap(vis_->getCloudActorMap()); + + rectangular_frustum_selector_->setCloudActorMap(vis_->getCloudActorMap()); + + selected_trackball_interactor_style_->setCloudActorMap(vis_->getCloudActorMap()); + selected_trackball_interactor_style_->setProjectModel(project_model_); + + click_trackball_interactor_style_->setCloudActorMap(vis_->getCloudActorMap()); + click_trackball_interactor_style_->setProjectModel(project_model_); } void -pcl::cloud_composer::InteractorStyleSwitch::setCurrentInteractorStyle (interactor_styles::INTERACTOR_STYLES interactor_style) +pcl::cloud_composer::InteractorStyleSwitch::setCurrentInteractorStyle( + interactor_styles::INTERACTOR_STYLES interactor_style) { - qDebug () << "Setting interactor style"; - vtkSmartPointer style_ptr = name_to_style_map_.value (interactor_style); + qDebug() << "Setting interactor style"; + vtkSmartPointer style_ptr = + name_to_style_map_.value(interactor_style); if (current_style_) - current_style_->SetInteractor (nullptr); - current_style_= style_ptr; - - if (current_style_) - { - qDebug () << "Modifying current interactor of style!"; - current_style_->SetInteractor (this->Interactor); - current_style_->SetTDxStyle (this->TDxStyle); - - if (interactor_style == interactor_styles::RECTANGULAR_FRUSTUM) - { - vtkInteractorStyleRubberBandPick* rubber_band_style = vtkInteractorStyleRubberBandPick::SafeDownCast (current_style_); - if (rubber_band_style) - { - vis_->getRenderWindow ()->GetInteractor ()->SetPicker (area_picker_); - rubber_band_style->StartSelect (); + current_style_->SetInteractor(nullptr); + current_style_ = style_ptr; + + if (current_style_) { + qDebug() << "Modifying current interactor of style!"; + current_style_->SetInteractor(this->Interactor); + current_style_->SetTDxStyle(this->TDxStyle); + + if (interactor_style == interactor_styles::RECTANGULAR_FRUSTUM) { + vtkInteractorStyleRubberBandPick* rubber_band_style = + vtkInteractorStyleRubberBandPick::SafeDownCast(current_style_); + if (rubber_band_style) { + vis_->getRenderWindow()->GetInteractor()->SetPicker(area_picker_); + rubber_band_style->StartSelect(); } } - - } - - - } //---------------------------------------------------------------------------- -void -pcl::cloud_composer::InteractorStyleSwitch::SetInteractor (vtkRenderWindowInteractor *iren) +void +pcl::cloud_composer::InteractorStyleSwitch::SetInteractor( + vtkRenderWindowInteractor* iren) { - if(iren == this->Interactor) - { + if (iren == this->Interactor) { return; } // if we already have an Interactor then stop observing it - if(this->Interactor) - { + if (this->Interactor) { this->Interactor->RemoveObserver(this->EventCallbackCommand); } this->Interactor = iren; // add observers for each of the events handled in ProcessEvents - if(iren) - { - iren->AddObserver(vtkCommand::CharEvent, - this->EventCallbackCommand, - this->Priority); - - iren->AddObserver(vtkCommand::DeleteEvent, - this->EventCallbackCommand, - this->Priority); + if (iren) { + iren->AddObserver( + vtkCommand::CharEvent, this->EventCallbackCommand, this->Priority); + + iren->AddObserver( + vtkCommand::DeleteEvent, this->EventCallbackCommand, this->Priority); } } //---------------------------------------------------------------------------- -void -pcl::cloud_composer::InteractorStyleSwitch::SetDefaultRenderer (vtkRenderer* renderer) +void +pcl::cloud_composer::InteractorStyleSwitch::SetDefaultRenderer(vtkRenderer* renderer) { vtkInteractorStyle::SetDefaultRenderer(renderer); pcl_vis_style_->SetDefaultRenderer(renderer); @@ -128,8 +123,8 @@ pcl::cloud_composer::InteractorStyleSwitch::SetDefaultRenderer (vtkRenderer* ren } //---------------------------------------------------------------------------- -void -pcl::cloud_composer::InteractorStyleSwitch::SetCurrentRenderer (vtkRenderer* renderer) +void +pcl::cloud_composer::InteractorStyleSwitch::SetCurrentRenderer(vtkRenderer* renderer) { this->vtkInteractorStyle::SetCurrentRenderer(renderer); pcl_vis_style_->SetCurrentRenderer(renderer); @@ -137,7 +132,7 @@ pcl::cloud_composer::InteractorStyleSwitch::SetCurrentRenderer (vtkRenderer* ren } void -pcl::cloud_composer::InteractorStyleSwitch::OnLeave () +pcl::cloud_composer::InteractorStyleSwitch::OnLeave() { - qDebug () << "ON LEAVE"; + qDebug() << "ON LEAVE"; } diff --git a/apps/cloud_composer/src/point_selectors/manipulation_event.cpp b/apps/cloud_composer/src/point_selectors/manipulation_event.cpp index 7c70d738fa2..f416edfbd10 100644 --- a/apps/cloud_composer/src/point_selectors/manipulation_event.cpp +++ b/apps/cloud_composer/src/point_selectors/manipulation_event.cpp @@ -1,9 +1,11 @@ #include void -pcl::cloud_composer::ManipulationEvent::addManipulation (const QString& id, const vtkSmartPointer& start, const vtkSmartPointer& end) +pcl::cloud_composer::ManipulationEvent::addManipulation( + const QString& id, + const vtkSmartPointer& start, + const vtkSmartPointer& end) { - id_start_map_.insert (id, start); - id_end_map_.insert (id, end); - + id_start_map_.insert(id, start); + id_end_map_.insert(id, end); } diff --git a/apps/cloud_composer/src/point_selectors/rectangular_frustum_selector.cpp b/apps/cloud_composer/src/point_selectors/rectangular_frustum_selector.cpp index 22f0de1c526..74be4073c64 100644 --- a/apps/cloud_composer/src/point_selectors/rectangular_frustum_selector.cpp +++ b/apps/cloud_composer/src/point_selectors/rectangular_frustum_selector.cpp @@ -3,88 +3,90 @@ #include -#include -#include -#include -#include -#include #include +#include +#include #include +#include +#include +#include -namespace pcl -{ - namespace cloud_composer - { - vtkStandardNewMacro(RectangularFrustumSelector); - } +namespace pcl { +namespace cloud_composer { +vtkStandardNewMacro(RectangularFrustumSelector); } +} // namespace pcl -pcl::cloud_composer::RectangularFrustumSelector::RectangularFrustumSelector () +pcl::cloud_composer::RectangularFrustumSelector::RectangularFrustumSelector() { selection_complete_event_ = interactor_events::SELECTION_COMPLETE_EVENT; } void -pcl::cloud_composer::RectangularFrustumSelector::OnLeftButtonUp () +pcl::cloud_composer::RectangularFrustumSelector::OnLeftButtonUp() { - + vtkSmartPointer selected_actor = vtkSmartPointer::New(); - vtkSmartPointer selected_mapper = vtkSmartPointer::New(); + vtkSmartPointer selected_mapper = + vtkSmartPointer::New(); selected_actor->SetMapper(selected_mapper); - - vtkInteractorStyleRubberBandPick::OnLeftButtonUp (); - - vtkPlanes* frustum = static_cast (this->GetInteractor ()->GetPicker ())->GetFrustum (); - - vtkSmartPointer id_filter = vtkSmartPointer::New (); - id_filter->PointIdsOn (); - - vtkSmartPointer extract_geometry = vtkSmartPointer::New (); - extract_geometry->SetImplicitFunction (frustum); - extract_geometry->SetInputConnection (id_filter->GetOutputPort ()); - - vtkSmartPointer glyph_filter = vtkSmartPointer::New (); - glyph_filter->SetInputConnection (extract_geometry->GetOutputPort ()); - - vtkSmartPointer append = vtkAppendPolyData::New (); - - QMap < QString, vtkPolyData* > id_selected_data_map; - for (const auto &actor : *actors_) - { - const pcl::visualization::CloudActor *act = &actor.second; - vtkMapper* mapper = act->actor->GetMapper (); - vtkDataSet* data = mapper->GetInput (); - vtkPolyData* poly_data = vtkPolyData::SafeDownCast (data); - id_filter->SetInputData (poly_data); - - vtkSmartPointer selected = vtkSmartPointer::New (); - glyph_filter->SetOutput (selected); - glyph_filter->Update (); - if (selected->GetNumberOfPoints() > 0) - { - qDebug () << "Selected " << selected->GetNumberOfPoints () << " points."; - id_selected_data_map.insert ( QString::fromStdString (actor.first), selected); - append->AddInputData (selected); - } + + vtkInteractorStyleRubberBandPick::OnLeftButtonUp(); + + vtkPlanes* frustum = + static_cast(this->GetInteractor()->GetPicker())->GetFrustum(); + + vtkSmartPointer id_filter = vtkSmartPointer::New(); + id_filter->PointIdsOn(); + + vtkSmartPointer extract_geometry = + vtkSmartPointer::New(); + extract_geometry->SetImplicitFunction(frustum); + extract_geometry->SetInputConnection(id_filter->GetOutputPort()); + + vtkSmartPointer glyph_filter = + vtkSmartPointer::New(); + glyph_filter->SetInputConnection(extract_geometry->GetOutputPort()); + + vtkSmartPointer append = vtkAppendPolyData::New(); + + QMap id_selected_data_map; + for (const auto& actor : *actors_) { + const pcl::visualization::CloudActor* act = &actor.second; + vtkMapper* mapper = act->actor->GetMapper(); + vtkDataSet* data = mapper->GetInput(); + vtkPolyData* poly_data = vtkPolyData::SafeDownCast(data); + id_filter->SetInputData(poly_data); + + vtkSmartPointer selected = vtkSmartPointer::New(); + glyph_filter->SetOutput(selected); + glyph_filter->Update(); + if (selected->GetNumberOfPoints() > 0) { + qDebug() << "Selected " << selected->GetNumberOfPoints() << " points."; + id_selected_data_map.insert(QString::fromStdString(actor.first), selected); + append->AddInputData(selected); + } } - append->Update (); - vtkSmartPointer all_points = append->GetOutput (); - qDebug () << "Allpoints = " <GetNumberOfPoints (); - - selected_mapper->SetInputData (all_points); - selected_mapper->ScalarVisibilityOff (); - - selected_actor->GetProperty ()->SetColor (0.0, 1.0, 0.0); //(R,G,B) - selected_actor->GetProperty ()->SetPointSize (3); - - this->CurrentRenderer->AddActor (selected_actor); - this->GetInteractor ()->GetRenderWindow ()->Render (); - this->HighlightProp (nullptr); - - if (all_points->GetNumberOfPoints () > 0) - { - SelectionEvent* selected = new SelectionEvent (all_points, selected_actor, selected_mapper, id_selected_data_map, this->CurrentRenderer); - this->InvokeEvent (this->selection_complete_event_, selected); + append->Update(); + vtkSmartPointer all_points = append->GetOutput(); + qDebug() << "Allpoints = " << all_points->GetNumberOfPoints(); + + selected_mapper->SetInputData(all_points); + selected_mapper->ScalarVisibilityOff(); + + selected_actor->GetProperty()->SetColor(0.0, 1.0, 0.0); //(R,G,B) + selected_actor->GetProperty()->SetPointSize(3); + + this->CurrentRenderer->AddActor(selected_actor); + this->GetInteractor()->GetRenderWindow()->Render(); + this->HighlightProp(nullptr); + + if (all_points->GetNumberOfPoints() > 0) { + SelectionEvent* selected = new SelectionEvent(all_points, + selected_actor, + selected_mapper, + id_selected_data_map, + this->CurrentRenderer); + this->InvokeEvent(this->selection_complete_event_, selected); } } - diff --git a/apps/cloud_composer/src/point_selectors/selected_trackball_interactor_style.cpp b/apps/cloud_composer/src/point_selectors/selected_trackball_interactor_style.cpp index 264e5f2f64b..16fef7815e7 100644 --- a/apps/cloud_composer/src/point_selectors/selected_trackball_interactor_style.cpp +++ b/apps/cloud_composer/src/point_selectors/selected_trackball_interactor_style.cpp @@ -4,124 +4,116 @@ #include #include -#include -#include -#include #include +#include +#include +#include #include +#include #include -#include - -namespace pcl -{ - namespace cloud_composer - { - vtkStandardNewMacro(SelectedTrackballStyleInteractor); - } +namespace pcl { +namespace cloud_composer { +vtkStandardNewMacro(SelectedTrackballStyleInteractor); } +} // namespace pcl -pcl::cloud_composer::SelectedTrackballStyleInteractor::SelectedTrackballStyleInteractor () +pcl::cloud_composer::SelectedTrackballStyleInteractor:: + SelectedTrackballStyleInteractor() { - manipulation_complete_event_ = interactor_events::MANIPULATION_COMPLETE_EVENT; + manipulation_complete_event_ = interactor_events::MANIPULATION_COMPLETE_EVENT; } void -pcl::cloud_composer::SelectedTrackballStyleInteractor::setSelectedActors () +pcl::cloud_composer::SelectedTrackballStyleInteractor::setSelectedActors() { - QList selected_cloud_ids; - QModelIndexList selected_indexes = model_->getSelectionModel()->selectedIndexes (); - foreach (QModelIndex index, selected_indexes) - { - QStandardItem* item = model_->itemFromIndex (index); - CloudItem* cloud_item = dynamic_cast (item); + QList selected_cloud_ids; + QModelIndexList selected_indexes = model_->getSelectionModel()->selectedIndexes(); + foreach (QModelIndex index, selected_indexes) { + QStandardItem* item = model_->itemFromIndex(index); + CloudItem* cloud_item = dynamic_cast(item); if (cloud_item) - selected_cloud_ids.append (cloud_item->getId ()); + selected_cloud_ids.append(cloud_item->getId()); } - - for (const auto &actorItem : *actors_) - { - QString id = QString::fromStdString (actorItem.first); - if (selected_cloud_ids.contains (id)) - { + + for (const auto& actorItem : *actors_) { + QString id = QString::fromStdString(actorItem.first); + if (selected_cloud_ids.contains(id)) { vtkLODActor* actor = actorItem.second.actor; - qDebug () << "Adding "<getId ())) - { - vtkPolyData* points_in_item = id_selected_data_map_.value (cloud_item->getId ()); - vtkIdTypeArray* point_ids = vtkIdTypeArray::SafeDownCast(points_in_item->GetPointData ()->GetArray ("vtkIdFilter_Ids")); - - indices->indices.resize (point_ids->GetNumberOfTuples ()); - for(vtkIdType i =0; i < point_ids->GetNumberOfTuples (); ++i) - { - //qDebug () << "id="<GetValue (i); - indices->indices[i] = point_ids->GetValue (i); + if (id_selected_data_map_.contains(cloud_item->getId())) { + vtkPolyData* points_in_item = id_selected_data_map_.value(cloud_item->getId()); + vtkIdTypeArray* point_ids = vtkIdTypeArray::SafeDownCast( + points_in_item->GetPointData()->GetArray("vtkIdFilter_Ids")); + + indices->indices.resize(point_ids->GetNumberOfTuples()); + for (vtkIdType i = 0; i < point_ids->GetNumberOfTuples(); ++i) { + // qDebug () << "id="<GetValue (i); + indices->indices[i] = point_ids->GetValue(i); } - //qDebug () << points_in_item->GetNumberOfPoints () << " selected points in "<getId (); + // qDebug () << points_in_item->GetNumberOfPoints () << " selected points in + // "<getId (); } - } diff --git a/apps/cloud_composer/src/properties_model.cpp b/apps/cloud_composer/src/properties_model.cpp index 5ac24ddb669..b9daf99d721 100644 --- a/apps/cloud_composer/src/properties_model.cpp +++ b/apps/cloud_composer/src/properties_model.cpp @@ -1,126 +1,129 @@ -#include #include +#include #include -pcl::cloud_composer::PropertiesModel::PropertiesModel (QObject* parent) - : QStandardItemModel (parent) +pcl::cloud_composer::PropertiesModel::PropertiesModel(QObject* parent) +: QStandardItemModel(parent) { - setHorizontalHeaderItem (0, new QStandardItem ("Name")); - setHorizontalHeaderItem (1, new QStandardItem ("Value")); + setHorizontalHeaderItem(0, new QStandardItem("Name")); + setHorizontalHeaderItem(1, new QStandardItem("Value")); } -pcl::cloud_composer::PropertiesModel::PropertiesModel (CloudComposerItem* parent_item, QObject* parent) - : QStandardItemModel (parent) - , parent_item_ (parent_item) +pcl::cloud_composer::PropertiesModel::PropertiesModel(CloudComposerItem* parent_item, + QObject* parent) +: QStandardItemModel(parent), parent_item_(parent_item) { - setHorizontalHeaderItem (0, new QStandardItem ("Name")); - setHorizontalHeaderItem (1, new QStandardItem ("Value")); - - connect (this, SIGNAL (itemChanged (QStandardItem*)), - this, SLOT (propertyChanged (QStandardItem*))); + setHorizontalHeaderItem(0, new QStandardItem("Name")); + setHorizontalHeaderItem(1, new QStandardItem("Value")); + + connect(this, + SIGNAL(itemChanged(QStandardItem*)), + this, + SLOT(propertyChanged(QStandardItem*))); } -pcl::cloud_composer::PropertiesModel::PropertiesModel (const PropertiesModel& to_copy) -: QStandardItemModel () +pcl::cloud_composer::PropertiesModel::PropertiesModel(const PropertiesModel& to_copy) +: QStandardItemModel() { - for (int i=0; i < to_copy.rowCount (); ++i){ - QList new_row; - QStandardItem* parent = to_copy.item(i,0); - QModelIndex parent_index = to_copy.index(i,0); - new_row.append (parent->clone ()); - for (int j=0; j < to_copy.columnCount (parent_index); ++j) - { - if (to_copy.item (i,j)) - new_row.append (to_copy.item(i,j)->clone ()); + for (int i = 0; i < to_copy.rowCount(); ++i) { + QList new_row; + QStandardItem* parent = to_copy.item(i, 0); + QModelIndex parent_index = to_copy.index(i, 0); + new_row.append(parent->clone()); + for (int j = 0; j < to_copy.columnCount(parent_index); ++j) { + if (to_copy.item(i, j)) + new_row.append(to_copy.item(i, j)->clone()); } - appendRow (new_row); + appendRow(new_row); } } void -pcl::cloud_composer::PropertiesModel::addProperty (const QString& prop_name, const QVariant& value, Qt::ItemFlags flags, const QString& category) +pcl::cloud_composer::PropertiesModel::addProperty(const QString& prop_name, + const QVariant& value, + Qt::ItemFlags flags, + const QString& category) { - QStandardItem* parent_item = invisibleRootItem (); - if (category.size () > 0) - { - QList items = findItems (category); - if (items.empty ()) - qWarning () << "No category named "<text ()<<" adding to root"; - else if (items.size () > 1) - qCritical () << "Multiple categories with same name found!! This is not good..."; + QStandardItem* parent_item = invisibleRootItem(); + if (category.size() > 0) { + QList items = findItems(category); + if (items.empty()) + qWarning() << "No category named " << prop_name << " found in " + << parent_item_->text() << " adding to root"; + else if (items.size() > 1) + qCritical() << "Multiple categories with same name found!! This is not good..."; else - parent_item = items.at (0); + parent_item = items.at(0); } - QList new_row; - QStandardItem* new_property = new QStandardItem (prop_name); - new_property->setFlags (Qt::ItemIsSelectable); - new_row.append (new_property); - - QStandardItem* new_value = new QStandardItem (); - new_value->setFlags (flags); - new_value->setData (value, Qt::EditRole); - new_row.append (new_value); - - parent_item->appendRow (new_row); + QList new_row; + QStandardItem* new_property = new QStandardItem(prop_name); + new_property->setFlags(Qt::ItemIsSelectable); + new_row.append(new_property); + + QStandardItem* new_value = new QStandardItem(); + new_value->setFlags(flags); + new_value->setData(value, Qt::EditRole); + new_row.append(new_value); + + parent_item->appendRow(new_row); } void -pcl::cloud_composer::PropertiesModel::addCategory (const QString& category_name) +pcl::cloud_composer::PropertiesModel::addCategory(const QString& category_name) { - QStandardItem* new_category = new QStandardItem (category_name); - appendRow (new_category); + QStandardItem* new_category = new QStandardItem(category_name); + appendRow(new_category); } -QVariant -pcl::cloud_composer::PropertiesModel::getProperty (const QString& prop_name) const +QVariant +pcl::cloud_composer::PropertiesModel::getProperty(const QString& prop_name) const { - //qDebug () << "Searching for property " << prop_name; - QList items = findItems (prop_name, Qt::MatchExactly | Qt::MatchRecursive, 0); - if (items.empty ()) - { - qWarning () << "No property named "<text (); - return QVariant (); + // qDebug () << "Searching for property " << prop_name; + QList items = + findItems(prop_name, Qt::MatchExactly | Qt::MatchRecursive, 0); + if (items.empty()) { + qWarning() << "No property named " << prop_name << " found in " + << parent_item_->text(); + return QVariant(); } - if (items.size () > 1) - { - qWarning () << "Multiple properties found with name "<text (); + if (items.size() > 1) { + qWarning() << "Multiple properties found with name " << prop_name << " in " + << parent_item_->text(); } - // qDebug () << "Found properties size ="<text()<< " cols ="<columnCount (); - new_row.append (parent->clone ()); - for (int j=1; j < to_copy->columnCount (); ++j) - { - if (to_copy->item (i,j)) - { - new_row.append (to_copy->item(i,j)->clone ()); + for (int i = 0; i < to_copy->rowCount(); ++i) { + QList new_row; + QStandardItem* parent = to_copy->item(i, 0); + qDebug() << "Copying " << parent->text() << " cols =" << to_copy->columnCount(); + new_row.append(parent->clone()); + for (int j = 1; j < to_copy->columnCount(); ++j) { + if (to_copy->item(i, j)) { + new_row.append(to_copy->item(i, j)->clone()); } } - appendRow (new_row); + appendRow(new_row); } } - void -pcl::cloud_composer::PropertiesModel::propertyChanged (QStandardItem*) +pcl::cloud_composer::PropertiesModel::propertyChanged(QStandardItem*) { - //qDebug () << "Property Changed in properties model"; - parent_item_->propertyChanged (); + // qDebug () << "Property Changed in properties model"; + parent_item_->propertyChanged(); } diff --git a/apps/cloud_composer/src/signal_multiplexer.cpp b/apps/cloud_composer/src/signal_multiplexer.cpp index be0506b6496..16612f078d4 100644 --- a/apps/cloud_composer/src/signal_multiplexer.cpp +++ b/apps/cloud_composer/src/signal_multiplexer.cpp @@ -1,15 +1,14 @@ -#include #include +#include -pcl::cloud_composer::SignalMultiplexer::SignalMultiplexer (QObject* parent) - : QObject (parent) -{ - -} - +pcl::cloud_composer::SignalMultiplexer::SignalMultiplexer(QObject* parent) +: QObject(parent) +{} void -pcl::cloud_composer::SignalMultiplexer::connect (QObject* sender, const char* signal, const char* slot) +pcl::cloud_composer::SignalMultiplexer::connect(QObject* sender, + const char* signal, + const char* slot) { Connection conn; conn.sender = sender; @@ -17,12 +16,13 @@ pcl::cloud_composer::SignalMultiplexer::connect (QObject* sender, const char* si conn.slot = slot; connections << conn; - connect (conn); + connect(conn); } - void -pcl::cloud_composer::SignalMultiplexer::connect (const char* signal, QObject* receiver, const char* slot) +pcl::cloud_composer::SignalMultiplexer::connect(const char* signal, + QObject* receiver, + const char* slot) { Connection conn; conn.receiver = receiver; @@ -30,21 +30,20 @@ pcl::cloud_composer::SignalMultiplexer::connect (const char* signal, QObject* re conn.slot = slot; connections << conn; - connect (conn); + connect(conn); } - bool -pcl::cloud_composer::SignalMultiplexer::disconnect (QObject* sender, const char* signal, const char* slot) +pcl::cloud_composer::SignalMultiplexer::disconnect(QObject* sender, + const char* signal, + const char* slot) { - QMutableListIterator it (connections); - while (it.hasNext ()) - { + QMutableListIterator it(connections); + while (it.hasNext()) { Connection conn = it.next(); - if ( (QObject*) conn.sender == sender && - qstrcmp (conn.signal, signal) == 0 && qstrcmp (conn.slot, slot) == 0) - { - disconnect (conn); + if ((QObject*)conn.sender == sender && qstrcmp(conn.signal, signal) == 0 && + qstrcmp(conn.slot, slot) == 0) { + disconnect(conn); it.remove(); return true; } @@ -52,18 +51,17 @@ pcl::cloud_composer::SignalMultiplexer::disconnect (QObject* sender, const char* return false; } - bool -pcl::cloud_composer::SignalMultiplexer::disconnect (const char* signal, QObject* receiver, const char* slot) +pcl::cloud_composer::SignalMultiplexer::disconnect(const char* signal, + QObject* receiver, + const char* slot) { - QMutableListIterator it (connections); - while (it.hasNext ()) - { + QMutableListIterator it(connections); + while (it.hasNext()) { Connection conn = it.next(); - if ( (QObject*) conn.receiver == receiver && - qstrcmp (conn.signal, signal) == 0 && qstrcmp (conn.slot, slot) == 0) - { - disconnect (conn); + if ((QObject*)conn.receiver == receiver && qstrcmp(conn.signal, signal) == 0 && + qstrcmp(conn.slot, slot) == 0) { + disconnect(conn); it.remove(); return true; } @@ -71,9 +69,8 @@ pcl::cloud_composer::SignalMultiplexer::disconnect (const char* signal, QObject* return false; } - void -pcl::cloud_composer::SignalMultiplexer::connect (const Connection& conn) +pcl::cloud_composer::SignalMultiplexer::connect(const Connection& conn) { if (!object) return; @@ -81,14 +78,13 @@ pcl::cloud_composer::SignalMultiplexer::connect (const Connection& conn) return; if (conn.sender) - QObject::connect ( (QObject*) conn.sender, conn.signal, (QObject*) object, conn.slot); + QObject::connect((QObject*)conn.sender, conn.signal, (QObject*)object, conn.slot); else - QObject::connect ( (QObject*) object, conn.signal, (QObject*) conn.receiver, conn.slot); + QObject::connect((QObject*)object, conn.signal, (QObject*)conn.receiver, conn.slot); } - -void -pcl::cloud_composer::SignalMultiplexer::disconnect (const Connection& conn) +void +pcl::cloud_composer::SignalMultiplexer::disconnect(const Connection& conn) { if (!object) return; @@ -96,29 +92,29 @@ pcl::cloud_composer::SignalMultiplexer::disconnect (const Connection& conn) return; if (conn.sender) - QObject::disconnect ( (QObject*) conn.sender, conn.signal, (QObject*) object, conn.slot); + QObject::disconnect( + (QObject*)conn.sender, conn.signal, (QObject*)object, conn.slot); else - QObject::disconnect ( (QObject*) object, conn.signal, (QObject*) conn.receiver, conn.slot); - + QObject::disconnect( + (QObject*)object, conn.signal, (QObject*)conn.receiver, conn.slot); } - -void -pcl::cloud_composer::SignalMultiplexer::setCurrentObject (QObject* newObject) +void +pcl::cloud_composer::SignalMultiplexer::setCurrentObject(QObject* newObject) { if (newObject == object) return; - for (const auto &connection : connections) - disconnect (connection); + for (const auto& connection : connections) + disconnect(connection); object = newObject; - for (const auto &connection : connections) - connect (connection); + for (const auto& connection : connections) + connect(connection); - ProjectModel* model = dynamic_cast (newObject); + ProjectModel* model = dynamic_cast(newObject); if (model) - model->emitAllStateSignals (); - - //let the world know about who's on top now - emit currentObjectChanged (object); + model->emitAllStateSignals(); + + // let the world know about who's on top now + emit currentObjectChanged(object); } diff --git a/apps/cloud_composer/src/tool_interface/abstract_tool.cpp b/apps/cloud_composer/src/tool_interface/abstract_tool.cpp index 8a23d6947db..21708ef50ca 100644 --- a/apps/cloud_composer/src/tool_interface/abstract_tool.cpp +++ b/apps/cloud_composer/src/tool_interface/abstract_tool.cpp @@ -1,23 +1,21 @@ #include -pcl::cloud_composer::AbstractTool::AbstractTool (PropertiesModel* parameter_model, QObject* parent) - : QObject (parent) - +pcl::cloud_composer::AbstractTool::AbstractTool(PropertiesModel* parameter_model, + QObject* parent) +: QObject(parent) + { - parameter_model_ = new PropertiesModel (this); - //If there's a model copy it into the local copy - if (parameter_model) - { + parameter_model_ = new PropertiesModel(this); + // If there's a model copy it into the local copy + if (parameter_model) { parameter_model_->copyProperties(parameter_model); - } - - } -QList -pcl::cloud_composer::AbstractTool::performAction (QList , PointTypeFlags::PointType) +QList +pcl::cloud_composer::AbstractTool::performAction(QList, + PointTypeFlags::PointType) { - qDebug () << "AbstractTool::performTemplatedAction"; - return QList (); + qDebug() << "AbstractTool::performTemplatedAction"; + return QList(); } diff --git a/apps/cloud_composer/src/toolbox_model.cpp b/apps/cloud_composer/src/toolbox_model.cpp index dd70fbd2c13..8e3f70bd33e 100644 --- a/apps/cloud_composer/src/toolbox_model.cpp +++ b/apps/cloud_composer/src/toolbox_model.cpp @@ -1,247 +1,242 @@ -#include +#include +#include #include #include -#include -#include +#include #include #include -pcl::cloud_composer::ToolBoxModel::ToolBoxModel (QTreeView* tool_view, QTreeView* parameter_view_, QObject* parent) -: QStandardItemModel (parent) -, tool_view_ (tool_view) -, parameter_view_ (parameter_view_) -, project_model_ (nullptr) -{ - -} +pcl::cloud_composer::ToolBoxModel::ToolBoxModel(QTreeView* tool_view, + QTreeView* parameter_view_, + QObject* parent) +: QStandardItemModel(parent) +, tool_view_(tool_view) +, parameter_view_(parameter_view_) +, project_model_(nullptr) +{} -pcl::cloud_composer::ToolBoxModel::ToolBoxModel (const ToolBoxModel&) -: QStandardItemModel () -{ -} +pcl::cloud_composer::ToolBoxModel::ToolBoxModel(const ToolBoxModel&) +: QStandardItemModel() +{} void -pcl::cloud_composer::ToolBoxModel::addTool (ToolFactory* tool_factory) +pcl::cloud_composer::ToolBoxModel::addTool(ToolFactory* tool_factory) { - //qDebug () << "Icon name:"<< tool_factory->getIconName (); - QIcon new_tool_icon = QIcon (tool_factory->getIconName ()); - QStandardItem* new_tool_item = new QStandardItem (new_tool_icon, tool_factory->getPluginName ()); - new_tool_item->setEditable (false); - - new_tool_item->setData (QVariant::fromValue (tool_factory), FACTORY); - PropertiesModel* new_tool_parameters= tool_factory->createToolParameterModel (this); - new_tool_item->setData (QVariant::fromValue (new_tool_parameters), PARAMETER_MODEL); - - tool_items.insert (new_tool_item); - QStandardItem* group_item = addToolGroup (tool_factory->getToolGroupName ()); - group_item->appendRow (new_tool_item); - //Expand the view for this tool group + // qDebug () << "Icon name:"<< tool_factory->getIconName (); + QIcon new_tool_icon = QIcon(tool_factory->getIconName()); + QStandardItem* new_tool_item = + new QStandardItem(new_tool_icon, tool_factory->getPluginName()); + new_tool_item->setEditable(false); + + new_tool_item->setData(QVariant::fromValue(tool_factory), FACTORY); + PropertiesModel* new_tool_parameters = tool_factory->createToolParameterModel(this); + new_tool_item->setData(QVariant::fromValue(new_tool_parameters), PARAMETER_MODEL); + + tool_items.insert(new_tool_item); + QStandardItem* group_item = addToolGroup(tool_factory->getToolGroupName()); + group_item->appendRow(new_tool_item); + // Expand the view for this tool group QModelIndex group_index = this->indexFromItem(group_item); - tool_view_->setExpanded (group_index, true); + tool_view_->setExpanded(group_index, true); } void -pcl::cloud_composer::ToolBoxModel::setSelectionModel (QItemSelectionModel* selection_model) +pcl::cloud_composer::ToolBoxModel::setSelectionModel( + QItemSelectionModel* selection_model) { selection_model_ = selection_model; } - + QStandardItem* -pcl::cloud_composer::ToolBoxModel::addToolGroup (const QString& tool_group_name) +pcl::cloud_composer::ToolBoxModel::addToolGroup(const QString& tool_group_name) { - QList matches_name = findItems (tool_group_name); - if (matches_name.empty ()) - { - QStandardItem* new_group_item = new QStandardItem (tool_group_name); - appendRow (new_group_item); - new_group_item->setSelectable (false); - new_group_item->setEditable (false); + QList matches_name = findItems(tool_group_name); + if (matches_name.empty()) { + QStandardItem* new_group_item = new QStandardItem(tool_group_name); + appendRow(new_group_item); + new_group_item->setSelectable(false); + new_group_item->setEditable(false); return new_group_item; } - if (matches_name.size () > 1) - { - qWarning () << "Multiple tool groups with same name in ToolBoxModel!!"; + if (matches_name.size() > 1) { + qWarning() << "Multiple tool groups with same name in ToolBoxModel!!"; } - - return matches_name.value (0); - + + return matches_name.value(0); } -void -pcl::cloud_composer::ToolBoxModel::activeProjectChanged(ProjectModel* new_model, ProjectModel*) +void +pcl::cloud_composer::ToolBoxModel::activeProjectChanged(ProjectModel* new_model, + ProjectModel*) { - //Disconnect old project model signal for selection change - if (project_model_) - { - disconnect (project_model_->getSelectionModel (), SIGNAL (selectionChanged (QItemSelection,QItemSelection)), - this, SLOT (selectedItemChanged (QItemSelection,QItemSelection))); - disconnect (project_model_, SIGNAL (modelChanged()), - this, SLOT (modelChanged())); - - } - qDebug () << "Active project changed in ToolBox Model!"; - project_model_ = new_model; - - //Update enabled tools, make connection for doing this automatically - if (project_model_) - { - updateEnabledTools (project_model_->getSelectionModel ()->selection ()); - connect (project_model_->getSelectionModel (), SIGNAL (selectionChanged (QItemSelection,QItemSelection)), - this, SLOT (selectedItemChanged (QItemSelection,QItemSelection))); - connect (project_model_, SIGNAL (modelChanged()), - this, SLOT (modelChanged())); + // Disconnect old project model signal for selection change + if (project_model_) { + disconnect(project_model_->getSelectionModel(), + SIGNAL(selectionChanged(QItemSelection, QItemSelection)), + this, + SLOT(selectedItemChanged(QItemSelection, QItemSelection))); + disconnect(project_model_, SIGNAL(modelChanged()), this, SLOT(modelChanged())); } + qDebug() << "Active project changed in ToolBox Model!"; + project_model_ = new_model; + // Update enabled tools, make connection for doing this automatically + if (project_model_) { + updateEnabledTools(project_model_->getSelectionModel()->selection()); + connect(project_model_->getSelectionModel(), + SIGNAL(selectionChanged(QItemSelection, QItemSelection)), + this, + SLOT(selectedItemChanged(QItemSelection, QItemSelection))); + connect(project_model_, SIGNAL(modelChanged()), this, SLOT(modelChanged())); + } } void -pcl::cloud_composer::ToolBoxModel::selectedToolChanged (const QModelIndex & current, const QModelIndex &) +pcl::cloud_composer::ToolBoxModel::selectedToolChanged(const QModelIndex& current, + const QModelIndex&) { - //qDebug() << "Selected Tool changed"; - if (!parameter_view_) - { - qCritical () << "Toolbox parameter view not set!!!"; + // qDebug() << "Selected Tool changed"; + if (!parameter_view_) { + qCritical() << "Toolbox parameter view not set!!!"; return; - } - QVariant parameter_model = current.data (PARAMETER_MODEL); - parameter_view_->setModel ( parameter_model.value ()); - parameter_view_->expandAll (); + } + QVariant parameter_model = current.data(PARAMETER_MODEL); + parameter_view_->setModel(parameter_model.value()); + parameter_view_->expandAll(); } - void -pcl::cloud_composer::ToolBoxModel::toolAction () +pcl::cloud_composer::ToolBoxModel::toolAction() { - QModelIndex current_index = selection_model_->currentIndex (); - if (!current_index.isValid ()) - { - QMessageBox::warning (qobject_cast(this->parent ()), "No Tool Selected", "Cannot execute action, no tool selected!"); + QModelIndex current_index = selection_model_->currentIndex(); + if (!current_index.isValid()) { + QMessageBox::warning(qobject_cast(this->parent()), + "No Tool Selected", + "Cannot execute action, no tool selected!"); return; } - ToolFactory* tool_factory = (current_index.data (FACTORY)).value (); - PropertiesModel* parameter_model = (current_index.data (PARAMETER_MODEL)).value (); + ToolFactory* tool_factory = (current_index.data(FACTORY)).value(); + PropertiesModel* parameter_model = + (current_index.data(PARAMETER_MODEL)).value(); // - AbstractTool* tool = tool_factory->createTool (parameter_model); - - emit enqueueToolAction (tool); + AbstractTool* tool = tool_factory->createTool(parameter_model); + + emit enqueueToolAction(tool); } -void -pcl::cloud_composer::ToolBoxModel::selectedItemChanged ( const QItemSelection & selected, const QItemSelection &) +void +pcl::cloud_composer::ToolBoxModel::selectedItemChanged(const QItemSelection& selected, + const QItemSelection&) { - updateEnabledTools (selected); + updateEnabledTools(selected); } -void -pcl::cloud_composer::ToolBoxModel::enableAllTools () +void +pcl::cloud_composer::ToolBoxModel::enableAllTools() { - foreach (QStandardItem* tool, tool_items) - { - tool->setEnabled (true); + foreach (QStandardItem* tool, tool_items) { + tool->setEnabled(true); } } void -pcl::cloud_composer::ToolBoxModel::modelChanged () +pcl::cloud_composer::ToolBoxModel::modelChanged() { - updateEnabledTools (project_model_->getSelectionModel ()->selection ()); + updateEnabledTools(project_model_->getSelectionModel()->selection()); } void -pcl::cloud_composer::ToolBoxModel::updateEnabledTools (const QItemSelection& current_selection) +pcl::cloud_composer::ToolBoxModel::updateEnabledTools( + const QItemSelection& current_selection) { - //qDebug () << "UPDATING ENABLED TOOLS!"; - QModelIndexList current_indices = current_selection.indexes (); - QMultiMap < int, QStandardItem* > type_items_map; - foreach (QModelIndex current, current_indices) - { - if (current.isValid ()) - { - QStandardItem* current_item = project_model_->itemFromIndex (current); - type_items_map.insert (current_item->type (), current_item); + // qDebug () << "UPDATING ENABLED TOOLS!"; + QModelIndexList current_indices = current_selection.indexes(); + QMultiMap type_items_map; + foreach (QModelIndex current, current_indices) { + if (current.isValid()) { + QStandardItem* current_item = project_model_->itemFromIndex(current); + type_items_map.insert(current_item->type(), current_item); } } - enableAllTools (); - QList enabled_tools = tool_items.values (); - QMap disabled_tools; + enableAllTools(); + QList enabled_tools = tool_items.values(); + QMap disabled_tools; QMutableListIterator enabled_itr(enabled_tools); - //Go through tools, removing from enabled list if they fail to pass tests - while (enabled_itr.hasNext()) - { - QStandardItem* tool_item = enabled_itr.next (); - ToolFactory* tool_factory = (tool_item->data (FACTORY)).value (); - CloudComposerItem::ItemType input_type = tool_factory->getInputItemType (); - QList required_children_types = tool_factory->getRequiredInputChildrenTypes(); - //Check if enough items for tool are selected - if ( tool_factory-> getNumInputItems() > current_indices.size() ) - { - enabled_itr.remove (); - disabled_tools.insert (tool_item, tr("Tool Requires %1 Items (%2 Selected)").arg(tool_factory-> getNumInputItems()).arg(current_indices.size ())); + // Go through tools, removing from enabled list if they fail to pass tests + while (enabled_itr.hasNext()) { + QStandardItem* tool_item = enabled_itr.next(); + ToolFactory* tool_factory = (tool_item->data(FACTORY)).value(); + CloudComposerItem::ItemType input_type = tool_factory->getInputItemType(); + QList required_children_types = + tool_factory->getRequiredInputChildrenTypes(); + // Check if enough items for tool are selected + if (tool_factory->getNumInputItems() > current_indices.size()) { + enabled_itr.remove(); + disabled_tools.insert(tool_item, + tr("Tool Requires %1 Items (%2 Selected)") + .arg(tool_factory->getNumInputItems()) + .arg(current_indices.size())); } - //Check if selection includes at least one item with correct input type - else if ( ! type_items_map.keys ().contains (input_type)) - { - enabled_itr.remove (); - disabled_tools.insert (tool_item, tr("Tool Requires item type %1 selected").arg (ITEM_TYPES_STRINGS.value (input_type - CloudComposerItem::CLOUD_COMPOSER_ITEM))); + // Check if selection includes at least one item with correct input type + else if (!type_items_map.keys().contains(input_type)) { + enabled_itr.remove(); + disabled_tools.insert( + tool_item, + tr("Tool Requires item type %1 selected") + .arg(ITEM_TYPES_STRINGS.value(input_type - + CloudComposerItem::CLOUD_COMPOSER_ITEM))); } - //Check if any of selected items have required children - else if ( !required_children_types.empty ()) - { - QList matching_selected_items = type_items_map.values (input_type); + // Check if any of selected items have required children + else if (!required_children_types.empty()) { + QList matching_selected_items = type_items_map.values(input_type); bool found_valid_items = false; - QList missing_children = required_children_types; - foreach (QStandardItem* item, matching_selected_items) - { - QList found_children_types; - if (!item->hasChildren ()) + QList missing_children = required_children_types; + foreach (QStandardItem* item, matching_selected_items) { + QList found_children_types; + if (!item->hasChildren()) continue; - - //Find types of all children + + // Find types of all children for (int i = 0; i < item->rowCount(); ++i) - found_children_types.append ( static_cast(item->child (i)->type ())); - //Make temporary copy, remove type from it if is present as child - QList req_children_temp = required_children_types; + found_children_types.append( + static_cast(item->child(i)->type())); + // Make temporary copy, remove type from it if is present as child + QList req_children_temp = required_children_types; foreach (CloudComposerItem::ItemType type, found_children_types) - req_children_temp.removeAll (type); - //If temporary is empty, we found all required children - if (req_children_temp.isEmpty ()) - { + req_children_temp.removeAll(type); + // If temporary is empty, we found all required children + if (req_children_temp.isEmpty()) { found_valid_items = true; break; } - //Otherwise, set missing children list - if (req_children_temp.size () < missing_children.size ()) + // Otherwise, set missing children list + if (req_children_temp.size() < missing_children.size()) missing_children = req_children_temp; - - } - //If we didn't find all required children - if (!found_valid_items) - { - enabled_itr.remove (); + // If we didn't find all required children + if (!found_valid_items) { + enabled_itr.remove(); QString missing_children_string; foreach (CloudComposerItem::ItemType type, missing_children) - missing_children_string.append (" "+ITEM_TYPES_STRINGS.value (type - CloudComposerItem::CLOUD_COMPOSER_ITEM)); - disabled_tools.insert (tool_item, tr ("Tool Requires child item of type(s) %1").arg (missing_children_string)); + missing_children_string.append( + " " + + ITEM_TYPES_STRINGS.value(type - CloudComposerItem::CLOUD_COMPOSER_ITEM)); + disabled_tools.insert( + tool_item, + tr("Tool Requires child item of type(s) %1").arg(missing_children_string)); } } } - foreach (QStandardItem* tool, tool_items) - { - if (enabled_tools.contains (tool)) - { - //qDebug () << tool->text() << " is enabled!"; - tool->setToolTip (tool->text() + " is enabled"); + foreach (QStandardItem* tool, tool_items) { + if (enabled_tools.contains(tool)) { + // qDebug () << tool->text() << " is enabled!"; + tool->setToolTip(tool->text() + " is enabled"); } - else - { - // qDebug () << tool->text() << " disabled: "<setToolTip (disabled_tools.value (tool)); - tool->setEnabled (false); + else { + // qDebug () << tool->text() << " disabled: "<setToolTip(disabled_tools.value(tool)); + tool->setEnabled(false); } } - - - } diff --git a/apps/cloud_composer/src/transform_clouds.cpp b/apps/cloud_composer/src/transform_clouds.cpp index 54658e745fa..cde2459a371 100644 --- a/apps/cloud_composer/src/transform_clouds.cpp +++ b/apps/cloud_composer/src/transform_clouds.cpp @@ -1,36 +1,31 @@ -#include +#include #include - +#include #include -#include - -pcl::cloud_composer::TransformClouds::TransformClouds (QMap > transform_map, QObject* parent) - : ModifyItemTool (nullptr, parent) - , transform_map_ (std::move(transform_map)) -{ - -} +pcl::cloud_composer::TransformClouds::TransformClouds( + QMap> transform_map, QObject* parent) +: ModifyItemTool(nullptr, parent), transform_map_(std::move(transform_map)) +{} -QList -pcl::cloud_composer::TransformClouds::performAction (ConstItemList input_data, PointTypeFlags::PointType type) +QList +pcl::cloud_composer::TransformClouds::performAction(ConstItemList input_data, + PointTypeFlags::PointType type) { - if (type != PointTypeFlags::NONE) - { - switch ((std::uint8_t) type) - { - case (PointTypeFlags::XYZ): - return this->performTemplatedAction (input_data); - case (PointTypeFlags::XYZ | PointTypeFlags::RGB): - return this->performTemplatedAction (input_data); - case (PointTypeFlags::XYZ | PointTypeFlags::RGBA): - return this->performTemplatedAction (input_data); + if (type != PointTypeFlags::NONE) { + switch ((std::uint8_t)type) { + case (PointTypeFlags::XYZ): + return this->performTemplatedAction(input_data); + case (PointTypeFlags::XYZ | PointTypeFlags::RGB): + return this->performTemplatedAction(input_data); + case (PointTypeFlags::XYZ | PointTypeFlags::RGBA): + return this->performTemplatedAction(input_data); } } - - QList output; - qCritical () << "Transform requires templated types!"; - + QList output; + + qCritical() << "Transform requires templated types!"; + return output; } diff --git a/apps/cloud_composer/src/work_queue.cpp b/apps/cloud_composer/src/work_queue.cpp index 2d4fb11d09c..b8662619d0b 100644 --- a/apps/cloud_composer/src/work_queue.cpp +++ b/apps/cloud_composer/src/work_queue.cpp @@ -1,58 +1,45 @@ -#include #include +#include -pcl::cloud_composer::WorkQueue::WorkQueue (QObject* parent) - : QObject (parent) -{ - - - -} +pcl::cloud_composer::WorkQueue::WorkQueue(QObject* parent) : QObject(parent) {} void -pcl::cloud_composer::WorkQueue::enqueueNewAction (AbstractTool* new_tool, ConstItemList input_data) +pcl::cloud_composer::WorkQueue::enqueueNewAction(AbstractTool* new_tool, + ConstItemList input_data) { ActionPair new_action; - //Create a command which will manage data for the tool - new_action.command = new_tool->createCommand (std::move(input_data)); + // Create a command which will manage data for the tool + new_action.command = new_tool->createCommand(std::move(input_data)); new_action.tool = new_tool; - - work_queue_.enqueue (new_action); - checkQueue (); + + work_queue_.enqueue(new_action); + checkQueue(); } void -pcl::cloud_composer::WorkQueue::actionFinished (ActionPair finished_action) +pcl::cloud_composer::WorkQueue::actionFinished(ActionPair finished_action) { - //Signal the project model that the command is done - emit commandComplete (finished_action.command); - - //Queue the tool for deletion - finished_action.tool->deleteLater (); - //Check if there are any remaining commands in queue - checkQueue (); - + // Signal the project model that the command is done + emit commandComplete(finished_action.command); + + // Queue the tool for deletion + finished_action.tool->deleteLater(); + // Check if there are any remaining commands in queue + checkQueue(); } void -pcl::cloud_composer::WorkQueue::checkQueue ( ) +pcl::cloud_composer::WorkQueue::checkQueue() { - if (work_queue_.length () > 0) - { - ActionPair action_to_execute = work_queue_.dequeue (); - if (action_to_execute.command->runCommand (action_to_execute.tool)) - { - //Success, send the command back to the main thread - actionFinished (action_to_execute); + if (work_queue_.length() > 0) { + ActionPair action_to_execute = work_queue_.dequeue(); + if (action_to_execute.command->runCommand(action_to_execute.tool)) { + // Success, send the command back to the main thread + actionFinished(action_to_execute); } - else - { - qDebug () << "FAILED TO EXECUTE COMMAND"; - //Failure, what to do with data?? + else { + qDebug() << "FAILED TO EXECUTE COMMAND"; + // Failure, what to do with data?? } - - } - - } diff --git a/apps/cloud_composer/tools/euclidean_clustering.cpp b/apps/cloud_composer/tools/euclidean_clustering.cpp index fc1a407350a..2413544ec90 100644 --- a/apps/cloud_composer/tools/euclidean_clustering.cpp +++ b/apps/cloud_composer/tools/euclidean_clustering.cpp @@ -1,131 +1,138 @@ -#include #include - -#include // for pcl::make_shared -#include +#include #include #include #include +#include // for pcl::make_shared +#include Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") -pcl::cloud_composer::EuclideanClusteringTool::EuclideanClusteringTool (PropertiesModel* parameter_model, QObject* parent) - : SplitItemTool (parameter_model, parent) -{ - -} +pcl::cloud_composer::EuclideanClusteringTool::EuclideanClusteringTool( + PropertiesModel* parameter_model, QObject* parent) +: SplitItemTool(parameter_model, parent) +{} -QList -pcl::cloud_composer::EuclideanClusteringTool::performAction (ConstItemList input_data, PointTypeFlags::PointType) +QList +pcl::cloud_composer::EuclideanClusteringTool::performAction(ConstItemList input_data, + PointTypeFlags::PointType) { - QList output; + QList output; const CloudComposerItem* input_item; // Check input data length - if ( input_data.empty ()) - { - qCritical () << "Empty input in Euclidean Clustering Tool!"; + if (input_data.empty()) { + qCritical() << "Empty input in Euclidean Clustering Tool!"; return output; } - if ( input_data.size () > 1) - { - qWarning () << "Input vector has more than one item in Euclidean Clustering!"; + if (input_data.size() > 1) { + qWarning() << "Input vector has more than one item in Euclidean Clustering!"; } - input_item = input_data.value (0); + input_item = input_data.value(0); - if (input_item->type () == CloudComposerItem::CLOUD_ITEM) - { - const CloudItem* cloud_item = dynamic_cast (input_item); - if ( cloud_item->isSanitized()) - { - double cluster_tolerance = parameter_model_->getProperty ("Cluster Tolerance").toDouble(); - int min_cluster_size = parameter_model_->getProperty ("Min Cluster Size").toInt(); - int max_cluster_size = parameter_model_->getProperty ("Max Cluster Size").toInt(); + if (input_item->type() == CloudComposerItem::CLOUD_ITEM) { + const CloudItem* cloud_item = dynamic_cast(input_item); + if (cloud_item->isSanitized()) { + double cluster_tolerance = + parameter_model_->getProperty("Cluster Tolerance").toDouble(); + int min_cluster_size = parameter_model_->getProperty("Min Cluster Size").toInt(); + int max_cluster_size = parameter_model_->getProperty("Max Cluster Size").toInt(); - pcl::PCLPointCloud2::ConstPtr input_cloud = input_item->data (ItemDataRole::CLOUD_BLOB).value (); - //Get the cloud in template form - pcl::PointCloud::Ptr cloud (new pcl::PointCloud); - pcl::fromPCLPointCloud2 (*input_cloud, *cloud); + pcl::PCLPointCloud2::ConstPtr input_cloud = + input_item->data(ItemDataRole::CLOUD_BLOB) + .value(); + // Get the cloud in template form + pcl::PointCloud::Ptr cloud(new pcl::PointCloud); + pcl::fromPCLPointCloud2(*input_cloud, *cloud); //////////////// THE WORK - COMPUTING CLUSTERS /////////////////// // Creating the KdTree object for the search method of the extraction - pcl::search::KdTree::Ptr tree (new pcl::search::KdTree); - tree->setInputCloud (cloud); + pcl::search::KdTree::Ptr tree( + new pcl::search::KdTree); + tree->setInputCloud(cloud); std::vector cluster_indices; pcl::EuclideanClusterExtraction ec; - ec.setClusterTolerance (cluster_tolerance); - ec.setMinClusterSize (min_cluster_size); - ec.setMaxClusterSize (max_cluster_size); - ec.setSearchMethod (tree); - ec.setInputCloud (cloud); - ec.extract (cluster_indices); + ec.setClusterTolerance(cluster_tolerance); + ec.setMinClusterSize(min_cluster_size); + ec.setMaxClusterSize(max_cluster_size); + ec.setSearchMethod(tree); + ec.setInputCloud(cloud); + ec.extract(cluster_indices); ////////////////////////////////////////////////////////////////// - //Get copies of the original origin and orientation - Eigen::Vector4f source_origin = input_item->data (ItemDataRole::ORIGIN).value (); - Eigen::Quaternionf source_orientation = input_item->data (ItemDataRole::ORIENTATION).value (); - //Vector to accumulate the extracted indices - pcl::IndicesPtr extracted_indices (new pcl::Indices ()); - //Put found clusters into new cloud_items! - qDebug () << "Found "<data(ItemDataRole::ORIGIN).value(); + Eigen::Quaternionf source_orientation = + input_item->data(ItemDataRole::ORIENTATION).value(); + // Vector to accumulate the extracted indices + pcl::IndicesPtr extracted_indices(new pcl::Indices()); + // Put found clusters into new cloud_items! + qDebug() << "Found " << cluster_indices.size() << " clusters!"; int cluster_count = 0; pcl::ExtractIndices filter; - for (const auto& cluster : cluster_indices) - { - filter.setInputCloud (input_cloud); - // It's annoying that I have to do this, but Euclidean returns a PointIndices struct - pcl::PointIndices::ConstPtr indices_ptr = pcl::make_shared(cluster); - filter.setIndices (indices_ptr); - extracted_indices->insert (extracted_indices->end (), cluster.indices.begin (), cluster.indices.end ()); - //This means remove the other points - filter.setKeepOrganized (false); - pcl::PCLPointCloud2::Ptr cloud_filtered (new pcl::PCLPointCloud2); - filter.filter (*cloud_filtered); + for (const auto& cluster : cluster_indices) { + filter.setInputCloud(input_cloud); + // It's annoying that I have to do this, but Euclidean returns a PointIndices + // struct + pcl::PointIndices::ConstPtr indices_ptr = + pcl::make_shared(cluster); + filter.setIndices(indices_ptr); + extracted_indices->insert( + extracted_indices->end(), cluster.indices.begin(), cluster.indices.end()); + // This means remove the other points + filter.setKeepOrganized(false); + pcl::PCLPointCloud2::Ptr cloud_filtered(new pcl::PCLPointCloud2); + filter.filter(*cloud_filtered); qDebug() << "Cluster has " << cloud_filtered->width << " data points."; - CloudItem* cloud_item = new CloudItem (input_item->text ()+tr("-Clstr %1").arg(cluster_count) - , cloud_filtered - , source_origin - , source_orientation); - output.append (cloud_item); + CloudItem* cloud_item = + new CloudItem(input_item->text() + tr("-Clstr %1").arg(cluster_count), + cloud_filtered, + source_origin, + source_orientation); + output.append(cloud_item); ++cluster_count; } - //We copy input cloud over for special case that no clusters found, since ExtractIndices doesn't work for 0 length vectors - pcl::PCLPointCloud2::Ptr remainder_cloud (new pcl::PCLPointCloud2(*input_cloud)); - if (!cluster_indices.empty ()) - { - //make a cloud containing all the remaining points - filter.setIndices (extracted_indices); - filter.setNegative (true); - filter.filter (*remainder_cloud); + // We copy input cloud over for special case that no clusters found, since + // ExtractIndices doesn't work for 0 length vectors + pcl::PCLPointCloud2::Ptr remainder_cloud(new pcl::PCLPointCloud2(*input_cloud)); + if (!cluster_indices.empty()) { + // make a cloud containing all the remaining points + filter.setIndices(extracted_indices); + filter.setNegative(true); + filter.filter(*remainder_cloud); } - qDebug() << "Cloud has " << remainder_cloud->width << " data points after clusters removed."; - CloudItem* cloud_item = new CloudItem (input_item->text ()+ " unclustered" - , remainder_cloud - , source_origin - , source_orientation); - output.push_front (cloud_item); + qDebug() << "Cloud has " << remainder_cloud->width + << " data points after clusters removed."; + CloudItem* cloud_item = new CloudItem(input_item->text() + " unclustered", + remainder_cloud, + source_origin, + source_orientation); + output.push_front(cloud_item); } else - qCritical () << "Input item in Clustering is not SANITIZED!!!"; + qCritical() << "Input item in Clustering is not SANITIZED!!!"; } - else - { - qCritical () << "Input item in Clustering is not a cloud!!!"; + else { + qCritical() << "Input item in Clustering is not a cloud!!!"; } - return output; } /////////////////// PARAMETER MODEL ///////////////////////////////// pcl::cloud_composer::PropertiesModel* -pcl::cloud_composer::EuclideanClusteringToolFactory::createToolParameterModel (QObject* parent) +pcl::cloud_composer::EuclideanClusteringToolFactory::createToolParameterModel( + QObject* parent) { PropertiesModel* parameter_model = new PropertiesModel(parent); - parameter_model->addProperty ("Cluster Tolerance", 0.02, Qt::ItemIsEditable | Qt::ItemIsEnabled); - parameter_model->addProperty ("Min Cluster Size", 100, Qt::ItemIsEditable | Qt::ItemIsEnabled); - parameter_model->addProperty ("Max Cluster Size", 25000, Qt::ItemIsEditable | Qt::ItemIsEnabled); + parameter_model->addProperty( + "Cluster Tolerance", 0.02, Qt::ItemIsEditable | Qt::ItemIsEnabled); + parameter_model->addProperty( + "Min Cluster Size", 100, Qt::ItemIsEditable | Qt::ItemIsEnabled); + parameter_model->addProperty( + "Max Cluster Size", 25000, Qt::ItemIsEditable | Qt::ItemIsEnabled); return parameter_model; } diff --git a/apps/cloud_composer/tools/fpfh_estimation.cpp b/apps/cloud_composer/tools/fpfh_estimation.cpp index a65056a1567..9366754584b 100644 --- a/apps/cloud_composer/tools/fpfh_estimation.cpp +++ b/apps/cloud_composer/tools/fpfh_estimation.cpp @@ -1,105 +1,107 @@ -#include #include -#include #include - +#include +#include #include -#include #include +#include Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") -pcl::cloud_composer::FPFHEstimationTool::FPFHEstimationTool (PropertiesModel* parameter_model, QObject* parent) - : NewItemTool (parameter_model, parent) -{ +pcl::cloud_composer::FPFHEstimationTool::FPFHEstimationTool( + PropertiesModel* parameter_model, QObject* parent) +: NewItemTool(parameter_model, parent) +{} - -} - -QList -pcl::cloud_composer::FPFHEstimationTool::performAction (ConstItemList input_data, PointTypeFlags::PointType) +QList +pcl::cloud_composer::FPFHEstimationTool::performAction(ConstItemList input_data, + PointTypeFlags::PointType) { - QList output; + QList output; const CloudComposerItem* input_item; // Check input data length - if ( input_data.empty ()) - { - qCritical () << "Empty input in FPFH Estimation Tool!"; + if (input_data.empty()) { + qCritical() << "Empty input in FPFH Estimation Tool!"; return output; } - if ( input_data.size () > 1) - { - qWarning () << "Input vector has more than one item in FPFH Estimation!"; + if (input_data.size() > 1) { + qWarning() << "Input vector has more than one item in FPFH Estimation!"; } - input_item = input_data.value (0); - - - if (input_item->type () == CloudComposerItem::CLOUD_ITEM) - { - //Check if this cloud has normals computed! - QList normals_list = input_item->getChildren (CloudComposerItem::NORMALS_ITEM); - if ( normals_list.empty () ) - { - qCritical () << "No normals item child found in this cloud item"; + input_item = input_data.value(0); + + if (input_item->type() == CloudComposerItem::CLOUD_ITEM) { + // Check if this cloud has normals computed! + QList normals_list = + input_item->getChildren(CloudComposerItem::NORMALS_ITEM); + if (normals_list.empty()) { + qCritical() << "No normals item child found in this cloud item"; return output; } - qDebug () << "Found item text="<text(); + qDebug() << "Found item text=" << normals_list.at(0)->text(); double radius = parameter_model_->getProperty("Radius").toDouble(); - - pcl::PCLPointCloud2::ConstPtr input_cloud = input_item->data (ItemDataRole::CLOUD_BLOB).value (); - //Get the cloud in template form - pcl::PointCloud::Ptr cloud (new pcl::PointCloud); - pcl::fromPCLPointCloud2 (*input_cloud, *cloud); - - //Get the normals cloud, we just use the first normals that were found if there are more than one - pcl::PointCloud::ConstPtr input_normals = normals_list.value(0)->data(ItemDataRole::CLOUD_TEMPLATED).value ::ConstPtr> (); - + + pcl::PCLPointCloud2::ConstPtr input_cloud = + input_item->data(ItemDataRole::CLOUD_BLOB) + .value(); + // Get the cloud in template form + pcl::PointCloud::Ptr cloud(new pcl::PointCloud); + pcl::fromPCLPointCloud2(*input_cloud, *cloud); + + // Get the normals cloud, we just use the first normals that were found if there are + // more than one + pcl::PointCloud::ConstPtr input_normals = + normals_list.value(0) + ->data(ItemDataRole::CLOUD_TEMPLATED) + .value::ConstPtr>(); + pcl::FPFHEstimation fpfh; - // qDebug () << "Input cloud size = "<size (); + // qDebug () << "Input cloud size = "<size (); //////////////// THE WORK - COMPUTING FPFH /////////////////// // Create the FPFH estimation class, and pass the input dataset+normals to it - fpfh.setInputCloud (cloud); - fpfh.setInputNormals (input_normals); + fpfh.setInputCloud(cloud); + fpfh.setInputNormals(input_normals); // Create an empty kdtree representation, and pass it to the FPFH estimation object. - // Its content will be filled inside the object, based on the given input dataset (as no other search surface is given). - qDebug () << "Building KD Tree"; - pcl::search::KdTree::Ptr tree (new pcl::search::KdTree); - fpfh.setSearchMethod (tree); + // Its content will be filled inside the object, based on the given input dataset + // (as no other search surface is given). + qDebug() << "Building KD Tree"; + pcl::search::KdTree::Ptr tree(new pcl::search::KdTree); + fpfh.setSearchMethod(tree); // Output datasets - pcl::PointCloud::Ptr fpfhs (new pcl::PointCloud ()); + pcl::PointCloud::Ptr fpfhs( + new pcl::PointCloud()); // Use all neighbors in a sphere of radius 5cm - // IMPORTANT: the radius used here has to be larger than the radius used to estimate the surface normals!!! - fpfh.setRadiusSearch (radius); + // IMPORTANT: the radius used here has to be larger than the radius used to estimate + // the surface normals!!! + fpfh.setRadiusSearch(radius); // Compute the features - qDebug () << "Computing FPFH features"; - fpfh.compute (*fpfhs); - qDebug () << "Size of computed features ="<width; + qDebug() << "Computing FPFH features"; + fpfh.compute(*fpfhs); + qDebug() << "Size of computed features =" << fpfhs->width; ////////////////////////////////////////////////////////////////// - FPFHItem* fpfh_item = new FPFHItem (tr("FPFH r=%1").arg(radius),fpfhs,radius); - output.append (fpfh_item); + FPFHItem* fpfh_item = new FPFHItem(tr("FPFH r=%1").arg(radius), fpfhs, radius); + output.append(fpfh_item); } - else - { - qCritical () << "Input item in FPFH Estimation is not a cloud!!!"; + else { + qCritical() << "Input item in FPFH Estimation is not a cloud!!!"; } - - + return output; } /////////////////// PARAMETER MODEL ///////////////////////////////// pcl::cloud_composer::PropertiesModel* -pcl::cloud_composer::FPFHEstimationToolFactory::createToolParameterModel (QObject* parent) +pcl::cloud_composer::FPFHEstimationToolFactory::createToolParameterModel( + QObject* parent) { PropertiesModel* parameter_model = new PropertiesModel(parent); - - parameter_model->addProperty ("Radius", 0.03, Qt::ItemIsEditable | Qt::ItemIsEnabled); - + + parameter_model->addProperty("Radius", 0.03, Qt::ItemIsEditable | Qt::ItemIsEnabled); + return parameter_model; } diff --git a/apps/cloud_composer/tools/normal_estimation.cpp b/apps/cloud_composer/tools/normal_estimation.cpp index 55ced5d3e92..ddef0a393ed 100644 --- a/apps/cloud_composer/tools/normal_estimation.cpp +++ b/apps/cloud_composer/tools/normal_estimation.cpp @@ -1,83 +1,82 @@ -#include #include - +#include #include #include Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") -pcl::cloud_composer::NormalEstimationTool::NormalEstimationTool (PropertiesModel* parameter_model, QObject* parent) - : NewItemTool (parameter_model, parent) -{ - - -} +pcl::cloud_composer::NormalEstimationTool::NormalEstimationTool( + PropertiesModel* parameter_model, QObject* parent) +: NewItemTool(parameter_model, parent) +{} -QList -pcl::cloud_composer::NormalEstimationTool::performAction (ConstItemList input_data, PointTypeFlags::PointType) +QList +pcl::cloud_composer::NormalEstimationTool::performAction(ConstItemList input_data, + PointTypeFlags::PointType) { - QList output; + QList output; const CloudComposerItem* input_item; // Check input data length - if ( input_data.empty ()) - { - qCritical () << "Empty input in Normal Estimation Tool!"; + if (input_data.empty()) { + qCritical() << "Empty input in Normal Estimation Tool!"; return output; } - if ( input_data.size () > 1) - { - qWarning () << "Input vector has more than one item in Normal Estimation!"; + if (input_data.size() > 1) { + qWarning() << "Input vector has more than one item in Normal Estimation!"; } - input_item = input_data.value (0); - + input_item = input_data.value(0); + pcl::PCLPointCloud2::ConstPtr input_cloud; - if (input_item->type () == CloudComposerItem::CLOUD_ITEM) - { + if (input_item->type() == CloudComposerItem::CLOUD_ITEM) { double radius = parameter_model_->getProperty("Radius").toDouble(); - qDebug () << "Received Radius = " <data (ItemDataRole::CLOUD_BLOB).value (); - qDebug () << "Got cloud size = "<width; + qDebug() << "Received Radius = " << radius; + pcl::PCLPointCloud2::ConstPtr input_cloud = + input_item->data(ItemDataRole::CLOUD_BLOB) + .value(); + qDebug() << "Got cloud size = " << input_cloud->width; //////////////// THE WORK - COMPUTING NORMALS /////////////////// - pcl::PointCloud::Ptr cloud (new pcl::PointCloud); - pcl::fromPCLPointCloud2 (*input_cloud, *cloud); + pcl::PointCloud::Ptr cloud(new pcl::PointCloud); + pcl::fromPCLPointCloud2(*input_cloud, *cloud); // Create the normal estimation class, and pass the input dataset to it pcl::NormalEstimation ne; - ne.setInputCloud (cloud); + ne.setInputCloud(cloud); - // Create an empty kdtree representation, and pass it to the normal estimation object. - // Its content will be filled inside the object, based on the given input dataset (as no other search surface is given). - pcl::search::KdTree::Ptr tree (new pcl::search::KdTree ()); - ne.setSearchMethod (tree); + // Create an empty kdtree representation, and pass it to the normal estimation + // object. Its content will be filled inside the object, based on the given input + // dataset (as no other search surface is given). + pcl::search::KdTree::Ptr tree( + new pcl::search::KdTree()); + ne.setSearchMethod(tree); // Output datasets - pcl::PointCloud::Ptr cloud_normals (new pcl::PointCloud); + pcl::PointCloud::Ptr cloud_normals(new pcl::PointCloud); // Use all neighbors in a sphere of radius 3cm - ne.setRadiusSearch (radius); + ne.setRadiusSearch(radius); // Compute the features - ne.compute (*cloud_normals); + ne.compute(*cloud_normals); ////////////////////////////////////////////////////////////////// - NormalsItem* normals_item = new NormalsItem (tr("Normals r=%1").arg(radius),cloud_normals,radius); - output.append (normals_item); - qDebug () << "Calced normals"; + NormalsItem* normals_item = + new NormalsItem(tr("Normals r=%1").arg(radius), cloud_normals, radius); + output.append(normals_item); + qDebug() << "Calced normals"; } - else - { - qDebug () << "Input item in Normal Estimation is not a cloud!!!"; + else { + qDebug() << "Input item in Normal Estimation is not a cloud!!!"; } - - + return output; } /////////////////// PARAMETER MODEL ///////////////////////////////// pcl::cloud_composer::PropertiesModel* -pcl::cloud_composer::NormalEstimationToolFactory::createToolParameterModel (QObject* parent) +pcl::cloud_composer::NormalEstimationToolFactory::createToolParameterModel( + QObject* parent) { PropertiesModel* parameter_model = new PropertiesModel(parent); - - parameter_model->addProperty ("Radius", 0.04, Qt::ItemIsEditable | Qt::ItemIsEnabled); - + + parameter_model->addProperty("Radius", 0.04, Qt::ItemIsEditable | Qt::ItemIsEnabled); + return parameter_model; } diff --git a/apps/cloud_composer/tools/organized_segmentation.cpp b/apps/cloud_composer/tools/organized_segmentation.cpp index 47d7430fad0..73679e871d3 100644 --- a/apps/cloud_composer/tools/organized_segmentation.cpp +++ b/apps/cloud_composer/tools/organized_segmentation.cpp @@ -1,58 +1,59 @@ -#include #include - -#include +#include +#include #include #include #include - - -#include +#include Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") -pcl::cloud_composer::OrganizedSegmentationTool::OrganizedSegmentationTool (PropertiesModel* parameter_model, QObject* parent) -: SplitItemTool (parameter_model, parent) -{ - -} +pcl::cloud_composer::OrganizedSegmentationTool::OrganizedSegmentationTool( + PropertiesModel* parameter_model, QObject* parent) +: SplitItemTool(parameter_model, parent) +{} -QList -pcl::cloud_composer::OrganizedSegmentationTool::performAction (ConstItemList input_data, PointTypeFlags::PointType type) +QList +pcl::cloud_composer::OrganizedSegmentationTool::performAction( + ConstItemList input_data, PointTypeFlags::PointType type) { - if (type != PointTypeFlags::NONE) - { - switch ((std::uint8_t) type) - { - case (PointTypeFlags::XYZ): - return this->performTemplatedAction (input_data); - case (PointTypeFlags::XYZ | PointTypeFlags::RGB): - return this->performTemplatedAction (input_data); - case (PointTypeFlags::XYZ | PointTypeFlags::RGBA): - return this->performTemplatedAction (input_data); + if (type != PointTypeFlags::NONE) { + switch ((std::uint8_t)type) { + case (PointTypeFlags::XYZ): + return this->performTemplatedAction(input_data); + case (PointTypeFlags::XYZ | PointTypeFlags::RGB): + return this->performTemplatedAction(input_data); + case (PointTypeFlags::XYZ | PointTypeFlags::RGBA): + return this->performTemplatedAction(input_data); } } - - QList output; - - qCritical () << "organized_segmentation requires templated types!"; - + + QList output; + + qCritical() << "organized_segmentation requires templated types!"; + return output; -} +} /////////////////// PARAMETER MODEL ///////////////////////////////// pcl::cloud_composer::PropertiesModel* -pcl::cloud_composer::OrganizedSegmentationToolFactory::createToolParameterModel (QObject* parent) +pcl::cloud_composer::OrganizedSegmentationToolFactory::createToolParameterModel( + QObject* parent) { PropertiesModel* parameter_model = new PropertiesModel(parent); - - parameter_model->addProperty ("Min Inliers", 1000, Qt::ItemIsEditable | Qt::ItemIsEnabled); - parameter_model->addProperty ("Min Plane Size", 10000, Qt::ItemIsEditable | Qt::ItemIsEnabled); - parameter_model->addProperty ("Angular Threshold", 2.0, Qt::ItemIsEditable | Qt::ItemIsEnabled); - parameter_model->addProperty ("Distance Threshold", 0.02, Qt::ItemIsEditable | Qt::ItemIsEnabled); - parameter_model->addProperty ("Cluster Dist. Thresh.", 0.01, Qt::ItemIsEditable | Qt::ItemIsEnabled); - parameter_model->addProperty ("Min Cluster Size", 1000, Qt::ItemIsEditable | Qt::ItemIsEnabled); - - + + parameter_model->addProperty( + "Min Inliers", 1000, Qt::ItemIsEditable | Qt::ItemIsEnabled); + parameter_model->addProperty( + "Min Plane Size", 10000, Qt::ItemIsEditable | Qt::ItemIsEnabled); + parameter_model->addProperty( + "Angular Threshold", 2.0, Qt::ItemIsEditable | Qt::ItemIsEnabled); + parameter_model->addProperty( + "Distance Threshold", 0.02, Qt::ItemIsEditable | Qt::ItemIsEnabled); + parameter_model->addProperty( + "Cluster Dist. Thresh.", 0.01, Qt::ItemIsEditable | Qt::ItemIsEnabled); + parameter_model->addProperty( + "Min Cluster Size", 1000, Qt::ItemIsEditable | Qt::ItemIsEnabled); + return parameter_model; } diff --git a/apps/cloud_composer/tools/sanitize_cloud.cpp b/apps/cloud_composer/tools/sanitize_cloud.cpp index d56d5276c36..90d371954cd 100644 --- a/apps/cloud_composer/tools/sanitize_cloud.cpp +++ b/apps/cloud_composer/tools/sanitize_cloud.cpp @@ -1,75 +1,75 @@ -#include #include +#include #include -#include // for pcl::make_shared +#include // for pcl::make_shared Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") -pcl::cloud_composer::SanitizeCloudTool::SanitizeCloudTool (PropertiesModel* parameter_model, QObject* parent) -: ModifyItemTool (parameter_model, parent) -{ -} +pcl::cloud_composer::SanitizeCloudTool::SanitizeCloudTool( + PropertiesModel* parameter_model, QObject* parent) +: ModifyItemTool(parameter_model, parent) +{} -QList -pcl::cloud_composer::SanitizeCloudTool::performAction (ConstItemList input_data, PointTypeFlags::PointType) +QList +pcl::cloud_composer::SanitizeCloudTool::performAction(ConstItemList input_data, + PointTypeFlags::PointType) { - QList output; + QList output; const CloudComposerItem* input_item; // Check input data length - if ( input_data.empty ()) - { - qCritical () << "Empty input in SanitizeCloudTool!"; + if (input_data.empty()) { + qCritical() << "Empty input in SanitizeCloudTool!"; return output; } - input_item = input_data.value (0); - - if (input_item->type () == CloudComposerItem::CLOUD_ITEM ) - { - pcl::PCLPointCloud2::ConstPtr input_cloud = input_item->data (ItemDataRole::CLOUD_BLOB).value (); - - bool keep_organized = parameter_model_->getProperty("Keep Organized").toBool (); - + input_item = input_data.value(0); + + if (input_item->type() == CloudComposerItem::CLOUD_ITEM) { + pcl::PCLPointCloud2::ConstPtr input_cloud = + input_item->data(ItemDataRole::CLOUD_BLOB) + .value(); + + bool keep_organized = parameter_model_->getProperty("Keep Organized").toBool(); + //////////////// THE WORK - FILTERING NANS /////////////////// // Create the filtering object pcl::PassThrough pass_filter; - pass_filter.setInputCloud (input_cloud); - pass_filter.setKeepOrganized (keep_organized); - - //Create output cloud - pcl::PCLPointCloud2::Ptr cloud_filtered = pcl::make_shared (); - //Filter! - pass_filter.filter (*cloud_filtered); - + pass_filter.setInputCloud(input_cloud); + pass_filter.setKeepOrganized(keep_organized); + + // Create output cloud + pcl::PCLPointCloud2::Ptr cloud_filtered = pcl::make_shared(); + // Filter! + pass_filter.filter(*cloud_filtered); + ////////////////////////////////////////////////////////////////// - //Get copies of the original origin and orientation - Eigen::Vector4f source_origin = input_item->data (ItemDataRole::ORIGIN).value (); - Eigen::Quaternionf source_orientation = input_item->data (ItemDataRole::ORIENTATION).value (); - //Put the modified cloud into an item, stick in output - CloudItem* cloud_item = new CloudItem (input_item->text () + tr (" sanitized") - , cloud_filtered - , source_origin - , source_orientation); - - - output.append (cloud_item); + // Get copies of the original origin and orientation + Eigen::Vector4f source_origin = + input_item->data(ItemDataRole::ORIGIN).value(); + Eigen::Quaternionf source_orientation = + input_item->data(ItemDataRole::ORIENTATION).value(); + // Put the modified cloud into an item, stick in output + CloudItem* cloud_item = new CloudItem(input_item->text() + tr(" sanitized"), + cloud_filtered, + source_origin, + source_orientation); + + output.append(cloud_item); } - else - { - qDebug () << "Input item in StatisticalOutlierRemovalTool is not a cloud!!!"; + else { + qDebug() << "Input item in StatisticalOutlierRemovalTool is not a cloud!!!"; } - - + return output; } /////////////////// PARAMETER MODEL ///////////////////////////////// pcl::cloud_composer::PropertiesModel* -pcl::cloud_composer::SanitizeCloudToolFactory::createToolParameterModel (QObject* parent) +pcl::cloud_composer::SanitizeCloudToolFactory::createToolParameterModel(QObject* parent) { PropertiesModel* parameter_model = new PropertiesModel(parent); - - parameter_model->addProperty ("Keep Organized", false, Qt::ItemIsEditable | Qt::ItemIsEnabled); - + + parameter_model->addProperty( + "Keep Organized", false, Qt::ItemIsEditable | Qt::ItemIsEnabled); + return parameter_model; } - diff --git a/apps/cloud_composer/tools/statistical_outlier_removal.cpp b/apps/cloud_composer/tools/statistical_outlier_removal.cpp index 3213a9755d5..d67426016a9 100644 --- a/apps/cloud_composer/tools/statistical_outlier_removal.cpp +++ b/apps/cloud_composer/tools/statistical_outlier_removal.cpp @@ -1,89 +1,87 @@ -#include #include - +#include #include #include Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") -pcl::cloud_composer::StatisticalOutlierRemovalTool::StatisticalOutlierRemovalTool (PropertiesModel* parameter_model, QObject* parent) - : ModifyItemTool (parameter_model, parent) -{ +pcl::cloud_composer::StatisticalOutlierRemovalTool::StatisticalOutlierRemovalTool( + PropertiesModel* parameter_model, QObject* parent) +: ModifyItemTool(parameter_model, parent) +{} - -} - -QList -pcl::cloud_composer::StatisticalOutlierRemovalTool::performAction (ConstItemList input_data, PointTypeFlags::PointType) +QList +pcl::cloud_composer::StatisticalOutlierRemovalTool::performAction( + ConstItemList input_data, PointTypeFlags::PointType) { - QList output; + QList output; const CloudComposerItem* input_item; // Check input data length - if ( input_data.empty ()) - { - qCritical () << "Empty input in StatisticalOutlierRemovalTool!"; + if (input_data.empty()) { + qCritical() << "Empty input in StatisticalOutlierRemovalTool!"; return output; } - if ( input_data.size () > 1) - { - qWarning () << "Input vector has more than one item in StatisticalOutlierRemovalTool"; + if (input_data.size() > 1) { + qWarning() + << "Input vector has more than one item in StatisticalOutlierRemovalTool"; } - input_item = input_data.value (0); - if ( !input_item->isSanitized () ) - { - qCritical () << "StatisticalOutlierRemovalTool requires sanitized input!"; + input_item = input_data.value(0); + if (!input_item->isSanitized()) { + qCritical() << "StatisticalOutlierRemovalTool requires sanitized input!"; return output; } - - if (input_item->type () == CloudComposerItem::CLOUD_ITEM ) - { - pcl::PCLPointCloud2::ConstPtr input_cloud = input_item->data (ItemDataRole::CLOUD_BLOB).value (); - - int mean_k = parameter_model_->getProperty("Mean K").toInt (); - double std_dev_thresh = parameter_model_->getProperty ("Std Dev Thresh").toDouble (); - + + if (input_item->type() == CloudComposerItem::CLOUD_ITEM) { + pcl::PCLPointCloud2::ConstPtr input_cloud = + input_item->data(ItemDataRole::CLOUD_BLOB) + .value(); + + int mean_k = parameter_model_->getProperty("Mean K").toInt(); + double std_dev_thresh = parameter_model_->getProperty("Std Dev Thresh").toDouble(); + //////////////// THE WORK - FILTERING OUTLIERS /////////////////// // Create the filtering object pcl::StatisticalOutlierRemoval sor; - sor.setInputCloud (input_cloud); - sor.setMeanK (mean_k); - sor.setStddevMulThresh (std_dev_thresh); - - //Create output cloud - pcl::PCLPointCloud2::Ptr cloud_filtered (new pcl::PCLPointCloud2); - //Filter! - sor.filter (*cloud_filtered); + sor.setInputCloud(input_cloud); + sor.setMeanK(mean_k); + sor.setStddevMulThresh(std_dev_thresh); + + // Create output cloud + pcl::PCLPointCloud2::Ptr cloud_filtered(new pcl::PCLPointCloud2); + // Filter! + sor.filter(*cloud_filtered); ////////////////////////////////////////////////////////////////// - //Get copies of the original origin and orientation - Eigen::Vector4f source_origin = input_item->data (ItemDataRole::ORIGIN).value (); - Eigen::Quaternionf source_orientation = input_item->data (ItemDataRole::ORIENTATION).value (); - //Put the modified cloud into an item, stick in output - CloudItem* cloud_item = new CloudItem (input_item->text () + tr (" sor filtered") - , cloud_filtered - , source_origin - , source_orientation); + // Get copies of the original origin and orientation + Eigen::Vector4f source_origin = + input_item->data(ItemDataRole::ORIGIN).value(); + Eigen::Quaternionf source_orientation = + input_item->data(ItemDataRole::ORIENTATION).value(); + // Put the modified cloud into an item, stick in output + CloudItem* cloud_item = new CloudItem(input_item->text() + tr(" sor filtered"), + cloud_filtered, + source_origin, + source_orientation); - - output.append (cloud_item); + output.append(cloud_item); } - else - { - qDebug () << "Input item in StatisticalOutlierRemovalTool is not a cloud!!!"; + else { + qDebug() << "Input item in StatisticalOutlierRemovalTool is not a cloud!!!"; } - - + return output; } /////////////////// PARAMETER MODEL ///////////////////////////////// pcl::cloud_composer::PropertiesModel* -pcl::cloud_composer::StatisticalOutlierRemovalToolFactory::createToolParameterModel (QObject* parent) +pcl::cloud_composer::StatisticalOutlierRemovalToolFactory::createToolParameterModel( + QObject* parent) { PropertiesModel* parameter_model = new PropertiesModel(parent); - - parameter_model->addProperty ("Mean K", 50, Qt::ItemIsEditable | Qt::ItemIsEnabled); - parameter_model->addProperty ("Std Dev Thresh", 1.0, Qt::ItemIsEditable | Qt::ItemIsEnabled); - + + parameter_model->addProperty("Mean K", 50, Qt::ItemIsEditable | Qt::ItemIsEnabled); + parameter_model->addProperty( + "Std Dev Thresh", 1.0, Qt::ItemIsEditable | Qt::ItemIsEnabled); + return parameter_model; } diff --git a/apps/cloud_composer/tools/supervoxels.cpp b/apps/cloud_composer/tools/supervoxels.cpp index 6c22b37f9fc..853a32e2555 100644 --- a/apps/cloud_composer/tools/supervoxels.cpp +++ b/apps/cloud_composer/tools/supervoxels.cpp @@ -1,56 +1,61 @@ -#include #include +#include +#include #include #include -#include #include - -#include +#include Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") -pcl::cloud_composer::SupervoxelsTool::SupervoxelsTool (PropertiesModel* parameter_model, QObject* parent) -: SplitItemTool (parameter_model, parent) -{ - -} +pcl::cloud_composer::SupervoxelsTool::SupervoxelsTool(PropertiesModel* parameter_model, + QObject* parent) +: SplitItemTool(parameter_model, parent) +{} -QList -pcl::cloud_composer::SupervoxelsTool::performAction (ConstItemList input_data, PointTypeFlags::PointType type) +QList +pcl::cloud_composer::SupervoxelsTool::performAction(ConstItemList input_data, + PointTypeFlags::PointType type) { - if (type != PointTypeFlags::NONE) - { - switch ((std::uint8_t) type) - { - case (PointTypeFlags::XYZ | PointTypeFlags::RGB): - return this->performTemplatedAction (input_data); - case (PointTypeFlags::XYZ | PointTypeFlags::RGBA): - return this->performTemplatedAction (input_data); + if (type != PointTypeFlags::NONE) { + switch ((std::uint8_t)type) { + case (PointTypeFlags::XYZ | PointTypeFlags::RGB): + return this->performTemplatedAction(input_data); + case (PointTypeFlags::XYZ | PointTypeFlags::RGBA): + return this->performTemplatedAction(input_data); } } - - QList output; - - qCritical () << "supervoxels requires templated types!"; - - return output; -} -template QList pcl::cloud_composer::SupervoxelsTool::performTemplatedAction (const QList &); -//template QList pcl::cloud_composer::SupervoxelsTool::performTemplatedAction (const QList &); + QList output; + + qCritical() << "supervoxels requires templated types!"; + + return output; +} +template QList +pcl::cloud_composer::SupervoxelsTool::performTemplatedAction( + const QList&); +// template QList +// pcl::cloud_composer::SupervoxelsTool::performTemplatedAction +// (const QList &); /////////////////// PARAMETER MODEL ///////////////////////////////// pcl::cloud_composer::PropertiesModel* -pcl::cloud_composer::SupervoxelsToolFactory::createToolParameterModel (QObject* parent) +pcl::cloud_composer::SupervoxelsToolFactory::createToolParameterModel(QObject* parent) { PropertiesModel* parameter_model = new PropertiesModel(parent); - - parameter_model->addProperty ("Resolution", 0.008, Qt::ItemIsEditable | Qt::ItemIsEnabled); - parameter_model->addProperty ("Seed Resolution", 0.08, Qt::ItemIsEditable | Qt::ItemIsEnabled); - parameter_model->addProperty ("RGB Weight", 0.2, Qt::ItemIsEditable | Qt::ItemIsEnabled); - parameter_model->addProperty ("Normals Weight", 0.8, Qt::ItemIsEditable | Qt::ItemIsEnabled); - parameter_model->addProperty ("Spatial Weight", 0.4, Qt::ItemIsEditable | Qt::ItemIsEnabled); - + + parameter_model->addProperty( + "Resolution", 0.008, Qt::ItemIsEditable | Qt::ItemIsEnabled); + parameter_model->addProperty( + "Seed Resolution", 0.08, Qt::ItemIsEditable | Qt::ItemIsEnabled); + parameter_model->addProperty( + "RGB Weight", 0.2, Qt::ItemIsEditable | Qt::ItemIsEnabled); + parameter_model->addProperty( + "Normals Weight", 0.8, Qt::ItemIsEditable | Qt::ItemIsEnabled); + parameter_model->addProperty( + "Spatial Weight", 0.4, Qt::ItemIsEditable | Qt::ItemIsEnabled); + return parameter_model; } diff --git a/apps/cloud_composer/tools/voxel_grid_downsample.cpp b/apps/cloud_composer/tools/voxel_grid_downsample.cpp index 5b15c3409d4..3590c273d32 100644 --- a/apps/cloud_composer/tools/voxel_grid_downsample.cpp +++ b/apps/cloud_composer/tools/voxel_grid_downsample.cpp @@ -1,88 +1,85 @@ -#include #include - +#include #include #include - Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") -pcl::cloud_composer::VoxelGridDownsampleTool::VoxelGridDownsampleTool (PropertiesModel* parameter_model, QObject* parent) - : ModifyItemTool (parameter_model, parent) -{ - - -} +pcl::cloud_composer::VoxelGridDownsampleTool::VoxelGridDownsampleTool( + PropertiesModel* parameter_model, QObject* parent) +: ModifyItemTool(parameter_model, parent) +{} -QList -pcl::cloud_composer::VoxelGridDownsampleTool::performAction (ConstItemList input_data, PointTypeFlags::PointType) +QList +pcl::cloud_composer::VoxelGridDownsampleTool::performAction(ConstItemList input_data, + PointTypeFlags::PointType) { - QList output; + QList output; const CloudComposerItem* input_item; // Check input data length - if ( input_data.empty ()) - { - qCritical () << "Empty input in VoxelGridDownsampleTool!"; + if (input_data.empty()) { + qCritical() << "Empty input in VoxelGridDownsampleTool!"; return output; } - if ( input_data.size () > 1) - { - qWarning () << "Input vector has more than one item in VoxelGridDownsampleTool"; + if (input_data.size() > 1) { + qWarning() << "Input vector has more than one item in VoxelGridDownsampleTool"; } - input_item = input_data.value (0); - - if (input_item->type () == CloudComposerItem::CLOUD_ITEM) - { - double leaf_x = parameter_model_->getProperty("Leaf Size x").toDouble (); - double leaf_y = parameter_model_->getProperty("Leaf Size y").toDouble (); - double leaf_z = parameter_model_->getProperty("Leaf Size z").toDouble (); - - pcl::PCLPointCloud2::ConstPtr input_cloud = input_item->data (ItemDataRole::CLOUD_BLOB).value (); - + input_item = input_data.value(0); + + if (input_item->type() == CloudComposerItem::CLOUD_ITEM) { + double leaf_x = parameter_model_->getProperty("Leaf Size x").toDouble(); + double leaf_y = parameter_model_->getProperty("Leaf Size y").toDouble(); + double leaf_z = parameter_model_->getProperty("Leaf Size z").toDouble(); + + pcl::PCLPointCloud2::ConstPtr input_cloud = + input_item->data(ItemDataRole::CLOUD_BLOB) + .value(); + //////////////// THE WORK - FILTERING OUTLIERS /////////////////// // Create the filtering object pcl::VoxelGrid vox_grid; - vox_grid.setInputCloud (input_cloud); - vox_grid.setLeafSize (float (leaf_x), float (leaf_y), float (leaf_z)); - - - //Create output cloud - pcl::PCLPointCloud2::Ptr cloud_filtered (new pcl::PCLPointCloud2); - //Filter! - vox_grid.filter (*cloud_filtered); + vox_grid.setInputCloud(input_cloud); + vox_grid.setLeafSize(float(leaf_x), float(leaf_y), float(leaf_z)); + + // Create output cloud + pcl::PCLPointCloud2::Ptr cloud_filtered(new pcl::PCLPointCloud2); + // Filter! + vox_grid.filter(*cloud_filtered); ////////////////////////////////////////////////////////////////// - //Get copies of the original origin and orientation - Eigen::Vector4f source_origin = input_item->data (ItemDataRole::ORIGIN).value (); - Eigen::Quaternionf source_orientation = input_item->data (ItemDataRole::ORIENTATION).value (); - //Put the modified cloud into an item, stick in output - CloudItem* cloud_item = new CloudItem (input_item->text () + tr (" vox ds") - , cloud_filtered - , source_origin - , source_orientation); + // Get copies of the original origin and orientation + Eigen::Vector4f source_origin = + input_item->data(ItemDataRole::ORIGIN).value(); + Eigen::Quaternionf source_orientation = + input_item->data(ItemDataRole::ORIENTATION).value(); + // Put the modified cloud into an item, stick in output + CloudItem* cloud_item = new CloudItem(input_item->text() + tr(" vox ds"), + cloud_filtered, + source_origin, + source_orientation); - - output.append (cloud_item); + output.append(cloud_item); } - else - { - qDebug () << "Input item in VoxelGridDownsampleTool is not a cloud!!!"; + else { + qDebug() << "Input item in VoxelGridDownsampleTool is not a cloud!!!"; } - - + return output; } /////////////////// PARAMETER MODEL ///////////////////////////////// pcl::cloud_composer::PropertiesModel* -pcl::cloud_composer::VoxelGridDownsampleToolFactory::createToolParameterModel (QObject* parent) +pcl::cloud_composer::VoxelGridDownsampleToolFactory::createToolParameterModel( + QObject* parent) { PropertiesModel* parameter_model = new PropertiesModel(parent); - - parameter_model->addProperty ("Leaf Size x", 0.01, Qt::ItemIsEditable | Qt::ItemIsEnabled); - parameter_model->addProperty ("Leaf Size y", 0.01, Qt::ItemIsEditable | Qt::ItemIsEnabled); - parameter_model->addProperty ("Leaf Size z", 0.01, Qt::ItemIsEditable | Qt::ItemIsEnabled); - + parameter_model->addProperty( + "Leaf Size x", 0.01, Qt::ItemIsEditable | Qt::ItemIsEnabled); + parameter_model->addProperty( + "Leaf Size y", 0.01, Qt::ItemIsEditable | Qt::ItemIsEnabled); + parameter_model->addProperty( + "Leaf Size z", 0.01, Qt::ItemIsEditable | Qt::ItemIsEnabled); + return parameter_model; }