Ejemplo n.º 1
0
void Scene::contextMenuEvent(QGraphicsSceneContextMenuEvent * event) {
  event->accept();
  QMenu* menu = new QMenu();
  QAction *ImageInfoAction = menu->addAction(QIcon(":/info.svg"),
                             tr("Image info"));
  connect(ImageInfoAction, SIGNAL(triggered()), this, SLOT(imageInfo()));
  menu->addSeparator();

  QAction* rotateCWAction = menu->addAction(QIcon(":/rotateCW.svg"),
                            tr("Rotate CW"));
  connect(rotateCWAction, SIGNAL(triggered()), this, SLOT(rotateCW()));

  QAction* rotateCCWAction = menu->addAction(QIcon(":/rotateCCW.svg"),
                             tr("Rotate CCW"));
  connect(rotateCCWAction, SIGNAL(triggered()), this, SLOT(rotateCCW()));

  QAction* rotateHalfAction = menu->addAction(QIcon(":/rotateCCW.svg"),
                              tr("Rotate 180°"));
  connect(rotateHalfAction, SIGNAL(triggered()), this, SLOT(rotateHalf()));
  QAction* detectOrientationAction = menu->addAction(QIcon(":/orientation.svg"),
                                                     tr("Detect orientation"));
  detectOrientationAction->setToolTip(
    tr("Page orientation detection (four 90 degree angles)"));
  connect(detectOrientationAction, SIGNAL(triggered()), this,
          SLOT(detectOrientation()));
  menu->exec(event->screenPos());
  menu->deleteLater();
}
Ejemplo n.º 2
0
	void PageGraphicsItem::contextMenuEvent (QGraphicsSceneContextMenuEvent *event)
	{
		QMenu rotateMenu;

		auto ccwAction = rotateMenu.addAction (tr ("Rotate 90 degrees counter-clockwise"),
				this, SLOT (rotateCCW ()));
		ccwAction->setProperty ("ActionIcon", "object-rotate-left");

		auto cwAction = rotateMenu.addAction (tr ("Rotate 90 degrees clockwise"),
				this, SLOT (rotateCW ()));
		cwAction->setProperty ("ActionIcon", "object-rotate-right");

		auto arbAction = rotateMenu.addAction (tr ("Rotate arbitrarily..."));
		arbAction->setProperty ("ActionIcon", "transform-rotate");

		auto arbMenu = new QMenu ();
		arbAction->setMenu (arbMenu);

		ArbWidget_ = new ArbitraryRotationWidget;
		ArbWidget_->setValue (LayoutManager_->GetRotation () +
				LayoutManager_->GetRotation (PageNum_));
		connect (ArbWidget_,
				SIGNAL (valueChanged (double)),
				this,
				SLOT (requestRotation (double)));
		connect (LayoutManager_,
				SIGNAL (rotationUpdated (double, int)),
				this,
				SLOT (updateRotation (double, int)));
		auto actionWidget = new QWidgetAction (arbMenu);
		actionWidget->setDefaultWidget (ArbWidget_);
		arbMenu->addAction (actionWidget);

		rotateMenu.exec (event->screenPos ());
	}
Ejemplo n.º 3
0
void AppWindow::keyPressEvent(QKeyEvent *event) {
    
    if(m_viewer->gameStatus>=0){
        if (event->key() == Qt::Key_Escape) {
            QCoreApplication::instance()->quit();
        } else if (event->key() == Qt::Key_Right) {
            moveRight();
        } else if (event->key() == Qt::Key_Left) {
            moveLeft();
        } else if (event->key() == Qt::Key_Down) {
            rotateCW();
        } else if (event->key() == Qt::Key_Up) {
            rotateCCW();
        } else if (event->key() == Qt::Key_Space) {
            dropPiece();
        } else if (event->key() == Qt::Key_Shift) {
           shiftPressed();
        }
    }




    if (event->key() == Qt::Key_1) {
        slowSpeed();
        slowSpeedAct->setChecked(true);
    }else if (event->key() == Qt::Key_2) {
        normalSpeed();
        normalSpeedAct->setChecked(true);
    }else if (event->key() == Qt::Key_3) {
        fastSpeed();
        fastSpeedAct->setChecked(true);
    }else if (event->key() == Qt::Key_W) {
        wire_frame();
        wireAct->setChecked(true);
    }else if (event->key() == Qt::Key_F) {
        face();
        faceAct->setChecked(true);
    }else if (event->key() == Qt::Key_M) {
        multi_coloured();
        multiAct->setChecked(true);
    }else if (event->key() == Qt::Key_N) {
        new_game();
    }else if (event->key() == Qt::Key_R) {
        reset();
    }else if (event->key() == Qt::Key_Q) {
        close();
    }else {
        QWidget::keyPressEvent(event);
    }
}
Ejemplo n.º 4
0
int main(void) {
	//uint8_t seq[] = {0x08, 0x04, 0x02, 0x01};
	uint8_t ccw = 1;
		
	// reset A
 	DDRA = 0x00;
	PORTA = 0x00;
	// reset B
	DDRB = 0x00;
	PORTB = 0x00;
	// reset C
	DDRD = 0x00;
	PORTD = 0x00;
	

	DDRB = 0xff;//B as OUT
	PORTB = 0x00;//set to LO

	DDRD = 0x00;//D as IN
	PORTD = 0xff;//enable pull-up
	
	PORTB |= (1 << PB7);
	
	blink(200, 400);
	
    while(1) {
		if (~PIND & (1 << PD2)) {
			PORTB |= 1 << PB6;
			delay_ms(200);
			PORTB &= ~(1 << PB6);
			if (~PIND & (1 << PD2)) {
				ccw = !ccw;
				blink(125, 500);
			}
		}
		PORTB &= ~(1 << PB6);
		if (ccw) {
			rotateCCW();
		} else {
			rotateCW();
		}
    }
}
Ejemplo n.º 5
0
void rotate(unsigned int steps, unsigned int speed, uint8_t flags)
{
	const uint8_t* sequence;
	uint8_t length = 4;

	if (flags & HALF_STEP)
	{
		sequence = halfSequence;
		length <<= 1;
	}
	else if (flags & WAVE_STEP)
		sequence = waveSequence;
	else
		sequence = fullSequence;
	
	if (flags & ROTATE_CCW)
		rotateCCW(steps, speed, sequence, length);
	else
		rotateCW(steps, speed, sequence, length);
}
Ejemplo n.º 6
0
bool Camera::pollEvent( SDL_Event *event )
    // This should be called at regular intervals to avoid key-response lag
{

    if( !SDL_PollEvent(event) ) {

        if( event->type==SDL_QUIT )
            exit(0);
        if( event->type!=SDL_KEYDOWN )
        {
            step();
            return false;
        }

    }

    switch( event->key.keysym.sym ) {

    case SDLK_LEFT:
        if( event->key.keysym.mod & KMOD_SHIFT )
            revolveLeft();
        else if( event->key.keysym.mod & KMOD_CTRL )
            rotateCW();
        else if( event->key.keysym.mod & KMOD_ALT )
            accelerateLeft(accInc);
        else
            panLeft();
        break;
    case SDLK_RIGHT:
        if( event->key.keysym.mod & KMOD_SHIFT )
            revolveRight();
        else if( event->key.keysym.mod & KMOD_CTRL )
            rotateCCW();
        else if( event->key.keysym.mod & KMOD_ALT )
            accelerateRight(accInc);
        else
            panRight();
        break;
    case SDLK_UP:
        if( event->key.keysym.mod & KMOD_SHIFT )
            revolveUp();
        else if( event->key.keysym.mod & KMOD_ALT )
            accelerateUp(accInc);
        else
            panUp();
        break;
    case SDLK_DOWN:
        if( event->key.keysym.mod & KMOD_SHIFT )
            revolveDown();
        else if( event->key.keysym.mod & KMOD_ALT )
            accelerateDown(accInc);
        else
            panDown();
        break;
	case SDLK_f:
	case SDLK_PERIOD:
        accelerate(accInc);
        break;
	case SDLK_b:
    case SDLK_COMMA:
        accelerate(-accInc);
        break;
    case SDLK_SPACE:
        stop();
        break;
    case SDLK_F1:
        accInc = accel[0];
        break;
    case SDLK_F2:
        accInc = accel[1];
        break;
    case SDLK_F3:
        accInc = accel[2];
        break;
    case SDLK_F4:
        accInc = accel[3];
        break;
    case SDLK_F5:
        accInc = accel[4];
        break;
    case SDLK_F6:
        accInc = accel[5];
        break;
    case SDLK_F7:
        accInc = accel[6];
        break;
    case SDLK_F8:
        accInc = accel[7];
        break;
    case SDLK_F9:
        accInc = accel[8];
        break;
    case SDLK_ESCAPE:
        exit(0);
        break;
    case SDLK_TAB:
        if( event->key.keysym.mod & KMOD_SHIFT )
            storeCamera(camStore);
        else
            restoreCamera(camStore);
            stop();
        break;

    default:
        break;

    }

    step();
    return true;

}
Ejemplo n.º 7
0
FITSViewer::FITSViewer (QWidget *parent)
        : KXmlGuiWindow (parent)
{
#ifdef Q_OS_OSX
    if(Options::independentWindowFITS())
         setWindowFlags(Qt::Window);
     else{
        setWindowFlags(Qt::Window | Qt::WindowStaysOnTopHint);
        connect(QApplication::instance(), SIGNAL(applicationStateChanged(Qt::ApplicationState)), this, SLOT(changeAlwaysOnTop(Qt::ApplicationState)));
     }
#endif

    fitsTab   = new QTabWidget(this);
    undoGroup = new QUndoGroup(this);

    fitsID = 0;
    debayerDialog= NULL;
    markStars = false;

    lastURL = QUrl(QDir::homePath());

    fitsTab->setTabsClosable(true);

    setWindowIcon(QIcon::fromTheme("kstars_fitsviewer", QIcon(":/icons/breeze/default/kstars_fitsviewer.svg")));

    setCentralWidget(fitsTab);

    connect(fitsTab, SIGNAL(currentChanged(int)), this, SLOT(tabFocusUpdated(int)));
    connect(fitsTab, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int)));

    //These two connections will enable or disable the scope button if a scope is available or not.
    //Of course this is also dependent on the presence of WCS data in the image.

    #ifdef HAVE_INDI
    connect(INDIListener::Instance(), SIGNAL(newTelescope(ISD::GDInterface *)), this, SLOT(updateWCSFunctions()));
    connect(INDIListener::Instance(), SIGNAL(deviceRemoved(ISD::GDInterface *)), this, SLOT(updateWCSFunctions()));
    #endif

    led.setColor(Qt::green);

    fitsPosition.setAlignment(Qt::AlignCenter);
    fitsValue.setAlignment(Qt::AlignCenter);

    //fitsPosition.setFixedWidth(100);
    //fitsValue.setFixedWidth(100);
    fitsWCS.setVisible(false);

    statusBar()->insertPermanentWidget(FITS_WCS, &fitsWCS);
    statusBar()->insertPermanentWidget(FITS_VALUE, &fitsValue);
    statusBar()->insertPermanentWidget(FITS_POSITION, &fitsPosition);
    statusBar()->insertPermanentWidget(FITS_ZOOM, &fitsZoom);
    statusBar()->insertPermanentWidget(FITS_RESOLUTION, &fitsResolution);
    statusBar()->insertPermanentWidget(FITS_LED, &led);

    QAction *action;

    action = actionCollection()->addAction("rotate_right", this, SLOT(rotateCW()));
    action->setText(i18n("Rotate Right"));
    action->setIcon(QIcon::fromTheme("object-rotate-right", QIcon(":/icons/breeze/default/object-rotate-right.svg")));

    action = actionCollection()->addAction("rotate_left", this, SLOT(rotateCCW()));
    action->setText(i18n("Rotate Left"));
    action->setIcon(QIcon::fromTheme("object-rotate-left", QIcon(":/icons/breeze/default/object-rotate-left.svg")));

    action = actionCollection()->addAction("flip_horizontal", this, SLOT(flipHorizontal()));
    action->setText(i18n("Flip Horizontal"));
    action->setIcon(QIcon::fromTheme("object-flip-horizontal", QIcon(":/icons/breeze/default/object-flip-horizontal.svg")));

    action = actionCollection()->addAction("flip_vertical", this, SLOT(flipVertical()));
    action->setText(i18n("Flip Vertical"));
    action->setIcon(QIcon::fromTheme("object-flip-vertical", QIcon(":/icons/breeze/default/object-flip-vertical.svg")));

    action = actionCollection()->addAction("image_histogram");
    action->setText(i18n("Histogram"));
    connect(action, SIGNAL(triggered(bool)), SLOT (histoFITS()));
    actionCollection()->setDefaultShortcut(action, QKeySequence::Replace);

    action->setIcon(QIcon(":/icons/histogram.png"));

    action = KStandardAction::open(this,   SLOT(openFile()),   actionCollection());
    action->setIcon(QIcon::fromTheme("document-open", QIcon(":/icons/breeze/default/document-open.svg")));
    
    saveFileAction    = KStandardAction::save(this,   SLOT(saveFile()),   actionCollection());
    saveFileAction->setIcon(QIcon::fromTheme("document-save", QIcon(":/icons/breeze/default/document-save.svg")));

    action=saveFileAsAction  = KStandardAction::saveAs(this, SLOT(saveFileAs()), actionCollection());
    saveFileAsAction->setIcon(QIcon::fromTheme("document-save_as", QIcon(":/icons/breeze/default/document-save-as.svg")));

    action = actionCollection()->addAction("fits_header");
    actionCollection()->setDefaultShortcut(action, QKeySequence(Qt::CTRL+Qt::Key_H));
    action->setIcon(QIcon::fromTheme("document-properties", QIcon(":/icons/breeze/default/document-properties.svg")));
    action->setText(i18n( "FITS Header"));
    connect(action, SIGNAL(triggered(bool) ), SLOT(headerFITS()));

    action = actionCollection()->addAction("fits_debayer");
    actionCollection()->setDefaultShortcut(action, QKeySequence(Qt::CTRL+Qt::Key_D));
    action->setIcon(QIcon::fromTheme("view-preview", QIcon(":/icons/breeze/default/view-preview.svg")));
    action->setText(i18n( "Debayer..."));
    connect(action, SIGNAL(triggered(bool) ), SLOT(debayerFITS()));

    action = actionCollection()->addAction("image_stretch");
    action->setText(i18n("Auto stretch"));
    connect(action, SIGNAL(triggered(bool)), SLOT (stretchFITS()));
    actionCollection()->setDefaultShortcut(action, QKeySequence::SelectAll);
    action->setIcon(QIcon::fromTheme("transform-move", QIcon(":/icons/breeze/default/transform-move.svg")));

    action = KStandardAction::close(this,  SLOT(close()),  actionCollection());
    action->setIcon(QIcon::fromTheme("window-close", QIcon(":/icons/breeze/default/window-close.svg")));
    
    action = KStandardAction::copy(this,   SLOT(copyFITS()),   actionCollection());
    action->setIcon(QIcon::fromTheme("edit-copy", QIcon(":/icons/breeze/default/edit-copy.svg")));
    
    action=KStandardAction::zoomIn(this,     SLOT(ZoomIn()),      actionCollection());
    action->setIcon(QIcon::fromTheme("zoom-in", QIcon(":/icons/breeze/default/zoom-in.svg")));
    
    action=KStandardAction::zoomOut(this,    SLOT(ZoomOut()),     actionCollection());
    action->setIcon(QIcon::fromTheme("zoom-out", QIcon(":/icons/breeze/default/zoom-out.svg")));
    
    action=KStandardAction::actualSize(this, SLOT(ZoomDefault()), actionCollection());
    action->setIcon(QIcon::fromTheme("zoom-fit-best", QIcon(":/icons/breeze/default/zoom-fit-best.svg")));

    QAction *kundo = KStandardAction::undo(undoGroup, SLOT(undo()), actionCollection());
    kundo->setIcon(QIcon::fromTheme("edit-undo", QIcon(":/icons/breeze/default/edit-undo.svg")));
    
    QAction *kredo = KStandardAction::redo(undoGroup, SLOT(redo()), actionCollection());
    kredo->setIcon(QIcon::fromTheme("edit-redo", QIcon(":/icons/breeze/default/edit-redo.svg")));

    connect(undoGroup, SIGNAL(canUndoChanged(bool)), kundo, SLOT(setEnabled(bool)));
    connect(undoGroup, SIGNAL(canRedoChanged(bool)), kredo, SLOT(setEnabled(bool)));

    action = actionCollection()->addAction("image_stats");
    action->setIcon(QIcon::fromTheme("view-statistics", QIcon(":/icons/breeze/default/view-statistics.svg")));
    action->setText(i18n( "Statistics"));
    connect(action, SIGNAL(triggered(bool)), SLOT(statFITS()));

    action = actionCollection()->addAction("view_crosshair");
    action->setIcon(QIcon::fromTheme("crosshairs", QIcon(":/icons/breeze/default/crosshairs.svg")));
    action->setText(i18n( "Show Cross Hairs"));
    action->setCheckable(true);
    connect(action, SIGNAL(triggered(bool)), SLOT(toggleCrossHair()));

    action = actionCollection()->addAction("view_pixel_grid");
    action->setIcon(QIcon::fromTheme("map-flat", QIcon(":/icons/breeze/default/map-flat.svg")));
    action->setText(i18n( "Show Pixel Gridlines"));
    action->setCheckable(true);
    connect(action, SIGNAL(triggered(bool)), SLOT(togglePixelGrid()));

    action = actionCollection()->addAction("view_eq_grid");
    action->setIcon(QIcon::fromTheme("kstars_grid", QIcon(":/icons/breeze/default/kstars_grid.svg")));
    action->setText(i18n( "Show Equatorial Gridlines"));
    action->setCheckable(true);
    action->setDisabled(true);
    connect(action, SIGNAL(triggered(bool)), SLOT(toggleEQGrid()));

    action = actionCollection()->addAction("view_objects");
    action->setIcon(QIcon::fromTheme("help-hint", QIcon(":/icons/breeze/default/help-hint.svg")));
    action->setText(i18n( "Show Objects in Image"));
    action->setCheckable(true);
    action->setDisabled(true);
    connect(action, SIGNAL(triggered(bool)), SLOT(toggleObjects()));

    action = actionCollection()->addAction("center_telescope");
    action->setIcon(QIcon(":/icons/center_telescope.svg"));
    action->setText(i18n( "Center Telescope\n*No Telescopes Detected*"));
    action->setDisabled(true);
    action->setCheckable(true);
    connect(action, SIGNAL(triggered(bool)), SLOT(centerTelescope()));

    action = actionCollection()->addAction("view_zoom_fit");
    action->setIcon(QIcon::fromTheme("zoom-fit-width", QIcon(":/icons/breeze/default/zoom-fit-width.svg")));
    action->setText(i18n( "Zoom To Fit"));
    connect(action, SIGNAL(triggered(bool)), SLOT(ZoomToFit()));

    action = actionCollection()->addAction("mark_stars");
    action->setText(i18n( "Mark Stars"));
    connect(action, SIGNAL(triggered(bool)), SLOT(toggleStars()));

    QSignalMapper *filterMapper = new QSignalMapper(this);

    int filterCounter=1;

    foreach(QString filter, FITSViewer::filterTypes)
    {

        action = actionCollection()->addAction(QString("filter%1").arg(filterCounter));
        action->setText(i18n(filter.toUtf8().constData()));
        filterMapper->setMapping(action, filterCounter++);
        connect(action, SIGNAL(triggered()), filterMapper, SLOT(map()));


    }