Skip to content

pcbnew: code reuse between copper zone dialog and Zone Manager

Description

This is a code reuse issue, feel free to close if not desired. Follow up to !2122 (merged). Just wanted to start a discussion and get buy in before embarking on this project.

I feel like there is a fair amount of code that could be unified between the copper zone dialog and zone manager. See attached screenshots for comparison.

20250221_14h06m22s_grim

20250221_14h06m18s_grim

I propose that we do that by introducing a common base class between the two, located in root of pcbnew/, say ZONE_EDITOR_BASE, which both of the derived dialog and panel classes, respectively, inherit. That class would implement common behaviors of these dialogs (which, in my boldest dreams, we'll be able to extend to the copper zone properties panel as well). Open to suggestions on some other ways to achieve this!

(Now that I look deeper, I notice a possible pre-existing attempt to move in this direction: the ZONE_MANAGEMENT_BASE class.)

cc @liangtie @jeffyoung since the two of you seem most involved in zone manager by the look of git log --stat

Steps to reproduce

  1. https://gitlab.com/kicad/code/kicad/-/blob/master/pcbnew/zone_manager/dialog_zone_manager.cpp?ref_type=heads
  2. https://gitlab.com/kicad/code/kicad/-/blob/master/pcbnew/dialogs/dialog_copper_zones.cpp?ref_type=heads

KiCad Version

master