%
%	ReadViewDef.m
%
%	Carina Winter [1998], Markus Junghoefer [2000]
%
%   This software is protected by german copyright and international treaties.             
%   Copyright 2004 Markus Junghöfer & Peter Peyk. All Rights Reserved.                     
%                                                                                          
%   THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE        
%   NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO,    
%   WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE    
%   OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS,
%   TRADEMARKS OR OTHER RIGHTS. COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT,       
%   INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE      
%   OR DOCUMENTATION.                                                                      
%
%	
%	Function definition

function[ReadViewDefVersion,DefECfgFilePath,DefZeroLineStyle,DefZeroLineColor,DefTriggerLineStyle,DefTriggerLineColor,...
DefCursorLineStyle,DefCursorLineColor,DefTrigPoint, DefCursorPoint,DefViewVal,DefMinAmp,...
DefMaxAmp,DefMinPoint,DefMaxPoint,DefMinBase,DefMaxBase, ...
DefChanFigBGColor,DefFileNoVec,Color,LineStyle,DefCalcBaseStatus,...
DefZeroLineStatus,DefTriggerLineStatus,DefCursorLineStatus]=ReadViewDef(FilePath)
%	
%	
%=================================================================

fid=fopen(FilePath,'r','b');

F = fread(fid,7,'char');
if strcmp(setstr(F'),'Version')
    ReadViewDefVersion=fread(fid,1,'int16');
else
    ReadViewDefVersion=0;
    fseek(fid,0,-1);
end
StringSize = fread(fid,1,'int8');
F = fread(fid,StringSize,'char');
DefECfgFilePath = setstr(F');

StringSize = fread(fid,1,'int8');
F = fread(fid,StringSize,'char');
DefZeroLineStyle = setstr(F');
DefZeroLineColor = fread(fid,3,'int8');
if ReadViewDefVersion>1
    DefZeroLineStatus = fread(fid,1,'int8');
else
    DefZeroLineStatus=1;
end

StringSize = fread(fid,1,'int8');
F = fread(fid,StringSize,'char');
DefTriggerLineStyle = setstr(F');
DefTriggerLineColor = fread(fid,3,'int8');
if ReadViewDefVersion>1
    DefTriggerLineStatus = fread(fid,1,'int8');
else
    DefTriggerLineStatus=1;
end

StringSize = fread(fid,1,'int8');
F = fread(fid,StringSize,'char');
DefCursorLineStyle = setstr(F');
DefCursorLineColor = fread(fid,3,'int8');
if ReadViewDefVersion>1
    DefCursorLineStatus = fread(fid,1,'int8');
else
    DefCursorLineStatus=1;
end

DefTrigPoint = fread(fid,1,'float32');

StringSize = fread(fid,1,'int8');
F = fread(fid,StringSize,'char');
DefCursorPoint = setstr(F');

DefViewVal = fread(fid,1,'int8');

DefMinAmp = fread(fid,1,'float32');
DefMaxAmp = fread(fid,1,'float32');

StringSize = fread(fid,1,'int8');
F = fread(fid,StringSize,'char');
DefMinPoint = setstr(F');

StringSize = fread(fid,1,'int8');
F = fread(fid,StringSize,'char');
DefMaxPoint = setstr(F');

StringSize = fread(fid,1,'int8');
F = fread(fid,StringSize,'char');
DefMinBase = setstr(F');

StringSize = fread(fid,1,'int8');
F = fread(fid,StringSize,'char');
DefMaxBase = setstr(F');
if ReadViewDefVersion>0
    DefCalcBaseStatus=fread(fid,1,'int8');
else
    DefCalcBaseStatus=1;
end
DefChanFigBGColor = fread(fid,3,'float32');	%Geaendert MJ
vec_size = fread(fid,1,'int8');
DefFileNoVec = fread(fid,vec_size,'int8');

for FileNo=1:length(DefFileNoVec)
    Color(FileNo)=fread(fid,1,'int8');
    LineStyle(FileNo) = fread(fid,1,'int8');
end;
fclose(fid);
