-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Help Wanted: Testing the Hit-Test feature #148
Comments
I am currently playing around with this feature. Unfortunately I'm having a little difficulty getting it to work with the SVGs that I have been given. The paths and rectangles in this document are grouped into a layer which has a transform. This seems to be causing the bounds check to fail in HitTestDrawing() in WpfDrawingDocument.cs. He comes to the line: if (group.Bounds.Contains(pt)) and leaves. There maybe also a problem with transparent objects. I need to investigate further as far as this goes but he doesn't seem to like some of the styles that are used. I will also keep digging but im not sure if I will discover the problem. I'm attaching one of the SVGs incase it is something of interest. `` |
@KarlAbson Thanks for the feedback, I will investigate with the attached file to improve this feature. |
@paulushub I had some success in fixing this. It appears that there are two problems. The first problem can be easily fixed by not using the transform. The second of the transparency is not so easy. It would be nice to be able to use this. Do you have an idea as to why transparency would cause a problem? Many thanks, |
@KarlAbson Thanks for the updates. I cannot tell why the transparency will have effect, I will look into it. The transformation and maybe clipping are the main problems I thought I needed to resolve to this to work well. The WPF documentation does not help with this "low-level" issues and I have not found any sample addressing this issue. |
@paulushub I found a solution for the transparency issue. In HitTestDrawing(DrawingGroup group, Point pt, out Drawing hitDrawing) in WpfDrawingDocument.cs, I'm not sure if it's being put into a group with another node due to the transparency. As far as the other problem goes, I simply won't use the transformations / groupings. |
@KarlAbson By my tests, the hit-test for your drawing is working as expected! Or if you can come with some other options, I will look into it. |
@paulushub Thanks for looking into this. Yes I also worked this out after further investigation. As I mentioned in my comment on Friday, the hit test works. He finds the hit object but it's the calls to SvgObject.GetUniqueId() / SvgObject.GetId(drawing) that needed changing. When you click on the slightly transparent objects you need to pass the group rather than the drawing. If you pass the drawing these methods return null when transparency is used. |
@KarlAbson Trying to create a new Nuget package today, I will get back to this issue. |
Hallo there, I finally found time to come back to this. I'm attaching a modified version of WpfDrawingDocument.cs which solves the problems. I'm not an expert however with this code so I hope that this does not cause any other problems. The method WpfDrawingDocument.HitTest(Point) originally returned IsHit as false and SelectedItem as null with the test SVG that we have. I believe that this is due to the groups and the particular styles used. With the following changes this is resolved. Here is a quick overview of the changes made:
Now the HitTest method returns the WpfHitTestResult with the selectedElement and IsHit as true where as before they were null and false respectively.
|
@KarlAbson Thanks for the updates. The hit-test code has evolved a bit, which makes it different from yours. I am trying to see how to incorporate your codes, but I could not get it working with the image file you posted. |
@paulushub True! I forgot that I also altered the SVG in illustrator to remove the main grouping. |
@paulushub How do we build the solution? I keep getting the following error:
|
@amine-aboufirass I will check and get back to you - for sometime now, I have not tested this sample. |
@amine-aboufirass Are you trying the WpfTestOtherSvg sample? The sample for this thread is name WpfTestSvgControl |
I tried |
Please provide more information. |
Hi @paulushub , I am using Drawing Page to load the SVG , I have written a code to draw a rectangle inside the Drawing Page
But unfortunately I was not able to get the elements using the Regards |
With the updates (d0e6dc2), the current hit testing issue with transformed geometry is fixed.
However, more tests are needed to verify this feature and your help is needed.
The hit test feature is implemented in the
WpfDrawingDocument
class and will be the basis of interactivity support in the controls;SvgCanvas
andSvgViewbox
.A sample application
WpfTestSvgControl
is available for testing this important feature.How to help?
WpfTestSvgControl
and use it to open SVG files.The text was updated successfully, but these errors were encountered: