← Back to team overview

kicad-developers team mailing list archive

Re: Assumptions about EDA_DRAW_FRAME in pcbnew

 

Hi Reece,

> On 3 Jul 2020, at 21:32, Reece R. Pollack <reece@xxxxxxx> wrote:
> 
> Noting that the PCB_BASE_FRAME class is derived from the EDA_DRAW_FRAME class, is it acceptable to assume that the EDA_DRAW_FRAME pointer parameters passed to functions in Pcbnew classes are actually pointers to a PCB_BASE_FRAME?

Yes, but it would be considered bad practice.

> 
> Specifically:
> The UNIT_BINDER class constructor
> The classes implementing the GetMsgPanelInfo function
> The classes implementing the GetSelectMenuText function
> The reason I'm asking is that to implement origin transforms these functions need access to the user's display option that chooses the display origin. This needs access to a function defined in the PCB_BASE_FRAME class. I can make that a common function defined in EDU_DRAW_FRAME and overridden in PCB_BASE_FRAME, or the code needs to know that parameter is really a pointer to a PCB_BASE_FRAME object.
> 
Ask yourself this: is there anything PCB-specific about a settable origin?  Is there any reason a settable origin wouldn’t also be useful, say, a schematic?  If the answer is “no”, then you should push the origin (along with its getters and setters) down in to EDA_DRAW_FRAME.

If this really is PCB-specific, then you can either push just the origin getters/setters down into EDA_DRAW_FRAME and override them in PCB_BASE_FRAME, or do a dynamic_cast to PCB_BASE_FRAME and if non-null call the getters/setters.

Cheers,
Jeff.

> If the functions defined in PCB-specific classes are defined to be getting pointers to PCB_BASE_FRAME classes, I can just change the parameter type and avoid the need to play games with dynamic casts.
> 
> Thanks!
> 
> -Reece
> 
> _______________________________________________
> 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


Follow ups

References