js::Value GCodeLibrary::arcCB(const js::Arguments &args) { Vector3D offset(args.getNumber("x"), args.getNumber("y"), args.getNumber("z")); double angle = args.getNumber("angle"); plane_t plane = args.has("plane") ? (plane_t)args.getUint32("plane") : XY; ctx.machine.arc(offset, angle, plane); return js::Value(); }
void GCodeLibrary::parseAxes(const js::Arguments &args, Axes &axes, bool incremental) { for (const char *axis ="xyzabcuvw"; *axis; axis++) { string name = string(1, *axis); if (args.has(name)) axes.set(*axis, args.getNumber(name) + (incremental ? axes.get(*axis) : 0)); } }
js::Value GCodeLibrary::toolSetCB(const js::Arguments &args) { SmartPointer<OpenSCAM::Tool> tool = ctx.tools->get(args["number"].toUint32()); uint32_t units; double scale = 1; if (args.has("units")) units = args["units"].toUint32(); else units = unitAdapter.getUnits(); if (units == MachineUnitAdapter::METRIC) tool->setUnits(OpenSCAM::ToolUnits::UNITS_MM); else { tool->setUnits(OpenSCAM::ToolUnits::UNITS_INCH); scale = 25.4; } if (args.has("shape")) tool->setShape((OpenSCAM::ToolShape::enum_t)args["shape"].toUint32()); tool->setLength(scale * args.getNumber("length")); tool->setDiameter(scale * args.getNumber("diameter")); tool->setSnubDiameter(scale * args.getNumber("snub")); tool->setFrontAngle(args.getNumber("front_angle")); tool->setBackAngle(args.getNumber("back_angle")); tool->setOrientation(args.getNumber("orientation")); return js::Value(); }
js::Value MatrixModule::rotateCB(const js::Arguments &args) { matrix.rotate(args.getNumber("angle"), args.getNumber("x"), args.getNumber("y"), args.getNumber("z"), parseMatrix(args)); return js::Value(); }
js::Value MatrixModule::scaleCB(const js::Arguments &args) { matrix.scale(args.getNumber("x"), args.getNumber("y"), args.getNumber("z"), parseMatrix(args)); return js::Value(); }