Message: Re: Writing UIcommands with units, and G4BestUnit interface Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Re: Writing UIcommands with units, and G4BestUnit interface 

Forum: (Graphical) User Interfaces
Re: None Writing UIcommands with units, and G4BestUnit interface (Michael H. Kelsey)
Re: None RE: Writing UIcommands with units, and G4BestUnit interface (Makoto Asai)
Date: 23 Dec, 2010
From: Michael H. Kelsey <Michael H. Kelsey>

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:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

1 None: RE: Writing UIcommands with units, and G4BestUnit interface   (Asai, Makoto - 23 Dec, 2010)
(_ None: Re: Writing UIcommands with units, and G4BestUnit interface   (Mike Kelsey - 23 Dec, 2010)
 Add Message Add Message
to: "Re: Writing UIcommands with units, and G4BestUnit interface"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]