function varargout = PhasePortraitFigure(varargin)
% PHASEPORTRAITFIGURE M-file for PhasePortraitFigure.fig
%      PHASEPORTRAITFIGURE, by itself, creates a new PHASEPORTRAITFIGURE or raises the existing
%      singleton*.
%
%      H = PHASEPORTRAITFIGURE returns the handle to a new PHASEPORTRAITFIGURE or the handle to
%      the existing singleton*.
%
%      PHASEPORTRAITFIGURE('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in PHASEPORTRAITFIGURE.M with the given input arguments.
%
%      PHASEPORTRAITFIGURE('Property','Value',...) creates a new PHASEPORTRAITFIGURE or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before PhasePortraitFigure_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to PhasePortraitFigure_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 PhasePortraitFigure

% Last Modified by GUIDE v2.5 23-May-2009 11:57:37

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @PhasePortraitFigure_OpeningFcn, ...
                   'gui_OutputFcn',  @PhasePortraitFigure_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin & isstr(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 PhasePortraitFigure is made visible.
function PhasePortraitFigure_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to PhasePortraitFigure (see VARARGIN)

% Choose default command line output for PhasePortraitFigure
handles.output = hObject;
handles.baseFigure=varargin{1};
% Update handles structure
guidata(hObject, handles);

% UIWAIT makes PhasePortraitFigure wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = PhasePortraitFigure_OutputFcn(hObject, eventdata, handles)
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;


% --- Executes during object creation, after setting all properties.
function beginWidthMovingWindowEdit_CreateFcn(hObject, eventdata, handles)
% hObject    handle to beginWidthMovingWindowEdit (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



function beginWidthMovingWindowEdit_Callback(hObject, eventdata, handles)
% hObject    handle to beginWidthMovingWindowEdit (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of beginWidthMovingWindowEdit as text
%        str2double(get(hObject,'String')) returns contents of beginWidthMovingWindowEdit as a double


% --- Executes during object creation, after setting all properties.
function edit3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



function edit3_Callback(hObject, eventdata, handles)
% hObject    handle to edit3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit3 as text
%        str2double(get(hObject,'String')) returns contents of edit3 as a double


% --- Executes on button press in kindofMoving.
function kindofMoving_Callback(hObject, eventdata, handles)
% hObject    handle to kindofMoving (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in plotDynamicPPButton.
function plotDynamicPPButton_Callback(hObject, eventdata, handles)
% hObject    handle to plotDynamicPPButton (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global SERIES
global SERIESNAMES
global SERIESINDEX
global SERIESTYPE
global SERIESSTAT

handles=guidata(gcbo);
handlesBase=guidata(handles.baseFigure);

index=get(handlesBase.listbox1,'Value');
X=SERIES{index};

if (CmpStr(get(handles.kindOfMovingWindowPushbutton,'String'),'Перемещение окна')==0)
    kindOfMovingWindow=0;
else
    kindOfMovingWindow=1;
end
windowWidth=str2num(get(handles.beginWidthMovingWindowEdit,'String'));
windowMovingStep=str2num(get(handles.windowMovingEdit,'String'));

indexStart=1;
[m,n]=size(X);
if (n==1) X=X'; [m,n]=size(X); end
figure    
while (indexStart+windowWidth<n)
    %XResTemp=X(1,indexStart:indexStart+windowWidth-1);
    for i = indexStart:indexStart+windowWidth-2
        plot(X(i),X(i+1),'o')
        hold on
    end
    if (kindOfMovingWindow==0)
        indexStart=indexStart+windowMovingStep;
    else
        windowWidth=windowWidth+windowMovingStep;
    end
end
%plot(X)
hold off

% --- Executes during object creation, after setting all properties.
function windowMovingEdit_CreateFcn(hObject, eventdata, handles)
% hObject    handle to windowMovingEdit (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



function windowMovingEdit_Callback(hObject, eventdata, handles)
% hObject    handle to windowMovingEdit (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of windowMovingEdit as text
%        str2double(get(hObject,'String')) returns contents of windowMovingEdit as a double


% --- Executes on button press in kindOfMovingWindowPushbutton.
function kindOfMovingWindowPushbutton_Callback(hObject, eventdata, handles)
% hObject    handle to kindOfMovingWindowPushbutton (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles=guidata(gcbo);
if (CmpStr(get(handles.kindOfMovingWindowPushbutton,'String'),'Перемещение окна')==0)
    set(handles.kindOfMovingWindowPushbutton,'String','Увеличение окна');
    set(handles.windowMovingText,'String','Шаг увеличения окна');
else
    set(handles.kindOfMovingWindowPushbutton,'String','Перемещение окна');
    set(handles.windowMovingText,'String','Шаг перемещения окна');
end


% --- Executes during object creation, after setting all properties.
function edit5_CreateFcn(hObject, eventdata, handles)
% hObject    handle to beginWidthMovingWindowEdit (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



function edit5_Callback(hObject, eventdata, handles)
% hObject    handle to beginWidthMovingWindowEdit (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of beginWidthMovingWindowEdit as text
%        str2double(get(hObject,'String')) returns contents of beginWidthMovingWindowEdit as a double


