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
Set colors doesn't work on objects that have edit mode reimplemented #5611
Comments
@0penBrain any idea how to tackle this? (given your work on user edit mode) |
Thinking about this further a good solution could be to do the same as with "display modes" of the view providers. So, there can be a virtual function getEditModes() that returns a list of strings and these strings are saved with the QAction instances when creating the context-menu. setEdit() must be changed where the second parameter that currently is an int will be replaced with a string. This avoids the difficulties with int's as described in the older posts above and a string automatically is a speaking name and thus easier to memorize when used in scripts. |
Related to #5546 |
Thanks @Roy-043! what's left to do in this ticket then ? |
IMO this ticket can be closed. I'll go ahead and do that next. If any of the other participants disagrees they can reopen it. |
Issue imported from https://tracker.freecad.org/view.php?id=1954
Original report text
It seem that Set colors is not working on objects that have their edit mode reimlemented (Arch, Draft, etc)
Additional information
Steps to reproduce
Create an Arch Object (Wall, Structure...)
Right clic on it in the tree view
Clic on set colors
Instead of having the task panel to change colors per faces the component task widget is open.
Other bug information
Discussion from Mantis ticket
Comment by jmaustpc 2016-01-20 14:00
In current master from today, "Set colours..."
works for Draft Clone
does not for Draft Array which give the error message "this object is not editable"
Sets an Arch wall into task "Components of this object" and so does Arch Structure and Arch stairs.
Building does not have "set colours" in its context menu at all.
Comment by @yorikvanhavre 2016-01-31 18:15
I had a better look at this now, the "set colors" dialog uses the different edit modes system (
setEdit()
can receive a number, allowing the object to have several different edit modes.This is defined in
Mod/Part/ViewProviderExt.cpp
L694However, although that system works in python too (setEdit can receive a number), there is apparently no system to fall back to the C++ setEdit if the python setEdit returns False. (Gui/ViewProviderPythonFeature.cpp L415). If the python setEdit exists, the C++ setEdit is never called, no matter the returned value, unless I'm wrong...
I thought about mimicking the ViewProviderExt above (adding a "
return Gui::ViewProviderDocumentObject::setEdit(ModNum);
" if the python setEdit returns False) but it's apparently not the right way to do.I'll investigate further
Comment by @luzpaz 2017-01-17 20:01
Forum thread: http://forum.freecadweb.org/viewtopic.php?f=10&t=19989
Comment by wmayer 2017-01-19 13:04
At the moment the whole "edit modes" framework is broken by design. When setting up an edit mode for a view provider then two methods are involved:
setupContextMenu
where aQAction
can be added to aQMenu
setEdit(int)
where an int of the actual edit mode is passedThe difficulty is that inside
setupContextMenu
a unique integer should be set to theQAction
which is still unique when a method invokes the same method of the parent class. And insidesetEdit
a view provider must know the edit mode numbers it must handle.With the current implementation when a sub-class wants to handle the edit modes of the base class it must know its implementation.
When thinking about it I guess it would work if
setupContextMenu
returns an int which is the number of edit modes it handles. Then the sub-class would know from which value to start with.setEdit
should then also return an int and depending on its value a sub-class knows if the base class handled it already.Example (in pseudo code):
The only important point is that a programmer has to take care to use the correct values in
setEdit
to be consistent withsetupContextMenu
. But he doesn't have to know about the implementation of the base class any more.Comment by Kunda1 2017-10-02 04:42
Related to #5546
The text was updated successfully, but these errors were encountered: