Import Geant4 10.3.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2016-06-30 14:12:05 +02:00
parent a654a7ab1f
commit 4ec577e5c4
2021 changed files with 100995 additions and 78277 deletions
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4OpenInventorWin.cc 66373 2012-12-18 09:41:34Z gcosmo $
// $Id: G4OpenInventorWin.cc 97241 2016-05-30 12:06:54Z gcosmo $
//
// OpenInventor graphics system factory.
@@ -50,9 +50,8 @@ void G4OpenInventorWin::Initialize ()
if(fInited) return; //Done
SetInteractorManager (G4Win32::getInstance());
GetInteractorManager () -> RemoveDispatcher((G4DispatchFunction)G4Win32::dispatchWin32Event);
// GetInteractorManager () -> AddDispatcher((G4DispatchFunction)SoWin::dispatchEvent);
GetInteractorManager () -> RemoveDispatcher((G4DispatchFunction)G4Win32::DispatchWin32Event);
GetInteractorManager () -> AddDispatcher((G4DispatchFunction)SoWin::dispatchEvent);
HWND toplevel = (HWND)GetInteractorManager()->GetMainInteractor();
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4OpenInventorWinViewer.cc 66373 2012-12-18 09:41:34Z gcosmo $
// $Id: G4OpenInventorWinViewer.cc 97241 2016-05-30 12:06:54Z gcosmo $
//
/*
* jck : 05 Feb 1997 : Initial Implementation
@@ -204,6 +204,7 @@ void G4OpenInventorWinViewer::Initialise() {
fInteractorManager->FlushAndWaitExecution ();
}
fInteractorManager->SetCreatedInteractor (fViewer -> getWidget());
fViewer->setTransparencyType(SoGLRenderAction::SORTED_OBJECT_ADD);
}
G4OpenInventorWinViewer::~G4OpenInventorWinViewer () {
@@ -81,8 +81,10 @@
#include <Inventor/sensors/SoTimerSensor.h> // Animation
#include <Inventor/sensors/SoNodeSensor.h> // Detect start of run
#include "saveViewPt.h"
#include "console.h"
#include "favorites.h"
#include "pickext.h"
#include "pickref.h"
//#include "console.h"
//#include "favorites.h"
#include "Geant4_SoPolyhedron.h"
//#include "G4RunManager.hh"
@@ -746,14 +748,22 @@ void G4OpenInventorXtExaminerViewer::createViewerButtons(Widget parent,
xmToggleButtonWidgetClass, parent, XmNindicatorOn, False, NULL);
XtAddCallback(abbrOutputButton, XmNdisarmCallback, G4OpenInventorXtExaminerViewer::abbrOutputCB,
this);
Pixmap consolexpm, consolexpm_ins;
consolexpm = SoXtInternal::createPixmapFromXpm(abbrOutputButton,
console_xpm);
consolexpm_ins = SoXtInternal::createPixmapFromXpm(abbrOutputButton,
console_xpm, TRUE);
Pixmap pickextxpm, pickextxpm_ins;
pickextxpm = SoXtInternal::createPixmapFromXpm(abbrOutputButton,
pickext_xpm);
pickextxpm_ins = SoXtInternal::createPixmapFromXpm(abbrOutputButton,
pickext_xpm, TRUE);
XtVaSetValues(abbrOutputButton, XmNlabelType, XmPIXMAP, XmNlabelPixmap,
consolexpm, XmNselectPixmap, consolexpm, XmNlabelInsensitivePixmap,
consolexpm_ins, XmNselectInsensitivePixmap, consolexpm_ins, NULL);
pickextxpm, XmNselectPixmap, pickextxpm, XmNlabelInsensitivePixmap,
pickextxpm_ins, XmNselectInsensitivePixmap, pickextxpm_ins, NULL);
// Pixmap consolexpm, consolexpm_ins;
// consolexpm = SoXtInternal::createPixmapFromXpm(abbrOutputButton,
// console_xpm);
// consolexpm_ins = SoXtInternal::createPixmapFromXpm(abbrOutputButton,
// console_xpm, TRUE);
// XtVaSetValues(abbrOutputButton, XmNlabelType, XmPIXMAP, XmNlabelPixmap,
// consolexpm, XmNselectPixmap, consolexpm, XmNlabelInsensitivePixmap,
// consolexpm_ins, XmNselectInsensitivePixmap, consolexpm_ins, NULL);
buttonlist->append(abbrOutputButton);
// Button for selecting the beam that will act as reference path
@@ -761,14 +771,22 @@ void G4OpenInventorXtExaminerViewer::createViewerButtons(Widget parent,
parent, NULL);
XtAddCallback(pickRefPathButton, XmNactivateCallback,
G4OpenInventorXtExaminerViewer::pickRefPathCB, this);
Pixmap favoritesxpm, favoritesxpm_ins;
favoritesxpm = SoXtInternal::createPixmapFromXpm(pickRefPathButton,
favorites_xpm);
favoritesxpm_ins = SoXtInternal::createPixmapFromXpm(pickRefPathButton,
favorites_xpm, TRUE);
Pixmap pickrefxpm, pickrefxpm_ins;
pickrefxpm = SoXtInternal::createPixmapFromXpm(pickRefPathButton,
pickref_xpm);
pickrefxpm_ins = SoXtInternal::createPixmapFromXpm(pickRefPathButton,
pickref_xpm, TRUE);
XtVaSetValues(pickRefPathButton, XmNlabelType, XmPIXMAP, XmNlabelPixmap,
favoritesxpm, XmNselectPixmap, favoritesxpm, XmNlabelInsensitivePixmap,
favoritesxpm_ins, XmNselectInsensitivePixmap, favoritesxpm_ins, NULL);
pickrefxpm, XmNselectPixmap, pickrefxpm, XmNlabelInsensitivePixmap,
pickrefxpm_ins, XmNselectInsensitivePixmap, pickrefxpm_ins, NULL);
// Pixmap favoritesxpm, favoritesxpm_ins;
// favoritesxpm = SoXtInternal::createPixmapFromXpm(pickRefPathButton,
// favorites_xpm);
// favoritesxpm_ins = SoXtInternal::createPixmapFromXpm(pickRefPathButton,
// favorites_xpm, TRUE);
// XtVaSetValues(pickRefPathButton, XmNlabelType, XmPIXMAP, XmNlabelPixmap,
// favoritesxpm, XmNselectPixmap, favoritesxpm, XmNlabelInsensitivePixmap,
// favoritesxpm_ins, XmNselectInsensitivePixmap, favoritesxpm_ins, NULL);
buttonlist->append(pickRefPathButton);
}
@@ -1219,7 +1237,7 @@ void G4OpenInventorXtExaminerViewer::mouseoverCB(void *aThis, SoEventCallback *e
if(attHolder && attHolder->GetAttDefs().size()) {
std::string strTrajPoint = "G4TrajectoryPoint:";
std::ostringstream oss;
G4String t1, t2, t3, t4;
G4String t1, t1Ch, t2, t3, t4;
for (size_t i = 0; i < attHolder->GetAttDefs().size(); ++i) {
// G4cout << "Getting index " << i << " from attHolder" << G4endl;
// No, returns a vector! G4AttValue* attValue = attHolder->GetAttValues()[i];
@@ -1228,20 +1246,21 @@ void G4OpenInventorXtExaminerViewer::mouseoverCB(void *aThis, SoEventCallback *e
for (iValue = vals->begin(); iValue != vals->end(); ++iValue) {
const G4String& valueName = iValue->GetName();
const G4String& value = iValue->GetValue();
// G4cout << " valueName = " << valueName << G4endl;
// G4cout << " value = " << value << G4endl;
// G4cout << " valueName = " << valueName << G4endl;
// G4cout << " value = " << value << G4endl;
// LINE 1
if (valueName == "PN") t1 = value;
if (valueName == "Ch") {
if (atof(value.c_str()) > 0)
t1 += " +";
t1Ch = " +";
else
t1 += " ";
t1 += value;
t1Ch = " ";
t1Ch += value;
}
if (valueName == "PDG") {
t1 += " ";
t1 += value;
t1 += t1Ch;
This->mouseOverTextLogName->string.setValue(t1);
}
// G4cout << " t1 = " << t1 << G4endl;
@@ -1262,7 +1281,8 @@ void G4OpenInventorXtExaminerViewer::mouseoverCB(void *aThis, SoEventCallback *e
t3 += " P (" + value1 + ")";
}
if (valueName == "IMag") {
t3 += " " + value;
t3 += " " + value + "/c";
// t3 += " " + value;
This->mouseOverTextMaterial->string.setValue(t3);
}
// LINE 4
@@ -2052,9 +2072,12 @@ void G4OpenInventorXtExaminerViewer::findAndSetRefPath()
// Check if next character is a number,
// in which case we don't have Track ID 1
const char * nextChar =
oss.str().substr(idx + findStr.size() + 1,1).c_str();
if(std::isdigit(nextChar[0]))
// FWJ attempt to fix Coverity issue.
char nextChar = oss.str().at(idx+findStr.size()+1);
// const char * nextChar =
// oss.str().substr(idx + findStr.size() + 1,1).c_str();
if(std::isdigit(nextChar))
// if(std::isdigit(nextChar[0]))
break; //Not a primary track, continue with next track
coords = this->getCoordsNode(path);
@@ -2345,7 +2368,15 @@ void G4OpenInventorXtExaminerViewer::sortElements()
for(itEl = this->sceneElements.begin(), elementIndex = 0;
itEl != this->sceneElements.end(); ++itEl, ++elementIndex){
bAction.apply(itEl->path);
elementCoord = bAction.getBoundingBox().getCenter();
// FWJ sceneElement already has a center
elementCoord = itEl->center;
// ... and this sometimes returns an empty box!
// elementCoord = bAction.getBoundingBox().getCenter();
// if (bAction.getBoundingBox().isEmpty()) {
// G4cout << "sortElements: Box is empty!" << G4endl;
// G4cout << " element name=" << itEl->name << G4endl;
// }
int index;
distanceToTrajectory(elementCoord, el.smallestDistance, el.closestPoint, index);
@@ -2447,7 +2478,7 @@ void G4OpenInventorXtExaminerViewer::constructListsDialog(Widget w,
XtPointer client_data,
XtPointer)
{
G4cout << "DEBUG constructListsDialog w = " << w << G4endl;
// G4cout << "DEBUG constructListsDialog w = " << w << G4endl;
G4OpenInventorXtExaminerViewer * This = (G4OpenInventorXtExaminerViewer *) client_data;
if (This->listsDialog) {
return;
@@ -2480,7 +2511,7 @@ void G4OpenInventorXtExaminerViewer::constructListsDialog(Widget w,
// This is unnecessary because the parent is passed in
// topShell = SoXt::getShellWidget(This->getParentWidget());
topShell = w;
G4cout << "DEBUG PARENT (topShell) FOR AUX WINDOW = " << topShell << G4endl;
// G4cout << "DEBUG PARENT (topShell) FOR AUX WINDOW = " << topShell << G4endl;
// Shell Dialog
std::string dialogNameStr = This->fileName.substr(This->fileName.rfind('/') + 1);
@@ -3289,9 +3320,19 @@ void G4OpenInventorXtExaminerViewer::deleteViewPt(char *vpName)
fileIn.clear();
fileIn.close();
remove(fileName.c_str());
rename("temporaryFile.txt", fileName.c_str());
// FWJ check return status
int istat = remove(fileName.c_str());
if (istat == -1) {
char dialogName[] = "Warning";
warningMsgDialog("Error removing bookmarks file", dialogName,
NULL);
}
istat = rename("temporaryFile.txt", fileName.c_str());
if (istat == -1) {
char dialogName[] = "Warning";
warningMsgDialog("Error renaming bookmarks file", dialogName,
NULL);
}
fileOut.open(fileName.c_str(), std::ios::in);
fileOut.seekp(0, std::ios::end);
@@ -4303,28 +4344,29 @@ void G4OpenInventorXtExaminerViewer::renameBookmarkCB(Widget,
int end = vpNameStr.find_last_not_of(' ');
vpNameStr = vpNameStr.substr(beg, end - beg + 1);
const int nVPName = vpNameStr.size() + 1;
vpName = new char[nVPName];
strncpy(vpName, vpNameStr.c_str(), nVPName);
char* vpName1 = new char[nVPName];
strncpy(vpName1, vpNameStr.c_str(), nVPName);
int size = This->viewPtList.size();
for (int i = 0; i < size; i++) {
if (!strcmp(vpName, This->viewPtList[i].viewPtName)) {
if (!strcmp(vpName1, This->viewPtList[i].viewPtName)) {
String dialogName = (char *) "Existing Viewpoint";
std::string msg = "'";
msg += vpName;
msg += vpName1;
msg += "' already exists. Choose a different name";
This->warningMsgDialog(msg, dialogName, NULL);
delete[] vpName1;
return;
}
}
XmString vpNameXmStr = XmStringCreateLocalized(vpName);
XmString vpNameXmStr = XmStringCreateLocalized(vpName1);
if (XmListGetSelectedPos(This->myViewPtList, &pos_list, &pos_cnt)) {
XmListReplaceItemsPos(This->myViewPtList, &vpNameXmStr, 1, pos_list[0]);
This->renameViewPt(vpName);
This->renameViewPt(vpName1);
XtFree((char *) pos_list);
}
@@ -4332,6 +4374,7 @@ void G4OpenInventorXtExaminerViewer::renameBookmarkCB(Widget,
This->scheduleRedraw();
XmStringFree(vpNameXmStr);
delete[] vpName1;
}
@@ -4370,7 +4413,7 @@ void G4OpenInventorXtExaminerViewer::sortBookmarksCB(Widget,
char *vpName2 = new char[nVPName];
strncpy(vpName2, charList[i].c_str(), nVPName);
newStrList[i] = XmStringCreateLocalized(vpName2);
delete vpName2;
delete [] vpName2;
}
XmListDeleteAllItems(This->myViewPtList);
@@ -54,7 +54,7 @@ G4OpenInventorXtExtended::G4OpenInventorXtExtended ()
void G4OpenInventorXtExtended::Initialize()
{
G4cout << "DEBUG G4OpenInventorXtExtended::Initialize() CALLED" << G4endl;
// G4cout << "DEBUG G4OpenInventorXtExtended::Initialize() CALLED" << G4endl;
if(fInited) return; //Done
SetInteractorManager (G4Xt::getInstance ());
@@ -89,7 +89,7 @@ void G4OpenInventorXtExtendedViewer::Initialise() {
G4String wName = fName;
Widget parent = (Widget)fInteractorManager->GetParentInteractor ();
G4cout << "DEBUG G4OpenInventorXtExtendedViewer: parent = " << parent << G4endl;
// G4cout << "DEBUG G4OpenInventorXtExtendedViewer: parent = " << parent << G4endl;
int width = 600;
int height = 600;
@@ -124,7 +124,7 @@ void G4OpenInventorXtExtendedViewer::Initialise() {
SoXt::getDisplay(),
args,3);
G4cout << "DEBUG CREATING THE VIEWER WITH CREATED SHELL = " << fShell << G4endl;
// G4cout << "DEBUG CREATING THE VIEWER WITH CREATED SHELL = " << fShell << G4endl;
fViewer = new G4OpenInventorXtExaminerViewer(fShell, wName.c_str(), TRUE);
fViewer->addEscapeCallback(EscapeFromKeyboardCbk, (void *)this);
@@ -199,7 +199,7 @@ void G4OpenInventorXtExtendedViewer::Initialise() {
} else {
char* str = fInteractorManager->GetCreationString();
if(str!=0) wName = str;
G4cout << "DEBUG CREATING THE VIEWER WITH parent = " << parent << G4endl;
// G4cout << "DEBUG CREATING THE VIEWER WITH parent = " << parent << G4endl;
fViewer = new G4OpenInventorXtExaminerViewer(parent, wName.c_str(), TRUE);
}
@@ -279,7 +279,7 @@ Widget G4OpenInventorXtExtendedViewer::AddMenu(
// Cascade button :
Arg args[2];
XmString cps =
XmStringLtoRCreate((char*)aLabel.c_str(),XmSTRING_DEFAULT_CHARSET);
XmStringLtoRCreate((char*)aLabel.c_str(),(char*)XmSTRING_DEFAULT_CHARSET);
XtSetArg (args[0],XmNlabelString,cps);
XtSetArg (args[1],XmNsubMenuId,menu);
Widget widget = XmCreateCascadeButton(aMenuBar,(char*)aName.c_str(),args,2);
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4OpenInventorXtViewer.cc 66373 2012-12-18 09:41:34Z gcosmo $
// $Id: G4OpenInventorXtViewer.cc 97241 2016-05-30 12:06:54Z gcosmo $
//
/*
* jck 05 Feb 1997 - Initial Implementation
@@ -203,6 +203,7 @@ void G4OpenInventorXtViewer::Initialise() {
fInteractorManager->FlushAndWaitExecution ();
}
fInteractorManager->SetCreatedInteractor (fViewer -> getWidget());
fViewer->setTransparencyType(SoGLRenderAction::SORTED_OBJECT_ADD);
}
G4OpenInventorXtViewer::~G4OpenInventorXtViewer () {
@@ -253,7 +254,7 @@ Widget G4OpenInventorXtViewer::AddMenu(
// Cascade button :
Arg args[2];
XmString cps =
XmStringLtoRCreate((char*)aLabel.c_str(),XmSTRING_DEFAULT_CHARSET);
XmStringLtoRCreate((char*)aLabel.c_str(),(char*)XmSTRING_DEFAULT_CHARSET);
XtSetArg (args[0],XmNlabelString,cps);
XtSetArg (args[1],XmNsubMenuId,menu);
Widget widget = XmCreateCascadeButton(aMenuBar,(char*)aName.c_str(),args,2);