From 42daa97cccbfcf5b618773f39ff4ce00fdf97f6c Mon Sep 17 00:00:00 2001 From: Nils Schmidt Date: Tue, 28 Feb 2017 21:06:36 +0100 Subject: [PATCH] Fixed issue #509. --- .../dialogs/rotate/RotateDesign.java | 3 ++ .../dialogs/rotate/RotateDialog.java | 14 +++++++ .../dialogs/scale/ScaleDesign.java | 3 ++ .../dialogs/scale/ScaleDialog.java | 14 +++++++ .../setcoordinates/CoordinatesDesign.java | 3 ++ .../setcoordinates/CoordinatesDialog.java | 14 +++++++ .../dialogs/translate/TranslateDesign.java | 3 ++ .../dialogs/translate/TranslateDialog.java | 14 +++++++ .../ldparteditor/i18n/Editor3D.properties | 2 + src/org/nschmidt/ldparteditor/i18n/I18n.java | 1 + .../shells/editor3d/Editor3DWindow.java | 38 ++++++++++++++++++- 11 files changed, 108 insertions(+), 1 deletion(-) diff --git a/src/org/nschmidt/ldparteditor/dialogs/rotate/RotateDesign.java b/src/org/nschmidt/ldparteditor/dialogs/rotate/RotateDesign.java index 90a6d5f50..539c70ae7 100644 --- a/src/org/nschmidt/ldparteditor/dialogs/rotate/RotateDesign.java +++ b/src/org/nschmidt/ldparteditor/dialogs/rotate/RotateDesign.java @@ -55,6 +55,8 @@ class RotateDesign extends Dialog { final Button[] btn_Local = new Button[1]; final Button[] btn_Global = new Button[1]; + final Button[] btn_Copy = new Button[1]; + final Button[] rb_Xaxis = new Button[1]; final Button[] rb_Yaxis = new Button[1]; final Button[] rb_Zaxis = new Button[1]; @@ -251,6 +253,7 @@ protected Control createDialogArea(Composite parent) { */ @Override protected void createButtonsForButtonBar(Composite parent) { + btn_Copy[0] = createButton(parent, IDialogConstants.OK_ID, I18n.E3D_CreateTransformedCopy, false); createButton(parent, IDialogConstants.OK_ID, I18n.DIALOG_OK, false); createButton(parent, IDialogConstants.CANCEL_ID, I18n.DIALOG_Cancel, false); } diff --git a/src/org/nschmidt/ldparteditor/dialogs/rotate/RotateDialog.java b/src/org/nschmidt/ldparteditor/dialogs/rotate/RotateDialog.java index d5c76cde9..290a7794a 100644 --- a/src/org/nschmidt/ldparteditor/dialogs/rotate/RotateDialog.java +++ b/src/org/nschmidt/ldparteditor/dialogs/rotate/RotateDialog.java @@ -44,6 +44,7 @@ public class RotateDialog extends RotateDesign { private static boolean x = true; private static boolean y = false; private static boolean z = false; + private static boolean creatingCopy = false; /** * Create the dialog. @@ -55,6 +56,7 @@ public RotateDialog(Shell parentShell, Vertex v, Set clipboardVertices, x = true; y = false; z = false; + creatingCopy = false; if (v == null) { setAngles(new Vertex(0f, 0f, 0f)); } else { @@ -188,9 +190,21 @@ public void widgetSelected(SelectionEvent e) { spn_pZ[0].setValue(c.Z); } }); + btn_Copy[0].addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + creatingCopy = true; + setReturnCode(OK); + close(); + } + }); return super.open(); } + public static boolean isCreatingCopy() { + return creatingCopy; + } + public static boolean isZ() { return z; } diff --git a/src/org/nschmidt/ldparteditor/dialogs/scale/ScaleDesign.java b/src/org/nschmidt/ldparteditor/dialogs/scale/ScaleDesign.java index fcf7baa91..7ef141987 100644 --- a/src/org/nschmidt/ldparteditor/dialogs/scale/ScaleDesign.java +++ b/src/org/nschmidt/ldparteditor/dialogs/scale/ScaleDesign.java @@ -55,6 +55,8 @@ class ScaleDesign extends Dialog { final Button[] btn_Local = new Button[1]; final Button[] btn_Global = new Button[1]; + final Button[] btn_Copy = new Button[1]; + final Button[] cb_Xaxis = new Button[1]; final Button[] cb_Yaxis = new Button[1]; final Button[] cb_Zaxis = new Button[1]; @@ -265,6 +267,7 @@ protected Control createDialogArea(Composite parent) { */ @Override protected void createButtonsForButtonBar(Composite parent) { + btn_Copy[0] = createButton(parent, IDialogConstants.OK_ID, I18n.E3D_CreateTransformedCopy, false); createButton(parent, IDialogConstants.OK_ID, I18n.DIALOG_OK, false); createButton(parent, IDialogConstants.CANCEL_ID, I18n.DIALOG_Cancel, false); } diff --git a/src/org/nschmidt/ldparteditor/dialogs/scale/ScaleDialog.java b/src/org/nschmidt/ldparteditor/dialogs/scale/ScaleDialog.java index 951399cbd..733eb5d4b 100644 --- a/src/org/nschmidt/ldparteditor/dialogs/scale/ScaleDialog.java +++ b/src/org/nschmidt/ldparteditor/dialogs/scale/ScaleDialog.java @@ -44,6 +44,7 @@ public class ScaleDialog extends ScaleDesign { private static boolean x = true; private static boolean y = true; private static boolean z = true; + private static boolean creatingCopy = false; /** * Create the dialog. @@ -55,6 +56,7 @@ public ScaleDialog(Shell parentShell, Vertex v, Set clipboardVertices, V x = true; y = true; z = true; + creatingCopy = false; if (v == null) { setScaleFactors(new Vertex(1f, 1f, 1f)); } else { @@ -158,9 +160,21 @@ public void widgetSelected(SelectionEvent e) { spn_pZ[0].setValue(c.Z); } }); + btn_Copy[0].addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + creatingCopy = true; + setReturnCode(OK); + close(); + } + }); return super.open(); } + public static boolean isCreatingCopy() { + return creatingCopy; + } + public static boolean isZ() { return z; } diff --git a/src/org/nschmidt/ldparteditor/dialogs/setcoordinates/CoordinatesDesign.java b/src/org/nschmidt/ldparteditor/dialogs/setcoordinates/CoordinatesDesign.java index f5df68bc2..c58485d96 100644 --- a/src/org/nschmidt/ldparteditor/dialogs/setcoordinates/CoordinatesDesign.java +++ b/src/org/nschmidt/ldparteditor/dialogs/setcoordinates/CoordinatesDesign.java @@ -54,6 +54,8 @@ class CoordinatesDesign extends Dialog { final Button[] btn_Local = new Button[1]; final Button[] btn_Global = new Button[1]; + final Button[] btn_Copy = new Button[1]; + final Button[] cb_Xaxis = new Button[1]; final Button[] cb_Yaxis = new Button[1]; final Button[] cb_Zaxis = new Button[1]; @@ -211,6 +213,7 @@ protected Control createDialogArea(Composite parent) { */ @Override protected void createButtonsForButtonBar(Composite parent) { + btn_Copy[0] = createButton(parent, IDialogConstants.OK_ID, I18n.E3D_CreateTransformedCopy, false); createButton(parent, IDialogConstants.OK_ID, I18n.DIALOG_OK, false); createButton(parent, IDialogConstants.CANCEL_ID, I18n.DIALOG_Cancel, false); } diff --git a/src/org/nschmidt/ldparteditor/dialogs/setcoordinates/CoordinatesDialog.java b/src/org/nschmidt/ldparteditor/dialogs/setcoordinates/CoordinatesDialog.java index 404947773..8cfec8cd5 100644 --- a/src/org/nschmidt/ldparteditor/dialogs/setcoordinates/CoordinatesDialog.java +++ b/src/org/nschmidt/ldparteditor/dialogs/setcoordinates/CoordinatesDialog.java @@ -50,6 +50,7 @@ public class CoordinatesDialog extends CoordinatesDesign { private static boolean x = false; private static boolean y = false; private static boolean z = false; + private static boolean creatingCopy = false; private final Manipulator mani; @@ -63,6 +64,7 @@ public CoordinatesDialog(Shell parentShell, Vertex v, Vertex manipulatorPosition x = false; y = false; z = false; + creatingCopy = false; if (v == null) { vertex = new Vertex(0f, 0f, 0f); } else { @@ -166,9 +168,21 @@ public void widgetSelected(SelectionEvent e) { updateXYZ(); } }); + btn_Copy[0].addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + creatingCopy = true; + setReturnCode(OK); + close(); + } + }); return super.open(); } + public static boolean isCreatingCopy() { + return creatingCopy; + } + public static boolean isZ() { return z; } diff --git a/src/org/nschmidt/ldparteditor/dialogs/translate/TranslateDesign.java b/src/org/nschmidt/ldparteditor/dialogs/translate/TranslateDesign.java index 386f5beb6..c6575e165 100644 --- a/src/org/nschmidt/ldparteditor/dialogs/translate/TranslateDesign.java +++ b/src/org/nschmidt/ldparteditor/dialogs/translate/TranslateDesign.java @@ -53,6 +53,8 @@ class TranslateDesign extends Dialog { final Button[] btn_Local = new Button[1]; final Button[] btn_Global = new Button[1]; + final Button[] btn_Copy = new Button[1]; + final Button[] cb_Xaxis = new Button[1]; final Button[] cb_Yaxis = new Button[1]; final Button[] cb_Zaxis = new Button[1]; @@ -192,6 +194,7 @@ protected Control createDialogArea(Composite parent) { */ @Override protected void createButtonsForButtonBar(Composite parent) { + btn_Copy[0] = createButton(parent, IDialogConstants.OK_ID, I18n.E3D_CreateTransformedCopy, false); createButton(parent, IDialogConstants.OK_ID, I18n.DIALOG_OK, false); createButton(parent, IDialogConstants.CANCEL_ID, I18n.DIALOG_Cancel, false); } diff --git a/src/org/nschmidt/ldparteditor/dialogs/translate/TranslateDialog.java b/src/org/nschmidt/ldparteditor/dialogs/translate/TranslateDialog.java index a0216c7d6..8daa4a8a4 100644 --- a/src/org/nschmidt/ldparteditor/dialogs/translate/TranslateDialog.java +++ b/src/org/nschmidt/ldparteditor/dialogs/translate/TranslateDialog.java @@ -42,6 +42,7 @@ public class TranslateDialog extends TranslateDesign { private static boolean x = true; private static boolean y = true; private static boolean z = true; + private static boolean creatingCopy = false; /** * Create the dialog. @@ -53,6 +54,7 @@ public TranslateDialog(Shell parentShell, Vertex manipulatorPosition, Manipulato x = true; y = true; z = true; + creatingCopy = false; manipulator = manipulatorPosition; } @@ -135,9 +137,21 @@ public void valueChanged(BigDecimalSpinner spn) { setOffset(new Vertex(spn_X[0].getValue(), spn_Y[0].getValue(), spn_Z[0].getValue())); } }); + btn_Copy[0].addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + creatingCopy = true; + setReturnCode(OK); + close(); + } + }); return super.open(); } + public static boolean isCreatingCopy() { + return creatingCopy; + } + public static boolean isZ() { return z; } diff --git a/src/org/nschmidt/ldparteditor/i18n/Editor3D.properties b/src/org/nschmidt/ldparteditor/i18n/Editor3D.properties index 5187ad933..5be0ecf42 100644 --- a/src/org/nschmidt/ldparteditor/i18n/Editor3D.properties +++ b/src/org/nschmidt/ldparteditor/i18n/Editor3D.properties @@ -73,6 +73,8 @@ CopyToUnofficialLibrary = Copy To Unofficial Library CreateNewDat = Create a new *.dat file +CreateTransformedCopy = Create Copy + Decolour = Decolour Part DeleteConfig = Are you sure to delete your configuration on the next start? diff --git a/src/org/nschmidt/ldparteditor/i18n/I18n.java b/src/org/nschmidt/ldparteditor/i18n/I18n.java index 4e54ecf92..67746ea9f 100644 --- a/src/org/nschmidt/ldparteditor/i18n/I18n.java +++ b/src/org/nschmidt/ldparteditor/i18n/I18n.java @@ -390,6 +390,7 @@ private static void adjust() { // Calculate line offset public static final String E3D_ControlClickModify = E3D.getString(getProperty()); public static final String E3D_CopyToUnofficialLibrary = E3D.getString(getProperty()); public static final String E3D_CreateNewDat = E3D.getString(getProperty()); + public static final String E3D_CreateTransformedCopy = E3D.getString(getProperty()); public static final String E3D_Decolour = E3D.getString(getProperty()); public static final String E3D_DeleteConfig = E3D.getString(getProperty()); public static final String E3D_DragHint = E3D.getString(getProperty()); diff --git a/src/org/nschmidt/ldparteditor/shells/editor3d/Editor3DWindow.java b/src/org/nschmidt/ldparteditor/shells/editor3d/Editor3DWindow.java index e8201426d..97cfd7260 100644 --- a/src/org/nschmidt/ldparteditor/shells/editor3d/Editor3DWindow.java +++ b/src/org/nschmidt/ldparteditor/shells/editor3d/Editor3DWindow.java @@ -3995,7 +3995,16 @@ public void widgetSelected(SelectionEvent e) { CoordinatesDialog.setZ(c); } } else { - vm.setXyzOrTranslateOrTransform(CoordinatesDialog.getVertex(), null, TransformationMode.SET, CoordinatesDialog.isX(), CoordinatesDialog.isY(), CoordinatesDialog.isZ(), isMovingAdjacentData() || vm.getSelectedData().size() == 0 || vm.getSelectedVertices().size() == 1, true, CoordinatesDialog.getTransformationMode()); + final boolean moveAdjacentData = isMovingAdjacentData(); + if (CoordinatesDialog.isCreatingCopy()) { + vm.copy(); + vm.paste(); + setMovingAdjacentData(false); + vm.setXyzOrTranslateOrTransform(CoordinatesDialog.getVertex(), null, TransformationMode.SET, CoordinatesDialog.isX(), CoordinatesDialog.isY(), CoordinatesDialog.isZ(), false, true, CoordinatesDialog.getTransformationMode()); + setMovingAdjacentData(moveAdjacentData); + } else { + vm.setXyzOrTranslateOrTransform(CoordinatesDialog.getVertex(), null, TransformationMode.SET, CoordinatesDialog.isX(), CoordinatesDialog.isY(), CoordinatesDialog.isZ(), isMovingAdjacentData() || vm.getSelectedData().size() == 0 || vm.getSelectedVertices().size() == 1, true, CoordinatesDialog.getTransformationMode()); + } } if (noReset) { @@ -4024,7 +4033,16 @@ public void widgetSelected(SelectionEvent e) { Editor3DWindow.getWindow().setWorkingAction(WorkingMode.MOVE); if (new TranslateDialog(getShell(), new Vertex(c3d.getManipulator().getAccuratePosition()), transformationMode).open() == IDialogConstants.OK_ID) { c3d.getLockableDatFileReference().getVertexManager().addSnapshot(); + final boolean moveAdjacentData = isMovingAdjacentData(); + if (TranslateDialog.isCreatingCopy()) { + c3d.getLockableDatFileReference().getVertexManager().copy(); + c3d.getLockableDatFileReference().getVertexManager().paste(); + setMovingAdjacentData(false); + } c3d.getLockableDatFileReference().getVertexManager().setXyzOrTranslateOrTransform(TranslateDialog.getOffset(), null, TransformationMode.TRANSLATE, TranslateDialog.isX(), TranslateDialog.isY(), TranslateDialog.isZ(), isMovingAdjacentData(), true, TranslateDialog.getTransformationMode()); + if (TranslateDialog.isCreatingCopy()) { + setMovingAdjacentData(moveAdjacentData); + } } Editor3DWindow.getWindow().setWorkingAction(action); regainFocus(); @@ -4075,7 +4093,16 @@ public void widgetSelected(SelectionEvent e) { Editor3DWindow.getWindow().setWorkingAction(WorkingMode.MOVE); if (new RotateDialog(getShell(), null, clipboard, mani, transformationMode).open() == IDialogConstants.OK_ID) { c3d.getLockableDatFileReference().getVertexManager().addSnapshot(); + final boolean moveAdjacentData = isMovingAdjacentData(); + if (RotateDialog.isCreatingCopy()) { + c3d.getLockableDatFileReference().getVertexManager().copy(); + c3d.getLockableDatFileReference().getVertexManager().paste(); + setMovingAdjacentData(false); + } c3d.getLockableDatFileReference().getVertexManager().setXyzOrTranslateOrTransform(RotateDialog.getAngles(), RotateDialog.getPivot(), TransformationMode.ROTATE, RotateDialog.isX(), RotateDialog.isY(), RotateDialog.isZ(), isMovingAdjacentData(), true, RotateDialog.getTransformationMode()); + if (RotateDialog.isCreatingCopy()) { + setMovingAdjacentData(moveAdjacentData); + } } Editor3DWindow.getWindow().setWorkingAction(action); regainFocus(); @@ -4126,7 +4153,16 @@ public void widgetSelected(SelectionEvent e) { Editor3DWindow.getWindow().setWorkingAction(WorkingMode.MOVE); if (new ScaleDialog(getShell(), null, clipboard, mani, transformationMode).open() == IDialogConstants.OK_ID) { c3d.getLockableDatFileReference().getVertexManager().addSnapshot(); + final boolean moveAdjacentData = isMovingAdjacentData(); + if (ScaleDialog.isCreatingCopy()) { + c3d.getLockableDatFileReference().getVertexManager().copy(); + c3d.getLockableDatFileReference().getVertexManager().paste(); + setMovingAdjacentData(false); + } c3d.getLockableDatFileReference().getVertexManager().setXyzOrTranslateOrTransform(ScaleDialog.getScaleFactors(), ScaleDialog.getPivot(), TransformationMode.SCALE, ScaleDialog.isX(), ScaleDialog.isY(), ScaleDialog.isZ(), isMovingAdjacentData(), true, ScaleDialog.getTransformationMode()); + if (ScaleDialog.isCreatingCopy()) { + setMovingAdjacentData(moveAdjacentData); + } } Editor3DWindow.getWindow().setWorkingAction(action); regainFocus();