Interfacing function
eng


VECTORSCOPEXY_c

File content


//VECTORSCOPEXY_c Scicos vector visualization block
//Classical interface function ver1.0 - scilab-4.1
//24 Mai 2007 - INRIA - Author : A.Layec
function [x,y,typ]=VECTORSCOPEXY_c(job,arg1,arg2)
x=[];y=[];typ=[]
select job
case 'plot' then
  standard_draw(arg1)
case 'getinputs' then
  [x,y,typ]=standard_inputs(arg1)
case 'getoutputs' then
  x=[];y=[];typ=[];
case 'getorigin' then
  [x,y]=standard_origin(arg1)
case 'set' then
  x=arg1;
  graphics=arg1.graphics;
  exprs=graphics.exprs;
  model=arg1.model;

  //compatibility : add wdim
  if size(exprs,'*')==7 then exprs=[exprs;'[400;400]'], end

  while %t do
    [ok,nu,wid,nvec,isline,x_dim,y_dim,herit,wdim,exprs] = getvalue(..
        'Set Scope parameters',..
        ['In size';
         'Output window number (automatic:-1)';
         'Number of vector to display';
         'Plot lines (no:0, yes:1)';
         'X axis bound [min,max] (autoscale:-1)';
         'Y axis bound [min,max] (autoscale:-1)';
         'Inherit (no:0, yes:1)';
         'Window sizes'],..
        list('vec',1,..
             'vec',1,..
             'vec',1,..
             'vec',1,..
             'vec',-1,..
             'vec',-1,..
             'vec',1,..
             'vec',-1),exprs)

    if ~ok then break,end //user cancel modification

    mess=[]

    //check values of user param
    if size(y_dim,'*')>=2 then
      if y_dim(1)<>-1 & y_dim(2)<>-1 then
        if y_dim(1)>=y_dim(2) then
          mess=[mess;'Ymax must be greater than Ymin';' ']
          ok=%f
        end
      end
    end
    if size(x_dim,'*')>=2 then
      if x_dim(1)<>-1 & x_dim(2)<>-1 then
        if x_dim(1)>=x_dim(2) then
          mess=[mess;'Xmax must be greater than Xmin';' ']
          ok=%f
        end
      end
    end

    if size(wdim,'*')<>0 &size(wdim,'*')<>2 then
      mess=[mess;'Window dim must be [] or a 2 vector';' ']
      ok=%f
    end

    if ~ok then
      message(['Some specified values are inconsistent:';
                 ' ';mess])
    end

    //adjust size of ports block
    if ok then
      if nu==0 then nu=-1, end
      if isline<>0 then isline=1, end
      if herit==1 then
        [model,graphics,ok]=check_io(model,graphics,[nu;nu],[],[],[])
      else
        [model,graphics,ok]=check_io(model,graphics,[nu;nu],[],1,[])
      end
    end

    //auto adjustement of some values
    if ok then
      if nvec<=0 then nvec=1, end;
      if size(y_dim,'*')==1 then //autoscale
        ymin=%eps;
        ymax=1;
        scaltyp_y=1
      else
        if y_dim(1)==-1 & y_dim(2)==-1 then //autoscale
          ymin=%eps;
          ymax=1;
          scaltyp_y=1
        else
          ymin=y_dim(1);
          ymax=y_dim(2);
          scaltyp_y=0
        end
      end
      if size(x_dim,'*')==1 then //autoscale
        xmin=%eps;
        xmax=1;
        scaltyp_x=1
      else
        if x_dim(1)==-1 & x_dim(2)==-1 then //autoscale
          xmin=%eps;
          xmax=1;
          scaltyp_x=1
        else
          xmin=x_dim(1);
          xmax=x_dim(2);
          scaltyp_x=0
        end
      end
    end

    //set model
    if ok then
      if wdim==[] then wdim=[-1;-1];end
      ipar=[wid;nvec;scaltyp_y;scaltyp_x;isline;wdim(:)]
      rpar=[ymin;ymax;xmin;xmax]
      model.rpar=rpar(:)
      model.ipar=ipar(:)
      graphics.exprs=exprs;
      x.graphics=graphics;
      x.model=model
      break
    end

  end
case 'define' then
  //ipar
  wid       = -1        //ipar(1)
  nvec      =  1        //ipar(2)
  scaltyp_y =  0        //ipar(3)
  scaltyp_x =  0        //ipar(4)
  isline    =  1        //ipar(5)
  wdim      = [400;400] //ipar(6)/ipar(7)

  ipar = [wid;nvec;scaltyp_y;scaltyp_x;isline;wdim]

  //rpar
  ymin  =  -1.5 //rpar(1)
  ymax  =  1.5  //rpar(2)
  xmin  =  -1.5 //rpar(3)
  xmax  =  1.5  //rpar(4)

  rpar  =  [ymin;ymax;xmin;xmax]

  herit =  0
  nu    =  -1

  model=scicos_model()
  model.sim=list('vectorscopexy41',4)
  model.in=[nu;nu]
  model.out=[]
  model.evtin=[1]
  model.evtout=[]
  model.dstate=[0]
  model.ipar=ipar(:)
  model.rpar=rpar(:)
  model.blocktype='d'
  model.firing=[]
  model.dep_ut=[%t %f]

  exprs=[string(nu)          //1 in size
         string(wid)         //2 windows id
         string(nvec)        //3 number of vectors
         string(isline)      //4 y axis bounds
         sci2exp([-1.5 1.5]) //5 y axis bounds
         sci2exp([-1.5 1.5]) //6 y axis bounds
         string(herit)       //7 Inherit
         sci2exp(wdim)       //8 window size
        ];
  gr_i=['thick=xget(''thickness'');';
        'pat=xget(''pattern'');';
        'fnt=xget(''font'');';
        'xset(''thickness'',2);';
        'xrect(orig(1)+sz(1)/10,orig(2)+(1-1/10)*sz(2),sz(1)*8/10,sz(2)*8/10);';
        'xset(''thickness'',1);';
        'x=orig(1)+sz(1)/10+sz(1)/8;';
        'y=orig(2)+(1-1/10-1/8)*sz(2);';
        'w1=sz(1)*(8/10-1/4);';
        'h1=sz(2)*(8/10-1/4);';
        'a=0.015*w1;';
        'b=0.015*w1;';
        'w2 = w1;   h2 = a*h1;';
        'w3 = b*w1; h3 = h1;';
        'w4 = w2;   h4 = h2;';
        'w5 = w3;   h5 = h3;';
        'u1 = [x         , y         ];';
        'u2 = [x         , y+h2/2    ];';
        'u3 = [x+w1-w3/2 , y         ];';
        'u4 = [x         , y-h1+h4/2 ];';
        'u5 = [x-w5/2    , y         ];';
        'xarc(u2(1,1),u2(1,2),w2,h2,0,360*64);';
        'xarc(u3(1,1),u3(1,2),w3,h3,0,360*64);';
        'xarc(u4(1,1),u4(1,2),w4,h4,0,360*64);';
        'xarc(u5(1,1),u5(1,2),w5,h5,0,360*64);';
        'xrect(u1(1,1),u1(1,2),w1,h1);';
        'xfarc(u1(1,1)-w1/20,u1(1,2)+w1/20,w1/10,h1/10,0,360*64);';
        'xfarc(u1(1,1)-w1/20+w1,u1(1,2)+w1/20,w1/10,h1/10,0,360*64);';
        'xfarc(u1(1,1)-w1/20+w1,u1(1,2)+w1/20-h1,w1/10,h1/10,0,360*64);';
        'xfarc(u1(1,1)-w1/20,u1(1,2)+w1/20-h1,w1/10,h1/10,0,360*64);';
        'xset(''thickness'',thick);';
        'xset(''pattern'',pat);';
        'xset(''font'',fnt(1),fnt(2));';
       ]
  x=standard_define([2 2],model,exprs,gr_i)

end
endfunction