From 05b3ddd49bc58dd363b72a30b6490801b94d1d94 Mon Sep 17 00:00:00 2001 From: Nils Schmidt Date: Sat, 24 Aug 2024 17:29:00 +0200 Subject: [PATCH] Fixed issue #1099. --- .../ldparteditor/composite/Composite3D.java | 79 +++++++++++++------ .../composite3d/Composite3DModifier.java | 4 + .../ldparteditor/i18n/Composite3D.properties | 4 +- src/org/nschmidt/ldparteditor/i18n/I18n.java | 4 +- .../ldparteditor/opengl/OpenGLRenderer20.java | 30 +++++-- .../ldparteditor/opengl/OpenGLRenderer33.java | 30 +++++-- .../shell/editor3d/Editor3DWindow.java | 1 + .../shell/editor3d/toolitem/MiscToolItem.java | 4 + .../workbench/Composite3DState.java | 9 +++ 9 files changed, 129 insertions(+), 36 deletions(-) diff --git a/src/org/nschmidt/ldparteditor/composite/Composite3D.java b/src/org/nschmidt/ldparteditor/composite/Composite3D.java index 5c20f5df4..bb9b2f940 100644 --- a/src/org/nschmidt/ldparteditor/composite/Composite3D.java +++ b/src/org/nschmidt/ldparteditor/composite/Composite3D.java @@ -134,6 +134,8 @@ public class Composite3D extends ScalableComposite { public final Menu mnuRenderMode; /** The "Line Mode"-Menu */ private final Menu mnuLineMode; + /** The "XYZ-Axis"-Menu */ + private final Menu mnuXyzAxis; /** The "Synchronise..."-Menu */ private final Menu mnuSyncronise; /** The "Manipulator"-Menu */ @@ -254,6 +256,7 @@ public Vector4f getScreenXY() { private boolean syncZoom; private boolean showingAxis; + private boolean showingAxisCentered; private boolean showingLabels; private boolean smoothShading; @@ -284,6 +287,7 @@ public Vector4f getScreenXY() { public final MenuItem[] mntmWireframeModePtr = new MenuItem[1]; private final MenuItem[] mntmAnaglyphPtr = new MenuItem[1]; private final MenuItem[] mntmAxisPtr = new MenuItem[1]; + private final MenuItem[] mntmAxisCenteredPtr = new MenuItem[1]; private final MenuItem[] mntmAxisLabelPtr = new MenuItem[1]; private final MenuItem[] mntmAlwaysBlackPtr = new MenuItem[1]; private final MenuItem[] mntmHideAllPtr = new MenuItem[1]; @@ -902,29 +906,9 @@ public void applyValue() { }); KeyStateManager.addKeyText(mntmShowScale, I18n.E3D_RULER, Task.SHOW_RULER); - final MenuItem mntmAxis = new MenuItem(mnuViewActions, SWT.CHECK); - this.mntmAxisPtr[0] = mntmAxis; - widgetUtil(mntmAxis).addSelectionListener(e -> c3dModifier.switchAxis(mntmAxis.getSelection())); - mntmAxis.setText(I18n.C3D_XYZ_AXIS); - mntmAxis.setSelection(true); - - final MenuItem mntmAxisLabel = new MenuItem(mnuViewActions, SWT.CHECK); - this.mntmAxisLabelPtr[0] = mntmAxisLabel; - widgetUtil(mntmAxisLabel).addSelectionListener(e -> { - final UserSettingState userSettings = WorkbenchManager.getUserSettingState(); - userSettings.setShowingAxisLabels(!userSettings.isShowingAxisLabels()); - if (userSettings.isShowingAxisLabels()) { - Colour.textColourR = Colour.textColourAltR; Colour.textColourG = Colour.textColourAltG; Colour.textColourB = Colour.textColourAltB; - } else { - Colour.textColourR = Colour.textColourDefaultR; Colour.textColourG = Colour.textColourDefaultG; Colour.textColourB = Colour.textColourDefaultB; - } - for (OpenGLRenderer renderer : Editor3DWindow.getRenders()) { - renderer.getC3D().getMntmAxisLabel().setSelection(userSettings.isShowingAxisLabels()); - } - }); - mntmAxisLabel.setText(I18n.C3D_AXIS_LABEL); - mntmAxisLabel.setSelection(WorkbenchManager.getUserSettingState().isShowingAxisLabels()); + final MenuItem mntmXyzAxis = new MenuItem(mnuViewActions, SWT.CASCADE); + mntmXyzAxis.setText(I18n.C3D_XYZ_AXIS_MENU); final MenuItem mntmLabel = new MenuItem(mnuViewActions, SWT.CHECK); this.mntmLabelPtr[0] = mntmLabel; @@ -960,6 +944,43 @@ public void applyValue() { widgetUtil(mntmClose).addSelectionListener(e -> c3dModifier.closeView()); mntmClose.setText(I18n.E3D_CLOSE_VIEW); + + { + // MARK CMenu XYZ axis + mnuXyzAxis = new Menu(mntmXyzAxis); + mntmXyzAxis.setMenu(mnuXyzAxis); + + final MenuItem mntmAxis = new MenuItem(mnuXyzAxis, SWT.CHECK); + this.mntmAxisPtr[0] = mntmAxis; + widgetUtil(mntmAxis).addSelectionListener(e -> c3dModifier.switchAxis(mntmAxis.getSelection())); + mntmAxis.setText(I18n.C3D_XYZ_AXIS_SHOW); + mntmAxis.setSelection(true); + + final MenuItem mntmAxisCentered = new MenuItem(mnuXyzAxis, SWT.CHECK); + this.mntmAxisCenteredPtr[0] = mntmAxisCentered; + widgetUtil(mntmAxisCentered).addSelectionListener(e -> c3dModifier.switchAxisCentered(mntmAxisCentered.getSelection())); + mntmAxisCentered.setText(I18n.C3D_XYZ_AXIS_CENTER); + mntmAxisCentered.setSelection(false); + + final MenuItem mntmAxisLabel = new MenuItem(mnuXyzAxis, SWT.CHECK); + this.mntmAxisLabelPtr[0] = mntmAxisLabel; + widgetUtil(mntmAxisLabel).addSelectionListener(e -> { + final UserSettingState userSettings = WorkbenchManager.getUserSettingState(); + userSettings.setShowingAxisLabels(!userSettings.isShowingAxisLabels()); + if (userSettings.isShowingAxisLabels()) { + Colour.textColourR = Colour.textColourAltR; Colour.textColourG = Colour.textColourAltG; Colour.textColourB = Colour.textColourAltB; + } else { + Colour.textColourR = Colour.textColourDefaultR; Colour.textColourG = Colour.textColourDefaultG; Colour.textColourB = Colour.textColourDefaultB; + } + + for (OpenGLRenderer renderer : Editor3DWindow.getRenders()) { + renderer.getC3D().getMntmAxisLabel().setSelection(userSettings.isShowingAxisLabels()); + } + }); + mntmAxisLabel.setText(I18n.C3D_AXIS_LABEL); + mntmAxisLabel.setSelection(WorkbenchManager.getUserSettingState().isShowingAxisLabels()); + } + { // MARK CMenu LineMode final MenuItem[] mntmAlwaysBlack = new MenuItem[1]; @@ -1852,6 +1873,14 @@ public void setShowingAxis(boolean showingAxis) { this.showingAxis = showingAxis; } + public boolean isShowingAxisCentered() { + return showingAxisCentered; + } + + public void setShowingAxisCentered(boolean showingAxisCentered) { + this.showingAxisCentered = showingAxisCentered; + } + public boolean isShowingLabels() { return showingLabels; } @@ -1912,6 +1941,10 @@ public MenuItem getMntmAxis() { return mntmAxisPtr[0]; } + public MenuItem getMntmAxisCentered() { + return mntmAxisCenteredPtr[0]; + } + public MenuItem getMntmAxisLabel() { return mntmAxisLabelPtr[0]; } @@ -2454,6 +2487,7 @@ public void loadState(Composite3DState state) { setLineMode(tmpLineMode); setBlackEdges(state.isAlwaysBlackLines()); setShowingAxis(state.isShowAxis()); + setShowingAxisCentered(state.isShowAxisCentered()); setAnaglyph3d(state.isAnaglyph3d()); setRenderMode(tmpRenderMode); setShowingCondlineControlPoints(state.isCondlineControlPoints()); @@ -2482,6 +2516,7 @@ public void loadState(Composite3DState state) { getMntmControlPointVertices().setSelection(state.isCondlineControlPoints()); getMntmStudLogo().setSelection(state.isStudLogo()); getMntmAxis().setSelection(state.isShowAxis()); + getMntmAxisCentered().setSelection(state.isShowAxisCentered()); getMntmAxisLabel().setSelection(WorkbenchManager.getUserSettingState().isShowingAxisLabels()); getMntmAnaglyph().setSelection(state.isAnaglyph3d()); setRenderModeOnContextMenu(tmpRenderMode); diff --git a/src/org/nschmidt/ldparteditor/helper/composite3d/Composite3DModifier.java b/src/org/nschmidt/ldparteditor/helper/composite3d/Composite3DModifier.java index 6853979df..9e6a7f521 100644 --- a/src/org/nschmidt/ldparteditor/helper/composite3d/Composite3DModifier.java +++ b/src/org/nschmidt/ldparteditor/helper/composite3d/Composite3DModifier.java @@ -499,6 +499,10 @@ public void switchAxis(boolean selection) { c3d.setShowingAxis(selection); } + public void switchAxisCentered(boolean selection) { + c3d.setShowingAxisCentered(selection); + } + public void switchLabel(boolean selection) { c3d.setShowingLabels(selection); } diff --git a/src/org/nschmidt/ldparteditor/i18n/Composite3D.properties b/src/org/nschmidt/ldparteditor/i18n/Composite3D.properties index 9a4099671..2e4199930 100644 --- a/src/org/nschmidt/ldparteditor/i18n/Composite3D.properties +++ b/src/org/nschmidt/ldparteditor/i18n/Composite3D.properties @@ -51,4 +51,6 @@ VERTEX_3 = 3 Vertices VERTEX_4 = 4 Vertices VERTICES = Vertices WIREFRAME = Wireframe -XYZ_AXIS = XYZ-Axis +XYZ_AXIS_CENTER = Center Axis +XYZ_AXIS_MENU = XYZ-Axis +XYZ_AXIS_SHOW = Show Axis diff --git a/src/org/nschmidt/ldparteditor/i18n/I18n.java b/src/org/nschmidt/ldparteditor/i18n/I18n.java index 4ef1a1481..e14494b80 100644 --- a/src/org/nschmidt/ldparteditor/i18n/I18n.java +++ b/src/org/nschmidt/ldparteditor/i18n/I18n.java @@ -167,7 +167,9 @@ private static void adjust() { // Calculate line offset public static final String C3D_VERTEX_4 = C3D.getString(getProperty()); public static final String C3D_VERTICES = C3D.getString(getProperty()); public static final String C3D_WIREFRAME = C3D.getString(getProperty()); - public static final String C3D_XYZ_AXIS = C3D.getString(getProperty()); + public static final String C3D_XYZ_AXIS_CENTER = C3D.getString(getProperty()); + public static final String C3D_XYZ_AXIS_MENU = C3D.getString(getProperty()); + public static final String C3D_XYZ_AXIS_SHOW = C3D.getString(getProperty()); public static final String CALIBRATE_BG_IMAGE = CALIBRATE.getString(getProperty()); public static final String CALIBRATE_DRAW_LINE = CALIBRATE.getString(getProperty()); public static final String CALIBRATE_LENGTH = CALIBRATE.getString(getProperty()); diff --git a/src/org/nschmidt/ldparteditor/opengl/OpenGLRenderer20.java b/src/org/nschmidt/ldparteditor/opengl/OpenGLRenderer20.java index 5f6ef8fa4..b296ec417 100644 --- a/src/org/nschmidt/ldparteditor/opengl/OpenGLRenderer20.java +++ b/src/org/nschmidt/ldparteditor/opengl/OpenGLRenderer20.java @@ -2071,16 +2071,28 @@ else if (zoom > 1.0E-2) switch (IconSize.getIconsize()) { case 4, 5: l = 1f; - ox = .1f; - oy = .11f; + if (c3d.isShowingAxisCentered()) { + ox = viewportWidth; + oy = viewportHeight; + } else { + ox = .1f; + oy = .11f; + } + cone_height = .00030f; cone_width = .00008f; line_width = 6f; break; case 2, 3: l = .75f; - ox = .075f; - oy = .085f; + if (c3d.isShowingAxisCentered()) { + ox = viewportWidth; + oy = viewportHeight; + } else { + ox = .075f; + oy = .085f; + } + cone_height = .00023f; cone_width = .00006f; line_width = 4f; @@ -2088,8 +2100,14 @@ else if (zoom > 1.0E-2) case 0, 1: default: l = .5f; - ox = .05f; - oy = .06f; + if (c3d.isShowingAxisCentered()) { + ox = viewportWidth; + oy = viewportHeight; + } else { + ox = .05f; + oy = .06f; + } + cone_height = .00015f; cone_width = .00004f; line_width = 2f; diff --git a/src/org/nschmidt/ldparteditor/opengl/OpenGLRenderer33.java b/src/org/nschmidt/ldparteditor/opengl/OpenGLRenderer33.java index 22aa4cb75..0226d18d6 100644 --- a/src/org/nschmidt/ldparteditor/opengl/OpenGLRenderer33.java +++ b/src/org/nschmidt/ldparteditor/opengl/OpenGLRenderer33.java @@ -1438,16 +1438,28 @@ else if (zoom > 1.0E-2) switch (IconSize.getIconsize()) { case 4, 5: l = 1f; - ox = .1f; - oy = .11f; + if (c3d.isShowingAxisCentered()) { + ox = viewportWidth; + oy = viewportHeight; + } else { + ox = .1f; + oy = .11f; + } + cone_height = .00030f; cone_width = .00008f; line_width = 6f; break; case 2, 3: l = .75f; - ox = .075f; - oy = .085f; + if (c3d.isShowingAxisCentered()) { + ox = viewportWidth; + oy = viewportHeight; + } else { + ox = .075f; + oy = .085f; + } + cone_height = .00023f; cone_width = .00006f; line_width = 4f; @@ -1455,8 +1467,14 @@ else if (zoom > 1.0E-2) case 0, 1: default: l = .5f; - ox = .05f; - oy = .06f; + if (c3d.isShowingAxisCentered()) { + ox = viewportWidth; + oy = viewportHeight; + } else { + ox = .05f; + oy = .06f; + } + cone_height = .00015f; cone_width = .00004f; line_width = 2f; diff --git a/src/org/nschmidt/ldparteditor/shell/editor3d/Editor3DWindow.java b/src/org/nschmidt/ldparteditor/shell/editor3d/Editor3DWindow.java index 9f74ad5fa..607bbd837 100644 --- a/src/org/nschmidt/ldparteditor/shell/editor3d/Editor3DWindow.java +++ b/src/org/nschmidt/ldparteditor/shell/editor3d/Editor3DWindow.java @@ -2418,6 +2418,7 @@ public void fillC3DState(Composite3DState st, Composite3D c3d) { st.setRenderMode(c3d.getRenderMode()); st.setShowLabel(c3d.isShowingLabels()); st.setShowAxis(c3d.isShowingAxis()); + st.setShowAxisCentered(c3d.isShowingAxisCentered()); st.setShowGrid(c3d.isGridShown()); st.setShowGrid3D(c3d.isGridShown3D()); st.setShowEmptySubfiles(c3d.isShowingEmptySubfiles()); diff --git a/src/org/nschmidt/ldparteditor/shell/editor3d/toolitem/MiscToolItem.java b/src/org/nschmidt/ldparteditor/shell/editor3d/toolitem/MiscToolItem.java index 71902005d..ceb580858 100644 --- a/src/org/nschmidt/ldparteditor/shell/editor3d/toolitem/MiscToolItem.java +++ b/src/org/nschmidt/ldparteditor/shell/editor3d/toolitem/MiscToolItem.java @@ -3768,6 +3768,10 @@ private static void openPartReviewFileIn3DEditor() { c3d.getMntmStudLogo().setSelection(true); c3d.getModifier().switchShowingLogo(true); c3d.getModifier().setRenderMode(0); + c3d.getMntmAxis().setSelection(true); + c3d.getModifier().switchAxis(true); + c3d.getMntmAxisCentered().setSelection(true); + c3d.getModifier().switchAxisCentered(true); } if (state == 1) { c3d.mntmRandomColoursPtr[0].setSelection(true); diff --git a/src/org/nschmidt/ldparteditor/workbench/Composite3DState.java b/src/org/nschmidt/ldparteditor/workbench/Composite3DState.java index 1fe53487d..efef473c7 100644 --- a/src/org/nschmidt/ldparteditor/workbench/Composite3DState.java +++ b/src/org/nschmidt/ldparteditor/workbench/Composite3DState.java @@ -28,6 +28,7 @@ public class Composite3DState implements Serializable { private int renderMode = 0; private boolean showLabel = false; private boolean showAxis = false; + private boolean showAxisCentered = false; private boolean showOrigin = false; private boolean showGrid = false; private boolean showGrid3D = false; @@ -121,6 +122,14 @@ public void setShowAxis(boolean showAxis) { this.showAxis = showAxis; } + public boolean isShowAxisCentered() { + return showAxisCentered; + } + + public void setShowAxisCentered(boolean showAxisCentered) { + this.showAxisCentered = showAxisCentered; + } + public boolean isShowOrigin() { return showOrigin; }