Page 1 of 1

How to delete original entity after moving in c++

Posted: Wed Mar 06, 2019 3:20 pm
by ezm
Hi,

I am trying to create and entity and move it using moveReferencePoint funtion. The entity moves but i see the original one as well. How do we delete or keep copies =1 using c++ ?

QSharedPointer<RCircleEntity> myCircle;

void function1()
{
myCircle = QSharedPointer<RCircleEntity>(new RCircleEntity(document, RCircleData(centre, radius)));
RAddObjectOperation op = new RAddObjectOperation(myCircle, false);
documentInterface->applyOperation(op);
}

void function2()
{
myCircle.moveReferencePoint(centre, targetCentre);
RModifyObjectOperation op = new RModifyObjectOperation(myCircle, false);
documentInterface->applyOperation(op); ---> This moves the circle to new centre but I can also see the original circle.
}

Please let me know how to delete the previous circle.
I am using QCAD version : 3.20.1.5
Thanks,
EZM

Re: How to delete original entity after moving in c++

Posted: Mon Mar 11, 2019 4:20 pm
by ezm
Hi,

Is there any solution/update regarding the above issue.

Thanks,
ezm

Re: How to delete original entity after moving in c++

Posted: Mon Mar 11, 2019 5:35 pm
by andrew
Adding an object to an operation twice adds two objects. Note that myCircle is just an object under your control. When adding it to the document a new object is created under the control of the document. You'd have to store the ID after adding the object and then query the object from the document, change it, re-add it for the document to know it's the same object.

Re: How to delete original entity after moving in c++

Posted: Wed Mar 27, 2019 4:06 pm
by ezm
Thanks Andrew!

Re: How to delete original entity after moving in c++

Posted: Sat Mar 30, 2019 12:57 pm
by Vannote
Hi Andrew, what do you do if the document returns that it's not the same object but it should be? How do you correct this?

Re: How to delete original entity after moving in c++

Posted: Mon Apr 01, 2019 10:23 am
by andrew
Vannote: please provide more information / context.