Snap to Grid

I’ve implemented Snap-to-Grid feature in eCAD today. It was quite easy, just had to round off the mouse position in the scene to the grid points.

So I created a new function to calculate the round off and set a temporary point in the eventFilter() so that it will calculate according to the grid size.

And this temporary point has been used wherever the mouse’s scene position has been used.

Now I’m going to implement dimensioning.

Mouse Axes Disappeared

I observed one little issue, that mouse axes disappeared when we are zoomed in. So on my code walkthrough I saw that the QGraphicsColorizeEffect significantly lowers the performance of QGraphicsView, in short the whole eCAD.

And when I removed that effect the performance shoot up as well as the axes appeared.

So this color of axes must be set in some different manner and for now this issue has been resolved.

Now i’m working on Snap-to-Grid feature that eCAD lacks.

Solving issues back to back

We have been solving eCAD issues back to back. I’ve also added mouse-axes preview while drawing entities which is quite useful for a user working in a CAD environment.

Once again I used eventFilter function to draw those axes preview. And I had to use QGraphicsEffect on them to give a different effect to them.

Solved three issues as well.

  1. Corrected the Menu Check for both script and console widgets
  2. Fixed the issue of grid option for respective view
  3. Changed Origin from qgraphicsitem to a background item.


New Bugs

Every time I work in eCAD, it seems I find one or another bug. Maybe that’s because I’m always on the lookout for something to improve in it.

From last 2 days Kamalpreet and I have been working on correcting the coordinates of our CAD. It has the coordinates as ‘computer graphics’ with origin at the top left of the screen. But we usually work in a CAD software with more ‘drawing’ or ‘graph’ like sense with origin at the bottom left of the screen.

And today we solved it. We had to scale the scene by flipping the y-axis and then two of our entities, i.e Text and Image, had to be flipped as well.

I also solved an issue of empty text items saved in the scene.

Solving Bugs

We are now solving bugs and issues. After helping Kamalpreet in correcting the bounding rect() of ellipse entity, I have fixed the issue of line weight.

Earlier the width/weight of the entities drawn on scene changed as we zoom in/out of the scene.

Now it remains consistent, which is a pretty useful to get an overview of the drawings in CAD.

I’ve also implemented ‘Delete Entity’ feature which lets the user click on the entity to delete it.

Live Preview

At last we have successfully implemented live preview of the entities in eCAD. Kamalpreet and I have looked in this issue on and off since we started this project.

And today we did it. We tried to administer several different logic potions to our patient to get a live preview of an entity. We have searched a lot, asked as well on forums but never got the solution we wanted.

And that solution was gawking right at our faces and we never took notice. Sometimes things are way more simple than we reckon they are.

Now our eCAD looks more lively. 🙂

Another one down

Today Kamalpreet and I solved another older issue we had in eCAD regarding selection of entities.

Earlier if there were multiple entities overlapping each other, user can’t select the entity beneath the other one because the bounding rectangle was obscuring the other.

And now by overloading the shape function we have been to adjust the bounding rectangle of the entity and now only the boundary of the entities are selectable.

This has been implemented for circle and line entities. Arc and ellipse will also be done in a day or so, just need to figure out a way to adjust their shape as well.

Oldest Bug

Today we have been successful in solving the oldest bug of eCAD. This bug was about the MDI implementation. If multiple documents have been created in eCAD, you can only work on the latest one. All the previous documents were unresponsive.

So we used a signal that is emitted whenever MDI subWindow is changed or created.

And we connected this slot to a function that then updates the pointer of the graphicsview to the corresponding subWindow.

This solves the issue and every document can be accessed now.

Now we can solve other issues related to this as well like respective menu items and shortcut keys.

Names of Documents corrected

Today I corrected the implementation of the titles of the documents created or loaded.

When the new document is created the file get the name of “Document i” where i could be 1,2,3…. and so on.

And when a file is opened, its saved name is displayed as the title.

I’ve also corrected the Cancel button bug, i.e even if the user clicks cancel on any file dialog the rest of the function was still getting executed. So implemented an exception to that.

While writing this post I’ve got another idea to further improve the issue I solved today. Going to work on that as well.