Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Orientation cube using JCSG #2631

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions ugs-platform/ugs-platform-visualizer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@
<publicPackage>com.willwinder.ugs.nbm.visualizer.shared</publicPackage>
<publicPackage>com.willwinder.ugs.nbm.visualizer.options</publicPackage>
<publicPackage>com.willwinder.ugs.nbm.visualizer.renderables</publicPackage>
<publicPackage>org.apache.commons.io</publicPackage>
<publicPackage>javax.xml.datatype</publicPackage>
<publicPackage>org.w3c.dom</publicPackage>
<publicPackage>org.w3c.dom.ls</publicPackage>
<publicPackage>org.xml.sax</publicPackage>
<publicPackage>javax.xml.parsers</publicPackage>
<publicPackage>org.w3c.dom.bootstrap</publicPackage>
<publicPackage>org.xml.sax.helpers</publicPackage>
<publicPackage>com.jogamp.opengl</publicPackage>
</publicPackages>
</configuration>
</plugin>
Expand Down Expand Up @@ -64,6 +73,13 @@
<version>${netbeans.version}</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.netbeans.modules</groupId>
<artifactId>org-openide-util-ui-svg</artifactId>
<version>${netbeans.version}</version>
<type>jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>ugs-platform-ugslib</artifactId>
Expand Down Expand Up @@ -91,5 +107,72 @@
<artifactId>ugs-platform-ugscore</artifactId>
<version>${project.version}</version>
</dependency>

<!-- For creating Constructive Solid Geometry -->
<dependency>
<groupId>com.neuronrobotics</groupId>
<artifactId>JavaCad</artifactId>
<version>1.8.8</version>
</dependency>
<dependency>
<groupId>eu.mihosoft.vvecmath</groupId>
<artifactId>vvecmath</artifactId>
<version>0.4.0</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>17.0.8</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-base</artifactId>
<version>17.0.8</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>17.0.9</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>17.0.9</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-swing</artifactId>
<version>17.0.9</version>
</dependency>

<!-- For geometric operations -->
<dependency>
<groupId>org.locationtech.jts</groupId>
<artifactId>jts-core</artifactId>
<version>${jts.version}</version>
</dependency>

<!-- For reading SVG -->
<dependency>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>batik-all</artifactId>
<version>${batik.version}</version>
</dependency>
<dependency>
<groupId>javax.vecmath</groupId>
<artifactId>vecmath</artifactId>
<version>1.5.2</version>
</dependency>

<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>${gson.version}</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ This file is part of Universal Gcode Sender (UGS).
public class RendererInputHandler implements
WindowListener, MouseWheelListener, MouseMotionListener,
MouseListener, KeyListener, PreferenceChangeListener, UGSEventListener {
private static final int HIGH_FPS = 15;
private static final int LOW_FPS = 4;
private final int highFps;
private final int lowFps;
private final GcodeRenderer gcodeRenderer;
private final AnimatorBase animator;
private final BackendAPI backend;
Expand All @@ -76,11 +76,13 @@ public class RendererInputHandler implements
private Position selectionStart = null;
private Position selectionEnd = null;

public RendererInputHandler(GcodeRenderer gr, AnimatorBase a, BackendAPI backend) {
public RendererInputHandler(GcodeRenderer gr, AnimatorBase a, BackendAPI backend, int lowFps, int highFps) {
gcodeRenderer = gr;
animator = a;
this.backend = backend;
settings = backend.getSettings();
this.highFps = highFps;
this.lowFps = lowFps;

gcodeModel = new GcodeModel(Localization.getString("platform.visualizer.renderable.gcode-model"), backend);
sizeDisplay = new SizeDisplay(Localization.getString("platform.visualizer.renderable.gcode-model-size"));
Expand Down Expand Up @@ -271,7 +273,7 @@ public void mouseClicked(MouseEvent e) {
*/
@Override
public void mousePressed(MouseEvent e) {
setFPS(HIGH_FPS);
setFPS(highFps);
// Zoom
if (e.getButton() == MouseEvent.BUTTON1 && e.isMetaDown()) {
selecting = true;
Expand All @@ -282,7 +284,7 @@ public void mousePressed(MouseEvent e) {

@Override
public void mouseReleased(MouseEvent e) {
setFPS(LOW_FPS);
setFPS(lowFps);

// Finish selecting.
if (selecting) {
Expand Down Expand Up @@ -317,7 +319,7 @@ public void keyTyped(KeyEvent ke) {
*/
@Override
public void keyPressed(KeyEvent ke) {
setFPS(HIGH_FPS);
setFPS(highFps);

int DELTA_SIZE = 1;

Expand Down Expand Up @@ -358,7 +360,7 @@ public void keyPressed(KeyEvent ke) {
*/
@Override
public void keyReleased(KeyEvent ke) {
setFPS(LOW_FPS);
setFPS(lowFps);
}

public void dispose() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ This file is part of Universal Gcode Sender (UGS).
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.GLCapabilities;
import com.jogamp.opengl.GLException;
import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.util.FPSAnimator;
import com.willwinder.ugs.nbm.visualizer.RendererInputHandler;
import com.willwinder.ugs.nbm.visualizer.options.VisualizerOptions;
import static com.willwinder.ugs.nbm.visualizer.options.VisualizerOptions.VISUALIZER_OPTION_NEWT_SAMPLES;
Expand Down Expand Up @@ -134,8 +134,8 @@ private NewtCanvasAWT makeWindow() throws GLException {
lock.lock();
lock.unlock();

Animator animator = new Animator(glWindow);
this.rih = new RendererInputHandler(renderer, animator, backend);
FPSAnimator animator = new FPSAnimator(glWindow, 60);
this.rih = new RendererInputHandler(renderer, animator, backend, 30, 60);

Preferences pref = NbPreferences.forModule(VisualizerOptionsPanel.class);
pref.addPreferenceChangeListener(this.rih);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private GLJPanel makeWindow() throws GLException {
}

FPSAnimator animator = new FPSAnimator(p, 15);
this.rih = new RendererInputHandler(renderer, animator, backend);
this.rih = new RendererInputHandler(renderer, animator, backend, 4, 15);

Preferences pref = NbPreferences.forModule(VisualizerOptionsPanel.class);
pref.addPreferenceChangeListener(this.rih);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@ This file is part of Universal Gcode Sender (UGS).

import com.jogamp.opengl.GL;
import com.jogamp.opengl.GL2;
import com.jogamp.opengl.GLAutoDrawable;
import com.willwinder.ugs.nbm.visualizer.options.VisualizerOptions;
import com.willwinder.ugs.nbm.visualizer.shader.PlainShader;
import com.willwinder.ugs.nbm.visualizer.shared.VertexObjectRenderable;
import com.willwinder.universalgcodesender.model.Position;

import static com.willwinder.ugs.nbm.visualizer.options.VisualizerOptions.VISUALIZER_OPTION_GRID;
import static com.willwinder.ugs.nbm.visualizer.options.VisualizerOptions.VISUALIZER_OPTION_X;
import static com.willwinder.ugs.nbm.visualizer.options.VisualizerOptions.VISUALIZER_OPTION_XY_GRID;
import static com.willwinder.ugs.nbm.visualizer.options.VisualizerOptions.VISUALIZER_OPTION_Y;
import static com.willwinder.ugs.nbm.visualizer.options.VisualizerOptions.VISUALIZER_OPTION_Z;
import com.willwinder.ugs.nbm.visualizer.shared.VertexObjectRenderable;
import com.willwinder.universalgcodesender.model.Position;

/**
* @author wwinder
Expand All @@ -39,7 +42,7 @@ public class Grid extends VertexObjectRenderable {
private float[] zAxisColor;

public Grid(String title) {
super(6, title, VISUALIZER_OPTION_GRID);
super(6, title, VISUALIZER_OPTION_GRID, new PlainShader());
reloadPreferences(new VisualizerOptions());
}

Expand All @@ -53,7 +56,8 @@ public final void reloadPreferences(VisualizerOptions vo) {
}

@Override
public void render(GL2 gl) {
public void render(GLAutoDrawable drawable) {
GL2 gl = drawable.getGL().getGL2();
gl.glLineWidth(1.2f);
gl.glDisable(GL.GL_DEPTH_TEST);
gl.glDrawArrays(GL.GL_LINES, 0, getVertexCount());
Expand Down
Loading
Loading