Hatch issues

Discussions about the development of the TechDraw workbench
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Hatch issues

Post by uwestoehr »

I created a dialog for the hatch feature: https://github.com/FreeCAD/FreeCAD/pull/3604

While doing this, I encountered 2 hatch issues (that are independent of the dialog) and don't know what to do:

1. then selecting a hatch in the tree and then going to the Data tab, you see the setting "Dir Projection". One cannot set or change anything. so what is it meant for?

2. For few of the available SVG hatch files, the set color is not applied. Select for example a hatch in the tree, then change in the tab "View" the color to e.g. red. This should color your hatch red. But now go to the tab "Data" and change the "Hatch Pattern" to e.g. "aluminium.svg".
Result: this patter is not red but grey.
It is not clear to me what causes this, since e.g. "steel.svg" can be colored while "general_steel.svg" cannot be colored.
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: Hatch issues

Post by vocx »

uwestoehr wrote: Fri Jun 12, 2020 1:16 am ...
1. then selecting a hatch in the tree and then going to the Data tab, you see the setting "Dir Projection". One cannot set or change anything. so what is it meant for?
...
Maybe this is inherited from its parent class and doesn't do much.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: Hatch issues

Post by uwestoehr »

Besides the issues, there is a bug:

- select a hatch in the tree and press DEL

result: the hatch is deleted, but still shown in the drawing. The document is not recomputed nor marked to e recomputed.
For GeomHatch, it is fine.

I had now a look to find what GeomHatch does on deleting but cannot find the according code.
User avatar
wandererfan
Veteran
Posts: 6326
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Hatch issues

Post by wandererfan »

uwestoehr wrote: Fri Jun 12, 2020 1:16 am 1. then selecting a hatch in the tree and then going to the Data tab, you see the setting "Dir Projection". One cannot set or change anything. so what is it meant for?
The property is the Direction of the base object at the time the hatch was created. If I remember correctly it was used to invalidate the hatch if the base direction didn't match the hatch direction. The face drawing code has changed quite a bit since then, and DirProjection is no longer relevant.

Should be hidden, maybe even deleted. Or we should have a setting for properties along the lines of "App::Prop_Programmer" that would be "App::Prop_None" in debug versions and "App::Prop_Hidden" in release builds. :)
It is not clear to me what causes this, since e.g. "steel.svg" can be colored while "general_steel.svg" cannot be colored.
In "simple.svg", the color is specified in a style attribute as stroke:#000000;, which is what the program is expecting.

In "aluminium.svg", the color is specified without a style attribute as stroke="#000000", which is not what the program is expecting.

So we either change the svg files to use a consistent specification for stroke colour, or we modify QGIFace.cpp to handle multiple forms of colour spec.

Since I don't know how many different ways there are to specify colour in an Svg file, my vote would be to make the Svg patterns consistent so the code only has to deal with one form.
User avatar
wandererfan
Veteran
Posts: 6326
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Hatch issues

Post by wandererfan »

uwestoehr wrote: Fri Jun 12, 2020 12:43 pm I had now a look to find what GeomHatch does on deleting but cannot find the according code.
unsetupObject looks like it is trying to handle this, but I think that is the wrong place. The hatch object still exists at this point so repainting will still include the hatch.

The unsetupObject code is the same for both hatch types, so I'm not sure why they behave differently.
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: Hatch issues

Post by uwestoehr »

wandererfan wrote: Fri Jun 12, 2020 1:19 pm The face drawing code has changed quite a bit since then, and DirProjection is no longer relevant.
so I will delete it. I am not a fan of keeping things and hiding them. Old stuff should go since this only costs time, in this case for example for me, just to understand it is no longer relevant.

In "simple.svg", the color is specified in a style attribute as stroke:#000000;, which is what the program is expecting.
In "aluminium.svg", the color is specified without a style attribute as stroke="#000000", which is not what the program is expecting.

So we either change the svg files to use a consistent specification for stroke colour, or we modify QGIFace.cpp to handle multiple forms of colour spec.

Since I don't know how many different ways there are to specify colour in an Svg file, my vote would be to make the Svg patterns consistent so the code only has to deal with one form.
I would go the other way and change QGIFace.cpp because I had a look and there are 2 allowed ways in the specification:
- either put everything in the style="" property as done in simple.svg
- or declare it separately as stroke-width="", stroke="" etc.
So this is like with HTML.

Therefore QGIFace.cpp should be able to handle both. I mean we can now easily change our SVGs but users might take their own and then wonder why the color is not applied.
User avatar
wandererfan
Veteran
Posts: 6326
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Hatch issues

Post by wandererfan »

uwestoehr wrote: Fri Jun 12, 2020 1:48 pm I would go the other way and change QGIFace.cpp ...
Another overrun on the maintenance budget! :lol:

Are you doing the change to QGIFace? If not, I'm happy to do it.

I have the fix for updating the face after a hatch is removed. It will go in my next PR.
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: Hatch issues

Post by uwestoehr »

wandererfan wrote: Fri Jun 12, 2020 7:45 pm Are you doing the change to QGIFace? If not, I'm happy to do it.
Please go on. I already had a look and one needs to implement a method that reads from the SVG what definition style is actually used. I am not that familiar with this, so I will learn from you you do this.

I have the fix for updating the face after a hatch is removed. It will go in my next PR.
Thanks!
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: Hatch issues

Post by uwestoehr »

uwestoehr wrote: Fri Jun 12, 2020 11:53 pm Please go on.
I could not resist and it turned out to be quite simple: https://github.com/FreeCAD/FreeCAD/pull/3608
(and I learned a new Qt class I never used before 8-) )
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: Hatch issues

Post by uwestoehr »

uwestoehr wrote: Fri Jun 12, 2020 1:48 pm
wandererfan wrote: Fri Jun 12, 2020 1:19 pm The face drawing code has changed quite a bit since then, and DirProjection is no longer relevant.
so I will delete it...
Here it is: https://github.com/FreeCAD/FreeCAD/pull/3609
I tested it with some of my real-life files and it makes no problem.
I hope there are no side-effects because of the deletion.
Post Reply