/*! Expand the selected rectangle to minZoomSize() and zoom in if accepted. \sa accept(), minZoomSize() */ bool QwtPlotZoomer::end(bool ok) { ok = QwtPlotPicker::end(ok); if (!ok) return false; QwtPlot *plot = QwtPlotZoomer::plot(); if ( !plot ) return false; const QwtPolygon &pa = selection(); if ( pa.count() < 2 ) return false; QRect rect = QRect(pa[0], pa[int(pa.count() - 1)]); #if QT_VERSION < 0x040000 rect = rect.normalize(); #else rect = rect.normalized(); #endif QwtDoubleRect zoomRect = invTransform(rect).normalized(); const QwtDoublePoint center = zoomRect.center(); zoomRect.setSize(zoomRect.size().expandedTo(minZoomSize())); zoomRect.moveCenter(center); zoom(zoomRect); return true; }
JulyUrl::JulyUrl(QWidget *parent, int x, int y, int w, int h, QString link) : QLabel(parent) { startRect=QRect(x,y,w,h); setGeometry(startRect); zoomTimer = new QTimer(this); connect(zoomTimer,SIGNAL(timeout()),this,SLOT(zoom())); udNormalFont=0; isAnimating=false; add=2; text=link;; QFont font; font.setFamily("Arial"); font.setPixelSize(46); font.setStretch(60); double textWidth=QFontMetrics(font).width(link); pixmap1 = QPixmap(400,100); pixmap1.fill(Qt::transparent); QPainter painter(&pixmap1); painter.setPen(Qt::blue); painter.setFont(font); painter.drawText(QRectF(0,0,400,100),Qt::AlignCenter,text); pixmap2=pixmap1; QPixmap line(textWidth,4); line.fill(Qt::blue); painter.drawPixmap((400-textWidth)/2,84,line); setPixmap(pixmap1); notPressing=true; setScaledContents(true); }
/** * Mouse active motion callback (when button is pressed) */ void MouseMotionCallback(int x, int y) { if (gPreviousMouseX >= 0 && gPreviousMouseY >= 0) { //compute delta float deltaX = x-gPreviousMouseX; float deltaY = y-gPreviousMouseY; gPreviousMouseX = x; gPreviousMouseY = y; float zoomSensitivity = 0.2f; float rotateSensitivity = 0.5f; //orbit or zoom if (gMouseButton == GLUT_LEFT_BUTTON) { AdjustCameraAzimuthBy(-deltaX*rotateSensitivity); AdjustCameraElevationBy(-deltaY*rotateSensitivity); } else if (gMouseButton == GLUT_RIGHT_BUTTON) { STVector3 zoom(0,0,deltaX); AdjustCameraTranslationBy(zoom * zoomSensitivity); } } else { gPreviousMouseX = x; gPreviousMouseY = y; } }
QUndoCommand* Navigator::mouseMoveEvent(QMouseEvent* e) { switch (m_currentAction) { case Rotation: { QPoint delta = e->pos() - m_lastMousePosition; rotate(m_renderer->scene().center(), delta.y(), delta.x(), 0); e->accept(); break; } case Translation: { Vector2f fromScreen(m_lastMousePosition.x(), m_lastMousePosition.y()); Vector2f toScreen(e->localPos().x(), e->localPos().y()); translate(m_renderer->scene().center(), fromScreen, toScreen); e->accept(); break; } case ZoomTilt: { QPoint delta = e->pos() - m_lastMousePosition; // Tilt rotate(m_renderer->scene().center(), 0, 0, delta.x()); // Zoom zoom(m_renderer->scene().center(), delta.y()); e->accept(); break; } default:; } m_lastMousePosition = e->pos(); if (e->isAccepted()) emit updateRequested(); return nullptr; }
/** We received a request to paint the drawing area. */ void CSailDispLabel::paintEvent( QPaintEvent * ) { // erase viewport CSailPainter painter( this ); QRect rect = painter.viewport(); painter.eraseRect(rect); // check if the window was resized since last redraw if ( wasResized ) { setViewRect(painter.viewRect()); wasResized = 0; } // set coordinate system to match the logical viewport painter.setWindow(logicalRect()); painter.setFontSize(8, zoom()); painter.setPenWidth(); // draw the sail const CPanelGroup obj = dispObject(); painter.draw(obj); // optionally draw labels if (drawLabels) { painter.drawLabels(obj); /*/ draw markers on edges for test purpose painter.setFontSize(10, zoom/10); painter.drawMarkers(obj); */ } // painter.end(); }
int ged_zoom(struct ged *gedp, int argc, const char *argv[]) { int ret; double sf = 1.0; GED_CHECK_VIEW(gedp, GED_ERROR); GED_CHECK_ARGC_GT_0(gedp, argc, GED_ERROR); /* initialize result */ bu_vls_trunc(gedp->ged_result_str, 0); /* must be wanting help */ if (argc != 2) { bu_vls_printf(gedp->ged_result_str, "Usage: %s scale_factor", argv[0]); return (argc == 1) ? GED_HELP : GED_ERROR; } /* get the scale factor */ ret = sscanf(argv[1], "%lf", &sf); if (ret != 1 || sf < SMALL_FASTF || sf > INFINITY) { bu_vls_printf(gedp->ged_result_str, "ERROR: bad scale factor [%s]", argv[1]); return GED_ERROR; } return zoom(gedp, sf); }
void CommandInterpreter::handleCommand(TACommand command) { XTestGrabControl(display, True); printf("COMMAND: %i, %i, %i, %i, %f\n", command.type, command.touch, command.xDifference, command.yDifference, command.zoomValue); switch(command.type) { case TACommandTypeZoom: zoom(command); break; case TACommandTypePan: pan(command); break; case TACommandTypeRotate: rotate(command); break; default: break; } XSync(display, 0); XTestGrabControl(display, False); usleep(100); }
/** * \fn bool Dessin::on_event_happend (GdkEvent* event) * \brief Méthode gérant les évènements de la souris * \param event Evènement (appui souris, mouvement en restant appuyé ou relâchement de la souris) ayant provoqué l'instanciation de la méthode * \return Indicateur de bon deroulement de la méthode */ bool Dessin::on_event_happend(GdkEvent* event){ if (event->type == GDK_BUTTON_PRESS) { x = event->button.x; y = event->button.y; type_bouton = event->button.button; } if (event->type == GDK_MOTION_NOTIFY) { dessiner_cadre_selection_zoom(event->button.x, event->button.y); } if (event->type == GDK_BUTTON_RELEASE) { switch (type_bouton){ case 1: zoom(event->button.x, event->button.y); break; case 2: dezoom(); break; case 3: dezoom(); break; default: break; } type_bouton = 0; } return false; }
void Camera::mouseInput( int x, int y, int Button, int State) { if(State == GLUT_DOWN) { if(m_LastMouseX==-1) m_LastMouseX = x; if(m_LastMouseY==-1) m_LastMouseY = y; if( Button == GLUT_LEFT_BUTTON ) { rotate((float)x, (float)y ); } else if( Button == GLUT_RIGHT_BUTTON) { pan( (float)(m_LastMouseX-x)*0.01f, (float)(m_LastMouseY-y)*0.01f ); } else if( Button == GLUT_MIDDLE_BUTTON) { zoom( (float)(m_LastMouseY-y)*0.01f ); } } else { m_Position += m_Panning + m_Zoom + m_Rotation; m_Target += m_Panning; m_Panning = Vector(0,0,0); m_Zoom = Vector(0,0,0); m_Rotation = Vector(0,0,0); m_LastMouseX = -1; m_LastMouseY = -1; } }
SlippyCoordinates SlippyCoordinates::operator+(QPoint offset) { SlippyCoordinates res(zoom(), x(), y()); res.settilePos(res.tilePos()+ offset); return res; }
void GUIDanielPerspectiveChanger::onMouseMove(void*data) { FXEvent* e = (FXEvent*) data; myCallback.setWindowCursorPosition(e->win_x, e->win_y); int xdiff = myMouseXPosition - e->win_x; int ydiff = myMouseYPosition - e->win_y; switch (myMouseButtonState) { case MOUSEBTN_LEFT: move(xdiff, ydiff); if (xdiff!=0||ydiff!=0) { myMoveOnClick = true; } break; case MOUSEBTN_RIGHT: zoom(ydiff); rotate(xdiff); if (xdiff!=0||ydiff!=0) { myMoveOnClick = true; } break; default: if (xdiff!=0||ydiff!=0) { myCallback.updateToolTip(); } break; } myMouseXPosition = e->win_x; myMouseYPosition = e->win_y; }
void TWindow::handleEvent(TEvent &event) { TRect limits; TPoint min, max; TGroup::handleEvent(event); if (event.what== evCommand) switch (event.message.command) { case cmResize: if ((flags & (wfMove | wfGrow)) != 0) { limits = owner->getExtent(); sizeLimits(min, max); dragView(event, dragMode | (flags & (wfMove | wfGrow)), limits, min, max); clearEvent(event); } break; case cmClose: if ((flags & wfClose) != 0 && (event.message.infoPtr == 0 || event.message.infoPtr == this)) { clearEvent(event); if ((state & sfModal) == 0) close(); else { event.what = evCommand; event.message.command = cmCancel; putEvent(event); clearEvent(event); } } break; case cmZoom: if ((flags & wfZoom) != 0 && (event.message.infoPtr == 0 || event.message.infoPtr == this)) { zoom(); clearEvent(event); } break; } else if (event.what == evKeyDown) switch (event.keyDown.keyCode) { case kbTab: focusNext(False); clearEvent(event); break; case kbShiftTab: focusNext(True); clearEvent(event); break; } else if (event.what == evBroadcast && event.message.command == cmSelectWindowNum && event.message.infoInt == number && (options & ofSelectable) != 0 ) { select(); clearEvent(event); } }
/*! Expand the selected rectangle to minZoomSize() and zoom in if accepted. \sa accept(), minZoomSize() */ bool QwtPlotZoomer::end( bool ok ) { ok = QwtPlotPicker::end( ok ); if ( !ok ) return false; QwtPlot *plot = QwtPlotZoomer::plot(); if ( !plot ) return false; const QPolygon &pa = selection(); if ( pa.count() < 2 ) return false; QRect rect = QRect( pa[0], pa[int( pa.count() - 1 )] ); rect = rect.normalized(); QRectF zoomRect = invTransform( rect ).normalized(); const QSizeF minSize = minZoomSize(); if ( minSize.isValid() ) { const QPointF center = zoomRect.center(); zoomRect.setSize( zoomRect.size().expandedTo( minZoomSize() ) ); zoomRect.moveCenter( center ); } zoom( zoomRect ); return true; }
//Update frame void myApp::update() { // Call predecessor update cglApp::update(); // Process keyboard float dx = 0.0f; float dy = 0.0f; float dr = 0.0f; if (m_keysPressed[VK_LEFT]) dx -= s_rKbd2Rotate * m_timer.getDelta(); if (m_keysPressed[VK_RIGHT]) dx += s_rKbd2Rotate * m_timer.getDelta(); if (m_keysPressed[VK_UP]) dy -= s_rKbd2Rotate * m_timer.getDelta(); if (m_keysPressed[VK_DOWN]) dy += s_rKbd2Rotate * m_timer.getDelta(); if (m_keysPressed[VK_SUBTRACT]) dr -= s_rKbd2Zoom * m_timer.getDelta(); if (m_keysPressed[VK_ADD]) dr += s_rKbd2Zoom * m_timer.getDelta(); rotateObject(dx, dy); zoom(dr); /* float rI = 0.0f; for (int i = 0; i < 10000000;i++) rI += sin(i);*/ }
void GUIDanielPerspectiveChanger::onMouseMove(void* data) { FXEvent* e = (FXEvent*) data; myCallback.setWindowCursorPosition(e->win_x, e->win_y); const int xdiff = myMouseXPosition - e->win_x; const int ydiff = myMouseYPosition - e->win_y; const bool moved = xdiff != 0 || ydiff != 0; const bool pastDelay = !gSchemeStorage.getDefault().gaming && FXThread::time() > (myMouseDownTime + myDragDelay); switch (myMouseButtonState) { case MOUSEBTN_LEFT: if (pastDelay) { move(xdiff, ydiff); if (moved) { myMoveOnClick = true; } } break; case MOUSEBTN_RIGHT: if (pastDelay) { zoom(1 + 10.0 * ydiff / myCallback.getWidth()); rotate(xdiff); if (moved) { myMoveOnClick = true; } } break; default: if (moved) { myCallback.updateToolTip(); } break; } myMouseXPosition = e->win_x; myMouseYPosition = e->win_y; }
KPrView::~KPrView() { saveZoomConfig(zoomMode(), zoom()); delete m_presentationMode; delete m_notesMode; delete m_slidesSorterMode; }
void PlotZoomer::zoomSync(const QRectF &rect) { if (!_ignoreSync) { // if (QwtPlotZoomer *zoomer = qobject_cast<QwtPlotZoomer *>(sender())) // { // setZoomStack(zoomer->zoomStack(), zoomer->zoomRectIndex()); // } // else // { // zoom(rect); // } // Adjust the zoom rect according to the zoom mode. QRectF adjustedRect = rect; switch (_zoomMode) { default: case ZoomBoth: break; case ZoomX: adjustedRect.setY(zoomRect().y()); adjustedRect.setHeight(zoomRect().height()); break; case ZoomY: adjustedRect.setX(zoomRect().x()); adjustedRect.setWidth(zoomRect().width()); break; } zoom(adjustedRect); } }
void Camera::update(UNUSED gdl::Clock const& clock, Binput& input) { bomber::Event event; if (input._default.getMouseWheel().y) zoom(0.05 * input._default.getMouseWheel().y); if (input._default.getKey(SDL_BUTTON_LEFT)) rotate(glm::vec3(0, 1, 0), static_cast<float>(input._default.getMouseDelta().x)); if (input._default.getKey(SDL_BUTTON_RIGHT)) { glm::vec3 delta(input._default.getMouseDelta().x * -0.1, input._default.getMouseDelta().y * 0.1, 0); _target += delta; } if (input._default.getKey(SDLK_KP_PLUS) || input.handleEvent(event, bomber::Event::TriggerLT)) rotate(glm::vec3(-1, 0, 0), 0.10f); if (input._default.getKey(SDLK_KP_MINUS) || input.handleEvent(event, bomber::Event::TriggerRT)) rotate(glm::vec3(1, 0, 0), 0.10f); if (input._default.getKey(SDLK_UP) || input.handleEvent(event, bomber::Event::JoyRightUp)) move(glm::vec3(0, 0, 1)); if (input._default.getKey(SDLK_DOWN) || input.handleEvent(event, bomber::Event::JoyRightDown)) move(glm::vec3(0, 0, -1)); if (input._default.getKey(SDLK_LEFT) || input.handleEvent(event, bomber::Event::JoyRightLeft)) move(glm::vec3(1, 0, 0)); if (input._default.getKey(SDLK_RIGHT) || input.handleEvent(event, bomber::Event::JoyRightRight)) move(glm::vec3(-1, 0, 0)); if (_position == _target) _target += glm::vec3(1, 1, 1); refreshPosition(); }
t_p *ft_posxy(t_p *f, char ***t, int l, int h) { int i; i = 0; f = zoom(f); while (t[h]) { while (t[h][l]) { if (!(f->m[h][l] = (int *)malloc(sizeof(int) * 1))) exit(EXIT_FAILURE); if (ft_atoi(t[h][l]) > 100) ft_big(); isdig(t[h][l]); f->m[h][l][0] = ft_atoi(t[h][l]); f->pos[h][l] = (int *)malloc(sizeof(int) * 1); f->posy[h][l] = (int *)malloc(sizeof(int) * 1); f->pos[h][l][0] = l * f->zoom + f->h / 25 + h * f->zoom; f->posy[h][l][0] = h * f->zoomy + f->l / 4 - f->m[h][l][0] * 5; l++; i++; } l = 0; h++; } return (f); }
/* Function: keyboardKeys * Description: Reads keyboard input from user. * Input: unsigned char key - ASCII value of the key pressed. * int x - X-position * int y - Y-position * Output: None */ void keyboardKeys(unsigned char key, int x, int y) { switch(tolower(key)) { case 27: exit(0); break; case 'z': zoom(-1, camFol); break; case 'x': zoom(1, camFol); break; case ' ': saveScreenToFile = 1 - saveScreenToFile; case 'w': if (camFol == 0) cameraFreeMove(0); break; case 's': if (camFol == 0) cameraFreeMove(1); break; case 'q': if (camFol == 0) cameraFreeMove(2); break; case 'e': if (camFol == 0) cameraFreeMove(3); break; case 'd': if (camFol == 0) cameraFreeMove(4); break; case 'a': if (camFol == 0) cameraFreeMove(5); break; case 'f': camFol = 1 - camFol; break; case 'p': saveScreenToFile = 1 - saveScreenToFile; break; } //end switch } //end keyboardKeys
bool PlotZoomer::end(bool ok) { // Code here is taken from QwtPlotZoomer. The only modification is around the _zoomMode handling. ok = QwtPlotPicker::end(ok); if (!ok) { return false; } QwtPlot *plot = QwtPlotZoomer::plot(); if (!plot) { return false; } const QPolygon &pa = selection(); if (pa.count() < 2) { return false; } QRect rect = QRect(pa[0], pa[int(pa.count() - 1)]); rect = rect.normalized(); QRectF currentZoomRect = zoomRect(); QRectF zoomRect = invTransform(rect).normalized(); switch (_zoomMode) { default: case ZoomBoth: // nothing. break; case ZoomX: // Maintain current zoom y and height. zoomRect.setY(currentZoomRect.y()); zoomRect.setHeight(currentZoomRect.height()); break; case ZoomY: // Maintain current zoom x and width. zoomRect.setX(currentZoomRect.x()); zoomRect.setWidth(currentZoomRect.width()); break; } const QSizeF minSize = minZoomSize(); if (minSize.isValid()) { const QPointF center = zoomRect.center(); zoomRect.setSize(zoomRect.size().expandedTo(minZoomSize())); zoomRect.moveCenter(center); } zoom(zoomRect); return true; }
/** * Process the mouse button release event. */ void InputControllerMoveUnwrapped::mouseReleaseEvent(QMouseEvent *) { if ( m_isButtonPressed ) { emit zoom(); } m_isButtonPressed = false; }
bool uiGeoscapeNode::onScroll (uiNode_t* node, int deltaX, int deltaY) { bool down = deltaY > 0; if (deltaY == 0) return false; zoom(node, down); return true; }
void GraphicsView::wheelEvent( QWheelEvent *event ) { QPoint numDegrees = event->angleDelta()/8; QPoint numSteps = numDegrees/15; QPoint hoverPos = event->pos(); QPointF scenePos = mapToScene(hoverPos); emit zoom(numSteps.y(), scenePos); }
void PlotZoomer::widgetWheelEvent(QWheelEvent *event) { if (event->delta()) { int numSteps = event->delta() > 0 ? 1 : -1; zoom(numSteps); } }
void TOPPASWidget::keyPressEvent(QKeyEvent * e) { if (e->key() == Qt::Key_C && e->modifiers() == Qt::ControlModifier) { scene_->copySelected(); e->accept(); } else if (e->key() == Qt::Key_X && e->modifiers() == Qt::ControlModifier) { scene_->copySelected(); scene_->removeSelected(); e->accept(); } else if (e->key() == Qt::Key_V && e->modifiers() == Qt::ControlModifier) { scene_->paste(); e->accept(); } else if (e->key() == Qt::Key_Control) { setDragMode(QGraphicsView::RubberBandDrag); //color of hovering edge may change TOPPASEdge* hover_edge = scene_->getHoveringEdge(); if (hover_edge) hover_edge->update(); e->accept(); } else if (e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace) { scene_->removeSelected(); e->accept(); } else if (e->key() == Qt::Key_Plus) { zoom(false); e->accept(); } else if (e->key() == Qt::Key_Minus) { zoom(true); e->accept(); } else { e->ignore(); } }
void wxFrameworkGLCanvas::OnMouseWheel(wxMouseEvent &event) { float dY; dY = -(event.m_wheelRotation / 120.); zoom((dY / 160.0), (dY * 5.0)); }
lib_test_client::lib_test_client(const string &filename, visualizer *pvis, draw_scope *pscope) : base_visualizer_client(pvis, pscope) , r(filename) { pgraph_ = &r.get_graph(); g_desc = upload_graph(*pgraph_); zoom(r.get_mins(), r.get_maxs()); }
int QwtPlotZoomer::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QwtPlotPicker::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: zoomed((*reinterpret_cast< const QwtDoubleRect(*)>(_a[1]))); break; case 1: moveBy((*reinterpret_cast< double(*)>(_a[1])),(*reinterpret_cast< double(*)>(_a[2]))); break; case 2: move((*reinterpret_cast< double(*)>(_a[1])),(*reinterpret_cast< double(*)>(_a[2]))); break; case 3: zoom((*reinterpret_cast< const QwtDoubleRect(*)>(_a[1]))); break; case 4: zoom((*reinterpret_cast< int(*)>(_a[1]))); break; } _id -= 5; } return _id; }
void TopLevel::zoomout() { if (oz < MAXZOOM && Image->width >= 256) { ++oz; zoom( oz ); } }