SEXP qt_qfitScene_QGraphicsView(SEXP v) { QGraphicsView *view = unwrapQObject(v, QGraphicsView); view->fitInView(view->sceneRect()); return R_NilValue; }
Geometryval::Geometryval(const MltVideoProfile profile, QPoint frame_size, QWidget* parent) : QWidget(parent), m_profile(profile), m_paramRect(NULL), m_geom(NULL), m_path(NULL), m_fixedMode(false), m_frameSize(frame_size) { m_ui.setupUi(this); QVBoxLayout* vbox = new QVBoxLayout(m_ui.widget); QGraphicsView *view = new QGraphicsView(this); view->setBackgroundBrush(QBrush(Qt::black)); vbox->addWidget(view); vbox->setContentsMargins(0, 0, 0, 0); QVBoxLayout* vbox2 = new QVBoxLayout(m_ui.keyframeWidget); m_helper = new KeyframeHelper(this); vbox2->addWidget(m_helper); vbox2->setContentsMargins(0, 0, 0, 0); connect(m_helper, SIGNAL(positionChanged(int)), this, SLOT(slotPositionChanged(int))); m_scene = new GraphicsSceneRectMove(this); m_scene->setTool(TITLE_SELECT); view->setScene(m_scene); QGraphicsRectItem *m_frameBorder = new QGraphicsRectItem(QRectF(0, 0, profile.width, profile.height)); m_frameBorder->setZValue(-1100); m_frameBorder->setBrush(QColor(255, 255, 0, 30)); m_frameBorder->setPen(QPen(QBrush(QColor(255, 255, 255, 255)), 1.0, Qt::DashLine)); m_scene->addItem(m_frameBorder); m_ui.buttonNext->setIcon(KIcon("media-skip-forward")); m_ui.buttonNext->setToolTip(i18n("Go to next keyframe")); m_ui.buttonPrevious->setIcon(KIcon("media-skip-backward")); m_ui.buttonPrevious->setToolTip(i18n("Go to previous keyframe")); m_ui.buttonAdd->setIcon(KIcon("document-new")); m_ui.buttonAdd->setToolTip(i18n("Add keyframe")); m_ui.buttonDelete->setIcon(KIcon("edit-delete")); m_ui.buttonDelete->setToolTip(i18n("Delete keyframe")); QMenu *configMenu = new QMenu(i18n("Misc..."), this); m_ui.buttonMenu->setIcon(KIcon("system-run")); m_ui.buttonMenu->setMenu(configMenu); m_ui.buttonMenu->setPopupMode(QToolButton::QToolButton::InstantPopup); configMenu->addAction(i18n("Geometry"), this, SLOT(slotGeometry())); m_scaleMenu = new QMenu(i18n("Resize..."), this); configMenu->addMenu(m_scaleMenu); m_scaleMenu->addAction(i18n("50%"), this, SLOT(slotResize50())); m_scaleMenu->addAction(i18n("100%"), this, SLOT(slotResize100())); m_scaleMenu->addAction(i18n("200%"), this, SLOT(slotResize200())); m_scaleMenu->addAction(i18n("Original size"), this, SLOT(slotResizeOriginal())); m_scaleMenu->addAction(i18n("Custom"), this, SLOT(slotResizeCustom())); m_alignMenu = new QMenu(i18n("Align..."), this); configMenu->addMenu(m_alignMenu); m_alignMenu->addAction(i18n("Center"), this, SLOT(slotAlignCenter())); m_alignMenu->addAction(i18n("Hor. Center"), this, SLOT(slotAlignHCenter())); m_alignMenu->addAction(i18n("Vert. Center"), this, SLOT(slotAlignVCenter())); m_alignMenu->addAction(i18n("Right"), this, SLOT(slotAlignRight())); m_alignMenu->addAction(i18n("Left"), this, SLOT(slotAlignLeft())); m_alignMenu->addAction(i18n("Top"), this, SLOT(slotAlignTop())); m_alignMenu->addAction(i18n("Bottom"), this, SLOT(slotAlignBottom())); m_syncAction = configMenu->addAction(i18n("Sync timeline cursor"), this, SLOT(slotSyncCursor())); m_syncAction->setCheckable(true); m_syncAction->setChecked(KdenliveSettings::transitionfollowcursor()); //scene->setSceneRect(0, 0, profile.width * 2, profile.height * 2); //view->fitInView(m_frameBorder, Qt::KeepAspectRatio); const double sc = 100.0 / profile.height * 0.8; QRectF srect = view->sceneRect(); view->setSceneRect(srect.x(), -srect.height() / 3 + 10, srect.width(), srect.height() + srect.height() / 3 * 2 - 10); m_scene->setZoom(sc); view->centerOn(m_frameBorder); connect(m_ui.buttonNext , SIGNAL(clicked()) , this , SLOT(slotNextFrame())); connect(m_ui.buttonPrevious , SIGNAL(clicked()) , this , SLOT(slotPreviousFrame())); connect(m_ui.buttonDelete , SIGNAL(clicked()) , this , SLOT(slotDeleteFrame())); connect(m_ui.buttonAdd , SIGNAL(clicked()) , this , SLOT(slotAddFrame())); connect(m_scene, SIGNAL(actionFinished()), this, SLOT(slotUpdateTransitionProperties())); connect(m_scene, SIGNAL(doubleClickEvent()), this, SLOT(slotGeometry())); }
void MultiTouchListener::handleEvent( TUIO::TuioCursor* tcur, const QEvent::Type eventType ) { QGraphicsView* view = _graphicsViewProxy->getGraphicsView(); if( !view ) return; const QPoint& viewPos = view->mapToGlobal( view->pos()); const QRectF& sceneRect = view->sceneRect(); const int viewWidth = view->geometry().width(); const int viewHeight = view->geometry().height(); const qreal w = viewWidth / sceneRect.width(); const qreal h = viewHeight / sceneRect.height(); const int x = qreal(viewWidth - w) * .5; const int y = qreal(viewHeight - h) * .5; const QPoint sceneOffset( x, y ); const QPointF normPos( tcur->getX(), tcur->getY( )); const QPoint pos( w * normPos.x(), h * normPos.y( )); const QPoint screenPos( viewPos + sceneOffset + pos ); const QPoint wallPos( g_configuration->getTotalWidth() * tcur->getX(), g_configuration->getTotalHeight() * tcur->getY( )); QTouchEvent::TouchPoint touchPoint( tcur->getCursorID( )); touchPoint.setPressure( 1.0 ); touchPoint.setNormalizedPos( normPos ); touchPoint.setPos( wallPos ); // need for pan gesture recognition touchPoint.setScenePos( normPos ); touchPoint.setScreenPos( screenPos ); // need for hotspot & itemAt Qt::TouchPointStates touchPointStates = 0; if( tcur->getCursorID() == 0 ) touchPointStates |= Qt::TouchPointPrimary; switch( eventType ) { case QEvent::TouchBegin: touchPointStates = Qt::TouchPointPressed; touchPoint.setStartNormalizedPos( normPos ); touchPoint.setStartPos( touchPoint.pos( )); touchPoint.setStartScreenPos( screenPos ); touchPoint.setStartScenePos( touchPoint.scenePos( )); touchPoint.setLastNormalizedPos( normPos ); touchPoint.setLastPos( touchPoint.pos( )); touchPoint.setLastScreenPos( screenPos ); touchPoint.setLastScenePos( touchPoint.scenePos( )); break; case QEvent::TouchUpdate: case QEvent::TouchEnd: { if( eventType == QEvent::TouchUpdate ) touchPointStates = tcur->isMoving() ? Qt::TouchPointMoved : Qt::TouchPointStationary; else touchPointStates = Qt::TouchPointReleased; const QTouchEvent::TouchPoint& prevPoint = _touchPointMap.value( tcur->getCursorID( )); touchPoint.setStartNormalizedPos( prevPoint.startNormalizedPos( )); touchPoint.setStartPos( prevPoint.startPos( )); touchPoint.setStartScreenPos( prevPoint.startScreenPos( )); touchPoint.setStartScenePos( prevPoint.startScenePos( )); touchPoint.setLastNormalizedPos( prevPoint.normalizedPos( )); touchPoint.setLastPos( prevPoint.pos( )); touchPoint.setLastScreenPos( prevPoint.screenPos( )); touchPoint.setLastScenePos( prevPoint.scenePos( )); break; } default: put_flog( LOG_ERROR, "Got wrong touch event type %i", eventType ); return; } touchPoint.setState( touchPointStates ); _touchPointMap.insert( tcur->getCursorID(), touchPoint ); QEvent* touchEvent = new QTouchEvent( eventType, QTouchEvent::TouchScreen, Qt::NoModifier, touchPointStates, _touchPointMap.values( )); QApplication::postEvent( view->viewport(), touchEvent ); if( eventType == QEvent::TouchEnd ) _touchPointMap.remove( tcur->getCursorID( )); }