43 return (e->type == MapNotify) && (e->xmap.window == (Window) arg);
49 ,theIRow(0), theIColumn(0)
50 ,display(0), win(0), scmap(0)
67 G4int nMax = std::max (nRow, nColumn);
115 G4warn <<
"G4RTXScanner::Initialize(): cannot get display."
120 int screen_num = DefaultScreen(
display);
123 int xOffset = 0, yOffset = 0;
124 XSizeHints* size_hints = XAllocSizeHints();
125 unsigned int width, height;
127 if (!XGeometryString.empty()) {
128 G4int geometryResultMask = XParseGeometry
129 ((
char*)XGeometryString.c_str(),
130 &xOffset, &yOffset, &width, &height);
131 if (geometryResultMask & (WidthValue | HeightValue)) {
132 if (geometryResultMask & XValue) {
133 if (geometryResultMask & XNegative) {
134 xOffset = DisplayWidth(
display, screen_num) + xOffset - width;
136 size_hints->flags |= PPosition;
137 size_hints->x = xOffset;
139 if (geometryResultMask & YValue) {
140 if (geometryResultMask & YNegative) {
141 yOffset = DisplayHeight(
display, screen_num) + yOffset - height;
143 size_hints->flags |= PPosition;
144 size_hints->y = yOffset;
147 G4warn <<
"ERROR: Geometry string \""
149 <<
"\" invalid. Using \"600x600\"."
155 G4warn <<
"ERROR: Geometry string \""
157 <<
"\" is empty. Using \"600x600\"."
162 size_hints->width = width;
163 size_hints->height = height;
164 size_hints->flags |= PSize;
166 win = XCreateSimpleWindow
168 xOffset, yOffset, width, height,
170 WhitePixel(
display, screen_num),
171 BlackPixel(
display, screen_num));
177 Status status = XGetRGBColormaps
179 &
scmap, &nMaps, XA_RGB_BEST_MAP);
181 system(
"xstdcmap -best");
182 status = XGetRGBColormaps
184 &
scmap, &nMaps, XA_RGB_BEST_MAP);
187 "G4RTXScanner::Initialize(): cannot get color map."
188 "\n Perhaps your system does not support XA_RGB_BEST_MAP."
193 if (!
scmap->colormap) {
194 G4warn <<
"G4RTXScanner::Initialize(): color map empty."
199 XWMHints* wm_hints = XAllocWMHints();
200 XClassHint* class_hint = XAllocClassHint();
201 const char* window_name = name.c_str();
202 XTextProperty windowName;
203 XStringListToTextProperty((
char**)&window_name, 1, &windowName);
205 XSetWMProperties(
display,
win, &windowName, &windowName,
206 0, 0, size_hints, wm_hints, class_hint);
211 XSelectInput(
display,
win, StructureNotifyMask);
219(
unsigned char red,
unsigned char green,
unsigned char blue)
222 unsigned long pixel_value =
scmap->base_pixel +
223 ((
unsigned long) ((red *
scmap->red_max) / 256.) *
scmap->red_mult) +
224 ((
unsigned long) ((green *
scmap->green_max) / 256.) *
scmap->green_mult) +
225 ((
unsigned long) ((blue *
scmap->blue_max) / 256.) *
scmap->blue_mult);
226 XSetForeground(
display,
gc, pixel_value);
Bool G4RayTracerXScannerWaitForNotify(Display *, XEvent *e, char *arg)
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