bool MainWindow::eventFilter(QObject *obj, QEvent *event) { if (obj == scene) { QGraphicsSceneMouseEvent* mouseEvent; switch(event->type()) { // ** MOUSE BUTTON RELEASE ** // case QEvent::GraphicsSceneMouseRelease: { mouseEvent = static_cast<QGraphicsSceneMouseEvent*>(event); QPoint pos = mouseEvent->scenePos().toPoint(); if (mouseEvent->button() == Qt::LeftButton) { if (inputPoints == 0 || inputPoints == 1) points[inputPoints++] = pos; if (inputPoints == 2) { // We've finished adding points now. view->setCursor(Qt::ArrowCursor); updateScene(); } } return true; } // ** MOUSE MOVED ** // case QEvent::GraphicsSceneMouseMove: { mouseEvent = static_cast<QGraphicsSceneMouseEvent*>(event); QPoint pos = mouseEvent->scenePos().toPoint(); if (inputPoints == 0) { points[0] = pos; updateScene(); } if (inputPoints == 1) { points[1] = pos; updateScene(); } return true; } default: return QMainWindow::eventFilter(obj, event); } } // pass the event on to the parent class return QMainWindow::eventFilter(obj, event); }
void Qgs3DMapScene::onCameraChanged() { updateScene(); bool changedCameraPlanes = updateCameraNearFarPlanes(); if ( changedCameraPlanes ) { // repeat update of entities - because we have updated camera's near/far planes, // the active nodes may have changed as well updateScene(); updateCameraNearFarPlanes(); } }
void ImageCalibrator::on_CropW_valueChanged(int arg1) { if(ImgCalibratorLock) return; imgOffsets[frmX][frmY].W = arg1; updateScene(); }
void ImageCalibrator::on_FrameY_valueChanged(int arg1) { if(ImgCalibratorLock) return; frmY = arg1; updateControls(); updateScene(); }
void GameWrapper::updateScene() { // http://gafferongames.com/game-physics/fix-your-timestep/ double newTime = timingSource->GetCurrentTimeInSeconds(); double frameTime = newTime - currentTime; if ( frameTime > 0.25 ) frameTime = 0.25; // note: max frame time to avoid spiral of death currentTime = newTime; accumulator += frameTime; bool continueUpdating = true; while ( continueUpdating && accumulator >= dt ) { sceneManager->getCurrentScene()->stepSimulation(dt); inputManager->resetForNextFrame(); continueUpdating = sceneManager->checkSceneTransition(); accumulator -= dt; } if(!continueUpdating) { currentTime = timingSource->GetCurrentTimeInSeconds() - dt; accumulator = 0.0; updateScene(); } }
void QtOpenCVViewerGl::resizeGL(int width, int height) { makeCurrent(); glViewport(0, 0, (GLint)width, (GLint)height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, width, 0, height, 0, 1); // To Draw image in the center of the area glMatrixMode(GL_MODELVIEW); // ---> Scaled Image Sizes mOutH = width/mImgRatio; mOutW = width; if(mOutH>height) { mOutW = height*mImgRatio; mOutH = height; } emit imageSizeChanged( mOutW, mOutH ); // <--- Scaled Image Sizes mPosX = (width-mOutW)/2; mPosY = (height-mOutH)/2; mSceneChanged = true; updateScene(); }
void QtOpenCVViewerGl::showImage( cv::Mat image ) { cv::circle(image, cv::Point(image.cols/2, image.rows/2), 1, CV_RGB(0,255,0), 2); image.copyTo(mOrigImage); mImgRatio = (float)image.cols/(float)image.rows; if( mOrigImage.channels() == 3) mRenderQtImg = QImage((const unsigned char*)(mOrigImage.data), mOrigImage.cols, mOrigImage.rows, mOrigImage.step, QImage::Format_RGB888).rgbSwapped(); else if( mOrigImage.channels() == 1) mRenderQtImg = QImage((const unsigned char*)(mOrigImage.data), mOrigImage.cols, mOrigImage.rows, mOrigImage.step, QImage::Format_Indexed8); else return; mRenderQtImg = QGLWidget::convertToGLFormat(mRenderQtImg); mSceneChanged = true; updateScene(); return; }
void CalibrationMain::OpenFile(QString fileName) { QList<QString > tmp; QString imgFileM; QFileInfo ourFile(fileName); currentFile = fileName; LastOpenDir = ourFile.absoluteDir().path(); tmp = ourFile.fileName().split(".", QString::SkipEmptyParts); if(tmp.size()==2) imgFileM = tmp[0] + "m." + tmp[1]; else imgFileM = ""; //mask = ; QImage maskImg; if(QFile::exists(ourFile.absoluteDir().path() + "/" + imgFileM)) maskImg = Graphics::loadQImage( ourFile.absoluteDir().path() + "/" + imgFileM ); else maskImg = QImage(); x_imageSprite = QPixmap::fromImage( Graphics::setAlphaMask( Graphics::loadQImage( fileName ) , maskImg ) ); loadConfig(fileName); initScene(); updateControls(); updateScene(); }
void CalibrationMain::on_PasteButton_clicked() { framesX[frmX][frmY] = buffer; updateControls(); updateScene(); }
void CalibrationMain::on_Width_valueChanged(int arg1) { if(lockControls) return; framesX[frmX][frmY].W = arg1; frameWidth = arg1; updateScene(); }
void CalibrationMain::on_Height_valueChanged(int arg1) { if(lockControls) return; framesX[frmX][frmY].H = arg1; frameHeight = arg1; updateScene(); }
int executeApplication() { MSG msg = {0}; TimerUtils::reset(Globals::gTimer); while (msg.message != WM_QUIT) { // If there are Window messages then process them. if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } // Otherwise, do animation/game stuff. else { TimerUtils::tick(Globals::gTimer); if (!Globals::gWindowState.mIsPaused) { calculateFrameStats(); updateScene(static_cast<float> (Globals::gTimer.mDeltaTime)); drawScene(); } else { Sleep(100); } } } destroy(); return static_cast<int> (msg.wParam); }
void incOffset(float xInc, float yInc) { mOffset[0] += xInc; mOffset[1] += yInc; std::cout << "Offset: " << mOffset << std::endl; updateScene(); }
/** * Deploy particles over the volume */ void MainWindow::on_actionDeploy_triggered() { g_pointList.clear(); g_numberOfPoints = ui.numberOfParticles->value(); const unsigned nVars = g_numberOfPoints * POINT_DIMENSIONS; for (unsigned j = 0; j < g_boundaryMapList.size(); j++) { std::vector<ImageType::IndexType> insideIndex; itk::ImageRegionConstIteratorWithIndex<ImageType> iter(g_boundaryMapList[j], g_boundaryMapList[j]->GetBufferedRegion()); for (iter.GoToBegin(); !iter.IsAtEnd(); ++iter) { if (iter.Get() > 0) { insideIndex.push_back(iter.GetIndex()); } } std::random_shuffle(insideIndex.begin(), insideIndex.end()); if (insideIndex.size() > g_numberOfPoints) { PointVectorType initialPoints; initialPoints.reserve(nVars); for (unsigned i = 0; i < g_numberOfPoints; i++) { for (unsigned j = 0; j < POINT_DIMENSIONS; j++) { int k = i; initialPoints.push_back((float) insideIndex[k][j]); } } g_pointList.push_back(initialPoints); } } updateScene(); }
Window::Window(QScreen *screen) : QWindow (screen), scene_ (new BasicUsageScene) { setSurfaceType(OpenGLSurface); QSurfaceFormat format; format.setDepthBufferSize(24); format.setMajorVersion(3); format.setMinorVersion(3); format.setSamples(4); format.setProfile(QSurfaceFormat::CoreProfile); resize(800, 600); setFormat(format); create(); context_ = new QOpenGLContext(); context_->setFormat(format); context_->create(); scene_->setContext(context_); initializeGl(); connect(this, SIGNAL(widthChanged(int)), this, SLOT(resizeGl())); connect(this, SIGNAL(heightChanged(int)), this, SLOT(resizeGl())); resizeGl(); QTimer* timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(updateScene())); timer->start(16); }
void OpenCVwidget::resizeGL(int width, int height) { makeCurrent(); glViewport(0, 0, (GLint)width, (GLint)height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, width, 0, height, 0, 1); glMatrixMode(GL_MODELVIEW); mOutH = width/mImgRatio; mOutW = width; if(mOutH>height) { mOutW = height*mImgRatio; mOutH = height; } emit imageSizeChanged( mOutW, mOutH ); mPosX = (width-mOutW)/2; mPosY = (height-mOutH)/2; mSceneChanged = true; updateScene(); }
void OpenCVViewer::resizeGL(int width, int height) { makeCurrent(); glViewport(0, 0, (GLint)width, (GLint)height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); // Draw image in the center of the area. glOrtho(0, width, 0, height, 0, 1); glMatrixMode(GL_MODELVIEW); outH = width/imgRatio; outW = width; if(outH > height) { outW = height*imgRatio; outH = height; } emit imageSizeChanged(outW, outH); posX = (width - outW)/2; posY = (height - outH)/2; isSceneChanged = true; updateScene(); }
bool OpenCVwidget::showImage( cv::Mat image ) { image.copyTo(mOrigImage); mImgRatio = (float)image.cols/(float)image.rows; if( mOrigImage.channels() == 3) mRenderQtImg = QImage((const unsigned char*)(mOrigImage.data), mOrigImage.cols, mOrigImage.rows, mOrigImage.step, QImage::Format_RGB888).rgbSwapped(); else if( mOrigImage.channels() == 1) mRenderQtImg = QImage((const unsigned char*)(mOrigImage.data), mOrigImage.cols, mOrigImage.rows, mOrigImage.step, QImage::Format_Indexed8); else return false; mRenderQtImg = QGLWidget::convertToGLFormat(mRenderQtImg); mSceneChanged = true; updateScene(); return true; }
int D3DApp::run() { MSG msg = {0}; mTimer.reset(); while(msg.message != WM_QUIT) { // If there are Window messages then process them. if(PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) { TranslateMessage( &msg ); DispatchMessage( &msg ); } // Otherwise, do animation/game stuff. else { mTimer.tick(); if( !mAppPaused ) updateScene(mTimer.getDeltaTime()); else Sleep(50); drawScene(); } } return (int)msg.wParam; }
void executeScene() { if (!initialized) { initialize(); initialized = true; } updateScene(); }
bool QGLWindow::showImage(const cv::Mat &image, const SFace &face) { // get the detected face position m_face = SFace(face); // keep original image ratio m_ratio = static_cast<float>(image.cols)/static_cast<float>(image.rows); // convert the image in a Qt/OpenGL one if (image.channels() == 3) { m_renderedImage = QImage((const unsigned char*)image.data, image.cols, image.rows, static_cast<int>(image.step), QImage::Format_RGB888); } else if (image.channels() == 1) { m_renderedImage = QImage((const unsigned char*)image.data, image.cols, image.rows, static_cast<int>(image.step), QImage::Format_Indexed8); } else return false; // impossible to convert the image // conversion needs to mirror back the image m_renderedImage = m_renderedImage.mirrored(); updateScene(); return true; }
void QtOpenCVViewerGl::initializeGL() { mSceneChanged = true; showImage(cv::Mat::zeros(480, 640, 16)); updateScene(); }
void QVoxelDeformerPanel::onFalloffChanged(double value) { if(!activeDeformer) return; activeDeformer->sigmaControl = value; emit(updateScene()); }
void QVoxelDeformerPanel::setActiveScene( Scene * newScene) { activeScene = newScene; if(!activeScene) return; connect(this, SIGNAL(updateScene()), activeScene, SLOT(updateActiveObject())); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { ui.setupUi(this); m_particleColors = new QActionGroup(this); m_particleColors->addAction(ui.actionParticleBlack); m_particleColors->addAction(ui.actionParticleRed); m_particleColors->addAction(ui.actionParticleGreen); m_particleColors->addAction(ui.actionParticleBlue); m_particleColors->addAction(ui.actionParticleWhite); m_particleColors->addAction(ui.actionParticleHSV); ui.actionParticleHSV->setChecked(true); // QSize gvSize = ui.graphicsView->size(); // ui.graphicsView->setSceneRect(0, 0, gvSize.width(), gvSize.height()); // qDebug() << "Scene Rect: " << ui.graphicsView->sceneRect(); ui.graphicsView->setScene(&gs); ui.graphicsView->setRenderHints( QPainter::Antialiasing | QPainter::SmoothPixmapTransform); ui.graphicsView->scale(2, 2); ui.graphicsView->setBackgroundBrush(QBrush(Qt::black, Qt::SolidPattern)); // addImage(tr("/base/imageParticles/data/12.T2.slice.nrrd")); // addImage(tr("/base/imageParticles/data/13.T2.slice.nrrd")); #ifdef __APPLE__ addImage(tr("/data/2D/circle.jpg")); loadMask(tr("/data/2D/circle-boundary.png")); addImage(tr("/data/2D/circle.jpg")); loadMask(tr("/data/2D/random-boundary.jpg")); #else addImage(tr("/base/imageParticles/data/10.T2.slice.nrrd")); addImage(tr("/base/imageParticles/data/circle.jpg")); loadMask(tr("/base/imageParticles/data/circle-boundary.png")); loadMask(tr("/base/imageParticles/data/random-boundary.jpg")); #endif QObject::connect(&m_Timer, SIGNAL(timeout()), this, SLOT(particleAnimationTimeout())); QObject::connect(ui.actionShowImage, SIGNAL(triggered()), this, SLOT(updateScene())); QObject::connect(ui.actionShowShapeMask, SIGNAL(triggered()), this, SLOT(updateScene())); QObject::connect(ui.actionShowShapeDistanceMap, SIGNAL(triggered()), this, SLOT(updateScene())); QObject::connect(m_particleColors, SIGNAL(triggered(QAction*)), this, SLOT(updateScene())); QObject::connect(ui.actionShowPhantomParticles, SIGNAL(triggered()), this, SLOT(updateScene())); ui.listWidget->setCurrentRow(0); }
/*! Function testing if the program must stop rendering or not. \param evt : Frame event to process. \return False if the program must be stopped. */ bool vpAROgre::stopTest(const Ogre::FrameEvent& evt) { // Always keep this part if(keepOn){ return updateScene(evt); } else return keepOn; }
void CanvasView::updateOutline() { QList<QRectF> rect; rect.append(QRectF(_prevoutlinepoint.x() - _outlinesize, _prevoutlinepoint.y() - _outlinesize, _dia, _dia)); updateScene(rect); }
void ImageCalibrator::on_Reset_clicked() { imgOffsets[frmX][frmY].offsetX = 0; imgOffsets[frmX][frmY].offsetY = 0; imgOffsets[frmX][frmY].W = 0; imgOffsets[frmX][frmY].H = 0; updateControls(); updateScene(); }
void MapWidget::setMapView(QGraphicsView* view) { _view = view; _view->setScene(_scene); _view->setMaximumSize(589,514); _view->setMinimumSize(_view->maximumSize()); connect(_scene, SIGNAL(changed(QList<QRectF>)),_view,SLOT(updateScene(QList<QRectF>))); }
void VTKImageWidgetImplementation::connectSignals() { connect( m_ViewerCore, SIGNAL( emitUpdateScene( ) ), this, SLOT( updateScene( ) ) ); connect( m_ViewerCore, SIGNAL( emitPhysicalCoordsChanged( util::fvector3 ) ), this, SLOT( lookAtPhysicalCoords( util::fvector3 ) ) ); connect( m_ViewerCore, SIGNAL( emitZoomChanged( float ) ), this, SLOT( setZoom( float ) ) ); connect( m_ViewerCore, SIGNAL( emitSetEnableCrosshair( bool ) ), this, SLOT( setEnableCrosshair( bool ) ) ); m_ViewerCore->emitImageContentChanged.connect( boost::bind( &VTKImageWidgetImplementation::reloadImage, this, _1 ) ); m_ViewerCore->emitCurrentImageChanged.connect( boost::bind( &VTKImageWidgetImplementation::currentImageChanged, this, _1 ) ); }