void OLSOntologyGraphView::mouseMoveEvent(QMouseEvent *event) { if (hasMouseTracking()) { emit mousePositionChangedSignal(event->pos()); } QGraphicsView::mouseMoveEvent(event); }
void Window::mouseDoubleClickEvent(QMouseEvent *e){ int s = list.size(); if ((e->buttons() & Qt::LeftButton) && tool.shape == Poly){addElement();} if (e->buttons() & Qt::RightButton){ for (int i = 0; i < s; i++){list[i].selected = 0;} if (hasMouseTracking() && tool.shape != None){ tool.ps.clear(); setMouseTracking(false); } update(); } }
void Window::mouseMoveEvent(QMouseEvent *e){ if (e->buttons() & Qt::RightButton){ QPoint qp = e->pos(); for (int i = list.size() - 1; i >= 0; i--){ if (list[i].selected){ for (int j = list[i].ps.size() - 1; j >= 0; j--){ list[i].ps[j] = list[i].ps[j] - mvpos + qp; } } } mvpos = qp; } if ((hasMouseTracking() && !(tool.shape == Curve && tool.ps.size() < 2)) || (e->buttons() & Qt::RightButton)){update();} }
void ImageDisplay::mouseMoveEvent(QMouseEvent *e) { if (e->buttons().testFlag(Qt::LeftButton)) { m_states.manhattan += (e->pos()-m_states.mousePrevPos).manhattanLength(); } m_states.mousePrevPos = e->pos(); if (!m_aScaling->isChecked()) { #if QT_VERSION < 0x040700 if (e->buttons().testFlag(Qt::MidButton)) { #else if (e->buttons().testFlag(Qt::MiddleButton)) { #endif // Move the viewport QPointF offset = m_states.mouseInitialImagePos - convertCanvasToPixel(e->pos()); m_imageOffset = offset; repaint(); } } if (hasMouseTracking() && !m_image.isNull()) { int x = e->pos().x() - contentsRect().x(); int y = e->pos().y() - contentsRect().y(); if (x < 0 || y < 0 || x >= contentsRect().width() || y >= contentsRect().height()) { // qDebug() << "Not inside drawing boundaries."; return; } QPointF pos = convertCanvasToImage(e->pos()); emit signalMouseMoved(pos.x(), pos.y()); } repaint(); } void ImageDisplay::mouseReleaseEvent(QMouseEvent *e) { QPointF p0 = m_states.mouseInitialImagePos; QPointF releasePos = convertCanvasToImage(e->pos()); QPointF minPoint = min(p0, releasePos, true); QPointF maxPoint = max(p0, releasePos, true); qDebug() << p0 << releasePos << minPoint << maxPoint; QRectF mouseRect(minPoint, maxPoint); if (m_states.countsAsMove()) { emit signalRectDrawn(mouseRect); } }
void fix() { QRect g = geometry(); QColor bg = backgroundColor(); bool mt = hasMouseTracking(); bool hascurs = testWFlags( WCursorSet ); QCursor curs = cursor(); clearWFlags( WState_Created ); clearWFlags( WState_Visible ); create( 0, TRUE, FALSE ); setGeometry(g); setBackgroundColor( bg ); setMouseTracking( mt ); if ( hascurs ) { setCursor( curs ); } }
SN_PointerUI::~SN_PointerUI() { _tcpMsgSock.disconnect(); // disconnect all signal/slot connections _fileTransferSemaphore.release(100); delete ui; if (fdialog) delete fdialog; if (hasMouseTracking()) releaseMouse(); if (_tcpMsgSock.state() == QAbstractSocket::ConnectingState) _tcpMsgSock.abort(); _tcpMsgSock.close(); if (_tcpDataSock.state() == QAbstractSocket::ConnectingState) _tcpDataSock.abort(); _tcpDataSock.close(); if (macCapture) { macCapture->kill(); // delete macCapture; // doesn't need because macCapture is a child Qt object macCapture->waitForFinished(-1); } if (_winCapture) { _winCapture->kill(); _winCapture->waitForFinished(-1); } if (_winCaptureServer) { _winCaptureServer->close(); } if (_winCapturePipe.isOpen()) { _winCapturePipe.close(); } qDebug() << "Good Bye"; }
void TVHBox::mouseMoveEvent(QMouseEvent *e) { if (hasMouseTracking()) emit mouseAt(e->pos()); }
int QWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 23) qt_static_metacall(this, _c, _id, _a); _id -= 23; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< bool*>(_v) = isModal(); break; case 1: *reinterpret_cast< Qt::WindowModality*>(_v) = windowModality(); break; case 2: *reinterpret_cast< bool*>(_v) = isEnabled(); break; case 3: *reinterpret_cast< QRect*>(_v) = geometry(); break; case 4: *reinterpret_cast< QRect*>(_v) = frameGeometry(); break; case 5: *reinterpret_cast< QRect*>(_v) = normalGeometry(); break; case 6: *reinterpret_cast< int*>(_v) = x(); break; case 7: *reinterpret_cast< int*>(_v) = y(); break; case 8: *reinterpret_cast< QPoint*>(_v) = pos(); break; case 9: *reinterpret_cast< QSize*>(_v) = frameSize(); break; case 10: *reinterpret_cast< QSize*>(_v) = size(); break; case 11: *reinterpret_cast< int*>(_v) = width(); break; case 12: *reinterpret_cast< int*>(_v) = height(); break; case 13: *reinterpret_cast< QRect*>(_v) = rect(); break; case 14: *reinterpret_cast< QRect*>(_v) = childrenRect(); break; case 15: *reinterpret_cast< QRegion*>(_v) = childrenRegion(); break; case 16: *reinterpret_cast< QSizePolicy*>(_v) = sizePolicy(); break; case 17: *reinterpret_cast< QSize*>(_v) = minimumSize(); break; case 18: *reinterpret_cast< QSize*>(_v) = maximumSize(); break; case 19: *reinterpret_cast< int*>(_v) = minimumWidth(); break; case 20: *reinterpret_cast< int*>(_v) = minimumHeight(); break; case 21: *reinterpret_cast< int*>(_v) = maximumWidth(); break; case 22: *reinterpret_cast< int*>(_v) = maximumHeight(); break; case 23: *reinterpret_cast< QSize*>(_v) = sizeIncrement(); break; case 24: *reinterpret_cast< QSize*>(_v) = baseSize(); break; case 25: *reinterpret_cast< QPalette*>(_v) = palette(); break; case 26: *reinterpret_cast< QFont*>(_v) = font(); break; case 27: *reinterpret_cast< QCursor*>(_v) = cursor(); break; case 28: *reinterpret_cast< bool*>(_v) = hasMouseTracking(); break; case 29: *reinterpret_cast< bool*>(_v) = isActiveWindow(); break; case 30: *reinterpret_cast< Qt::FocusPolicy*>(_v) = focusPolicy(); break; case 31: *reinterpret_cast< bool*>(_v) = hasFocus(); break; case 32: *reinterpret_cast< Qt::ContextMenuPolicy*>(_v) = contextMenuPolicy(); break; case 33: *reinterpret_cast< bool*>(_v) = updatesEnabled(); break; case 34: *reinterpret_cast< bool*>(_v) = isVisible(); break; case 35: *reinterpret_cast< bool*>(_v) = isMinimized(); break; case 36: *reinterpret_cast< bool*>(_v) = isMaximized(); break; case 37: *reinterpret_cast< bool*>(_v) = isFullScreen(); break; case 38: *reinterpret_cast< QSize*>(_v) = sizeHint(); break; case 39: *reinterpret_cast< QSize*>(_v) = minimumSizeHint(); break; case 40: *reinterpret_cast< bool*>(_v) = acceptDrops(); break; case 41: *reinterpret_cast< QString*>(_v) = windowTitle(); break; case 42: *reinterpret_cast< QIcon*>(_v) = windowIcon(); break; case 43: *reinterpret_cast< QString*>(_v) = windowIconText(); break; case 44: *reinterpret_cast< double*>(_v) = windowOpacity(); break; case 45: *reinterpret_cast< bool*>(_v) = isWindowModified(); break; case 46: *reinterpret_cast< QString*>(_v) = toolTip(); break; case 47: *reinterpret_cast< QString*>(_v) = statusTip(); break; case 48: *reinterpret_cast< QString*>(_v) = whatsThis(); break; case 49: *reinterpret_cast< QString*>(_v) = accessibleName(); break; case 50: *reinterpret_cast< QString*>(_v) = accessibleDescription(); break; case 51: *reinterpret_cast< Qt::LayoutDirection*>(_v) = layoutDirection(); break; case 52: *reinterpret_cast< bool*>(_v) = autoFillBackground(); break; case 53: *reinterpret_cast< QString*>(_v) = styleSheet(); break; case 54: *reinterpret_cast< QLocale*>(_v) = locale(); break; case 55: *reinterpret_cast< QString*>(_v) = windowFilePath(); break; case 56: *reinterpret_cast< Qt::InputMethodHints*>(_v) = inputMethodHints(); break; } _id -= 57; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 1: setWindowModality(*reinterpret_cast< Qt::WindowModality*>(_v)); break; case 2: setEnabled(*reinterpret_cast< bool*>(_v)); break; case 3: setGeometry(*reinterpret_cast< QRect*>(_v)); break; case 8: move(*reinterpret_cast< QPoint*>(_v)); break; case 10: resize(*reinterpret_cast< QSize*>(_v)); break; case 16: setSizePolicy(*reinterpret_cast< QSizePolicy*>(_v)); break; case 17: setMinimumSize(*reinterpret_cast< QSize*>(_v)); break; case 18: setMaximumSize(*reinterpret_cast< QSize*>(_v)); break; case 19: setMinimumWidth(*reinterpret_cast< int*>(_v)); break; case 20: setMinimumHeight(*reinterpret_cast< int*>(_v)); break; case 21: setMaximumWidth(*reinterpret_cast< int*>(_v)); break; case 22: setMaximumHeight(*reinterpret_cast< int*>(_v)); break; case 23: setSizeIncrement(*reinterpret_cast< QSize*>(_v)); break; case 24: setBaseSize(*reinterpret_cast< QSize*>(_v)); break; case 25: setPalette(*reinterpret_cast< QPalette*>(_v)); break; case 26: setFont(*reinterpret_cast< QFont*>(_v)); break; case 27: setCursor(*reinterpret_cast< QCursor*>(_v)); break; case 28: setMouseTracking(*reinterpret_cast< bool*>(_v)); break; case 30: setFocusPolicy(*reinterpret_cast< Qt::FocusPolicy*>(_v)); break; case 32: setContextMenuPolicy(*reinterpret_cast< Qt::ContextMenuPolicy*>(_v)); break; case 33: setUpdatesEnabled(*reinterpret_cast< bool*>(_v)); break; case 34: setVisible(*reinterpret_cast< bool*>(_v)); break; case 40: setAcceptDrops(*reinterpret_cast< bool*>(_v)); break; case 41: setWindowTitle(*reinterpret_cast< QString*>(_v)); break; case 42: setWindowIcon(*reinterpret_cast< QIcon*>(_v)); break; case 43: setWindowIconText(*reinterpret_cast< QString*>(_v)); break; case 44: setWindowOpacity(*reinterpret_cast< double*>(_v)); break; case 45: setWindowModified(*reinterpret_cast< bool*>(_v)); break; case 46: setToolTip(*reinterpret_cast< QString*>(_v)); break; case 47: setStatusTip(*reinterpret_cast< QString*>(_v)); break; case 48: setWhatsThis(*reinterpret_cast< QString*>(_v)); break; case 49: setAccessibleName(*reinterpret_cast< QString*>(_v)); break; case 50: setAccessibleDescription(*reinterpret_cast< QString*>(_v)); break; case 51: setLayoutDirection(*reinterpret_cast< Qt::LayoutDirection*>(_v)); break; case 52: setAutoFillBackground(*reinterpret_cast< bool*>(_v)); break; case 53: setStyleSheet(*reinterpret_cast< QString*>(_v)); break; case 54: setLocale(*reinterpret_cast< QLocale*>(_v)); break; case 55: setWindowFilePath(*reinterpret_cast< QString*>(_v)); break; case 56: setInputMethodHints(*reinterpret_cast< Qt::InputMethodHints*>(_v)); break; } _id -= 57; } else if (_c == QMetaObject::ResetProperty) { switch (_id) { case 27: unsetCursor(); break; case 51: unsetLayoutDirection(); break; case 54: unsetLocale(); break; } _id -= 57; } else if (_c == QMetaObject::QueryPropertyDesignable) { bool *_b = reinterpret_cast<bool*>(_a[0]); switch (_id) { case 41: *_b = isWindow(); break; case 42: *_b = isWindow(); break; case 43: *_b = isWindow(); break; case 44: *_b = isWindow(); break; case 45: *_b = isWindow(); break; case 55: *_b = isWindow(); break; } _id -= 57; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 57; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 57; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 57; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 57; } #endif // QT_NO_PROPERTIES return _id; }
void Window::paintEvent(QPaintEvent *){ QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing, true); int s = list.size(); for (int i = 0; i < s; i++){ if (list[i].selected){painter.setPen(QPen(Qt::red, list[i].width, Qt::SolidLine));}else{painter.setPen(QPen(Qt::black, list[i].width, Qt::SolidLine));} if (list[i].fill && list[i].shape != Curve){painter.setBrush(QBrush(Qt::white));}else{painter.setBrush(Qt::NoBrush);} if (list[i].shape == Line){ painter.drawLine(list[i].ps[0],list[i].ps[1]); }else if (list[i].shape == Poly || list[i].shape == Diamond){ painter.drawPolygon(list[i].ps.constData(), list[i].ps.size()); }else if (list[i].shape == Circle){ int r = qSqrt(qPow(list[i].ps[0].x()-list[i].ps[1].x(), 2)+qPow(list[i].ps[0].y()-list[i].ps[1].y(), 2)); painter.drawEllipse(list[i].ps[0], r, r); }else if (list[i].shape == Curve){ QPainterPath path; path.moveTo(list[i].ps[0]); path.cubicTo(list[i].ps[0], list[i].ps[2], list[i].ps[1]); painter.drawPath(path); } } if (hasMouseTracking()){ QPoint qp = Window::mapFromGlobal(QCursor::pos()); painter.setPen(QPen(Qt::gray, tool.width, Qt::DashLine)); if (tool.fill && tool.shape != Curve){painter.setBrush(QBrush(Qt::white));}else{painter.setBrush(Qt::NoBrush);} if (tool.shape == Line){ painter.drawLine(tool.ps.last(), qp); }else if (tool.shape == Poly){ tool.ps.append(qp); painter.drawPolygon(tool.ps.constData(), tool.ps.size()); tool.ps.removeLast(); }else if (tool.shape == Diamond){ tool.ps.append(qp); tool.ps.append(QPoint(2*qp.x()-tool.ps[0].x(), tool.ps[0].y())); tool.ps.append(QPoint(qp.x(), 2*tool.ps[0].y()-qp.y())); painter.drawPolygon(tool.ps.constData(), tool.ps.size()); for (int i = 3; i > 0; i--){tool.ps.removeLast();} }else if (tool.shape == Circle){ int r = qSqrt(qPow(tool.ps[0].x()-qp.x(), 2)+qPow(tool.ps[0].y()-qp.y(), 2)); painter.drawEllipse(tool.ps[0], r, r); }else if (tool.shape == Curve){ QPainterPath path; path.moveTo(tool.ps[0]); path.cubicTo(tool.ps[0], qp, tool.ps[1]); painter.drawPath(path); }else if (tool.shape == None && pressed){ painter.setBrush(Qt::NoBrush); painter.setPen(QPen(Qt::gray, 1, Qt::SolidLine)); for (int i = 0; i < s; i++){ for (int j = list[i].ps.size() - 1; j >=0; j--){ painter.drawEllipse(list[i].ps[j], 3, 3); } } painter.setPen(QPen(Qt::gray, 1, Qt::DotLine)); QPoint lt = QPoint(qMin(qp.x(), tool.ps.last().x()), qMin(qp.y(), tool.ps.last().y())); QPoint rb = QPoint(qMax(qp.x(), tool.ps.last().x()), qMax(qp.y(), tool.ps.last().y())); painter.drawRect(lt.x(), lt.y(), qAbs(lt.x()-rb.x()), qAbs(lt.y()-rb.y())); } } painter.end(); }
void Window::keyPressEvent(QKeyEvent* event){ int key = event->key(); int s = list.size(); if (key == Qt::Key_H){ QMessageBox::about(this,tr("Help"),tr( "VGedit :: rev.1\n\nKeys:\n[1] Select\n[2] Line\n" "[3] Polygon (doubleclick to finish)\n[4] Rhombus\n[5] Circle\n" "[6] Curved line (3 points)\n[F]ill toggle\n[C]lone selected objects\n[Del]ete selected objects\n" "[Esc] Stop drawing / remove selection\n[O]pen / [S]ave file\n" "[ArrowUP] Increase width\n[ArrowDOWN] Decrease width\n\nAlex Y & Max Ch")); }else if (key == Qt::Key_O){ QString fileName = QFileDialog::getOpenFileName(this, tr("Open"), "", tr("VG file (*.vg)")); if (!fileName.isNull()){ QFile file(fileName); if (file.open(QIODevice::ReadOnly)){ QTextStream io(&file); list.clear(); while (!io.atEnd()){ QString line = io.readLine(); QStringList core = line.split(";"); if (core.size() != 4){continue;} item temp; temp.shape = (Shape)core[0].toInt(); temp.selected = 0; temp.width = core[1].toInt(); temp.fill = core[2].toInt(); QStringList points = core[3].split(" "); for (int i = 0; i < points.size(); i++){ QStringList xy = points[i].split(","); if (xy.size() == 2){ temp.ps.append(QPoint(xy[0].toInt(),xy[1].toInt())); } } if (((temp.shape == Line || temp.shape == Poly || temp.shape == Diamond || temp.shape == Circle) && temp.ps.size() > 1) || (temp.shape == Curve && temp.ps.size() > 2)){list.append(temp);} } file.close(); update(); }else{QMessageBox::critical(this, tr("Error"), tr("Can't open this file"));} } }else if (key == Qt::Key_S){ QString fileName = QFileDialog::getSaveFileName(this, tr("Save"), "", tr("VG file (*.vg)")); if (!fileName.isNull()){ QFile file(fileName); if (file.open(QIODevice::WriteOnly)){ QTextStream io(&file); for (int i = 0; i < s; i++){ io << QString("%1;%2;%3;").arg(list[i].shape).arg(list[i].width).arg(list[i].fill); int p = list[i].ps.size(); for (int j = 0; j < p; j++){ io << QString("%1,%2 ").arg(list[i].ps[j].x()).arg(list[i].ps[j].y()); } io << QString("\n"); } file.close(); QMessageBox::information(this, tr("Save"), tr("File saved")); }else{QMessageBox::critical(this, tr("Error"), tr("Can't write this file"));} } }else if (key == Qt::Key_Escape){ for (int i = 0; i < s; i++){list[i].selected = 0;} if (hasMouseTracking() && tool.shape != None){ tool.ps.clear(); setMouseTracking(false); } update(); }else if (key == Qt::Key_Delete){ for (int i = 0; i < s; i++){if (list[i].selected){list.remove(i); i--; s--;}} update(); }else if (key == Qt::Key_C){ for (int i = 0; i < s; i++){if (list[i].selected){list.append(list[i]); list[i].selected = 0;}} update(); }else if (key == Qt::Key_Up && tool.width < 16){tool.width++;} else if (key == Qt::Key_Down && tool.width > 1){tool.width--;} else if (key == Qt::Key_F){tool.fill = !tool.fill;} else if (key == Qt::Key_1){tool.shape = None;} else if (key == Qt::Key_2){tool.shape = Line;} else if (key == Qt::Key_3){tool.shape = Poly;} else if (key == Qt::Key_4){tool.shape = Diamond;} else if (key == Qt::Key_5){tool.shape = Circle;} else if (key == Qt::Key_6){tool.shape = Curve;} if (key >= 0x31 && key <= 0x36){ tool.ps.clear(); update(); setMouseTracking(false); } setNewTitle(); }