Exemple #1
0
void SkCanvasWidget::resetWidgetTransform() {
    fUserOffset.set(0,0);
    fUserScaleFactor = 1.0;
    fDebugger->setUserOffset(fUserOffset);
    fDebugger->setUserScale(fUserScaleFactor);
    emit scaleFactorChanged(fUserScaleFactor);
    drawTo(fDebugger->index());
}
TableEditor::TableEditor(QWidget *parent): Editor(parent)
{
    QVBoxLayout *layout = new QVBoxLayout(this);
    setLayout(layout);

    // toolbar
    _toolbar = new QWidget(this);
    layout->addWidget(_toolbar);
    _ui_toolbar = new Ui::TableEditorToolbar;
    _ui_toolbar->setupUi(_toolbar);
    _ui_toolbar->firstPageButton->setIcon(QIcon(IconLoader::getIconIdentifier(":/drawable/actions/allLeft")));
    _ui_toolbar->previousPageButton->setIcon(QIcon(IconLoader::getIconIdentifier(":/drawable/actions/left")));
    _ui_toolbar->nextPageButton->setIcon(QIcon(IconLoader::getIconIdentifier(":/drawable/actions/right")));
    _ui_toolbar->lastPageButton->setIcon(QIcon(IconLoader::getIconIdentifier(":/drawable/actions/allRight")));

    _ui_toolbar->refreshButton->setIcon(QIcon(IconLoader::getIconIdentifier(":/drawable/actions/refresh")));

    _ui_toolbar->addRowButton->setIcon(QIcon(IconLoader::getIconIdentifier(":/drawable/general/add")));
    _ui_toolbar->deleteRowButton->setIcon(QIcon(IconLoader::getIconIdentifier(":/drawable/general/remove")));

    _ui_toolbar->commitButton->setIcon(QIcon(IconLoader::getIconIdentifier(":/drawable/actions/checked")));
    _ui_toolbar->rollbackButton->setIcon(QIcon(IconLoader::getIconIdentifier(":/drawable/actions/rollback")));

    _ui_toolbar->dumpDataButton->setIcon(QIcon(IconLoader::getIconIdentifier(":/drawable/actions/export")));

    _tableView = new QTableView(this);
    _tableModel = new QSqlTableModel(_tableView /* TODO database connection */);
    _tableView->setModel(_tableModel);
    layout->addWidget(_tableView);

    // connections
    connect(_ui_toolbar->commitButton, SIGNAL(clicked()), _tableModel, SLOT(submitAll()));
    connect(_ui_toolbar->rollbackButton, SIGNAL(clicked()), _tableModel, SLOT(revertAll()));
    connect(_ui_toolbar->addRowButton, SIGNAL(clicked()), this, SLOT(addRow()));
    connect(_ui_toolbar->deleteRowButton, SIGNAL(clicked()), this, SLOT(deleteRows()));
    connect(_ui_toolbar->refreshButton, SIGNAL(clicked()), _tableModel, SLOT(select()));



    connect(_ui_toolbar->toolButtonExportImage, SIGNAL(clicked()),_imageView, SLOT(exportImage()));
    connect(_ui_toolbar->toolButtonZoomIn, SIGNAL(clicked()),_imageView,SLOT(zoomIn()));
    connect(_ui_toolbar->toolButtonZoomOut, SIGNAL(clicked()),_imageView, SLOT(zoomOut()));
    connect(_ui_toolbar->toolButtonFitToScreen, SIGNAL(clicked()),_imageView, SLOT(fitToScreen()));
    connect(_ui_toolbar->toolButtonOriginalSize, SIGNAL(clicked()),_imageView, SLOT(resetToOriginalSize()));
    connect(_ui_toolbar->toolButtonBackground, SIGNAL(toggled()),_imageView, SLOT(setViewBackground()));
    connect(_ui_toolbar->toolButtonOutline, SIGNAL(toggled()),_imageView, SLOT(setViewOutline()));
    connect(_ui_toolbar->toolButtonPlayPause, SIGNAL(clicked()),this, SLOT(playToggled()));
    connect(_file, SIGNAL(imageSizeChanged()),this, SLOT(imageSizeUpdated()));
    connect(_file, SIGNAL(openFinished()),_imageView, SLOT(createScene()));
    connect(_file, SIGNAL(openFinished()),this, SLOT(updateToolButtons()));
    connect(_file, SIGNAL(aboutToReload()),_imageView, SLOT(reset()));
    connect(_file, SIGNAL(reloadFinished()),_imageView, SLOT(createScene()));
    connect(_file, SIGNAL(isPausedChanged()),this, SLOT(updatePauseAction()));
    connect(_imageView, SIGNAL(scaleFactorChanged()),this, SLOT(scaleFactorUpdate()));
}
Exemple #3
0
void SkCanvasWidget::zoom(float zoomIncrement) {
    fUserScaleFactor += zoomIncrement;

    /* The range of the fUserScaleFactor crosses over the range -1,0,1 frequently.
    * Based on the code below, -1 and 1 both scale the image to it's original
    * size we do the following to never have a registered wheel scroll
    * not effect the fUserScaleFactor. */
    if (fUserScaleFactor == 0) {
        fUserScaleFactor = 2 * zoomIncrement;
    }
    emit scaleFactorChanged(fUserScaleFactor);
    fDebugger->setUserScale(fUserScaleFactor);
    drawTo(fDebugger->index());
}
void TimelineGraphicsLayout::setTimeline(const QmlTimeline &timeline)
{
    m_layout->removeItem(m_rulerItem);
    m_layout->removeItem(m_placeholder1);
    m_layout->removeItem(m_placeholder2);

    m_rulerItem->setParentItem(nullptr);
    m_placeholder1->setParentItem(nullptr);
    m_placeholder2->setParentItem(nullptr);

    qDeleteAll(this->childItems());

    m_rulerItem->setParentItem(this);
    m_rulerItem->invalidateRulerSize(timeline);
    m_layout->addItem(m_rulerItem);

    m_placeholder1->setParentItem(this);
    m_layout->addItem(m_placeholder1);

    m_layout->invalidate();

    if (timeline.isValid()) {
        for (const ModelNode &target : timeline.allTargets()) {
            if (target.isValid()) {
                auto item = TimelineSectionItem::create(timeline, target, this);
                m_layout->addItem(item);
            }
        }
    }

    m_placeholder2->setParentItem(this);
    m_layout->addItem(m_placeholder2);

    if (auto *scene = timelineScene())
        if (auto *view = scene->timelineView())
            if (!timeline.isValid() && view->isAttached())
                emit scaleFactorChanged(0);
}
Exemple #5
0
void ImageView::emitScaleFactor()
{
    // get scale factor directly from the transform matrix
    qreal factor = transform().m11();
    emit scaleFactorChanged(factor);
}
void SkCanvasWidget::zoom(float scale, int px, int py) {
    fUserMatrix.postScale(scale, scale, px, py);
    emit scaleFactorChanged(fUserMatrix.getScaleX());
    fDebugger->setUserMatrix(fUserMatrix);
    drawTo(fDebugger->index());
}
void SkCanvasWidget::resetWidgetTransform() {
    fUserMatrix.reset();
    fDebugger->setUserMatrix(fUserMatrix);
    emit scaleFactorChanged(fUserMatrix.getScaleX());
    drawTo(fDebugger->index());
}
Exemple #8
0
void QDecTouchArea::updateTouchData(QEvent *event)
{  
    QTouchEvent *e = static_cast<QTouchEvent*>(event);
    QList<QTouchEvent::TouchPoint> listTouchPts = e->touchPoints();
    for(int i=0; i < listTouchPts.count(); i++)
    {
        int touchPtId = listTouchPts[i].id();
        Qt::TouchPointState touchPtState = listTouchPts[i].state();
        QPointF touchPtPos = listTouchPts[i].pos();

        QDecTouchPoint * qDecTouchPt = m_listTouchPoints[touchPtId];

        // set touch point active/inactive
        if(touchPtState & Qt::TouchPointPressed)  {
            qDecTouchPt->setActive(true);
            qDecTouchPt->setX(touchPtPos.x());
            qDecTouchPt->setY(touchPtPos.y());
            emit touchPointPressed(touchPtId);
        }
        else if(touchPtState & Qt::TouchPointReleased)  {
            qDecTouchPt->setActive(false);
            qDecTouchPt->setX(touchPtPos.x());
            qDecTouchPt->setY(touchPtPos.y());
            emit touchPointReleased(touchPtId);
        }

        // if point moved, set new position
        if(touchPtState & Qt::TouchPointMoved)  {
            qDecTouchPt->setX(touchPtPos.x());
            qDecTouchPt->setY(touchPtPos.y());
            emit touchPointMoved(touchPtId);
        }
    }

    // handle two touch inputs
    if(listTouchPts.count() == 2)
    {
        QTouchEvent::TouchPoint tp1 = listTouchPts.at(0);
        QTouchEvent::TouchPoint tp2 = listTouchPts.at(1);

        QPointF tp1LastPos = tp1.lastPos();
        QPointF tp2LastPos = tp2.lastPos();
        QPointF tp1Pos = tp1.pos();
        QPointF tp2Pos = tp2.pos();

        QPointF deltaA = tp1LastPos - tp2LastPos;
        QPointF deltaB = tp1Pos - tp2Pos;

        qreal distanceA = sqrt(pow(deltaA.x(),2.0)+pow(deltaA.y(),2.0));
        qreal distanceB = sqrt(pow(deltaB.x(),2.0)+pow(deltaB.y(),2.0));

        if (distanceA != 0 && distanceB != 0) {
            m_diffScaleFactor = (distanceB/distanceA);
            m_totalScaleFactor *= m_diffScaleFactor;
            emit(scaleFactorChanged());
        }

        QLineF lineA(tp1LastPos, tp2LastPos);
        QLineF lineB(tp1Pos,tp2Pos);
        m_diffRotationAngle = lineA.angleTo(lineB);
        m_totalRotationAngle -= m_diffRotationAngle;

        if(m_totalRotationAngle > 360)  {
            m_totalRotationAngle -= 360;
        }
        else if(m_totalRotationAngle < -360)  {
            m_totalRotationAngle += 360;
        }

        emit(rotationAngleChanged());
    }

//    // handle two touch inputs
//    if(listTouchPts.count() == 2)
//    {
//        QTouchEvent::TouchPoint tp1 = listTouchPts.at(0);
//        QTouchEvent::TouchPoint tp2 = listTouchPts.at(1);

//        QPointF tp1Prv = tp1.lastPos();
//        QPointF tp2Prv = tp2.lastPos();

//        QPointF tp1New = tp1.pos();
//        QPointF tp2New = tp2.pos();

//        // get previous and current distances
//        qreal distPrv = sqrt(pow(tp1Prv.x()-tp2Prv.x(),2) +
//                             pow(tp1Prv.y()-tp2Prv.y(),2));

//        qreal distNew = sqrt(pow(tp1New.x()-tp2New.x(),2) +
//                             pow(tp1New.y()-tp2New.y(),2));

//        if(distPrv !=0 && distNew != 0)  {
//            if(fabs(distNew/distPrv - 1) > 0.008)  {
//                m_diffScaleFactor = (distNew/distPrv);
//                m_totalScaleFactor *= m_diffScaleFactor;
//                emit(scaleFactorChanged());
//            }
//        }

//        // get previous and current angles
//        QLineF linePrv(tp1Prv,tp2Prv);
//        QLineF lineNew(tp1New,tp2New);
//        m_diffRotationAngle = linePrv.angleTo(lineNew);
//        m_totalRotationAngle -= m_diffRotationAngle;

//        if(m_totalRotationAngle > 360)  {
//            m_totalRotationAngle -= 360;
//        }
//        else if(m_totalRotationAngle < -360)  {
//            m_totalRotationAngle += 360;
//        }

//        emit(rotationAngleChanged());
//    }
}
Exemple #9
0
void MainWindow::setupDockWidgets(void)
{
	/* TODO: Do not create new dockWidgets if we already have them. */

	/* TODO: Kill any old dockWidgets before creating new ones? */

	for (int i = 0; i < getNumChannels(); ++i) {
		channelForms[i] = new ChannelForm(this);
		channelForms[i]->setChannelNumber(i);

		dockWidgets[i] = new QDockWidget(this);
		dockWidgets[i]->setAllowedAreas(Qt::BottomDockWidgetArea);

		QDockWidget::DockWidgetFeatures f;
		f = QDockWidget::DockWidgetClosable |
		    QDockWidget::DockWidgetMovable |
		    QDockWidget::DockWidgetFloatable;
		if (configChannelTitleBarLayout == DOCK_VERTICAL)
			f |= QDockWidget::DockWidgetVerticalTitleBar;
		dockWidgets[i]->setFeatures(f);
		dockWidgets[i]->setWidget(channelForms[i]);
		addDockWidget(Qt::BottomDockWidgetArea, dockWidgets[i],
			      Qt::Vertical);

		/* Update labels upon changes. */
		QObject::connect(channelForms[i],
			SIGNAL(sampleStartChanged(QString)),
			ui->labelSampleStart, SLOT(setText(QString)));
		QObject::connect(channelForms[i],
			SIGNAL(sampleEndChanged(QString)),
			ui->labelSampleEnd, SLOT(setText(QString)));
		QObject::connect(channelForms[i],
			SIGNAL(scaleFactorChanged(QString)),
			ui->labelScaleFactor, SLOT(setText(QString)));

		/* Redraw channels upon changes. */
		QObject::connect(channelForms[i],
			SIGNAL(sampleStartChanged(QString)),
			channelForms[i], SLOT(generatePainterPath()));
		QObject::connect(channelForms[i],
			SIGNAL(sampleEndChanged(QString)),
			channelForms[i], SLOT(generatePainterPath()));
		QObject::connect(channelForms[i],
			SIGNAL(scaleFactorChanged(QString)),
			channelForms[i], SLOT(generatePainterPath()));

		// dockWidgets[i]->show();

#if 0
		/* If the user renames a channel, adapt the dock title. */
		QObject::connect(lineEdits[i], SIGNAL(textChanged(QString)),
				 dockWidgets[i], SLOT(setWindowTitle(QString)));
#endif
	}

	/* For now, display only one scrollbar which scrolls all channels. */
	QDockWidget* scrollWidget = new QDockWidget(this);
	scrollWidget->setAllowedAreas(Qt::BottomDockWidgetArea);
	horizontalScrollBar = new QScrollBar(this);
	horizontalScrollBar->setOrientation(Qt::Horizontal);
	
	QDockWidget::DockWidgetFeatures f;
	if (configChannelTitleBarLayout == DOCK_VERTICAL)
		f |= QDockWidget::DockWidgetVerticalTitleBar;
	scrollWidget->setFeatures(f);
	scrollWidget->setWidget(horizontalScrollBar);
	addDockWidget(Qt::BottomDockWidgetArea, scrollWidget,
			      Qt::Vertical);
	
	for (int i = 0; i < getNumChannels(); ++i) {
		/* The scrollbar scrolls all channels. */
		connect(horizontalScrollBar, SIGNAL(valueChanged(int)),
				channelForms[i], SLOT(setScrollBarValue(int)));
	}
}