render_window_item.cpp
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Point Cloud Library (PCL) - www.pointclouds.org
00005  *  Copyright (c) 2012, Willow Garage, Inc.
00006  *  All rights reserved.
00007  *
00008  *  Redistribution and use in source and binary forms, with or without
00009  *  modification, are permitted provided that the following conditions
00010  *  are met:
00011  *
00012  *   * Redistributions of source code must retain the above copyright
00013  *     notice, this list of conditions and the following disclaimer.
00014  *   * Redistributions in binary form must reproduce the above
00015  *     copyright notice, this list of conditions and the following
00016  *     disclaimer in the documentation and/or other materials provided
00017  *     with the distribution.
00018  *   * Neither the name of Willow Garage, Inc. nor the names of its
00019  *     contributors may be used to endorse or promote products derived
00020  *     from this software without specific prior written permission.
00021  *
00022  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00023  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00024  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00025  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00026  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00027  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00028  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00029  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00030  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00031  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00032  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00033  *  POSSIBILITY OF SUCH DAMAGE.
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 }


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:32:08