KisGridConfig GridConfigWidget::fetchGuiGridConfig() const { KisGridConfig config; config.setShowGrid(ui->chkShowGrid->isChecked()); config.setSnapToGrid(ui->chkSnapToGrid->isChecked()); QPoint pt; pt.rx() = ui->intHSpacing->value(); pt.ry() = ui->intVSpacing->value(); config.setSpacing(pt); pt.rx() = ui->intXOffset->value(); pt.ry() = ui->intYOffset->value(); config.setOffset(pt); config.setSubdivision(ui->intSubdivision->value()); config.setOffsetAspectLocked(ui->offsetAspectButton->keepAspectRatio()); config.setSpacingAspectLocked(ui->spacingAspectButton->keepAspectRatio()); config.setLineTypeMain(KisGridConfig::LineTypeInternal(ui->selectMainStyle->currentIndex())); config.setLineTypeSubdivision(KisGridConfig::LineTypeInternal(ui->selectSubdivisionStyle->currentIndex())); config.setColorMain(ui->colorMain->color()); config.setColorSubdivision(ui->colorSubdivision->color()); return config; }
MapEditorPopup::MapEditorPopup(QPoint pos,QPointF value, int i,QWidget * parent) :QWidget(parent) // :QWidget(parent,Qt::Popup) // :QDialog(parent,Qt::Popup) { index = i; pos.rx() += 5; pos.ry() -= 5; QGridLayout * layout = new QGridLayout; layout->addWidget(new QLabel("Iteration:"),1,0); xEdit = new QLineEdit; xEdit->setText(QString::number(value.x(),'g',6)); xEdit->setMaximumWidth(80); QDoubleValidator * sv = new QDoubleValidator(xEdit); sv->setNotation(QDoubleValidator::ScientificNotation); xEdit->setValidator(sv); layout->addWidget(xEdit,1,1); layout->addWidget(new QLabel("Value:"),0,0); yEdit = new QLineEdit; yEdit->setText(QString::number(value.y(),'g',6)); yEdit->setMaximumWidth(80); sv = new QDoubleValidator(yEdit); sv->setNotation(QDoubleValidator::ScientificNotation); yEdit->setValidator(sv); layout->addWidget(yEdit,0,1); setLayout(layout); pos.ry() -= sizeHint().height()/2; // move(parent->mapToGlobal(pos)); move(pos); xEdit->setFocus(Qt::ActiveWindowFocusReason); // setAttribute(Qt::WA_DeleteOnClose,true); }
void AdmScrollAreaSmoothDrag::sDragEnterEvent(AdmExtensionWidget *obj, QDragEnterEvent *event) { // Make sure the timer is not going and we are scrollable if(_timer == NULL && _scrollDir == ScrollOff && verticalScrollBar()->isVisible() && height() >= ScrollMinHeight) { // Get the mouse position _pointDragMoveEvent = mapTo(this,event->pos()); QPoint eventPos = event->pos(); // Determine the region of the mouse position if((eventPos.ry()+obj->y())-verticalScrollBar()->value() <= ScrollRegionHeight) { // Test for upper region and start the scroll timer scrolling up _scrollDir = ScrollUp; _timer = new QTimer(); connect(_timer,SIGNAL(timeout()),this,SLOT(sTickTock())); _timer->start(ScrollTimerTimout); } else if (rect().height() + verticalScrollBar()->value() - (eventPos.ry()+obj->y()) <= ScrollRegionHeight) { // Test for lower region and start the scroll timer scrolling down _scrollDir = ScrollDown; _timer = new QTimer(); connect(_timer,SIGNAL(timeout()),this,SLOT(sTickTock())); _timer->start(ScrollTimerTimout); } } }
void SyszuxIM::updateHandler(int type) { switch(type) { case QWSInputMethod::FocusIn: { QWidget *currentWidget = new QWidget; QWidget *parentWidget = new QWidget; currentWidget = QApplication::focusWidget(); parentWidget = currentWidget->parentWidget(); QPoint globalPoint (currentWidget->mapToGlobal(QPoint(0,0))); // 获取控件在窗体中的坐标 QPoint parentGlobalPoint (parentWidget->mapToGlobal(QPoint(0,0))); if ( globalPoint.ry() > 239) //输入法遮挡了当前要输入的窗口部件 { widgetMoveY = globalPoint.ry() - 239 + parentGlobalPoint.ry(); parentWidget->move(0,-widgetMoveY); // qDebug() << "move"<<(-widgetMoveY); } syszuxpinyin->show(); } break; case QWSInputMethod::FocusOut: { syszuxpinyin->hide(); } break; default: break; } }
void Oubliette::keyPressEvent(QKeyEvent *ke) { QPoint newPos = m_character.position(); switch (ke->key()) { case Qt::Key_Up: case Qt::Key_K: newPos.ry() -= 1; break; case Qt::Key_Down: case Qt::Key_J: newPos.ry() += 1; break; case Qt::Key_Left: case Qt::Key_H: newPos.rx() -= 1; break; case Qt::Key_Right: case Qt::Key_L: newPos.rx() += 1; break; case Qt::Key_I: showInventory(); break; default: QWidget::keyPressEvent(ke); } if (tryMove(newPos)) { QRect r(QPoint((newPos.x() - 8) * TileWidth, (newPos.y() - 8) * TileHeight), QSize(24 * TileWidth, 24 * TileHeight)); update(r); emit characterMoved(visualCursorPos()); } }
void TimeLine::wheelEvent(QWheelEvent* event) { QPoint numPixels = event->pixelDelta(); QPoint numDegrees = event->angleDelta() / 8; int isForward =0; if (!numPixels.isNull()) { if (numPixels.ry()>0) isForward =1; else if (numPixels.ry()<0) isForward =-1; } else if (!numDegrees.isNull()) { if (numDegrees.ry()>0) isForward =1; else if (numDegrees.ry()<0) isForward =-1; } if (isForward >0) mVScrollbar->triggerAction(QAbstractSlider::SliderSingleStepAdd); else if (isForward <0) mVScrollbar->triggerAction(QAbstractSlider::SliderSingleStepSub); else { //Do nothing we've had a wheel event where we are neither going forward or backward //which should never happen? } event->accept(); }
void Canvas::drawGraph(int n) { pixmap.fill(Qt::white); QPainter painter(&pixmap); painter.setRenderHint(QPainter::Antialiasing, true); const int R = 3; std::vector<QPoint> points = getPoints(n); painter.setPen(QPen(QBrush(Qt::black), 0.5)); for (size_t i = 0; i < points.size(); ++i) { for (size_t j = i; j < points.size(); ++j) { painter.drawLine(points[i], points[j]); } } painter.setPen(Qt::black); painter.setBrush(QBrush(Qt::black)); for (size_t i = 0; i < points.size(); ++i) { painter.drawEllipse(points[i].rx() - R, points[i].ry() - R, 2*R, 2*R); QPoint c = geometry().center(); int labelX = (int)(1.12*(points[i].rx() - c.rx())) + c.rx() - 4; int labelY = (int)(1.12*(points[i].ry() - c.ry())) + c.ry() + 5; painter.drawText(QPoint(labelX, labelY), QString("%1").arg(i)); } }
void OBSBasic::on_volCtrlBtn_released() { QPoint pt = QCursor::pos(); //悬浮在鼠标上方的位置 pt.setY(pt.ry() - ui->volCtrlBtn->height() / 2); m_pHoverVolCtrlWidget->ShowAt(pt.rx(), pt.ry()); }
QPoint GeneralManager::getPatchCoordinate(QPointF scenePoint){ QPoint patchCoordinate; int patchSizeMinusOverlap = parameter.patchSizeLower - parameter.OverlapSizeLower; patchCoordinate.setX(scenePoint.rx()/patchSizeMinusOverlap); patchCoordinate.setY(scenePoint.ry()/patchSizeMinusOverlap); int PatchStepLower = parameter.patchSizeLower - parameter.OverlapSizeLower; int NumWidLower = (parameter.imageCol- parameter.patchSizeLower)/PatchStepLower + 1; int NumHeiLower = (parameter.imageRol- parameter.patchSizeLower)/PatchStepLower + 1; //compute too Right and too Bottom case cout << "too Right? " << patchCoordinate.rx() << "/\n";// << Sketch->NumWidLower - 1 << endl; if (patchCoordinate.rx() > NumWidLower - 1){ //cout << "At too Right" << endl; patchCoordinate.setX(NumWidLower - 1); } cout << "too Bottom? " << patchCoordinate.ry() << "/\n";// << Sketch->NumHeiLower - 1 << endl; if (patchCoordinate.ry() > NumHeiLower - 1){ //cout << "At too Bottom" << endl; patchCoordinate.setY(NumHeiLower - 1); } return patchCoordinate; }
void SourceImage::mouseMoveEvent(QMouseEvent *event) { if(event->buttons() &Qt::LeftButton) { if(boundary.isEmpty()) { boundary<<event->pos(); return; } QPoint oldpos = boundary.last(); QPoint newpos = event->pos(); qDebug()<<event->pos(); if(((oldpos.rx()-newpos.rx())<=1) &&((oldpos.rx()-newpos.rx())>=-1) &&((oldpos.ry()-newpos.ry())<=1) &&((oldpos.ry()-newpos.ry())>=-1)) boundary<<newpos; else { linkPoint(oldpos, newpos); boundary<<newpos; } this->update(); } }
void SegmentTip::moveTo(QPoint p, QWidget &canvas, bool placeAbove) { //**** this function is very slow and seems to be visibly influenced by operations like mapFromGlobal() (who knows why!) // ** so any improvements are much desired //TODO uints could improve the class p.rx() -= rect().center().x(); p.ry() -= (placeAbove ? 8 + height() : m_cursorHeight - 8); const QRect screen = KGlobalSettings::desktopGeometry(parentWidget()); const int x = p.x(); const int y = p.y(); const int x2 = x + width(); const int y2 = y + height(); //how's it ever gunna get below screen height?! (well you never know I spose) const int sw = screen.width(); const int sh = screen.height(); if (x < 0 ) p.setX(0); if (y < 0 ) p.setY(0); if (x2 > sw) p.rx() -= x2 - sw; if (y2 > sh) p.ry() -= y2 - sh; //I'm using this QPoint to determine where to offset the bitBlt in m_pixmap QPoint offset = canvas.mapToGlobal(QPoint()) - p; if (offset.x() < 0) offset.setX(0); if (offset.y() < 0) offset.setY(0); const QRect alphaMaskRect(canvas.mapFromGlobal(p), size()); const QRect intersection(alphaMaskRect.intersect(canvas.rect())); m_pixmap = QPixmap(size()); //move to updateTip once you are sure it can never be null const QColor c = QToolTip::palette().color(QPalette::Active, QPalette::Background); if (!m_backing_store) m_pixmap.fill(c); QPainter paint(&m_pixmap); paint.setPen(Qt::black); paint.setBrush(Qt::NoBrush); paint.drawRect(rect()); paint.end(); /* if (m_backing_store) m_pixmap = QPixmap::fromImage(Blitz::fade(m_pixmap.toImage() , 0.6f, c)); */ // TODO: reimplement this paint.begin(&m_pixmap); paint.drawText(rect(), Qt::AlignCenter, m_text); paint.end(); p += screen.topLeft(); //for Xinerama users move(x, y); show(); update(); }
void BbVideoWindowControl::updateVideoPosition() { if (m_context && m_videoId != -1 && m_widget) { QPoint topLeft = m_fullscreen ? QPoint(0,0) : m_widget->mapToGlobal(m_displayRect.topLeft()); int width = m_fullscreen ? QApplication::desktop()->width() : m_displayRect.width(); int height = m_fullscreen ? QApplication::desktop()->height() : m_displayRect.height(); if (m_metaData.hasVideo()) { // We need the source size to do aspect ratio scaling const qreal sourceRatio = m_metaData.width() / static_cast<float>(m_metaData.height()); const qreal targetRatio = width / static_cast<float>(height); if (m_aspectRatioMode == Qt::KeepAspectRatio) { if (targetRatio < sourceRatio) { // Need to make height smaller const int newHeight = width / sourceRatio; const int heightDiff = height - newHeight; topLeft.ry() += heightDiff / 2; height = newHeight; } else { // Need to make width smaller const int newWidth = sourceRatio * height; const int widthDiff = width - newWidth; topLeft.rx() += widthDiff / 2; width = newWidth; } } else if (m_aspectRatioMode == Qt::KeepAspectRatioByExpanding) { if (targetRatio < sourceRatio) { // Need to make width larger const int newWidth = sourceRatio * height; const int widthDiff = newWidth - width; topLeft.rx() -= widthDiff / 2; width = newWidth; } else { // Need to make height larger const int newHeight = width / sourceRatio; const int heightDiff = newHeight - height; topLeft.ry() -= heightDiff / 2; height = newHeight; } } } if (m_window != 0) { const int position[2] = { topLeft.x(), topLeft.y() }; const int size[2] = { width, height }; if (screen_set_window_property_iv(m_window, SCREEN_PROPERTY_POSITION, position) != 0) perror("Setting video position failed"); if (screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SIZE, size) != 0) perror("Setting video size failed"); } } }
/* * whether the mouse is on the window */ bool MainWindow::isMouseInsideWindow(QPoint p) { int left=this->geometry().x(); int right=left+this->width(); int top=this->geometry().y(); int bottom=top+this->height(); if(p.rx()>=left && p.rx()<=right) if(p.ry()>=top && p.ry()<=bottom) return true; return false; }
int Field::count_neighbour_bombs(QPoint pt) { int neighbours = 0; for (int dy = -1; dy <= 1; ++dy) for (int dx = -1; dx <= 1; ++dx) if (cells[pt.ry() + dy][pt.rx() + dx] != nullptr && !(cells[pt.ry() + dy][pt.rx() + dx]->empty())) { neighbours++; } return neighbours; }
void QAbstractKineticScrollerPrivate::checkMove(QMouseEvent *me, QPoint &delta) { Q_Q(QAbstractKineticScroller); if (firstDrag && !moved && ((qAbs(delta.x()) > panningThreshold) || (qAbs(delta.y()) > panningThreshold))) { moved = true; // ignore the panning distance if (delta.x() > panningThreshold) delta.rx() -= panningThreshold; else if (delta.x() < -panningThreshold) delta.rx() += panningThreshold; else delta.setX(0); if (delta.y() > panningThreshold) delta.ry() -= panningThreshold; else if (delta.y() < -panningThreshold) delta.ry() += panningThreshold; else delta.setY(0); if (firstDrag) { int deltaXtoY = qAbs(ipos.x() - me->globalPos().x()) - qAbs(ipos.y() - me->globalPos().y()); qKSDebug() << "First Drag with delta " << delta << ", greater than " << panningThreshold << " -- deltaXtoY: " << deltaXtoY; QPoint maxPos = q->maximumScrollPosition(); bool canScrollX = (maxPos.x() > 0); bool canScrollY = (maxPos.y() > 0); if ((!canScrollX || !canScrollY) && (overshootPolicy == QAbstractKineticScroller::OvershootAlwaysOn)) canScrollX = canScrollY = true; if (deltaXtoY < 0) { if (!canScrollY && (!canScrollX || (-deltaXtoY >= directionErrorMargin))) moved = false; } else { if (!canScrollX && (!canScrollY || (deltaXtoY >= directionErrorMargin))) moved = false; } } firstDrag = false; if (moved && (mode == QAbstractKineticScroller::AccelerationMode)) { if (!idleTimerId) { changeState(QAbstractKineticScroller::AutoScrolling); idleTimerId = startTimer(1000 / scrollsPerSecond); } } } }
QRect GeneralManager::getPatchRect(QPoint patchCoordinate){ int patchSizeMinusOverlap = parameter.patchSizeLower - parameter.OverlapSizeLower; QPoint topLeft; QPoint bottomRight; topLeft.setX(patchCoordinate.rx() * patchSizeMinusOverlap); topLeft.setY(patchCoordinate.ry() * patchSizeMinusOverlap); bottomRight.setX(parameter.patchSizeLower + topLeft.rx()); bottomRight.setY(parameter.patchSizeLower + topLeft.ry()); QRect returnRect(topLeft, bottomRight); return returnRect; }
void OSDPreviewWidget::mouseMoveEvent( QMouseEvent *e ) { if( m_dragging && this == mouseGrabber() ) { // Here we implement a "snap-to-grid" like positioning system for the preview widget const QRect screenRect = QApplication::desktop()->screenGeometry( screen() ); const uint hcenter = screenRect.width() / 2; const uint eGlobalPosX = e->globalPos().x() - screenRect.left(); const uint snapZone = screenRect.width() / 24; QPoint destination = e->globalPos() - m_dragOffset - screenRect.topLeft(); int maxY = screenRect.height() - height() - MARGIN; if( destination.y() < MARGIN ) destination.ry() = MARGIN; if( destination.y() > maxY ) destination.ry() = maxY; if( eGlobalPosX < ( hcenter - snapZone ) ) { setAlignment(Left); destination.rx() = MARGIN; } else if( eGlobalPosX > ( hcenter + snapZone ) ) { setAlignment(Right); destination.rx() = screenRect.width() - MARGIN - width(); } else { const uint eGlobalPosY = e->globalPos().y() - screenRect.top(); const uint vcenter = screenRect.height() / 2; destination.rx() = hcenter - width() / 2; if( eGlobalPosY >= ( vcenter - snapZone ) && eGlobalPosY <= ( vcenter + snapZone ) ) { setAlignment(Center); destination.ry() = vcenter - height() / 2; } else setAlignment(Middle); } destination += screenRect.topLeft(); move( destination ); } }
void ToolTip::placeTip(const QPoint &pos, QWidget *w) { QRect screen = Internal::screenGeometry(pos, w); QPoint p = pos; p += QPoint(2, #ifdef Q_WS_WIN 21 #else 16 #endif ); if (p.x() + m_tip->width() > screen.x() + screen.width()) p.rx() -= 4 + m_tip->width(); if (p.y() + m_tip->height() > screen.y() + screen.height()) p.ry() -= 24 + m_tip->height(); if (p.y() < screen.y()) p.setY(screen.y()); if (p.x() + m_tip->width() > screen.x() + screen.width()) p.setX(screen.x() + screen.width() - m_tip->width()); if (p.x() < screen.x()) p.setX(screen.x()); if (p.y() + m_tip->height() > screen.y() + screen.height()) p.setY(screen.y() + screen.height() - m_tip->height()); m_tip->move(p); }
QUML_BEGIN_NAMESPACE_GW Popover::Popover(QWidget* parent, QPoint pos, Qt::Orientation orientation) : QWidget(parent), mLayout(new QVBoxLayout()) { setWindowFlags(Qt::Popup | Qt::Window | Qt::CustomizeWindowHint); setAttribute(Qt::WA_DeleteOnClose); mMouse = pos; mOrientation = orientation; // Slightly shift the origin for looks. if(mOrientation == Qt::Horizontal) { pos.ry() -= 26; } else { pos.rx() -= 26; } mPos = pos; setWindowOpacity(0.85); setLayout(mLayout); mLayout->setAlignment(Qt::AlignTop); setFocus(); }
void LapsusOSD::reposition( QSize newSize ) { if( !newSize.isValid() ) newSize = size(); QPoint newPos = _position; const QRect& screen = QApplication::desktop()->screenGeometry( _screen ); // now to properly resize if put into one of the corners we interpret the position // depending on the quadrant int midH = screen.width()/2; int midV = screen.height()/2; if( newPos.x() > midH ) newPos.rx() -= newSize.width(); if( newPos.y() > midV ) newPos.ry() -= newSize.height(); newPos = fixupPosition( newPos ); // correct for screen position newPos += screen.topLeft(); // ensure we are painted before we move if( isVisible() ) paintEvent( 0 ); // fancy X11 move+resize, reduces visual artifacts XMoveResizeWindow( x11Display(), winId(), newPos.x(), newPos.y(), newSize.width(), newSize.height() ); }
void GTUtilsMSAEditorSequenceArea::selectArea(HI::GUITestOpStatus &os, QPoint p1, QPoint p2) { MSAEditorSequenceArea *msaEditArea = qobject_cast<MSAEditorSequenceArea*>(GTWidget::findWidget(os, "msa_editor_sequence_area", GTUtilsMdi::activeWindow(os))); GT_CHECK(msaEditArea != NULL, "MsaEditorSequenceArea not found"); p1.rx() = p1.x()==-1 ? msaEditArea->getNumVisibleBases(true)-1 : p1.x(); p2.rx() = p2.x()==-1 ? msaEditArea->getNumVisibleBases(true)-1 : p2.x(); p1.ry() = p1.y()==-1 ? msaEditArea->getNumVisibleSequences(true)-1 : p1.y(); p2.ry() = p2.y()==-1 ? msaEditArea->getNumVisibleSequences(true)-1 : p2.y(); moveTo(os, p1); GTMouseDriver::press(); GTMouseDriver::moveTo(convertCoordinates(os,p2)); GTMouseDriver::release(); GTGlobals::sleep(1000); }
QPoint QxtToolTipPrivate::calculatePos(int scr, const QPoint& eventPos) const { #ifdef Q_WS_MAC QRect screen = QApplication::desktop()->availableGeometry(scr); #else QRect screen = QApplication::desktop()->screenGeometry(scr); #endif QPoint p = eventPos; p += QPoint(2, #ifdef Q_WS_WIN 24 #else 16 #endif ); QSize s = sizeHint(); if (p.x() + s.width() > screen.x() + screen.width()) p.rx() -= 4 + s.width(); if (p.y() + s.height() > screen.y() + screen.height()) p.ry() -= 24 + s.height(); if (p.y() < screen.y()) p.setY(screen.y()); if (p.x() + s.width() > screen.x() + screen.width()) p.setX(screen.x() + screen.width() - s.width()); if (p.x() < screen.x()) p.setX(screen.x()); if (p.y() + s.height() > screen.y() + screen.height()) p.setY(screen.y() + screen.height() - s.height()); return p; }
QPoint FitRect (QPoint pos, const QSize& size, const QRect& geometry, FitFlags flags, const QPoint& shiftAdd) { int xDiff = std::max (0, pos.x () + size.width () - (geometry.width () + geometry.x ())); if (!xDiff) xDiff = std::min (0, pos.x () - geometry.x ()); int yDiff = std::max (0, pos.y () + size.height () - (geometry.height () + geometry.y ())); if (!yDiff) yDiff = std::min (0, pos.y () - geometry.y ()); if (flags & FitFlag::NoOverlap) { auto overlapFixer = [] (int& diff, int dim) { if (diff > 0) diff = dim > diff ? dim : diff; }; if (QRect (pos - QPoint (xDiff, yDiff), size).contains (pos) && yDiff < size.height ()) overlapFixer (yDiff, size.height ()); if (QRect (pos - QPoint (xDiff, yDiff), size).contains (pos) && xDiff < size.width ()) overlapFixer (xDiff, size.width ()); } if (xDiff) pos.rx () -= xDiff + shiftAdd.x (); if (yDiff) pos.ry () -= yDiff + shiftAdd.y (); return pos; }
void AdmToolBoxSmoothDrag::sDelayedDragMoveEvent() { // Make sure the timer is valid and we have a mouse position. if(NULL != _timer && _pointDragMoveEvent.isNull() == false) { // Stop the timer disconnect(_timer,SIGNAL(timeout()),this,SLOT(sDelayedDragMoveEvent())); _timer->stop(); // Loop through the buttons of this widget and determine which button the // mouse is hovering over. The x value should be the widget location in this // QToolBox object int x = -1; foreach(QAbstractButton *btn, findChildren<QAbstractButton *>()) { ++x; // Determine the button's region in relation to this QToolBox object QPoint mp = mapTo(this, btn->pos()); QRect r( mp.rx(), mp.ry(), btn->rect().width(), btn->rect().height() ); // If the mouse position is hovering over this button, then select this // widget (x) and break out of the loop if(r.contains(_pointDragMoveEvent,false)) { setCurrentWidget(widget(x)); break; } }
//Caculate the click location using one of the sixense controllers. Scale is not applied QPoint ApplicationCompositor::getPalmClickLocation(const PalmData *palm) const { QPoint rv; auto canvasSize = qApp->getCanvasSize(); if (qApp->isHMDMode()) { glm::vec2 polar = getPolarCoordinates(*palm); glm::vec2 point = sphericalToScreen(-polar); rv.rx() = point.x; rv.ry() = point.y; } else { MyAvatar* myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar(); glm::dmat4 projection; qApp->getProjectionMatrix(&projection); glm::quat invOrientation = glm::inverse(myAvatar->getOrientation()); glm::vec3 eyePos = myAvatar->getDefaultEyePosition(); glm::vec3 tip = myAvatar->getLaserPointerTipPosition(palm); glm::vec3 tipPos = invOrientation * (tip - eyePos); glm::vec4 clipSpacePos = glm::vec4(projection * glm::dvec4(tipPos, 1.0)); glm::vec3 ndcSpacePos; if (clipSpacePos.w != 0) { ndcSpacePos = glm::vec3(clipSpacePos) / clipSpacePos.w; } rv.setX(((ndcSpacePos.x + 1.0) / 2.0) * canvasSize.x); rv.setY((1.0 - ((ndcSpacePos.y + 1.0) / 2.0)) * canvasSize.y); } return rv; }
DS14::Coordinate replayDevice::toGameCo(QPoint programCo) { DS14::Coordinate z; z.x = double((programCo.rx()-300))*4; z.y = double((300-programCo.ry()))*4; return z; }
void CanvasWidget::addSelectedPatch(QPoint point2D) { glm::vec3 realPoint = getOpenGLCoord(point2D); QPoint upperLeft; upperLeft.rx() = floor(float(realPoint.x) / float(SURFACE_STRIDE)); upperLeft.ry() = floor(float(realPoint.y) / float(SURFACE_STRIDE)); selectedPatches.push_back(upperLeft); }
void QuotesTableView::onToolTip(QHelpEvent* e) { if( !e ) return; // QT BUG: substract the header height (header row taken as row=0, // so last row in the table will be mapped from point with row=-1) QPoint pt = mapFromGlobal(e->globalPos()); pt.ry() -= height()/20; QModelIndex index = indexAt(pt); if( index.data().isNull() ) { QToolTip::hideText(); return; } QString tipText; if( index.column() == 4 ) { QToolTip::showText(e->globalPos(), QString("The last request processed %1 msecs").arg(index.data().toInt()), this); } else if( index.column() == 5 ) { QToolTip::showText(e->globalPos(), index.data().toString(), this); } }
/** * @brief execMenuAtWidget * @param menu * @param widget */ static void execMenuAtWidget(QMenu* menu, QWidget* widget) { QPoint p; QRect screen = dream3dApp->desktop()->availableGeometry(widget); QSize sh = menu->sizeHint(); QRect rect = widget->rect(); if (widget->isRightToLeft()) { if (widget->mapToGlobal(QPoint(0, rect.bottom())).y() + sh.height() <= screen.height()) { p = widget->mapToGlobal(rect.bottomRight()); } else { p = widget->mapToGlobal(rect.topRight() - QPoint(0, sh.height())); } p.rx() -= sh.width(); } else { if (widget->mapToGlobal(QPoint(0, rect.bottom())).y() + sh.height() <= screen.height()) { p = widget->mapToGlobal(rect.bottomLeft()); } else { p = widget->mapToGlobal(rect.topLeft() - QPoint(0, sh.height())); } } p.rx() = qMax(screen.left(), qMin(p.x(), screen.right() - sh.width())); p.ry() += 1; menu->exec(p); }
QRect HexagonalRenderer::boundingRect(const QRect &rect) const { const RenderParams p(map()); QPoint topLeft = tileToScreenCoords(rect.topLeft()).toPoint(); int width, height; if (p.staggerX) { width = rect.width() * p.columnWidth + p.sideOffsetX; height = rect.height() * (p.tileHeight + p.sideLengthY); if (rect.width() > 1) { height += p.rowHeight; if (p.doStaggerX(rect.x())) topLeft.ry() -= p.rowHeight; } } else { width = rect.width() * (p.tileWidth + p.sideLengthX); height = rect.height() * p.rowHeight + p.sideOffsetY; if (rect.height() > 1) { width += p.columnWidth; if (p.doStaggerY(rect.y())) topLeft.rx() -= p.columnWidth; } } return QRect(topLeft.x(), topLeft.y(), width, height); }