// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> void Circle::draw(QPainter& painter, const QPointF& startTile, const QRect& viewport, const int& zoom) { if ( !isVisible() ) return; QPointF coords; coord2screen(geoPosition(), coords, startTile, zoom); if ( !viewport.contains(coords.toPoint()) ) coord2screen(geoPosition(), coords, startTile, zoom, true); setScreenPosition(coords); qreal yu = size().height() / WGS84CELLSIZE / pow(2, 18 - zoom) * 1000; qreal xu = size().width() / WGS84CELLSIZE / pow(2, 18 - zoom) * 1000; painter.save(); painter.setPen(pen()); painter.setBrush(brush()); painter.setOpacity(opacity()); painter.setRenderHint(QPainter::Antialiasing, isAntialiased()); if ( isSizeInKm() ) painter.drawEllipse(coords, xu, yu); else painter.drawEllipse(coords, size().width(), size().height()); painter.restore(); }
void QvisScreenPositioner::setScreenPosition(double xp, double yp) { int ixp = int(xp * double(xScreenSize)); int iyp = int(yp * double(yScreenSize)); setScreenPosition(ixp, iyp); }
void CActorObject::doAction(CGameObject* object) { if (object->getType() == type) return; float distance = (object->getTilePosition() - getTilePosition()).getLength(); if (distance <= 2.0f) { if ( object->getType() == ((CGameObject::OBJECT_TYPE_CONSUMABLE << 8) | ConsumableConstants::OBJECT_TYPE_FLOWER) ) { setState(ActorConstants::ACTOR_STATE_HARVESTING); setTilePosition(object->getTilePosition()); setScreenPosition(object->getScreenPosition()); } } }
void handleUnboundedDrag (Component& current) { const Rectangle<float> componentScreenBounds = ScalingHelpers::scaledScreenPosToUnscaled (current.getParentMonitorArea().reduced (2, 2).toFloat()); if (! componentScreenBounds.contains (lastScreenPos)) { const Point<float> componentCentre (current.getScreenBounds().toFloat().getCentre()); unboundedMouseOffset += (lastScreenPos - ScalingHelpers::scaledScreenPosToUnscaled (componentCentre)); setScreenPosition (componentCentre); } else if (isCursorVisibleUntilOffscreen && (! unboundedMouseOffset.isOrigin()) && componentScreenBounds.contains (lastScreenPos + unboundedMouseOffset)) { MouseInputSource::setRawMousePosition (lastScreenPos + unboundedMouseOffset); unboundedMouseOffset = Point<float>(); } }
//============================================================================== void enableUnboundedMouseMovement (bool enable, bool keepCursorVisibleUntilOffscreen) { enable = enable && isDragging(); isCursorVisibleUntilOffscreen = keepCursorVisibleUntilOffscreen; if (enable != isUnboundedMouseModeOn) { if ((! enable) && ((! isCursorVisibleUntilOffscreen) || ! unboundedMouseOffset.isOrigin())) { // when released, return the mouse to within the component's bounds if (Component* current = getComponentUnderMouse()) setScreenPosition (current->getScreenBounds().toFloat() .getConstrainedPoint (ScalingHelpers::unscaledScreenPosToScaled (lastScreenPos))); } isUnboundedMouseModeOn = enable; unboundedMouseOffset = Point<float>(); revealCursor (true); } }