mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-13 02:32:09 +10:00
Parts dragged from the component tree or toolbox into a board's Underside Display go on the bottom of the board
This commit is contained in:
@@ -1668,8 +1668,11 @@ public class Presenter implements IPlugInPort {
|
|||||||
// messageDispatcher.dispatchMessage(EventType.SELECTION_RECT_CHANGED,
|
// messageDispatcher.dispatchMessage(EventType.SELECTION_RECT_CHANGED,
|
||||||
// selectionRect);
|
// selectionRect);
|
||||||
} else if (instantiationManager.getComponentSlot() != null) {
|
} else if (instantiationManager.getComponentSlot() != null) {
|
||||||
|
// a component dragged in from the component tree or the toolbox
|
||||||
this.previousScaledPoint = scalePoint(point);
|
this.previousScaledPoint = scalePoint(point);
|
||||||
instantiationManager.updateSingleClick(previousScaledPoint, isSnapToGrid(), currentProject.getGridSpacing());
|
updatePlacementMirror(previousScaledPoint);
|
||||||
|
instantiationManager.updateSingleClick(toPlacementSpace(previousScaledPoint), isSnapToGrid(),
|
||||||
|
currentProject.getGridSpacing());
|
||||||
}
|
}
|
||||||
|
|
||||||
messageDispatcher.dispatchMessage(EventType.REPAINT, false, resizeInProgress);
|
messageDispatcher.dispatchMessage(EventType.REPAINT, false, resizeInProgress);
|
||||||
@@ -2086,6 +2089,9 @@ public class Presenter implements IPlugInPort {
|
|||||||
// calculateSelectionDimension());
|
// calculateSelectionDimension());
|
||||||
} else if (instantiationManager.getComponentSlot() != null) {
|
} else if (instantiationManager.getComponentSlot() != null) {
|
||||||
preDragProject = currentProject.clone();
|
preDragProject = currentProject.clone();
|
||||||
|
if (placementMirrorBoard != null) {
|
||||||
|
MirrorPlacement.placeOnBottom(instantiationManager.getComponentSlot());
|
||||||
|
}
|
||||||
addPendingComponentsToProject(scaledPoint, instantiationManager.getComponentTypeSlot(), null, null, preDragProject);
|
addPendingComponentsToProject(scaledPoint, instantiationManager.getComponentTypeSlot(), null, null, preDragProject);
|
||||||
} else {
|
} else {
|
||||||
updateSelection(selectedComponents);
|
updateSelection(selectedComponents);
|
||||||
|
|||||||
@@ -368,6 +368,25 @@ public class PresenterTests extends TestBase {
|
|||||||
Assert.assertTrue(board.getBoardRectangle().contains(eyelet.getControlPoint(0)));
|
Assert.assertTrue(board.getBoardRectangle().contains(eyelet.getControlPoint(0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDropFromComponentTreeIntoUndersideMirror() {
|
||||||
|
BlankBoard board = mirroredBoard();
|
||||||
|
Rectangle2D region = UndersideMirror.getMirrorRegion(board);
|
||||||
|
Point inMirror = toScreen(new Point2D.Double(region.getCenterX(), region.getCenterY()));
|
||||||
|
ComponentType resistorType = presenter.getComponentTypes().get("Passive").stream()
|
||||||
|
.filter(x -> x.getName().equals("Resistor")).findFirst().get();
|
||||||
|
|
||||||
|
// what the component tree and the canvas drop target do for a drag and drop
|
||||||
|
presenter.setNewComponentTypeSlot(resistorType, null, null, true);
|
||||||
|
presenter.dragOver(inMirror);
|
||||||
|
presenter.dragEnded(inMirror);
|
||||||
|
|
||||||
|
Assert.assertEquals(2, presenter.getCurrentProject().getComponents().size());
|
||||||
|
Resistor resistor = (Resistor) presenter.getCurrentProject().getComponents().get(1);
|
||||||
|
Assert.assertEquals(PCBLayer._1, resistor.getBoardSide());
|
||||||
|
Assert.assertTrue(board.getBoardRectangle().contains(resistor.getControlPoint(0)));
|
||||||
|
}
|
||||||
|
|
||||||
// a board with its underside mirror below it, with nothing on it yet
|
// a board with its underside mirror below it, with nothing on it yet
|
||||||
private BlankBoard mirroredBoard() {
|
private BlankBoard mirroredBoard() {
|
||||||
BlankBoard board = new BlankBoard();
|
BlankBoard board = new BlankBoard();
|
||||||
|
|||||||
@@ -130,8 +130,9 @@ order.
|
|||||||
through that mirror, under the cursor. On placement, `MirrorPlacement.placeOnBottom` sets an
|
through that mirror, under the cursor. On placement, `MirrorPlacement.placeOnBottom` sets an
|
||||||
`IBoardSideComponent` to `_1` (Bottom) and a component with a `PCBLayer` (`setLayer`, found the
|
`IBoardSideComponent` to `_1` (Bottom) and a component with a `PCBLayer` (`setLayer`, found the
|
||||||
same way `PCBLayerFilter` reads `getLayer`) to `_1`; nothing is mirrored. Anything else, such as
|
same way `PCBLayerFilter` reads `getLayer`) to `_1`; nothing is mirrored. Anything else, such as
|
||||||
a jumper, eyelet or wire, is placed at the reflected point unchanged. Dragging a new part from
|
a jumper, eyelet or wire, is placed at the reflected point unchanged. A part dragged in from
|
||||||
the component tree onto a mirror still places it in the main view.
|
the component tree or the toolbox goes through `Presenter.dragOver` and `dragEnded` instead,
|
||||||
|
which pick the mirror and put the part on the bottom the same way.
|
||||||
|
|
||||||
## 4. Open questions
|
## 4. Open questions
|
||||||
|
|
||||||
@@ -150,7 +151,7 @@ order.
|
|||||||
- `MirrorPlacementTest` covers what placing through the mirror changes, and
|
- `MirrorPlacementTest` covers what placing through the mirror changes, and
|
||||||
`PresenterTests.testPlaceThroughUndersideMirror` and `testPlaceUnsidedPartThroughUndersideMirror`
|
`PresenterTests.testPlaceThroughUndersideMirror` and `testPlaceUnsidedPartThroughUndersideMirror`
|
||||||
place a resistor and an eyelet in a mirror and check that they land on the board, the resistor on
|
place a resistor and an eyelet in a mirror and check that they land on the board, the resistor on
|
||||||
the bottom.
|
the bottom; `testDropFromComponentTreeIntoUndersideMirror` does the same for a drag and drop.
|
||||||
- `SilkScreenFilterTest` covers which side's page each part and board outline goes on, and
|
- `SilkScreenFilterTest` covers which side's page each part and board outline goes on, and
|
||||||
`SilkScreenDrawingProviderTest` checks that the bottom page appears only for a bottom part.
|
`SilkScreenDrawingProviderTest` checks that the bottom page appears only for a bottom part.
|
||||||
- `DrawingManagerTest` checks rendered pixels for a part that reports its own side: a bottom part
|
- `DrawingManagerTest` checks rendered pixels for a part that reports its own side: a bottom part
|
||||||
|
|||||||
Reference in New Issue
Block a user