Skip to content

Commit

Permalink
Fixed issue #1099.
Browse files Browse the repository at this point in the history
  • Loading branch information
nilsschmidt1337 committed Aug 24, 2024
1 parent 3e521fd commit 05b3ddd
Show file tree
Hide file tree
Showing 9 changed files with 129 additions and 36 deletions.
79 changes: 57 additions & 22 deletions src/org/nschmidt/ldparteditor/composite/Composite3D.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -254,6 +256,7 @@ public Vector4f getScreenXY() {
private boolean syncZoom;

private boolean showingAxis;
private boolean showingAxisCentered;
private boolean showingLabels;

private boolean smoothShading;
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -1912,6 +1941,10 @@ public MenuItem getMntmAxis() {
return mntmAxisPtr[0];
}

public MenuItem getMntmAxisCentered() {
return mntmAxisCenteredPtr[0];
}

public MenuItem getMntmAxisLabel() {
return mntmAxisLabelPtr[0];
}
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 3 additions & 1 deletion src/org/nschmidt/ldparteditor/i18n/Composite3D.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 3 additions & 1 deletion src/org/nschmidt/ldparteditor/i18n/I18n.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
30 changes: 24 additions & 6 deletions src/org/nschmidt/ldparteditor/opengl/OpenGLRenderer20.java
Original file line number Diff line number Diff line change
Expand Up @@ -2071,25 +2071,43 @@ 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;
break;
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;
Expand Down
30 changes: 24 additions & 6 deletions src/org/nschmidt/ldparteditor/opengl/OpenGLRenderer33.java
Original file line number Diff line number Diff line change
Expand Up @@ -1438,25 +1438,43 @@ 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;
break;
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 9 additions & 0 deletions src/org/nschmidt/ldparteditor/workbench/Composite3DState.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 05b3ddd

Please sign in to comment.