Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
5.5.0 - Français

Change language to:
English - 日本語 - Português - Русский

Please note that the recommended version of Scilab is 2025.0.0. This page might be outdated.
See the recommended documentation of this function

Aide de Scilab >> Graphiques > interaction > rubberbox

rubberbox

rubberband box for rectangle selection

Calling Sequence

[final_rect, btn] = rubberbox()
[final_rect, btn] = rubberbox(initial_rect)
[final_rect, btn] = rubberbox(edition_mode)
[final_rect, btn] = rubberbox(initial_rect, edition_mode)

Arguments

initial_rect

a vector with two or four entries. With four entries it gives the initial rectangle defined by [x_min, y_max, width, height] (where x_min and y_max are coordinates of initial corner position, with two entries width and height are supposed to be 0.

edition_mode

a boolean, if edition_mode is %t button press selects the first corner, release selects the opposite corner. If edition_mode is %f, a button press or click selects the first corner, a click is requested to select the opposite corner. The default value is %f.

final_rect

a rectangle defined by [x_min, y_max, width, height].

btn

an integer, the number of the mouse button clicked.

Description

rubberbox(initial_rect) tracks a rubberband box in the current graphic window, following the mouse. When a button is clicked rubberbox returns the final rectangles definition in final_Rect. If the argument initial_rect is not specified, a click is needed to fix the initial corner position.

Examples

clf
plot2d()
a = gca();
db = a.data_bounds;
x0 = (db(1)*2+db(2))/3;
dx = (db(2)-db(1))/3;
y0 = (db(3)+db(4)*2)/3;
dy = (db(4)-db(3))/3;
xtitle(msprintf("With an initial starting corner: x0 = %0.2f, y0 = %0.2f",x0,y0))
r = rubberbox([x0 y0])
clf
plot2d()
a = gca();
db = a.data_bounds;
x0 = (db(1)*2+db(2))/3;
dx = (db(2)-db(1))/3;
y0 = (db(3)+db(4)*2)/3;
dy = (db(4)-db(3))/3;
xtitle(msprintf("With an initial box: x0 = %0.2f, y0 = %0.2f, width = %0.2f, height = %0.2f,",x0-dx/4,y0+dy/5,2*dx,dy))
r = rubberbox([x0-dx/4 y0+dy/5 2*dx dy])
clf
plot2d()
a = gca();
db = a.data_bounds;
x0 = (db(1)*2+db(2))/3;
dx = (db(2)-db(1))/3;
y0 = (db(3)+db(4)*2)/3;
dy = (db(4)-db(3))/3;
xtitle("In press -- drag -- release mode selection:")
r = rubberbox(%t)
clf
plot2d()
a = gca();
db = a.data_bounds;
x0 = (db(1)*2+db(2))/3;
dx = (db(2)-db(1))/3;
y0 = (db(3)+db(4)*2)/3;
dy = (db(4)-db(3))/3;
xtitle("In starting click -- drag -- stopping click mode selection:")
r = rubberbox()

See Also

  • xrect — dessine un rectangle
  • xrects — dessine ou remplit un ensemble de rectangles
  • xclick — Attend une action d'un bouton de la souris, du clavier dans une fenêtre graphique.
  • xgetmouse — get the mouse events and current position
  • dragrect — déplace un ou plusieurs rectangles avec la souris
Report an issue
<< event handler functions interaction seteventhandler >>

Copyright (c) 2022-2024 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Fri Apr 11 14:14:56 CEST 2014