Finally :D

Besides helping out in scripting, I have been slow for my own job because of boredom ascribed to continuous trials but with no results. It was confusing and it had to be. I was doing the right things but at wrong places. 😛

So I kept line again aside and starting hunting the undo/redo implementation for circle and ellipse. Though logic was same but even trivial things like displaying correct information in the undo stack seemed of much significance to us. This was tricky since I was doing it all in the wrong place. But it worked finally.

Then the bulb glowed again. And I did undo/redo for line without constructor over-riding now. It involved so much less effort today. And that feeling when your commit reduces the lines of code and does the same work correctly. So finally I am done with my undo/redo task. It is over. 😀

Moving further

The day started with fixing of issue #50 out of the 4 issues I mentioned yesterday. To have a track of mouse position in the drawing area is helpful to the user. Previously, the eventfilter has been deployed on the entire eCAD window. However, it was required to be working only when mouse was in the drawing area.

Fixed the issue by installing the eventfilter on scene using
view->scene->installEventFilter(this);

And then it was time when everyone present was installing eCAD and reporting issues. Felt more responsibility towards my project. The journey has been awesome till now.

Meanwhile, we continued comprehending the solution to implemenatation of undo/redo for move command. Someone has been pointing me out to use the same logic as it has been done for point entity and I didn’t take much notice considering it to be inappropriate.

From creating a logic to push different number of arguments to the undoStack, I figured the coordinates being local to the entity created, I moved onto understanding the mapToScene() which returns a point’s value in terms of scene coordinates which is required right now. And this would saving so much of redundant efforts we have been thinking that could get involved.

Will be continuing keeping track of various issues and the features in the to do list.

Undo/Redo for deletion && updating selection

Today we implemented undo/redo for delete operation. Likewise, we proceeded with undo/redo for move operation. Successfully implemented it for point entity. Saving the file also showed the updated coordinates of point. Moving the other entities resulted in inconsistent pushing of positions to the undo stack. Since the other entities need more information to be pushed to the stack, not figured this out yet.

Another issue came by. An item if deleted from the scene got saved because the list being iterated in the writeStream() method keeps a record of all the entities that were once added to the scene. Getting surprises daily. 😉

Also the entities’ properties have been set while one or more of them is selected. The points’ color is changed when selected. A dotted pattern has been implemented showing the selection of other entities accompanied by a change in the color of the points associated with the same entity, say center point for circle, likewise for line and ellipse too.

Turning hands to Undo & Redo

Since undo/redo form a very essential part of any application, we chose to implement this after the deployment of movement and selection of items. This will avoid the chaos when proceeding with actions like cut, copy and paste. The Qt’s Undo Framework supports undo/redo for all those actions/functions that are inherited from QUndoCommand.

The previous implementation of adding any graphics item to the scene was nowhere close to this. Why had we not inherited QGraphicsItemGroup instead of QGraphicsItem before? Well, moving to this stage made us realize we need to switch to the former and made our implementation quite better and reduced redundancy of a few things too.

Each event like addition, deletion, moving will be having classes of their own where items will be added, deleted and moved respectively. The mousePressEvent dealt with the pushing of the action to the undoStack. We have done with undo/redo associated with addition event today. Will be completing the other two tomorrow.

Feels good to see Ctrl+Z and Ctrl+Shift+Z working. ^_^