Skip to content

Commit

Permalink
Fixed issue #1005.
Browse files Browse the repository at this point in the history
  • Loading branch information
nilsschmidt1337 committed Dec 1, 2023
1 parent 3f3352a commit 601a0bb
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 12 deletions.
28 changes: 27 additions & 1 deletion src/org/nschmidt/ldparteditor/composite/Composite3D.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
import org.nschmidt.ldparteditor.dialog.snapshot.SnapshotDialog;
import org.nschmidt.ldparteditor.dialog.value.ValueDialog;
import org.nschmidt.ldparteditor.dnd.PrimitiveDragAndDropTransfer;
import org.nschmidt.ldparteditor.enumtype.Colour;
import org.nschmidt.ldparteditor.enumtype.LDConfig;
import org.nschmidt.ldparteditor.enumtype.OpenInWhat;
import org.nschmidt.ldparteditor.enumtype.Perspective;
Expand Down Expand Up @@ -115,6 +116,7 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
import org.nschmidt.ldparteditor.vertexwindow.VertexWindow;
import org.nschmidt.ldparteditor.widget.listener.Win32MouseWheelFilter;
import org.nschmidt.ldparteditor.workbench.Composite3DState;
import org.nschmidt.ldparteditor.workbench.UserSettingState;
import org.nschmidt.ldparteditor.workbench.WorkbenchManager;

/**
Expand Down Expand Up @@ -173,7 +175,7 @@ public class Composite3D extends ScalableComposite {

private final Set<GData> tmpRaytraceSkipSet = new HashSet<>();
private Set<GData> tmpRaytraceSkipSetResult = new HashSet<>();

public Vector4f getScreenXY() {
return screenXY;
}
Expand Down Expand Up @@ -275,6 +277,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[] mntmAxisLabelPtr = new MenuItem[1];
private final MenuItem[] mntmAlwaysBlackPtr = new MenuItem[1];
private final MenuItem[] mntmHideAllPtr = new MenuItem[1];
private final MenuItem[] mntmStdLinesPtr = new MenuItem[1];
Expand Down Expand Up @@ -882,6 +885,24 @@ public void applyValue() {
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 mntmLabel = new MenuItem(mnuViewActions, SWT.CHECK);
this.mntmLabelPtr[0] = mntmLabel;
Expand Down Expand Up @@ -1868,6 +1889,10 @@ public MenuItem getMntmAnaglyph() {
public MenuItem getMntmAxis() {
return mntmAxisPtr[0];
}

public MenuItem getMntmAxisLabel() {
return mntmAxisLabelPtr[0];
}

public MenuItem getMntmAlwaysBlack() {
return mntmAlwaysBlackPtr[0];
Expand Down Expand Up @@ -2423,6 +2448,7 @@ public void loadState(Composite3DState state) {
getMntmControlPointVertices().setSelection(state.isCondlineControlPoints());
getMntmStudLogo().setSelection(state.isStudLogo());
getMntmAxis().setSelection(state.isShowAxis());
getMntmAxisLabel().setSelection(WorkbenchManager.getUserSettingState().isShowingAxisLabels());
getMntmAnaglyph().setSelection(state.isAnaglyph3d());
setRenderModeOnContextMenu(tmpRenderMode);

Expand Down
15 changes: 13 additions & 2 deletions src/org/nschmidt/ldparteditor/dialog/options/OptionsDesign.java
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ public void mouseDoubleClick(MouseEvent e) {

final Tree tree = new Tree(cmpContainer, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL, 67);
treeColours = tree;

tree.setLinesVisible(true);
tree.setHeaderVisible(true);
tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
Expand Down Expand Up @@ -658,7 +658,18 @@ public void mouseDoubleClick(MouseEvent e) {
registerColour(trtmEditor3D, I18n.COLOUR_SELECTED_CONDLINE_COLOUR, ColourType.OPENGL_COLOUR, new Object[]{Colour.condlineSelectedColourR, Colour.condlineSelectedColourG, Colour.condlineSelectedColourB}, (r, g, b) -> { Colour.condlineSelectedColourR = r; Colour.condlineSelectedColourG = g; Colour.condlineSelectedColourB = b;});
registerColour(trtmEditor3D, I18n.COLOUR_SELECTED_MANIPULATOR_COLOUR, ColourType.OPENGL_COLOUR, new Object[]{Colour.manipulatorSelectedColourR, Colour.manipulatorSelectedColourG, Colour.manipulatorSelectedColourB}, (r, g, b) -> { Colour.manipulatorSelectedColourR = r; Colour.manipulatorSelectedColourG = g; Colour.manipulatorSelectedColourB = b;});
registerColour(trtmEditor3D, I18n.COLOUR_RUBBERBAND_COLOUR, ColourType.OPENGL_COLOUR, new Object[]{Colour.rubberBandColourR, Colour.rubberBandColourG, Colour.rubberBandColourB}, (r, g, b) -> { Colour.rubberBandColourR = r; Colour.rubberBandColourG = g; Colour.rubberBandColourB = b;});
registerColour(trtmEditor3D, I18n.COLOUR_TEXT_COLOUR, ColourType.OPENGL_COLOUR, new Object[]{Colour.textColourR, Colour.textColourG, Colour.textColourB}, (r, g, b) -> { Colour.textColourR = r; Colour.textColourG = g; Colour.textColourB = b;});
registerColour(trtmEditor3D, I18n.COLOUR_TEXT_COLOUR_1, ColourType.OPENGL_COLOUR, new Object[]{Colour.textColourDefaultR, Colour.textColourDefaultG, Colour.textColourDefaultB}, (r, g, b) -> {
Colour.textColourDefaultR = r; Colour.textColourDefaultG = g; Colour.textColourDefaultB = b;
if (!userSettings.isShowingAxisLabels()) {
Colour.textColourR = r; Colour.textColourG = g; Colour.textColourB = b;
}
});
registerColour(trtmEditor3D, I18n.COLOUR_TEXT_COLOUR_2, ColourType.OPENGL_COLOUR, new Object[]{Colour.textColourAltR, Colour.textColourAltG, Colour.textColourAltB}, (r, g, b) -> {
Colour.textColourAltR = r; Colour.textColourAltG = g; Colour.textColourAltB = b;
if (userSettings.isShowingAxisLabels()) {
Colour.textColourR = r; Colour.textColourG = g; Colour.textColourB = b;
}
});
registerColour(trtmEditor3D, I18n.COLOUR_X_AXIS_COLOUR, ColourType.OPENGL_COLOUR, new Object[]{Colour.xAxisColourR, Colour.xAxisColourG, Colour.xAxisColourB}, (r, g, b) -> { Colour.xAxisColourR = r; Colour.xAxisColourG = g; Colour.xAxisColourB = b;});
registerColour(trtmEditor3D, I18n.COLOUR_Y_AXIS_COLOUR, ColourType.OPENGL_COLOUR, new Object[]{Colour.yAxisColourR, Colour.yAxisColourG, Colour.yAxisColourB}, (r, g, b) -> { Colour.yAxisColourR = r; Colour.yAxisColourG = g; Colour.yAxisColourB = b;});
registerColour(trtmEditor3D, I18n.COLOUR_Z_AXIS_COLOUR, ColourType.OPENGL_COLOUR, new Object[]{Colour.zAxisColourR, Colour.zAxisColourG, Colour.zAxisColourB}, (r, g, b) -> { Colour.zAxisColourR = r; Colour.zAxisColourG = g; Colour.zAxisColourB = b;});
Expand Down
13 changes: 7 additions & 6 deletions src/org/nschmidt/ldparteditor/dialog/options/OptionsDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,15 @@ public void run() {
widgetUtil(btnInvertInvertWheelZoomDirectionPtr[0]).addSelectionListener(e -> WorkbenchManager.getUserSettingState().setInvertingWheelZoomDirection(btnInvertInvertWheelZoomDirectionPtr[0].getSelection()));
widgetUtil(btnShowAxisLabelsPtr[0]).addSelectionListener(e -> {
WorkbenchManager.getUserSettingState().setShowingAxisLabels(btnShowAxisLabelsPtr[0].getSelection());

if (WorkbenchManager.getUserSettingState().isShowingAxisLabels()) {
Colour.textColourR = 1.0f;
Colour.textColourG = 0.75f;
Colour.textColourB = 0.80f;
Colour.textColourR = Colour.textColourAltR;
Colour.textColourG = Colour.textColourAltG;
Colour.textColourB = Colour.textColourAltB;
} else {
Colour.textColourR = 0f;
Colour.textColourG = 0f;
Colour.textColourB = 0f;
Colour.textColourR = Colour.textColourDefaultR;
Colour.textColourG = Colour.textColourDefaultG;
Colour.textColourB = Colour.textColourDefaultB;
}
});

Expand Down
8 changes: 8 additions & 0 deletions src/org/nschmidt/ldparteditor/enumtype/Colour.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,14 @@ public enum Colour {
public static float textColourR = 0f;
public static float textColourG = 0f;
public static float textColourB = 0f;

public static float textColourAltR = 1.0f;
public static float textColourAltG = 0.5019608f;
public static float textColourAltB = 0f;

public static float textColourDefaultR = 0f;
public static float textColourDefaultG = 0f;
public static float textColourDefaultB = 0f;

public static float xAxisColourR = 1f;
public static float xAxisColourG = 0f;
Expand Down
3 changes: 2 additions & 1 deletion src/org/nschmidt/ldparteditor/i18n/Colour.properties
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ SELECTED_CONDLINE_COLOUR = Selected Conditional Line
SELECTED_MANIPULATOR_COLOUR = Selected Manipulator
SELECTED_VERTEX_COLOUR = Selected Vertex
SHOWN_CONDLINE_COLOUR = Shown Cond. Line (Cond. Line Mode)
TEXT_COLOUR = Text
TEXT_COLOUR_1 = Text (1)
TEXT_COLOUR_2 = Text (2)
TEXT_EDITOR_BG_COLOUR = Background
TEXT_EDITOR_BOX_COLOUR = SyncEdit Box
TEXT_EDITOR_COLOUR_ATTR_COLOUR = Colour Attribute
Expand Down
1 change: 1 addition & 0 deletions src/org/nschmidt/ldparteditor/i18n/Composite3D.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
ANAGLYPH_3D = Anaglyph 3D
AXIS_LABEL = Axis Label
CONDLINE_MODE = Special Cond. Line Mode
CONDLINE_VERTICES = Conditional Control Point Vertices
COPLANARITY_MODE = Coplanarity Heatmap
Expand Down
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 @@ -112,6 +112,7 @@ private static void adjust() { // Calculate line offset
}
// Constants (Need case sensitive sorting!)
public static final String C3D_ANAGLYPH_3D = C3D.getString(getProperty());
public static final String C3D_AXIS_LABEL = C3D.getString(getProperty());
public static final String C3D_CONDLINE_MODE = C3D.getString(getProperty());
public static final String C3D_CONDLINE_VERTICES = C3D.getString(getProperty());
public static final String C3D_COPLANARITY_MODE = C3D.getString(getProperty());
Expand Down Expand Up @@ -218,7 +219,8 @@ private static void adjust() { // Calculate line offset
public static final String COLOUR_SELECTED_MANIPULATOR_COLOUR = COLOUR.getString(getProperty());
public static final String COLOUR_SELECTED_VERTEX_COLOUR = COLOUR.getString(getProperty());
public static final String COLOUR_SHOWN_CONDLINE_COLOUR = COLOUR.getString(getProperty());
public static final String COLOUR_TEXT_COLOUR = COLOUR.getString(getProperty());
public static final String COLOUR_TEXT_COLOUR_1 = COLOUR.getString(getProperty());
public static final String COLOUR_TEXT_COLOUR_2 = COLOUR.getString(getProperty());
public static final String COLOUR_TEXT_EDITOR_BG_COLOUR = COLOUR.getString(getProperty());
public static final String COLOUR_TEXT_EDITOR_BOX_COLOUR = COLOUR.getString(getProperty());
public static final String COLOUR_TEXT_EDITOR_COLOUR_ATTR_COLOUR = COLOUR.getString(getProperty());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3151,6 +3151,9 @@ private List<String> buildFileList(String source, List<String> result, Set<Strin
widgetUtil(mntmOptionsPtr[0]).addSelectionListener(e -> {
OptionsDialog dialog = new OptionsDialog(Editor3DWindow.getWindow().getShell());
dialog.run();
for (OpenGLRenderer renderer : Editor3DWindow.getRenders()) {
renderer.getC3D().getMntmAxisLabel().setSelection(WorkbenchManager.getUserSettingState().isShowingAxisLabels());
}
regainFocus();
});

Expand Down
36 changes: 35 additions & 1 deletion src/org/nschmidt/ldparteditor/workbench/UserSettingState.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ public class UserSettingState implements Serializable {
private float[] gridColour = null;
private float[] rubberBandColour = null;
private float[] textColour = null;
private float[] textColourAlt = null;
private float[] textColourDefault = null;
private float[] xAxisColour = null;
private float[] yAxisColour = null;
private float[] zAxisColour = null;
Expand Down Expand Up @@ -708,6 +710,8 @@ void saveColours() {
rubberBandColour = new float[] {Colour.rubberBandColourR,Colour.rubberBandColourG,Colour.rubberBandColourB};

textColour = new float[] {Colour.textColourR,Colour.textColourG,Colour.textColourB};
textColourAlt = new float[] {Colour.textColourAltR,Colour.textColourAltG,Colour.textColourAltB};
textColourDefault = new float[] {Colour.textColourDefaultR,Colour.textColourDefaultG,Colour.textColourDefaultB};

xAxisColour = new float[] {Colour.xAxisColourR,Colour.xAxisColourG,Colour.xAxisColourB};
yAxisColour = new float[] {Colour.yAxisColourR,Colour.yAxisColourG,Colour.yAxisColourB};
Expand Down Expand Up @@ -952,7 +956,37 @@ public void loadColours() {
Colour.textColourG = textColour[1];
Colour.textColourB = textColour[2];
}


if (textColourAlt != null) {
Colour.textColourAltR = textColourAlt[0];
Colour.textColourAltG = textColourAlt[1];
Colour.textColourAltB = textColourAlt[2];
} else {
Colour.textColourAltR = 1.0f;
Colour.textColourAltG = 0.5019608f;
Colour.textColourAltB = 0.0f;
}

if (textColourDefault != null) {
Colour.textColourDefaultR = textColourDefault[0];
Colour.textColourDefaultG = textColourDefault[1];
Colour.textColourDefaultB = textColourDefault[2];
} else {
Colour.textColourDefaultR = Colour.textColourR;
Colour.textColourDefaultG = Colour.textColourG;
Colour.textColourDefaultB = Colour.textColourB;
}

if (isShowingAxisLabels()) {
Colour.textColourR = Colour.textColourAltR;
Colour.textColourG = Colour.textColourAltG;
Colour.textColourB = Colour.textColourAltB;
} else {
Colour.textColourR = Colour.textColourDefaultR;
Colour.textColourR = Colour.textColourDefaultG;
Colour.textColourR = Colour.textColourDefaultB;
}

if (xAxisColour != null) {
Colour.xAxisColourR = xAxisColour[0];
Colour.xAxisColourG = xAxisColour[1];
Expand Down

0 comments on commit 601a0bb

Please sign in to comment.