41 return (e->type == MapNotify) && (e->xmap.window == (Window) arg);
47 ,theIRow(0), theIColumn(0)
48 ,display(0), win(0), scmap(0)
113 G4cerr <<
"G4RTXScanner::Initialize(): cannot get display."
118 int screen_num = DefaultScreen(
display);
121 int xOffset = 0, yOffset = 0;
122 XSizeHints* size_hints = XAllocSizeHints();
123 unsigned int width, height;
125 if (!XGeometryString.empty()) {
126 G4int geometryResultMask = XParseGeometry
127 ((
char*)XGeometryString.c_str(),
128 &xOffset, &yOffset, &width, &height);
129 if (geometryResultMask & (WidthValue | HeightValue)) {
130 if (geometryResultMask & XValue) {
131 if (geometryResultMask & XNegative) {
132 xOffset = DisplayWidth(
display, screen_num) + xOffset - width;
134 size_hints->flags |= PPosition;
135 size_hints->x = xOffset;
137 if (geometryResultMask & YValue) {
138 if (geometryResultMask & YNegative) {
139 yOffset = DisplayHeight(
display, screen_num) + yOffset - height;
141 size_hints->flags |= PPosition;
142 size_hints->y = yOffset;
145 G4cout <<
"ERROR: Geometry string \""
147 <<
"\" invalid. Using \"600x600\"."
153 G4cout <<
"ERROR: Geometry string \""
155 <<
"\" is empty. Using \"600x600\"."
160 size_hints->width = width;
161 size_hints->height = height;
162 size_hints->flags |= PSize;
164 win = XCreateSimpleWindow
166 xOffset, yOffset, width, height,
168 WhitePixel(
display, screen_num),
169 BlackPixel(
display, screen_num));
175 Status status = XGetRGBColormaps
177 &
scmap, &nMaps, XA_RGB_BEST_MAP);
179 system(
"xstdcmap -best");
180 status = XGetRGBColormaps
182 &
scmap, &nMaps, XA_RGB_BEST_MAP);
185 "G4RTXScanner::Initialize(): cannot get color map."
186 "\n Perhaps your system does not support XA_RGB_BEST_MAP."
191 if (!
scmap->colormap) {
192 G4cerr <<
"G4RTXScanner::Initialize(): color map empty."
197 XWMHints* wm_hints = XAllocWMHints();
198 XClassHint* class_hint = XAllocClassHint();
199 const char* window_name =
name.c_str();
200 XTextProperty windowName;
201 XStringListToTextProperty((
char**)&window_name, 1, &windowName);
203 XSetWMProperties(
display,
win, &windowName, &windowName,
204 0, 0, size_hints, wm_hints, class_hint);
209 XSelectInput(
display,
win, StructureNotifyMask);
217(
unsigned char red,
unsigned char green,
unsigned char blue)
220 unsigned long pixel_value =
scmap->base_pixel +
221 ((
unsigned long) ((red *
scmap->red_max) / 256.) *
scmap->red_mult) +
222 ((
unsigned long) ((green *
scmap->green_max) / 256.) *
scmap->green_mult) +
223 ((
unsigned long) ((blue *
scmap->blue_max) / 256.) *
scmap->blue_mult);
224 XSetForeground(
display,
gc, pixel_value);
Bool G4RayTracerXScannerWaitForNotify(Display *, XEvent *e, char *arg)
static G4String Status(G4StepStatus stps)
G4GLOB_DLL std::ostream G4cerr
G4GLOB_DLL std::ostream G4cout
XStandardColormap * scmap
G4bool GetXWindow(const G4String &name, G4ViewParameters &)
virtual void Draw(unsigned char red, unsigned char green, unsigned char blue)
virtual const G4String & GetGSNickname() const
virtual G4bool Coords(G4int &iRow, G4int &iColumn)
virtual const G4String & GetGSName() const
virtual void Initialize(G4int nRow, G4int nColumn)
const G4String & GetXGeometryString() const
T max(const T t1, const T t2)
brief Return the largest of the two arguments
const char * name(G4int ptype)