I have attempted to add a exclude selection for Krita, and while it does compile nicely and smoothly, there is a issue where Krita crash from the very beginning. Everything seem to check out.
The idea is just to finish the basic selection of Krita
dkazakov |
Krita |
I have attempted to add a exclude selection for Krita, and while it does compile nicely and smoothly, there is a issue where Krita crash from the very beginning. Everything seem to check out.
The idea is just to finish the basic selection of Krita
Lint Skipped |
Unit Tests Skipped |
Here's the crash trace. Alternative crash log is provided too in case the other isn't useful. Segmentation fault.
Using what's below
if (m_d->outlineCacheValid) { m_d->outlineCache |= selection->outlineCache();
instead of
if (m_d->outlineCacheValid) { m_d->outlineCache -= selection->outlineCache();
wouldn't fix it.
-
Actually, never mind, it turns out that I may just need to only do the GUI part to fix the crash issue, and see what to do from there. Hopefully, it won't crash by then.
I have added more lines related to GUI to attempt to resolve the crash. However, a new problem occured. 4 lines of this error happens:
‘class WdgSelectionOptions’ has no member named ‘exclude’
Hi, @Reptorian!
The error happens because you need to add actual buttons to the .ui file that defines WdgSelectionOptions class, that is to 'libs/ui/forms/wdgselectionoptions.ui'. Just open it in QtCreator, copy-paste an existing button and rename it into 'exclude'.
Could you also a bit elaborate what is the difference between "exclude" mode and "subtract" mode? I look at the formula and they look exactly the same...
Updated for current master. Now that I was able to test the result of the code, it turns out that the patch works partly. This patch forces every selection to be exclude selection, so that's something I don't where to start to look into. Krita no longer crashes.
The proof that it partly works -
I have added a note to the commits here. Please see note to see current issue to be resolved before fixing the other bug. It's particularly a hard to fix issue.
Also, the other issue is that while mapping can resolve the forced to exclude mode only, it appears that it eliminates the option of being able to exclude unless you use keyboard shortcut.
libs/image/kis_pixel_selection.cpp | ||
---|---|---|
280 | It seems that no matter the operator used here, the ants just doesn't show up in some area, or the ants just doesn't show up at all. |
Changed keyboard shortcut for maximizing productivity only. With keyboard shortcut, and global mask selection, you can preview how selections works altogether.
Here's a video to demonstrate - https://streamable.com/7e22h
We're getting somewhere! The tooltip for the exclusion button needs to be changed, though, since it now also says "subtract".
Only thing fixed is what Boud mentioned. I'm still having trouble fixing the issue that the button only activates subtract selection, but not exclude. A lot of lines were changed in search for an answer to that.
EDIT: In light of reddit post, name has to be looked into - https://www.reddit.com/r/krita/comments/9b4yj8/unofficial_new_minifeature_development_exclude/
"Cool. So is "exclude" another name for XOR? I found "exclude" a bit confusing, myself; just sounded like it would subtract as normal." - wthit56
"I second this. I know XOR is called "exclusive or", but in that case I feel it need to be mentioned what exactly is excluded from the result. "Symmetric difference", "Disjunctive union" or "Exclusive or (XOR)" would be better, or maybe it could be better to find artists who doesn't know Math as well as we and can name it even better (easier for other artists to grab)." - tiar
Now, the button activates exclude selection tool thanks to boud. After I get the ants working, naming convention will be addressed by myself.
EDIT: There's a regression that need to be addressed. If I select, nothing shows up on layers. Also, there is a issue with ants at the moment. Did so many attempts that I do not believe that changing line 287 at kis_pixel_selection.cpp would change anything.
I believe I may have bad news. This requires coding beyond Krita. QTGui:QPainterPath and QtGui:Qrect are the source of the issue.
Updated to current master.
Fixed ant selection issue. There's still a few bug to be solved. Confident that it can be done.
I have fixed the button issue. One blocker bug remains. It doesn't work for pixel selection, but it works very well for vector selection. I have no idea if Dmitry changes to Krita has to do anything with that or if it my fault that I somehow broke it. Dmitry has been notified shortly after this post.
I have enabled the button to work. It actually does something.
One blocker bug remaining : The pixel ant selection. I have tried so many different lines, and it still gives wrong result. Vector selection ant selection works fine and dandy though. That it does.
Hi, @Reptorian!
Here is a patch that fixes pixel selection in your patch. Basically, when processing a pixel selection you forgot to write the result somewhere.
In this patch, I have fixed the ant selection issue to the point where it's apparent that there has been a selection made with symmetric difference selection. I will have to look at Dmitry patch again to see if it fixes the absence of anti-aliased line, but I did observe a error somewhere during a compilation even though it works (could be false error as it works while the ant selection ant is still wrong with the patch from what I seen). When I do a circle with symmetric selection issue, and overlay it with another circle, I get two overlapping circle with visible selection lines on the middle which is the expected behavior. Not expected was that the lines gets pixelated.
Hi, @Reptorian!
The patch works kind of fine. Although it has a few blockers codewise. The main one is that the keyboard modifiers have changed. We need to know painters' opinion on that. The other comments are easily fixable.
libs/image/kis_pixel_selection.cpp | ||
---|---|---|
269 | This check is incorrect because both values are quint8, which is unsigned it, therefore the condition is always true, unless *dst... == *src... | |
280 | This line looks weird. Did you mean m_d->outlineCache? | |
libs/ui/tool/kis_selection_tool_helper.cpp | ||
272 | Is it correct that INTERSECT is not a part of the condition anymore? | |
plugins/tools/selectiontools/kis_selection_modifier_mapper.cc | ||
95 | Did you consult with the painters before changing modifiers? |
Okay, I talked to @woltherav and I think we both agree that the old keyboard modifiers should not be changed. So please revert this part of the patch.
All the comments have been addressed, and thanks to one of the comment, one of the bug I just found during testing have been solved. Also, I had to make up a keyboard modifier for this patch as otherwise, you'd always be stuck on symmetric difference selection mode unless you use a keyboard shortcut. I chose cntrl+alt as a temporary keyboard shortcut.
By the way, the weird line was the only line I saw that made that selection ants works as expected (barring absence of vector in pixel selection).
Erased one line in pixelselection cpp file. Didn't noticed that on the last update. Now it looks good.
I found something that may hint to the solution to the selection
There's this line
// parent selection is not supposed to be shared
If parent selection can be shared, then you would be able to shared selection outlines which is how the outline should look like when selected. But, I have no idea how to get around that issue. So, I have to say I cannot continue with this patch at all.
Applied changes accordingly to Sven Langkamp instruction. It solved the blocky outline issue! Now, symmetric difference pixel selection behaves similar to the other selection modes.
Now the only thing that left to be done are shortcuts, and add the option layer-based selection which Dmitry has added.