Faster way to plot objects on Document Interface
Posted: Wed Nov 14, 2018 7:30 pm
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
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