function varargout = test_motion(varargin)
% TEST_MOTION MATLAB code for test_motion.fig
%      TEST_MOTION, by itself, creates a new TEST_MOTION or raises the existing
%      singleton*.
%
%      H = TEST_MOTION returns the handle to a new TEST_MOTION or the handle to
%      the existing singleton*.
%
%      TEST_MOTION('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in TEST_MOTION.M with the given input arguments.
%
%      TEST_MOTION('Property','Value',...) creates a new TEST_MOTION or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before test_motion_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to test_motion_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help test_motion

% Last Modified by GUIDE v2.5 05-Dec-2013 18:27:21

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @test_motion_OpeningFcn, ...
                   'gui_OutputFcn',  @test_motion_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before test_motion is made visible.
function test_motion_OpeningFcn(hObject, eventdata, handles, varargin)

handles.output = hObject;

% Update handles structure
guidata(hObject, handles);


% --- Outputs from this function are returned to the command line.
function varargout = test_motion_OutputFcn(hObject, eventdata, handles) 

varargout{1} = handles.output;


function axes1_CreateFcn(hObject, eventdata, handles)
imshow('fragezeichen.jpg')


function axes2_CreateFcn(hObject, eventdata, handles)
imshow('fragezeichen.jpg')


function figure1_WindowButtonMotionFcn(hObject, eventdata, handles)
pos = get(handles.figure1,'Currentpoint');
x1 = pos(1);
y1 = pos(2);

pos_panel = get(handles.uipanel1,'position');

pos_axes1 = get(handles.axes1,'position');
% Position auf figure1 beziehen
pos_axes1(1) = pos_axes1(1) + pos_panel(1);
pos_axes1(2) = pos_axes1(2) + pos_panel(2);

pos_axes2 = get(handles.axes2,'position');
% Position auf figure1 beziehen
pos_axes2(1) = pos_axes2(1) + pos_panel(1);
pos_axes2(2) = pos_axes2(2) + pos_panel(2);

if (x1>pos_axes1(1) && x1<(pos_axes1(1)+pos_axes1(3))) && (y1>pos_axes1(2) && y1<(pos_axes1(2)+pos_axes1(4)))

    if ~isfield(handles,'help')
        handles.help = text((pos_axes1(1)+0.5*pos_axes1(3)),(pos_axes1(2)+0.5*pos_axes1(4)),...
            'text1','BackgroundColor',[.7 .9 .7],'EdgeColor','red');
    end
    
elseif (x1>pos_axes2(1) && x1<(pos_axes2(1)+pos_axes2(3))) && (y1>pos_axes2(2) && y1<(pos_axes2(2)+pos_axes2(4)))
    if ~isfield(handles,'help')
        handles.help = text((pos_axes2(1)+0.5*pos_axes2(3)),(pos_axes2(2)+0.5*pos_axes2(4)),...
            'text2','BackgroundColor',[.7 .9 .7],'EdgeColor','red','FontUnits','pixels');
    end
    
else
    if isfield(handles,'help')
        delete(handles.help)
        handles = rmfield(handles,'help');
    end
end
    
guidata(hObject,handles)
    
