コード例 #1
0
ファイル: main_window.cpp プロジェクト: sncn-private/PCL-OCL
pcl::ofd::MainWindow::MainWindow ()
  : ui_          (new Ui::MainWindow ()),
    vis_timer_ (new QTimer (this)),
    grabber_ (NULL)
{
  ui_->setupUi (this);

  QWidget* spacer = new QWidget ();
  spacer->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Expanding);


  //Initialize QVTK widget for OpenNI data display
  vis_.reset (new pcl::visualization::PCLVisualizer ("", false));
  vis_->addText("Initializing camera...", 50, 50, 22, 255.0, 1.0, 255.0, "InitInformation");
  ui_->qvtkWidget->SetRenderWindow (vis_->getRenderWindow ());
  vis_->setupInteractor (ui_->qvtkWidget->GetInteractor (), ui_->qvtkWidget->GetRenderWindow ());
  vis_->getInteractorStyle ()->setKeyboardModifier (pcl::visualization::INTERACTOR_KB_MOD_SHIFT);
  vis_->setShowFPS(false);
  ui_->qvtkWidget->update ();
  connect (vis_timer_, SIGNAL (timeout ()), this, SLOT (timeoutSlot ()));
  vis_timer_->start (5);

  // Init grabber as thread in "background"
  boost::thread initGrabberThread(boost::bind(&pcl::ofd::MainWindow::initGrabber, this));
  initGrabberThread.detach();


}
コード例 #2
0
ファイル: gtimer.cpp プロジェクト: EngReemBasheer/ring
GTimer::GTimer(QObject *parent,VM *pVM)  : QTimer(parent)
{
	this->pVM = pVM;
	strcpy(this->ctimeoutEvent,"");

	QObject::connect(this, SIGNAL(timeout()),this, SLOT(timeoutSlot()));

}
コード例 #3
0
ファイル: glf_render_widget.cpp プロジェクト: lihw/glf
void GLFRenderWidget::initializeGL()
{
    //
    // Initialize the GLEW.
    glewExperimental = GL_TRUE; 
    if (glewInit() != GLEW_OK)
    {
        qCritical("Fail to initialize GLEW");
        return ;
    }
    
    // FIXME: there's an OpenGL error in glewInit(), we need to
    // remove it before entering Kiwi context initialization.
    GLenum error = glGetError();

    // Get the display/drawable resolution.
    QRect rect = QApplication::desktop()->screenGeometry();
    qDebug("Display resolution: %d x %d", rect.width(), rect.height());
    qDebug("Drawable resolution: %d x %d", size().width(), size().height());

    // Get the information of OpenGL context.
    const char* profileStrings[] =
    {
        "No Profile",
        "Core Profile",
        "Compatibility Profile",
    };
    qDebug("OpenGL %d.%d %s", format().majorVersion(), format().minorVersion(),
        profileStrings[format().profile()]);

    qDebug("GL surface created. RGBA=(%d,%d,%d,%d), depth=%d, stencil=%d, multisample=%d", 
            format().redBufferSize(),
            format().greenBufferSize(),
            format().blueBufferSize(),
            format().alphaBufferSize(),
            format().depthBufferSize(),
            format().stencilBufferSize(),
            format().samples());
    
    _timer = new QTimer(this);
    connect(_timer, SIGNAL(timeout()), this, SLOT(timeoutSlot()));
    
    // FIXME: change the update frequency.
    _timer->start(5);

    // Initialize the viewport size
    glViewport(0, 0, width(), height());


    // Initialize the user renderer
    if (!_renderer->initialize())
    {
        delete _renderer;
        _renderer = NULL;
    }
}
コード例 #4
0
ファイル: timeoutsocket.cpp プロジェクト: wfairclough/TAE
/**
 * @brief connectToHost Overridden connectToHost() method to add timeout functionality;
 * @param host
 * @param port
 */
void TimeoutSocket::connectToHostWithTimeout(QString host, quint16 port, quint16 timeout) {
    this->disconnectFromHost();
    close();

    connect(mAuthTimeout, SIGNAL(timeout()), this, SLOT(timeoutSlot()));
    connect(this, SIGNAL(connected()), this, SLOT(connectedToHost()));
    mAuthTimeout->start(timeout);

    connectToHost(host, port);
}
コード例 #5
0
// Auto-open timeout method.
void qtractorFileListView::setAutoOpenTimeout ( int iAutoOpenTimeout )
{
	m_iAutoOpenTimeout = iAutoOpenTimeout;

	if (m_pAutoOpenTimer)
		delete m_pAutoOpenTimer;
	m_pAutoOpenTimer = 0;

	if (m_iAutoOpenTimeout > 0) {
		m_pAutoOpenTimer = new QTimer(this);
		QObject::connect(m_pAutoOpenTimer,
			SIGNAL(timeout()),
			SLOT(timeoutSlot()));
	}
}
コード例 #6
0
ファイル: qjackctlConnect.cpp プロジェクト: joelmo/qjackctl
// Auto-open timeout method.
void qjackctlClientListView::setAutoOpenTimeout ( int iAutoOpenTimeout )
{
	m_iAutoOpenTimeout = iAutoOpenTimeout;

	if (m_pAutoOpenTimer)
		delete m_pAutoOpenTimer;
	m_pAutoOpenTimer = NULL;

	if (m_iAutoOpenTimeout > 0) {
		m_pAutoOpenTimer = new QTimer(this);
		QObject::connect(m_pAutoOpenTimer,
			SIGNAL(timeout()),
			SLOT(timeoutSlot()));
	}
}
コード例 #7
0
void RemoteControl::initBuffer(unsigned char *buffer)
{
    QPixmap pm;
    pm = QPixmap::grabWindow(QApplication::desktop()->winId());

    pm = pm.scaled(maxx, maxy,Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
    QImage image = pm.toImage();

    int i, j;
    for(i=0; i<maxy; i++)
    {
        const uchar* data = image.scanLine(i);
        memcpy(&buffer[i*maxx*bpp], data, maxx*bpp);
    }

    //开始计时
    timer = new QTimer(this);
    connect(timer, SIGNAL(timeout()), this, SLOT(timeoutSlot()));
    timer->start(100);

}
コード例 #8
0
ファイル: timeoutsocket.cpp プロジェクト: wfairclough/TAE
/**
 * @brief TimeoutSocket::timeoutSlot
 */
void TimeoutSocket::timeoutSlot() {
    emit networkTimeout();
    disconnect(mAuthTimeout, SIGNAL(timeout()), this, SLOT(timeoutSlot()));
    this->disconnectFromHost();
    close();
}
コード例 #9
0
ファイル: timeoutsocket.cpp プロジェクト: wfairclough/TAE
/**
 * @brief TimeoutSocket::connectedToHost triggered when connected to host.
 */
void TimeoutSocket::connectedToHost() {
    disconnect(mAuthTimeout, SIGNAL(timeout()), this, SLOT(timeoutSlot()));
    disconnect(this, SIGNAL(connected()), this, SLOT(connectedToHost()));

    mAuthTimeout->stop(); // stop the timeout timer
}
コード例 #10
0
ファイル: mv_window.cpp プロジェクト: imod-mirror/IMOD
// Constructor for window
ImodvWindow::ImodvWindow(ImodvApp *a,
                         QWidget * parent, const char * name, Qt::WindowFlags f)
  : QMainWindow(parent, f)
{
  int numWidg = 0;
  const char *helpStr = "&Help";
  const char *useHelp = helpStr;
  double posValues[3];
  int numVals = 0;

  mRotationTool = NULL;
  mResizeTool = NULL;
  mDBw = mSBw = mDBstw = mSBstw = mDBalw = mDBstAlw = NULL;
  mMinimized = false;
  setAttribute(Qt::WA_DeleteOnClose);
  setAttribute(Qt::WA_AlwaysShowToolTips);

  QSignalMapper *fileMapper = new QSignalMapper(this);
  QSignalMapper *editMapper = new QSignalMapper(this);
  QSignalMapper *viewMapper = new QSignalMapper(this);
  QSignalMapper *helpMapper = new QSignalMapper(this);

  // construct file menu
  QMenu *fileMenu = menuBar()->addMenu("&File");
  ADD_ACTION_KEY(file, "&Open Model", VFILE_MENU_LOAD, Qt::CTRL + Qt::Key_O);
  mActions[VFILE_MENU_LOAD]->setEnabled(a->standalone);

  ADD_ACTION(file, "&Save Model", VFILE_MENU_SAVE);
  mActions[VFILE_MENU_SAVE]->setEnabled(a->standalone);

  ADD_ACTION(file, "Save Model &As...", VFILE_MENU_SAVEAS);
  mActions[VFILE_MENU_SAVEAS]->setEnabled(a->standalone);
  fileMenu->addSeparator();

  ADD_ACTION(file, "Snap &Tiff As...", VFILE_MENU_SNAPTIFF);
  ADD_ACTION(file, "Snap &NonT As...", VFILE_MENU_SNAPRGB);
  ADD_ACTION(file, "&Zero Snap File #", VFILE_MENU_ZEROSNAP);
  ADD_ACTION(file, "S&et Snap Dir...", VFILE_MENU_SNAPDIR);
  ADD_ACTION_KEY(file, "&Movie/Montage...", VFILE_MENU_MOVIE, Qt::Key_M);
  ADD_ACTION_KEY(file, "Movie Seque&nce...", VFILE_MENU_SEQUENCE, Qt::Key_N);

  ADD_ACTION_KEY(file, a->standalone ? "&Quit" : "&Close", VFILE_MENU_QUIT,
                 Qt::CTRL + Qt::Key_Q);

  connect(fileMapper, SIGNAL(mapped(int)), this, SLOT(fileMenuSlot(int)));

  // Construct Edit menu
  QMenu *editMenu = menuBar()->addMenu("&Edit");
  ADD_ACTION_KEY(edit, "&Objects...", VEDIT_MENU_OBJECTS, Qt::SHIFT + Qt::Key_O);
  ADD_ACTION_KEY(edit, "&Controls...", VEDIT_MENU_CONTROLS, Qt::SHIFT + Qt::Key_C);
  ADD_ACTION_KEY(edit, "&Rotation...", VEDIT_MENU_ROTATION, Qt::SHIFT + Qt::Key_R);
  ADD_ACTION_KEY(edit, "Object &List...", VEDIT_MENU_OBJLIST, Qt::SHIFT + Qt::Key_L);
  ADD_ACTION_KEY(edit, "&Background...", VEDIT_MENU_BKG, Qt::SHIFT + Qt::Key_B);
  ADD_ACTION_KEY(edit, "&Models...", VEDIT_MENU_MODELS, Qt::SHIFT + Qt::Key_M);
  ADD_ACTION_KEY(edit, "&Views...", VEDIT_MENU_VIEWS, Qt::SHIFT + Qt::Key_V);
  ADD_ACTION_KEY(edit, "&Image...", VEDIT_MENU_IMAGE, Qt::SHIFT + Qt::Key_I);
  ADD_ACTION_KEY(edit, "Isos&urface...", VEDIT_MENU_ISOSURFACE, Qt::SHIFT + Qt::Key_U);
  mActions[VEDIT_MENU_IMAGE]->setEnabled(imodvByteImagesExist() != 0);
  mActions[VEDIT_MENU_ISOSURFACE]->setEnabled(imodvByteImagesExist() != 0);
  connect(editMapper, SIGNAL(mapped(int)), this, SLOT(editMenuSlot(int)));

  // View menu
  QMenu *viewMenu = menuBar()->addMenu("&View");
  ADD_ACTION_KEY(view, "Low &Resolution", VVIEW_MENU_LOWRES, Qt::CTRL + Qt::Key_R);
  mActions[VVIEW_MENU_LOWRES]->setCheckable(true);
  mActions[VVIEW_MENU_LOWRES]->setChecked(a->lowres);
  if (!a->standalone) {
    ADD_ACTION_KEY(view, "&Current Point", VVIEW_MENU_CURPNT, Qt::Key_P);
    mActions[VVIEW_MENU_CURPNT]->setCheckable(true);
  }
  ADD_ACTION(view, "Bounding Bo&x", VVIEW_MENU_BOUNDBOX);
  mActions[VVIEW_MENU_BOUNDBOX]->setCheckable(true);

  ADD_ACTION(view, "&Stereo...", VVIEW_MENU_STEREO);
  ADD_ACTION(view, "&Depth Cue...", VVIEW_MENU_DEPTH);
  ADD_ACTION(view, "Scale &Bar...", VVIEW_MENU_SCALEBAR);
  ADD_ACTION(view, "Window Si&ze...", VVIEW_MENU_RESIZE);

  ADD_ACTION(view, "&Invert Z", VVIEW_MENU_INVERTZ);
  mActions[VVIEW_MENU_INVERTZ]->setCheckable(true);
  mActions[VVIEW_MENU_INVERTZ]->setChecked(a->invertZ);

  ADD_ACTION(view, "&Lighting", VVIEW_MENU_LIGHTING);
  mActions[VVIEW_MENU_LIGHTING]->setCheckable(true);
  mActions[VVIEW_MENU_LIGHTING]->setChecked(a->lighting);

  ADD_ACTION(view, "&Wireframe", VVIEW_MENU_WIREFRAME);
  mActions[VVIEW_MENU_WIREFRAME]->setCheckable(true);
  connect(viewMapper, SIGNAL(mapped(int)), this, SLOT(viewMenuSlot(int)));

  ADD_ACTION(view, "&Transparent Bkgd", VVIEW_MENU_TRANSBKGD);
  mActions[VVIEW_MENU_TRANSBKGD]->setCheckable(true);
  ADD_ACTION(view, "Do&uble Buffer", VVIEW_MENU_DB);

  // This made it act on a shifted D only and steal it from imodv_input
  //mViewMenu->setAccel(Qt::Key_D, VVIEW_MENU_DB);
  mActions[VVIEW_MENU_DB]->setCheckable(true);

  QMenu *keyMenu = menuBar()->addMenu("Hot&Keys");
  QSignalMapper *keyMapper = new QSignalMapper(this);
  connect(keyMapper, SIGNAL(mapped(int)), this, SLOT(keyMenuSlot(int)));
  utilBuildPopupMenu(sPopupTable, false, keyMapper, keyMenu, mNumKeyEntries, mActions);

  // Help menu
  // To stabilize the 3dmod menu with model view open, it had to have a 
  // modified menu name PLUS omit the code for the about entry - making it
  // conditional on standalone did not work!  Qt 4.5+ Cocoa Mac. 3/1/10
  // Even this is not perfect, if there is a 3dmodv already up.
#if defined(Q_OS_MACX) && QT_VERSION >= 0x040500
  const char *altHelp = ".&Help.";
  if (!a->standalone)
    useHelp = altHelp;
#endif
  QMenu *helpMenu = menuBar()->addMenu(useHelp);
  ADD_ACTION(help, "&Menus", VHELP_MENU_MENUS);
  ADD_ACTION(help, "&Keyboard", VHELP_MENU_KEYBOARD);
  ADD_ACTION(help, "M&ouse", VHELP_MENU_MOUSE);
#if !(defined(Q_OS_MACX) && QT_VERSION >= 0x040500)
  helpMenu->addSeparator();
  ADD_ACTION(help, "&About", VHELP_MENU_ABOUT);
#endif
  connect(helpMapper, SIGNAL(mapped(int)), this, SLOT(helpMenuSlot(int)));
  
  // Get the widget stack and the GL widgets
  mStack = new QStackedWidget(this);
  setCentralWidget(mStack);
  QGLFormat glFormat;

  if (a->enableDepthDB >= 0) { 
    mDBw = addGLWidgetToStack(&glFormat, true, a->enableDepthDB, false, false);
    mCurGLw = mDBw;
    numWidg++;
  }

  if (a->enableDepthDBal >= 0) { 
    mDBalw = addGLWidgetToStack(&glFormat, true, a->enableDepthDB, false, true);
    if (!numWidg) {
      mCurGLw = mDBalw;
      a->alphaVisual = 1;
    }
    numWidg++;
  }

  if (!numWidg && a->enableDepthDBst >= 0) { 
    mDBstw = addGLWidgetToStack(&glFormat, true, a->enableDepthDBst, true, false);
    if (!numWidg)
      mCurGLw = mDBstw;
    numWidg++;
  }

  if (!numWidg && a->enableDepthDBstAl >= 0) { 
    mDBstAlw = addGLWidgetToStack(&glFormat, true, a->enableDepthDBstAl, true, true);
    if (!numWidg) {
      mCurGLw = mDBstAlw;
      a->alphaVisual = 1;
    }
    numWidg++;
  }

  if (a->enableDepthSB >= 0) { 
    mSBw = addGLWidgetToStack(&glFormat, false, a->enableDepthSB, false, false);
    if (!numWidg) {
      mCurGLw = mSBw;
      a->dblBuf = 0;
    }
    numWidg++;
  }

  if (!numWidg && a->enableDepthSBst >= 0) { 
    mSBstw = addGLWidgetToStack(&glFormat, true, a->enableDepthSBst, true, false);
    if (!numWidg) {
      mCurGLw = mSBstw;
      a->dblBuf = 0;
    }
    numWidg++;
  }
  a->dbPossible = a->dblBuf;

  if (a->transBkgd) {
    if (a->dblBuf && a->enableDepthDBal >= 0) {
      mCurGLw = mDBalw;
      a->alphaVisual = 1;
    } else {
      a->transBkgd = 0;
    }
  }

  // Set the topmost widget of the stack
  mStack->setCurrentWidget(mCurGLw);
  mActions[VVIEW_MENU_DB]->setChecked(a->dblBuf > 0);
  mActions[VVIEW_MENU_DB]->setEnabled(a->dblBuf > 0 && a->enableDepthSB >= 0 && 
                                      !a->transBkgd);
  mActions[VVIEW_MENU_TRANSBKGD]->setChecked(a->transBkgd > 0);
  mActions[VVIEW_MENU_TRANSBKGD]->setEnabled(a->dblBuf > 0 && (a->enableDepthDBal >= 0 || 
                                                           a->enableDepthDBstAl >= 0));

  mTimer = new QTimer(this);
  connect(mTimer, SIGNAL(timeout()), this, SLOT(timeoutSlot()));

  // First time, get the preferences for rotation tool and store in statics
  if (sRToolWithImodv < 0) {
    numVals = ImodPrefs->getGenericSettings("ModvRotationTool", posValues, 3);
    if (numVals > 1) {
      sRToolLeftPos = (int)posValues[0];
      sRToolTopPos = (int)posValues[1];
    }
    if (numVals > 2) 
      sRToolWithImodv = (int)posValues[2];
    else
      sRToolWithImodv = 0;
  }

  // Open tool if it closed with window before
  if (sRToolWithImodv > 0)
    openRotationTool(a);
}
コード例 #11
0
 void startTimer() {
     stopwatch.start();
     timer = new QTimer(this);
     QObject::connect(timer, SIGNAL(timeout()), this, SLOT(timeoutSlot()));
     timer->start(1000);
 }
コード例 #12
0
OrganizedSegmentationDemo::OrganizedSegmentationDemo (pcl::Grabber& grabber) : grabber_ (grabber)
{
  //Create a timer
  vis_timer_ = new QTimer (this);
  vis_timer_->start (5);//5ms

  connect (vis_timer_, SIGNAL (timeout ()), this, SLOT (timeoutSlot()));

  ui_ = new Ui::MainWindow;
  ui_->setupUi (this);
  
  this->setWindowTitle ("PCL Organized Connected Component Segmentation Demo");
  vis_.reset (new pcl::visualization::PCLVisualizer ("", false));
  ui_->qvtk_widget->SetRenderWindow (vis_->getRenderWindow ());
  vis_->setupInteractor (ui_->qvtk_widget->GetInteractor (), ui_->qvtk_widget->GetRenderWindow ());
  vis_->getInteractorStyle ()->setKeyboardModifier (pcl::visualization::INTERACTOR_KB_MOD_SHIFT);
  ui_->qvtk_widget->update ();

  boost::function<void (const CloudConstPtr&)> f = boost::bind (&OrganizedSegmentationDemo::cloud_cb, this, _1);
  boost::signals2::connection c = grabber_.registerCallback(f);
  
  connect (ui_->captureButton, SIGNAL(clicked()), this, SLOT(toggleCapturePressed()));

  connect (ui_->euclideanComparatorButton, SIGNAL (clicked ()), this, SLOT (useEuclideanComparatorPressed ()));
  connect (ui_->planeComparatorButton, SIGNAL (clicked ()), this, SLOT (usePlaneComparatorPressed ()));
  connect (ui_->rgbComparatorButton, SIGNAL (clicked ()), this, SLOT (useRGBComparatorPressed ()));
  connect (ui_->edgeAwareComparatorButton, SIGNAL (clicked ()), this, SLOT (useEdgeAwareComparatorPressed ()));

  connect (ui_->displayCurvatureButton, SIGNAL (clicked ()), this, SLOT (displayCurvaturePressed ()));
  connect (ui_->displayDistanceMapButton, SIGNAL (clicked ()), this, SLOT (displayDistanceMapPressed ()));
  connect (ui_->displayNormalsButton, SIGNAL (clicked ()), this, SLOT (displayNormalsPressed ()));

  connect (ui_->disableRefinementButton, SIGNAL (clicked ()), this, SLOT (disableRefinementPressed ()));
  connect (ui_->planarRefinementButton, SIGNAL (clicked ()), this, SLOT (usePlanarRefinementPressed ()));

  connect (ui_->disableClusteringButton, SIGNAL (clicked ()), this, SLOT (disableClusteringPressed ()));
  connect (ui_->euclideanClusteringButton, SIGNAL (clicked ()), this, SLOT (useEuclideanClusteringPressed ()));

  capture_ = false;
  previous_data_size_ = 0;
  previous_clusters_size_ = 0;
  data_modified_ = true;

  display_normals_ = false;
  display_curvature_ = false;
  display_distance_map_ = false;

  use_planar_refinement_ = true;
  use_clustering_ = false;
  

  // Set up Normal Estimation
  //ne.setNormalEstimationMethod (ne.SIMPLE_3D_GRADIENT);
  ne.setNormalEstimationMethod (ne.COVARIANCE_MATRIX);
  ne.setMaxDepthChangeFactor (0.02);
  ne.setNormalSmoothingSize (20.0);

  plane_comparator_.reset (new pcl::PlaneCoefficientComparator<PointT, pcl::Normal> ());
  euclidean_comparator_.reset (new pcl::EuclideanPlaneCoefficientComparator<PointT, pcl::Normal> ());
  rgb_comparator_.reset (new pcl::RGBPlaneCoefficientComparator<PointT, pcl::Normal> ());
  edge_aware_comparator_.reset (new pcl::EdgeAwarePlaneComparator<PointT, pcl::Normal> ());
  euclidean_cluster_comparator_ = pcl::EuclideanClusterComparator<PointT, pcl::Normal, pcl::Label>::Ptr (new pcl::EuclideanClusterComparator<PointT, pcl::Normal, pcl::Label> ());

  // Set up Organized Multi Plane Segmentation
  mps.setMinInliers (10000);
  mps.setAngularThreshold (pcl::deg2rad (3.0)); //3 degrees
  mps.setDistanceThreshold (0.02); //2cm
  

  PCL_INFO ("starting grabber\n");
  grabber_.start ();
}