Thanks everyone for your input. First off, I too think it will get the most usage in the footprint editor, specifically when calculating the position and size of a pad from cryptic datasheet dimensions. I chose the schematic value entry dialog simply because its a small target. But even having the ability to calculate values using an expression when designing the schematic I think will be useful.
With regard to exposing the exprtk library to the python interface its beyond my pay grade. At this point i'm ambivalent to what library is finally used, but exprtk was easy to integrate and as Tomasz pointed out comes as a single header file. It has plenty of features and from my reading of the docs it might be possible to use it to create a program wide parametric design system using hierarchical symbol tables. It does compile to a fairly large object file though ~43 MB. Since python is already integrated to it might also be suitable parser. I was actually looking for create a custom wx Control instead of creating the MathProcesssor class, but couldn't find a suitable example from the wxWidgets doc. I think it would be fairly easy to extend the WX_UNIT_BINDER control to include the parser, and a few find and replaces could spread the functionality across Kicad. In regards to using the equals sign to denote an expression, I think this will only be needed in fields where the the final value is a string. In combination with using OnTextEnter event, the user expressly denotes if the input string is to be evaluated or left as is for the odd case where they want to leave the equals sign in place. Otherwise for numerical inputs it can always be evaluated in the way Michael has implemented his. Kind Regards Russell On Mon, Aug 28, 2017 at 11:42 PM Michael Geselbracht < mgeselbrac...@gmail.com> wrote: > Incidentally I have written a similar calculator last week and included it > in Pcbnew. I used the lemon parser generator > but exprtk might be a better choice. That way it should be easy to extend > the calculator with support for > variables without re-inventing the wheel. > > I wanted to mimick the behaviour of Solidworks or CorelDraw; they do not > use '=' to introduce a formula. > The text is always interpreted as expression and constants may have units. > > So if I want to move a FP from x:80.442 50mil to the right I write (or > append) "80.442+50mil". > A difference is that I use the OnTextFocusLost event to start the > evaluation and OnTextFocusGet to restore > the previous text just before the evaluation (ups, should have been > 25mils). > > The next step would be to integrate the evaluator in the footprint editor > as well. But it does not seem to be wise > right now ;). > > > - Michael > > > > On Mon, Aug 28, 2017 at 2:45 PM, hauptmech <hauptm...@gmail.com> wrote: > >> or perhaps the python parser is already used in enough kicad builds that >> it should be used? >> >> On 28/08/17 19:56, Tomasz Wlostowski wrote: >> >>> On 27.08.2017 22:28, Marco Ciampa wrote: >>> >>>> +1 muparser is already present in many distros: >>>> >>>> apt-cache search muparser >>>> libmuparser-dev - fast mathematical expressions parse library >>>> (development) >>>> libmuparser-doc - fast mathematical expressions parser library >>>> (documentation) >>>> libmuparser2v5 - fast mathematical expressions parser library (runtime) >>>> >>> ...And exprtk is a single header file, which compiles on any OS. There >>> is life outside Linux, too. >>> >>> - my 5 cents, >>> Tom >>> >>> >>> _______________________________________________ >>> 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 >>> >> >> >> >> _______________________________________________ >> 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 >> > > _______________________________________________ > 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 >
_______________________________________________ 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