Sysquake Pro – Table of Contents

Sysquake for LaTeX – Table of Contents

# Interactivity Functions

Interactive figures defined in SQ files and SQ scripts rely on special functions which describe precisely which element the user maniulates and where. For more informations, you should read the chapters SQ Files References and SQ Script References.

### firstrun

Determine whether the SQ script is run for the first time.

#### Syntax

b = firstrun

#### Description

`firstrun` returns true if the SQ script is run for the first
time after loading or reset, or false otherwise. For SQ scripts with interactive
graphics, it should be used to give an initial value to variables which can
later be manipulated by the user.

`firstrun` must not be used in SQ files.

#### Example

The following SQ script initializes variable `x` only once
to random values; then the user can manipuate each point interactively.

if firstrun x = rand(1,10); end if _id == 1 x(_ix) = _y1; end plot(1:10, x, '', 1);

### _dx _dy _dz

Displacement between current and previous position during a manipulation.

#### Syntax

dx = _dx dy = _dy dz = _dz

#### Description

When the button of the mouse is held down, `_dx` gives the horizontal
displacement from the previous to the current position of the mouse;
it is equivalent to `_x1-_x`. `_dy` give the vertical
displacement. `_dz` give both displacements as a complex number.

#### See also

`_x`,
`_y`,
`_y`,
`_x1`,
`_y1`,
`_y1`,
`_kx`,
`_ky`,
`_kz`

### _id

ID of the manipulated graphics object.

#### Syntax

n = _id

#### Description

When a graphics object drawn with an ID argument larger than zero is
manipulated with the mouse, `_id` gives its ID; in all other
cases, `_id` is the empty array `[]`.

#### Example

if firstrun y = 3; x = 2; end switch _id case 1 % the horizontal line is being manipulated y = _y1; case 2 % the vertical line is being manipulated x = _x1; end line([0,1], y, 'b', 1); line([1,0], x, 'r', 2);

### _ix

Index of the manipulated graphical element.

#### Syntax

n = _ix

#### Description

When a graphical object drawn with an ID argument larger than zero is
manipulated with the mouse, `_ix` gives the index of the point
being manipulated; in all other
cases, `_ix` is the empty array `[]`.

#### Example

if firstrun y = rand(1,10); end if ~isempty(_ix) y(_ix) = _y1; end plot(y, 'g', 1);

### _kx _ky _kz

Ratio between current and previous position during a manipulation.

#### Syntax

kx = _kx ky = _ky kz = _kz

#### Description

When the button of the mouse is held down, `_kx` gives the ratio
between the horizontal position of the mouse and the previous horizontal position;
it is equivalent to `_x1/_x`. `_kx` is
typically used to change a scale or a gain. `_ky` does the same
vertically, and `_kz` for both directions as a complex number.

#### Example

if firstrun num = 1; den = [1,2,3,4]; end if ~isempty(_ky) % change the gain of the transfer function num/den num = _ky * num; end step(num,den,'b',1);

#### See also

`_x`,
`_y`,
`_z`,
`_x1`,
`_y1`,
`_z1`,
`_dx`,
`_dy`,
`_dz`

### _nb

Number of the manipulated trace.

#### Syntax

n = _nb

#### Description

When a graphical object drawn with an ID argument larger than zero is
manipulated with the mouse, `_nb` gives the number of the trace
being manipulated; in all other
cases, `_ix` is the empty array `[]`.

#### Example

if firstrun Y = rand(5,10); end if ~isempty(_nb) Y(_nb,_ix) = _y1; end plot(Y, 'b', 1);

### _m

State of the Shift key during a manipulation.

#### Syntax

b = _m

#### Description

During a manipulation with the mouse, `_m` is
true if the Shift key is held down or false otherwise.

### _q

Plot-specific value.

#### Syntax

q = _q

#### Description

When a graphical object drawn with an ID argument larger than zero is
manipulated with the mouse, `_q` gives a value which
depends on the graphics; in all other
cases, `_ix` is the empty array `[]`. Not
all graphics define a value for `_q`.

#### Example

Root locus where the closed-loop and open-loop poles may be manipulated:

if firstrun % define an initial transfer function num = -1; den = 1:4; end switch _id case 1 % gain change num = num * _q; case 2 % new location of open-loop poles den = movezero(den, _z0, _z1); end scale('equal',[-3,1,-2,2]); sgrid; % root locus for a gain >= 0 rlocus(num,den,'r',1); % closed-loop poles on the root locus plotroots(addpol(num,den),'^',1); % open-loop poles (gain=0) plotroots(den, 'x', 2);

### _rho _theta

Mouse position in polar coordinates when the button was pressed.

#### Syntax

rho = _rho theta = _theta

#### Description

When the button of the mouse is held down, `_rho` and
`_theta` give the position at the instant when the button was
pressed in polar coordinates, i.e. `_rho` is `sqrt(_x^2+_y^2)`
and `_theta` is `atan2(_y,_x)`. In all other cases,
they return the empty array `[]`.

#### See also

`_x`,
`_y`,
`_z`,
`_rho0`,
`_theta0`,
`_rho1`,
`_theta1`

### _rho0 _theta0

Initial position of the object being manipulated in polar coordinates.

#### Syntax

rho = _rho0 theta = _theta0

#### Description

When the button of the mouse is held down over a graphical object
drawn with an ID argument larger than zero, `_rho0` and
`_theta0` give its initial position in polar coordinates,
i.e. `_rho0` is `sqrt(_x0^2+_y0^2)`
and `_theta0` is `atan2(_y0,_x0)`. In all other cases,
they return the empty array `[]`.

#### See also

`_x0`,
`_y0`,
`_z0`,
`_rho`,
`_theta`,
`_rho1`,
`_theta1`

### _rho1 _theta1

Current position of the mouse in polar coordinates during a manipulation.

#### Syntax

rho = _rho1 theta = _theta1

#### Description

When the button of the mouse is held down, `_rho` and
`_theta` give the current position of the mouse in polar coordinates,
i.e. `_rho1` is `sqrt(_x1^2+_y1^2)`
and `_theta1` is `atan2(_y1,_x1)`. In all other cases,
they return the empty array `[]`.

#### See also

`_x1`,
`_y1`,
`_z1`,
`_rho0`,
`_theta0`,
`_rho`,
`_theta`

### _str1

Current string parameter during a manipulation.

#### Syntax

s = _str1

#### Description

`_str1` gives the new string value of a textfield. It is typically
used in the mousedrag handler, like `_x1` for numeric textfield values,
even if it is not related to mouse operations.

#### See also

### _v

Values of SQ variables.

#### Syntax

v = _v

#### Description

In a handler, `_v` gives a structure whose fields contain
the value of SQ variables.

### _x _y _z

Mouse position when the button was pressed.

#### Syntax

x = _x y = _y z = _z

#### Description

When the button of the mouse is held down, `_x` gives the
horizontal position at the instant when the button was pressed; in all other
cases, `_x` is the empty array `[]`. `_y`
gives the vertical position; `_z` gives the horizontal and
vertical position as a complex number.

#### Example

% define a region where the user can click scale([0,10,0,10]); if ~isempty(_x) % draws a line between the mousedown position % and the current position plot([_x,_x1],[_y,_y1]); end

#### See also

### _x0 _y0 _z0 _p0

Initial position of the object being manipulated with the mouse.

#### Syntax

x = _x0 y = _y0 z = _z0 p = _p0

#### Description

When the button of the mouse is held down over a graphical object
drawn with an ID argument larger than zero, `_x0` gives its initial
horizontal position; in all other
cases, `_x0` is the empty array `[]`. `_y0`
gives the vertical position; `_z0` gives the horizontal and
vertical position as a complex number; and `_p0` gives the
position as a 2D vector for 2D graphics and as a 3D vector for 3D graphics.

#### See also

`_x`,
`_y`,
`_z`,
`_x1`,
`_y1`,
`_z1`,
`_p1`

### _x1 _y1 _z1 _p1

Current position of the mouse during a manipulation.

#### Syntax

x = _x1 y = _y1 z = _z1 p = _p1

#### Description

When the button of the mouse is held down, `_x1` gives the current
horizontal position of the mouse; otherwise (when the button is up), `_x1`
is the empty array `[]`. `_y1`
gives the vertical position; `_z1` gives the horizontal and
vertical position as a complex number; and `_p1` gives
the position as a 2D vector for 2D graphics and as a 3D vector for 3D
graphics, using the associated surface set by `sensor3`.