fraus@forwiss.uni-passau.de (Uli Fraus) (06/03/91)
Hello everybody,
I am trying to learn InterViews (we have IV 2.6 with g++ under SunOS 4.1.)
and now have the following problem. According to the examples in publications
I specified a global constant 'space' and failed. The constant always had
the value 0. But when I write the same constant definition after defining
a World variable the constant value is non zero!
For example the following small program
#include <stream.h>
#include <InterViews/world.h>
int main() {
const double space1 = inch;
World* world = new World();
const double space2 = inch;
cout << inch <<" "<< space1<<" "<< space2 <<"\n";
return 0;
}
produces the output:
90 0 90
So maybe the variable inch (from file defs.h) is initialized by defining
a World variable.
Is this a bug or a feature???
How is it possible to have (global) constants based on 'inch'?
Thanks for hints and information
Uli.
--
Ulrich Fraus, FORWISS Passau, University of Passau, West Germany ||====
E-Mail: fraus@forwiss.uni-passau.de || || || () ||__
Phone : +49 851/509-496 || || || || ||
Fax : +49 851/509-497 \\==// ||=== || || o
glenn@glenn@bitstream.com (Glenn P. Parker) (06/04/91)
In article <1991Jun3.151557.10753@forwiss.uni-passau.de> fraus@forwiss.uni-passau.de (Uli Fraus) writes: > So maybe the variable inch (from file defs.h) is initialized by defining > a World variable. Precisely. > Is this a bug or a feature??? It's a bug or a feature, depending on how you look at it. :-) The global variable "inch" is set by the InterViews library to be the number of *pixels* per inch in a *particular* World, i.e. X display. Since display resolutions differ widely, this variable can't be set until a World has been created (establishing a connection to an X server, which can provide appropriate information about resolution). > How is it possible to have (global) constants based on 'inch'? It isn't, but is that what you really want? If you use a hard constant, your software will only work at one resolution. If you use inch instead (or something based on inch), things should scale nicely. In my Reconfig functions, I frequently begin with a statement like: const Coord spacer = round(inch/4); I then use spacer to express the Shape's of other components. This works fine because Reconfig can't (well... never should) be called before a World has been created. Why is this a bug and not just a feature? It is possible to have two Worlds with different resolutions. I've never had to worry about this, myself. -- Glenn P. Parker glenn@bitstream.com Bitstream, Inc. uunet!huxley!glenn 215 First Street BIX: parker Cambridge, MA 02142-1270