File: do_delete1.sci

package info (click to toggle)
scilab 2.4-1
  • links: PTS
  • area: non-free
  • in suites: potato, slink
  • size: 55,196 kB
  • ctags: 38,019
  • sloc: ansic: 231,970; fortran: 148,976; tcl: 7,099; makefile: 4,585; sh: 2,978; csh: 154; cpp: 101; asm: 39; sed: 5
file content (89 lines) | stat: -rw-r--r-- 2,902 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
function [scs_m,DEL,DELL]=do_delete1(scs_m,K,gr)
//perform deletion of scs_m object whose index are given in the vector 
//K and all other relevant objects (link, splits,..)
// if gr==%t objects are also graphicaly erased.
//
// deleted objects are replaced by the value : list('Deleted') not to 
// change the indexing use do_purge to suppress them and to renumber objects 
//!
// Copyright INRIA
DEL=[] //table of deleted objects
DELL=[] //table of redefined links
while K<>[] do
  k=K(1);K(1)=[]
  o=scs_m(k);
  if find(DEL==k)==[] then typ=o(1);else typ='Deleted',end
  //typ=o(1)
  DEL=[DEL k]

  if typ=='Link' then
    [ct,from,to]=o(7:9)
    //  free connected ports
    scs_m(from(1))=mark_prt(scs_m(from(1)),from(2),'out',ct(2),0)
    scs_m(to(1))=mark_prt(scs_m(to(1)),to(2),'in',ct(2),0)
    
    // erase and delete link
    if gr==%t then drawobj(o),end
    fromblock=scs_m(from(1));
    toblock=scs_m(to(1));
    if fromblock(5)=='SPLIT_f'|fromblock(5)=='CLKSPLIT_f' then
      //user kills a split  output link, 
      //we create a unique link with  the split input and remaining output links
      //and suppress the split block
      connected=get_connected(scs_m,from(1))//get links connected to the split block
      if size(connected,'*')==2 then
	if find(connected(2)==DEL)<>[] then // delete split
	  K=[from(1) K]
	else
	  if gr==%t then drawobj(scs_m(from(1))),end // clear  split block
	  DEL=[DEL  from(1)]       //suppress split block
	  //create a unique link
	  o1=scs_m(connected(1));from1=o1(9);
	  o2=scs_m(connected(2));
	  if from1(1)<>from(1) then [o1,o2]=(o2,o1),connected=connected([2 1]);end
	  from1=o1(9);to2=o2(9);ct2=o2(7)
	  //the links comes from connected(1) block and goes to connected(2) block
	  x1=o1(2);y1=o1(3)
	  if x1($-1)==x1($)&o2(2)(1)==o2(2)(2)|.. // both segs are vertical
	    y1($-1)==y1($)&o2(3)(1)==o2(3)(2) then // both segs are horizontal
	    o1(2)=[x1(1:$-1);o2(2)(2:$)];
	    o1(3)=[y1(1:$-1);o2(3)(2:$)];
	  else
	    o1(2)=[x1(1:$-1);o2(2)];
	    o1(3)=[y1(1:$-1);o2(3)];
	  end
	  o1(9)=o2(9);
	  DEL=[DEL connected(2)] // supress one link
	  DELL=[DELL  connected(2)]
	  scs_m(connected(1))=o1 //change link
	  scs_m(to2(1))=mark_prt(scs_m(to2(1)),to2(2),'in',ct2(2),connected(1))
	end
      end
    end
    if toblock(5)=='SPLIT_f'|toblock(5)=='CLKSPLIT_f' then
      //user kills a split input link
      //ask for split deletion
      K=[K to(1)]
    end
  elseif typ=='Block' then
    // get connected links
    connected=get_connected(scs_m,k)
    //ask for connected links deletion
    K=[K connected]
    // erase and delete block
    if gr==%t then drawobj(scs_m(k)),end
  elseif typ=='Text' then
    if gr==%t then drawobj(o),end
  elseif typ=='Deleted' then
  else
    message('This object can''t be deleted')
  end
end


if gr==%t then 
  if pixmap then xset('wshow'),end,
end
for k=DEL,scs_m(k)=list('Deleted'),end