Hatch issues
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Hatch issues
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.
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.
Re: Hatch issues
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.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
Re: Hatch issues
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.
- 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.
- wandererfan
- Veteran
- Posts: 6326
- Joined: Tue Nov 06, 2012 5:42 pm
- Contact:
Re: Hatch issues
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.
In "simple.svg", the color is specified in a style attribute as stroke:#000000;, which is what the program is expecting.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 "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.
- wandererfan
- Veteran
- Posts: 6326
- Joined: Tue Nov 06, 2012 5:42 pm
- Contact:
Re: Hatch issues
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.
Re: Hatch issues
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.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.
I would go the other way and change QGIFace.cpp because I had a look and there are 2 allowed ways in the specification: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.
- 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.
- wandererfan
- Veteran
- Posts: 6326
- Joined: Tue Nov 06, 2012 5:42 pm
- Contact:
Re: Hatch issues
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.wandererfan wrote: ↑Fri Jun 12, 2020 7:45 pm Are you doing the change to QGIFace? If not, I'm happy to do it.
Thanks!I have the fix for updating the face after a hatch is removed. It will go in my next PR.
Re: Hatch issues
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 )
Re: Hatch issues
Here it is: https://github.com/FreeCAD/FreeCAD/pull/3609uwestoehr wrote: ↑Fri Jun 12, 2020 1:48 pmso I will delete it...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.
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.