Hello Andrew,
I am working on a QCAD application that gets (x,y) values from laser and plots them on the Document Interface. I get values from laser every 100ms.
Each time a get a value, I delete and redraw 1 polyline + 3 circles and draw 1 point to the document. This works fine for a couple of minutes but after that, the plotting gets slow and eventually the document becomes unresponsive and hangs. So is there a way to handle such fast data ? I was even looking to move this to C++ so that I can use threads but as Document Interface is a GUI object I cannot move it. Also is there a way to select points from the document and export them as csv?
//--Point--
view = EAction.getGraphicsView();
PlotXY = function(X,Y){
var op = new RAddObjectsOperation();
var point = new RPointEntity(document,new RPointData(new RVector(X, Y)));
op.addObject(point);
documentInterface.applyOperation(op);
view.repaintNow();
};
//--Line--
PlotLine = function(V1, V2) {
deleteSegment();
var List = [V1, V2];
var poly = new RPolyline(List,false);
var polyData = new RPolylineData(poly);
lineSegment = new RPolylineEntity(document, polyData);
var op = new RAddObjectsOperation();
op.addObject(lineSegment ,false);
documentInterface.applyOperation(op);
};
function deleteSegment()
{
var op = new RDeleteObjectsOperation(true);
if(lineSegment != null){
op.deleteObject(lineSegment );
lineSegment = null;
op.apply(document,false);
}
}; //Similarly I add and delete 3 circles.
I am using QCAD version : 3.20.1.5
Appreciate your help.
Thanks!
EZM
Faster way to plot objects on Document Interface
Moderator: andrew
Forum rules
Always indicate your operating system and QCAD version.
Attach drawing files, scripts and screenshots.
Post one question per topic.
Always indicate your operating system and QCAD version.
Attach drawing files, scripts and screenshots.
Post one question per topic.
Re: Faster way to plot objects on Document Interface
Code: Select all
applyOperation
Code: Select all
RAddObjectsOperation
Arch Linux, QCad 3.22.0 Prof.
Re: Faster way to plot objects on Document Interface
The problem is that by adding and removing entities, an huge stack of undo / redo history is created.
If your intention is to display short-lived data as a kind of a preview, you might want to consider using a preview instead. Previews are not added to a document but only shown on top of a drawing. This is fast and what QCAD does to display previews while drawing and editing.
If you really need to add that data to your drawing, you might want to add it as not undoable:
This can of course break undo / redo and can have other side effects (e.g. widgets not being updated).
If your intention is to display short-lived data as a kind of a preview, you might want to consider using a preview instead. Previews are not added to a document but only shown on top of a drawing. This is fast and what QCAD does to display previews while drawing and editing.
If you really need to add that data to your drawing, you might want to add it as not undoable:
Code: Select all
var op = new RAddObjectsOperation(false);
Re: Faster way to plot objects on Document Interface
A new option has been added in the current snapshot release 3.21.3.7 to flush the transaction history (and all objects that were undone) at any point:
Call this after every operation or e.g. every 10 operations to clear the undo / redo stack and reduce the size of indices, etc.
Code: Select all
documentInterface.flushTransactions();
Re: Faster way to plot objects on Document Interface
Thank you Andrew! I changed the undoable to "false" and it already improved the plotting. Can you guide me into creating a preview ? I tried to follow this example but nothing shows up on the screen. Only difference is I am doing this from C++.
https://github.com/qcad/qcad/blob/maste ... hDialog.js
Thanks
https://github.com/qcad/qcad/blob/maste ... hDialog.js
Thanks