Hello,
Thank you so much for the time you spend for me.
Sorry that my explanations are rather confusing. My skill regarding English language is far from what I would like it to be.
And my code was mixing to many topics at a time.
Therefor I have reviewed both my description of the problem, and my code.
What I need:
The goal of this postprocessor is to allow the optional insertion of G-Codes M07/M08 and M09 for each toolpath.
For example, I need to be able to
- Start the first toolpath with M07 only, and finish with M09
- Start the second toolpath with M08 only, and finish with M09
- Start a third toolpath with both M07 and M08, and finish with M09
- Start a fourth toolpath without M07 neither M08, and of course finish without M09
How I am trying to do it
The only solution I found so far for doing so is to dynamically update the definition of the toolpathHeader and toolpathFooter for each toolpath.
For that, each toolpath have its own flags defined as custom properties:
- ToolpathWriteM07 : Defines wherther we have to insert M07 and M09 or not for the current toolpath.
- ToolpathWriteM08 : Defines wherther we have to insert M07 and M09 or not for the current toolpath.
At camexport, both toolpathHeader and toolpathFooter are dynamically updated accordingly by function writeToolpathHeader.
Doing so, camexport works pretty well as expected.
In a first time, I have defined these two flags manually for each toolpath.
Now, I need to be able to set/reset these flags from the dialog "CamProfileToolpathDialog" when defining all parameters of each toolpath.
Therefore, I have added two checkBox's to the "CamProfileToolpathDialog" dialog.
At initialisation of this dialog, I can use these two flags ToolpathWriteM07 and ToolpathWriteM08 to set these two new checkBox's correctly.
What my problem is:
My problem is that when I close the dialog by clicking button "OK", I have no idea on how to store the result of the two checkbox's into the two flags of the toolpath on concern (I mean into the DXF).
I have tried to follow the way original data of a toolpath is managed, but the only relation I can see between the dialog widgets and custom properties of a toolpath is by their object names that are identical. So I try to give to my CheckBox's the same names as their relative custom properties, but it seams to have no effect at all. This is the reason why I try to set and retrieve the state of these CheckBoxes the way I do.
Code: Select all
include("LinuxCNCOffsetMM.js");
[b]And my questions are:[/b]
- Do you know any function that I could hack at the closing of the dialog box and where I could retrieve its data by myself (as shown in my hypothetical function by the end of my code) ?
- Do you know any much better way of doing what I want to do?
[code]
/**
* This configuration provides:
* - M7, M8 and M9 management for each toolPath.
*
* On camexport, toopathHeader and toolpathFooter are dynamically updated
* depending on flags ToolpathWriteM07 and ToolpathWriteM08, in order to include or not
* include G-Codes M7, M8 and M9 separatly for each toolpath.
*
*/
function LinuxCNCEvanCNC2(cadDocumentInterface, camDocumentInterface) {
LinuxCNCOffsetMM.call(this, cadDocumentInterface, camDocumentInterface);
this.debugging = true;
}
LinuxCNCEvanCNC2.prototype = new LinuxCNCOffsetMM();
LinuxCNCEvanCNC2.displayName = "LinuxCNC EvanCNC2";
LinuxCNCEvanCNC2.prototype.writeToolpathHeader = function(filename) {
// Dynamic update of toolpathHeader and toolpathFooter in order to insert M07/M08/M09
// depending on custom options ToolpathWriteM07 and ToolpathWriteM08
this.toolpathHeader = [
"[N] (------------ Begin Tool Path [TOOLPATH_INDEX]: [TOOLPATH_NAME] --------------)",
];
this.toolpathFooter = [
"[N] (------------ End Tool Path [TOOLPATH_INDEX]: [TOOLPATH_NAME] --------------)"
];
if (this.getToolpathOption("ToolpathWriteM07", 0) == 1)
this.toolpathHeader.push("[N] M07");
if (this.getToolpathOption("ToolpathWriteM08", 0) == 1)
this.toolpathHeader.push("[N] M08");
if ((this.getToolpathOption("ToolpathWriteM07", 0) == 1) || (this.getToolpathOption("ToolpathWriteM08", 0) == 1))
this.toolpathFooter.unshift("[N] M09");
LinuxCNCOffsetMM.prototype.writeToolpathHeader.call(this,filename);
}
LinuxCNCEvanCNC2.prototype.initDialog = function(dialog, di, resourceBlock) {
if (dialog.objectName==="CamProfileToolpathDialog") {
// ********** add a G-Code group ********
//
// retrieve the Layout of the dialog
var mainLayout = dialog.layout();
// add a QGoupBox for G-Codes
var gcodeGroup = new QGroupBox("G-Code");
// bind it to the Layout of the dialog
mainLayout.addWidget(gcodeGroup,3,0);
// retrieve the Layout of the new QGroupBox
var vBoxLayout = gcodeGroup.layout();
// add a HBoxLayout for grouping checkboxes in
var hBoxLayout = new QHBoxLayout(gcodeGroup);
// ******* add a CheckBox for M07 option ********
//
// create a new checkbox for managing M07:
var cbToolpathWriteM07 = new QCheckBox(qsTr("Enable M07"));
cbToolpathWriteM07.objectName = "ToolpathWriteM07";
// bind the CheckBox to the HBoxLayout
hBoxLayout.addWidget(cbToolpathWriteM07,0,0);
// try to retrieve the state of the option, and init the CheckBox accordingly
if (resourceBlock.getCustomProperty("QCAD","ToolpathWriteM07",0) == 1)
cbToolpathWriteM07.setCheckState(Qt.Checked);
else
cbToolpathWriteM07.setCheckState(Qt.Unchecked);
// ******* add a CheckBox for M08 option ********
//
// create a new checkbox for managing M08:
var cbToolpathWriteM08 = new QCheckBox(qsTr("Enable M08"));
cbToolpathWriteM08.objectName = "ToolpathWriteM08";
// bind the CheckBox to the HBoxLayout
hBoxLayout.addWidget(cbToolpathWriteM08,0,1);
// try to retrieve the state of the option, and init the CheckBox accordingly
if (resourceBlock.getCustomProperty("QCAD","ToolpathWriteM08",0) == 1)
cbToolpathWriteM08.setCheckState(Qt.Checked);
else
cbToolpathWriteM08.setCheckState(Qt.Unchecked);
}
}
// I am just missing a function that would be called when button OK of the dialog is clicked
// and where I could do as follow:
LinuxCNCEvanCNC2.prototype.hypoteticalNameOnButtonOkClicked = function(dialog) {
if (dialog.objectName==="CamProfileToolpathDialog") {
if (dialog.cbToolpathWriteM07.checkState() == Qt.Checked)
dialog.resourceBlock.setCustomProperty("QCAD","ToolpathWriteM07",1)
else
dialog.resourceBlock.setCustomProperty("QCAD","ToolpathWriteM07",0);
if (dialog.cbToolpathWriteM08.checkState() == Qt.Checked)
dialog.resourceBlock.setCustomProperty("QCAD","ToolpathWriteM08",1)
else
dialog.resourceBlock.setCustomProperty("QCAD","ToolpathWriteM08",0);
}
}