Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #include <pcl/apps/modeler/render_window_item.h>
00038 #include <pcl/apps/modeler/render_window.h>
00039 #include <pcl/apps/modeler/cloud_mesh_item.h>
00040 #include <pcl/apps/modeler/main_window.h>
00041 #include <pcl/apps/modeler/parameter.h>
00042 #include <pcl/apps/modeler/parameter_dialog.h>
00043
00044
00046 pcl::modeler::RenderWindowItem::RenderWindowItem(QTreeWidget * parent)
00047 : QTreeWidgetItem(parent),
00048 AbstractItem(),
00049 render_window_(new RenderWindow(this)),
00050 background_color_(new ColorParameter("Background Color", "The background color of the render window", QColor(0, 0, 0))),
00051 show_axes_(new BoolParameter("Show Axes", "Show Axes", true))
00052 {
00053 setFlags(flags()&(~Qt::ItemIsDragEnabled));
00054 }
00055
00057 pcl::modeler::RenderWindowItem::~RenderWindowItem()
00058 {
00059 render_window_->deleteLater();
00060 }
00061
00063 bool
00064 pcl::modeler::RenderWindowItem::openPointCloud(const QString& filename)
00065 {
00066 CloudMeshItem* cloud_mesh_item = new CloudMeshItem(this, filename.toStdString());
00067 addChild(cloud_mesh_item);
00068
00069 if (!cloud_mesh_item->open())
00070 {
00071 removeChild(cloud_mesh_item);
00072 delete cloud_mesh_item;
00073 return (false);
00074 }
00075
00076 treeWidget()->setCurrentItem(cloud_mesh_item);
00077
00078 return (true);
00079 }
00080
00082 pcl::modeler::CloudMeshItem*
00083 pcl::modeler::RenderWindowItem::addPointCloud(CloudMesh::PointCloudPtr cloud)
00084 {
00085 CloudMeshItem* cloud_mesh_item = new CloudMeshItem(this, cloud);
00086 addChild(cloud_mesh_item);
00087
00088 treeWidget()->setCurrentItem(cloud_mesh_item);
00089
00090 return (cloud_mesh_item);
00091 }
00092
00094 void
00095 pcl::modeler::RenderWindowItem::prepareContextMenu(QMenu* menu) const
00096 {
00097 menu->addAction(ui()->actionOpenPointCloud);
00098 menu->addAction(ui()->actionImportPointCloud);
00099 if (treeWidget()->topLevelItem(0) != this && childCount() == 0)
00100 menu->addAction(ui()->actionCloseRenderWindow);
00101 }
00102
00104 void
00105 pcl::modeler::RenderWindowItem::prepareProperties(ParameterDialog* parameter_dialog)
00106 {
00107 double r, g, b;
00108 render_window_->getBackground(r, g, b);
00109 QColor color(static_cast<int> (r*255), static_cast<int> (g*255), static_cast<int> (b*255));
00110 background_color_->setDefaultValue(color);
00111 parameter_dialog->addParameter(background_color_);
00112 parameter_dialog->addParameter(show_axes_);
00113 }
00114
00116 void
00117 pcl::modeler::RenderWindowItem::setProperties()
00118 {
00119 QColor color = *background_color_;
00120 render_window_->setBackground(color.red()/255.0, color.green()/255.0, color.blue()/255.0);
00121
00122 render_window_->setShowAxes(*show_axes_);
00123
00124 return;
00125 }