cloud_viewer.cpp
Go to the documentation of this file.
00001 #include <pcl/apps/cloud_composer/qt.h>
00002 #include <pcl/apps/cloud_composer/cloud_viewer.h>
00003 #include <pcl/apps/cloud_composer/project_model.h>
00004 #include <pcl/apps/cloud_composer/cloud_view.h>
00005 
00006 pcl::cloud_composer::CloudViewer::CloudViewer (QWidget* parent)
00007   : QTabWidget (parent)
00008 
00009 {
00010   connect (this, SIGNAL (currentChanged (int)),
00011            this, SLOT (modelChanged (int)));
00012 }
00013 
00014 pcl::cloud_composer::CloudViewer::~CloudViewer ()
00015 {
00016   
00017 }
00018 
00019 void
00020 pcl::cloud_composer::CloudViewer::addModel (ProjectModel* new_model)
00021 {
00022   CloudView* new_view = new CloudView (new_model);
00023   connect (new_model->getSelectionModel (), SIGNAL (selectionChanged (QItemSelection,QItemSelection)),
00024            new_view, SLOT (selectedItemChanged (QItemSelection,QItemSelection)));
00025   new_model->setCloudView (new_view);
00026   
00027   QStandardItem* title = new_model->horizontalHeaderItem (0);
00028   this->addTab (new_view, title->text ());
00029   
00030   model_view_map_.insert (new_model,new_view);
00031   
00032   setCurrentWidget (model_view_map_.value (new_model));
00033   //Refresh the view
00034   new_view->refresh ();
00035 
00036 }
00037   
00038 pcl::cloud_composer::ProjectModel*
00039 pcl::cloud_composer::CloudViewer::getModel () const
00040 {
00041   if (this->count() == 0)
00042     return 0;
00043   else
00044     return dynamic_cast<CloudView*> (currentWidget ())->getModel (); 
00045 }
00046 
00047 void
00048 pcl::cloud_composer::CloudViewer::addNewProject (ProjectModel* new_model)
00049 {
00050   //If we're already there, abort
00051   if (new_model == getModel ())
00052     return;
00053   //Check whether we've seen the model yet
00054   if ( !model_view_map_.contains (new_model))
00055   {
00056     addModel (new_model);
00057   }
00058   else
00059   {
00060     setCurrentWidget (model_view_map_.value (new_model));
00061     //Refresh the view
00062     model_view_map_.value (new_model)->refresh ();
00063   }
00064 }
00065 
00066 void
00067 pcl::cloud_composer::CloudViewer::modelChanged (int index)
00068 {
00069   CloudView* view = static_cast<CloudView*> (this->widget (index)); view = view;
00070   emit newModelSelected (getModel ());
00071 }
00072 


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:22:46