Skip to content

Commit

Permalink
generic circuits have access to the circuit specific settings, closes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
hneemann committed Feb 5, 2021
1 parent f7a37fc commit 822a6f0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class ResolveGenerics {
* Key uses to store the args for the generic circuits
*/
public static final String GEN_ARGS_KEY = "genArgs";
private static final String SETTINGS_KEY = "settings";
private final HashMap<String, Statement> map;
private final HashMap<Args, CircuitHolder> circuitMap;
private final Circuit circuit;
Expand Down Expand Up @@ -163,6 +164,7 @@ private Context createContext(Circuit circuit, ArrayList<VisualElement> newCompo
Context context = new Context();
if (circuit.getOrigin() != null)
context.declareVar(Context.BASE_FILE_KEY, circuit.getOrigin());
context.declareVar(SETTINGS_KEY, new SubstituteLibrary.AllowSetAttributes(circuit.getAttributes()));
context.declareFunc("addWire", new AddWire(newWires));
context.declareFunc("addComponent", new AddComponent(newComponents, args));
return context;
Expand Down Expand Up @@ -308,7 +310,7 @@ private static void addVal(StringBuilder sb, String key, Object val, HashSet<Str
return;
}

if (!key.equals(Context.BASE_FILE_KEY)) {
if (!key.equals(Context.BASE_FILE_KEY) && !key.equals(SETTINGS_KEY)) {
contentSet.add(key);
sb.append(key).append(":=");
if (val instanceof String) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/de/neemann/digital/draw/shapes/LayoutShape.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ public LayoutShape(ElementTypeDescriptionCustom custom, ElementAttributes elemen
}
}

height = left.max(right.max(custom.getAttributes().get(Keys.HEIGHT)));
width = top.max(bottom.max(custom.getAttributes().get(Keys.WIDTH)));
height = left.max(right.max(circuit.getAttributes().get(Keys.HEIGHT)));
width = top.max(bottom.max(circuit.getAttributes().get(Keys.WIDTH)));

HashMap<String, PinPos> map = new HashMap<>();
top.createPosition(map, new Vector(0, 0), width);
Expand Down

0 comments on commit 822a6f0

Please sign in to comment.