Skip to content

Commit

Permalink
Prepared fix for issue #987.
Browse files Browse the repository at this point in the history
  • Loading branch information
nilsschmidt1337 committed Oct 15, 2023
1 parent 9cb099c commit 0c48753
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/org/nschmidt/ldparteditor/i18n/Editor3D.properties
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ SLICER_PRO = SlicerPro
SMOOTH = Smooth Vertices
SNAPPING = Snapping:
SNAPSHOT = Save Data Snapshot\n(Last Snapshot: {0})
SNAP_TO_GRID = Snap To Grid
SPLIT = Split
SPLIT_EDGES = Split edges:
SPLIT_HORIZONTALLY = Split horizontally
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 @@ -665,6 +665,7 @@ private static void adjust() { // Calculate line offset
public static final String E3D_SMOOTH = E3D.getString(getProperty());
public static final String E3D_SNAPPING = E3D.getString(getProperty());
public static final String E3D_SNAPSHOT = E3D.getString(getProperty());
public static final String E3D_SNAP_TO_GRID = E3D.getString(getProperty());
public static final String E3D_SPLIT = E3D.getString(getProperty());
public static final String E3D_SPLIT_EDGES = E3D.getString(getProperty());
public static final String E3D_SPLIT_HORIZONTALLY = E3D.getString(getProperty());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
import org.nschmidt.ldparteditor.enumtype.MergeTo;
import org.nschmidt.ldparteditor.enumtype.MyLanguage;
import org.nschmidt.ldparteditor.enumtype.OpenInWhat;
import org.nschmidt.ldparteditor.enumtype.Perspective;
import org.nschmidt.ldparteditor.enumtype.Task;
import org.nschmidt.ldparteditor.enumtype.Threshold;
import org.nschmidt.ldparteditor.enumtype.TransformationMode;
Expand Down Expand Up @@ -204,6 +205,8 @@ public class MiscToolItem extends ToolItem {
private static final MenuItem[] mntmRotatePtr = new MenuItem[1];
private static final MenuItem[] mntmScalePtr = new MenuItem[1];

private static final MenuItem[] mntmSnapToGridPtr = new MenuItem[1];

private static final MenuItem[] mntmFlipPtr = new MenuItem[1];
private static final MenuItem[] mntmSmoothPtr = new MenuItem[1];
private static final MenuItem[] mntmSubdivideCatmullClarkPtr = new MenuItem[1];
Expand Down Expand Up @@ -492,6 +495,8 @@ private static void createWidgets(MiscToolItem miscToolItem) {
btnMergeNSplit.setText(I18n.E3D_MERGE_SPLIT);
final Menu mnuMerge = new Menu(miscToolItem.getShell(), SWT.POP_UP);
widgetUtil(btnMergeNSplit).addSelectionListener(e -> {
final Composite3D c3d = Editor3DWindow.getWindow().getCurrentCoposite3d();
MiscToolItem.mntmSnapToGridPtr[0].setEnabled(c3d != null && c3d.isClassicPerspective());
Point loc = btnMergeNSplit.getLocation();
Rectangle rect = btnMergeNSplit.getBounds();
Point mLoc = new Point(loc.x - 1, loc.y + rect.height);
Expand Down Expand Up @@ -571,6 +576,12 @@ private static void createWidgets(MiscToolItem miscToolItem) {

new MenuItem(mnuMerge, SWT.SEPARATOR);

MenuItem mntmSnapToGrid = new MenuItem(mnuMerge, SWT.PUSH);
MiscToolItem.mntmSnapToGridPtr[0] = mntmSnapToGrid;
mntmSnapToGrid.setText(I18n.E3D_SNAP_TO_GRID);

new MenuItem(mnuMerge, SWT.SEPARATOR);

MenuItem mntmSubdivideCatmullClark = new MenuItem(mnuMerge, SWT.PUSH);
MiscToolItem.mntmSubdivideCatmullClarkPtr[0] = mntmSubdivideCatmullClark;
mntmSubdivideCatmullClark.setText(I18n.E3D_SUBDIVIDE_CATMULL_CLARK);
Expand Down Expand Up @@ -1287,6 +1298,43 @@ public void applyValue() {
}
regainFocus();
});

widgetUtil(mntmSnapToGridPtr[0]).addSelectionListener(e -> {
final Composite3D c3d = Editor3DWindow.getWindow().getCurrentCoposite3d();
if (c3d != null && c3d.isClassicPerspective()) {
final boolean snapOnX;
final boolean snapOnY;
final boolean snapOnZ;
final Perspective perspective = c3d.getPerspectiveIndex();
switch (perspective) {
case FRONT, BACK:
snapOnX = true;
snapOnY = true;
snapOnZ = false;
break;
case TOP, BOTTOM:
snapOnX = true;
snapOnY = false;
snapOnZ = true;
break;
case LEFT, RIGHT:
snapOnX = false;
snapOnY = true;
snapOnZ = true;
break;
case TWO_THIRDS:
default:
return;
}

NLogger.debug(MiscToggleToolItem.class, "Perspective :" + perspective); //$NON-NLS-1$
NLogger.debug(MiscToggleToolItem.class, "Snap on X :" + snapOnX); //$NON-NLS-1$
NLogger.debug(MiscToggleToolItem.class, "Snap on Y :" + snapOnY); //$NON-NLS-1$
NLogger.debug(MiscToggleToolItem.class, "Snap on Z :" + snapOnZ); //$NON-NLS-1$

// FIXME Needs implementation!
}
});

widgetUtil(mntmSelectSingleVertexPtr[0]).addSelectionListener(e -> {
for (OpenGLRenderer renderer : Editor3DWindow.getRenders()) {
Expand Down

0 comments on commit 0c48753

Please sign in to comment.