mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
Revert "Rollback Include layer id in continuity areas"
This reverts commit 0f2e581a02.
This commit is contained in:
@@ -27,9 +27,5 @@ public enum PCBLayer {
|
||||
|
||||
public String toString() {
|
||||
return name().substring(1);
|
||||
};
|
||||
|
||||
public int getId() {
|
||||
return Integer.parseInt(toString());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -42,10 +42,9 @@ public interface IDrawingObserver {
|
||||
/**
|
||||
* Notifies the observer that it should start tracking conductive continuity areas.
|
||||
*
|
||||
* @param layerId id of the layer
|
||||
* @param positive designates if the area should be additive or subtractive
|
||||
*/
|
||||
void startTrackingContinuityArea(int layerId, boolean positive);
|
||||
void startTrackingContinuityArea(boolean positive);
|
||||
|
||||
/**
|
||||
* Notifies the observer that it should stop tracking conductive continuity areas.
|
||||
|
||||
@@ -32,17 +32,15 @@ public class ComponentArea implements Serializable {
|
||||
private Area outlineArea;
|
||||
private Collection<Area> continuityPositiveAreas;
|
||||
private Collection<Area> continuityNegativeAreas;
|
||||
private int layerId;
|
||||
|
||||
public ComponentArea() {
|
||||
}
|
||||
|
||||
public ComponentArea(Area outlineArea, Collection<Area> continuityPositiveAreas, Collection<Area> continuityNegativeAreas, int layerId) {
|
||||
public ComponentArea(Area outlineArea, Collection<Area> continuityPositiveAreas, Collection<Area> continuityNegativeAreas) {
|
||||
super();
|
||||
this.outlineArea = outlineArea;
|
||||
this.continuityPositiveAreas = continuityPositiveAreas;
|
||||
this.continuityNegativeAreas = continuityNegativeAreas;
|
||||
this.layerId = layerId;
|
||||
}
|
||||
|
||||
public Area getOutlineArea() {
|
||||
@@ -56,8 +54,4 @@ public class ComponentArea implements Serializable {
|
||||
public Collection<Area> getContinuityNegativeAreas() {
|
||||
return continuityNegativeAreas;
|
||||
}
|
||||
|
||||
public int getLayerId() {
|
||||
return layerId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ public class DrawingCache {
|
||||
stats.getSecond().add(componentEnd - componentStart);
|
||||
|
||||
// copy over tracking area from the cache, regardless if we rendered or not
|
||||
g2d.merge(value.getCurrentArea(), value.getContinuityPositiveAreas(), value.getContinuityNegativeAreas(), value.getLayerId());
|
||||
g2d.merge(value.getCurrentArea(), value.getContinuityPositiveAreas(), value.getContinuityNegativeAreas());
|
||||
} else {
|
||||
// no caching, just draw as usual
|
||||
component.draw(g2d, componentState, outlineMode, project, g2d);
|
||||
@@ -264,7 +264,7 @@ public class DrawingCache {
|
||||
|
||||
// add to the cache
|
||||
value = new CacheValue(component, image, wrapper.getCurrentArea(), wrapper.getContinuityPositiveAreas(),
|
||||
wrapper.getContinuityNegativeAreas(), wrapper.getLayerId(), componentState, outlineMode, zoom, dx, dy, rect);
|
||||
wrapper.getContinuityNegativeAreas(), componentState, outlineMode, zoom, dx, dy, rect);
|
||||
imageCache.put(component, new SoftReference<DrawingCache.CacheValue>(value));
|
||||
}
|
||||
|
||||
@@ -283,13 +283,11 @@ public class DrawingCache {
|
||||
int dx;
|
||||
int dy;
|
||||
Rectangle2D cacheBounds;
|
||||
int layerId;
|
||||
|
||||
public CacheValue(IDIYComponent<?> component, BufferedImage image, Area currentArea,
|
||||
Map<String, Area> continuityPositiveAreas, Map<String, Area> continuityNegativeAreas, int layerId,
|
||||
Map<String, Area> continuityPositiveAreas, Map<String, Area> continuityNegativeAreas,
|
||||
ComponentState state, boolean outlineMode, double zoom, int dx, int dy, Rectangle2D cacheBounds) {
|
||||
super();
|
||||
this.layerId = layerId;
|
||||
this.cacheBounds = cacheBounds;
|
||||
// take a copy of the component, so we can check if it changed in the meantime
|
||||
try {
|
||||
@@ -326,10 +324,6 @@ public class DrawingCache {
|
||||
public Map<String, Area> getContinuityNegativeAreas() {
|
||||
return continuityNegativeAreas;
|
||||
}
|
||||
|
||||
public int getLayerId() {
|
||||
return layerId;
|
||||
}
|
||||
|
||||
public ComponentState getState() {
|
||||
return state;
|
||||
|
||||
@@ -684,22 +684,23 @@ public class DrawingManager {
|
||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||
}
|
||||
|
||||
public void findContinuityAreaAtPoint(Point2D p) {
|
||||
public void findContinuityAreaAtPoint(Project project, Point2D p) {
|
||||
if (continuityGraphCache == null)
|
||||
continuityGraphCache = getContinuityGraph();
|
||||
continuityGraphCache = getContinuityGraph(project);
|
||||
|
||||
currentContinuityAreas = continuityGraphCache.findAreasFor(p);
|
||||
}
|
||||
|
||||
public List<Area> getContinuityAreas() {
|
||||
public List<Area> getContinuityAreas(Project project) {
|
||||
// Find all individual continuity areas for all components
|
||||
List<Area> preliminaryAreas = new ArrayList<Area>();
|
||||
List<Boolean> checkBreakout = new ArrayList<Boolean>();
|
||||
|
||||
for (ComponentArea a : this.componentAreaMap.values()) {
|
||||
for (IDIYComponent<?> c : project.getComponents()) {
|
||||
ComponentArea a = getComponentArea(c);
|
||||
|
||||
if (a == null || a.getOutlineArea() == null)
|
||||
continue;
|
||||
|
||||
Collection<Area> positiveAreas = a.getContinuityPositiveAreas();
|
||||
if (positiveAreas != null)
|
||||
for (Area a1 : positiveAreas) {
|
||||
@@ -732,9 +733,9 @@ public class DrawingManager {
|
||||
return areas;
|
||||
}
|
||||
|
||||
public ContinuityGraph getContinuityGraph() {
|
||||
public ContinuityGraph getContinuityGraph(Project project) {
|
||||
Set<Connection> connections = new HashSet<Connection>();
|
||||
for (IDIYComponent<?> c : this.componentAreaMap.keySet()) {
|
||||
for (IDIYComponent<?> c : project.getComponents()) {
|
||||
if (c instanceof IContinuity) {
|
||||
for (int i = 0; i < c.getControlPointCount() - 1; i++)
|
||||
for (int j = i + 1; j < c.getControlPointCount(); j++)
|
||||
@@ -743,13 +744,13 @@ public class DrawingManager {
|
||||
}
|
||||
}
|
||||
|
||||
List<Area> areas = getContinuityAreas();
|
||||
List<Area> areas = getContinuityAreas(project);
|
||||
|
||||
return NetlistBuilder.buildContinuityGraph(areas, connections);
|
||||
}
|
||||
|
||||
public List<Area> getContinuityAreaProximity(float threshold) {
|
||||
List<Area> continuityAreas = getContinuityAreas();
|
||||
public List<Area> getContinuityAreaProximity(Project project, float threshold) {
|
||||
List<Area> continuityAreas = getContinuityAreas(project);
|
||||
Stroke s = ObjectCache.getInstance().fetchBasicStroke(threshold - 1); // value eyeballed for
|
||||
// approx good results
|
||||
List<Area> expanded = continuityAreas.parallelStream()
|
||||
|
||||
@@ -82,7 +82,6 @@ class G2DWrapper extends Graphics2D implements IDrawingObserver {
|
||||
|
||||
private boolean drawingComponent = false;
|
||||
private boolean trackingAllowed = true;
|
||||
private int layerId;
|
||||
private boolean trackingContinuityAllowed = false;
|
||||
private boolean trackingContinuityPositive = true;
|
||||
|
||||
@@ -104,7 +103,7 @@ class G2DWrapper extends Graphics2D implements IDrawingObserver {
|
||||
private String continuityMarker;
|
||||
private Shape lastShape;
|
||||
|
||||
private double zoom;
|
||||
private double zoom;
|
||||
|
||||
/**
|
||||
* Creates a wrapper around specified {@link Graphics2D} object.
|
||||
@@ -134,7 +133,6 @@ class G2DWrapper extends Graphics2D implements IDrawingObserver {
|
||||
currentArea = new Area();
|
||||
continuityPositiveAreas = new HashMap<String, Area>();
|
||||
continuityNegativeAreas = new HashMap<String, Area>();
|
||||
layerId = 0;
|
||||
// trackingStacks.clear();
|
||||
continuityMarker = null;
|
||||
originalStroke = canvasGraphics.getStroke();
|
||||
@@ -161,8 +159,7 @@ class G2DWrapper extends Graphics2D implements IDrawingObserver {
|
||||
canvasGraphics.setComposite(originalComposite);
|
||||
canvasGraphics.setFont(originalFont);
|
||||
// Map<String, Integer> sorted = sortByComparator(trackingStacks, false);
|
||||
return new ComponentArea(currentArea, new ArrayList<Area>(continuityPositiveAreas.values()),
|
||||
new ArrayList<Area>(continuityNegativeAreas.values()), layerId);
|
||||
return new ComponentArea(currentArea, new ArrayList<Area>(continuityPositiveAreas.values()), new ArrayList<Area>(continuityNegativeAreas.values()));
|
||||
}
|
||||
|
||||
// start - used for caching
|
||||
@@ -179,18 +176,12 @@ class G2DWrapper extends Graphics2D implements IDrawingObserver {
|
||||
return continuityNegativeAreas;
|
||||
}
|
||||
|
||||
public int getLayerId() {
|
||||
return layerId;
|
||||
}
|
||||
|
||||
// end - used for caching
|
||||
|
||||
public void merge(Area currentArea, Map<String, Area> continuityPositiveAreas,
|
||||
Map<String, Area> continuityNegativeAreas, int layerId) {
|
||||
public void merge(Area currentArea, Map<String, Area> continuityPositiveAreas, Map<String, Area> continuityNegativeAreas) {
|
||||
this.currentArea = currentArea;
|
||||
this.continuityPositiveAreas = continuityPositiveAreas;
|
||||
this.continuityNegativeAreas = continuityNegativeAreas;
|
||||
this.layerId = layerId;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -204,8 +195,7 @@ class G2DWrapper extends Graphics2D implements IDrawingObserver {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startTrackingContinuityArea(int layerId, boolean positive) {
|
||||
this.layerId = layerId;
|
||||
public void startTrackingContinuityArea(boolean positive) {
|
||||
this.trackingContinuityAllowed = true;
|
||||
this.trackingContinuityPositive = positive;
|
||||
}
|
||||
|
||||
@@ -680,7 +680,7 @@ public class Presenter implements IPlugInPort {
|
||||
projectFileManager.notifyFileChange();
|
||||
}
|
||||
} else if (configManager.readBoolean(HIGHLIGHT_CONTINUITY_AREA, false) || altDown) {
|
||||
drawingManager.findContinuityAreaAtPoint(scaledPoint);
|
||||
drawingManager.findContinuityAreaAtPoint(currentProject, scaledPoint);
|
||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||
} else {
|
||||
List<IDIYComponent<?>> newSelection = new ArrayList<IDIYComponent<?>>(selectedComponents);
|
||||
@@ -2809,7 +2809,7 @@ public class Presenter implements IPlugInPort {
|
||||
|
||||
@Override
|
||||
public List<Netlist> extractNetlists(boolean includeSwitches) throws NetlistException {
|
||||
List<Area> continuityAreas = drawingManager.getContinuityAreas();
|
||||
List<Area> continuityAreas = drawingManager.getContinuityAreas(currentProject);
|
||||
|
||||
return NetlistBuilder.extractNetlists(includeSwitches, currentProject, continuityAreas);
|
||||
}
|
||||
@@ -2874,12 +2874,11 @@ public class Presenter implements IPlugInPort {
|
||||
ComponentArea componentArea = drawingManager.getComponentArea(c);
|
||||
areas.put(c, componentArea);
|
||||
}
|
||||
return new Snapshot(currentProject.clone(), new HashSet<IDIYComponent<?>>(selectedComponents), areas,
|
||||
new HashSet<Area>(drawingManager.getContinuityAreas()));
|
||||
return new Snapshot(currentProject.clone(), new HashSet<IDIYComponent<?>>(selectedComponents), areas, new HashSet<Area>(drawingManager.getContinuityAreas(currentProject)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Area> checkContinuityAreaProximity(Size threshold) {
|
||||
return drawingManager.getContinuityAreaProximity((float)threshold.convertToPixels());
|
||||
return drawingManager.getContinuityAreaProximity(this.currentProject, (float)threshold.convertToPixels());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user