/** Build a viewport to show this source rectangle, zoomed out by zoom factor */ void asf::pixel_viewport::set(const asf::pixel_rectangle &src,int zoom) { set_zoom(zoom); m_src=src; m_size=pixel_size(m_src.width()>>m_zoom, m_src.height()>>m_zoom); m_self=pixel_rectangle(0,0,m_size.x,m_size.y); }
void GraphicContextState::set_zoom(const Vector2f& pos, float z) { float old_zoom = impl->zoom; set_zoom(z); impl->offset.x = pos.x/impl->zoom - pos.x/old_zoom + impl->offset.x; impl->offset.y = pos.y/impl->zoom - pos.y/old_zoom + impl->offset.y; }
/** * map_control -- draw a cursor on the screen and accept control from FSM * @ch: the input word from the FSM */ int map_control(int ch) { bool dozoom = false; struct map_t *tmp; if (!nav_win) map_cursor_init(); top_panel(nav_pan); switch (ch) { case MODE_STARTED: map_controls_active = true; cursor->Show(cursor); show_panel(nav_pan); break; /* Scroll the map in a direction */ case 'w': case 'a': case 's': case 'd': case 'W': case 'A': case 'S': case 'D': map_scroll(MAPBOOK->active, ch); break; /* Move the zoom frame in a direction */ case 'h': case 'j': case 'k': case 'l': case 'H': case 'J': case 'K': case 'L': cursor->Move(cursor, ch); break; /* Select the current zoom frame */ case '\n': dozoom = true; break; case KEY_ESC: case 'm': map_controls_active = false; show_dock(); cursor->Hide(cursor); hide_panel(nav_pan); return MODE_RELEASE; } /* Adjust for changing y0 or x0 of the map pad */ y_map = pos_y(cursor->pos) + pos_y(ACTIVE->pos); x_map = pos_x(cursor->pos) + pos_x(ACTIVE->pos); zoomlevel = MAPBOOK->page; print_map_control(y_map, x_map); draw_zoom_box(ACTIVE, y_map, x_map); if (dozoom) set_zoom(MAPBOOK, y_map, x_map); return MODE_PERSIST; }
bool MapDrawingArea::on_scroll_event(GdkEventScroll* event) { int z = zoom; switch (event->direction) { case GDK_SCROLL_UP: z = set_zoom(zoom + 1); break; case GDK_SCROLL_DOWN: z = set_zoom(zoom - 1); break; default: break; } if (z != zoom) { after_change(); zoom_changed(zoom); } return true; }
void MapDrawingArea::add_dp(int priority, std::shared_ptr<DisplayProvider> dp) { dps.insert(std::pair<int, std::shared_ptr<DisplayProvider> >(-priority, dp)); if (dps.size() == 1) { min_z = dp->get_min_zoom(); max_z = dp->get_max_zoom(); lat = dp->center_lat(); lon = dp->center_lon(); set_zoom(min_z); } after_change(); }
UmlCanvas::UmlCanvas(CanvasFormat f, BrowserDiagram * br_diag) : Q3Canvas(formatSize[f].w, formatSize[f].h), br_diagram(br_diag), view(0), all_items((const char *) 0) { width100percent = width(); height100percent = height(); do_paste = FALSE; hlimit = 0; vlimit = 0; set_zoom(1); // set do_scale do_scale = FALSE; br_diag->update_drawing_settings(); show_shadow = br_diag->get_shadow(); draw_all_relations = br_diag->get_draw_all_relations(); All.append(this); }
void Canvas::zoom_to( wxRect rect ) { wxSize window_size = wxWindow::GetClientSize(); float ratio = std::max( float(rect.GetWidth()) / window_size.GetWidth(), float(rect.GetHeight()) / window_size.GetHeight() ); int zoom; if ( ratio < 1 ) { /* Zoom in. */ zoom = round( 1 / ratio ) - 1; } else { /* Zoom out. */ zoom = - round( ratio ); } zoom = std::max( -16, std::min( zoom, 16 ) ); wxPoint sumPoint = (rect.GetTopLeft() + rect.GetBottomRight()); wxPoint centerPoint( sumPoint.x/2, sumPoint.y/2); set_zoom( zoom, centerPoint ); }
/** * @brief Create a sprite previewer. * @param parent The parent object or nullptr. */ SpritePreviewer::SpritePreviewer(QWidget *parent) : QWidget(parent), model(nullptr), zoom(1.0) { ui.setupUi(this); // Create frame and origin items. item = new QGraphicsPixmapItem(); origin_h = new QGraphicsLineItem(); origin_v = new QGraphicsLineItem(); origin_h->setPen(QPen(Qt::blue)); origin_v->setPen(QPen(Qt::blue)); // Create the scene. ui.frame_view->setScene(new QGraphicsScene()); ui.frame_view->scene()->addItem(item); ui.frame_view->scene()->addItem(origin_h); ui.frame_view->scene()->addItem(origin_v); ui.frame_view->scene()->setBackgroundBrush( ui.frame_view->scene()->palette().base()); // Zoom. ui.zoom_button->setMenu(create_zoom_menu()); ui.zoom_button->setPopupMode(QToolButton::InstantPopup); set_zoom(2.0); update_zoom(); connect(&timer, SIGNAL(timeout()), this, SLOT(timeout())); connect(ui.start_button, SIGNAL(clicked()), this, SLOT(start())); connect(ui.stop_button, SIGNAL(clicked()), this, SLOT(stop())); connect(ui.first_button, SIGNAL(clicked()), this, SLOT(first())); connect(ui.previous_button, SIGNAL(clicked()), this, SLOT(previous())); connect(ui.last_button, SIGNAL(clicked()), this, SLOT(last())); connect(ui.next_button, SIGNAL(clicked()), this, SLOT(next())); connect(ui.origin_check_box, SIGNAL(clicked()), this, SLOT(update_origin())); }
void loop() { // Make sure we don't update the map tile on screen when we don't need to! uint8_t update_display_window = 0; if ( first_time ) { first_time = 0; update_display_window = 1; } // Joystick displacement. int16_t dx = 0; int16_t dy = 0; uint8_t select_button_event = 0; // If the map has been zoomed in or out we need to do a redraw, // and will center the display window about the cursor. // So a zoom in-out will re-center over a mis-positioned cursor! // if the map changed as a result of a zoom button press if (shared_new_map_num != current_map_num) { #ifdef DEBUG_SCROLLING Serial.print("Zoom from "); Serial.print(current_map_num); Serial.print(" x "); Serial.print(cursor_map_x); Serial.print(" y "); Serial.print(cursor_map_y); #endif // change the map and figure out the position of the cursor on // the new map. set_zoom(); // center the display window around the cursor move_window_to( cursor_map_x - display_window_width/2, cursor_map_y - display_window_height/2); #ifdef DEBUG_SCROLLING Serial.print(" to "); Serial.print(current_map_num); Serial.print(" x "); Serial.print(cursor_map_x); Serial.print(" y "); Serial.print(cursor_map_y); Serial.println(); #endif // Changed the zoom level, so we want to redraw the window update_display_window = 1; } // Now, see if the joystick has moved, in which case we want to // also want to move the visible cursor on the screen. // Process joystick input. select_button_event = process_joystick(&dx, &dy); // the joystick routine filters out small changes, so anything non-0 // is a real movement if ( abs(dx) > 0 || abs(dy) > 0 ) { // redraw the path if the cursor moves: (brute force yay) // comment out if you find it runs too slowly, and live with the // cursor erasing the path if ( path_length > 0 ) { draw_path(path_length, path, current_map_num); } // Is the cursor getting near the edge of the screen? If so // then scroll the map over by re-centering the window. uint16_t new_screen_map_x = screen_map_x; uint16_t new_screen_map_y = screen_map_y; uint8_t need_to_move = 0; uint16_t cursor_screen_x; uint16_t cursor_screen_y; if ( get_cursor_screen_x_y(&cursor_screen_x, &cursor_screen_y) ) { // if the cursor is visible, then adjust the display to // to scroll if near the edge. if ( cursor_screen_x < screen_left_margin ) { new_screen_map_x = screen_map_x - screen_scroll_delta; move_cursor_by(3, 0); need_to_move = 1; } else if ( cursor_screen_x > screen_right_margin ) { new_screen_map_x = screen_map_x + screen_scroll_delta; move_cursor_by(-3, 0); need_to_move = 1; } if ( cursor_screen_y < screen_top_margin ) { new_screen_map_y = screen_map_y - screen_scroll_delta; move_cursor_by(0, 3); need_to_move = 1; } else if ( cursor_screen_y > screen_bottom_margin ) { new_screen_map_y = screen_map_y + screen_scroll_delta; move_cursor_by(0, -3); need_to_move = 1; } if ( need_to_move ) { // move the display window, leaving cursor at same lat-lon move_window_to(new_screen_map_x, new_screen_map_y); update_display_window = 1; } else { // erase old cursor, move, and draw new one, no need to // redraw the underlying map tile erase_cursor(); move_cursor_by(dx, dy); draw_cursor(); } } } // at this point the screen is updated, with a new tile window and // cursor position if necessary // will only be down once, then waits for a min time before allowing // pres again. if (select_button_event) { // Button was pressed, we are selecting a point! #ifdef DEBUG_PATH Serial.print("x "); Serial.print(cursor_map_x); Serial.print(" y "); Serial.print(cursor_map_y); Serial.println(); #endif // which press is this, the start or the stop selection? // If we are making a request to find a shortest path, we will send out // the request on the serial port and then wait for a response from the // server. While this is happening, the client user interface is // suspended. // if the stop point, then we send out the server request and wait. if ( request_state == 0 ) { // collect the start point start_lat = cursor_lat; start_lon = cursor_lon; request_state = 1; } else if ( request_state == 1) { // collect the stop point stop_lat = cursor_lat; stop_lon = cursor_lon; request_state = 0; // send out the start and stop coordinates to the server Serial.print(start_lat); Serial.print(" "); Serial.print(start_lon); Serial.print(" "); Serial.print(stop_lat); Serial.print(" "); Serial.print(stop_lon); Serial.println(); // free any existing path if ( path_length > 0 ) { free(path); } // read the path from the serial port status_msg("WAITING"); if ( read_path(&path_length, &path) ) { #ifdef DEBUG_PATH uint8_t is_visible; for (uint16_t i=0; i < path_length; i++) { is_visible = is_coord_visible(path[i]); Serial.print(i); Serial.print(": "); Serial.print(path[i].lat); Serial.print(","); Serial.print(path[i].lon); Serial.print(is_visible ? "V": ""); Serial.println(); } #endif update_display_window = 1; } else { // should display this error on the screen Serial.print("Path read error, code "); Serial.println(path_errno); if ( path_errno == 1 ) { status_msg("Path too long"); delay(5000); } } } } // end of select_button_event processing // do we have to redraw the map tile? if (update_display_window) { #ifdef DEBUG_SCROLLING Serial.println("Screen update"); Serial.print(current_map_num); Serial.print(" "); Serial.print(cursor_lon); Serial.print(" "); Serial.print(cursor_lat); Serial.println(); #endif draw_map_screen(); draw_cursor(); // Need to redraw any other things that are on the screen if ( path_length > 0 ) { draw_path(path_length, path, current_map_num); } // force a redisplay of status message clear_status_msg(); } // always update the status message area if message changes // Indicate which point we are waiting for if ( request_state == 0 ) { status_msg("FROM?"); } else { status_msg("TO?"); } }
void GraphEdit::_zoom_plus() { set_zoom(zoom * ZOOM_SCALE); }
void GraphEdit::_zoom_reset() { set_zoom(1); }
void GraphEdit::_zoom_minus() { set_zoom(zoom / ZOOM_SCALE); }
void dmz::QtModuleCanvasBasic::zoom_out () { set_zoom (get_zoom () / _zoomStep); }
/************** pixel viewport ****************/ asf::pixel_viewport::pixel_viewport() :m_size(0,0) { set_zoom(0); }
void dmz::QtModuleCanvasBasic::_init (Config &local) { qwidget_config_read ("widget", local, this); const Int32 MinX = config_to_int32 ("scene.min.x", local, -50000); const Int32 MinY = config_to_int32 ("scene.min.y", local, -50000); const Int32 MaxX = config_to_int32 ("scene.max.x", local, 100000); const Int32 MaxY = config_to_int32 ("scene.max.y", local, 100000); _scene.setSceneRect (QRectF (MinX, MinY, MaxX - MinX, MaxY - MinY)); //_scene.setItemIndexMethod (QGraphicsScene::NoIndex); _canvas = new QtCanvasView (this); _canvas->setTransformationAnchor (QGraphicsView::AnchorViewCenter); _canvas->setResizeAnchor (QGraphicsView::AnchorViewCenter); const Boolean ScrollBars = config_to_boolean ("scrollbars.value", local, False); if (!ScrollBars) { _canvas->setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOff); _canvas->setVerticalScrollBarPolicy (Qt::ScrollBarAlwaysOff); } _canvas->setMouseTracking (true); //_canvas->setDragMode (QGraphicsView::ScrollHandDrag); setObjectName (get_plugin_name ().get_buffer ()); _scene.setObjectName (objectName () + "Scene"); _canvas->setObjectName (objectName () + "View"); _canvas->setScene (&_scene); //_canvas->setBackgroundBrush (QPixmap ("/assets/images/background1.png")); QVBoxLayout *layout (new QVBoxLayout ()); layout->addWidget (_canvas); setLayout (layout); setMouseTracking (true); _inputModuleName = config_to_string ("module.input.name", local); if (_canvas) { _keyEvent.set_source_handle (get_plugin_handle ()); _mouseEvent.set_source_handle (get_plugin_handle ()); String value; Boolean enableOpenGL (False); if (local.lookup_attribute ("canvas.opengl", value)) { if (value.to_lower () == "true") { enableOpenGL = True; } } Boolean enableAntialiasing (False); if (local.lookup_attribute ("canvas.antialiasing", value)) { if (value.to_lower () == "true") { enableAntialiasing = True; } } if (enableOpenGL) { _canvas->setViewport (new QGLWidget (QGLFormat (QGL::SampleBuffers))); _log.info << "OpenGL enabled" << endl; } if (enableAntialiasing) { if (enableOpenGL) { _canvas->setRenderHint (QPainter::HighQualityAntialiasing, true); _log.info << "High Quality Antialiasing enabled" << endl; } else { _canvas->setRenderHint (QPainter::Antialiasing, true); _log.info << "Antialiasing enabled" << endl; } } if (local.lookup_attribute ("canvas.textantialiasing", value)) { if (value.to_lower () == "true") { _canvas->setRenderHint (QPainter::TextAntialiasing, true); _log.info << "Test Antialiasing enabled" << endl; } } _canvas->setRenderHint (QPainter::SmoothPixmapTransform, true); set_zoom_min_value (config_to_float32 ("canvas.zoom.min", local, _zoomMin)); set_zoom_max_value (config_to_float32 ("canvas.zoom.max", local, _zoomMax)); set_zoom_step_value (config_to_float32 ("canvas.zoom.step", local, _zoomStep)); set_zoom (config_to_float32 ("canvas.zoom.default", local, _zoomDefault)); } }
void zoom_out() { double level = browser_->GetHost()->GetZoomLevel(); set_zoom(std::pow(1.2, level) - 0.1); }
void process() { /* static int tmc=0; tmc++; if(tmc==30) { tmc=0; set_indoor(); } */ int x, y; //初始化背景 if(bInited==0) { static int initCount=0; if(initCount<30) { initCount++; img_copy(&BACK, &Y); } else { bInited=1; img_fill(&UBAK, 0); set_target_pan_tilt(0, 0); set_zoom(1); } return; } img_fill(&COMP, 0); img_fill(&COMPB, 0); img_fill(&CLUS, 0); img_fill(&LABEL, 0); //计算准备 for (y = masky1; y < masky2; y++) for (x = maskx1; x < maskx2; x++) { COMP.data[y][x] = abs(Y.data[y][x] - PREV.data[y][x]) > compare_th ? 255 : 0; if(Y.data[y][x] < dark || PREV.data[y][x] < dark) COMP.data[y][x] = abs(Y.data[y][x] - PREV.data[y][x]) > compare_th*dark_th ? 255 : 0; COMPB.data[y][x] = abs(Y.data[y][x] - BACK.data[y][x]) > compare_th2 ? 255 : 0; if(Y.data[y][x] < dark || BACK.data[y][x] < dark) COMPB.data[y][x] = abs(Y.data[y][x] - BACK.data[y][x]) > compare_th2*dark_th ? 255 : 0; } img_copy(&PREV, &Y); //选择性更新背景 updataBack(); //聚类 cluster(); img_copy(&LABEL, &CLUS); //连通域 int k=label(); img_plot_rect(&Y, maskx1, masky1, maskx2 - maskx1, masky2 - masky1, 128); //输出连通域信息 int i=0; mon("count: %d\n", k); for(i=0;i<k;i++) { mon("area%d: %d\n", i, Box[i].area); } float p=0,t=0,z=1; int ml=IMG_W,mr=0,cx=0,dx; for(i=0;i<k;i++) { if(Box[i].left < ml) ml = Box[i].left; if(Box[i].right > mr) mr = Box[i].right; } cx=(ml+mr)/2; dx=(mr-ml)*1.3; p = (float)(cx - IMG_W/2) / (IMG_W/2) * (PAN_RANGE/2); z = CAM_RANGE / ((float)dx / IMG_W * PAN_RANGE); if(z<1.0) z=1; printf("--------%d\n",k); myTimer(&p,&t,&z,k); set_target_pan_tilt(p, t); set_zoom(z); mon("PZ:%f,%f\n", p, z); }
void dmz::QtModuleCanvasBasic::zoom_in () { set_zoom (get_zoom () * _zoomStep); }