mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
added ability to include or exclude switches from netlist analyzer
This commit is contained in:
@@ -35,9 +35,10 @@ public interface INetlistProcessor {
|
||||
/**
|
||||
* Finds all {@link Netlist}s for each switch position combination.
|
||||
*
|
||||
* @param includeSwitches
|
||||
* @return
|
||||
*/
|
||||
List<Netlist> extractNetlists();
|
||||
List<Netlist> extractNetlists(boolean includeSwitches);
|
||||
|
||||
/**
|
||||
* Finds all available {@link INetlistAnalyzer} implementations.
|
||||
|
||||
@@ -1906,7 +1906,7 @@ public class Presenter implements IPlugInPort {
|
||||
public void expandSelection(ExpansionMode expansionMode) {
|
||||
LOG.info(String.format("expandSelection(%s)", expansionMode));
|
||||
List<IDIYComponent<?>> newSelection = new ArrayList<IDIYComponent<?>>(this.selectedComponents);
|
||||
List<Netlist> netlists = extractNetlists();
|
||||
List<Netlist> netlists = extractNetlists(false);
|
||||
List<Set<IDIYComponent<?>>> allGroups = NetlistAnalyzer.extractComponentGroups(netlists);
|
||||
// Find control points of all selected components and all types
|
||||
Set<String> selectedNamePrefixes = new HashSet<String>();
|
||||
@@ -2699,29 +2699,30 @@ public class Presenter implements IPlugInPort {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public List<Netlist> extractNetlists() {
|
||||
public List<Netlist> extractNetlists(boolean includeSwitches) {
|
||||
Map<Netlist, Netlist> result = new HashMap<Netlist, Netlist>();
|
||||
List<Node> nodes = new ArrayList<Node>();
|
||||
|
||||
List<ISwitch> switches = new ArrayList<ISwitch>();
|
||||
|
||||
for (IDIYComponent<?> c : currentProject.getComponents()) {
|
||||
ComponentType type =
|
||||
ComponentProcessor.getInstance().extractComponentTypeFrom((Class<? extends IDIYComponent<?>>) c.getClass());
|
||||
|
||||
|
||||
// extract nodes
|
||||
if (!(c instanceof IContinuity)) {
|
||||
for (int i = 0; i < c.getControlPointCount(); i++) {
|
||||
String nodeName = c.getControlPointNodeName(i);
|
||||
if (nodeName != null) {
|
||||
if (nodeName != null && (!includeSwitches || !ISwitch.class.isAssignableFrom(type.getInstanceClass()))) {
|
||||
nodes.add(new Node(c, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// extract switches
|
||||
if (ISwitch.class.isAssignableFrom(type.getInstanceClass()))
|
||||
switches.add((ISwitch)c);
|
||||
}
|
||||
if (includeSwitches && ISwitch.class.isAssignableFrom(type.getInstanceClass()))
|
||||
switches.add((ISwitch) c);
|
||||
}
|
||||
|
||||
// save us the trouble
|
||||
if (nodes.isEmpty())
|
||||
|
||||
Reference in New Issue
Block a user