Fix drawing and rename recreateSegments to splitSegments

This commit is contained in:
PavelRatushny 2017-08-25 11:49:25 +03:00
parent ca6c91e995
commit 520aed2ede
3 changed files with 12 additions and 7 deletions

View file

@ -191,7 +191,7 @@ public class MeasurementEditingContext {
after = new TrkSegment();
}
public void recreateSegments(int position) {
public void splitSegments(int position) {
before = new TrkSegment();
before.points.addAll(measurementPoints.subList(0, position));
addBeforeRenders();

View file

@ -607,7 +607,7 @@ public class MeasurementToolFragment extends Fragment {
public void moveOnClick() {
if (measurementLayer != null) {
measurementLayer.enterMovingPointMode();
editingCtx.recreateSegments(editingCtx.getSelectedPointPosition());
editingCtx.splitSegments(editingCtx.getSelectedPointPosition());
}
switchMovePointMode(true);
}
@ -624,7 +624,7 @@ public class MeasurementToolFragment extends Fragment {
public void addPointAfterOnClick() {
if (measurementLayer != null) {
editingCtx.setSelectedPointPosition(editingCtx.getSelectedPointPosition() + 1);
editingCtx.recreateSegments(editingCtx.getSelectedPointPosition());
editingCtx.splitSegments(editingCtx.getSelectedPointPosition());
measurementLayer.enterAddingPointAfterMode();
}
switchAddPointAfterMode(true);
@ -633,7 +633,7 @@ public class MeasurementToolFragment extends Fragment {
@Override
public void addPointBeforeOnClick() {
if (measurementLayer != null) {
editingCtx.recreateSegments(editingCtx.getSelectedPointPosition());
editingCtx.splitSegments(editingCtx.getSelectedPointPosition());
measurementLayer.enterAddingPointBeforeMode();
}
switchAddPointBeforeMode(true);
@ -884,7 +884,7 @@ public class MeasurementToolFragment extends Fragment {
if (measurementLayer != null) {
if (addPointToPosition(editingCtx.getSelectedPointPosition())) {
editingCtx.setSelectedPointPosition(editingCtx.getSelectedPointPosition() + 1);
editingCtx.recreateSegments(editingCtx.getSelectedPointPosition());
editingCtx.splitSegments(editingCtx.getSelectedPointPosition());
measurementLayer.refreshMap();
}
}
@ -916,7 +916,7 @@ public class MeasurementToolFragment extends Fragment {
MeasurementToolLayer measurementLayer = getMeasurementLayer();
if (measurementLayer != null) {
if (addPointToPosition(editingCtx.getSelectedPointPosition())) {
editingCtx.recreateSegments(editingCtx.getSelectedPointPosition());
editingCtx.splitSegments(editingCtx.getSelectedPointPosition());
measurementLayer.refreshMap();
}
}
@ -1040,7 +1040,7 @@ public class MeasurementToolFragment extends Fragment {
MeasurementToolLayer measurementLayer = getMeasurementLayer();
if (measurementLayer != null) {
added = commandManager.execute(new AddPointCommand(measurementLayer, position));
editingCtx.recreateSegments(position);
editingCtx.splitSegments(position);
doAddOrMovePointCommonStuff();
}
return added;

View file

@ -249,6 +249,11 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL
ty.add(tb.getCenterPixelY());
}
if (after.points.size() > 0) {
if (before.points.size() == 0) {
path.moveTo(tb.getCenterPixelX(), tb.getCenterPixelY());
tx.add(tb.getCenterPixelX());
ty.add(tb.getCenterPixelY());
}
WptPt pt = after.points.get(0);
int locX = tb.getPixXFromLonNoRot(pt.lon);
int locY = tb.getPixYFromLatNoRot(pt.lat);