Ejemplo n.º 1
0
TrayIcon::TrayIcon(AppCore *core)
  : QSystemTrayIcon(core)
  , m_core(core)
  , m_message(Unknown)
{
  setIcon(QIcon(QLatin1String(":/images/icon16.png")));
  setToolTip(QString("%1 %2").arg(PRODUCT_NAME).arg(VERSION_STRING));

  m_widget = new QWidget();
  RecentItemDelegate *delegate = new RecentItemDelegate(core, this);

  m_window = new TrayWindow(core, m_widget);
  m_window->installEventFilter(this);
  m_window->recentView()->setItemDelegate(delegate);
  m_window->recentView()->setModel(core->recentModel());

  QTimer::singleShot(0, this, SLOT(show()));
  QTimer::singleShot(1000, this, SLOT(show()));

  connect(this, SIGNAL(messageClicked()), SLOT(onMessageClicked()));
  connect(this, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), SLOT(onActivated(QSystemTrayIcon::ActivationReason)));
  connect(m_window, SIGNAL(grabRect()), m_core, SLOT(grabRect()));
  connect(m_window, SIGNAL(grabScreen()), m_core, SLOT(grabScreen()));
  connect(m_window, SIGNAL(openFile()), m_core, SLOT(openFile()));
  connect(delegate, SIGNAL(closeRequest()), m_window, SLOT(close()));
  connect(delegate, SIGNAL(linkCopied(QUrl)), SLOT(onLinkCopied(QUrl)));
  connect(core->autoUpdate(), SIGNAL(done(int)), SLOT(onUpdateDone(int)));
}
Ejemplo n.º 2
0
void SmokeSim::draw(const Camera& c) {
  drawAxes(); 
  mGrid.draw(c);
  if (mRecordEnabled) {
    grabScreen();
  }
}
Ejemplo n.º 3
0
AddPictureWidget::AddPictureWidget( PolkaModel *model, QWidget *parent )
  : QWidget( parent ), m_model( model )
{
  QGridLayout *topLayout = new QGridLayout( this );

  QPushButton *button;

  button = new QPushButton( i18n("Grab from screen") );
  connect( button, SIGNAL( clicked() ), SLOT( grabScreen() ) );
  topLayout->addWidget( button, 0, 2 );

  topLayout->addWidget( new QLabel( i18n("Twitter name:") ), 1, 0,
    Qt::AlignRight );

  m_twitterNameEdit = new QLineEdit;
  topLayout->addWidget( m_twitterNameEdit, 1, 1 );
  connect( m_twitterNameEdit, SIGNAL( returnPressed() ),
           SLOT( getTwitter() ) );

  button = new QPushButton( i18n("Get from Twitter") );
  connect( button, SIGNAL( clicked() ), SLOT( getTwitter() ) );
  topLayout->addWidget( button, 1, 2 );

  topLayout->addWidget( new QLabel( i18n("Facebook name:") ), 2, 0,
    Qt::AlignRight );

  m_facebookNameEdit = new QLineEdit;
  topLayout->addWidget( m_facebookNameEdit, 2, 1 );
  connect( m_facebookNameEdit, SIGNAL( returnPressed() ),
           SLOT( getFacebook() ) );

  button = new QPushButton( i18n("Get from Facebook") );
  connect( button, SIGNAL( clicked() ), SLOT( getFacebook() ) );
  topLayout->addWidget( button, 2, 2 );
}
Ejemplo n.º 4
0
void ScreenshotGrabber::showGrabber()
{
    this->screenGrab = grabScreen();
    this->screenGrabDisplay->setPixmap(this->screenGrab);
    this->window->show();
    this->window->setFocus();
    this->window->grabKeyboard();
    adjustWindowSize();
    adjustTooltipPosition();
}
Ejemplo n.º 5
0
void onTimerCb(int value)
{
   glutTimerFunc(100, onTimerCb, 0);
   if (isRunning) 
   {
       theJello.Update(0.01, theWorld); 
       if (isRecording) grabScreen();
   }

   glutPostRedisplay();
}
Ejemplo n.º 6
0
void Player::keyPressEvent(QKeyEvent *e) {
        if (e->modifiers() == (Qt::ShiftModifier | Qt::ControlModifier) &&
                        e->key() == Qt::Key_S) {
                grabScreen();
        } else if (e->modifiers() == (Qt::ShiftModifier | Qt::ControlModifier) &&
                   e->key() == Qt::Key_Z) {
                startRecordScreen();
        } else if (e->modifiers() == (Qt::ShiftModifier | Qt::ControlModifier) &&
                   e->key() == Qt::Key_X) {
                stopRecordScreen();
        }
}
Ejemplo n.º 7
0
void ScreenshotGrabber::showGrabber()
{
    this->screenGrab = grabScreen();
    this->screenGrabDisplay->setPixmap(this->screenGrab);
    this->window->show();
    this->window->setFocus();
    this->window->grabKeyboard();

    QRect fullGrabbedRect = screenGrab.rect();
    QRect rec = QApplication::primaryScreen()->virtualGeometry();

    this->window->setGeometry(rec);
    this->scene->setSceneRect(fullGrabbedRect);
    this->overlay->setRect(fullGrabbedRect);

    adjustTooltipPosition();
}
Ejemplo n.º 8
0
void ScreenShot::mouseReleaseEvent(QMouseEvent *e)
{

        if(e->button()==Qt::LeftButton)
        {
            end = e->pos();//记录终点坐标
            grabScreen();
        }
        else if(e->button()==Qt::RightButton)
        {
            finish = true;
            rubber->close();
            label->close();
        }


}
void
GLView::slotTimerEvent( ){

	if( parameterVerhalten.zustand == ParameterVerhalten::AUS ) {

		return;
	}

	controlWindowsBehaviour( );

	switch( parameterVerhalten.zustand ) {

		case ParameterVerhalten::AUS : {

			return;
		}

		case ParameterVerhalten::HORIZONTAL : {

			parameterSimulation.mausX = 1.0 * ( mousePos.x( ) - screenOnLowerSide * desktopGeometry.width( ) / 2 ) / this->width( ),
			parameterSimulation.mausY = 1.0 * mousePos.y( ) / this->height( );

			break;
		}

		case ParameterVerhalten::VERTIKAL : {

			parameterSimulation.mausX = 1.0 * mousePos.x( ) / this->width( ),
			parameterSimulation.mausY = 1.0 * ( mousePos.y( ) - screenOnLowerSide * desktopGeometry.height( ) / 2 ) / this->height( );

			break;
		}
	}

	grabScreen( );

	updateGL( );
}
Ejemplo n.º 10
0
void ImageNavigator::initializeActions() {
    setAttribute(Qt::WA_DeleteOnClose);
    menu = mainMenuBar->addMenu("Focus Viewer");
    QSignalMapper *signalMap = new QSignalMapper(this);

    QAction *showFullScreenAction = new QAction(tr("Show Full Screen"), this);
    showFullScreenAction->setShortcut(tr("Ctrl+F"));
    showFullScreenAction->setCheckable(true);
    connect(showFullScreenAction, SIGNAL(toggled(bool)), this, SLOT(enableFullScreen(bool)));
    menu->addAction(showFullScreenAction);

    toggleInfoToolAction = new QAction(tr("Display Coordinate Info"), this);
    toggleInfoToolAction->setShortcut(tr("I"));
    toggleInfoToolAction->setCheckable(true);
    addAction(toggleInfoToolAction);
    connect(toggleInfoToolAction, SIGNAL(triggered()), this, SLOT(toggleInfoTool()));
    menu->addAction(toggleInfoToolAction);

    // #ifdef Q_OS_MAC
    QMenu *zoomMenu = new QMenu("Zoom", this);
    menu->addMenu(zoomMenu);
    QAction *zoomInAction = new QAction(tr("Zoom In"), this);
    zoomInAction->setShortcut(tr("."));
    addAction(zoomInAction);
    connect(zoomInAction, SIGNAL(triggered()), this, SLOT(zoomIn()));
    zoomMenu->addAction(zoomInAction);

    QAction *zoomOutAction = new QAction(tr("Zoom Out"), this);
    zoomOutAction->setShortcut(tr(","));
    addAction(zoomOutAction);
    connect(zoomOutAction, SIGNAL(triggered()), this, SLOT(zoomOut()));
    zoomMenu->addAction(zoomOutAction);
    QAction *zoomStandardAction = new QAction(tr("Zoom Standard"), this);
    zoomStandardAction->setShortcut(tr("Space"));
    addAction(zoomStandardAction);
    connect(zoomStandardAction, SIGNAL(triggered()), this, SLOT(zoomStandard()));
    zoomMenu->addAction(zoomStandardAction);
    menu->addMenu(zoomMenu);
    //#endif

    toggleColorToolAction = new QAction(tr("Adjust Contrast/Brightness"), this);
    toggleColorToolAction->setShortcut(tr("O"));
    toggleColorToolAction->setCheckable(true);
    addAction(toggleColorToolAction);
    connect(toggleColorToolAction, SIGNAL(triggered()), this, SLOT(toggleColorTool()));
    menu->addAction(toggleColorToolAction);

    // #ifdef Q_OS_MAC
    // CHEN: 4.1.2015
    // if(imageType =="fft")
    // {
    QMenu *brighterMenu = new QMenu("Quick-Adjust Brightness", this);
    menu->addMenu(brighterMenu);
    QAction *brighterAction = new QAction(tr("Brighter"), this);
    brighterAction->setShortcut(tr("b"));
    addAction(brighterAction);
    connect(brighterAction, SIGNAL(triggered()), this, SLOT(brighter()));
    brighterMenu->addAction(brighterAction);

    QAction *darkerAction = new QAction(tr("Darker"), this);
    darkerAction->setShortcut(tr("n"));
    addAction(darkerAction);
    connect(darkerAction, SIGNAL(triggered()), this, SLOT(darker()));
    brighterMenu->addAction(darkerAction);
    // }
    // #endif

    toggleMouseAssignAction = new QAction(tr("Show Mouse Button Assignment"), this);
    toggleMouseAssignAction->setShortcut(tr("M"));
    toggleMouseAssignAction->setCheckable(true);
    addAction(toggleMouseAssignAction);
    connect(toggleMouseAssignAction, SIGNAL(triggered()), this, SLOT(toggleAssignTool()));
    menu->addAction(toggleMouseAssignAction);

    QAction *screenshot = new QAction(tr("Screen Shot"), this);
    screenshot->setShortcut(tr("G"));
    addAction(screenshot);
    connect(screenshot, SIGNAL(triggered()), image, SLOT(grabScreen()));
    menu->addAction(screenshot);

    int projectMode = projectData.projectMode().toInt();

    if (imageType == "fft") {
        viewDisplayParametersAction = new QAction(tr("Display Parameters"), this);
        viewDisplayParametersAction->setShortcut(tr("D"));
        viewDisplayParametersAction->setCheckable(true);
        addAction(viewDisplayParametersAction);
        connect(viewDisplayParametersAction, SIGNAL(triggered()), this, SLOT(toggleDisplayParameters()));
        menu->addAction(viewDisplayParametersAction);

        toggleCTFViewAction = new QAction(tr("View CTF"), this);
        toggleCTFViewAction->setShortcut(tr("C"));
        // toggleCTFViewAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
        toggleCTFViewAction->setCheckable(true);
        addAction(toggleCTFViewAction);
        connect(toggleCTFViewAction, SIGNAL(triggered()), this, SLOT(toggleCTFView()));
        //connect(toggleCTFViewAction,SIGNAL(triggered()),image,SLOT(toggleCTFView()));
        menu->addAction(toggleCTFViewAction);

        if (projectMode == 1) {
            QAction *displayMillerIndicesAction = new QAction(tr("Show Miller Indices"), this);
            displayMillerIndicesAction->setShortcut(tr("Shift+D"));
            displayMillerIndicesAction->setCheckable(true);
            addAction(displayMillerIndicesAction);
            connect(displayMillerIndicesAction, SIGNAL(triggered()), signalMap, SLOT(map()));
            signalMap->setMapping(displayMillerIndicesAction, "millerindices");
            menu->addAction(displayMillerIndicesAction);


            QAction *viewPSPeaksAction = new QAction(tr("View Peak List"), this);
            viewPSPeaksAction->setShortcut(tr("Shift+P"));
            viewPSPeaksAction->setCheckable(true);
            addAction(viewPSPeaksAction);
            connect(viewPSPeaksAction, SIGNAL(triggered()), signalMap, SLOT(map()));
            signalMap->setMapping(viewPSPeaksAction, "pspeaklist");
            connect(signalMap, SIGNAL(mapped(const QString &)), image, SLOT(toggleVisible(const QString &)));
            menu->addAction(viewPSPeaksAction);

            QAction *loadPSPeaksAction = new QAction(tr("Load Peak List"), this);
            loadPSPeaksAction->setShortcut(tr("Shift+L"));
            addAction(loadPSPeaksAction);
            connect(loadPSPeaksAction, SIGNAL(triggered()), this, SLOT(selectPSList()));
            menu->addAction(loadPSPeaksAction);
        }

        QMenu *spotSelection = new QMenu("Spot Selection");
        if (projectMode == 1) menu->addMenu(spotSelection);

        togglePeakListAction = new QAction(tr("Identify Spots"), spotSelection);
        togglePeakListAction->setShortcut(tr("P"));
        togglePeakListAction->setCheckable(true);

        if (projectMode == 1) {
            addAction(togglePeakListAction);
            connect(togglePeakListAction, SIGNAL(triggered()), image, SLOT(togglePeakList()));
            spotSelection->addAction(togglePeakListAction);
        }

        enterSpotSelectionModeAction = new QAction(tr("Enter Spot Selection Mode"), spotSelection);
        enterSpotSelectionModeAction->setCheckable(true);
        enterSpotSelectionModeAction->setShortcut(tr("Ctrl+P"));

        if (projectMode == 1) {
            addAction(enterSpotSelectionModeAction);
            connect(enterSpotSelectionModeAction, SIGNAL(triggered()), this, SLOT(toggleSpotSelectMode()));
            spotSelection->addAction(enterSpotSelectionModeAction);
        }

        savePeakListAction = new QAction(tr("Save Spot List"), spotSelection);
        savePeakListAction->setShortcut(tr("Ctrl+Shift+S"));

        if (projectMode == 1) {
            addAction(savePeakListAction);
            savePeakListAction->setDisabled(true);
            connect(savePeakListAction, SIGNAL(triggered()), image, SLOT(savePeakList()));
            spotSelection->addAction(savePeakListAction);
        }

        loadPeakListAction = new QAction(tr("Reload Spot List"), spotSelection);
        loadPeakListAction->setShortcut(tr("Ctrl+R"));

        if (projectMode == 1) {
            addAction(loadPeakListAction);
            loadPeakListAction->setDisabled(true);
            connect(loadPeakListAction, SIGNAL(triggered()), image, SLOT(loadPeakList()));
            connect(loadPeakListAction, SIGNAL(triggered()), image, SLOT(update()));
            spotSelection->addAction(loadPeakListAction);
        }

        clearPeakListAction = new QAction(tr("Clear Spot List"), spotSelection);
        clearPeakListAction->setShortcut(tr("Ctrl+Shift+C"));

        if (projectMode == 1) {
            addAction(clearPeakListAction);
            clearPeakListAction->setDisabled(true);
            connect(clearPeakListAction, SIGNAL(triggered()), image, SLOT(clearPeakList()));
            spotSelection->addAction(clearPeakListAction);
        }

        QMenu *latticeRefinement = new QMenu("Lattice Refinement");
        if (projectMode == 1) menu->addMenu(latticeRefinement);

        toggleLatticeViewAction = new QAction(tr("View Lattice"), latticeRefinement);
        toggleLatticeViewAction->setShortcut(tr("L"));
        toggleLatticeViewAction->setCheckable(true);
        if (projectMode == 1) {
            addAction(toggleLatticeViewAction);
            connect(toggleLatticeViewAction, SIGNAL(triggered()), image, SLOT(toggleLatticeView()));
            latticeRefinement->addAction(toggleLatticeViewAction);


            QAction *toggleSecondLatticeViewAction = new QAction(tr("View Second Lattice"), latticeRefinement);
            toggleSecondLatticeViewAction->setShortcut(tr("S"));
            toggleSecondLatticeViewAction->setCheckable(true);
            addAction(toggleSecondLatticeViewAction);
            connect(toggleSecondLatticeViewAction, SIGNAL(triggered()), image, SLOT(toggleSecondLatticeView()));
            latticeRefinement->addAction(toggleSecondLatticeViewAction);
        }

        enterLatticeRefinementModeAction = new QAction(tr("Enter Lattice Refinement Mode"), latticeRefinement);
        enterLatticeRefinementModeAction->setShortcut(tr("Shift+R"));
        enterLatticeRefinementModeAction->setCheckable(true);

        if (projectMode == 1) {
            addAction(enterLatticeRefinementModeAction);
            connect(enterLatticeRefinementModeAction, SIGNAL(triggered()), this, SLOT(toggleLatticeRefinementMode()));
            latticeRefinement->addAction(enterLatticeRefinementModeAction);
        }

        addRefinementPointAction = new QAction(tr("Add Refinement Spot"), latticeRefinement);
        addRefinementPointAction->setShortcuts(QList<QKeySequence>() << tr("Enter") << tr("Return"));
        addRefinementPointAction->setEnabled(false);

        if (projectMode == 1) {
            addAction(addRefinementPointAction);
            connect(addRefinementPointAction, SIGNAL(triggered()), latticeTool, SLOT(insertPoint()));
            latticeRefinement->addAction(addRefinementPointAction);
        }

    } else {

        toggleLatticeViewAction = new QAction(tr("View Lattice"), this);
        toggleLatticeViewAction->setShortcut(tr("L"));
        toggleLatticeViewAction->setCheckable(true);

        if (projectMode == 1) {
            addAction(toggleLatticeViewAction);
            menu->addAction(toggleLatticeViewAction);
            connect(toggleLatticeViewAction, SIGNAL(triggered()), signalMap, SLOT(map()));
            signalMap->setMapping(toggleLatticeViewAction, "realLattice");
            connect(signalMap, SIGNAL(mapped(const QString &)), image, SLOT(toggleVisible(const QString &)));
        }

        toggleParticlesViewAction = new QAction(tr("View Particles"), this);
        toggleParticlesViewAction->setShortcut(tr("P"));
        toggleParticlesViewAction->setCheckable(true);

        if (projectMode == 2) {
            addAction(toggleParticlesViewAction);
            menu->addAction(toggleParticlesViewAction);
            connect(toggleParticlesViewAction, SIGNAL(triggered()), image, SLOT(toggleParticleView()));
        }

        QMenu *fftSelectionMenu = new QMenu("Selection based FFT");

        QAction *fftSelectionAction = new QAction(tr("FFT of Selection"), this);
        fftSelectionMenu->addAction(fftSelectionAction);
        fftSelectionAction->setShortcut(tr("Shift+F"));
        fftSelectionAction->setCheckable(true);
        addAction(fftSelectionAction);
        connect(fftSelectionAction, SIGNAL(triggered()), this, SLOT(toggleFFTSelection()));

        if (projectMode == 1) {
            QAction *setReferenceOriginAction = new QAction(tr("Set Reference Origin"), this);
            fftSelectionMenu->addAction(setReferenceOriginAction);
            setReferenceOriginAction->setShortcut(tr("Shift+O"));
            addAction(setReferenceOriginAction);
            connect(setReferenceOriginAction, SIGNAL(triggered()), this, SLOT(setReferenceOrigin()));
            connect(setReferenceOriginAction, SIGNAL(triggered()), spotSelect, SLOT(updateReferenceOrigin()));
        }

        menu->addMenu(fftSelectionMenu);

        selectionMenu = new QMenu("Polygonal Selection");

        if (projectMode == 1) {
            QAction *selectionAreaAction = new QAction(tr("Polygonal Selection Masking"), this);
            selectionMenu->addAction(selectionAreaAction);
            selectionAreaAction->setShortcut(tr("Shift+S"));
            selectionAreaAction->setCheckable(true);
            addAction(selectionAreaAction);
            connect(selectionAreaAction, SIGNAL(triggered()), this, SLOT(toggleCreatePathMode()));


            QAction *saveSelectionArea = new QAction(tr("Save Selection"), this);
            selectionMenu->addAction(saveSelectionArea);
            saveSelectionArea->setShortcut(tr("Ctrl+Shift+S"));
            addAction(saveSelectionArea);
            connect(saveSelectionArea, SIGNAL(triggered()), image, SLOT(saveSelectionList()));

            QAction *clearSelectionArea = new QAction(tr("Clear Selection"), this);
            selectionMenu->addAction(clearSelectionArea);
            clearSelectionArea->setShortcut(tr("Ctrl+Shift+C"));
            addAction(clearSelectionArea);
            connect(clearSelectionArea, SIGNAL(triggered()), image, SLOT(clearSelectionVertices()));

            menu->addMenu(selectionMenu);


            QMenu *referenceMenu = new QMenu("Unbending References", menu);

            QAction *toggleBoxa1Action = new QAction(tr("View Boxa1"), this);
            toggleBoxa1Action->setCheckable(true);
            referenceMenu->addAction(toggleBoxa1Action);
            addAction(toggleBoxa1Action);
            connect(toggleBoxa1Action, SIGNAL(triggered()), this, SLOT(toggleBoxa1()));

            QAction *toggleBoxa2Action = new QAction(tr("View Boxa2"), this);
            toggleBoxa2Action->setCheckable(true);
            referenceMenu->addAction(toggleBoxa2Action);
            addAction(toggleBoxa2Action);
            connect(toggleBoxa2Action, SIGNAL(triggered()), this, SLOT(toggleBoxa2()));

            QAction *toggleBoxb1Action = new QAction(tr("View Boxb1"), this);
            toggleBoxb1Action->setCheckable(true);
            referenceMenu->addAction(toggleBoxb1Action);
            addAction(toggleBoxb1Action);
            connect(toggleBoxb1Action, SIGNAL(triggered()), this, SLOT(toggleBoxb1()));

            QAction *toggleBoxb2Action = new QAction(tr("View Boxb2"), this);
            toggleBoxb2Action->setCheckable(true);
            referenceMenu->addAction(toggleBoxb2Action);
            addAction(toggleBoxb2Action);
            connect(toggleBoxb2Action, SIGNAL(triggered()), this, SLOT(toggleBoxb2()));

            menu->addMenu(referenceMenu);

            QAction *setPhaseOriginAction = new QAction(tr("Set Phase Origin"), this);
            menu->addAction(setPhaseOriginAction);
            setPhaseOriginAction->setShortcut(tr("Shift+P"));
            addAction(setPhaseOriginAction);
            connect(setPhaseOriginAction, SIGNAL(triggered()), this, SLOT(setPhaseOrigin()));
        }

    }

    if (projectMode == 1) {
        QAction *showTiltAxisAction = new QAction(tr("View Tilt Axis in Raw Image (TLTAXIS)"), this);
        menu->addAction(showTiltAxisAction);
        showTiltAxisAction->setCheckable(true);
        showTiltAxisAction->setShortcut(tr("T"));
        addAction(showTiltAxisAction);
        connect(showTiltAxisAction, SIGNAL(triggered()), signalMap, SLOT(map()));
        signalMap->setMapping(showTiltAxisAction, "tiltaxis");
        connect(signalMap, SIGNAL(mapped(const QString &)), image, SLOT(toggleVisible(const QString &)));

        QAction *showTaxisAction = new QAction(tr("View Tilt Axis in Final Map (TAXA)"), this);
        menu->addAction(showTaxisAction);
        showTaxisAction->setCheckable(true);
        showTaxisAction->setShortcut(tr("Shift+T"));
        addAction(showTaxisAction);
        connect(showTaxisAction, SIGNAL(triggered()), signalMap, SLOT(map()));
        signalMap->setMapping(showTaxisAction, "tiltaxa");
        connect(signalMap, SIGNAL(mapped(const QString &)), image, SLOT(toggleVisible(const QString &)));
    }


    QAction *helpAction = new QAction(tr("Help"), this);
    helpAction->setShortcut(tr("H"));
    helpAction->setCheckable(true);
    addAction(helpAction);
    connect(helpAction, SIGNAL(triggered()), this, SLOT(toggleHelp()));
    menu->addAction(helpAction);

    closeAction = new QAction(tr("Close"), this);
    closeAction->setShortcut(tr("Esc"));
    addAction(closeAction);
    connect(closeAction, SIGNAL(triggered()), this, SLOT(closeCurrent()));
    menu->addAction(closeAction);

    //  menuBar->addMenu(menu);
}
Ejemplo n.º 11
0
int main(int argc, char** argv)
{
	bool run = GL_TRUE;

    if(!glfwInit())
    {
        exit(EXIT_FAILURE);
    }

    if(!glfwOpenWindow(window_width, window_height, 8, 8, 8, 8, 24, 0, GLFW_WINDOW))
    {
        glfwTerminate();
        exit(EXIT_FAILURE);
    }

    glewInit();
    if (!glewIsSupported( "GL_VERSION_2_0 " 
        "GL_ARB_pixel_buffer_object"
        )) {
            fprintf( stderr, "ERROR: Support for necessary OpenGL extensions missing.");
            fflush( stderr);
            return false;
    }

    initShader("./Shader/vert.glsl", "./Shader/frag.glsl");

    glfwSetKeyCallback(keypress);
    glfwSetMouseButtonCallback(mouseClick);
    glfwSetMousePosCallback(mouseMotion);

    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
    glEnable(GL_DEPTH_TEST);
    glDepthFunc(GL_LEQUAL);
    glViewport(0, 0, window_width, window_height);

    VBO vbo_handle;
    Scene scene("../Scene/test_scene.xml");
    // TODO: change here if you want to use a smaller iteration number.
    ClothSim cloth_sim(10);
    // TODO: change here if you want to modify the dimension.
    cloth_sim.initialize(20, 20, glm::vec3(-5.0f, 10.0f, -5.0f), glm::vec3(5.0f, 10.0f, 5.0f));
	//cloth_sim.initialize(30, 30, glm::vec3(-5.0f, 10.0f, -5.0f), glm::vec3(5.0f, 10.0f, 5.0f));


    lastTime = glfwGetTime();
    while(run)
    {
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        aimCamera();

        if(!pause)
            cloth_sim.update(&scene, 0.006325f);
        if(flip_draw_mode)
        {
            cloth_sim.flip_draw_mode();
            flip_draw_mode = false;
        }
        activate_shaderprog(m_shaderprog_handle);
        cloth_sim.draw(vbo_handle);
        scene.draw(vbo_handle);
        deactivate_shaderprog(m_shaderprog_handle);

        drawAxes();
        if(!pause && record)
            grabScreen();
        frame_num++;

        now = glfwGetTime();
        char fpsInfo[256];
        sprintf(fpsInfo, "%f", 1.0f / (now - lastTime));
        lastTime = now;
        glfwSetWindowTitle(fpsInfo);

        glfwSwapBuffers();

        run = !glfwGetKey(GLFW_KEY_ESC) && glfwGetWindowParam(GLFW_OPENED);
    }
    
    cleanupShader();
    glfwTerminate();
    exit(EXIT_SUCCESS);
}
Ejemplo n.º 12
0
  linksLay->addStretch();

  QVBoxLayout *layout = new QVBoxLayout(this);
  layout->addWidget(m_topFrame);
  layout->addWidget(m_recentView);
  layout->addWidget(m_controlFrame);
  layout->addWidget(m_linksFrame);
  layout->setMargin(0);
  layout->setSpacing(0);

  foreach (QToolButton *button, m_buttons) {
    connect(button, SIGNAL(clicked()), SLOT(close()));
  }

  connect(m_buttons.value(RectangleBtn), SIGNAL(clicked()), SIGNAL(grabRect()));
  connect(m_buttons.value(FullscreenBtn), SIGNAL(clicked()), SIGNAL(grabScreen()));
  connect(m_buttons.value(FileBtn), SIGNAL(clicked()), SIGNAL(openFile()));
  connect(m_siteBtn, SIGNAL(clicked()), SLOT(onSiteClicked()));
  connect(m_pinBtn, SIGNAL(clicked(bool)), SLOT(setPin(bool)));

  Observers::watch(this);
}


void TrayWindow::changeEvent(QEvent *event)
{
  if (event->type() == QEvent::LanguageChange)
    retranslateUi();

  QFrame::changeEvent(event);
}