@egan
Well, I re-implemented the whole mouse moving the puzzle shape thing. I am not using itemChanged() override anymore. The fact that the item's position x and y was not the same as the boundingRect().topLeft() x and y after rotating was an issue that was too problematic. A tangram shape; a right triangle with a hypotenuse that equaled the leg * the square root of 2 being contained by a bounding rectangle during rotation produced too many effects. So, I got it working, and very well, but I ended up using
void PuzzlePiece::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
QRectF rect = scene()->sceneRect();
float mx = event->scenePos().x() - xbeta;
float my = event->scenePos().y() - ybeta;
setTangramPositionAndShape();
\\ sets the boundingRect to the bounds of the actual polygon points
if(rect.contains(boundingRect()))
{
setPos(mx, my);
setTangramPositionAndShape();
}
}
And yes, the shape stops moving when it goes out of the scene, but a mouseDown sets it position back inside the scene and all is good.
I made a tangram puzzle application way back when I was a young man. I used Cocoa/Objective C on a Mac. The thing was downloaded over 8 million times in a week. People from Japan would call me up and ask me about it. It was crazy. And yeah, it was free, so I am not a millionaire; my wife yelled at me for weeks for making it free. It was this small window about the size of an smart phone screen.
Cocoa does not have a simple implementation to make an graphic item movable with some easy setFlag(QGraphicsItem::ItemIsMovable). It was much more difficult to implement back then. So, I am basically using the same bounds checking and resetting the object the same way as I did 25 years ago.
My son is about to go to college for software engineering. I am teaching C++ with the implementation of this simple puzzle.
Thanks for your help. Your posts kept me thinking!
Craig