Пример #1
0
void GInstructionView::FitInstructionInView()
{
	if(!m_pInstruction || !m_pInsScene)
		return;
//	setSceneRect(m_pInstruction->BoundingSceneRect());
	fitInView(&m_pInstruction->m_GraphicsItem);

	QRectF SceneRect = sceneRect();
	if(!SceneRect.isValid())
		return;
	// we don't want blank areas at the beginning or at the ending of the G_old_Instruction in the QGraphicsView
	// so here is what we are going to do: we will see what is the viewport coordinate in the scene,...
	// then, we will add 1 or so, and change the scene coordinate so that it corresponds to the beginning/ending of the G_old_Instruction
	fitInView(SceneRect);
	QRect geomView = geometry();
	int Xini = -1;
	int Xfin = geomView.width() - 3;
	if(Xfin <= 2)
		return;
	double Xiniscene = mapToScene(Xini, 0).rx();
	double Xfinscene = mapToScene(Xfin, 0).rx() - m_pInstruction->Duration();
	SceneRect.adjust(- Xiniscene, 0, - Xfinscene, 0);
	setSceneRect(SceneRect);
	fitInView(SceneRect);
}
Пример #2
0
 virtual void resizeEvent(QResizeEvent *event)
 {
     QGraphicsView::resizeEvent(event);
     MainWindow *main_window = qobject_cast<MainWindow *>(parentWidget());
     if (scene()->inherits("RoomScene")) {
         RoomScene *room_scene = qobject_cast<RoomScene *>(scene());
         QRectF newSceneRect(0, 0, event->size().width(), event->size().height());
         room_scene->setSceneRect(newSceneRect);
         room_scene->adjustItems();
         setSceneRect(room_scene->sceneRect());
         if (newSceneRect != room_scene->sceneRect())
             fitInView(room_scene->sceneRect(), Qt::KeepAspectRatio);
         else
             this->resetTransform();
         main_window->setBackgroundBrush(false);
         return;
     } else if (scene()->inherits("StartScene")) {
         StartScene *start_scene = qobject_cast<StartScene *>(scene());
         QRectF newSceneRect(-event->size().width() / 2, -event->size().height() / 2,
             event->size().width(), event->size().height());
         start_scene->setSceneRect(newSceneRect);
         setSceneRect(start_scene->sceneRect());
         if (newSceneRect != start_scene->sceneRect())
             fitInView(start_scene->sceneRect(), Qt::KeepAspectRatio);
     }
     if (main_window)
         main_window->setBackgroundBrush(true);
 }
void ViewPreview::resizeEvent(QResizeEvent *event)
{
  if (m_viewAspectRatio == VIEW_ASPECT_RATIO_ONE_TO_ONE) {

    fitInView (scene()->sceneRect(),
               Qt::KeepAspectRatio);

  } else {

    // Make image fit the new window size. This is needed since QGraphicsView ignores layout stretching
    fitInView (scene()->itemsBoundingRect ());

    QGraphicsView::resizeEvent (event);
  }
}
Пример #4
0
void MiniMap::showScene()
{
	if (scene() != NULL) {
		setSceneRect(scene()->sceneRect());
		fitInView(sceneRect(), Qt::KeepAspectRatio);
	}
}
Пример #5
0
Файл: GView.cpp Проект: olii/ICP
void GView::init()
{
    scene()->clear();
    for( int i = 0; i< dimension.height(); ++i )
    {
        for ( int j = 0; j < dimension.width(); j++ )
        {
            GPixmapItem* tmp = new GPixmapItem(*podlaha);
            tmp->setPos( podlaha->width()*j, podlaha->height()*i);
            tmp->setToolTip(QString("TEST") + QString::number(i));
            this->scene()->addItem( tmp );
        }

    }
        scene()->setSceneRect(scene()->itemsBoundingRect());
       /* prisposobenie sceny rozmerom okna */
       fitInView(scene()->sceneRect(), Qt::KeepAspectRatio);
       savescale();
       /* magia, ktora odstranila bug sposobeny volanim fitInView */
       qreal factor = std::pow(1.001, 120);
       scale(factor, factor);
       factor = std::pow(1.001, -120);
       scale(factor, factor);

}
void DisplayGroupGraphicsView::resizeEvent( QResizeEvent * resizeEvt )
{
    // compute the scene rectangle to show such that the aspect ratio
    // corresponds to the actual aspect ratio of the tiled display
    const float tiledDisplayAspect = g_configuration->getAspectRatio();
    const float windowAspect = (float)width() / (float)height();

    float sceneWidth, sceneHeight;

    if( tiledDisplayAspect >= windowAspect )
    {
        sceneWidth = 1.;
        sceneHeight = tiledDisplayAspect / windowAspect;
    }
    else // tiledDisplayAspect < windowAspect
    {
        sceneHeight = 1.;
        sceneWidth = windowAspect / tiledDisplayAspect;
    }

    // make sure we have a small buffer around the (0,0,1,1) scene rectangle
    float border = 0.05;

    sceneWidth = std::max( sceneWidth, (float)1. + border );
    sceneHeight = std::max( sceneHeight, (float)1. + border );

    setSceneRect( -(sceneWidth - 1.)/2., -(sceneHeight - 1.)/2.,
                  sceneWidth, sceneHeight );

    fitInView(sceneRect());

    QGraphicsView::resizeEvent(resizeEvt);
}
Пример #7
0
void ViewPreview::resizeEvent(QResizeEvent *event)
{
  // Make image fit the new window size. This is needed since QGraphicsView ignores layout stretching
  fitInView (scene()->itemsBoundingRect ());

  QGraphicsView::resizeEvent (event);
}
Пример #8
0
void VLCStatsView::addValue( float value )
{
    value /= 1000;

    QPolygonF shape = totalbitrateShape->polygon();
    if ( shape.count() > ( STATS_LENGTH + 2 ) ) /* keep only STATS_LENGTH samples */
    {
        shape.remove( 1 );
        for(int i=1; i<( STATS_LENGTH + 2 ); i++)
            ( (QPointF &) shape.at(i) ).setX( i - 1 ); /*move back values*/
    }

    int count = shape.count();
    if ( count == 0 )
    {
        shape << QPointF( 0, 0 ); /* begin and close shape */
        shape << QPointF( count, 0 );
    }

    shape.insert( shape.end() - 1, QPointF( count, value ) );
    ( (QPointF &) shape.last() ).setX( count );
    totalbitrateShape->setPolygon( shape );

    addHistoryValue( value );

    QRectF maxsizes = scene()->itemsBoundingRect();
    maxsizes.setRight( STATS_LENGTH );
    fitInView( maxsizes ); /* fix viewport */
    drawRulers( maxsizes );
}
Пример #9
0
/*
 * 功能:
 * 	  满屏显示用户视角区域
 * 参数:
 * 返回值:
 */
void SlidingScreen::resizeEvent(QResizeEvent *event)
{
    if (!m_enable)
        return;
    fitInView(sceneRect(), Qt::IgnoreAspectRatio);
    QGraphicsView::resizeEvent(event);
}
Пример #10
0
void FMSampleTextView::mouseReleaseEvent ( QMouseEvent * e )
{
	if ( isPanning )
	{
		isPanning = false;
		QApplication::restoreOverrideCursor();
		return;
	}
	if ( !isSelecting )
		return;
// 	qDebug()<<"End mouse is "<< mapToScene( e->pos()).toPoint();
	if ( mouseStartPoint.toPoint() == mapToScene ( e->pos() ).toPoint() )
	{
		// scale(1,1)
// 		qDebug() << "Re-init transformation";
		emit pleaseZoom ( 0 );
		isSelecting = false;
		theRect->setRect ( QRectF() );
		return;
	}

	QRect zoomRect ( mouseStartPoint.toPoint(),mapToScene ( e->pos() ).toPoint() );
	ensureVisible ( zoomRect );
	isSelecting = false;
// 	qDebug() << "release " << theRect->scenePos();
	fitInView ( theRect->sceneBoundingRect(), Qt::KeepAspectRatio );
	theRect->setRect ( QRectF() );



}
Пример #11
0
void SinglePlayerView::resizeEvent( QResizeEvent *event )
{
	if ( data && data->isDataLoaded() )
		fitInView( data->bgItem()->boundingRect(), Qt::KeepAspectRatio );

	QWidget::resizeEvent( event );
}
int QPrintPreviewWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: paintRequested((*reinterpret_cast< QPrinter*(*)>(_a[1]))); break;
        case 1: previewChanged(); break;
        case 2: print(); break;
        case 3: zoomIn((*reinterpret_cast< qreal(*)>(_a[1]))); break;
        case 4: zoomIn(); break;
        case 5: zoomOut((*reinterpret_cast< qreal(*)>(_a[1]))); break;
        case 6: zoomOut(); break;
        case 7: setZoomFactor((*reinterpret_cast< qreal(*)>(_a[1]))); break;
        case 8: setOrientation((*reinterpret_cast< QPrinter::Orientation(*)>(_a[1]))); break;
        case 9: setViewMode((*reinterpret_cast< ViewMode(*)>(_a[1]))); break;
        case 10: setZoomMode((*reinterpret_cast< ZoomMode(*)>(_a[1]))); break;
        case 11: setCurrentPage((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 12: fitToWidth(); break;
        case 13: fitInView(); break;
        case 14: setLandscapeOrientation(); break;
        case 15: setPortraitOrientation(); break;
        case 16: setSinglePageViewMode(); break;
        case 17: setFacingPagesViewMode(); break;
        case 18: setAllPagesViewMode(); break;
        case 19: updatePreview(); break;
        case 20: d_func()->_q_fit(); break;
        case 21: d_func()->_q_updateCurrentPage(); break;
        }
        _id -= 22;
    }
    return _id;
}
Пример #13
0
void CView::resizeEvent( QResizeEvent *event)
{
	fitInView(sceneRect(), Qt::KeepAspectRatio);

	adjustScene();
	QGraphicsView::resizeEvent(event);
}
Пример #14
0
void TelemetryMonitorWidget::resizeEvent(QResizeEvent* event)
{
    Q_UNUSED(event);

    graph->setPos(0,-130);
    fitInView(graph, Qt::KeepAspectRatio);
}
Пример #15
0
void TransferFunctionEditorView::updateZoom() {
    fitInView(
        tfProperty_->getZoomH().x * scene()->sceneRect().width(),
        tfProperty_->getZoomV().x * scene()->sceneRect().height(),
        (tfProperty_->getZoomH().y - tfProperty_->getZoomH().x) * scene()->sceneRect().width(),
        (tfProperty_->getZoomV().y - tfProperty_->getZoomV().x) * scene()->sceneRect().height(),
        Qt::IgnoreAspectRatio);
}
Пример #16
0
void PlotView::resizeEvent(QResizeEvent *event)
{
    PlotScene *scene = (PlotScene *) this->scene();
    scene->setDrawnStatus(false);

    fitInView(scene->itemsBoundingRect(), Qt::IgnoreAspectRatio);
    QGraphicsView::resizeEvent(event);
}
Пример #17
0
void
Panner::slotSceneRectChanged(const QRectF &newRect)
{
    if (!scene()) return; // spurious
    fitInView(newRect, Qt::KeepAspectRatio);
    m_cache = QPixmap();
    viewport()->update();
}
Пример #18
0
void PlotView::mousePressEvent(QMouseEvent *event){
    if(event->button() == Qt::RightButton ){
        PlotScene *scene = (PlotScene *) this->scene();
        scene->setDrawnStatus(false);

        fitInView(scene->itemsBoundingRect(), Qt::IgnoreAspectRatio);
    }
    QGraphicsView::mousePressEvent(event);
}
Пример #19
0
void StratView::update()
{
    QRectF viewRect = _scene->itemsBoundingRect();
    _scene->setSceneRect(viewRect);
    QRectF sceneInView(_scene->MARGIN,_scene->MARGIN,
                       viewRect.width() + 2 * _scene->MARGIN,
                       viewRect.height() + 2 * _scene->MARGIN);
    fitInView(sceneInView, Qt::IgnoreAspectRatio);
}
Пример #20
0
void PianoKeybd::setRotation(int r)
{
    if (r != m_rotation) {
        m_rotation = r;
        resetTransform();
        rotate(m_rotation);
        fitInView(m_scene->sceneRect(), Qt::KeepAspectRatio);
    }
}
Пример #21
0
    virtual void resizeEvent(QResizeEvent *event) {
        QGraphicsView::resizeEvent(event);
        if(Config.FitInView)
            fitInView(sceneRect(), Qt::KeepAspectRatio);

        if(scene()->inherits("RoomScene")){
            RoomScene *room_scene = qobject_cast<RoomScene *>(scene());
            room_scene->adjustItems();
        }
    }
Пример #22
0
void ViewProfile::refit ()
{
  // Force the scene boundaries to be the same, even after resizing
  QRectF bounds = QRectF (VIEW_PROFILE_X_MIN - SLOP_ON_SIDES,
                          VIEW_PROFILE_Y_MIN,
                          VIEW_PROFILE_X_MAX + 2 * SLOP_ON_SIDES,
                          VIEW_PROFILE_Y_MAX);
  fitInView (bounds);
  setSceneRect (bounds);
}
Пример #23
0
void CView::openFile(const QString& fileName)
{
	QFileInfo info(fileName);
	QString ext = info.suffix();
	if (ext == "g")
	{
		dynamic_cast<CGraphicsScene*>(scene())->draw(fileName);
		fitInView(scene()->sceneRect(), Qt::KeepAspectRatio);
		adjustScene();
	}
}
Пример #24
0
void ImageView::zoomFit()
{
  if (!m_image.isNull() && m_image.width() <= width() && m_image.height() <= height()) {
    zoomOriginal();
    return;
  }

  fitInView(m_scene->sceneRect(), Qt::KeepAspectRatio);
  m_scaleFactor = transform().m11();

  queueGenerateCache();
}
void GpsConstellationWidget::showEvent(QShowEvent *event)
{
    Q_UNUSED(event)
    // Thit fitInView method should only be called now, once the
    // widget is shown, otherwise it cannot compute its values and
    // the result is usually a ahrsbargraph that is way too small.
    fitInView(world, Qt::KeepAspectRatio);
    // Scale, can't use fitInView since that doesn't work until we're shown.
    // qreal factor = height()/world->boundingRect().height();
// world->setScale(factor);
// setSceneRect(world->boundingRect());
}
Пример #26
0
//!
//! Sets the viewing transformation so that the given bounding rectangle is
//! fully visible in the graphics view, and centers the bounding rectangle
//! in the middle of the view.
//!
//! \param rect The rectangular region to frame in the graphics view.
//!
void BaseGraphicsView::frame ( const QRectF &rect )
{
    fitInView(rect, Qt::KeepAspectRatio);

    // make sure the scale factor does not exceed the limits
    double scaleFactor = matrix().m11();
    if (scaleFactor < MIN_SCALE)
        setScale(MIN_SCALE);
    else if (scaleFactor > MAX_SCALE)
        setScale(MAX_SCALE);

    centerOn(rect.left() + rect.width() / 2, rect.top() + rect.height() / 2);
}
Пример #27
0
void ImageView::zoomFit() {
  if(!image_.isNull()) {
    // if the image is smaller than our view, use its original size
    // instead of scaling it up.
    if(image_.width() <= width() && image_.height() <= height()) {
      zoomOriginal();
      return;
    }
  }
  fitInView(scene_->sceneRect(), Qt::KeepAspectRatio);
  scaleFactor_ = transform().m11();
  queueGenerateCache();
}
Пример #28
0
void
NodeGraph::centerOnAllNodes()
{
    assert( QThread::currentThread() == qApp->thread() );
    double xmin = INT_MAX;
    double xmax = INT_MIN;
    double ymin = INT_MAX;
    double ymax = INT_MIN;
    //_imp->_root->setPos(0,0);

    if ( _imp->_selection.empty() ) {
        QMutexLocker l(&_imp->_nodesMutex);

        for (NodesGuiList::iterator it = _imp->_nodes.begin(); it != _imp->_nodes.end(); ++it) {
            if ( /*(*it)->isActive() &&*/ (*it)->isVisible() ) {
                QSize size = (*it)->getSize();
                QPointF pos = (*it)->mapToScene( (*it)->mapFromParent( (*it)->pos() ) );
                xmin = std::min( xmin, pos.x() );
                xmax = std::max( xmax, pos.x() + size.width() );
                ymin = std::min( ymin, pos.y() );
                ymax = std::max( ymax, pos.y() + size.height() );
            }
        }
    } else {
        for (NodesGuiList::iterator it = _imp->_selection.begin(); it != _imp->_selection.end(); ++it) {
            if ( /*(*it)->isActive() && */ (*it)->isVisible() ) {
                QSize size = (*it)->getSize();
                QPointF pos = (*it)->mapToScene( (*it)->mapFromParent( (*it)->pos() ) );
                xmin = std::min( xmin, pos.x() );
                xmax = std::max( xmax, pos.x() + size.width() );
                ymin = std::min( ymin, pos.y() );
                ymax = std::max( ymax, pos.y() + size.height() );
            }
        }
    }
    QRectF bbox( xmin, ymin, (xmax - xmin), (ymax - ymin) );
    fitInView(bbox, Qt::KeepAspectRatio);

    double currentZoomFactor = transform().mapRect( QRectF(0, 0, 1, 1) ).width();
    assert(currentZoomFactor != 0);
    //we want to fit at scale 1 at most
    if (currentZoomFactor > 1.) {
        double scaleFactor = 1. / currentZoomFactor;
        setTransformationAnchor(QGraphicsView::AnchorViewCenter);
        scale(scaleFactor, scaleFactor);
        setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
    }

    _imp->_refreshOverlays = true;
    update();
} // NodeGraph::centerOnAllNodes
Пример #29
0
void PianoKeybd::setNumOctaves(const int numOctaves)
{
    if (numOctaves != m_scene->numOctaves()) {
        int baseOctave = m_scene->baseOctave();
        QColor color = m_scene->getKeyPressedColor();
        PianoHandler* handler = m_scene->getPianoHandler();
        KeyboardMap* keyMap = m_scene->getKeyboardMap();
        delete m_scene;
        initScene(baseOctave, numOctaves, color);
        m_scene->setPianoHandler(handler);
        m_scene->setKeyboardMap(keyMap);
        fitInView(m_scene->sceneRect(), Qt::KeepAspectRatio);
    }
}
Пример #30
0
void PixmapView::resizeEvent(QResizeEvent *event)
{
    QRectF rectf = m_sceneBig->itemsBoundingRect();
    m_sceneBig->setSceneRect( rectf );
//    this->fitInView(m_sceneBig->sceneRect());
    if( this->viewport()->width() < m_sceneBig->width() ||
            this->viewport()->height() < m_sceneBig->height() )
    {
        fitInView(m_sceneBig->items().at(0), Qt::KeepAspectRatio);
    }
    this->viewport()->update();

    QGraphicsView::resizeEvent(event);
}