File: showclass.ulp

package info (click to toggle)
eagle 5.10.0-2
  • links: PTS
  • area: non-free
  • in suites: squeeze
  • size: 88,616 kB
  • ctags: 720
  • sloc: makefile: 33; sh: 24
file content (115 lines) | stat: -rw-r--r-- 3,067 bytes parent folder | download | duplicates (2)
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#usage  "en:  <h3>Highlights all net with a given CLASS.</h3>\n"
             "This ULPs works from within a board or a schematic.<br>"
             "<p><author>Author: alf@cadsoft.de</author>",
        "de:  <h3>Hebt Signale der gegebenen CLASS hervor.</h3>\n"
             "Dieses ULP arbeitet aus Boards oder Schematics heraus.<br>"
             "<p><author>Author: alf@cadsoft.de</author>"

#require 5.0300

string strTexts[] = {
    "en\v"
    "de\v"
    ,
    ";This ULP requires a board or a schematic.\v"
    ";Dieses Ulp funktioniert nur in Boards und Schematics.\v"
    ,
    "Please type in the CLASS you want to highlight.\v"
    "Geben Sie dei hervorzuhebende CLASS ein.\v"
    ,
    ";No Nets/Signals found with CLASS \"%s\".\v"
    ";Es wurden keine Signale der CLASS \"%s\" gefunden.\v"
};

string strMessage;
string strScript, s;
int nCount;
string strValue;

/*** functions ***/
string Translate(string src) {
  string strLoc = lookup(strTexts, src, strstr(strTexts[0], language()) / 3, '\v');
  return((strLoc != "") ? strLoc : src);
}

string InputBox(string strPrompt, string strTitle, string strDefault) {
  string strReturn = strDefault;
  int nResult = dlgDialog(strTitle) {
    dlgGridLayout {
      dlgCell(1, 0)   dlgStringEdit(strReturn);
      dlgCell(0, 0)   dlgHBoxLayout {
                        dlgLabel(strPrompt);
                        dlgSpacing(20);
                        dlgVBoxLayout {
                          dlgPushButton("+OK") dlgAccept();
                          dlgPushButton("Cancel") dlgReject();
                        }
                     }
    }
  };
  return((nResult > 0) ? strReturn : "");
}


if (argv[1]) {
  strValue = argv[1];
}


if(board) board(B) {
  if (!strValue) {
    strValue = InputBox(Translate("Please type in the CLASS you want to highlight."), filename(argv[0]), B.name);
  }
  if(!strValue) exit(EXIT_SUCCESS);
  sprintf(strScript, "WINDOW;\n SHOW ");  // 2008-11-03
  B.signals(S) {
    if(S.class.number == strtol(strValue)) {
       sprintf(s, " %s ", S.name);
       strScript += s;
       ++nCount;
    }
  }
  strScript +=" ";

  if(!nCount) {
    sprintf(strMessage, Translate(";No Nets/Signals found with CLASS \"%s\"."), strValue);
    dlgMessageBox(strMessage);
    exit(EXIT_FAILURE);
  }
  else {
    exit(strScript);
  }
}

else if(sheet) sheet(S) {
  string strName;
  schematic(SCH) {
    strName = SCH.name;
  }
  if (!strValue) {
    strValue = InputBox(Translate("Please type in the value you want to highlight."), filename(argv[0]), "");
  }
  if(!strValue) exit(EXIT_SUCCESS);

  sprintf(strScript, "WINDOW;\nSHOW ");
  S.nets(N) {
    if(N.class.number == strtol(strValue)) {
      sprintf(s, " %s", N.name);
      strScript += s;
      ++nCount;
    }
  }
  strScript += " ";
  if(!nCount) {
    sprintf(strMessage, Translate(";No Nets/Signals found with CLASS \"%s\"."), strValue);
    dlgMessageBox(strMessage);
    exit(EXIT_FAILURE);
  }
  else {
    exit(strScript);
  }
}
else {
  dlgMessageBox(Translate(";This ULP requires a board or a schematic."));
}