function theResult = PXValue(self, theValue)

% PXValue -- Set/get the value.
%  PXValue(self, theValue) sets the value of self,
%   a "pxsurface", by selecting those points of self
%   indicated by the indices given in theValue.
%   Use a value of [] to de-select the whole surface.
%  PXValue(self) returns a logical array whose value
%   is 1 for each selected element of self.
 
% Copyright (C) 1997 Dr. Charles R. Denham, ZYDECO.
%  All Rights Reserved.
%   Disclosure without explicit written consent from the
%    copyright owner does not constitute publication.
 
% Version of 06-Jun-1997 11:00:55.

if nargin < 1, help(mfilename), return, end

g = pxget(self, 'itsCompanion');
gz = get(g, 'ZData');
[m, n] = size(gz);
i = 2:2:m; j = 2:2:n;
selected = ~isnan(gz(i, j));

if nargin > 1
   if isempty(theValue)
      selected = theValue;
   else
      selected(:) = theValue;
   end
end

if nargin > 1
   selected = theValue;
   if isempty(selected)
      gz(i, j) = NaN;
     else
      h = px(self);
      zz = get(h, 'ZData') + 1;
      zz(~selected) = NaN;
      gz(i,  j) = zz + 1;
   end
   set(g, 'ZData', gz)
end
  
result = selected;

if nargout > 0
   theResult = result;
else
   disp(result)
end
