mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 09:12:09 +10:00
snap rigid components back to the grid
This commit is contained in:
@@ -1321,19 +1321,23 @@ public class Presenter implements IPlugInPort {
|
|||||||
Dimension d = drawingManager.getCanvasDimensions(currentProject, 1d, useExtraSpace);
|
Dimension d = drawingManager.getCanvasDimensions(currentProject, 1d, useExtraSpace);
|
||||||
double extraSpace = useExtraSpace ? drawingManager.getExtraSpace(currentProject) : 0;
|
double extraSpace = useExtraSpace ? drawingManager.getExtraSpace(currentProject) : 0;
|
||||||
|
|
||||||
|
boolean isRigid = true;
|
||||||
|
|
||||||
List<Point2D> points = new ArrayList<Point2D>();
|
List<Point2D> points = new ArrayList<Point2D>();
|
||||||
for (Map.Entry<IDIYComponent<?>, Set<Integer>> entry : controlPointMap.entrySet()) {
|
for (Map.Entry<IDIYComponent<?>, Set<Integer>> entry : controlPointMap.entrySet()) {
|
||||||
for (Integer i : entry.getValue())
|
for (Integer i : entry.getValue())
|
||||||
{
|
{
|
||||||
Point2D p = entry.getKey().getControlPoint(i);
|
Point2D p = entry.getKey().getControlPoint(i);
|
||||||
|
if (entry.getKey().canPointMoveFreely(i))
|
||||||
|
isRigid = false;
|
||||||
points.add(p);
|
points.add(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Point2D firstPoint = points.iterator().next();
|
Point2D firstPoint = points.iterator().next();
|
||||||
if (points.size() == 1 || points.stream().allMatch((x) -> x.equals(firstPoint))) {
|
if (points.size() == 1 || points.stream().allMatch((x) -> x.equals(firstPoint)) || (controlPointMap.size() == 1 && isRigid)) {
|
||||||
double avgX = points.stream().mapToDouble((x) -> x.getX()).average().getAsDouble();
|
double avgX = firstPoint.getX();//points.stream().mapToDouble((x) -> x.getX()).average().getAsDouble();
|
||||||
double avgY = points.stream().mapToDouble((x) -> x.getY()).average().getAsDouble();
|
double avgY = firstPoint.getY();//points.stream().mapToDouble((x) -> x.getY()).average().getAsDouble();
|
||||||
|
|
||||||
Point2D testPoint = new Point2D.Double(avgX + dx, avgY + dy);
|
Point2D testPoint = new Point2D.Double(avgX + dx, avgY + dy);
|
||||||
if (snapToGrid) {
|
if (snapToGrid) {
|
||||||
|
|||||||
@@ -3298,6 +3298,10 @@
|
|||||||
<changeType>IMPROVEMENT</changeType>
|
<changeType>IMPROVEMENT</changeType>
|
||||||
<description>In cases when there's already a component in the selection that is reduced to nothing, allow moving the selection to avoid getting stuck</description>
|
<description>In cases when there's already a component in the selection that is reduced to nothing, allow moving the selection to avoid getting stuck</description>
|
||||||
</org.diylc.appframework.update.Change>
|
</org.diylc.appframework.update.Change>
|
||||||
|
<org.diylc.appframework.update.Change>
|
||||||
|
<changeType>IMPROVEMENT</changeType>
|
||||||
|
<description>Moving a rigid component (e.g. tube/transistor symbol) which is not snapped to grid makes it snap back to the grid when 'Snap to Grid' is switched on</description>
|
||||||
|
</org.diylc.appframework.update.Change>
|
||||||
<org.diylc.appframework.update.Change>
|
<org.diylc.appframework.update.Change>
|
||||||
<changeType>IMPROVEMENT</changeType>
|
<changeType>IMPROVEMENT</changeType>
|
||||||
<description>Apply context menu rotation and mirroring to Trimmer Potentiometer components</description>
|
<description>Apply context menu rotation and mirroring to Trimmer Potentiometer components</description>
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user