MATLAB Function Reference (Volume 2: Graphics)

MATLAB Function Reference (Volume 2: Graphics) MATLAB Function Reference (Volume 2: Graphics)

12.07.2015 Views

oxPurpose2rbboxCreate rubberband box for area selectionSynopsisDescriptionrbboxrbbox(initialRect)rbbox(initialRect,fixedPoint)rbbox(initialRect,fixedPoint,stepSize)finalRect = rbbox(...)rbbox initializes and tracks a rubberband box in the current figure. It sets theinitial rectangular size of the box to 0, anchors the box at the figure’sCurrentPoint, and begins tracking from this point.rbbox(initialRect) specifies the initial location and size of the rubberbandbox as [x y width height], where x and y define the lower-left corner, andwidth and height define the size. initialRect is in the units specified by thecurrent figure’s Units property, and measured from the lower-left corner of thefigure window. The corner of the box closest to the pointer position follows thepointer until rbbox receives a button-up event.rbbox(initialRect,fixedPoint) specifies the corner of the box that remainsfixed. All arguments are in the units specified by the current figure’s Unitsproperty, and measured from the lower-left corner of the figure window.fixedPoint is a two-element vector, [x y]. The tracking point is the cornerdiametrically opposite the anchored corner defined by fixedPoint.rbbox(initialRect,fixedPoint,stepSize) specifies how frequently therubberband box is updated. When the tracking point exceeds stepSize figureunits, rbbox redraws the rubberband box. The default stepsize is 1.finalRect = rbbox(...) returns a four-element vector, [x y width height],where x and y are the x and y components of the lower-left corner of the box,and width and height are the dimensions of the box.Remarksrbbox is useful for defining and resizing a rectangular region:2-384

ox• For box definition, initialRect is [x y 0 0], where (x,y) is the figure’sCurrentPoint.• For box resizing, initialRect defines the rectangular region that you resize(e.g., a legend). fixedPoint is the corner diametrically opposite the trackingpoint.rbbox returns immediately if a button is not currently pressed. Therefore, youuse rbbox with waitforbuttonpress so that the mouse button is down whenrbbox is called. rbbox returns when you release the mouse button.ExamplesAssuming the current view is view(2), use the current axes’ CurrentPointproperty to determine the extent of the rectangle in dataspace units:k = waitforbuttonpress;point1 = get(gca,'CurrentPoint');finalRect = rbbox;point2 = get(gca,'CurrentPoint');point1 = point1(1,1:2);point2 = point2(1,1:2);p1 = min(point1,point2);offset = abs(point1-point2);% button down detected% return figure units% button up detected% extract x and y% calculate locations% and dimensionsx = [p1(1) p1(1)+offset(1) p1(1)+offset(1) p1(1) p1(1)];y = [p1(2) p1(2) p1(2)+offset(2) p1(2)+offset(2) p1(2)];hold onaxis manualplot(x,y)% redraw in dataspace unitsSee Alsoaxis, dragrect, waitforbuttonpress2-385

oxPurpose2rbboxCreate rubberband box for area selectionSynopsisDescriptionrbboxrbbox(initialRect)rbbox(initialRect,fixedPoint)rbbox(initialRect,fixedPoint,stepSize)finalRect = rbbox(...)rbbox initializes and tracks a rubberband box in the current figure. It sets theinitial rectangular size of the box to 0, anchors the box at the figure’sCurrentPoint, and begins tracking from this point.rbbox(initialRect) specifies the initial location and size of the rubberbandbox as [x y width height], where x and y define the lower-left corner, andwidth and height define the size. initialRect is in the units specified by thecurrent figure’s Units property, and measured from the lower-left corner of thefigure window. The corner of the box closest to the pointer position follows thepointer until rbbox receives a button-up event.rbbox(initialRect,fixedPoint) specifies the corner of the box that remainsfixed. All arguments are in the units specified by the current figure’s Unitsproperty, and measured from the lower-left corner of the figure window.fixedPoint is a two-element vector, [x y]. The tracking point is the cornerdiametrically opposite the anchored corner defined by fixedPoint.rbbox(initialRect,fixedPoint,stepSize) specifies how frequently therubberband box is updated. When the tracking point exceeds stepSize figureunits, rbbox redraws the rubberband box. The default stepsize is 1.finalRect = rbbox(...) returns a four-element vector, [x y width height],where x and y are the x and y components of the lower-left corner of the box,and width and height are the dimensions of the box.Remarksrbbox is useful for defining and resizing a rectangular region:2-384

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!