
Sun, 12/29/2024 - 10:57
Forums:
No doubt, this is probably a simple one (again)...
I'm trying to move some shapes on screen, following instruction from the mouse pointer.
Tried a couple of different methods, but they all end up with the Translation being scaled way bigger than the actual mouse movement - for a small mouse movement, the shape flies off at around 10:1 ratio from the mouse vector, rather than tracking it.
gp_Trsf move; myView->Convert(old_x, old_y, mouseStart.x, mouseStart.y, nullz); myView->Convert(new_x, new_y, mouseEnd.x, mouseEnd.y, nullz); move.SetTranslation(gp_Pnt(mouseStart.x, mouseStart.y, 0), gp_Pnt(mouseEnd.x, mouseEnd.y, 0)); //also tried a direct transformation using... // move.SetValues (1, 0, 0, (mouseStart.x - mouseEnd.x), // 0, 1, 0, (mouseStart.y - mouseEnd.y), // 0, 0, 1, 0); TopLoc_Location loc(move); myContext->SetLocation(selectedShape, loc);
I've tried scaling this by myView->Scale() but its not effective. Obviously missing a scaling factor somewhere, anyone any ideas?
Mat