Skip to content

Commit

Permalink
Fixed issue #509.
Browse files Browse the repository at this point in the history
  • Loading branch information
nilsschmidt1337 committed Feb 28, 2017
1 parent 8d05340 commit 42daa97
Show file tree
Hide file tree
Showing 11 changed files with 108 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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);
}
Expand Down
14 changes: 14 additions & 0 deletions src/org/nschmidt/ldparteditor/dialogs/rotate/RotateDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -55,6 +56,7 @@ public RotateDialog(Shell parentShell, Vertex v, Set<Vertex> clipboardVertices,
x = true;
y = false;
z = false;
creatingCopy = false;
if (v == null) {
setAngles(new Vertex(0f, 0f, 0f));
} else {
Expand Down Expand Up @@ -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;
}
Expand Down
3 changes: 3 additions & 0 deletions src/org/nschmidt/ldparteditor/dialogs/scale/ScaleDesign.java
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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);
}
Expand Down
14 changes: 14 additions & 0 deletions src/org/nschmidt/ldparteditor/dialogs/scale/ScaleDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -55,6 +56,7 @@ public ScaleDialog(Shell parentShell, Vertex v, Set<Vertex> clipboardVertices, V
x = true;
y = true;
z = true;
creatingCopy = false;
if (v == null) {
setScaleFactors(new Vertex(1f, 1f, 1f));
} else {
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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 {
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -53,6 +54,7 @@ public TranslateDialog(Shell parentShell, Vertex manipulatorPosition, Manipulato
x = true;
y = true;
z = true;
creatingCopy = false;
manipulator = manipulatorPosition;
}

Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 2 additions & 0 deletions src/org/nschmidt/ldparteditor/i18n/Editor3D.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
1 change: 1 addition & 0 deletions src/org/nschmidt/ldparteditor/i18n/I18n.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 42daa97

Please sign in to comment.