How to delete original entity after moving in c++

Use this forum to ask questions about how to do things in QCAD.

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files and screenshots.

Post one question per topic.

Post Reply
ezm
Newbie Member
Posts: 8
Joined: Wed Nov 14, 2018 6:30 pm

How to delete original entity after moving in c++

Post by ezm » Wed Mar 06, 2019 3:20 pm

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

ezm
Newbie Member
Posts: 8
Joined: Wed Nov 14, 2018 6:30 pm

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

Post by ezm » Mon Mar 11, 2019 4:20 pm

Hi,

Is there any solution/update regarding the above issue.

Thanks,
ezm

User avatar
andrew
Site Admin
Posts: 9037
Joined: Fri Mar 30, 2007 6:07 am

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

Post by andrew » Mon Mar 11, 2019 5:35 pm

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.

ezm
Newbie Member
Posts: 8
Joined: Wed Nov 14, 2018 6:30 pm

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

Post by ezm » Wed Mar 27, 2019 4:06 pm

Thanks Andrew!

User avatar
andrew
Site Admin
Posts: 9037
Joined: Fri Mar 30, 2007 6:07 am

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

Post by andrew » Mon Apr 01, 2019 10:23 am

Vannote: please provide more information / context.

Post Reply

Return to “QCAD 'How Do I' Questions”