Yeah it involved struggle

Implementing move command only for line was not easy, albeit it has a glitch still but most of the important necessary things have been done.

The issues I faced include:

  1. setPos() function just with a single parameter viz. the scene position did all well. Undo redo had no issue. Though on undo, it quickly jumped to the very first position when it was initially added into the drawing area, which is quite not acceptable.
  2. The undo stack showed the changed position of the line in terms of its local coordinates. Well, we never wanted too. The scene position, preferably, should be shown in the undo stack for convenience.
  3. If the line is displaced from its original position and subsequently the file is saved, again we saw there were the coordinates of the very initial position when it was created in scene in first place.

The first still doesn’t make sense to me yet since a similar implementation in redo is working decently. For obtaining appropriate information for move operation on line, I followed constructor over-riding. The way the things were pushed on to the stack had also to be modified. Constructor over-riding did it in combination with a li’l hacks I had to do at a few places in order to obtain the desired results.

Similarly, saving the correct coordinates for line after is moved also was deployed with a li’l trick. Adding the current scene position to the original local position gave fruitful results while saving the file. The correct implementation for circle and ellipse is under development. 😀