|Message: RE: Writing UIcommands with units, and G4BestUnit interface||Not Logged In (login)|
Click on the Forum title, e.g. on the "Forums by Category" page, to read a sequence of postings to the Forum and its threads all in one page. If you are only interested in one thread or the thread following a specific posting, click the thread or the posting, which takes you to a smaller page, which contains only the part you are interested in and may be easier to navigate.
Messages are "chained" if there are only replies at the first level, i.e. 1/1.html, 1/1/1.html etc. In case of "chained" messages the message number is replaced by the icon and there is no indentation.
Inline: Display the subject line only or also the text of the posting(s); for the choice "All" the "Outline" choices are switched off.
|1||0||1||no text / full text of posting|
|2||1||All||text for level 1 only / text for All postings|
Outline: Choose the depth of the posting thread, successive toggle controls provide increasing detail.
|1||2||1||2 levels / 1 level (original posting)|
|2||3||2||3 levels / 2 levels|
|3||3||All||3 levels / all levels (all postings)|
Mike, I thought all of your un-defined number of parameters except the last one are numbers rather than strings, e.g. /your/command 1.2 3.4 5.6 .... 8.9 cm And you want to make the last unit parameter optional so that the user may omit it, i.e. /your/command 1.2 3.4 5.6 .... 8.9 Please note that ValueOf() method returns zero if the string is not defined as a unit string. Thus, for the very last parameter token, you may check 1) if ValueOf() method returns a non-zero value, then it is a valid unit string 2) if it is zero, convert it to a double. Makoto > -----Original Message----- > From: Mike Kelsey [mailto:firstname.lastname@example.org] > Sent: Thursday, December 23, 2010 10:30 AM > To: Asai, Makoto > Cc: userinterface-g4hn > Subject: Re: Writing UIcommands with units, and G4BestUnit interface > > Asai, Makoto writes: > > http://www- > geant4.kek.jp/lxr/source/intercoms/include/G4UIcommand.hh#L105 > > Yes, indeed, Makoto. That's where I started. I'm using ValueOf() in > several places, where I already have the specific unit name string in > hand. > > My situation is where I _don't_ have the unit string yet. G4BestUnit > doesn't appear to have a way to get either that string (or the scale > vlaue) > by itself. In G4UnitsTable.hh, the G4BestUnit functor, > > G4BestUnit(G4double value, G4String& category) > > returns only the composite string (either via operator G4String() or > operator<<) with both the scaled numeric value plus the chosen unit. > > From looking at the code, all of the computational work for G4BestUnit > is > embedded in the operator<<() implementation, with no encapsulation of > the > pieces. > > I'd like to know whether there might be a different interface somewhere > which does the same job: given a double value and a units category, it > returns the unit (by string or by scale) which best suits the input > value. > > Without such an interface, I can take the string returned by G4BestUnit > and > capture the second token, but that seems a bit wasteful. > > -- Mike
|Inline Depth:||Outline Depth:||Add message:|