Ejemplo n.º 1
0
void OsmAndMapView::moveTo(float dx, float dy) {
    float fy = calcDiffTileY(dx, dy);
    float fx = calcDiffTileX(dx, dy);
    this->latitude = OsmAnd::Utilities::getLatitudeFromTile(getZoom(), getYTile() + fy);
    this->longitude = OsmAnd::Utilities::getLongitudeFromTile(getZoom(), getXTile() + fx);
    updateLayersViewport();
}
QPixmap SplicePicturesImageItem::getTransformedPixmap(TransformFlag flag) {
    QMatrix matrix;
    int flagint = (int)flag;
    if (flagint & TRANS_SCALE) matrix.scale((double)getZoom(), (double)getZoom());
    if (flagint & TRANS_ROTATE) matrix.rotate((double)getRotation());
//    if (flagint & TRANS_MOVE) matrix.translate(getX(), getY());
    return getPixmap()->transformed(matrix);
}
Ejemplo n.º 3
0
void MapView::setZoom(double value, QPointF center)
{
	auto pos = this->center();
	auto zoom_pos = viewToMap(center);
	auto old_zoom = getZoom();
	
	setZoom(value);
	
	if (!qFuzzyCompare(old_zoom, getZoom()))
	{
		auto zoom_factor = getZoom() / old_zoom ;
		setCenter(zoom_pos + (pos - zoom_pos) / zoom_factor);
	}
}
void NSRPopplerDocument::renderPage(int page)
{
	double dpix, dpiy;

	if (_doc == NULL || page > getNumberOfPages() || page < 1)
		return;

	_page = _catalog->getPage(page);

	if (isTextOnly()) {
		PDFRectangle	*rect;
		GooString	*text;
		TextOutputDev	*dev;

		dev = new TextOutputDev (0, gFalse, gFalse, gFalse);

		_doc->displayPageSlice(dev, _page->getNum(), 72, 72, 0, gFalse, gTrue, gFalse, -1, -1, -1, -1);

		rect = _page->getCropBox();
		text = dev->getText(rect->x1, rect->y1, rect->x2, rect->y2);
		_text = processText(QString::fromUtf8(text->getCString()));

		delete text;
		delete dev;
		_readyForLoad = true;

		return;
	}

	if (isZoomToWidth()) {
		double wZoom = ((double) getScreenWidth() / (double) _page->getCropWidth() * 100.0);
		setZoomSilent((int) wZoom);
	}

	if (getZoom() > getMaxZoom())
		setZoomSilent (getMaxZoom());
	else if (getZoom() < getMinZoom())
		setZoomSilent (getMinZoom());

	if (_readyForLoad)
		_dev->startPage(0, NULL);

	dpix = _dpix * getZoom() / 100.0;
	dpiy = _dpiy * getZoom() / 100.0;

	_page->display(_dev, dpix, dpiy, getRotation(), gFalse, gFalse, gTrue, _catalog);

	_readyForLoad = true;
}
Ejemplo n.º 5
0
WindowHistoryInformation QtWebKitWebWidget::getHistory() const
{
	QVariantHash data;
	data[QLatin1String("position")] = m_webView->page()->mainFrame()->scrollPosition();
	data[QLatin1String("zoom")] = getZoom();

	m_webView->history()->currentItem().setUserData(data);

	QWebHistory *history = m_webView->history();
	WindowHistoryInformation information;
	information.index = history->currentItemIndex();

	for (int i = 0; i < history->count(); ++i)
	{
		const QWebHistoryItem item = history->itemAt(i);
		WindowHistoryEntry entry;
		entry.url = item.url().toString();
		entry.title = item.title();
		entry.position = item.userData().toHash().value(QLatin1String("position"), QPoint(0, 0)).toPoint();
		entry.zoom = item.userData().toHash().value(QLatin1String("zoom")).toInt();

		information.entries.append(entry);
	}

	return information;
}
Ejemplo n.º 6
0
ofxVec2f FboMaskManager::mouseVec(float mouseX, float mouseY){
	ofxVec2f mouse;
	float zoom = getZoom();
	mouse.x = (mouseX/zoom + displayCoords.x);
	mouse.y = (mouseY/zoom + displayCoords.y);
	return mouse;
}
Ejemplo n.º 7
0
void setZoom(float _z, float _duration, EaseType _e) {

    float z_start = getZoom();
    auto cb = [=](float t) { setZoomNow(ease(z_start, _z, t, _e)); };
    setEase(EaseField::zoom, { _duration, cb });

}
Ejemplo n.º 8
0
void NodeGraphDisplay::onScroll(APoint m_pos, Vec2f d_scroll)
{
	RVec a_zoom = getZoom();
	AVec mult = AVec(1.0f, 1.0f) - ZOOM_STEP*(d_scroll.x + d_scroll.y);
	setZoom(RVec(a_zoom.x*mult.x, a_zoom.y*mult.y));
	//moveZoom(-ZOOM_STEP*(d_scroll.x + d_scroll.y));
}
Ejemplo n.º 9
0
void Map::processQueue()
{
	if (_queue.size() > (_maxPending - _pending.size()))
    {
        std::sort(_queue.begin(),
                  _queue.end(),
                  QueueSorter(getTileCoordinateCenter().zoomTo(getZoom())));
	}

    // Transfer load queued coordinates.
    while (_pending.size() < _maxPending && !_queue.empty())
    {
		const TileCoordinate& coord = *(_queue.begin());

        std::vector<std::string> urls = _provider->getTileUrls(coord);

        if (!urls.empty())
        {
            _pending[coord] = ofLoadURLAsync(urls[0]);
        }
        else
        {

        }

		_queue.erase(_queue.begin());
	}  
}
Ejemplo n.º 10
0
void ccRenderToFileDlg::updateInfo()
{
    s_zoom = getZoom();

    unsigned w2 = (unsigned)(double(w)*s_zoom);
    unsigned h2 = (unsigned)(double(h)*s_zoom);

    finalSizeLabel->setText(QString("(%1 x %2)").arg(w2).arg(h2));
}
Ejemplo n.º 11
0
int ZDvidDataSliceHelper::getLowresZoom() const
{
  int zoom = getZoom() + 1;
  if (zoom > getMaxZoom()) {
    zoom -= 1;
  }

  return zoom;
}
Ejemplo n.º 12
0
void QtWebKitWebWidget::setZoom(int zoom)
{
	if (zoom != getZoom())
	{
		m_webView->setZoomFactor(qBound(0.1, ((qreal) zoom / 100), (qreal) 100));

		emit zoomChanged(zoom);
	}
}
Ejemplo n.º 13
0
PointI OsmAndMapView::getPixelPoint(int32_t x31, int32_t y31) const{
    int cx = getCenterPointX();
    int cy = getCenterPointY();
    auto pw = OsmAnd::Utilities::getPowZoom(31 - getZoom());
    float diffxTile = x31 / pw - getXTile();
    float diffyTile = y31 / pw - getYTile();
    int newX = (int) (calcDiffPixelX(diffxTile, diffyTile) + cx);
    int newY = (int) (calcDiffPixelY(diffxTile, diffyTile) + cy);
    return PointI(newX, newY);
}
Ejemplo n.º 14
0
int caCamera::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    
#ifndef QT_NO_PROPERTIES
     if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QString*>(_v) = getPV_Data(); break;
        case 1: *reinterpret_cast< QString*>(_v) = getPV_Width(); break;
        case 2: *reinterpret_cast< QString*>(_v) = getPV_Height(); break;
        case 3: *reinterpret_cast< QString*>(_v) = getPV_Code(); break;
        case 4: *reinterpret_cast< QString*>(_v) = getPV_BPP(); break;
        case 5: *reinterpret_cast< zoom*>(_v) = getZoom(); break;
        case 6: *reinterpret_cast< colormap*>(_v) = getColormap(); break;
        case 7: *reinterpret_cast< bool*>(_v) = getInitialAutomatic(); break;
        case 8: *reinterpret_cast< QString*>(_v) = getMinLevel(); break;
        case 9: *reinterpret_cast< QString*>(_v) = getMaxLevel(); break;
        case 10: *reinterpret_cast< QString*>(_v) = getDataProcChannels(); break;
        }
        _id -= 11;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setPV_Data(*reinterpret_cast< QString*>(_v)); break;
        case 1: setPV_Width(*reinterpret_cast< QString*>(_v)); break;
        case 2: setPV_Height(*reinterpret_cast< QString*>(_v)); break;
        case 3: setPV_Code(*reinterpret_cast< QString*>(_v)); break;
        case 4: setPV_BPP(*reinterpret_cast< QString*>(_v)); break;
        case 5: setZoom(*reinterpret_cast< zoom*>(_v)); break;
        case 6: setColormap(*reinterpret_cast< colormap*>(_v)); break;
        case 7: setInitialAutomatic(*reinterpret_cast< bool*>(_v)); break;
        case 8: setMinLevel(*reinterpret_cast< QString*>(_v)); break;
        case 9: setMaxLevel(*reinterpret_cast< QString*>(_v)); break;
        case 10: setDataProcChannels(*reinterpret_cast< QString*>(_v)); break;
        }
        _id -= 11;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 11;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 11;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 11;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 11;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 11;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 11;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Ejemplo n.º 15
0
void Viewport::drawMaps(QPainter *painter) {

	if(!this->isVisible() || !this->isEnabled()) return; // Don't bother drawing if not visible...

	// Calculate zoom and other commonly used values
	double zoom = getZoom();
	double rzoom = 1.0 / zoom; // the reversed zoom
	double scrollX = (double)scrollHorizontal->value() / (double)(scrollHorizontal->maximum());
	double scrollY = (double)scrollVertical->value() / (double)(scrollVertical->maximum());

	// Init painting region
	this->view.setX((int)( (maxMapWidth-view.width()) * scrollX ));
	this->view.setY((int)( maxMapHeight-view.height() - ((maxMapHeight-view.height()) * scrollY) ));
	this->view.setWidth((int)( canvas->width() * rzoom ));
	this->view.setHeight((int)( canvas->height() * rzoom));

	// Init painter and background
	painter->setRenderHint(QPainter::Antialiasing, antiAlias);
	painter->fillRect(0, 0, canvas->width(), canvas->height(), Qt::black);

	// Set the clipping region
	painter->setClipRect(0,0,canvas->width(),canvas->height());

	// Draw all maps :)

	lock.lockForRead(); {

		for(int i = 0; i < this->maps->count(); i++) {
			// Paint the map. Note: Map is responsible for painting it's objects
			if(mapMetas->at(i)->show == true) {

				// Reset the painter, so that we have a clean one for each map
				Util::resetPainter(*painter);

				// Do transform for zoom, if not 1.0
				if(zoom != 1.0) {
					QTransform t;
					t.scale(zoom,zoom);
					painter->setWorldTransform(t);
				}

				// Paint the actual map
				maps->at(i)->paint(*painter, this->view);

			}
		}

	} lock.unlock();

	// Make disabled effect
	if(this->isEnabled() == false) {
		painter->setOpacity(0.5);
		painter->fillRect(0, 0, canvas->width(), canvas->height(), Qt::white);
	}
}
Ejemplo n.º 16
0
WebWidget* QtWebKitWebWidget::clone(ContentsWidget *parent)
{
	QtWebKitWebWidget *widget = new QtWebKitWebWidget(isPrivate(), parent);
	widget->setDefaultTextEncoding(getDefaultTextEncoding());
	widget->setQuickSearchEngine(m_searchEngine);
	widget->setUrl(getUrl());
	widget->setHistory(getHistory());
	widget->setZoom(getZoom());

	return widget;
}
Ejemplo n.º 17
0
void QtWebKitWebWidget::saveState(QWebFrame *frame, QWebHistoryItem *item)
{
	if (frame == m_webView->page()->mainFrame())
	{
		QVariantHash data;
		data[QLatin1String("position")] = m_webView->page()->mainFrame()->scrollPosition();
		data[QLatin1String("zoom")] = getZoom();

		item->setUserData(data);
	}
}
Ejemplo n.º 18
0
void Map::keyPressed(ofKeyEventArgs& evt)
{
    int key = evt.key;

	if (key == '+' || key == '=')
    {
		if (getZoom() < 19)
        {
			zoomIn();
		}
	}
	else if (key == '-' || key == '_')
    {
		if (getZoom() > 1)
        {
			zoomOut();
		}
	}
	// TODO: keyboard movement
}
Ejemplo n.º 19
0
float TransformState::maxPitchScaleFactor() const {
    if (size.isEmpty()) {
        return {};
    }
    auto latLng = screenCoordinateToLatLng({ 0, static_cast<float>(getSize().height) });
    mat4 mat = coordinatePointMatrix(getZoom());
    Point<double> pt = Projection::project(latLng, scale) / util::tileSize;
    vec4 p = {{ pt.x, pt.y, 0, 1 }};
    vec4 topPoint;
    matrix::transformMat4(topPoint, p, mat);
    return topPoint[3] / getCameraToCenterDistance();
}
Ejemplo n.º 20
0
ScreenCoordinate TransformState::latLngToScreenCoordinate(const LatLng& latLng) const {
    if (size.isEmpty()) {
        return {};
    }

    mat4 mat = coordinatePointMatrix(getZoom());
    vec4 p;
    Point<double> pt = Projection::project(latLng, scale) / util::tileSize;
    vec4 c = {{ pt.x, pt.y, 0, 1 }};
    matrix::transformMat4(p, c, mat);
    return { p[0] / p[3], size.height - p[1] / p[3] };
}
Ejemplo n.º 21
0
void SourceViewerWidget::wheelEvent(QWheelEvent *event)
{
	if (event->modifiers().testFlag(Qt::ControlModifier))
	{
		setZoom(getZoom() + (event->delta() / 16));

		event->accept();

		return;
	}

	QPlainTextEdit::wheelEvent(event);
}
Ejemplo n.º 22
0
void GameRunningState::render(yam2d::ESContext *context)
{
    // Set OpenGL clear color
    glClearColor(1.0f, 0.0f, 1.0f, 1.0f);

    // Clear the color buffer
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    //Set screen size to camera
    m_tmap->getCamera()->setScreenSize(context->width, context->height, 400 / getZoom());

    m_tmap->render();
}
Ejemplo n.º 23
0
void BackendGoogleMaps::centerOn( const Marble::GeoDataLatLonBox& latLonBox, const bool useSaneZoomLevel)
{
    /// @todo Buffer this call if there is no widget or if inactive!
    if (!d->htmlWidget)
    {
        return;
    }

    const qreal boxWest  = latLonBox.west(Marble::GeoDataCoordinates::Degree);
    const qreal boxNorth = latLonBox.north(Marble::GeoDataCoordinates::Degree);
    const qreal boxEast  = latLonBox.east(Marble::GeoDataCoordinates::Degree);
    const qreal boxSouth = latLonBox.south(Marble::GeoDataCoordinates::Degree);

    d->htmlWidget->centerOn(boxWest, boxNorth, boxEast, boxSouth, useSaneZoomLevel);
    kDebug()<<getZoom();
}
Ejemplo n.º 24
0
void MapView::zoomSteps(float num_steps, bool preserve_cursor_pos, QPointF cursor_pos_view)
{
	auto zoom_to = getZoom() * pow(sqrt(2.0), num_steps);
	
	if (preserve_cursor_pos)
	{
		setZoom(zoom_to, cursor_pos_view);
	}
	else
	{
		setZoom(zoom_to);
		
		auto mouse_pos_map = viewToMapF(cursor_pos_view);
		for (auto widget : widgets)
			widget->updateCursorposLabel(mouse_pos_map);
	}
}
Ejemplo n.º 25
0
CameraOptions TransformState::getCameraOptions(const EdgeInsets& padding) const {
    CameraOptions camera;

    if (padding.isFlush()) {
        camera.center = getLatLng();
    } else {
        ScreenCoordinate point = padding.getCenter(size.width, size.height);
        point.y = size.height - point.y;
        camera.center = screenCoordinateToLatLng(point).wrapped();
    }
    camera.padding = padding;
    camera.zoom = getZoom();
    camera.angle = -angle * util::RAD2DEG;
    camera.pitch = pitch * util::RAD2DEG;

    return camera;
}
Ejemplo n.º 26
0
bool GameRunningState::update(yam2d::ESContext *context, float deltaTime)
{
   //Set zoom via mouse wheel
    setZoom(getZoom() - yam2d::getMouseWheelDelta());
    //std::string name;

    yam2d::vec2 pos = player->getPosition();

    // -------------- COLLISIONS -------- START
    //Collision with player
    if (ball->collidesTo(player))
    {
        ball->getComponent<BallController>()->handleCollision(player);
    }
    //Collision with static colliders "Walls"
    for (int i = 0; i < walls.size(); ++i)
    {
        if (ball->collidesTo(walls.at(i)))
        {
            ball->getComponent<BallController>()->handleCollision(walls.at(i));
        }
    }
    //Brick collisions
    for (int i = 0; i < bricks.size(); ++i)
    {
        if (ball->collidesTo(bricks.at(i)))
        {
            ball->getComponent<BallController>()->handleCollision(bricks.at(i));
        }
    }
    // -------------- COLLISIONS -------- END


    if (yam2d::getKeyState(yam2d::KEY_ESCAPE) == 1)
    {
        getApp()->setState(new MainMenuState(getApp()));
        return true;
    }


    m_tmap->update(deltaTime);
    return true;   
}
Ejemplo n.º 27
0
void FboMaskManager::draw(){
	if(editing && drawEditOverlay){
		
		if(worldFbo != NULL){
			glPushMatrix();
			float zoom = getZoom();
			glScalef(zoom, zoom, zoom);
			glTranslatef(-displayCoords.x, -displayCoords.y, 0);
			
			ofSetColor(255, 255, 255);
			worldFbo->draw(0, 0);
			
			drawEditShapes();
			
			glPopMatrix();
		}
		drawToWorld();
	}
	//maskImage.draw(0, 0);
}
Ejemplo n.º 28
0
std::forward_list<mbgl::Tile::ID> Source::covering_tiles(const TransformState &state, int32_t clamped_zoom, const box& points) {
    int32_t dim = std::pow(2, clamped_zoom);
    std::forward_list<mbgl::Tile::ID> tiles;
    bool is_raster = (info.type == SourceType::Raster);
    double search_zoom = getZoom(state);

    auto scanLine = [&tiles, clamped_zoom, is_raster, search_zoom](int32_t x0, int32_t x1, int32_t y, int32_t ymax) {
        int32_t x;
        if (y >= 0 && y <= ymax) {
            for (x = x0; x < x1; x++) {
                if (is_raster) {
                    Tile::ID id = Tile::ID(clamped_zoom, x, y);
                    auto ids = id.children(search_zoom);
                    for (const Tile::ID& child_id : ids) {
                        tiles.emplace_front(child_id.z, child_id.x, child_id.y);
                    }
                } else {
                    tiles.emplace_front(clamped_zoom, x, y);
                }
            }
        }
    };

    // Divide the screen up in two triangles and scan each of them:
    // \---+
    // | \ |
    // +---\.
    _scanTriangle(points.tl, points.tr, points.br, 0, dim, scanLine);
    _scanTriangle(points.br, points.bl, points.tl, 0, dim, scanLine);

    const vec2<double>& center = points.center;
    tiles.sort([&center](const Tile::ID& a, const Tile::ID& b) {
        // Sorts by distance from the box center
        return std::fabs(a.x - center.x) + std::fabs(a.y - center.y) <
        std::fabs(b.x - center.x) + std::fabs(b.y - center.y);
    });

    tiles.unique();

    return tiles;
}
Ejemplo n.º 29
0
void Viewport::canvasClicked(QMouseEvent *event)
{
	// Get the actual point clicked
	double rzoom = 1.0/getZoom();
	long x = (long)((double)(event->x()*rzoom)) + view.x();
	long y = view.height() - (long)((double)(event->y()*rzoom)) + view.y();

	// Go through all actions, checking if we have some pressed so we can
	// process it on the point clicked...
	QList<QAction*> actions = toolbar->actions();
	for(int i = 0; i < actions.count(); i++) {
		if(actions.at(i)->isChecked() == true) {
			// Check if we need to emit a signal or process it now
			if(actions.at(i)->data().toString().replace("[instant]","") == "focusviewport") {
				focusOnPoint(x*scale,y*scale);
			} else {
				emit toolbarAction(this, actions.at(i)->data().toString().replace("[instant]",""), x, y);
			}
		}
	}
}
Ejemplo n.º 30
0
void XournalView::zoomChanged(double lastZoom)
{
	XOJ_CHECK_TYPE(XournalView);

	Layout* layout = gtk_xournal_get_layout(this->widget);
	int currentPage = this->getCurrentPage();
	//double pageTop = layout->getVisiblePageTop(currentPage);
	double pageTop = 0.0;

	layout->layoutPages();

	this->scrollTo(currentPage, pageTop);

	Document* doc = control->getDocument();
	doc->lock();
	path file = doc->getEvMetadataFilename();
	doc->unlock();

	control->getMetadataManager()->setDouble(file, "zoom", getZoom());

	this->control->getScheduler()->blockRerenderZoom();
}