int Utils::savePointCloud(const CloudPtr &cloud, const std::string &path) { if (path.empty()) return -6; std::string ext(path.substr(path.rfind('.') == std::string::npos ? path.length() : path.rfind('.') + 1)); if (ext == "pcd" || ext == "PCD") { if (pcl::io::savePCDFileBinaryCompressed(path, *cloud) != 0) return -1; } if (ext == "ply" || ext == "PLY") { if (pcl::io::savePLYFileASCII(path, *cloud) != 0) return -1; } if (ext == "txt" || ext == "TXT") { if (saveTXTFile(path, *cloud) != 0) return -1; } return 0; }
//Create a CGLWin widget CGLWin::CGLWin(void): QMainWindow( 0, "View3D", WDestructiveClose), m_pListViews(NULL) { int i; // Data members; CGLDrawParms tDraw; _drawParms = tDraw; m_nTimeDelay = 0; for (i=0; i<VIEW3D_MAX_OBJ_COUNT; i++) _pCia3dObjs[i] = NULL; // setup printer m_pPrinter = new QPrinter; // GUI members, create a toolbar; m_pToolBar = _createToolBar(); // populate a menu with all actions m_pMenuBar = menuBar(); assert(m_pMenuBar!=NULL); //====================File options ========================== { QPopupMenu * file = new QPopupMenu( this ); menuBar()->insertItem( "&File ", file ); _fileNewAction->addTo( file ); _fileOpenAction->addTo( file ); _fileSaveAction->addTo( file ); file->insertSeparator(); file->insertItem( "Open Background", this, SLOT(openBackgroundImage()), NULL); file->insertItem( "Load Camera", this, SLOT(loadCamera()), NULL); file->insertItem( "Save Camera", this, SLOT(saveCamera()), NULL); file->insertSeparator(); //=========================== file->insertItem( "Export Povray", this, SLOT(exportPovray()), NULL); file->insertItem( "Export STL", this, SLOT(saveSTLFile()), NULL); file->insertItem( "Export TXT", this, SLOT(saveTXTFile()), NULL); file->insertItem( "Export EPS", this, SLOT(exportEps()), NULL); file->insertSeparator(); //=========================== _filePrintAction->addTo( file ); file->insertSeparator(); //=========================== file->insertItem( "E&xit", qApp, SLOT(closeAllWindows()), NULL); } //================ Tools Options ================================ { QPopupMenu * pMenuTools = new QPopupMenu( this ); menuBar()->insertItem( "&Tools", pMenuTools ); pMenuTools->insertItem( "Show Entire Scene", this, SLOT(show_entirescene())); pMenuTools->insertItem( "Dupe Current Object", this, SLOT(dupe_currentobj())); pMenuTools->insertItem( "Dupe Current Object N", this, SLOT(dupe_currentobjN())); {// Animation options pMenuTools->insertSeparator(); //======================= QPopupMenu * pAnimOption = new QPopupMenu( this ); pMenuTools->insertItem( "&Prepare Animation", pAnimOption); pAnimOption->insertItem( "Setup", this, SLOT(create_animation())); QAction* startAction = new QAction(QPixmap(play_xpm), "&Start Animation", Qt::Key_F10, this); connect(startAction, SIGNAL(activated()), this, SLOT(startAnimation())); startAction->addTo( pAnimOption ); pAnimOption->insertItem( "Stop Animation", this, SLOT(stopAnimation()), Qt::Key_F11); pAnimOption->insertItem( "Change Delay Time", this, SLOT(editDelayTime())); {//toggle fast draw mode m_pActRepeatPlay = new QAction("Repeat", CTRL+Key_T, this); connect(m_pActRepeatPlay, SIGNAL(activated()), this, SLOT(toggleRepeatPlay())); m_pActRepeatPlay->setToggleAction(true); m_pActRepeatPlay->setOn(false); m_pActRepeatPlay->addTo( pAnimOption ); } } pMenuTools->insertSeparator(); //======================= {// Stereo options QPopupMenu * pStereoOption = new QPopupMenu( this ); pMenuTools->insertItem( "&Stereo", pStereoOption); QAction* m_pActToggleStereo = new QAction("Stereo Mode", Qt::Key_F12, this); connect(m_pActToggleStereo, SIGNAL(activated()), this, SLOT(toggleStereo())); m_pActToggleStereo->setToggleAction(true); m_pActToggleStereo->setOn(false); m_pActToggleStereo->addTo( pStereoOption ); pStereoOption->insertItem( "Increase Eye Distance", this, SLOT(incEyeDistance()), Qt::Key_Plus); pStereoOption->insertItem( "Decrease Eye Distance", this, SLOT(decEyeDistance()), Qt::Key_Minus); } //pMenuTools->insertItem( "Rotation Axis", this, SLOT(InputRotationAxis()), NULL); //pMenuTools->insertItem( "Mirror Plane", this, SLOT(InputMirrorPlane()), NULL); //pMenuTools->insertSeparator(); //pMenuTools->insertItem( "Vector Hidden Line Removal", this, SLOT(hidden_line()), CTRL+Key_H); //pMenuTools->insertSeparator(); //======================= pMenuTools->insertSeparator(); //======================= pMenuTools->insertItem( "Set Mirror Plane", this, SLOT(InputMirrorPlane())); pMenuTools->insertItem( "Set Rotation Axis", this, SLOT(InputRotationAxis())); } //================ Rendering options ================================ { QPopupMenu * pMenuOption = new QPopupMenu( this ); menuBar()->insertItem( "&Options", pMenuOption ); pMenuOption->insertItem( "Global Setting", this, SLOT(OptionGlobalSetting())); pMenuOption->insertItem( "Surface Rendering", this, SLOT(OptionRendering())); pMenuOption->insertItem( "Volume Rendering", this, SLOT(OptionVolumeRendering())); pMenuOption->insertSeparator(); //======================= { QPopupMenu * pPickOption = new QPopupMenu( this ); pMenuOption->insertItem( "&Picking Types", pPickOption); pPickOption->insertItem( "Pick an Object", this, SLOT(set_obj_picking())); pPickOption->insertItem( "Pick a Polygon", this, SLOT(set_face_picking())); pPickOption->insertItem( "Pick a Line", this, SLOT(set_line_picking())); } QAction* act_mirroring = new QAction("Mirroring", 0, this); connect( act_mirroring, SIGNAL(activated()), this, SLOT(OptionMirroring())); act_mirroring->setToggleAction(true); act_mirroring->setOn(false); act_mirroring->addTo( pMenuOption ); m_pMirroringAction = act_mirroring; QPopupMenu * pRotOption = new QPopupMenu( this ); pMenuOption->insertItem( "&Rotation Types", pRotOption); QAction* act_rot0obj = new QAction("Rotate 90 Degree", 0, this); connect( act_rot0obj, SIGNAL(activated()), this, SLOT(OptionRotate90())); act_rot0obj->addTo( pRotOption ); QAction* act_rot1obj = new QAction("Rotate 180 Degree", 0, this); connect( act_rot1obj, SIGNAL(activated()), this, SLOT(OptionRotate180())); act_rot1obj->addTo( pRotOption ); QAction* act_rot2obj = new QAction("Rotate 270 Degree", 0, this); connect( act_rot2obj, SIGNAL(activated()), this, SLOT(OptionRotate270())); act_rot2obj->addTo( pRotOption ); m_pRot90Action = act_rot0obj; m_pRot180Action = act_rot1obj; m_pRot270Action = act_rot2obj; m_pRot90Action->setToggleAction(true); m_pRot90Action->setOn(false); m_pRot180Action->setToggleAction(true); m_pRot180Action->setOn(false); m_pRot270Action->setToggleAction(true); m_pRot270Action->setOn(false); //show background image buttion QAction* act_showbgimg = new QAction("Background Image", 0, this); connect( act_showbgimg, SIGNAL(activated()), this, SLOT(ShowBackgroundImage())); act_showbgimg->setToggleAction(true); act_showbgimg->setOn(false); act_showbgimg->addTo( pMenuOption ); m_pBGImageAction = act_showbgimg; //show floor plane buttion QAction* act_showfloor = new QAction(QString::fromLocal8Bit("Floor Plane"), 0, this); connect( act_showfloor, SIGNAL(activated()), this, SLOT(ShowFloor())); act_showfloor->setToggleAction(true); act_showfloor->setOn(false); act_showfloor->addTo( pMenuOption ); m_pFloorAction = act_showfloor; {//Toggle fast draw mode m_pActFastDraw = new QAction("Fast Drawing", 0, this); connect(m_pActFastDraw, SIGNAL(activated()), this, SLOT(toggleFastDraw())); m_pActFastDraw->setToggleAction(true); m_pActFastDraw->setOn(false); m_pActFastDraw->addTo( pMenuOption ); } } //========change opengl window size ========================== { QPopupMenu * pMenuGLWinsize = new QPopupMenu( this ); menuBar()->insertItem( "&Window", pMenuGLWinsize ); pMenuGLWinsize->insertItem( "320x200", this, SLOT(setGLWinSize320x200()), CTRL+Qt::Key_3); pMenuGLWinsize->insertItem( "400x400", this, SLOT(setGLWinSize400x400()), CTRL+Qt::Key_4); pMenuGLWinsize->insertItem( "500x400", this, SLOT(setGLWinSize500x400()), CTRL+Qt::Key_5); pMenuGLWinsize->insertItem( "500x500", this, SLOT(setGLWinSize500x500()), CTRL+Qt::Key_2 ); pMenuGLWinsize->insertItem( "640x480", this, SLOT(setGLWinSize640x480()), CTRL+Qt::Key_6); pMenuGLWinsize->insertItem( "800x600", this, SLOT(setGLWinSize800x600()), CTRL+Qt::Key_8); pMenuGLWinsize->insertItem( "1024x768", this, SLOT(setGLWinSize1024x768()), CTRL+Qt::Key_1); pMenuGLWinsize->insertSeparator(); pMenuGLWinsize->insertItem( "Swap Width/Height", this, SLOT(swapWidthHeight()), CTRL+Key_W); pMenuGLWinsize->insertItem( "Input Width/Height", this, SLOT(inputWidthHeight()), CTRL+Key_I); } /* { QPopupMenu * pPopMenu = new QPopupMenu( this ); menuBar()->insertItem( "&My Research", pPopMenu ); pPopMenu->insertItem( "Bar Recons", this, SLOT(detail_recon_bar())); pPopMenu->insertItem( "Vase Recons", this, SLOT(detail_recon_vase())); pPopMenu->insertSeparator(); pPopMenu->insertItem( "Letter Size Plate", this, SLOT(detail_recon_a4plate())); pPopMenu->insertSeparator(); pPopMenu->insertItem( "Detail Recon Dialog", this, SLOT(detail_recon_anyobj())); } */ //================ end Rendering options ================================ QGLFormat format; format.setStereo( true ); m_pGLUIWin = new Viewer(format, this, "Viewer3D"); assert(m_pGLUIWin!=NULL); statusBar()->setFixedHeight( fontMetrics().height() + 6 ); statusBar()->message( "Viewer ready", 3000 ); setCentralWidget(m_pGLUIWin); m_pGLUIWin->setDrawingData(&_drawParms); m_pGLUIWin->m_SceneGraph.hookObject(m_pGLUIWin); m_pGLUIWin->m_SceneGraph.hookGLWindow(m_pGLUIWin); //================ dock window================== QString appDir; m_pFemBar=_createDockWidgetBar(this, appDir); }