how can i get mouse position in a image

Discussion forum for contributors and developers who are using the QCAD ECMAScript development platform or the C++ plugin interface or who are otherwise looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

Post Reply
liguosheng
Active Member
Posts: 33
Joined: Thu Jan 14, 2016 4:17 am

how can i get mouse position in a image

Post by liguosheng » Sun Jul 30, 2017 9:39 am

when a image is loaded,like that:
image = new RImageEntity(doc, RImageData(strImageFile, RVector(0,0),RVector(1,0), RVector(0,1), 50, 50, 0));
image->setInsertionPoint(drawSect->ptDemInsert);
double pWid = image->getPixelWidth() * xRes;
double pHei = image->getPixelHeight() * xRes;
image->setWidth(pWid);
image->setHeight(pHei);
image->setAngle(0);

when a mouse position is got, how can i get postion in the image?

xRes,yRes are pixel resolution

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

Re: how can i get mouse position in a image

Post by andrew » Tue Aug 08, 2017 11:34 am

You'd have to calculate it using the image position, angle and width / height. There is no function to translate coordinates to image coordinates and vice versa.

Post Reply

Return to “QCAD Developers and Contributors”