Skip to content

Commit

Permalink
Merge branch 'master' into javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
i-make-robots committed Jan 12, 2024
2 parents f710c12 + 4ea6781 commit 199dc37
Show file tree
Hide file tree
Showing 36 changed files with 925 additions and 76 deletions.
35 changes: 34 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.marginallyclever</groupId>
<artifactId>RobotOverlord</artifactId>
<version>2.105.1</version>
<version>2.105.8</version>
<name>Robot Overlord</name>
<description>A friendly 3D user interface for controlling robots.</description>
<url>https://www.marginallyclever.com/</url>
Expand Down Expand Up @@ -302,6 +302,31 @@
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.8</version>
</plugin>
<!-- Code Coverage report generation -->
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.11</version>
<configuration>
<excludes>
<exclude>com/marginallyclever/robotoverlord/**</exclude>
</excludes>
</configuration>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>generate-code-coverage-report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>

<pluginManagement>
Expand Down Expand Up @@ -388,6 +413,14 @@
<scope>test</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/org.mockito/mockito-core -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.8.0</version>
<scope>test</scope>
</dependency>

<!-- used for some src/main/util/PreferencesHelper logging -->
<!-- https://mvnrepository.com/artifact/org.json/json -->
<dependency>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/marginallyclever/ro3/Registry.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.marginallyclever.ro3.mesh.MeshFactory;
import com.marginallyclever.ro3.node.nodes.*;
import com.marginallyclever.ro3.node.Node;
import com.marginallyclever.ro3.node.nodes.limbplanner.LimbPlanner;
import com.marginallyclever.ro3.node.nodes.limbsolver.LimbSolver;
import com.marginallyclever.ro3.node.nodes.marlinrobotarm.MarlinRobotArm;
import com.marginallyclever.ro3.node.nodes.pose.AttachmentPoint;
Expand Down Expand Up @@ -32,7 +33,6 @@ public class Registry {
public static final ListWithEvents<Camera> cameras = new ListWithEvents<>();
private static Camera activeCamera = null;
public static final ListWithEvents<Node> selection = new ListWithEvents<>();
public static final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();

public static void start() {
nodeFactory.clear();
Expand All @@ -44,7 +44,7 @@ public static void start() {
nodule.add("Material", Material::new);
nodule.add("MeshInstance", MeshInstance::new);
nodule.add("Motor", Motor::new);
nodule.add("TargetPlanner", TargetPlanner::new);
nodule.add("LimbPlanner", LimbPlanner::new);
Factory.Category<Node> pose = nodule.add("Pose", Pose::new);
pose.add("Camera", Camera::new);
pose.add("LookAt", LookAt::new);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@


import java.io.*;
import java.security.InvalidParameterException;
import java.util.*;
import javax.swing.*;
import javax.swing.filechooser.FileNameExtensionFilter;
Expand Down Expand Up @@ -42,6 +43,7 @@ public ExportScene(JFileChooser chooser) {
*/
@Override
public void actionPerformed(ActionEvent e) {
if( chooser == null ) throw new InvalidParameterException("file chooser cannot be null");
chooser.setFileFilter(ZIP_FILTER);
Component source = (Component) e.getSource();
JFrame parentFrame = (JFrame)SwingUtilities.getWindowAncestor(source);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.security.InvalidParameterException;
import java.util.Objects;

/**
Expand Down Expand Up @@ -36,6 +37,7 @@ public ImportScene(JFileChooser chooser) {
*/
@Override
public void actionPerformed(ActionEvent e) {
if( chooser == null ) throw new InvalidParameterException("file chooser cannot be null");
chooser.setFileFilter(RO3Frame.FILE_FILTER);

Component source = (Component) e.getSource();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.marginallyclever.ro3.apps.actions;

import com.marginallyclever.ro3.apps.RO3Frame;
import com.marginallyclever.ro3.apps.UndoSystem;
import com.marginallyclever.ro3.apps.RecentFilesMenu;
import com.marginallyclever.ro3.Registry;
Expand Down Expand Up @@ -76,6 +77,7 @@ public void actionPerformed(ActionEvent e) {

private File runFileDialog(Component source) {
if( chooser == null ) throw new InvalidParameterException("file chooser cannot be null");
chooser.setFileFilter(RO3Frame.FILE_FILTER);
JFrame parentFrame = (JFrame)SwingUtilities.getWindowAncestor(source);
if (chooser.showOpenDialog(parentFrame) == JFileChooser.APPROVE_OPTION) {
return chooser.getSelectedFile();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import javax.swing.*;
import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.FlavorEvent;
import java.awt.event.ActionEvent;
import java.util.ArrayList;
Expand All @@ -18,26 +19,27 @@
*/
public class PasteNode extends AbstractAction {
private final Logger logger = LoggerFactory.getLogger(PasteNode.class);
private final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();

public PasteNode() {
super();
putValue(Action.NAME,"Paste");
putValue(Action.SMALL_ICON,new ImageIcon(Objects.requireNonNull(getClass().getResource("icons8-paste-16.png"))));
putValue(SHORT_DESCRIPTION,"Paste the selected node(s).");

Registry.clipboard.addFlavorListener(this::clipboardChanged);
clipboard.addFlavorListener(this::clipboardChanged);
setEnabled(false);
}

private void clipboardChanged(FlavorEvent flavorEvent) {
// if the clipboard has changed, update the menu item
if(flavorEvent.getSource()==Registry.clipboard) {
if(flavorEvent.getSource()==clipboard) {
if(KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow() == null) {
setEnabled(false);
return;
}
try {
setEnabled(Registry.clipboard.isDataFlavorAvailable(JSONHelper.JSON_FLAVOR));
setEnabled(clipboard.isDataFlavorAvailable(JSONHelper.JSON_FLAVOR));
} catch (IllegalStateException ignored) {
// if this clipboard is currently unavailable
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.marginallyclever.ro3.apps.actions;

import com.marginallyclever.ro3.Registry;
import com.marginallyclever.ro3.apps.RO3Frame;
import com.marginallyclever.ro3.apps.RecentFilesMenu;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -12,6 +13,7 @@
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.security.InvalidParameterException;
import java.util.Objects;

/**
Expand Down Expand Up @@ -54,6 +56,9 @@ public void actionPerformed(ActionEvent e) {
}

private String askUserForDestinationPath(Component source) {
if( chooser == null ) throw new InvalidParameterException("file chooser cannot be null");
chooser.setFileFilter(RO3Frame.FILE_FILTER);

JFrame parentFrame = (JFrame)SwingUtilities.getWindowAncestor(source);

int response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

import javax.swing.undo.AbstractUndoableEdit;
import javax.swing.undo.CannotUndoException;
import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.Transferable;
import java.util.List;
Expand All @@ -20,10 +22,12 @@ public class CopyNode extends AbstractUndoableEdit {
private final Logger logger = LoggerFactory.getLogger(com.marginallyclever.ro3.apps.actions.CopyNode.class);
private final List<Node> selection;
private final Transferable before;
private final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();

public CopyNode(List<Node> selection) {
super();
this.selection = selection;
this.before = Registry.clipboard.getContents(null);
this.before = clipboard.getContents(null);
execute();
}

Expand All @@ -48,7 +52,7 @@ public void execute() {
jsonWrapper.put("copied",list);
// store the json in the clipboard.
StringSelection stringSelection = new StringSelection(jsonWrapper.toString());
Registry.clipboard.setContents(stringSelection, null);
clipboard.setContents(stringSelection, null);
}

@Override
Expand All @@ -58,6 +62,6 @@ public void undo() throws CannotUndoException {
}

public void reverse() {
Registry.clipboard.setContents(before, null);
clipboard.setContents(before, null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

import javax.swing.undo.AbstractUndoableEdit;
import javax.swing.undo.CannotUndoException;
import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.Transferable;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -18,9 +20,10 @@
*/
public class PasteNode extends AbstractUndoableEdit {
private final Logger logger = LoggerFactory.getLogger(PasteNode.class);
Transferable transfer;
private final List<Node> children = new ArrayList<>();
private final List<Node> parents;
private final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
private final Transferable transfer;

/**
* Paste the copied nodes as children of the parent nodes.
Expand All @@ -29,7 +32,7 @@ public class PasteNode extends AbstractUndoableEdit {
public PasteNode(List<Node> parents) {
super();
this.parents = parents;
transfer = Registry.clipboard.getContents(null);
transfer = clipboard.getContents(null);
execute();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ public RotateToolOneAxis(ColorRGB color) {
this.color = color;
buildMarkerMesh();
buildAngleMesh();
ringMesh.setRenderStyle(GL3.GL_LINE_LOOP);
}

private void buildAngleMesh() {
Expand Down Expand Up @@ -389,8 +390,11 @@ private void drawWhileDragging(GL3 gl,ShaderProgram shaderProgram) {

private void drawMainRingAndHandles(GL3 gl,ShaderProgram shaderProgram) {
Matrix4d m = new Matrix4d(pivotMatrix);
m.transpose();
shaderProgram.setMatrix4d(gl,"modelMatrix",m);

Matrix4d scale = MatrixHelper.createScaleMatrix4(getRingRadiusScaled());
scale.mul(m,scale);
scale.transpose();
shaderProgram.setMatrix4d(gl,"modelMatrix",scale);

float colorScale = cursorOverHandle ? 1:0.5f;
float red = color.red * colorScale / 255f;
Expand All @@ -399,6 +403,9 @@ private void drawMainRingAndHandles(GL3 gl,ShaderProgram shaderProgram) {
shaderProgram.set4f(gl, "objectColor", red, green, blue, 1.0f);
ringMesh.render(gl,1,360);

m.transpose();
shaderProgram.setMatrix4d(gl,"modelMatrix",m);

Matrix4d m2 = MatrixHelper.createScaleMatrix4(getGripRadiusScaled());
m2.m03 = getHandleLengthScaled();
m2.m13 = getHandleOffsetYScaled();
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/com/marginallyclever/ro3/node/nodes/DHParameter.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,18 +178,34 @@ public void fromJSON(JSONObject from) {
if(from.has("alpha")) alpha = from.getDouble("alpha");
}

public void setD(double d) {
this.d = d;
}

public double getD() {
return d;
}

public void setR(double r) {
this.r = r;
}

public double getR() {
return r;
}

public void setAlpha(double alpha) {
this.alpha = alpha;
}

public double getAlpha() {
return alpha;
}

public void setTheta(double theta) {
this.theta = theta;
}

public double getTheta() {
return theta;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void getComponents(List<JPanel> list) {
textureChooserDialog.setSelectedItem(texture);
int result = textureChooserDialog.run(pane);
if(result == JFileChooser.APPROVE_OPTION) {
texture = textureChooserDialog.getSelectedItem();
setTexture(textureChooserDialog.getSelectedItem());
setTextureButtonLabel(button);
}
});
Expand Down Expand Up @@ -120,6 +120,10 @@ public void getComponents(List<JPanel> list) {

}

public void setTexture(TextureWithMetadata selectedItem) {
texture = selectedItem;
}

private JComponent createShininessSlider() {
JPanel container = new JPanel(new BorderLayout());

Expand Down
11 changes: 4 additions & 7 deletions src/main/java/com/marginallyclever/ro3/node/nodes/Motor.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,6 @@ public void update(double dt) {
}
}

private HingeJoint addHinge() {
HingeJoint hinge = new HingeJoint("Motor Hinge");
Node parent = getParent();
if(parent!=null) parent.addChild(hinge);
return hinge;
}

@Override
public void getComponents(List<JPanel> list) {
JPanel pane = new JPanel(new GridLayout(0,2));
Expand Down Expand Up @@ -83,6 +76,10 @@ public HingeJoint getHinge() {
return hinge.getSubject();
}

/**
* Set the hinge this motor will drive. the hinge must be in the same node tree as this motor.
* @param hinge the hinge this motor will drive.
*/
public void setHinge(HingeJoint hinge) {
this.hinge.setRelativePath(this, hinge);
}
Expand Down
Loading

0 comments on commit 199dc37

Please sign in to comment.