Import Geant4 8.1.0 source tree
This commit is contained in:
@@ -1,28 +1,31 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * DISCLAIMER *
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The following disclaimer summarizes all the specific disclaimers *
|
||||
// * of contributors to this software. The specific disclaimers,which *
|
||||
// * govern, are listed with their locations in: *
|
||||
// * http://cern.ch/geant4/license *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the intellectual property of the *
|
||||
// * GEANT4 collaboration. *
|
||||
// * By copying, distributing or modifying the Program (or any work *
|
||||
// * based on the Program) you indicate your acceptance of this *
|
||||
// * statement, and all its terms. *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4RayTracerXViewer.cc,v 1.3 2005/11/18 23:05:04 allison Exp $
|
||||
// GEANT4 tag $Name: geant4-08-00 $
|
||||
// $Id: G4RayTracerXViewer.cc,v 1.5 2006/06/29 21:24:19 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-01 $
|
||||
|
||||
#ifdef G4VIS_BUILD_RAYTRACERX_DRIVER
|
||||
|
||||
@@ -30,131 +33,25 @@
|
||||
|
||||
#include "G4VSceneHandler.hh"
|
||||
#include "G4Scene.hh"
|
||||
#include "G4RayTracerX.hh"
|
||||
#include "G4TheRayTracer.hh"
|
||||
#include "G4RTJpegMaker.hh"
|
||||
#include "G4RTXScanner.hh"
|
||||
#include "G4UImanager.hh"
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xatom.h>
|
||||
|
||||
extern "C" {
|
||||
Bool G4RayTracerXViewerWaitForNotify (Display*, XEvent* e, char* arg) {
|
||||
return (e->type == MapNotify) && (e->xmap.window == (Window) arg);
|
||||
}
|
||||
}
|
||||
|
||||
G4RayTracerXViewer::G4RayTracerXViewer
|
||||
(G4VSceneHandler& sceneHandler, const G4String& name):
|
||||
G4RayTracerViewer(sceneHandler, name)
|
||||
G4RayTracerViewer(sceneHandler,
|
||||
name,
|
||||
new G4TheRayTracer(new G4RTJpegMaker, new G4RTXScanner))
|
||||
{
|
||||
G4RayTracerX* theTracer =
|
||||
(G4RayTracerX*) fSceneHandler.GetGraphicsSystem();
|
||||
|
||||
Display*& display = theTracer->display;
|
||||
Window& win = theTracer->win;
|
||||
GC& gc = theTracer->gc;
|
||||
XStandardColormap*& scmap = theTracer->scmap;
|
||||
|
||||
display = XOpenDisplay(0); // Use display defined by DISPLAY environment.
|
||||
if (!display) {
|
||||
// Set up X Window...
|
||||
G4RTXScanner* theXScanner = (G4RTXScanner*)theTracer->GetScanner();
|
||||
if (!theXScanner->GetXWindow(fName,fVP)) {
|
||||
fViewId = -1; // This flags an error.
|
||||
G4cerr << "G4RayTracerXViewer::G4RayTracerXViewer: cannot get display."
|
||||
<< G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
int screen_num = DefaultScreen(display);
|
||||
|
||||
// Window size and position...
|
||||
int xOffset = 0, yOffset = 0;
|
||||
unsigned int width, height;
|
||||
XSizeHints* size_hints = XAllocSizeHints();
|
||||
const G4String& XGeometryString = fVP.GetXGeometryString();
|
||||
if (!XGeometryString.empty()) {
|
||||
G4int geometryResultMask = XParseGeometry
|
||||
((char*)XGeometryString.c_str(),
|
||||
&xOffset, &yOffset, &width, &height);
|
||||
if (geometryResultMask & (WidthValue | HeightValue)) {
|
||||
if (geometryResultMask & XValue) {
|
||||
if (geometryResultMask & XNegative) {
|
||||
xOffset = DisplayWidth(display, screen_num) + xOffset - width;
|
||||
}
|
||||
size_hints->flags |= PPosition;
|
||||
size_hints->x = xOffset;
|
||||
}
|
||||
if (geometryResultMask & YValue) {
|
||||
if (geometryResultMask & YNegative) {
|
||||
yOffset = DisplayHeight(display, screen_num) + yOffset - height;
|
||||
}
|
||||
size_hints->flags |= PPosition;
|
||||
size_hints->y = yOffset;
|
||||
}
|
||||
} else {
|
||||
G4cout << "ERROR: Geometry string \""
|
||||
<< XGeometryString
|
||||
<< "\" invalid. Using \"600x600\"."
|
||||
<< G4endl;
|
||||
width = 600;
|
||||
height = 600;
|
||||
}
|
||||
}
|
||||
size_hints->width = width;
|
||||
size_hints->height = height;
|
||||
size_hints->flags |= PSize;
|
||||
|
||||
win = XCreateSimpleWindow
|
||||
(display, RootWindow(display, screen_num),
|
||||
xOffset, yOffset, width, height,
|
||||
0, // Border width.
|
||||
WhitePixel(display, screen_num), // Border colour.
|
||||
BlackPixel(display, screen_num)); // Background colour.
|
||||
|
||||
XGCValues values;
|
||||
gc = XCreateGC(display, win, 0, &values);
|
||||
|
||||
int nMaps;
|
||||
Status status = XGetRGBColormaps
|
||||
(display, RootWindow(display, screen_num),
|
||||
&scmap, &nMaps, XA_RGB_BEST_MAP);
|
||||
if (!status) {
|
||||
system("xstdcmap -best"); // ...and try again...
|
||||
Status status = XGetRGBColormaps
|
||||
(display, RootWindow(display, screen_num),
|
||||
&scmap, &nMaps, XA_RGB_BEST_MAP);
|
||||
if (!status) {
|
||||
fViewId = -1; // This flags an error.
|
||||
G4cerr <<
|
||||
"G4RayTracerXViewer::G4RayTracerXViewer: cannot get color map."
|
||||
"\n Perhaps your system does not support RGB_BEST_MAP."
|
||||
<< G4endl;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!scmap->colormap) {
|
||||
fViewId = -1; // This flags an error.
|
||||
G4cerr << "G4RayTracerXViewer::G4RayTracerXViewer: color map empty."
|
||||
<< G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
XWMHints* wm_hints = XAllocWMHints();
|
||||
XClassHint* class_hint = XAllocClassHint();
|
||||
const char* window_name = fName.c_str();
|
||||
XTextProperty windowName;
|
||||
XStringListToTextProperty((char**)&window_name, 1, &windowName);
|
||||
|
||||
XSetWMProperties(display, win, &windowName, &windowName,
|
||||
0, 0, size_hints, wm_hints, class_hint);
|
||||
|
||||
XMapWindow(display, win);
|
||||
|
||||
// Wait for window to appear (wait for an "map notify" event).
|
||||
XSelectInput(display, win, StructureNotifyMask);
|
||||
XEvent event;
|
||||
XIfEvent (display, &event, G4RayTracerXViewerWaitForNotify, (char*) win);
|
||||
|
||||
}
|
||||
|
||||
G4RayTracerXViewer::~G4RayTracerXViewer() {}
|
||||
|
||||
Reference in New Issue
Block a user