Ejemplo n.º 1
0
void QgsMapCanvas::wheelEvent( QWheelEvent *e )
{
  // Zoom the map canvas in response to a mouse wheel event. Moving the
  // wheel forward (away) from the user zooms in

  QgsDebugMsg( "Wheel event delta " + QString::number( e->delta() ) );

  if ( mMapTool )
  {
    mMapTool->wheelEvent( e );
  }

  if ( QgsApplication::keyboardModifiers() )
  {
    // leave the wheel for map tools if any modifier pressed
    return;
  }

  switch ( mWheelAction )
  {
    case WheelZoom:
      // zoom without changing extent
      if ( e->delta() > 0 )
        zoomIn();
      else
        zoomOut();
      break;

    case WheelZoomAndRecenter:
      // zoom and don't change extent
      zoomWithCenter( e->x(), e->y(), e->delta() > 0 );
      break;

    case WheelZoomToMouseCursor:
    {
      // zoom map to mouse cursor
      double scaleFactor = e->delta() > 0 ? 1 / mWheelZoomFactor : mWheelZoomFactor;

      QgsPoint oldCenter = center();
      QgsPoint mousePos( getCoordinateTransform()->toMapPoint( e->x(), e->y() ) );
      QgsPoint newCenter( mousePos.x() + (( oldCenter.x() - mousePos.x() ) * scaleFactor ),
                          mousePos.y() + (( oldCenter.y() - mousePos.y() ) * scaleFactor ) );

      zoomByFactor( scaleFactor, &newCenter );
      break;
    }

    case WheelNothing:
      // well, nothing!
      break;
  }
}
Ejemplo n.º 2
0
void FlickableMap::wheelEvent(QWheelEvent *event)
{
    if (event->orientation() == Qt::Horizontal) {
        event->ignore();
    } else {
        if (event->delta() > 0) {
            zoomIn();
        } else {
            zoomOut();
        }
        event->accept();
    }
}
Ejemplo n.º 3
0
/** Ctrl + Rotating the mouse wheel will increase/decrease the font size
 *
 */
void ScriptEditor::wheelEvent(QWheelEvent *e) {
    if (e->modifiers() == Qt::ControlModifier) {
        if (e->delta() > 0) {
            zoomIn();
            emit textZoomedIn(); // allows tracking
        } else {
            zoomOut();
            emit textZoomedOut(); // allows tracking
        }
    } else {
        QsciScintilla::wheelEvent(e);
    }
}
Ejemplo n.º 4
0
void HelpViewer::wheelEvent(QWheelEvent *e)
{
    if (e->modifiers() & Qt::ControlModifier) {
        const int delta = e->delta();
        if (delta > 0)
            zoomIn(delta / 120);
        else if (delta < 0)
            zoomOut(-delta / 120);
        e->accept();
        return;
    }
    QWebView::wheelEvent(e);
}
Ejemplo n.º 5
0
void MapTilesFrame::zoomOut()
{
    qDebug() << "zooming OUT . . . viewport coordinate: " << getViewportCoordinate();
    qDebug() << "viewport size: " << size();

//    ZoomEffect *ze = createZoomEffect(QPoint(width() / 2, height() / 2));
//    ze->zoomOutEffect();

    //以视口中心点为视点缩放(服务器坐标系)
    QPoint viewportCenterPoint(getViewportCoordinate().x() + getViewportWidth() / 2,
                               getViewportCoordinate().y() - getViewportHeight() / 2);
    zoomOut(viewportCenterPoint);
}
Ejemplo n.º 6
0
void CodeEditer::wheelEvent(QWheelEvent *e)
{
	//d->clearVisibleCollapsedBlock();
	if (e->modifiers() & Qt::ControlModifier) {
		const int delta = e->delta();
		if (delta < 0)
			zoomOut();
		else if (delta > 0)
			zoomIn();
		return;
	}
	QPlainTextEdit::wheelEvent(e);
}
Ejemplo n.º 7
0
Archivo: zoom.c Proyecto: zmike/compiz
static Bool
zoomTerminate(CompDisplay *d,
              CompAction *action,
              CompActionState state,
              CompOption *option,
              int nOption)
{
   CompScreen *s;
   Window xid;

   xid = getIntOptionNamed(option, nOption, "root", 0);

   for (s = d->screens; s; s = s->next)
     {
        ZOOM_SCREEN(s);

        if (xid && s->root != xid)
          continue;

        if (zs->grab)
          {
             int output;

             output = outputDeviceForPoint(s, zs->x1, zs->y1);

             if (zs->x2 > s->outputDev[output].region.extents.x2)
               zs->x2 = s->outputDev[output].region.extents.x2;

             if (zs->y2 > s->outputDev[output].region.extents.y2)
               zs->y2 = s->outputDev[output].region.extents.y2;

             zoomInitiateForSelection(s, output);

             zs->grab = FALSE;
          }
        else
          {
             CompOption o;

             o.type = CompOptionTypeInt;
             o.name = "root";
             o.value.i = s->root;

             zoomOut(d, action, state, &o, 1);
          }
     }

   action->state &= ~(CompActionStateTermKey | CompActionStateTermButton);

   return FALSE;
}
Ejemplo n.º 8
0
void MapWidget::wheelEvent(QWheelEvent* event)
{
    int numDegrees=event->delta()/8;
    int numSteps=numDegrees/15;

    if (numSteps>=0) {
        zoomIn(numSteps*1.35);
    }
    else {
        zoomOut(-numSteps*1.35);
    }

    event->accept();
}
Ejemplo n.º 9
0
Topology::Topology(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Topology)
{
    ui->setupUi(this);

    ui->flushBtn->setEnabled(false);
    flushClass = NULL;

    timerId = 0;
    seq = 0;

    scene = new QGraphicsScene(this);
    scene->setItemIndexMethod(QGraphicsScene::NoIndex);
    scene->setSceneRect(-960, -540, 1920, 1080);
    ui->graphicsView->setScene(scene);
    ui->graphicsView->setAcceptDrops(true);
    ui->graphicsView->setCacheMode(QGraphicsView::CacheBackground);
    ui->graphicsView->setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
    ui->graphicsView->setRenderHint(QPainter::Antialiasing);
    ui->graphicsView->setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
    ui->graphicsView->scale(qreal(0.8), qreal(0.8));

    centerNode = NULL;

    connect(ui->zoomOutBtn, SIGNAL(clicked()), this, SLOT(zoomOut()));
    connect(ui->zoomInBtn, SIGNAL(clicked()), this, SLOT(zoomIn()));

    configFile = new QFile("config.dat");
    if(!configFile->open(QIODevice::ReadWrite))
    {
        std::cerr << "Cannot open file:"
                  << qPrintable(configFile->errorString())
                  << endl;
        return;
    }

    QDataStream in(configFile);
    in.setVersion(QDataStream::Qt_4_3);

    QStringList argList;
    in >> argList;
    if(argList.count() == 3)
    {
        comName = argList[0];
        comStatue = argList[1];
        netStatue = argList[2];

        in >> panid >> chanel;
    }
Ejemplo n.º 10
0
void Navigation::setMap( MarbleWidget* widget )
{
    d->m_marbleWidget = widget;
    if ( d->m_marbleWidget ) {
        // Avoid the QWidget based warning
        d->m_marbleWidget->model()->routingManager()->setShowGuidanceModeStartupWarning( false );
        connect( d->m_marbleWidget->model()->routingManager()->routingModel(),
                SIGNAL(positionChanged()), this, SLOT(update()) );

        delete d->m_autoNavigation;
        d->m_autoNavigation = new Marble::AutoNavigation( d->m_marbleWidget->model(), d->m_marbleWidget->viewport(), this );
        connect( d->m_autoNavigation, SIGNAL(zoomIn(FlyToMode)),
                 d->m_marbleWidget, SLOT(zoomIn()) );
        connect( d->m_autoNavigation, SIGNAL(zoomOut(FlyToMode)),
                 d->m_marbleWidget, SLOT(zoomOut()) );
        connect( d->m_autoNavigation, SIGNAL(centerOn(GeoDataCoordinates,bool)),
                 d->m_marbleWidget, SLOT(centerOn(GeoDataCoordinates)) );

        connect( d->m_marbleWidget, SIGNAL(visibleLatLonAltBoxChanged()),
                 d->m_autoNavigation, SLOT(inhibitAutoAdjustments()) );
        connect( d->m_marbleWidget->model()->positionTracking(), SIGNAL(statusChanged(PositionProviderStatus)),
                 &d->m_voiceNavigation, SLOT(handleTrackingStatusChange(PositionProviderStatus)) );
    }
Ejemplo n.º 11
0
void MapWidget::keyPressEvent(QKeyEvent* e) {
	if ( _canvas.filterKeyPressEvent(e) ) {
		e->accept();
		return;
	}

	e->accept();

	int key = e->key();

	switch ( key ) {
		case Qt::Key_Plus:
		case Qt::Key_I:
			if ( e->modifiers() == Qt::NoModifier )
				zoomIn();
			break;
		case Qt::Key_Minus:
		case Qt::Key_O:
			if ( e->modifiers() == Qt::NoModifier )
				zoomOut();
			break;
		case Qt::Key_Left:
			_canvas.translate(QPointF(-1.0,0.0));
			update();
			break;
		case Qt::Key_Right:
			_canvas.translate(QPointF(1.0,0.0));
			update();
			break;
		case Qt::Key_Up:
			_canvas.translate(QPointF(0.0,1.0));
			update();
			break;
		case Qt::Key_Down:
			_canvas.translate(QPointF(0.0,-1.0));
			update();
			break;
		case Qt::Key_G:
			_canvas.setDrawGrid(!_canvas.isDrawGridEnabled());
			break;
		case Qt::Key_C:
			_canvas.setDrawCities(!_canvas.isDrawCitiesEnabled());
			break;
		default:
			e->ignore();
			emit keyPressed(e);
			break;
	};
}
Ejemplo n.º 12
0
    void QmlMapControl::touchEvent(QTouchEvent *evnt)
    {
        const QList<QTouchEvent::TouchPoint> & touchs = evnt->touchPoints();
        if( touchs.count() != 2 )
        {
            QQuickPaintedItem::touchEvent(evnt);
        }
        else
        {
            evnt->accept();

            const QTouchEvent::TouchPoint & t0 = touchs.first();
            const QTouchEvent::TouchPoint & t1 = touchs.last();

            if( last_t0_startPos.isNull() )
                last_t0_startPos = t0.startPos();
            if( last_t1_startPos.isNull() )
                last_t1_startPos = t1.startPos();

            qreal startW = qPow( qPow(last_t0_startPos.x()-last_t1_startPos.x(),2)+qPow(last_t0_startPos.y()-last_t1_startPos.y(),2), 0.5 );
            qreal endW = qPow( qPow(t0.pos().x()-t1.pos().x(),2)+qPow(t0.pos().y()-t1.pos().y(),2), 0.5 );

            if( startW*4/3<endW )
            {
                QPoint pnt( last_t0_startPos.x()/2+last_t1_startPos.x()/2, last_t0_startPos.y()/2+last_t1_startPos.y()/2 );
                QPoint newPoint( width()-pnt.x(), height()-pnt.y() );

                setView(clickToWorldCoordinate(pnt));
                zoomIn(pnt);
                setView(clickToWorldCoordinate(newPoint));

                last_t0_startPos = t0.pos();
                last_t1_startPos = t1.pos();
            }
            else
            if( startW*3/4>endW )
            {
                QPoint pnt( t0.pos().x()/2+t1.pos().x()/2, t0.pos().y()/2+t1.pos().y()/2 );
                QPoint newPoint( width()-pnt.x(), height()-pnt.y() );

                setView(clickToWorldCoordinate(pnt));
                zoomOut(pnt);
                setView(clickToWorldCoordinate(newPoint));

                last_t0_startPos = t0.pos();
                last_t1_startPos = t1.pos();
            }
        }
    }
Ejemplo n.º 13
0
void VMdEditor::zoomPage(bool p_zoomIn, int p_range)
{
    int delta;
    const int minSize = 2;

    if (p_zoomIn) {
        delta = p_range;
        zoomIn(p_range);
    } else {
        delta = -p_range;
        zoomOut(p_range);
    }

    m_zoomDelta += delta;

    QVector<HighlightingStyle> &styles = m_mdHighlighter->getHighlightingStyles();
    for (auto & it : styles) {
        int size = it.format.fontPointSize();
        if (size == 0) {
            // It contains no font size format.
            continue;
        }

        size += delta;
        if (size < minSize) {
            size = minSize;
        }

        it.format.setFontPointSize(size);
    }

    QHash<QString, QTextCharFormat> &cbStyles = m_mdHighlighter->getCodeBlockStyles();
    for (auto it = cbStyles.begin(); it != cbStyles.end(); ++it) {
        int size = it.value().fontPointSize();
        if (size == 0) {
            // It contains no font size format.
            continue;
        }

        size += delta;
        if (size < minSize) {
            size = minSize;
        }

        it.value().setFontPointSize(size);
    }

    m_mdHighlighter->rehighlight();
}
Ejemplo n.º 14
0
int FreqView::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = ViewWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: zoomIn(); break;
        case 1: zoomOut(); break;
        case 2: setAmplitudeZoom((*reinterpret_cast< double(*)>(_a[1]))); break;
        }
        _id -= 3;
    }
    return _id;
}
Ejemplo n.º 15
0
void ImageView::makeConnection()
{
	connect(tBtn_menu, SIGNAL(triggered(QAction*)), this, SLOT(goBack(QAction*)));
	connect(btn_oriMode, SIGNAL(clicked()), this, SLOT(enterOriginalMode()));
	connect(btn_proMode, SIGNAL(clicked()), this, SLOT(enterProcessedMode()));
	connect(btn_editMode, SIGNAL(clicked()), this, SLOT(enterEditableMode()));
	connect(btn_save, SIGNAL(clicked()), this, SLOT(saveImage()));
	connect(btn_process, SIGNAL(clicked()), this, SLOT(processImage()));

	connect(btn_zoomIn, SIGNAL(clicked()), this, SLOT(zoomIn()));
	connect(btn_zoomOut, SIGNAL(clicked()), this, SLOT(zoomOut()));
	connect(com_zoom, SIGNAL(currentIndexChanged(int)), this, SLOT(zoomTo(int)));
	
	
}
Ejemplo n.º 16
0
void MainWindow::connectUiToFunction()
{
    connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(open()));
    connect(ui->actionExit, SIGNAL(triggered()), this, SLOT(close()));
    connect(ui->actionSave, SIGNAL(triggered()), this, SLOT(save()));
    connect(ui->actionSaveAs, SIGNAL(triggered()), this, SLOT(saveAs()));
    connect(ui->actionZoom_In_25, SIGNAL(triggered()), this, SLOT(zoomIn()));
    connect(ui->actionZoom_Out_25, SIGNAL(triggered()), this, SLOT(zoomOut()));
    connect(ui->actionNormal_Size, SIGNAL(triggered()), this, SLOT(normlSize()));
    connect(ui->actionPrint, SIGNAL(triggered()), this, SLOT(print()));
    connect(ui->actionHelp, SIGNAL(triggered()), this, SLOT(about()));
    connect(ui->actionFit_to_Window, SIGNAL(triggered()), this, SLOT(fitToWindow()));

    connect(ui->actionLevel_Set_Segmentation, SIGNAL(triggered()), this, SLOT(level_set()));
}
Ejemplo n.º 17
0
void NavigationBarWidget::initialize()
	{
	// Connecting necessary Signals to Slots
	connect(iSlidingTimer, SIGNAL(timeout()), this, SLOT(slideTick()));
	connect(ui.SlidePushButton, SIGNAL(clicked()), this, SLOT(propagateSlideClicked()));
	connect(ui.SlidePushButton, SIGNAL(clicked()), this, SLOT(slide()));
	// Attaching Signals and Slots for Zooming
	connect(ui.ZoomInPushButton, SIGNAL(clicked()), this, SLOT(zoomIn()));
	connect(ui.ZoomOutPushButton, SIGNAL(clicked()), this, SLOT(zoomOut()));
	// Connecting internal Signals with external ones, for encapsulation
	connect(ui.BackPushButton, SIGNAL(clicked()), this, SIGNAL(backClicked()));
	connect(ui.ForwardPushButton, SIGNAL(clicked()), this, SIGNAL(forwardClicked()));
	connect(ui.HomePushButton, SIGNAL(clicked()), this, SIGNAL(homeClicked()));
	connect(ui.ZoomSlider, SIGNAL(valueChanged(int)), this, SIGNAL(zoomLevelChanged(int)));
	}
Ejemplo n.º 18
0
/*
 * Name:        keyPressEvent
 * Purpose:     user can zoom in or out based on user's use of the keyboard
 * Arguments:   QKeyEvent
 * Output:      none
 * Modifies:    none
 * Returns:     none
 * Assumptions: none
 * Bugs:        none...so far
 * Notes:       none
 */
void PreView::keyPressEvent(QKeyEvent *event)
{
    switch (event->key()) {
    case Qt::Key_Plus:
        zoomIn();
        break;
    case Qt::Key_Minus:
        zoomOut();
        break;
    case Qt::Key_Delete:
        break;
    default:
        QGraphicsView::keyPressEvent(event);
    }
}
Ejemplo n.º 19
0
/**
 * @brief ImageDialog::ImageDialog
 * @param parent
 */
ImageDialog::ImageDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ImageDialog)
{
    ui->setupUi(this);

#ifdef Q_WS_MAC
    setWindowFlags((windowFlags() & ~Qt::WindowType_Mask) | Qt::Sheet);
    setStyleSheet(styleSheet() + " #ImageDialog { border: 1px solid rgba(0, 0, 0, 100); border-top: none; }");
#else
    setWindowFlags((windowFlags() & ~Qt::WindowType_Mask) | Qt::Dialog);
#endif

    QSettings settings;
    resize(settings.value("ImageDialog/Size").toSize());

    connect(ui->table, SIGNAL(cellClicked(int,int)), this, SLOT(imageClicked(int, int)));
    connect(ui->table, SIGNAL(sigDroppedImage(QUrl)), this, SLOT(onImageDropped(QUrl)));
    connect(ui->buttonClose, SIGNAL(clicked()), this, SLOT(reject()));
    connect(ui->buttonChoose, SIGNAL(clicked()), this, SLOT(chooseLocalImage()));
    connect(ui->previewSizeSlider, SIGNAL(valueChanged(int)), this, SLOT(onPreviewSizeChange(int)));
    connect(ui->buttonZoomIn, SIGNAL(clicked()), this, SLOT(onZoomIn()));
    connect(ui->buttonZoomOut, SIGNAL(clicked()), this, SLOT(onZoomOut()));
    QMovie *movie = new QMovie(":/img/spinner.gif");
    movie->start();
    ui->labelSpinner->setMovie(movie);
    clear();
    setImageType(TypePoster);
    m_currentDownloadReply = 0;

    QPixmap zoomOut(":/img/zoom_out.png");
    QPixmap zoomIn(":/img/zoom_in.png");
    QPainter p;
    p.begin(&zoomOut);
    p.setCompositionMode(QPainter::CompositionMode_SourceIn);
    p.fillRect(zoomOut.rect(), QColor(0, 0, 0, 150));
    p.end();
    p.begin(&zoomIn);
    p.setCompositionMode(QPainter::CompositionMode_SourceIn);
    p.fillRect(zoomIn.rect(), QColor(0, 0, 0, 150));
    p.end();
    ui->buttonZoomOut->setIcon(QIcon(zoomOut));
    ui->buttonZoomIn->setIcon(QIcon(zoomIn));

    m_noElementsLabel = new QLabel(tr("No images found"), ui->table);
    m_noElementsLabel->setMargin(10);
    m_noElementsLabel->hide();
}
Ejemplo n.º 20
0
void MainWindow::createConnections()
{
    connect(fileNewAction, SIGNAL(triggered()),
            this, SLOT(fileNew()));
    connect(fileOpenAction, SIGNAL(triggered()),
            this, SLOT(fileOpen()));
    connect(fileSaveAction, SIGNAL(triggered()),
            this, SLOT(fileSave()));
    connect(fileSaveAsAction, SIGNAL(triggered()),
            this, SLOT(fileSaveAs()));
    connect(fileExportAction, SIGNAL(triggered()),
            this, SLOT(fileExport()));
    connect(filePrintAction, SIGNAL(triggered()),
            this, SLOT(filePrint()));
    connect(fileQuitAction, SIGNAL(triggered()),
            this, SLOT(close()));
    connect(editSelectedItemAction, SIGNAL(triggered()),
            this, SLOT(editSelectedItem()));
    connect(editAddTextAction, SIGNAL(triggered()),
            this, SLOT(editAddItem()));
    connect(editAddBoxAction, SIGNAL(triggered()),
            this, SLOT(editAddItem()));
    connect(editAddSmileyAction, SIGNAL(triggered()),
            this, SLOT(editAddItem()));
    connect(editCopyAction, SIGNAL(triggered()),
            this, SLOT(editCopy()));
    connect(editCutAction, SIGNAL(triggered()),
            this, SLOT(editCut()));
    connect(editPasteAction, SIGNAL(triggered()),
            this, SLOT(editPaste()));
    connect(QApplication::clipboard(), SIGNAL(dataChanged()),
            this, SLOT(updateUi()));
    foreach (QAction *action, QList<QAction*>()
             << editAlignmentAction << editAlignLeftAction
             << editAlignRightAction << editAlignTopAction
             << editAlignBottomAction)
        connect(action, SIGNAL(triggered()), this, SLOT(editAlign()));
    connect(editClearTransformsAction, SIGNAL(triggered()),
            this, SLOT(editClearTransforms()));
    connect(scene, SIGNAL(selectionChanged()),
            this, SLOT(selectionChanged()));
    connect(viewShowGridAction, SIGNAL(toggled(bool)),
            this, SLOT(viewShowGrid(bool)));
    connect(viewZoomInAction, SIGNAL(triggered()),
            view, SLOT(zoomIn()));
    connect(viewZoomOutAction, SIGNAL(triggered()),
            view, SLOT(zoomOut()));
}
Ejemplo n.º 21
0
void cv::viz::InteractorStyle::OnChar()
{
    // Make sure we ignore the same events we handle in OnKeyDown to avoid calling things twice
    FindPokedRenderer(Interactor->GetEventPosition()[0], Interactor->GetEventPosition()[1]);
    if (Interactor->GetKeyCode() >= '0' && Interactor->GetKeyCode() <= '9')
        return;

    String key(Interactor->GetKeySym());
    if (key.find("XF86ZoomIn") != String::npos)
        zoomIn();
    else if (key.find("XF86ZoomOut") != String::npos)
        zoomOut();

    int keymod = Interactor->GetAltKey();

    switch (Interactor->GetKeyCode())
    {
    // All of the options below simply exit
    case 'h': case 'H':
    case 'l': case 'L':
    case 'p': case 'P':
    case 'j': case 'J':
    case 'c': case 'C':
    case 43:        // KEY_PLUS
    case 45:        // KEY_MINUS
    case 'f': case 'F':
    case 'g': case 'G':
    case 'o': case 'O':
    case 'u': case 'U':
    case 'q': case 'Q':
    {
        break;
    }
        // S and R have a special !ALT case
    case 'r': case 'R':
    case 's': case 'S':
    {
        if (!keymod)
            Superclass::OnChar();
        break;
    }
    default:
    {
        Superclass::OnChar();
        break;
    }
    }
}
Ejemplo n.º 22
0
void MainWindow::zoomChanged(int newValue)
{
    int res =  m_lastZoomValue - newValue;

    m_lastZoomValue = newValue;

    if(res>0)
    {
        for(int i=0; i<res; i++)
            zoomOut();
    }
    else{
        for(int i=0; i<-res; i++)
            zoomIn();
    }
}
Ejemplo n.º 23
0
int QmlJSDebugger::ZoomTool::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = AbstractLiveEditTool::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: zoomTo100(); break;
        case 1: zoomIn(); break;
        case 2: zoomOut(); break;
        default: ;
        }
        _id -= 3;
    }
    return _id;
}
Ejemplo n.º 24
0
    void LayerManager::setViewAndZoomIn(const QList<QPointF> coordinates)
    {
        while (containsAll(coordinates))
        {
            setMiddle(coordinates);
            zoomIn();
        }


        if (!containsAll(coordinates))
        {
            zoomOut();
        }

        mapcontrol->update();
    }
void ImageWidget::wheelEvent(QWheelEvent *e)
{
    if(e->modifiers() == Qt::ControlModifier && m_imageLabel->pixmap()!= NULL)
    {
        if(e->delta() > 0)
        {
            zoomIn();
        }
        else  if(e->delta() < 0 )
        {
            zoomOut();
        }
        e->accept();
    }

}
Ejemplo n.º 26
0
MapWidget::MapWidget(QWidget *parent) :
    QWidget(parent),
    m_center(55.755831, 37.617673),
    m_zoom(10),
    m_online(true),
    m_lockWheel(false)
{
    m_tiles = new TilesMap(m_center, m_zoom, m_online, this);
    connect(m_tiles, SIGNAL(updated(QRect)), SLOT(updateMap(QRect)));
    connect(m_tiles, SIGNAL(tilesLoading(int)), SIGNAL(tilesLoading(int)));
    connect(m_tiles, SIGNAL(zoomChanged(int)), SIGNAL(zoomChanged(int)));

    m_overlays = new Overlays(m_center, m_zoom, this);

    m_pointDialog = new PointDialog(this);
    connect(m_pointDialog, SIGNAL(accepted()), SLOT(pointDialogAccepted()));

    QShortcut *sc;
    sc = new QShortcut(QKeySequence("Left"), this);
    connect(sc, SIGNAL(activated()), SLOT(panLeft()));
    sc = new QShortcut(QKeySequence("Right"), this);
    connect(sc, SIGNAL(activated()), SLOT(panRight()));
    sc = new QShortcut(QKeySequence("Down"), this);
    connect(sc, SIGNAL(activated()), SLOT(panDown()));
    sc = new QShortcut(QKeySequence("Up"), this);
    connect(sc, SIGNAL(activated()), SLOT(panUp()));
    sc = new QShortcut(QKeySequence("PgUp"), this);
    connect(sc, SIGNAL(activated()), SLOT(zoomIn()));
    sc = new QShortcut(QKeySequence("PgDown"), this);
    connect(sc, SIGNAL(activated()), SLOT(zoomOut()));
    sc = new QShortcut(QKeySequence("Escape"), this);
    connect(sc, SIGNAL(activated()), SLOT(hideAll()));
    sc = new QShortcut(QKeySequence("Shift+Insert"), this);
    connect(sc, SIGNAL(activated()), SLOT(openAddPointDialog()));
    sc = new QShortcut(QKeySequence("E"), this);
    connect(sc, SIGNAL(activated()), SLOT(openEditPointDialog()));
    sc = new QShortcut(QKeySequence("Delete"), this);
    connect(sc, SIGNAL(activated()), SLOT(openDeletePointDialog()));
    sc = new QShortcut(QKeySequence("Alt+I"), this);
    connect(sc, SIGNAL(activated()), SLOT(switchOnline()));
    sc = new QShortcut(QKeySequence("Alt+O, Alt+O"), this);
    connect(sc, SIGNAL(activated()), SLOT(openInOSM()));
    sc = new QShortcut(QKeySequence("Alt+O, Alt+G"), this);
    connect(sc, SIGNAL(activated()), SLOT(openInGoogleMaps()));
    sc = new QShortcut(QKeySequence("Alt+O, Alt+Y"), this);
    connect(sc, SIGNAL(activated()), SLOT(openInYandexMaps()));
}
Ejemplo n.º 27
0
bool TreeView::eventFilter(QObject *watched, QEvent *event) {
    if (watched == treeView()->viewport()) {
        if (event->type() == QEvent::Wheel) {
            auto wheelEvent = static_cast<QWheelEvent *>(event);

            if (wheelEvent->orientation() == Qt::Vertical && wheelEvent->modifiers() & Qt::ControlModifier) {
                if (wheelEvent->delta() > 0) {
                    zoomIn(1 + wheelEvent->delta() / 360);
                } else {
                    zoomOut(1 - wheelEvent->delta() / 360);
                }
                return true;
            }
        }
    }
    return QDockWidget::eventFilter(watched, event);
}
Ejemplo n.º 28
0
void BrowserWindow::createConnections()
{
    connect(webView, SIGNAL(loadProgress(int)),
            progressBar, SLOT(setValue(int)));
    connect(webView, SIGNAL(urlChanged(const QUrl&)),
            this, SLOT(urlChange(const QUrl&)));
    connect(webView, SIGNAL(loadFinished(bool)),
            this, SLOT(loadFinish(bool)));
    connect(setUrlAction, SIGNAL(triggered()), this, SLOT(setUrl()));
    connect(historyAction, SIGNAL(triggered()),
            this, SLOT(popUpHistoryMenu()));
    connect(zoomOutAction, SIGNAL(triggered()),
            this, SLOT(zoomOut()));
    connect(zoomInAction, SIGNAL(triggered()), this, SLOT(zoomIn()));
    connect(zoomSpinBox, SIGNAL(valueChanged(int)),
            this, SLOT(setZoomFactor(int)));
}
Ejemplo n.º 29
0
void MainWindow::createActions()
{
    enterRefPointAct = new QAction(tr("Enter Reference Point"), this);
    enterRefPointAct->setShortcut(tr("Ctrl+P"));
    connect(enterRefPointAct, SIGNAL(triggered()), this, SLOT(enterRefPoint()));

    exitAct = new QAction(tr("Exit"), this);
    exitAct->setShortcut(tr("Esc, Alt+F12"));
    connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));

    normalSizeAct = new QAction(tr("&Normal Size"), this);
    normalSizeAct->setShortcut(tr("Ctrl+S"));
    normalSizeAct->setEnabled(false);
    connect(normalSizeAct, SIGNAL(triggered()), this, SLOT(normalSize()));

    openAct = new QAction(tr("&Open..."), this);
    openAct->setShortcut(tr("Ctrl+O"));
    connect(openAct, SIGNAL(triggered()), this, SLOT(open()));

    saveTransfImgAct = new QAction(tr("Save Transformed Image"), this);
    saveTransfImgAct->setShortcut(tr("Ctrl+S"));
    saveTransfImgAct->setEnabled(false);
    connect(saveTransfImgAct, SIGNAL(triggered()), this, SLOT(saveTransfImg()));

    showMatrixAct = new QAction(tr("Show Matrix"), this);
    showMatrixAct->setShortcut(tr("Ctrl+M"));
    connect(showMatrixAct, SIGNAL(triggered()), this, SLOT(showMatrix()));

    transformAct = new QAction(tr("&Tranform"), this);
    transformAct->setShortcut(tr("Ctrl+T"));
    connect(transformAct, SIGNAL(triggered()), this, SLOT(transform()));

    testMatrixAct = new QAction(tr("Set Test Matrix"), this);
    testMatrixAct->setShortcut(tr("Ctrl+E"));
    connect(testMatrixAct, SIGNAL(triggered()), this, SLOT(setTestMatrix()));

    zoomInAct = new QAction(tr("Zoom &In (25%)"), this);
    zoomInAct->setShortcut(tr("Ctrl++"));
    zoomInAct->setEnabled(false);
    connect(zoomInAct, SIGNAL(triggered()), this, SLOT(zoomIn()));

    zoomOutAct = new QAction(tr("Zoom &Out (25%)"), this);
    zoomOutAct->setShortcut(tr("Ctrl+-"));
    zoomOutAct->setEnabled(false);
    connect(zoomOutAct, SIGNAL(triggered()), this, SLOT(zoomOut()));
}
Ejemplo n.º 30
0
void QtRenderer::ConnectPlugin( UpWindSceneInterface* scene, QWidget* frame, CoreChartProvider* model ){
    CoreViewRenderer::ConnectPlugin(scene, frame, model);
    QGraphicsScene *graphicsScene = new QGraphicsScene;
    QRectF chartBoundaries = model->getChartBoundaries();
    n_chartGraphicsObject = new ChartGraphicsObject(frame->size());
    routeWidget = new RouteWidget(frame->size(),scene,chartBoundaries);
    boatWidget = new BoatWidget(frame->size(), scene, chartBoundaries);

    // Make sure the view gets mouse events for dragging
    n_chartGraphicsObject->setAcceptedMouseButtons(Qt::NoButton);
    // Set routepoints with right mouse buttons
    routeWidget->setAcceptedMouseButtons(Qt::RightButton);

    graphicsScene->addItem(n_chartGraphicsObject);
    graphicsScene->addItem(routeWidget);

    Boat *boat = new Boat(frame->size(), chartBoundaries);
    scene->setBoat(boat);

    graphicsScene->addItem(scene->getBoat()->getBoatImage());    // put boat image on screen.
    graphicsScene->addItem(scene->getBoat()->getBoatCompass());
    //graphicsScene->addItem(scene->getBoat()->getBoatGPS());
    graphicsScene->addItem(scene->getBoat()->getPortLayline());
    graphicsScene->addItem(scene->getBoat()->getStarBoardLayline());

    connect(scene->getBoat(), SIGNAL(boatPositionChanged()), this, SLOT(handleBoatPositionChanged()));

    boatWidget->setBoat(scene->getBoat());
    boatWidget->updateBoatPosition();

    view = new ChartView(graphicsScene, frame);
    connect(view, SIGNAL(wheelUp()), this, SLOT(zoomOut()));
    connect(view, SIGNAL(wheelDown()), this, SLOT(zoomIn()));
    view->setResizeAnchor(QGraphicsView::AnchorViewCenter);

    view->setGeometry(0, 0, frame->size().width(), frame->size().height());
    n_chartGraphicsObject->setModel(model);
    view->lower();
    view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    view->setDragMode(QGraphicsView::ScrollHandDrag);
    view->setInteractive(true);
    view->setScene(graphicsScene);

    QPixmapCache::setCacheLimit(1024 * 320);
}