www.gusucode.com > mbcdata 工具箱 matlab 源码程序 > mbcdata/@cgcalinput/private/pGetCalibration.m
function out = pGetCalibration(cal, axisAware, pm) %PGETCALIBRATION Private helper function. % % OUT = PGETCALIBRATION(CAL,AXISAWARE,PM) is the workhorse for getting % cgcalinput information out of a calibration interface CAL. AXISAWARE is % a flag that is true for interfaces that treat axes as items in their own % right, and false for interfaces that treat axes as properties of their % parents. PM is a progress manager, used to display the progress of the % import operation. % % The current cgcalinput interface does not support use of the AXISAWARE % flag, but may in future. % Copyright 2000-2011 The MathWorks, Inc. % Input arguments narginchk(1,3); if nargin < 2 axisAware = true; end if nargin < 3 || isempty(pm) pm = calibrationdata.progressmanager; end pm.reset; pm.notify('Converting to CAGE information...'); % Get identifiers valueIdentifiers = cal.getValueIdentifiers; axisIdentifiers = cal.getAxisIdentifiers; axisIdentifierTypes = cal.pGetAxisIdentifierType(axisIdentifiers); axisIdentifiers(~strcmp(axisIdentifierTypes,'public')) = []; % only public curveIdentifiers = cal.getCurveIdentifiers; mapIdentifiers = cal.getMapIdentifiers; % Store lengths for convenience nValues = length(valueIdentifiers); nAxes = length(axisIdentifiers); nCurves = length(curveIdentifiers); nMaps = length(mapIdentifiers); % Preallocate output emptyStruct = struct('name',[],... 'description',[],... 'info',[],... 'data',struct('X',[],'Y',[],'Z',[]),... 'numaxes',[],... 'numrows',[],... 'numcols',[]); out = repmat(emptyStruct, nValues + nAxes + nCurves + nMaps, 1); % Set up standard import message message = sprintf('Loaded from %s', cal.Description); % Values if nValues > 0 pm.notify(sprintf('Retrieving %d values...', nValues)); values = cal.getValue(valueIdentifiers); valueDescriptions = get(values, {'Description'}); valueValues = get(values, {'Value'}); pm.notify(sprintf('Processing %d values...', nValues)); for i = 1:nValues, this = emptyStruct; this.name = valueIdentifiers{i}; this.description = valueDescriptions{i}; this.info = message; this.data.X = valueValues{i}; this.data.Y = 1; this.numaxes = 1; this.numrows = 1; this.numcols = 1; out(i) = this; pm.update(i/(nValues+nAxes+nCurves+nMaps)); end end % Axes if nAxes > 0 pm.notify(sprintf('Retrieving %d axes...', nAxes)); axes = cal.getAxis(axisIdentifiers); axisDescriptions = get(axes, {'Description'}); axisValues = get(axes, {'Value'}); axisIndices = get(axes, {'Index'}); pm.notify(sprintf('Processing %d axes...', nAxes)); for i = 1:nAxes, this = emptyStruct; this.name = axisIdentifiers{i}; this.description = axisDescriptions{i}; this.info = message; this.data.X = axisValues{i}; this.data.Y = axisIndices{i}-1; % CAGE is 0-based, axis is 1-based this.numaxes = 2; this.numrows = numel(this.data.X); this.numcols = 0; out(i+nValues) = this; pm.update((i+nValues)/(nValues+nAxes+nCurves+nMaps)); end end % Curves if nCurves > 0 pm.notify(sprintf('Retrieving %d curves...', nCurves)); curves = cal.getCurve(curveIdentifiers); xAxes = cal.getAxis(get(curves, {'XAxisIdentifier'})); curveDescriptions = get(curves, {'Description'}); curveValues = get(curves, {'Value'}); xAxisValues = get(xAxes, {'Value'}); pm.notify(sprintf('Processing %d curves...', nCurves)); for i = 1:nCurves, this = emptyStruct; this.name = curveIdentifiers{i}; this.description = curveDescriptions{i}; this.info = message; this.data.X = xAxisValues{i}; this.data.Y = curveValues{i}; this.numaxes = 2; this.numrows = length(this.data.X); this.numcols = 0; out(i+nValues+nAxes) = this; pm.update((i+nValues+nAxes)/(nValues+nAxes+nCurves+nMaps)); end end % Maps if nMaps > 0 pm.notify(sprintf('Retrieving %d maps...', nMaps)); maps = cal.getMap(mapIdentifiers); xAxes = cal.getAxis(get(maps, {'XAxisIdentifier'})); yAxes = cal.getAxis(get(maps, {'YAxisIdentifier'})); mapDescriptions = get(maps, {'Description'}); mapValues = get(maps, {'Value'}); xAxisValues = get(xAxes, {'Value'}); yAxisValues = get(yAxes, {'Value'}); pm.notify(sprintf('Processing %d maps...', nMaps)); for i = 1:nMaps, this = emptyStruct; this.name = mapIdentifiers{i}; this.description = mapDescriptions{i}; this.info = message; this.data.X = xAxisValues{i}; this.data.Y = yAxisValues{i}; this.data.Z = mapValues{i}; this.numaxes = 3; this.numrows = length(this.data.X); this.numcols = length(this.data.Y); out(i+nValues+nAxes+nCurves) = this; pm.update((i+nValues+nAxes+nCurves)/(nValues+nAxes+nCurves+nMaps)); end end pm.update(1); pm.notify('Import completed.');