From 06e5133049fdba6e8d959d8d393a4d28cdac893d Mon Sep 17 00:00:00 2001 From: Nils Schmidt Date: Tue, 12 Dec 2017 20:14:06 +0100 Subject: [PATCH] Prepared fix for issue #614. --- .../data/VM28SlantingMatrixProjector.java | 28 ++++++ .../ldparteditor/data/VM99Clipboard.java | 2 +- .../SlantingMatrixProjectorDesign.java | 92 +++++++++++++++++++ .../SlantingMatrixProjectorDialog.java | 49 ++++++++++ .../ldparteditor/i18n/Editor3D.properties | 2 + src/org/nschmidt/ldparteditor/i18n/I18n.java | 1 + .../shells/editor3d/Editor3DDesign.java | 6 ++ .../shells/editor3d/Editor3DWindow.java | 20 ++++ 8 files changed, 199 insertions(+), 1 deletion(-) create mode 100644 src/org/nschmidt/ldparteditor/data/VM28SlantingMatrixProjector.java create mode 100644 src/org/nschmidt/ldparteditor/dialogs/slantingmatrixprojector/SlantingMatrixProjectorDesign.java create mode 100644 src/org/nschmidt/ldparteditor/dialogs/slantingmatrixprojector/SlantingMatrixProjectorDialog.java diff --git a/src/org/nschmidt/ldparteditor/data/VM28SlantingMatrixProjector.java b/src/org/nschmidt/ldparteditor/data/VM28SlantingMatrixProjector.java new file mode 100644 index 000000000..0b9050008 --- /dev/null +++ b/src/org/nschmidt/ldparteditor/data/VM28SlantingMatrixProjector.java @@ -0,0 +1,28 @@ +/* MIT - License + +Copyright (c) 2012 - this year, Nils Schmidt + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +package org.nschmidt.ldparteditor.data; + +public class VM28SlantingMatrixProjector extends VM27YTruder { + + protected VM28SlantingMatrixProjector(DatFile linkedDatFile) { + super(linkedDatFile); + } + + public void projectWithSlantingMatrix() { + // FIXME Needs impl. + } + +} diff --git a/src/org/nschmidt/ldparteditor/data/VM99Clipboard.java b/src/org/nschmidt/ldparteditor/data/VM99Clipboard.java index e4bd58119..99b1746c8 100644 --- a/src/org/nschmidt/ldparteditor/data/VM99Clipboard.java +++ b/src/org/nschmidt/ldparteditor/data/VM99Clipboard.java @@ -45,7 +45,7 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of import org.nschmidt.ldparteditor.text.DatParser; import org.nschmidt.ldparteditor.text.StringHelper; -class VM99Clipboard extends VM27YTruder { +class VM99Clipboard extends VM28SlantingMatrixProjector { private static final List CLIPBOARD = new ArrayList(); private static final Set CLIPBOARD_InvNext = Collections.newSetFromMap(new ThreadsafeHashMap()); diff --git a/src/org/nschmidt/ldparteditor/dialogs/slantingmatrixprojector/SlantingMatrixProjectorDesign.java b/src/org/nschmidt/ldparteditor/dialogs/slantingmatrixprojector/SlantingMatrixProjectorDesign.java new file mode 100644 index 000000000..e19ec138e --- /dev/null +++ b/src/org/nschmidt/ldparteditor/dialogs/slantingmatrixprojector/SlantingMatrixProjectorDesign.java @@ -0,0 +1,92 @@ +/* MIT - License + +Copyright (c) 2012 - this year, Nils Schmidt + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +package org.nschmidt.ldparteditor.dialogs.slantingmatrixprojector; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.nschmidt.ldparteditor.i18n.I18n; + +/** + * The SlantingMatrixProjector dialog + *

+ * Note: This class should not be instantiated, it defines the gui layout and no + * business logic. + * + * @author nils + * + */ +class SlantingMatrixProjectorDesign extends Dialog { + + // Use final only for subclass/listener references! + + SlantingMatrixProjectorDesign(Shell parentShell) { + super(parentShell); + } + + /** + * Create contents of the dialog. + * + * @param parent + */ + @Override + protected Control createDialogArea(Composite parent) { + Composite cmp_container = (Composite) super.createDialogArea(parent); + GridLayout gridLayout = (GridLayout) cmp_container.getLayout(); + gridLayout.verticalSpacing = 10; + gridLayout.horizontalSpacing = 10; + + Label lbl_specify = new Label(cmp_container, SWT.NONE); + // TODO lbl_specify.setText(I18n.MATRIXPROJECTOR_Title); + + Label lbl_separator = new Label(cmp_container, SWT.SEPARATOR | SWT.HORIZONTAL); + lbl_separator.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); + + Label lbl_info = new Label(cmp_container, SWT.NONE); + lbl_info.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); + // TODO lbl_info.setText(I18n.MATRIXPROJECTOR_Hint); + + cmp_container.pack(); + return cmp_container; + } + + /** + * Create contents of the button bar. + * + * @param parent + */ + @Override + protected void createButtonsForButtonBar(Composite parent) { + createButton(parent, IDialogConstants.OK_ID, I18n.DIALOG_OK, true); + createButton(parent, IDialogConstants.CANCEL_ID, I18n.DIALOG_Cancel, false); + } + + /** + * Return the initial size of the dialog. + */ + @Override + protected Point getInitialSize() { + return super.getInitialSize(); + } + +} diff --git a/src/org/nschmidt/ldparteditor/dialogs/slantingmatrixprojector/SlantingMatrixProjectorDialog.java b/src/org/nschmidt/ldparteditor/dialogs/slantingmatrixprojector/SlantingMatrixProjectorDialog.java new file mode 100644 index 000000000..b1f663000 --- /dev/null +++ b/src/org/nschmidt/ldparteditor/dialogs/slantingmatrixprojector/SlantingMatrixProjectorDialog.java @@ -0,0 +1,49 @@ +/* MIT - License + +Copyright (c) 2012 - this year, Nils Schmidt + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +package org.nschmidt.ldparteditor.dialogs.slantingmatrixprojector; + +import org.eclipse.swt.widgets.Shell; + +/** + * + *

+ * Note: This class should be instantiated, it defines all listeners and part of + * the business logic. It overrides the {@code open()} method to invoke the + * listener definitions ;) + * + * @author nils + * + */ +public class SlantingMatrixProjectorDialog extends SlantingMatrixProjectorDesign { + + /** + * Create the dialog. + * + * @param parentShell + */ + public SlantingMatrixProjectorDialog(Shell parentShell) { + super(parentShell); + } + + @Override + public int open() { + super.create(); + // MARK All final listeners will be configured here.. + + return super.open(); + } + +} diff --git a/src/org/nschmidt/ldparteditor/i18n/Editor3D.properties b/src/org/nschmidt/ldparteditor/i18n/Editor3D.properties index d51bee655..5a285d508 100644 --- a/src/org/nschmidt/ldparteditor/i18n/Editor3D.properties +++ b/src/org/nschmidt/ldparteditor/i18n/Editor3D.properties @@ -503,6 +503,8 @@ SetXYZ = Set X/Y/Z (for Selection) ShowAll = Show All +SlantingMatrixProjector = SlantingMatrixProjector + SlicerPro = SlicerPro Smooth = Smooth Vertices diff --git a/src/org/nschmidt/ldparteditor/i18n/I18n.java b/src/org/nschmidt/ldparteditor/i18n/I18n.java index a4350addb..acb412667 100644 --- a/src/org/nschmidt/ldparteditor/i18n/I18n.java +++ b/src/org/nschmidt/ldparteditor/i18n/I18n.java @@ -616,6 +616,7 @@ private static void adjust() { // Calculate line offset public static final String E3D_SetIconSize = E3D.getString(getProperty()); public static final String E3D_SetXYZ = E3D.getString(getProperty()); public static final String E3D_ShowAll = E3D.getString(getProperty()); + public static final String E3D_SlantingMatrixProjector = E3D.getString(getProperty()); public static final String E3D_SlicerPro = E3D.getString(getProperty()); public static final String E3D_Smooth = E3D.getString(getProperty()); public static final String E3D_Snapping = E3D.getString(getProperty()); diff --git a/src/org/nschmidt/ldparteditor/shells/editor3d/Editor3DDesign.java b/src/org/nschmidt/ldparteditor/shells/editor3d/Editor3DDesign.java index 01bdbfcd9..ccdee2e67 100644 --- a/src/org/nschmidt/ldparteditor/shells/editor3d/Editor3DDesign.java +++ b/src/org/nschmidt/ldparteditor/shells/editor3d/Editor3DDesign.java @@ -268,6 +268,7 @@ class Editor3DDesign extends ApplicationWindow { final MenuItem[] mntm_Isecalc = new MenuItem[1]; final MenuItem[] mntm_SlicerPro = new MenuItem[1]; final MenuItem[] mntm_Intersector = new MenuItem[1]; + final MenuItem[] mntm_SlantingMatrixProjector = new MenuItem[1]; final MenuItem[] mntm_Lines2Pattern = new MenuItem[1]; final MenuItem[] mntm_PathTruder = new MenuItem[1]; final MenuItem[] mntm_YTruder = new MenuItem[1]; @@ -2563,6 +2564,11 @@ public void widgetSelected(SelectionEvent e) { this.mntm_Intersector[0] = mntm_Intersector; mntm_Intersector.setText(I18n.E3D_Intersector); } + { + MenuItem mntm_MatrixCalculator = new MenuItem(mnu_Tools, SWT.PUSH); + this.mntm_SlantingMatrixProjector[0] = mntm_MatrixCalculator; + mntm_MatrixCalculator.setText(I18n.E3D_SlantingMatrixProjector); + } { MenuItem mntm_Lines2Pattern = new MenuItem(mnu_Tools, SWT.PUSH); this.mntm_Lines2Pattern[0] = mntm_Lines2Pattern; diff --git a/src/org/nschmidt/ldparteditor/shells/editor3d/Editor3DWindow.java b/src/org/nschmidt/ldparteditor/shells/editor3d/Editor3DWindow.java index d1c48512a..dfb90ddd7 100644 --- a/src/org/nschmidt/ldparteditor/shells/editor3d/Editor3DWindow.java +++ b/src/org/nschmidt/ldparteditor/shells/editor3d/Editor3DWindow.java @@ -137,6 +137,7 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of import org.nschmidt.ldparteditor.dialogs.scale.ScaleDialog; import org.nschmidt.ldparteditor.dialogs.selectvertex.VertexDialog; import org.nschmidt.ldparteditor.dialogs.setcoordinates.CoordinatesDialog; +import org.nschmidt.ldparteditor.dialogs.slantingmatrixprojector.SlantingMatrixProjectorDialog; import org.nschmidt.ldparteditor.dialogs.slicerpro.SlicerProDialog; import org.nschmidt.ldparteditor.dialogs.smooth.SmoothDialog; import org.nschmidt.ldparteditor.dialogs.symsplitter.SymSplitterDialog; @@ -4758,6 +4759,25 @@ public void widgetSelected(SelectionEvent e) { } }); + mntm_SlantingMatrixProjector[0].addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + for (OpenGLRenderer renderer : renders) { + Composite3D c3d = renderer.getC3D(); + if (c3d.getLockableDatFileReference().equals(Project.getFileToEdit()) && !c3d.getLockableDatFileReference().isReadOnly()) { + VertexManager vm = c3d.getLockableDatFileReference().getVertexManager(); + if (new SlantingMatrixProjectorDialog(getShell()).open() == IDialogConstants.OK_ID) { + vm.addSnapshot(); + vm.projectWithSlantingMatrix(); + } + regainFocus(); + return; + } + } + regainFocus(); + } + }); + mntm_Lines2Pattern[0].addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) {