Since BOARD_COMMIT was a requested item to be added to the Python interface, since it's related to be previous questions about getting a redraw on the GAL canvas, and since it could make a good entry to my kicad python tutorials, I have some questions.
My questions will be mostly in the form of summarizing what I think I see in the code and hoping that someone will correct my summary as well as the actual questions I have. I can then try to add the needed SWIG stuff in a sane way. Is there a document the explains Board commit? An email thread about it perhaps? It seems to me that the broad purpose of BOARD_COMMIT (I'll call it BC) is to handle the details for undo. When changing a wire,module,pad,... you tell BC what you're doing. Undo then magically happens. Another side effect is that the canvas is redrawn when needed. If the above summary is wrong, then my coming questions will likely not make sense. I haven't actually tried to use BC 1) There will be cases when a utility/command developer doesn't care about undo. They just want to make their changes and if the result is not desired, just revert. This would be particularly true for automated, final processing. One that comes to mind is a teardrop generator <https://forum.kicad.info/t/yet-another-python-teardrop-script-adds-and-deletes-teardrops-to-a-pcb-v0-3-3/3388> *Will BC update still work if you don't tell it about any changes?* I ask because BC was given as a better way to redraw the canvas Following up on Maciej's comments <https://lists.launchpad.net/kicad-developers/msg31925.html> I tried calling KIGFX::VIEW::Update() but moved items don't move on the screen I tried adding the following to Refresh in pcbnew_scripting_helpers.cpp: s_PcbEditFrame->GetGalCanvas()->Refresh(); KIGFX::VIEW* view = s_PcbEditFrame->GetGalCanvas()->GetView(); KIGFX::VIEW_GROUP preview( view ); view->Update(&preview); I also tried calling frame->OnModify() which I've seen sprinkled all over. Doesn't do the trick either. *So how do I force a redraw?* 2) I see there are a bunch of Add, Remove,... functions that a script would need to call. *Why don't the relevant objects just make these calls when they are changed? *Then the code for undo is handled once and developers can forget about it. 3) I see there are pre and post modify methods. (ie Remove and Removed) *What's the difference?* Why use one over the other? 4) Since there isn't a single global BC object, *are there reasons to have multiple objects?* Does it make sense to have two objects active at the same time? I'm picturing an editing operation that puts some changes in BCa and others in BCc, but I can't think of a reason why. I guess that's all I have to ask about that. Miles
_______________________________________________ Mailing list: https://launchpad.net/~kicad-developers Post to : kicad-developers@lists.launchpad.net Unsubscribe : https://launchpad.net/~kicad-developers More help : https://help.launchpad.net/ListHelp