1 /* 2 * Software License Agreement (BSD License) 3 * 4 * Point Cloud Library (PCL) - www.pointclouds.org 5 * Copyright (c) 2012, Jeremie Papon. 6 * 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 13 * * Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * * Redistributions in binary form must reproduce the above 16 * copyright notice, this list of conditions and the following 17 * disclaimer in the documentation and/or other materials provided 18 * with the distribution. 19 * * Neither the name of Willow Garage, Inc. nor the names of its 20 * contributors may be used to endorse or promote products derived 21 * from this software without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 29 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 33 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 * POSSIBILITY OF SUCH DAMAGE. 35 * 36 */ 37 38 #pragma once 39 40 #include <pcl/point_types.h> 41 #include <pcl/visualization/pcl_visualizer.h> 42 #include <pcl/apps/cloud_composer/properties_model.h> 43 44 static QStringList ITEM_TYPES_STRINGS(QStringList() 45 << "Cloud Composer Item" 46 << "Cloud Item" 47 << "Normals Item" 48 << "FPFH Item" 49 ); 50 51 namespace pcl 52 { 53 namespace cloud_composer 54 { 55 class PropertiesModel; 56 namespace ItemDataRole 57 { 58 enum 59 { 60 PROPERTIES = Qt::UserRole, 61 ITEM_ID, 62 CLOUD_BLOB, 63 CLOUD_TEMPLATED, 64 GEOMETRY_HANDLER, 65 COLOR_HANDLER, 66 ORIGIN, 67 ORIENTATION, 68 KD_TREE_SEARCH 69 }; 70 }; 71 class CloudComposerItem : public QStandardItem 72 { 73 public: 74 75 76 enum ItemType 77 { 78 CLOUD_COMPOSER_ITEM = QStandardItem::UserType, 79 CLOUD_ITEM, 80 NORMALS_ITEM, 81 FPFH_ITEM 82 }; 83 84 CloudComposerItem (const QString& name = "default item"); 85 CloudComposerItem (const CloudComposerItem& to_copy); 86 ~CloudComposerItem (); 87 88 inline int type()89 type () const override { return CLOUD_COMPOSER_ITEM; } 90 91 /** \brief Convenience function to get Item's ID String */ 92 inline QString getId()93 getId () const { return data (ItemDataRole::ITEM_ID).toString (); } 94 95 /** \brief Convenience function to get Item's Property Pointer */ 96 inline PropertiesModel* getPropertiesModel()97 getPropertiesModel () const { return properties_; } 98 99 /** \brief Returns all children of item type type*/ 100 QList <CloudComposerItem*> 101 getChildren (ItemType type) const; 102 103 void 104 addChild (CloudComposerItem* item_arg); 105 106 CloudComposerItem* 107 clone () const override; 108 109 // /** \brief Convenience function which pulls out a cloud Ptr of type CloudPtrT */ 110 // template <typename CloudPtrT> 111 // CloudPtrT 112 // getCloudPtr () const; 113 114 /** \brief Paint View function - reimpliment in item subclass if it can be displayed in PCLVisualizer*/ 115 virtual void 116 paintView (pcl::visualization::PCLVisualizer::Ptr vis) const; 117 118 /** \brief Remove from View function - reimpliment in item subclass if it can be displayed in PCLVisualizer*/ 119 virtual void 120 removeFromView (pcl::visualization::PCLVisualizer::Ptr vis) const; 121 122 /** \brief Inspector additional tabs paint function - reimpliment in item subclass if item has additional tabs to show in Inspector*/ 123 virtual QMap <QString, QWidget*> 124 getInspectorTabs (); 125 126 /** \brief The property model calls this when a property changes */ 127 inline void propertyChanged()128 propertyChanged () 129 { 130 emitDataChanged (); 131 } 132 133 virtual bool isSanitized()134 isSanitized () const { return false; } 135 protected: 136 137 /** \brief Model for storing the properties of the item - pointer kept for convenience */ 138 PropertiesModel* properties_; 139 140 }; 141 142 143 144 /** \brief Templated helper class for converting QVariant to/from pointer classes */ 145 template <class T> class VPtr 146 { 147 public: asPtr(const QVariant & v)148 static T* asPtr (const QVariant& v) 149 { 150 return (static_cast<T *> (v.value<void *> ())); 151 } 152 asQVariant(T * ptr)153 static QVariant asQVariant (T* ptr) 154 { 155 return (QVariant::fromValue (static_cast<void*>(ptr))); 156 } 157 }; 158 159 } 160 } 161 162 using ConstItemList = QList<const pcl::cloud_composer::CloudComposerItem *>; 163 164 Q_DECLARE_METATYPE (pcl::cloud_composer::CloudComposerItem); 165