gusucode.com > 三维模仿源码程序 > 三维模仿源码程序/MathRubik2/FindRubikCube.m

    function Cube=FindRubikCube
%FindRubikAxes - Find a Rubik-cube

if isempty(findobj('Type','figure'))
	error('No figures available')
end
f=gcf;
hAxes=[];
if strcmp(get(f,'Tag'),'RubikFigure')
	ca=get(f,'CurrentAxes');
	if strcmp(get(ca,'Tag'),'RubikAxes')
		hAxes=ca;
	else
		hAxes=findobj(f,'Tag','RubikAxes');
		if isempty(hAxes)
			error('Can''t find the right axes in this figure')
		elseif length(hAxes)>1
			error('Can''t select the right axes in this figure!')
		end
	end
end
if isempty(hAxes)
	hAxes=findobj('Tag','RubikAxes');
	if isempty(hAxes)
		error('Cann''t find any Rubik axes');
	elseif length(hAxes)>1
		error('Can''t select the right axes!!')
	end
end
Cube=get(hAxes,'UserData');