Week 11 - Creating a base for Freehand Drawing
ganimtron_10
Published: 09/06/2022
What did you do this week?
This week I tried to imitate the working of vtkImageTracer. Previously, I had created a small prototype for freehand drawing by adding points at the mouse position (which you can check out here). As mentioned, there were some drawback of this method.
So to overcome these issues, I tried combining both methods. Considering points using the previous method and instead of adding points I tried creating lines between them which looks promising. Below you can see a demo.
Freehand Drawing:

While doing this, I started working on how I could efficiently draw the lines and smoothen them out. My mentors referred me this to learn more about constructing and rendering lines.
Along with this, I updated a few tests and some small bugs in PR #623 and #653.
Did you get stuck anywhere?
No, I didn't get stuck anywhere.
What is coming up next?
Enhancing the freehand drawing feature.
View Blog Post
Week 10 - Understanding Codes and Playing with Animation
ganimtron_10
Published: 08/29/2022
What did you do this week?
I started working on the PR #645 created last week and tested a few more corner cases such as What happens if the maximum value is exceeded?? What if we give a value less than the minimum value range??
Most of these worked as intended.
Then I moved on to vtkImageTracer, I tried implementing this locally. It required an ImageSource on which the tracing was done. As you can see below, I managed to implement the pure VTK version of the widget. After this, I tried integrating this with FURY and besides the ImageSource all things were successfully handled by FURY.

As per the suggestions from the mentors, I started looking at the implementation of the vtkImageTracer to see how they manage the widget. My prior experience with C++ helped me a lot with this because the original implementation of vtk is in C++.
Here, I found an approach similar to the polyline. They first grab the current point, check whether it's inside the area, and then use the last point to draw a line by calculating some kind of motion vector.
Using the Animation Architecture created by Mohamed, I created a Bouncing Text Animation using UI elements to check the compatibility of the UI System with the Animation.
Bouncing text animation:

Did you get stuck anywhere?
Proper tutorials weren't there to implement vtkImageTracer, which took time to make it work locally.
What is coming up next?
Working on the Freehand Drawing.
View Blog Post
Week 9 - Grouping and Transforming Shapes
ganimtron_10
Published: 08/18/2022
What did you do this week?
I started this week by creating a quick PR #645 for the UI sliders. The sliders raised ZeroDivsionError when the min and max values were the same. To solve this, I handled the case where the value_range becomes zero and then manually set the handle position to zero.
Then I updated the implementation of the Grouping Shapes feature to support the translation and rotation of the shapes grouped together, as you can see below.

After this, I worked on the PolyLine and removed the extra point being added to the start of the PolyLine whenever a new instance was created.

Did you get stuck anywhere?
No, everything went well.
What is coming up next?
Completing the PR #623 and #653.
Searching different approaches for implementing the freehand drawing.
View Blog Post
Week 8 - Working on the polyline feature
ganimtron_10
Published: 08/18/2022
What did you do this week?
This week I started working on the polyline feature. After a lot of investigating and trying out different things, I found a way to call the dragging event manually without any prior click event. VTK actually captures the mouse movement using the MouseMoveEvent. This event is then modified by FURY to only be called after the click event. So I added a new callback to track the mouse movement and set the current canvas as an active prop because it is required to capture the drag event happening on it.

I had to look for some ways by which we could make the icons look smoother. For this, I created an icon test file, which consisted of a set of icons of varying scales. Then on these icons, I used some vtkTexture methods discussed in the meeting, such as `MipmapOn and InterpolateOn. You can see some differences in the icons below:

Did you get stuck anywhere?
It took some time to get settled with all the things as my college reopened.
I was trying to use shaders with the UI elements to implement the freehand drawing, but then my mentors suggested that I should look into the tracer widget in the VTK.
What is coming up next?
Updating PR #623 to keep rotation_slider on the top of the screen.
Looking into various vtk tracer widgets to see if we can use that to create freehand drawings.
View Blog Post
Week 7 - Working on Rotation PR and Trying Freehand Drawing
ganimtron_10
Published: 08/03/2022
What did you do this week?
I continued PR #623 and fixed the displacement of the shape from its original position when applying rotation. This was happening because most of the calculations resulted in float values, but as the pixel position were integers we had to explicitly convert these values into int. This conversion rounded off the values and as we call this function continuously, each time the round-off would happen, the shape would get displaced.

To fix this, I converted all the calculations into integer calculations using floor division "//" instead of normal division "/".

The tests were failing in Ubuntu and the macOS because the mouse click event wasn't propagated to the line due to some unknown reasons. When investigating more about the issue, Mohamed suggested and helped me implement another approach to select the shapes. In this approach, we calculate the distance between the mouse click event position and each of the shapes, and if any of the distances is less than a specific value (which I call as limit value), then we send this current event to that element.
New shape selection technique:

I also tried to implement a freehand drawing mode by adding Disk2D as points. But as you can see below, there are many flaws in this.
- First of all, we add many Disk2D objects which make it memory consuming process.
- If the mouse moves very fast, then we can see the gaps between points.
- Storing, managing, and transforming are difficult.

Did you get stuck anywhere?
It was hard to debug why the tests were failing in Ubuntu and macOS. I tried investigating it by installing Ubuntu and got nothing, but then while implementing the new selection approach, it automatically got fixed.
What is coming up next?
Getting PR #623 merged and working on the polyline feature.
View Blog Post