Пример #1
0
void SearchWidget::setMarbleWidget( MarbleWidget* widget )
{
    if ( d->m_widget ) {
        return;
    }

    d->m_widget = widget;

    d->m_searchField->setCompletionModel( widget->model()->placemarkModel() );
    connect( d->m_searchField, SIGNAL(centerOn(GeoDataCoordinates)),
             widget, SLOT(centerOn(GeoDataCoordinates)) );

    d->m_runnerManager = new MarbleRunnerManager( widget->model()->pluginManager(), this );
    d->m_runnerManager->setModel( widget->model() );
    connect( d->m_runnerManager, SIGNAL(searchResultChanged(QVector<GeoDataPlacemark*>)),
             this,               SLOT(setSearchResult(QVector<GeoDataPlacemark*>)) );
    connect( d->m_runnerManager, SIGNAL(searchFinished(QString)),
             d->m_searchField,   SLOT(disableSearchAnimation()));

    GeoDataTreeModel* treeModel = d->m_widget->model()->treeModel();
    treeModel->addDocument( d->m_document );

    d->m_branchfilter.setSourceModel( treeModel );
    d->m_branchfilter.setBranchIndex( treeModel, treeModel->index( d->m_document ) );

    d->m_searchResultView->setRootIndex(
                d->m_sortproxy.mapFromSource(
                    d->m_branchfilter.mapFromSource( treeModel->index( d->m_document ) ) ) );
}
Пример #2
0
void PathView::zoom(int z, const QPoint &pos)
{
	if (_tracks.isEmpty() && _routes.isEmpty() && _waypoints.isEmpty())
		return;

	QPoint offset = pos - viewport()->rect().center();
	QPointF spos = mapToScene(pos);

	qreal os = mapScale(_zoom);
	_zoom = z;

	rescale(_zoom);

	QRectF sr = contentsSceneRect();
	_scene->setSceneRect(sr);

	if (sr.width() < viewport()->size().width()
	  && sr.height() < viewport()->size().height())
		centerOn(sr.center());
	else
		centerOn((spos * (os/mapScale(_zoom))) - offset);

	_mapScale->setZoom(_zoom);

	resetCachedContent();
}
Пример #3
0
void AutoNavigation::Private::moveOnBorderToCenter( const GeoDataCoordinates &position, qreal )
{
    qreal x = 0.0;
    qreal y = 0.0;
    //recenter if initially the gps location is not visible on the screen
    if(!( m_viewport->screenCoordinates( position, x, y ) ) ) {
        centerOn( position );
    }
    qreal centerLon = m_viewport->centerLongitude();
    qreal centerLat = m_viewport->centerLatitude();

    qreal centerX = 0.0;
    qreal centerY = 0.0;

    m_viewport->screenCoordinates( centerLon, centerLat, centerX, centerY );

    const qreal borderRatio = 0.25;
    //defining the default border distance from map center
    int shiftX = qRound( centerX * borderRatio );
    int shiftY = qRound( centerY * borderRatio );

    QRect recenterBorderBound;
    recenterBorderBound.setCoords( centerX-shiftX, centerY-shiftY, centerX+shiftX,  centerY+shiftY );

    if( !recenterBorderBound.contains( x,y ) ) {
        centerOn( position );
    }
}
Пример #4
0
void MapView::centerMapOnPath(QGraphicsPathItem *path)
{
    if (path == 0) {qDebug("cMoP: path is null!"); return; }

    QRect view = QRect(0,0,width(),height());
    QPoint center = view.center();
    QRect nextView = view;
    nextView.setSize(view.size()/2);
    nextView.moveCenter(center);

    QRectF pathBoundingRect = path->boundingRect();

    //if the item has no path data, abort
    if(pathBoundingRect.width() == 0.0)
    {
        qDebug("This item has no valid path");
        return;
    }

    centerOn(path);
    if (mapToScene(view).boundingRect().contains(pathBoundingRect))
    {
        centerOn(path);
        while (mapToScene(nextView).boundingRect().contains(pathBoundingRect)) {zoom(1);}
    } else {
        while (!mapToScene(view).boundingRect().contains(pathBoundingRect)) {zoom(-1);}
    }
}
Пример #5
0
void SerialTrack::append(PlaybackItem* item)
{
    connect( item, SIGNAL( progressChanged( double ) ), this, SLOT( changeProgress( double ) ) );
    connect( item, SIGNAL( centerOn( GeoDataCoordinates ) ), this, SIGNAL( centerOn( GeoDataCoordinates ) ) );
    connect( item, SIGNAL( finished() ), this, SLOT( handleFinishedItem() ) ) ;
    connect( item, SIGNAL( paused() ), this, SLOT( pause() ) ) ;
    m_items.append( item );
    if( m_items.size() == 1 ) {
        PlaybackFlyToItem *flyTo = dynamic_cast<PlaybackFlyToItem*>( item );
        if( flyTo != 0 ) {
            flyTo->setFirst( true )
;        }
    }
}
Пример #6
0
void GraphicsView::wheelEvent(QWheelEvent *event)
{
	if(event->modifiers().testFlag(Qt::ControlModifier))
	{
		const int numSteps = event->delta() / 15 / 8;
		if (numSteps == 0)
		{
			event->ignore();
			return;
		}

		const qreal factor = pow(ZOOM_FACTOR, numSteps);
		if((zoomCount > ZOOM_LIMIT && factor > 1) || (zoomCount == 0 && factor < 1))
			return;

		if(factor > 1)
			zoomCount += 1;
		else
			zoomCount -= 1;

		scale(factor, factor);
		centerOn(mapToScene(event->pos()));
	}
	else
		QGraphicsView::wheelEvent(event);
}
Пример #7
0
void SchematicSceneViewer::normalizeScene()
{

#if QT_VERSION >= 0x050000
	bool beforeIsLarge = (matrix().determinant() >= 1.0);
#else
	bool beforeIsLarge = (matrix().det() >= 1.0);
#endif
	//See QGraphicsView::mapToScene()'s doc for details
	QRect rect(0, 0, width(), height());
	QRectF sceneCenterRect(mapToScene(QRect(rect.center(), QSize(2, 2))).boundingRect());
	resetMatrix();
#if defined(MACOSX)
	scale(1.32, 1.32);
#endif
	centerOn(sceneCenterRect.center());

#if QT_VERSION >= 0x050000
	bool afterIsLarge = (matrix().determinant() >= 1.0);
#else
	bool afterIsLarge = (matrix().det() >= 1.0);
#endif
	if (beforeIsLarge != afterIsLarge) {
		FxSchematicScene *fxScene = qobject_cast<FxSchematicScene *>(scene());
		if (fxScene)
			fxScene->updateScene();
	}
}
Пример #8
0
void SchematicSceneViewer::centerOnCurrent()
{
	SchematicScene *schematicScene = dynamic_cast<SchematicScene *>(scene());
	QGraphicsItem *node = schematicScene->getCurrentNode();
	if (node)
		centerOn(node);
}
Пример #9
0
void SchematicSceneViewer::zoomQt(bool zoomin, bool resetZoom)
{
#if QT_VERSION >= 0x050000
	double scale2 = matrix().determinant();
#else
	double scale2 = matrix().det();
#endif

	// if the zoom scale is changed over 100% in FxSchematic, call updateScene
	bool beforeIsLarge = (scale2 >= 1.0);

	if (resetZoom || ((scale2 < 100000 || !zoomin) && (scale2 > 0.001 * 0.05 || zoomin))) {
		double oldZoomScale = sqrt(scale2);
		double zoomScale = resetZoom ? 1 : ImageUtils::getQuantizedZoomFactor(oldZoomScale, zoomin);
		QMatrix scale = QMatrix().scale(zoomScale / oldZoomScale, zoomScale / oldZoomScale);

		//See QGraphicsView::mapToScene()'s doc for details
		QRect rect(0, 0, width(), height());
		QRectF sceneCenterRect(mapToScene(QRect(rect.center(), QSize(2, 2))).boundingRect());
		setMatrix(scale, true);
		centerOn(sceneCenterRect.center());

#if QT_VERSION >= 0x050000
		bool afterIsLarge = (matrix().determinant() >= 1.0);
#else
		bool afterIsLarge = (matrix().det() >= 1.0);
#endif
		if (beforeIsLarge != afterIsLarge) {
			FxSchematicScene *fxScene = qobject_cast<FxSchematicScene *>(scene());
			if (fxScene)
				fxScene->updateScene();
		}
	}
}
Пример #10
0
//!
//! Resets the network graphics view's matrix.
//!
void BaseGraphicsView::homeView ()
{
    setScale(1);

    QRectF boundingRect = scene()->itemsBoundingRect();
    centerOn(boundingRect.left() + boundingRect.width() / 2, boundingRect.top() + boundingRect.height() / 2);
}
Пример #11
0
void
Panned::slotSetPannedRect(QRectF pr)
{
    centerOn(pr.center());
//	setSceneRect(pr);
//	m_pannedRect = pr;
}
Пример #12
0
void SmViewPanel::mouseMoveEvent(QMouseEvent *event)
{

    if (is_left_mouse_pressed_ && (sm_gadget_==smgis::ZoomIn ||sm_gadget_==smgis::ZoomOut))
    {
        is_mouse_dragged_=true;
        mouse_current_point_= event->pos();
        mouse_max_dragged_point_.setX((mouse_max_dragged_point_.x() > mouse_current_point_.x())?
                    mouse_max_dragged_point_.x():mouse_current_point_.x());
        mouse_max_dragged_point_.setY((mouse_max_dragged_point_.y() > mouse_current_point_.y())?
                    mouse_max_dragged_point_.y():mouse_current_point_.y());
        this->viewport()->update();
    }

        if(sm_gadget_==smgis::Pan)
        {
            mouse_current_point_=event->pos();
            QPoint delta_x=mouse_current_point_-mouse_press_point_;
            view_center_point_=view_center_point_-delta_x;
            centerOn(mapToScene( view_center_point_) );
            mouse_press_point_=mouse_current_point_;
            view_center_point_=this->viewport()->rect().center();
        }
     QGraphicsView::mouseMoveEvent(event);
}
Пример #13
0
void SmViewPanel::mouseReleaseEvent ( QMouseEvent * event )
{

        is_left_mouse_pressed_=false;
    if ((sm_gadget_==smgis::ZoomIn ||sm_gadget_==smgis::ZoomOut) && is_mouse_dragged_)
    {
        mouse_current_point_=event->pos();

        QRect zoom_extent(mouse_press_point_,mouse_current_point_);
        QPointF first_point=mapToScene(zoom_extent.center());
        double scale_rate=(zoom_extent.width()>zoom_extent.height())?zoom_extent.width():
                          zoom_extent.height();
        double darsad=viewport()->width()>viewport()->height()?viewport()->height():
                          viewport()->width();
        if (sm_gadget_==smgis::ZoomIn)
            scale(qAbs(darsad/scale_rate),qAbs(darsad/scale_rate));
        if(sm_gadget_==smgis::ZoomOut)
            scale(qAbs(scale_rate/darsad),qAbs(scale_rate/darsad));
//        QPointF second_point=mapToScene(zoom_extent.center());
//        std::cout<<first_point.x()<<","<<first_point.y()
//                <<"-------"<<second_point.x()<<","<<second_point.y()<<std::endl;
        centerOn(first_point);
        is_mouse_dragged_=false;
    }

    else if (sm_gadget_==smgis::FullExtent)
    {
        sm_gadget_=smgis::Cursor;

        return;
    }
    else if (sm_gadget_==smgis::Cursor)
    {
        QPointF cl=mapToScene(event->pos());

        temp_item_=(SmGeoItem*)scene_handle_->itemAt(cl);
       if (temp_item_)
       {
       this->viewport()->update();
       }
        return;
    }
    else if (sm_gadget_==smgis::Pan)
    {
        this->setCursor(Qt::OpenHandCursor);
        mouse_press_point_=QPoint();
    }
    else if (sm_gadget_==smgis::Identify)
    {
        QPointF cl=mapToScene(event->pos());
        temp_item_=(SmGeoItem*)scene_handle_->itemAt(cl);
        if (temp_item_)
        {
            identify_table_->execute(temp_item_->get_item_id_());
            this->viewport()->update();
        }
    }

     QGraphicsView::mouseReleaseEvent(event);
}
Пример #14
0
void GraphView::moveTo(const QModelIndex &index)
{
    QTableView *view = qobject_cast<QTableView *>(QObject::sender());
    GraphTableProxyModel *tableProxy = static_cast<GraphTableProxyModel *>(view->model());
    if (tableProxy == NULL)
    {
        qDebug() << "[GraphView]: can't cast sender of signal";
        return;
    }
    QVariant var = tableProxy->data(QModelIndex(), objectIdListRole);
    mapIntToInt idMap = qvariant_cast<mapIntToInt>(var);
    foreach(int id, idMap)
    {
        qDebug() << "[GraphView]: (table, model):(" << id << "," << idMap[id] << ")";
    }

    int modelRow = idMap.value(index.row(), -1);
    ObjectVisual *obj = scene()->getObjectById(modelRow);
    if (obj != NULL)
    {
        qDebug() << "[GraphView]: moving to #" << modelRow <<
                    "(tabled as#" << index.row() << ")=" << obj;
        centerOn(obj);
    }
}
Пример #15
0
Palapeli::PieceHolder::PieceHolder(QWidget* parent, const QSizeF& pieceArea,
					const QString& title)
	: m_scene(scene())
{
	qDebug() << "CONSTRUCTING Palapeli::PieceHolder" << title;
	setParent(parent);
	setWindowFlags(Qt::Window | Qt::Tool | Qt::WindowTitleHint);
	// Allow space for (2 * 2) pieces in minimum view initially.
	m_scene->setPieceAreaSize(pieceArea);
	m_scene->initializeGrid(QPointF(0.0, 0.0));
	m_scene->setMinGrid(minGrid);
	// Add margin for constraint_handles+spacer and setSceneRect().
	QRectF rect = m_scene->piecesBoundingRect();
	qreal handleWidth = qMin(rect.width(), rect.height())/25.0;
	m_scene->addMargin(handleWidth, 0.5*handleWidth);
	setWindowTitle(title);
	qreal s = calculateCloseUpScale();
	QRectF r = m_scene->sceneRect();
	setMinimumSize(s*r.width()+1.0, s*r.height()+1.0);
	resize(minimumSize());
	qDebug() << "Close-up scale" << s << "pieceArea" << pieceArea
		 << "size" << size();
	QTransform t;
	t.scale(s, s);
	setTransform(t);
	centerOn(r.center());
	setSelected(true);
	show();
}
Пример #16
0
QtTextureViewer::QtTextureViewer(QWidget* parent)
    : QGraphicsView(parent)
{
    m_scene = new QGraphicsScene();
    m_scene->setSceneRect(0, 0, 2048, 2048);
    setScene(m_scene);

    centerOn(1024, 1024);

    m_pixmapItem = new QGraphicsPixmapItem();
    m_scene->addItem(m_pixmapItem);

    setBackground();
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setRenderHint(QPainter::Antialiasing, false);
    setTransformationAnchor(AnchorUnderMouse);
    setDragMode(ScrollHandDrag);
    viewport()->setCursor(Qt::ArrowCursor);

    // Turn this off to make background grid pixmap sharp
    setRenderHint(QPainter::SmoothPixmapTransform, false);

    // Zoom in out to the current cursor location
    setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
}
Пример #17
0
void qfi_VSI::init()
{
	m_scaleX = (float)width()  / (float)m_originalWidth;
	m_scaleY = (float)height() / (float)m_originalHeight;

	reset();

	m_itemFace = new QGraphicsSvgItem( ":/qfi/"+m_theme+"/vsi/vsi_face.svg" );
	m_itemFace->setCacheMode( QGraphicsItem::NoCache );
	m_itemFace->setZValue( m_faceZ );
	m_itemFace->setTransform( QTransform::fromScale( m_scaleX, m_scaleY ), true );
	m_scene->addItem( m_itemFace );

	m_itemHand = new QGraphicsSvgItem( ":/qfi/"+m_theme+"/vsi/vsi_hand.svg" );
	m_itemHand->setCacheMode( QGraphicsItem::NoCache );
	m_itemHand->setZValue( m_handZ );
	m_itemHand->setTransform( QTransform::fromScale( m_scaleX, m_scaleY ), true );
	m_itemHand->setTransformOriginPoint( m_originalVsiCtr );
	m_scene->addItem( m_itemHand );

	m_itemCase = new QGraphicsSvgItem( ":/qfi/"+m_theme+"/vsi/vsi_case.svg" );
	m_itemCase->setCacheMode( QGraphicsItem::NoCache );
	m_itemCase->setZValue( m_caseZ );
	m_itemCase->setTransform( QTransform::fromScale( m_scaleX, m_scaleY ), true );
	m_scene->addItem( m_itemCase );

	centerOn( width() / 2.0f , height() / 2.0f );

	updateView();
}
Пример #18
0
QList<PathItem *> PathView::loadData(const Data &data)
{
	QList<PathItem *> paths;
	int zoom = _zoom;


	for (int i = 0; i < data.tracks().count(); i++)
		paths.append(addTrack(*(data.tracks().at(i))));
	for (int i = 0; i < data.routes().count(); i++)
		paths.append(addRoute(*(data.routes().at(i))));
	addWaypoints(data.waypoints());

	if (_tracks.empty() && _routes.empty() && _waypoints.empty())
		return paths;

	if ((_tracks.size() + _routes.size() > 1 && _zoom < zoom)
	  || (_waypoints.size() && _zoom < zoom))
		rescale(_zoom);
	else
		updatePOIVisibility();

	QRectF sr = contentsSceneRect();
	_scene->setSceneRect(sr);
	centerOn(sr.center());

	_mapScale->setZoom(_zoom, -(sr.center().ry() * mapScale(_zoom)));
	if (_mapScale->scene() != _scene)
		_scene->addItem(_mapScale);

	return paths;
}
Пример #19
0
void PianoView::setStaff(Staff* s, Pos* l)
      {
      staff    = s;
      _locator = l;
      setEnabled(staff != nullptr);
      if (!staff) {
            scene()->blockSignals(true);  // block changeSelection()
            scene()->clear();
            scene()->blockSignals(false);
            return;
            }

      pos.setContext(staff->score()->tempomap(), staff->score()->sigmap());
      Measure* lm = staff->score()->lastMeasure();
      ticks       = lm->tick() + lm->ticks();
      scene()->setSceneRect(0.0, 0.0, double(ticks + 960), keyHeight * 75);

      updateNotes();

      //
      // move to something interesting
      //
      QList<QGraphicsItem*> items = scene()->selectedItems();
      QRectF boundingRect;
      foreach (QGraphicsItem* item, items) {
            if (item->type() == PianoItemType)
                  boundingRect |= item->mapToScene(item->boundingRect()).boundingRect();
            }
      centerOn(boundingRect.center());
      horizontalScrollBar()->setValue(0);
      }
Пример #20
0
	void PagesView::handleSmoothScroll (int frame)
	{
		const int endFrame = ScrollTimeline_->endFrame ();
		auto interp = [frame, endFrame] (const QPair<qreal, qreal>& pair)
				{ return pair.first + (pair.second - pair.first) * frame / endFrame; };
		centerOn (interp (XPath_), interp (YPath_));
	}
Пример #21
0
ViewportParams::ViewportParams( Projection projection,
                                qreal centerLongitude, qreal centerLatitude,
                                int radius,
                                const QSize &size )
    : d( new ViewportParamsPrivate( projection, centerLongitude, centerLatitude, radius, size ) )
{
    centerOn( d->m_centerLongitude, d->m_centerLatitude );
}
Пример #22
0
void TimeLineWidget::wheelEvent(QWheelEvent* ev)
{
	scale_ += float(ev->delta()) / 120;
	scale_ = std::max(0.5f, scale_);
	scale_ = std::min(1.5f, scale_);
	centerOn(cursor_->pos());
	std::cout << scale_ << std::endl;
};
Пример #23
0
void PlaybackFlyToItem::center( double t )
{
    Q_ASSERT( t >= 0.0 && t <= 1.0 );
    Q_ASSERT( m_before );
    if ( m_flyTo->flyToMode() == GeoDataFlyTo::Bounce || !m_before->m_before || !m_next ) {
        GeoDataCoordinates const a = m_before->m_flyTo->view()->coordinates();
        GeoDataCoordinates const b = m_flyTo->view()->coordinates();
        emit centerOn( a.interpolate( b, t ) );
    } else {
        Q_ASSERT( m_flyTo->flyToMode() == GeoDataFlyTo::Smooth );
        GeoDataCoordinates const a = m_before->m_before->m_flyTo->view()->coordinates();
        GeoDataCoordinates const b = m_before->m_flyTo->view()->coordinates();
        GeoDataCoordinates const c = m_flyTo->view()->coordinates();
        GeoDataCoordinates const d = m_next->m_flyTo->view()->coordinates();
        emit centerOn( b.interpolate( a, c, d, t ) );
    }
}
Пример #24
0
void
ScaleSliderQWidget::setMinimumAndMaximum(double min,
                                         double max)
{
    _imp->minimum = min;
    _imp->maximum = max;
    centerOn(_imp->minimum, _imp->maximum);
}
Пример #25
0
void MainRSTView::rePort()
{
    resetTransform();
    centerOn(father_->fx_, father_->fy_);
    scale(father_->sc_, father_->sc_);

    emit portChanged(width() / father_->sc_, height() / father_->sc_);
}
Пример #26
0
void QBlockDiagramView::mouseMoveEvent( QMouseEvent *event )
{
  QGraphicsView::mouseMoveEvent(event);
  if(event->buttons() & Qt::MidButton)
  {
    centerOn( mapToScene(event->pos())  ); 
  }
}
Пример #27
0
void DREAM3DGraphicsView::loadBaseImageFile(const QString& filename)
{
  m_BaseImage = QImage(filename);
  if (m_BaseImage.isNull() == true)
  {
    return;
  }
  QSize pSize(0, 0);
  pSize = m_BaseImage.size();

  m_OverlayImage = m_BaseImage;
  m_CompositedImage = m_BaseImage;

  QVector<QRgb > colorTable(256);
  for (quint32 i = 0; i < 256; ++i)
  {
    colorTable[i] = qRgb(i, i, i);
  }
  m_BaseImage.setColorTable(colorTable);

  if (m_BaseImage.isNull() == true)
  {
    std::cout << "Base Image was NULL for some reason. Returning" << std::endl;
    return;
  }
  QGraphicsScene* gScene = scene();
  if (gScene == NULL)
  {
    gScene = new QGraphicsScene(this);
    setScene(gScene);
  }
  else
  {

    setScene(NULL);
    gScene->deleteLater();
    gScene = new QGraphicsScene(this);
    setScene(gScene);

    delete m_ImageGraphicsItem;
    m_ImageGraphicsItem = NULL;
  }
  if (NULL == m_ImageGraphicsItem)
  {
    QImageReader reader(filename);
    QPixmap pixmap = QPixmap::fromImageReader(&reader, 0);
    m_ImageGraphicsItem = gScene->addPixmap(pixmap);
  }
  m_ImageGraphicsItem->setAcceptDrops(true);
  m_ImageGraphicsItem->setZValue(-1);


  QRectF rect = m_ImageGraphicsItem->boundingRect();
  gScene->setSceneRect(rect);
  centerOn(m_ImageGraphicsItem);
  this->updateDisplay();
  emit fireBaseImageFileLoaded(filename);
}
Пример #28
0
//Set the current centerpoint in the
void GraphicView::SetCenter ( const QPointF& centerPoint )
{
    //Get the rectangle of the visible area in scene coords
    QRectF visibleArea = mapToScene ( rect() ).boundingRect();

    //Get the scene area
    QRectF sceneBounds = sceneRect();

    double boundX = visibleArea.width() / 2.0;
    double boundY = visibleArea.height() / 2.0;
    double boundWidth = sceneBounds.width() - 2.0 * boundX;
    double boundHeight = sceneBounds.height() - 2.0 * boundY;

    //The max boundary that the centerPoint can be to
    QRectF bounds ( boundX, boundY, boundWidth, boundHeight );

    if ( bounds.contains ( centerPoint ) )
    {
        //We are within the bounds
        CurrentCenterPoint = centerPoint;
    } else
    {
        //We need to clamp or use the center of the screen
        if ( visibleArea.contains ( sceneBounds ) )
        {
            //Use the center of scene ie. we can see the whole scene
            CurrentCenterPoint = sceneBounds.center();
        }
        else
        {

            CurrentCenterPoint = centerPoint;

            //We need to clamp the center. The centerPoint is too large
            if ( centerPoint.x() > bounds.x() + bounds.width() )
            {
                CurrentCenterPoint.setX ( bounds.x() + bounds.width() );
            }
            else if ( centerPoint.x() < bounds.x() )
            {
                CurrentCenterPoint.setX ( bounds.x() );
            }

            if ( centerPoint.y() > bounds.y() + bounds.height() )
            {
                CurrentCenterPoint.setY ( bounds.y() + bounds.height() );
            }
            else if ( centerPoint.y() < bounds.y() )
            {
                CurrentCenterPoint.setY ( bounds.y() );
            }

        }
    }

    //Update the scrollbars
    centerOn ( CurrentCenterPoint );
}
Пример #29
0
void
ScaleSliderQWidget::resizeEvent(QResizeEvent* e)
{
    _imp->zoomCtx.setScreenSize(e->size().width(), e->size().height());
    if (!_imp->mustInitializeSliderPosition) {
        centerOn(_imp->minimum, _imp->maximum);
    }
    QWidget::resizeEvent(e);
}
Пример #30
0
GameWidget::GameWidget(Scene *scene, QWidget *parent) :
    QGraphicsView(parent),
    m_scene(scene),
    m_timeLabel(this),
    m_checkpointRemainingLabel(this),
    m_paused(false),
    m_cameraScale(1.f),
    m_frameCount(0),
    m_timeBeforeStartLabel(this)
{
    if (!scene)
    {
        QMessageBox::information(nullptr, "Erreur (GameWidget)", "Aucune scène a afficher!", 0);
    }
    else if (!scene->loaded())
    {
        QMessageBox::information(nullptr, "Erreur (GameWidget)", "Le niveau n'a pas été chargé!", 0);
    }
    else
    {       
        this->setCursor(Qt::BlankCursor);

        //Placement du label du timer
        m_timeLabel.setGeometry(0,0,500,50);
        m_timeLabel.setStyleSheet("color: white;font: 24pt \"Leelawadee UI\";");

        //Placement du label du nombre de checkpoints restants
        m_checkpointRemainingLabel.setGeometry(parent->width()-250,0,250,50);
        m_checkpointRemainingLabel.setStyleSheet("color: white;font: 14pt \"Leelawadee UI\";");

        //Placement du label du affichant le temps avant le début de la partie
        m_timeBeforeStartLabel.setGeometry(350,250,100,100);
        m_timeBeforeStartLabel.setStyleSheet("font: 72pt \"Leelawadee UI\";");

        // prépare la scène pour l'affichage
        this->setScene(scene->graphicsScene());
        this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
        this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);

        // réglages du clavier
        grabKeyboard();
        scene->setPlayerInput(&m_playerInput);

        // démarrage du timer de rafraichissement du jeu
        startTimer(sf::seconds(1/60.f).asMilliseconds());

        //Centrage de la caméra
        View view = m_scene->calcViewPoint();
        centerOn(view.position());

        //Démarrage du timer de début de course ( 3,2,1 -> Go)
        m_preStartTimer = new PreStartTimer(this);
        m_preStartTimer->startTimer();
        connect(m_preStartTimer,SIGNAL(startGame()),this,SLOT(startGame()));

    }
}