Thanks for the input.
The two panels at the right side of the CAM export dialog ("Global options" and "Layer options") are very flexible and configurable.
For example, the configuration "GCode" is based on the file "scripts/Cam/CamConfigurations/GCode.js".
In the constructor, this exporter defines the files "GCode.ui" and "GCodeLayer.ui" to be the global and layer specific option panels to be shown for that configuration. Your own configuration can for example inherit GCode but use different global options and layer specific options. You can use "Qt Designer" to design such individual option panels (.ui files). Object names that are used for the widgets in the .ui file are directly mapped to document variables and layer properties.
Example:
We want to create a new configuration called "MyLaser", based on "GCode". But instead of GCode.ui and GCodeLayer.ui, we want to use our own .ui files:
File "MyLaser.js"
Code: Select all
include("GCode.js");
function MyLaser(documentInterface, newDocumentInterface) {
GCode.call(this, documentInterface, newDocumentInterface);
this.globalOptions = "MyLaser";
this.layerOptions = "MyLaserLayer";
}
MyLaser.prototype = new GCode();
MyLaser.ui contains one combo box with its object name set to "Power".
MyLaserLayer.ui contains one combo box with its object name also set to "Power".
The power chosen as global option is then accessible in MyLaser.js as document variable:
Code: Select all
var powerGlobal = this.document.getVariable("Cam/Power");
The power chosen for the layer which is currently being processed is accessible as layer property:
Code: Select all
var layer = this.document.queryLayer(this.getEntity().getLayerId());
var powerLayer = layer.getCustomProperty("Cam/Power", powerGlobal); // default to globally set power
Document variables and layer properties can be saved to the DXF file if XData is enabled. Since XData support is considered experimental, you will have to enable it on the command line when starting QCAD:
That's probably a lot of information to digest. The reason for this relatively complex design is flexibility. The information that has to be collected from the user greatly depends on the configuration and the target machine. Configurations might use lists, tables, combo boxes, check boxes, line edits or even multiline text fields. This is somewhat unpredictable at this point, but I didn't want to impose any unnecessary limits for the user interface. Users are usually more creative than expected at first
If someone only engraves text for example, an exporter might only ask for a line of text and a font and not even require any CAD input.