function OnAbout(event)
   ctrl = event:GetTextCtrl()
   ctrl:AppendText("EMC2 post processor for Plasma\n")
   ctrl:AppendText("by John Thornton\n")
   ctrl:AppendText("Modal G-codes and coordinates\n")
   ctrl:AppendText("Comments enclosed with ( and )\n")
   ctrl:AppendText("Incremental IJ\n")
end


--  created  8/1/2008
--  For Plasma Cutter

function OnInit()
   post.SetCommentChars ("()", "[]")  --make sure ( and ) characters do not appear in system text
   post.Text ("(Filename: ", fileName, ")\n")
   post.Text ("(Post processor: ", postName, ")\n")
   post.Text ("(Date: ", date, ")\n")
   if(scale == metric) then
      post.Text ("G21 (Units: Metric)\n") --metric mode
   else
      post.Text ("G20 (Units: Inches)\n") --inch mode
   end
   post.Text ("G40 (Cancel Cutter Comp)\n")
   post.Text ("G90 (Absolute Mode)\n")
   -- post.Text ("F1 (Feed Rate)\n")
   post.Text ("G64 P0.005 (Continuous mode + path tolerance)\n")
   post.Text ("G92 X0 Y0\n")
   bigArcs = 1 --stitch arc segments together
   minArcSize = 0.05 --arcs smaller than this are converted to moves
end

function OnNewPart()
   post.Text("(Part: ",partName,")\n");
end

function OnNewOperation()
   post.Text ("(Process: ", operationName, ")\n")
   if (plungeRate <= 0) then
      post.Warning("WARNING: Plunge rate is zero")
   end
   if (feedRate <= 0) then
      post.Warning("WARNING: Feed rate is zero")
   end
end

function OnToolChange()
   -- post.Text ("M6 T")
   -- post.Number (tool, "0")
   -- post.Text ("  (", toolName, ")\n")
   -- post.Eol()
end

function OnSpindleChanged()
   if (spindleSpeed <= 0) then
      post.Warning("WARNING: Spindle speed is zero")
   end
end

function OnRapid()
   post.ModalText ("G0")
   post.ModalNumber (" X", endX * scale, "0.0000")
   post.ModalNumber (" Y", endY * scale, "0.0000")
   post.ModalNumber (" Z", (endZ + toolOffset) * scale, "0.0000")
   post.Eol()
end

function OnMove()
   post.ModalText ("G1")
   post.ModalNumber (" X", endX * scale, "0.0000")
   post.ModalNumber (" Y", endY * scale, "0.0000")
   post.ModalNumber (" F", feedRate * scale, "0.###")
   post.ModalNumber (" S", spindleSpeed, "0.##")
   post.Eol()
end

function OnArc()
   if(arcAngle <0) then
      post.ModalText ("G3")
   else
      post.ModalText ("G2")
   end
   post.NonModalNumber (" X", endX * scale, "0.0000")
   post.NonModalNumber (" Y", endY * scale, "0.0000")
   post.Text (" I")
   post.Number ((arcCentreX - currentX) * scale, "0.0000")
   post.Text (" J")
   post.Number ((arcCentreY - currentY) * scale, "0.0000")
   post.ModalNumber (" F", feedRate * scale, "0.0###")
   post.ModalNumber (" S", spindleSpeed, "0.##")
   post.Eol()
end


function OnPenDown()
   post.NonModalNumber("o call [" ,pierceHeight * scale ,"0.000" )
      post.Text ("] ")
   post.NonModalNumber("[", pierceDelay * scale, "0.##")
   post.Text ("] ")
   post.NonModalNumber("[", cutHeight * scale, "0.##")
   post.Text ("] (Touchoff and start cutting)\n")
   post.NonModalNumber (" F", feedRate * scale, "0.###")
   post.Eol()
end

function OnPenUp()
   post.Text ("M5 (Torch Off)\n")
end

function OnComment()
  post.Text(" (",commentText,")\n")
end


function OnFinish()
   post.Text ("G92.1 (Cancel offsets and set to zero)\n")
   post.Text ("G0 Z0\n")
   post.Text ("M2\n")
end