Skip to content

Commit

Permalink
Added a settings object
Browse files Browse the repository at this point in the history
The settings object will interface to all the configurable parameters
across the tool, allowing for easy saving & restoring of configurations.
  • Loading branch information
xenovacivus committed Jan 18, 2014
1 parent ba19fc7 commit 3d39653
Show file tree
Hide file tree
Showing 9 changed files with 219 additions and 191 deletions.
16 changes: 12 additions & 4 deletions Commands/MoveTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@ namespace Commands
{
public class MoveTool : ICommand
{
public enum SpeedType
{
Cutting,
Rapid,
}

private Vector3 target; // Target location in inches
private float speed; // Moving speed in inches per minute
private SpeedType speed;

public MoveTool(Vector3 target, float speed)
public MoveTool(Vector3 target, SpeedType speed)
{
this.target = target;
this.speed = speed;
Expand All @@ -16,11 +22,13 @@ public MoveTool(Vector3 target, float speed)
public Vector3 Target
{
get { return target; }
set { target = value; }
}

public float Speed
public SpeedType Speed
{
get { return speed; }
get { return speed; }
set { speed = value; }
}
}
}
1 change: 1 addition & 0 deletions GUI/GUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
<Compile Include="Drawing3D.Designer.cs">
<DependentUpon>Drawing3D.cs</DependentUpon>
</Compile>
<Compile Include="Settings.cs" />
<Compile Include="TabsGUI.cs" />
<Compile Include="TriangleMeshGUI.cs" />
<Compile Include="Viewport3d.cs" />
Expand Down
23 changes: 11 additions & 12 deletions GUI/PathCAM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,25 @@ public partial class PathCAM : Form, IOpenGLDrawable
private RouterGUI router;
private string dragDropFilename = null;
private Regex acceptedFileRegex = new Regex(@".*(\.dae|\.obj|\.stl|\.nc|\.gcode)", RegexOptions.IgnoreCase);
private Settings settings;

public PathCAM()
{
InitializeComponent();

router = new RouterGUI();
propertyGrid.SelectedObject = router;
drawing3D.AddObject(router);
robotControl.AssignRouter(router);

drawing3D.AddObject(robotControl);
drawing3D.AddObject(this);
drawing3D.DragDrop += this.Drawing3D_DragDrop;
drawing3D.DragOver += this.Drawing3D_DragOver;
drawing3D.DragEnter += this.Drawing3D_DragEnter;
drawing3D.DragLeave += this.Drawing3D_DragLeave;

settings = new Settings(robotControl.GetRobot(), router);
propertyGrid.SelectedObject = settings;
}

void Drawing3D_DragLeave(object sender, EventArgs e)
Expand Down Expand Up @@ -313,10 +317,10 @@ private void InitializeComponent()
// propertyGrid
//
this.propertyGrid.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.propertyGrid.Location = new System.Drawing.Point(12, 128);
this.propertyGrid.Location = new System.Drawing.Point(12, 157);
this.propertyGrid.Name = "propertyGrid";
this.propertyGrid.PropertySort = System.Windows.Forms.PropertySort.NoSort;
this.propertyGrid.Size = new System.Drawing.Size(183, 163);
this.propertyGrid.Size = new System.Drawing.Size(183, 205);
this.propertyGrid.TabIndex = 5;
this.propertyGrid.ToolbarVisible = false;
//
Expand Down Expand Up @@ -363,7 +367,7 @@ private void InitializeComponent()
"25.4:1 (millimeters)",
".254:1 (meters)",
"1:12 (feet)"});
this.comboBox1.Location = new System.Drawing.Point(87, 299);
this.comboBox1.Location = new System.Drawing.Point(87, 129);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(107, 21);
this.comboBox1.TabIndex = 7;
Expand All @@ -373,7 +377,7 @@ private void InitializeComponent()
// openFileButton
//
this.openFileButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.openFileButton.Location = new System.Drawing.Point(12, 297);
this.openFileButton.Location = new System.Drawing.Point(12, 128);
this.openFileButton.Name = "openFileButton";
this.openFileButton.Size = new System.Drawing.Size(70, 23);
this.openFileButton.TabIndex = 6;
Expand All @@ -394,8 +398,8 @@ private void InitializeComponent()
//
// pictureBox1
//
this.pictureBox1.BackColor = System.Drawing.SystemColors.ActiveBorder;
this.pictureBox1.Location = new System.Drawing.Point(86, 298);
this.pictureBox1.BackColor = System.Drawing.Color.Black;
this.pictureBox1.Location = new System.Drawing.Point(86, 128);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(109, 23);
this.pictureBox1.TabIndex = 70;
Expand Down Expand Up @@ -475,11 +479,6 @@ private void checkBox1_CheckedChanged(object sender, EventArgs e)
robotControl.Visible = showRobotFormCheckbox.Checked;
}

private void drawing3D_Load(object sender, EventArgs e)
{

}

private void PathCAM_Load(object sender, EventArgs e)
{
// Programatically fill the entire client rectangle with the drawing area.
Expand Down
11 changes: 8 additions & 3 deletions GUI/RobotControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ public void AssignRouter(Router.Router router)
this.robot.onRobotStatusChange += new EventHandler(RobotStatusUpdate);
}

public Robot.Robot GetRobot()
{
return robot;
}

void RobotStatusUpdate(object o, EventArgs e)
{
if (this.InvokeRequired && !this.Disposing)
Expand Down Expand Up @@ -165,8 +170,8 @@ private void cancelButton_Click(object sender, EventArgs e)
{
robot.CancelPendingCommands();
Vector3 position = robot.GetPosition();
robot.AddCommand(new MoveTool(new Vector3(position.X, position.Y, router.MoveHeight), router.MoveSpeed));
robot.AddCommand(new MoveTool(new Vector3(0, 0, router.MoveHeight), router.MoveSpeed));
robot.AddCommand(new MoveTool(new Vector3(position.X, position.Y, router.MoveHeight), MoveTool.SpeedType.Rapid));
robot.AddCommand(new MoveTool(new Vector3(0, 0, router.MoveHeight), MoveTool.SpeedType.Rapid));
robot.SendResumeCommand();
this.pause_resume_button.Enabled = false;
this.cancelButton.Enabled = false;
Expand Down Expand Up @@ -195,7 +200,7 @@ private void runButton_Click(object sender, EventArgs e)
private void zGo_Click(object sender, EventArgs e)
{
float f = float.Parse(zbox.Text);
MoveTool move = new MoveTool(new Vector3(0, 0, f), router.MoveSpeed);
MoveTool move = new MoveTool(new Vector3(0, 0, f), MoveTool.SpeedType.Rapid);
robot.AddCommand(move);
}

Expand Down
51 changes: 0 additions & 51 deletions GUI/RouterGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,57 +38,6 @@ public RouterGUI() : base()
{
}

///
/// Accessors for the property grid
///
[DisplayName("Last Pass Height")]
[Description("Height of the last pass in inches")]
new public float LastPassHeight
{
get { return base.LastPassHeight; }
set { base.LastPassHeight = value; }
}

[DisplayName("Tool Diameter")]
[Description("Tool Diameter in inches")]
new public float ToolDiameter
{
get { return base.ToolDiameter; }
set { base.ToolDiameter = value; }
}

[DisplayName("Routing Speed")]
[Description("Rout Speed (inches per minute)")]
new public float RoutSpeed
{
get { return base.RoutSpeed; }
set { base.RoutSpeed = value; }
}

[DisplayName("Moving Speed")]
[Description("Moving speed (inches per minute)")]
new public float MoveSpeed
{
get { return base.MoveSpeed; }
set { base.MoveSpeed = value; }
}

[DisplayName("Move Height")]
[Description("Safe travel height")]
new public float MoveHeight
{
get { return base.MoveHeight; }
set { base.MoveHeight = value; }
}

[DisplayName("Max Cut Depth")]
[Description("Maximum Cut Depth")]
new public float MaxCutDepth
{
get { return base.MaxCutDepth; }
set { base.MaxCutDepth = value; }
}

void IOpenGLDrawable.Draw()
{
try
Expand Down
86 changes: 86 additions & 0 deletions GUI/Settings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
using OpenTK;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing.Design;
using System.Linq;
using System.Text;

namespace GUI
{
/// <summary>
/// Collects all settings and exposes them through one class.
/// </summary>
public class Settings
{
private Robot.Robot robot;
private Router.Router router;
public Settings(Robot.Robot robot, Router.Router router)
{
this.router = router;
this.robot = robot;
}


///
/// Accessors for the property grid
///
[DisplayName("Last Pass Height")]
[Description("Height of the last pass in inches")]
public float LastPassHeight
{
get { return router.LastPassHeight; }
set { router.LastPassHeight = value; }
}

[DisplayName("Tool Diameter")]
[Description("Tool Diameter in inches")]
public float ToolDiameter
{
get { return router.ToolDiameter; }
set { router.ToolDiameter = value; }
}

[DisplayName("Move Height")]
[Description("Safe travel height")]
public float MoveHeight
{
get { return router.MoveHeight; }
set { router.MoveHeight = value; }
}

[DisplayName("Max Cut Depth")]
[Description("Maximum Cut Depth")]
public float MaxCutDepth
{
get { return router.MaxCutDepth; }
set { router.MaxCutDepth = value; }
}



[DisplayName("Cutting Speed")]
[Description("Cutting Speed (inches per minute)")]
public float RoutSpeed
{
get { return robot.MaxCutSpeed; }
set { robot.MaxCutSpeed = value; }
}

[DisplayName("Moving Speed")]
[Description("Rapid movement speed (inches per minute)")]
public float MoveSpeed
{
get { return robot.MaxRapidSpeed; }
set { robot.MaxRapidSpeed = value; }
}

[DisplayName("Max Z Speed")]
[Description("Maximum possible Z axis speed (inches per minute)")]
public float MaxAxisSpeeds
{
get { return robot.MaxZSpeed; }
set { robot.MaxZSpeed = value; }
}
}
}
Loading

0 comments on commit 3d39653

Please sign in to comment.