kicad-developers team mailing list archive
Mailing list archive
Re: Pcbnew display origin transforms for v6
You should code internal stuff in VECTOR2I rather than wxPoint. wxPoint should only be used when going to the UI. (We’re trying to reduce our wxWidgets dependencies, although this is very much a work in progress.)
If you do use UNIT_BINDER keep in mind that it’s not yet used in WX_GRID (mainly because some work needs to be done so that cells know whether or not they hold a numeric value). If you want to tackle that too, that would be awesome.
> On 1 May 2019, at 02:50, Reece R. Pollack <reece@xxxxxxx> wrote:
> Inspired by KiCon (and before the high wears off) I'm moving forward with my project to allow the user to specify the coordinate display origin in pcbnew. I have this working as patches to the v5.1.2 branch, but they're hard-coded to use the Aux origin. I'd like some guidance on how best to code this for eventual inclusion into the v6 development branch.
> My plan is:
> Create a new class ORIGIN_TRANSFORM. This class maintains the user's configuration and provides functions to perform the transforms necessary to convert between the internal coordinate representation and the equivalent coordinates relative to the user-selected origin.
> Embed two ORIGIN_TRANSFORM objects in the BOARD_DESIGN_SETTINGS class representing the origin transforms for the X and Y axes.
> Create a new tab in the pcbnew "Preferences" to allow the user to select the origin (Page [default], Aux, or Grid) and direction (Left or Right [default], Up or Down [default]) for each axis.
> Modify the board file format to save and load the user's ORIGIN_TRANSFORM configuration. Saving this in the .kicad_pcb file allows everyone editing the board to see coordinates reported relative to the same origin.
> Modify each of the dialog classes that displays object coordinates to use the ORIGIN_TRANSFORM objects to display coordinates relative to the user-selected origin. When the dialog is closed object coordinates are converted back to internal coordinates.
> Modify the PCB_BASE_FRAME class to display the absolute cursor position relative to the user-selected origin.
> This is structured to allow the UNIT_BINDER class to manage origin transforms, much like it handles the mm/mil conversions. I would change the constructor to take a reference to an ORIGIN_TRANSFORM object as an additional argument; the default value would be a unity-transform whose conversion functions return the value to be converted unmodified. Those UNIT_BINDER objects that represent a coordinate value (commonly m_posX and m_posY) would be constructed with a reference to one of the two ORIGIN_TRANSFORM objects in the BOARD_DESIGN_SETTINGS class.
> The problem with this strategy is that KiCad reuses UNIT_BINDER objects for dissimilar purposes. For example, DIALOG_GRAPHIC_ITEM_PROPERTIES::m_endX can represent the end point of a graphic line, for which origin transform is needed. But it can also represent the radius of a circle, for which origin transform is inappropriate. Thus UNIT_BINDER needs a method similar to the Show() function to enable or disable the origin transform depending on how it is being used. This may argue against pushing this functionality into UNIT_BINDER.
> If I don't modify the UNIT_BINDER class I'll probably code the ORIGIN_TRANSFORM class to handle wxPoint objects rather than individual coordinates. Thus there would be only one ORIGIN_TRANSFORM object added to the BOARD_DESIGN_SETTINGS class. The transform in the dialog class then becomes a single call to transform a coordinate pair rather than one each for X and Y.
> Thoughts? Comments? Suggestions? Brickbats?
> Mailing list: https://launchpad.net/~kicad-developers
> Post to : kicad-developers@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help : https://help.launchpad.net/ListHelp