コマンドの実行

コマンドを実行させるには

ボタンなどのが押された時、スライダーの値が変化した時などにどのコマンド・手続きを 実行するかを定義するためには下に記したオプションを使用する。

コマンドを定義するためのオプション

以下のオプションの後ろに文字列で実行されるコマンドを定義する。
ただし、すべてのコマンドにこれらのオプションがあるとは限らない。

int $num;
float $rad;

proc changeSlider()
{
	global int $num;
	global float $rad;

	$num = `intSliderGrp -query -value numberSlider`;
	$rad = `floatSliderGrp -query -value radiusSlider`;
}

proc makeSphere()
{
	global float $rad;
	global int $num;
	float $x, $z;
	float $r;
	float $add;
	float $rr = 2 * 3.1415;

	$add = $rr / $num;
	for($r = 0.0; $r < $rr; $r += $add)
	{
		$x = $rad * cos($r);
		$z = $rad * sin($r);
		sphere;
		move $x 0.0 $z;
	}
}

$window = `window`;
columnLayout;
	text -label "Make Sphere Circle";

	floatSliderGrp -label "Circle Radius" -field true 
		-min 0.1 -max 20.0 -step 0.5 -value 1.0
		-changeCommand "changeSlider" radiusSlider;
	intSliderGrp -label "Number of Spheres" -field true
		-min 1 -max 20 -step 1 -value 1
		-changeCommand "changeSlider" numberSlider;
	rowColumnLayout -numberOfColumns 2;
		button -label "Apply" -align "center" -command "makeSphere";
		button -label "Cancel" -align "center" -command "deleteUI $window";
		setParent ..;

showWindow;

[sample of executing command]

参考


prev | next
Home | Contents
Mail