void Core::initWindow(const QString& ipcMessage) { if (!_wnd) { _wnd = new MainWindow; _wnd->setConfig(_conf); _wnd->updateModulesActions(_modules.generateModulesActions()); _wnd->updateModulesenus(_modules.generateModulesMenus()); screenShot(true); // first screenshot _wnd->resize(_conf->getRestoredWndSize()); if (_wnd) { if (runAsMinimized()) { if (_wnd->isTrayed()) _wnd->windowHideShow(); else _wnd->showMinimized(); } else _wnd->show(); } } else { _wnd->showWindow(ipcMessage); screenShot(); } }
void Core::setScreen() { _wnd->hideToShot(); // new code experimental if (_conf->getDelay() == 0) QTimer::singleShot(200, this, SLOT(screenShot())); else QTimer::singleShot(1000 * _conf->getDelay(), this, SLOT(screenShot())); }
void thread(void){ while(1){ if(isPressed(BUTTON_SELECT | BUTTON_X)){ screenShot(TOP_FRAME); screenShot(BOT_FRAME); } if(isPressed(BUTTON_START | BUTTON_X)){ memdump(L"sdmc:/FCRAM.bin", (void*)0x27500000, 0x600000); } patches(); } __asm("SVC 0x09"); }
void thread(void){ while(1){ if(isPressed(BUTTON_SELECT | BUTTON_X)){ screenShot(TOP_FRAME); screenShot(BOT_FRAME); } if(isPressed(BUTTON_START | BUTTON_X)){ memdump(L"sdmc:/BootRom.bin", 0xFFFF0000, 0x8000); } patches(); } __asm("SVC 0x09"); }
//! //! \brief GuidewareTrackingWindow::setConnections //! void GuidewareTrackingWindow::setConnections(){ this->connect(closeButton, SIGNAL(clicked()), this, SLOT(closeSystem())); this->connect(playButton, SIGNAL(clicked()), this, SLOT(realTimeVideoPlay())); this->connect(noVolumeButton, SIGNAL(clicked()), this, SLOT(lastFramePlay())); this->connect(screenShotButton, SIGNAL(clicked()), this, SLOT(screenShot())); this->connect(this->displayTaskTimer, SIGNAL(timeout()), this, SLOT(updateLastFrame())); }
//!---------------------------------------------------------------------------------------------------- //! //! \brief GuidewareTrackingWindow::setConnections //! void GuidewareTrackingWindow::setConnections(){ this->connect(closeButton, SIGNAL(clicked()), this, SLOT(closeSystem())); this->connect(screenShotButton, SIGNAL(clicked()), this, SLOT(screenShot())); this->connect(resetButton, SIGNAL(clicked()), this, SLOT(changeStateToReconstruct())); this->connect(this->displayTaskTimer, SIGNAL(timeout()), this, SLOT(updateLastFrame())); this->connect(this->playButton, SIGNAL(clicked()), this, SLOT(startNaigation())); }
void MainWindow::globalShortcutActivate(int type) { _ui->cbxTypeScr->setCurrentIndex(type); typeScreenShotChange(type); if (!_trayed) hide(); QTimer::singleShot(200, _core, SLOT(screenShot())); }
void compareScreenshots(const QString &image1, const QString &image2) { QImage screenShot(image1); QImage original(image2); //ignore the clock QPainter p1(&screenShot); QPainter p2(&original); p1.fillRect(310, 6, 400, 34, Qt::black); p2.fillRect(310, 6, 400, 34, Qt::black); QVERIFY(original == screenShot); }
bool GlutWindow::screenshot(){ static int count=0; char fileBase[32]="frames/Capture"; char fileName[64]; // png sprintf(fileName, "%s%.4d.png", fileBase, count++); int tw = glutGet(GLUT_WINDOW_WIDTH); int th = glutGet(GLUT_WINDOW_HEIGHT); bool antiAlias = true; sprintf(fileName, "%s%.4d.tga", fileBase, count++); screenShot(tw, th, fileName, antiAlias); return false; }
void ViewerWindow::createMenus() { /* * File menu */ _menuFile = menuBar()->addMenu( "&File" ) ; //-- load a file QAction* actionLoadFile = _menuFile->addAction( "&Load a file..." ); connect( actionLoadFile, SIGNAL( triggered() ), this, SLOT( loadFile() ) ); //-- save as file QAction* actionSaveFile = _menuFile->addAction( "&save to file..." ); connect( actionSaveFile, SIGNAL( triggered() ), this, SLOT( saveFile() ) ); //-- screenshot QAction* actionSaveAsImage = _menuFile->addAction( "&Save as image..." ); connect( actionSaveAsImage, SIGNAL( triggered() ), this, SLOT( screenShot() ) ); _menuFile->addSeparator(); //-- exit QAction* actionExit = _menuFile->addAction( "&Exit" ); connect( actionExit, SIGNAL( triggered() ), qApp, SLOT( quit() ) ); /* * Display menu */ QMenu* displayMenu = menuBar()->addMenu( "&Display" ); QAction* gisView = displayMenu->addAction( "GIS view\t0" ); connect( gisView, SIGNAL( triggered() ), this, SLOT( toGISView() ) ); QAction* freeView = displayMenu->addAction( "Free view\t1" ); connect( freeView, SIGNAL( triggered() ), this, SLOT( toFreeView() ) ); /* * Help menu */ _menuHelp = menuBar()->addMenu( "&Help" ) ; //-- about QAction* actionAbout = _menuHelp->addAction( "&About" ); connect( actionAbout, SIGNAL( triggered() ), this, SLOT( about() ) ); }
void compareScreenshots(const QString &image1, const QString &image2) { QImage screenShot(image1); QImage original(image2); // cut away the title bar before comparing QDesktopWidget desktop; QRect desktopFrameRect = desktop.frameGeometry(); QRect desktopClientRect = desktop.availableGeometry(); QPainter p1(&screenShot); QPainter p2(&original); //screenShot.save("scr1.png", "PNG"); p1.fillRect(0, 0, desktopFrameRect.width(), desktopClientRect.y(), Qt::black); p2.fillRect(0, 0, desktopFrameRect.width(), desktopClientRect.y(), Qt::black); //screenShot.save("scr2.png", "PNG"); //original.save("orig1.png", "PNG"); QVERIFY(original == screenShot); }
void TohoSettings::saveOledScreen() { QDBusInterface getScreenShotCall("com.kimmoli.toholed", "/", "com.kimmoli.toholed", QDBusConnection::systemBus()); getScreenShotCall.setTimeout(2000); QDBusMessage getScreenShotReply = getScreenShotCall.call(QDBus::AutoDetect, "captureOled"); QImage screenShot(64, 32, QImage::Format_RGB32); screenShot.fill(Qt::white); if (getScreenShotReply.type() == QDBusMessage::ErrorMessage) { qDebug() << "Error getting screenshot:" << getScreenShotReply.errorMessage(); } else { QByteArray screenShot_ba = getScreenShotReply.arguments().at(0).toByteArray(); screenShot.loadFromData(screenShot_ba, "PNG"); QDate ssDate = QDate::currentDate(); QTime ssTime = QTime::currentTime(); QString ssFilename = QString("%8/oled%1%2%3-%4%5%6-%7.png") .arg((int) ssDate.day(), 2, 10, QLatin1Char('0')) .arg((int) ssDate.month(), 2, 10, QLatin1Char('0')) .arg((int) ssDate.year(), 2, 10, QLatin1Char('0')) .arg((int) ssTime.hour(), 2, 10, QLatin1Char('0')) .arg((int) ssTime.minute(), 2, 10, QLatin1Char('0')) .arg((int) ssTime.second(), 2, 10, QLatin1Char('0')) .arg((int) ssTime.msec(), 3, 10, QLatin1Char('0')) .arg(QStandardPaths::writableLocation(QStandardPaths::PicturesLocation)); screenShot.save(ssFilename); qDebug() << "Oled screenshot saved:" << ssFilename; } }
MainForm::MainForm(QWidget *parent) : QWidget(parent), ui(new Ui::MainForm) { ui->setupUi(this); q = QApplication::clipboard(); q->clear(QClipboard::Selection); st = new ShowText(0); //st->setWindowFlags(Qt::Dialog); trayIcon = new QSystemTrayIcon(QIcon("ScreenCatch64.png"),this); quitAction = new QAction("Quit",this); //connect(quitAction,SIGNAL(triggered()),qApp,SLOT(quit())); connect(quitAction,SIGNAL(triggered()),this,SLOT(aquit())); catchSwitch = new QAction("on/off",this); catchSwitch->setCheckable(true); catchSwitch->setChecked(true); connect(catchSwitch,SIGNAL(triggered()),this,SLOT(getSwitch())); tiMenu = new QMenu(this); tiMenu->addAction(catchSwitch); tiMenu->addAction(quitAction); trayIcon->setContextMenu(tiMenu); timer = new QTimer(this); connect(timer, SIGNAL(timeout()),this, SLOT(checkClipBoard())); timer->start(500); stimer = new QTimer(this); connect(stimer, SIGNAL(timeout()),this, SLOT(screenShot())); //stimer->start(5000); connect(this,SIGNAL(emitShow(QString)),st,SLOT(showMe(QString))); trayIcon->show(); }
void display_func() { get_extern_force(); sph_system->animate(); glViewport(0, 0, window_width, window_height); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glEnable(GL_POINT_SMOOTH); glHint(GL_POINT_SMOOTH_HINT, GL_NICEST); glEnable(GL_LINE_SMOOTH); glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); glClearColor(0.7, 0.7, 0.7, 1.0); glClear(GL_COLOR_BUFFER_BIT); display_particle(); if(create_video == 1) { if (frameNum % 2 == 0) { screenShot(frameNum / 2); } frameNum++; } glutSwapBuffers(); sph_timer->update(); memset(window_title, 0, 50); sprintf(window_title, "SPH Smoke 2D. FPS: %0.2f", sph_timer->get_fps()); glutSetWindowTitle(window_title); }
/* Key press handler. Called from keymap->process() if actual key was pressed */ void Tohkbd::handleKeyPressed(QList< QPair<int, int> > keyCode) { bool processAllKeys = true; presenceTimer->start(); if (!displayIsOn && !slideEventEmitted) { emitKeypadSlideEvent(true); /* slideEventEmitted is used to limit events to just one * emitted once when key pressed while display is off * it is reset when display turns on. */ slideEventEmitted = true; } if ((capsLockSeq == 1 || capsLockSeq == 2)) /* Abort caps-lock if other key pressed */ capsLockSeq = 0; checkDoWeNeedBacklight(); /* alt+TAB is the task-switcher */ if (keymap->altPressed && keyCode.at(0).first == KEY_TAB) { if (!taskSwitcherVisible) { /* show taskswitcher and advance one app */ taskSwitcherVisible = true; tohkbd2user->call(QDBus::AutoDetect, "nextAppTaskSwitcher"); tohkbd2user->call(QDBus::AutoDetect, "showTaskSwitcher"); } else { /* Toggle to next app */ tohkbd2user->call(QDBus::AutoDetect, "nextAppTaskSwitcher"); } /* Don't process further */ keyIsPressed = true; return; } /* Alt-p takes a screenshot */ if (keymap->altPressed && keyCode.at(0).first == KEY_P) { screenShot(); /* Don't process further */ keyIsPressed = true; return; } /* if F1...F12 key is pressed then launch detached process */ if (FKEYS.contains(keyCode.at(0).first)) { QString cmd = applicationShortcuts[keyCode.at(0).first]; if (!cmd.isEmpty()) { printf("Requesting user daemon to start %s\n", qPrintable(cmd)); QList<QVariant> args; args.append(cmd); tohkbd2user->callWithArgumentList(QDBus::AutoDetect, "launchApplication", args); /* Don't process further */ keyIsPressed = true; return; } } if (processAllKeys) { for (int i=0; i<keyCode.count(); i++) { /* Some of the keys require shift pressed to get correct symbol */ if (keyCode.at(i).second & FORCE_COMPOSE) uinputif->sendUinputKeyPress(KEY_COMPOSE, 1); if ((keyCode.at(i).second & FORCE_RIGHTALT)) uinputif->sendUinputKeyPress(KEY_RIGHTALT, 1); if ((keyCode.at(i).second & FORCE_SHIFT) || keymap->shiftPressed) uinputif->sendUinputKeyPress(KEY_LEFTSHIFT, 1); if ((keyCode.at(i).second & FORCE_ALT) || keymap->altPressed) uinputif->sendUinputKeyPress(KEY_LEFTALT, 1); if ((keyCode.at(i).second & FORCE_CTRL) || keymap->ctrlPressed) uinputif->sendUinputKeyPress(KEY_LEFTCTRL, 1); /* Mimic key pressing */ uinputif->sendUinputKeyPress(keyCode.at(i).first, 1); QThread::msleep(KEYREPEAT_RATE); uinputif->sendUinputKeyPress(keyCode.at(i).first, 0); if ((keyCode.at(i).second & FORCE_CTRL) || keymap->ctrlPressed) uinputif->sendUinputKeyPress(KEY_LEFTCTRL, 0); if ((keyCode.at(i).second & FORCE_ALT) || keymap->altPressed) uinputif->sendUinputKeyPress(KEY_LEFTALT, 0); if ((keyCode.at(i).second & FORCE_SHIFT) || keymap->shiftPressed) uinputif->sendUinputKeyPress(KEY_LEFTSHIFT, 0); if ((keyCode.at(i).second & FORCE_RIGHTALT)) uinputif->sendUinputKeyPress(KEY_RIGHTALT, 0); if (keyCode.at(i).second & FORCE_COMPOSE) uinputif->sendUinputKeyPress(KEY_COMPOSE, 0); } } uinputif->synUinputDevice(); /* store keycode for repeat */ lastKeyCode = keyCode; /* Repeat delay first, then repeat rate */ repeatTimer->start(keyRepeat ? (keyRepeatRate-(KEYREPEAT_RATE-1)) : keyRepeatDelay); keyIsPressed = true; }
bool myWorld::Init(int perso) { cont_cond_t cond; uint8 c; GLboolean xp = GL_FALSE; GLboolean yp = GL_FALSE; Vehicle *vehicle; int i; int f=NEG; float d=0.0; int ft=f; int throttle=0; int brake=0; int ang=0; ogg sultan("/rd/sons/ogg/sultanTribes.ogg"); init(); //speed tabulation for(i=-NEG;i<0;i++) aSpeed[i+NEG]=-(0.24*(float)7*i/(PLUS+NEG)+2)* log((float) -10*(float)7*i/(PLUS+NEG)+1)*3.6; for(i=NEG;i<PLUS+NEG;i++) aSpeed[i]=(-0.11*(float)(7*(i-NEG))/(PLUS+NEG)+2)*5* log((float) 3*(float)7*(i-NEG)/(PLUS+NEG)+1)*3.6; /* Declaration des objets */ SkyBox *skyBox = new SkyBox(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f); Landscape *cliff = new Landscape(JPEG, "/rd/terrain.jpg", "/rd/terrain.pcx", 256.0f, 32, 1, 1, 0); Landscape *sand = new Landscape(JPEG, "/rd/circuit.jpg", "/rd/circuit.pcx", 450.0f, 30, 4, 1/3.0f, -12.0f); PalmTree *palmier = new PalmTree("/rd/palmier.png", 69.0f, (sand->getYFromXZ(69,12)) + 10, 12.0f, 20.0f, 20.0f, 20.0f); PalmTree *cactus= new PalmTree("/rd/cactus.png", 10.0f, sand->getYFromXZ(10, 30) + 10, 30.0f, 40.0f, 40.0f, 40.0f); Landscape *sea = new Landscape(NJPEG, NULL, "/rd/eau.pcx", 700.0f, 7, 4, 0.0f, 3.0f, 0.5f, 0.6f, 0.8f); TheLittleHouseOnThePrairie *house = new TheLittleHouseOnThePrairie(-170.0f, 4.5f, -140.0f, 4.0f, 4.0f, 4.0f); StartPane *startPane = new StartPane(-155.0f,sand->getYFromXZ(69,12) , 35.0f, 25.0f, 50.0f, 50.0f); Caisse *caisse1 = new Caisse("/rd/decor/caisses/caisseGrande.png", -320.0f, -5.0f, -280.0f, 15.0f, 15.0f, 15.0f); Caisse *caisse2 = new Caisse("/rd/decor/caisses/caisseCroix.png", 80.0f, 2.0f, -280.0f, 15.0f, 15.0f, 15.0f); /*Caisse *caisse3 = new Caisse("/cd/decor/caisses/explosif.png", 280.0f, 2.0f, -220.0f, 15.0f, 15.0f, 15.0f);*/ /* Character creation */ switch(perso + 2) { case 2: vehicle = new OisisVehicle(-155.0f, (sand->getYFromXZ (-155, 35)) + 1.25, 35.0f, -155.0f, (sand->getYFromXZ (-155, 34.9)) + 1.25, 34.9f, 6.25f, 2.5f, 2.5f, 1.5); break; case 3: vehicle = new MomoVehicle(-155.0f, sand->getYFromXZ (-155, 35) + 1.25, 35.0f, -155.0f, sand->getYFromXZ (-155, 34.9) + 1.25 - 0.5, 34.9f, 2.5f , 5.0f, 2.5f, 0.5); break; case 4: vehicle = new NoelVehicle(-155.0f, sand->getYFromXZ (-155, 35) + 7.5, 35.0f, -155.0f, sand->getYFromXZ (-155, 34.9) + 7.5 - 10, 34.9f, 3.25f , 15.0f, 13.0f, 10); break; default: vehicle = new NoelVehicle(-155.0f, sand->getYFromXZ (-155, 35) + 7.5, 35.0f, -155.0f, sand->getYFromXZ (-155, 34.9) + 7.5, 34.9f, 3.25f , 15.0f, 13.0f, 10); break; } sultan.play(1); //vehicle->updateSlope(sand); //Vector3D tmp1= (vehicle->getPosition()) + (Vector3D (0, 10,17.5)); /*Vector3D tmp1= (vehicle->getPosition()) + (Vector3D (0, 10 - vehicle->getOffset(), 17.5)); Vector3D tmp2= Vector3D (0,1,0); Camera cam(tmp1, vehicle->getPosition(), tmp2);*/ Vector3D tmp1= (vehicle->getPosition()) + (Vector3D (0, 10 - vehicle->getOffset(), 17.5)); Vector3D tmp3= Vector3D (0,1,0); Vector3D tmp2 = vehicle->getPosition(); tmp2.y -= vehicle->getOffset(); Camera cam(tmp1, tmp2, tmp3); palmier->shape(); cactus->setColor(0.0f, 0.6f, 0.2f); cactus->shape(); cliff->shape(); sand->shape(); sea->shape(); startPane->shape(); house->shape(); vehicle->shape(); caisse1->shape(); caisse2->shape(); /*caisse3->shape();*/ c = maple_first_controller(); bool noRotatingThisFrame = false; while(1) { noRotatingThisFrame = false; c = maple_first_controller(); ft=f; if (c == 0) continue; if (cont_get_cond(c, &cond) < 0) continue; if (!(cond.buttons & CONT_START)) { sultan.stop(); return false; } if (!(cond.buttons & CONT_DPAD_LEFT)){ if(f!=NEG){ vehicle->rotate(ROT_ANGLE, sand); cam.move(vehicle->getPosition(), vehicle->getDirection()); } } if (!(cond.buttons & CONT_DPAD_RIGHT)) { if(f!=NEG){ vehicle->rotate(-ROT_ANGLE, sand); cam.move(vehicle->getPosition(), vehicle->getDirection()); } } brake=0; if (!(cond.buttons & CONT_B)) brake=1; throttle=0; if (!(cond.buttons & CONT_A)) throttle=1; if (!(cond.buttons & CONT_B )&&!(cond.buttons & CONT_X )) screenShot(); if (!(cond.buttons & CONT_Y)) { wav klaxon ("/rd/Klaxon.wav"); klaxon.play(); } if (cond.ltrig) { noRotatingThisFrame = true; cam.rotateAroundView(2); } if (cond.rtrig) { noRotatingThisFrame = true; cam.rotateAroundView(-2); } if (!(cond.buttons & CONT_B)&&!(cond.buttons & CONT_X)&&!(cond.buttons & CONT_A)&&!(cond.buttons & CONT_Y)) { return false; } /* Begin frame */ /* Draw the GL "scene" */ Vector3D dir = vehicle->getDirection(); Vector3D dirNoY (dir.x, 0, dir.z); if (!noRotatingThisFrame) cam.updateRotation(vehicle->getPosition(), dirNoY); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glKosBeginFrame(); /* Switch to the blended polygon list if needed */ glKosFinishList(); glDepthMask(0); /*******************************************/ glLoadIdentity(); glPushMatrix(); cam.affiche(); glEnable(GL_KOS_NEARZ_CLIPPING); glPushMatrix(); glScalef(350.0f, 200.0f, 350.0f); /* Paint the Sky Box */ skyBox->shape(); glPopMatrix(); cliff->displayElement(); sea->displayElement(); glPushMatrix(); glScalef(2.0f, 2.0f, 2.0f); house->displayElement(); glPopMatrix(); palmier->displayElement(); cactus->displayElement(); /* Draw the second house on the Prairie */ glPushMatrix(); glTranslatef(200.0f, 60.0f, 200.0f); house->displayElement(); glPopMatrix(); /* Draw a second cactus */ glPushMatrix(); glTranslatef(-320.0f, sand->getYFromXZ (120, 250), -120.0f); cactus->displayElement(); glPopMatrix(); /* Draw a second palmtree */ glPushMatrix(); glTranslatef(-125.0f, sand->getYFromXZ (-125, 10), 10.0f); cactus->displayElement(); glPopMatrix(); sand->displayElement(); startPane->displayElement(); caisse1->displayElement(); caisse2->displayElement(); /*caisse3->displayElement();*/ /* Draw the vehicle */ glPushMatrix(); /* METTRE LA PENTE A LA PLACE DU PREMIER 0 */ f=PhysicalEngine::speed(f,throttle,brake,0,0); float d=PhysicalEngine::distance(ft,f)*SCALE; vehicle->moveRelatif(d,sand); cam.move(vehicle->getPosition(),vehicle->getDirection()); glTranslatef(vehicle->getPosition().x, vehicle->getPosition().y, vehicle->getPosition().z); //1st rotation, in x and z float rotatefAngle = angleBetweenVectorsWithReference (Vector3D(0,0,1), Vector3D(1,0,0), dirNoY); //convert to degrees : rotatefAngle = radToDeg (rotatefAngle); Vector3D rotateUp = cam.getUpVector(); glRotatef(rotatefAngle, rotateUp.x, rotateUp.y, rotateUp.z); //2nd rotation, in z and y Vector3D tF = vehicle->getFront(); Vector3D tPos = vehicle->getPosition(); Vector3D dir2 = tF - tPos; rotatefAngle = asin (dir2.y / dir2.Magnitude()); //convert to degrees : rotatefAngle = radToDeg (rotatefAngle); Vector3D rotateX (1,0,0); glRotatef(-rotatefAngle, rotateX.x, rotateX.y, rotateX.z); vehicle->displayElement(); glPopMatrix(); glDisable(GL_KOS_NEARZ_CLIPPING); glPopMatrix(); /* Finish the frame */ glKosFinishFrame(); } }
void CAScreenShot::changeValue (const short & /*connstatus*/, const double &value) { if(value == 1.0) screenShot(p_data->m_number); //screenShot(p_data->m_number); };
PointViewerMainWindow::PointViewerMainWindow(const QGLFormat& format) : m_progressBar(0), m_pointView(0), m_shaderEditor(0), m_helpDialog(0), m_logTextView(0), m_maxPointCount(200*1000*1000), // 200 million m_geometries(0), m_ipcServer(0), m_hookManager(0) { #ifndef _WIN32 setWindowIcon(QIcon(":resource/icons/hicolor/256x256/apps/displaz.png")); #else // On windows, application icon is set via windows resource file #endif setWindowTitle("Displaz"); setAcceptDrops(true); m_helpDialog = new HelpDialog(this); m_geometries = new GeometryCollection(this); connect(m_geometries, SIGNAL(layoutChanged()), this, SLOT(updateTitle())); connect(m_geometries, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(updateTitle())); connect(m_geometries, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(updateTitle())); connect(m_geometries, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(updateTitle())); //-------------------------------------------------- // Set up file loader in a separate thread // // Some subtleties regarding qt thread usage are discussed here: // http://mayaposch.wordpress.com/2011/11/01/how-to-really-truly-use-qthreads-the-full-explanation // // Main point: each QObject has a thread affinity which determines which // thread its slots will execute on, when called via a connected signal. QThread* loaderThread = new QThread(); m_fileLoader = new FileLoader(m_maxPointCount); m_fileLoader->moveToThread(loaderThread); connect(loaderThread, SIGNAL(finished()), m_fileLoader, SLOT(deleteLater())); connect(loaderThread, SIGNAL(finished()), loaderThread, SLOT(deleteLater())); //connect(m_fileLoader, SIGNAL(finished()), this, SIGNAL(fileLoadFinished())); connect(m_fileLoader, SIGNAL(geometryLoaded(std::shared_ptr<Geometry>, bool, bool)), m_geometries, SLOT(addGeometry(std::shared_ptr<Geometry>, bool, bool))); connect(m_fileLoader, SIGNAL(geometryMutatorLoaded(std::shared_ptr<GeometryMutator>)), m_geometries, SLOT(mutateGeometry(std::shared_ptr<GeometryMutator>))); loaderThread->start(); //-------------------------------------------------- // Menus menuBar()->setNativeMenuBar(false); // OS X doesn't activate the native menu bar under Qt5 // File menu QMenu* fileMenu = menuBar()->addMenu(tr("&File")); QAction* openAct = fileMenu->addAction(tr("&Open")); openAct->setToolTip(tr("Open a data set")); openAct->setShortcuts(QKeySequence::Open); connect(openAct, SIGNAL(triggered()), this, SLOT(openFiles())); QAction* addAct = fileMenu->addAction(tr("&Add")); addAct->setToolTip(tr("Add a data set")); connect(addAct, SIGNAL(triggered()), this, SLOT(addFiles())); QAction* reloadAct = fileMenu->addAction(tr("&Reload")); reloadAct->setStatusTip(tr("Reload point files from disk")); reloadAct->setShortcut(Qt::Key_F5); connect(reloadAct, SIGNAL(triggered()), this, SLOT(reloadFiles())); fileMenu->addSeparator(); QAction* screenShotAct = fileMenu->addAction(tr("Scree&nshot")); screenShotAct->setStatusTip(tr("Save screen shot of 3D window")); screenShotAct->setShortcut(Qt::Key_F9); connect(screenShotAct, SIGNAL(triggered()), this, SLOT(screenShot())); fileMenu->addSeparator(); QAction* quitAct = fileMenu->addAction(tr("&Quit")); quitAct->setStatusTip(tr("Exit the application")); quitAct->setShortcuts(QKeySequence::Quit); connect(quitAct, SIGNAL(triggered()), this, SLOT(close())); // View menu QMenu* viewMenu = menuBar()->addMenu(tr("&View")); QAction* trackballMode = viewMenu->addAction(tr("Use &Trackball camera")); trackballMode->setCheckable(true); trackballMode->setChecked(false); // Background sub-menu QMenu* backMenu = viewMenu->addMenu(tr("Set &Background")); QSignalMapper* mapper = new QSignalMapper(this); // Selectable backgrounds (svg_names from SVG standard - see QColor docs) const char* backgroundNames[] = {/* "Display Name", "svg_name", */ "Default", "#3C3232", "Black", "black", "Dark Grey", "dimgrey", "Slate Grey", "#858C93", "Light Grey", "lightgrey", "White", "white" }; for(size_t i = 0; i < sizeof(backgroundNames)/sizeof(const char*); i+=2) { QAction* backgroundAct = backMenu->addAction(tr(backgroundNames[i])); QPixmap pixmap(50,50); QString colName = backgroundNames[i+1]; pixmap.fill(QColor(colName)); QIcon icon(pixmap); backgroundAct->setIcon(icon); mapper->setMapping(backgroundAct, colName); connect(backgroundAct, SIGNAL(triggered()), mapper, SLOT(map())); } connect(mapper, SIGNAL(mapped(QString)), this, SLOT(setBackground(QString))); backMenu->addSeparator(); QAction* backgroundCustom = backMenu->addAction(tr("&Custom")); connect(backgroundCustom, SIGNAL(triggered()), this, SLOT(chooseBackground())); // Check boxes for drawing various scene elements by category viewMenu->addSeparator(); QAction* drawBoundingBoxes = viewMenu->addAction(tr("Draw Bounding bo&xes")); drawBoundingBoxes->setCheckable(true); drawBoundingBoxes->setChecked(false); QAction* drawCursor = viewMenu->addAction(tr("Draw 3D &Cursor")); drawCursor->setCheckable(true); drawCursor->setChecked(true); QAction* drawAxes = viewMenu->addAction(tr("Draw &Axes")); drawAxes->setCheckable(true); drawAxes->setChecked(true); QAction* drawGrid = viewMenu->addAction(tr("Draw &Grid")); drawGrid->setCheckable(true); drawGrid->setChecked(false); QAction* drawAnnotations = viewMenu->addAction(tr("Draw A&nnotations")); drawAnnotations->setCheckable(true); drawAnnotations->setChecked(true); // Shader menu QMenu* shaderMenu = menuBar()->addMenu(tr("&Shader")); QAction* openShaderAct = shaderMenu->addAction(tr("&Open")); openShaderAct->setToolTip(tr("Open a shader file")); connect(openShaderAct, SIGNAL(triggered()), this, SLOT(openShaderFile())); QAction* editShaderAct = shaderMenu->addAction(tr("&Edit")); editShaderAct->setToolTip(tr("Open shader editor window")); QAction* saveShaderAct = shaderMenu->addAction(tr("&Save")); saveShaderAct->setToolTip(tr("Save current shader file")); connect(saveShaderAct, SIGNAL(triggered()), this, SLOT(saveShaderFile())); shaderMenu->addSeparator(); // Help menu QMenu* helpMenu = menuBar()->addMenu(tr("&Help")); QAction* helpAct = helpMenu->addAction(tr("User &Guide")); connect(helpAct, SIGNAL(triggered()), this, SLOT(helpDialog())); helpMenu->addSeparator(); QAction* aboutAct = helpMenu->addAction(tr("&About")); connect(aboutAct, SIGNAL(triggered()), this, SLOT(aboutDialog())); //-------------------------------------------------- // Point viewer m_pointView = new View3D(m_geometries, format, this); setCentralWidget(m_pointView); connect(drawBoundingBoxes, SIGNAL(triggered()), m_pointView, SLOT(toggleDrawBoundingBoxes())); connect(drawCursor, SIGNAL(triggered()), m_pointView, SLOT(toggleDrawCursor())); connect(drawAxes, SIGNAL(triggered()), m_pointView, SLOT(toggleDrawAxes())); connect(drawGrid, SIGNAL(triggered()), m_pointView, SLOT(toggleDrawGrid())); connect(drawAnnotations, SIGNAL(triggered()), m_pointView, SLOT(toggleDrawAnnotations())); connect(trackballMode, SIGNAL(triggered()), m_pointView, SLOT(toggleCameraMode())); connect(m_geometries, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(geometryRowsInserted(QModelIndex,int,int))); //-------------------------------------------------- // Docked widgets // Shader parameters UI QDockWidget* shaderParamsDock = new QDockWidget(tr("Shader Parameters"), this); shaderParamsDock->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable); QWidget* shaderParamsUI = new QWidget(shaderParamsDock); shaderParamsDock->setWidget(shaderParamsUI); m_pointView->setShaderParamsUIWidget(shaderParamsUI); // Shader editor UI QDockWidget* shaderEditorDock = new QDockWidget(tr("Shader Editor"), this); shaderEditorDock->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetFloatable); QWidget* shaderEditorUI = new QWidget(shaderEditorDock); m_shaderEditor = new ShaderEditor(shaderEditorUI); QGridLayout* shaderEditorLayout = new QGridLayout(shaderEditorUI); shaderEditorLayout->setContentsMargins(2,2,2,2); shaderEditorLayout->addWidget(m_shaderEditor, 0, 0, 1, 1); connect(editShaderAct, SIGNAL(triggered()), shaderEditorDock, SLOT(show())); shaderEditorDock->setWidget(shaderEditorUI); shaderMenu->addAction(m_shaderEditor->compileAction()); connect(m_shaderEditor->compileAction(), SIGNAL(triggered()), this, SLOT(compileShaderFile())); // TODO: check if this is needed - test shader update functionality //connect(m_shaderEditor, SIGNAL(sendShader(QString)), // &m_pointView->shaderProgram(), SLOT(setShader(QString))); // Log viewer UI QDockWidget* logDock = new QDockWidget(tr("Log"), this); logDock->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable); QWidget* logUI = new QWidget(logDock); m_logTextView = new LogViewer(logUI); m_logTextView->setReadOnly(true); m_logTextView->setTextInteractionFlags(Qt::TextSelectableByKeyboard | Qt::TextSelectableByMouse); m_logTextView->connectLogger(&g_logger); // connect to global logger m_progressBar = new QProgressBar(logUI); m_progressBar->setRange(0,100); m_progressBar->setValue(0); m_progressBar->hide(); connect(m_fileLoader, SIGNAL(loadStepStarted(QString)), this, SLOT(setProgressBarText(QString))); connect(m_fileLoader, SIGNAL(loadProgress(int)), m_progressBar, SLOT(setValue(int))); connect(m_fileLoader, SIGNAL(resetProgress()), m_progressBar, SLOT(hide())); QVBoxLayout* logUILayout = new QVBoxLayout(logUI); //logUILayout->setContentsMargins(2,2,2,2); logUILayout->addWidget(m_logTextView); logUILayout->addWidget(m_progressBar); //m_logTextView->setLineWrapMode(QPlainTextEdit::NoWrap); logDock->setWidget(logUI); // Data set list UI QDockWidget* dataSetDock = new QDockWidget(tr("Data Sets"), this); dataSetDock->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetFloatable); DataSetUI* dataSetUI = new DataSetUI(this); dataSetDock->setWidget(dataSetUI); QAbstractItemView* dataSetOverview = dataSetUI->view(); dataSetOverview->setModel(m_geometries); connect(dataSetOverview, SIGNAL(doubleClicked(const QModelIndex&)), m_pointView, SLOT(centerOnGeometry(const QModelIndex&))); m_pointView->setSelectionModel(dataSetOverview->selectionModel()); // Set up docked widgets addDockWidget(Qt::RightDockWidgetArea, shaderParamsDock); addDockWidget(Qt::LeftDockWidgetArea, shaderEditorDock); addDockWidget(Qt::RightDockWidgetArea, logDock); addDockWidget(Qt::RightDockWidgetArea, dataSetDock); tabifyDockWidget(logDock, dataSetDock); logDock->raise(); shaderEditorDock->setVisible(false); // Add dock widget toggles to view menu viewMenu->addSeparator(); viewMenu->addAction(shaderParamsDock->toggleViewAction()); viewMenu->addAction(logDock->toggleViewAction()); viewMenu->addAction(dataSetDock->toggleViewAction()); // Create custom hook events from CLI at runtime m_hookManager = new HookManager(this); }