예제 #1
0
파일: pane.cpp 프로젝트: daivanov/Curves
bool Pane::eventFilter(QObject *obj, QEvent *event)
{
    switch (event->type()) {
    case QEvent::WindowActivate: {
        QRectF newSceneRect(QPointF(0.0, 0.0), maximumViewportSize());
        m_scene->setSceneRect(newSceneRect);
    }
        break;
    case QEvent::GraphicsSceneMousePress: {
        if (!m_active) {
            /* Clear everything */
            m_points.clear();
            m_angles.clear();
            QList<QGraphicsItem*> items = m_scene->items();
            foreach (QGraphicsItem *item, items) {
                m_scene->removeItem(item);
                delete item;
            }
            m_active = true;
        }
        QGraphicsSceneMouseEvent *mouseEvent =
            static_cast<QGraphicsSceneMouseEvent*>(event);

        Q_ASSERT(mouseEvent);

        QPointF point = mouseEvent->scenePos();
        m_out << point.x() << ","
              << point.y() << ","
              << QDateTime::currentMSecsSinceEpoch() << "\n";

        m_points << point;
    }
void ZoomableGerberView::set(GerberReader *reader, PathContur *contur1, PathContur *contur2, DrillReader *drillReader, Mirror drill2mirror)
{
    mView->set(reader, contur1, contur2, drillReader, drill2mirror);
    QSize bs = mView->bestSize();
    const double aspect = (double)bs.width()/(double)bs.height();
    const int h = QApplication::desktop()->height()/2;
    resize(h*aspect, h);
    initSize = maximumViewportSize();
    mZoomCoeficient = 1.0L;
    mView->resize(initSize);
}
예제 #3
0
void UIMachineView::updateSliders()
{
    QSize p = viewport()->size();
    QSize m = maximumViewportSize();

    QSize v = QSize(frameBuffer()->width(), frameBuffer()->height());
    /* No scroll bars needed: */
    if (m.expandedTo(v) == m)
        p = m;

    horizontalScrollBar()->setRange(0, v.width() - p.width());
    verticalScrollBar()->setRange(0, v.height() - p.height());
    horizontalScrollBar()->setPageStep(p.width());
    verticalScrollBar()->setPageStep(p.height());
}
예제 #4
0
파일: ImageGrid.cpp 프로젝트: Bullatov/gts
/** @brief Recalculate the layout size (rows x columns) and organise the images appropriately.
 *
 */
void ImageGrid::ReflowImages()
{
    m_frame->setFixedSize( maximumViewportSize()*m_zoom );

    if ( m_imageViews.size() > 0 )
    {
        for ( size_t i = 0; i < m_imageViews.size(); ++i )
        {
            m_gridLayout->removeWidget(m_imageViews[i].get());
        }

        CalculateNumRowsColumns();

        for ( size_t i = 0; i < m_imageViews.size(); ++i )
        {
            InsertImageInGrid( i );
        }
    }
    else
    {
        m_rows = 0;
        m_columns = 0;
    }
}