Import Geant4 11.0.0.beta source tree
This commit is contained in:
@@ -56,48 +56,12 @@ void G4OpenInventorQt::Initialize()
|
||||
SetInteractorManager(G4SoQt::getInstance());
|
||||
|
||||
// FWJ DEBUG
|
||||
// G4cout << "G4OpenInventorQt: GETINTERACTORMANAGER " << GetInteractorManager()
|
||||
// << G4endl;
|
||||
|
||||
// FWJ from G4OIXt: these have no counterpart in Qt
|
||||
// GetInteractorManager() ->
|
||||
// RemoveDispatcher((G4DispatchFunction)XtDispatchEvent);
|
||||
// GetInteractorManager() ->
|
||||
// AddDispatcher((G4DispatchFunction)SoXt::dispatchEvent);
|
||||
// Widget top = (Widget)GetInteractorManager()->GetMainInteractor();
|
||||
|
||||
// FWJ apparently not used in OpenGLQt:
|
||||
// if(getenv("XENVIRONMENT")==NULL) {
|
||||
// XrmDatabase database = XrmGetDatabase(QtDisplay(top));
|
||||
// if(database!=NULL) {
|
||||
// XrmPutLineResource(&database,"*topShadowColor:white");
|
||||
// XrmPutLineResource(&database,"*bottomShadowColor:black");
|
||||
// XrmPutLineResource(&database,"*foreground:black");
|
||||
// XrmPutLineResource(&database,"*background:lightgrey");
|
||||
// XrmPutLineResource(&database,"*borderColor:lightgrey");
|
||||
// XrmPutLineResource(&database,"*fontList:-*-helvetica-bold-r-*-*-*-120-*-*-*-*-iso8859-1");
|
||||
// XrmPutLineResource(&database,"*help_popup.title:Help");
|
||||
// XrmPutLineResource(&database,"*helpCancel.labelString:Cancel");
|
||||
// XrmPutLineResource(&database,"*helpText.editMode:multi_line_edit");
|
||||
// XrmPutLineResource(&database,"*helpText.columns:60");
|
||||
// XrmPutLineResource(&database,"*helpText.rows:20");
|
||||
// XrmPutLineResource(&database,"*helpText.background:white");
|
||||
// XrmPutLineResource(&database,"*helpText.fontList:*courier*-r-*--14-*");
|
||||
// XrmPutLineResource(&database,"*helpText.maxLength:8000");
|
||||
// }
|
||||
// }
|
||||
// G4cout << "G4OpenInventorQt: GETINTERACTORMANAGER " <<
|
||||
// GetInteractorManager() << G4endl;
|
||||
|
||||
// FWJ for now, create an independent main window
|
||||
|
||||
// NOW should be done in G4SoQt [public G4VInteractorManager]
|
||||
//QWidget* mainWin = SoQt::init("Geant4");
|
||||
|
||||
// Note that GetMainInteractor() returns G4Interactor [typedef void*]
|
||||
//QWidget* mainWin = (QWidget*)(GetInteractorManager()->GetMainInteractor());
|
||||
|
||||
// FWJ DEBUG
|
||||
// G4cout << "OpenInventorQt: OBTAINED SoQt main window " << mainWin << G4endl;
|
||||
// G4cout << "SoQt::getTopLevelWidget()" << SoQt::getTopLevelWidget() << G4endl;
|
||||
// QWidget* mainWin = SoQt::init("Geant4");
|
||||
|
||||
// In parent G4OpenInventor
|
||||
InitNodes();
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#include "G4OpenInventorQtExaminerViewer.hh"
|
||||
|
||||
#include "ui_OIQtListsDialog.h"
|
||||
//#include "ui_OIQTAuxWindowQT5.h"
|
||||
|
||||
#include "saveViewPt.h"
|
||||
#include "pickext.h"
|
||||
#include "pickref.h"
|
||||
@@ -87,7 +87,6 @@
|
||||
// For searching for nodes within kits:
|
||||
#include <Inventor/nodekits/SoBaseKit.h>
|
||||
|
||||
|
||||
#include <QMenuBar>
|
||||
#include <QPushButton>
|
||||
#include <QRadioButton>
|
||||
@@ -120,18 +119,17 @@ G4OpenInventorQtExaminerViewer::
|
||||
G4OpenInventorQtExaminerViewer(QWidget* parent, const char* name, SbBool embed,
|
||||
SoQtFullViewer::BuildFlag flag,
|
||||
SoQtViewer::Type type)
|
||||
// : SoQtExaminerViewer(parent, name, embed, BUILD_NONE, type)
|
||||
: SoQtExaminerViewer(parent, name, embed, flag, type),
|
||||
externalQtApp(0)
|
||||
externalQtApp(0), processSoEventCount(0)
|
||||
{
|
||||
// FWJ DEBUG
|
||||
// G4cout << "G4OpenInventorQtExaminerViewer CONSTRUCTOR CALLED" << G4endl;
|
||||
// G4cout << "G4OpenInventorQtExaminerViewer parent=" << parent << G4endl;
|
||||
// G4cout << "G4OpenInventorQtExaminerViewer CONSTRUCTOR CALLED" << G4endl;
|
||||
// G4cout << "G4OpenInventorQtExaminerViewer parent=" << parent << G4endl;
|
||||
|
||||
// FWJ THIS DOESN'T WORK APPARENTLY NO MAINWINDOW
|
||||
// QMenuBar* menubar = ((QMainWindow*)parent)->menuBar();
|
||||
// G4cout << "G4OpenInventorQtExaminerViewer menubar=" << menubar << G4endl;
|
||||
fName = name;
|
||||
|
||||
fName = new QString(name);
|
||||
viewer = this;
|
||||
construct(TRUE);
|
||||
}
|
||||
@@ -157,7 +155,7 @@ G4OpenInventorQtExaminerViewer::~G4OpenInventorQtExaminerViewer()
|
||||
|
||||
void G4OpenInventorQtExaminerViewer::construct(const SbBool)
|
||||
{
|
||||
// setClassName(thisClassName);
|
||||
setFeedbackSize(40);
|
||||
|
||||
hookBeamOn = new HookEventProcState(this);
|
||||
newEvents = false;
|
||||
@@ -447,8 +445,7 @@ void G4OpenInventorQtExaminerViewer::buildWidget(QWidget* parent)
|
||||
// MENU BAR
|
||||
|
||||
menubar = new QMenuBar(getRenderAreaWidget());
|
||||
// menubar = new QMenuBar(parent);
|
||||
// menubar = new QMenuBar(parent->parentWidget());
|
||||
// FWJ DEBUG
|
||||
// G4cout << "G4OpenInventorQtExaminerViewer: GOT A menubar=" <<
|
||||
// menubar << G4endl;
|
||||
|
||||
@@ -560,7 +557,6 @@ void G4OpenInventorQtExaminerViewer::buildWidget(QWidget* parent)
|
||||
addAppPushButton(prevViewPtButton);
|
||||
|
||||
abbrOutputButton = new QPushButton;
|
||||
// abbrOutputButton = new QRadioButton;
|
||||
abbrOutputButton->setCheckable(true);
|
||||
abbrOutputButton->setIconSize(QSize(24,24));
|
||||
abbrOutputButton->setIcon(QPixmap((const char **)pickext_xpm));
|
||||
@@ -578,7 +574,6 @@ void G4OpenInventorQtExaminerViewer::buildWidget(QWidget* parent)
|
||||
addAppPushButton(pickRefPathButton);
|
||||
|
||||
switchWireFrameButton = new QPushButton;
|
||||
// switchWireFrameButton = new QRadioButton;
|
||||
switchWireFrameButton->setCheckable(true);
|
||||
switchWireFrameButton->setIconSize(QSize(24,24));
|
||||
switchWireFrameButton->setIcon(QPixmap((const char **)wireframe_xpm));
|
||||
@@ -587,6 +582,23 @@ void G4OpenInventorQtExaminerViewer::buildWidget(QWidget* parent)
|
||||
SLOT(SwitchWireFrameCB(bool)));
|
||||
addAppPushButton(switchWireFrameButton);
|
||||
|
||||
switchAxesButton = new QPushButton;
|
||||
switchAxesButton->setCheckable(true);
|
||||
switchAxesButton->setText(QString("A"));
|
||||
switchAxesButton->setToolTip("Axes on/off");
|
||||
connect(switchAxesButton, SIGNAL(toggled(bool)), this,
|
||||
SLOT(SwitchAxesCB(bool)));
|
||||
addAppPushButton(switchAxesButton);
|
||||
|
||||
detachButton = new QPushButton;
|
||||
detachButton->setIconSize(QSize(24,24));
|
||||
detachButton->setIcon(style.standardIcon(QStyle::SP_CommandLink));
|
||||
detachButton->setToolTip("Detach viewer window");
|
||||
connect(detachButton, SIGNAL(clicked()), this,
|
||||
SLOT(DetachCB()));
|
||||
// Used for UIQt only so check and add later
|
||||
// addAppPushButton(detachButton);
|
||||
|
||||
// HELP WINDOW
|
||||
|
||||
helpmsgbox = new QMessageBox(getParentWidget());
|
||||
@@ -627,8 +639,6 @@ FLY mode (requires Reference Path):\n\n\
|
||||
|
||||
// Bypass the namespace in order to make a persistent object
|
||||
AuxWindowDialog = new Ui_Dialog;
|
||||
// AuxWindowDialog = new Ui::Dialog;
|
||||
// Ui::Dialog AuxWindowDialog;
|
||||
AuxWindow = new QDialog(parent);
|
||||
AuxWindowDialog->setupUi(AuxWindow);
|
||||
|
||||
@@ -644,11 +654,6 @@ FLY mode (requires Reference Path):\n\n\
|
||||
connect(AuxWindowDialog->pushButton, SIGNAL(clicked()),
|
||||
this, SLOT(SortBookmarksCB()));
|
||||
|
||||
// AuxWindowDialog.setupUi(AuxWindow);
|
||||
// NO AuxWindowDialog.setupUi(&AuxWindow);
|
||||
// FWJ DEBUG
|
||||
// G4cout << "CALLING SHOW() ON AUXWINDOW !!!!!!!!!!!!!!!!!!!!" << G4endl;
|
||||
|
||||
// FWJ Better to do this after viewer window is realized
|
||||
// AuxWindow->show();
|
||||
// AuxWindow->raise();
|
||||
@@ -758,9 +763,16 @@ void G4OpenInventorQtExaminerViewer::afterRealizeHook()
|
||||
AuxWindow->activateWindow();
|
||||
|
||||
auto UI = G4UImanager::GetUIpointer();
|
||||
auto uiQt = dynamic_cast<G4UIQt*>(UI->GetG4UIWindow());
|
||||
uiQt = dynamic_cast<G4UIQt*>(UI->GetG4UIWindow());
|
||||
// This explicitly sets the TabWidget as parent before addTab():
|
||||
if (uiQt) uiQt->AddTabWidget(getParentWidget(), QString(fName));
|
||||
if (uiQt) {
|
||||
viewerParent = getParentWidget();
|
||||
viewerParent2 = viewerParent->parentWidget();
|
||||
uiQt->AddTabWidget(getParentWidget(), *fName);
|
||||
uiQtTabIndex = uiQt->GetViewerTabWidget()->currentIndex();
|
||||
// attached = TRUE;
|
||||
addAppPushButton(detachButton);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -887,7 +899,7 @@ void G4OpenInventorQtExaminerViewer::superimpositionEvent(SoAction * action)
|
||||
char zPos[20];
|
||||
// FWJ need a better format here
|
||||
sprintf(zPos, "%-7.2f [m]", refZPositions[refParticleIdx] / 1000);
|
||||
// sprintf(zPos, "%7.2f [m]", refZPositions[refParticleIdx] / 1000);
|
||||
// sprintf(zPos, "%7.2f [m]", refZPositions[refParticleIdx] / 1000);
|
||||
curInfoText->string.setValue(SbString(zPos));
|
||||
}
|
||||
}
|
||||
@@ -1321,15 +1333,16 @@ void G4OpenInventorQtExaminerViewer::mouseoverCB(void *aThis, SoEventCallback *e
|
||||
}
|
||||
// FWJ Mouseover for trajectories
|
||||
else if(node->getTypeId() == SoLineSet::getClassTypeId()) {
|
||||
// G4cout << "Trajectory!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << G4endl;
|
||||
// G4cout << "Trajectory!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << G4endl;
|
||||
G4AttHolder* attHolder = dynamic_cast<G4AttHolder*>(node);
|
||||
if(attHolder && attHolder->GetAttDefs().size()) {
|
||||
std::string strTrajPoint = "G4TrajectoryPoint:";
|
||||
std::ostringstream oss;
|
||||
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];
|
||||
// G4cout << "Getting index " << i << " from attHolder" << G4endl;
|
||||
// No, returns a vector!
|
||||
// G4AttValue* attValue = attHolder->GetAttValues()[i];
|
||||
const std::vector<G4AttValue>* vals = attHolder->GetAttValues()[i];
|
||||
std::vector<G4AttValue>::const_iterator iValue;
|
||||
for (iValue = vals->begin(); iValue != vals->end(); ++iValue) {
|
||||
@@ -1383,19 +1396,19 @@ void G4OpenInventorQtExaminerViewer::mouseoverCB(void *aThis, SoEventCallback *e
|
||||
This->mouseOverTextZPos->string.setValue(SbString(t4oss.str().c_str()));
|
||||
}
|
||||
}
|
||||
// G4cout << " NOW CALLING G4AttCheck" << G4endl;
|
||||
// G4cout << G4AttCheck(attHolder->GetAttValues()[i],
|
||||
// G4cout << " NOW CALLING G4AttCheck" << G4endl;
|
||||
// G4cout << G4AttCheck(attHolder->GetAttValues()[i],
|
||||
// attHolder->GetAttDefs()[i]);
|
||||
// oss << G4AttCheck(attHolder->GetAttValues()[i],
|
||||
// oss << G4AttCheck(attHolder->GetAttValues()[i],
|
||||
// attHolder->GetAttDefs()[i]);
|
||||
// if(oss.str().find(strTrajPoint) != std::string::npos) {
|
||||
// // Last attribute displayed was a trajectory point. Since we
|
||||
// // want abbreviated output, display the last one and exit
|
||||
// // (unless we're already at the last (and only) trajectory point)
|
||||
// if(i != attHolder->GetAttDefs().size()-1) {
|
||||
// G4cout << G4AttCheck(
|
||||
// attHolder->GetAttValues()[attHolder->GetAttDefs().size()-1],
|
||||
// attHolder->GetAttDefs()[attHolder->GetAttDefs().size()-1]);
|
||||
// if(oss.str().find(strTrajPoint) != std::string::npos) {
|
||||
// // Last attribute displayed was a trajectory point. Since we
|
||||
// // want abbreviated output, display the last one and exit
|
||||
// // (unless we're already at the last (and only) trajectory point)
|
||||
// if(i != attHolder->GetAttDefs().size()-1) {
|
||||
// G4cout << G4AttCheck(
|
||||
// attHolder->GetAttValues()[attHolder->GetAttDefs().size()-1],
|
||||
// attHolder->GetAttDefs()[attHolder->GetAttDefs().size()-1]);
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
@@ -1632,7 +1645,6 @@ void G4OpenInventorQtExaminerViewer::findAndSetRefPath()
|
||||
// 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 = getCoordsNode(path);
|
||||
@@ -2583,13 +2595,6 @@ void G4OpenInventorQtExaminerViewer::addEscapeCallback(void (*callback)())
|
||||
escapeCallback = callback;
|
||||
}
|
||||
|
||||
//void G4OpenInventorQtExaminerViewer::addEscapeCallback(
|
||||
// void (*callback)(void *), void * object)
|
||||
//{
|
||||
// escapeCallback = callback;
|
||||
// examinerObject = object;
|
||||
//}
|
||||
|
||||
|
||||
void G4OpenInventorQtExaminerViewer::sceneChangeCB(void* userData, SoSensor*)
|
||||
{
|
||||
@@ -3150,6 +3155,30 @@ void G4OpenInventorQtExaminerViewer::SwitchWireFrameCB(bool checked)
|
||||
}
|
||||
|
||||
|
||||
void G4OpenInventorQtExaminerViewer::SwitchAxesCB(bool checked)
|
||||
{
|
||||
// FWJ DEBUG
|
||||
// G4cout << "App Button: switchAxes CALLBACK" << G4endl;
|
||||
setFeedbackVisibility(checked);
|
||||
// if (checked) {
|
||||
// setFeedbackVisibility(TRUE);
|
||||
// } else {
|
||||
// setFeedbackVisibility(FALSE);
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
void G4OpenInventorQtExaminerViewer::DetachCB()
|
||||
{
|
||||
// FWJ DEBUG
|
||||
// G4cout << "App Button: detach CALLBACK" << G4endl;
|
||||
uiQt->GetViewerTabWidget()->removeTab(uiQtTabIndex);
|
||||
viewerParent->setParent(viewerParent2);
|
||||
removeAppPushButton(detachButton);
|
||||
show();
|
||||
}
|
||||
|
||||
|
||||
void G4OpenInventorQtExaminerViewer::DeleteBookmarkCB()
|
||||
{
|
||||
// FWJ DEBUG
|
||||
@@ -3442,59 +3471,70 @@ void G4OpenInventorQtExaminerViewer::sortViewPts(std::vector<std::string> sorted
|
||||
}
|
||||
|
||||
|
||||
// Emulating private method SoGuiFullViewerP::zoom()
|
||||
void
|
||||
G4OpenInventorQtExaminerViewer::zoom(const float diffvalue)
|
||||
{
|
||||
float multiplicator = float(std::exp(diffvalue));
|
||||
SoCamera *cam = getCamera();
|
||||
|
||||
if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
|
||||
const float oldfocaldist = cam->focalDistance.getValue();
|
||||
const float newfocaldist = oldfocaldist * multiplicator;
|
||||
|
||||
SbVec3f direction;
|
||||
cam->orientation.getValue().multVec(SbVec3f(0, 0, -1), direction);
|
||||
|
||||
const SbVec3f oldpos = cam->position.getValue();
|
||||
const SbVec3f newpos = oldpos + (newfocaldist - oldfocaldist) * -direction;
|
||||
cam->position = newpos;
|
||||
cam->focalDistance = newfocaldist;
|
||||
} else if (cam->isOfType(SoOrthographicCamera::getClassTypeId())) {
|
||||
SoOrthographicCamera * oc = (SoOrthographicCamera *)cam;
|
||||
oc->height = oc->height.getValue() * multiplicator;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Handling mouse and keyboard events
|
||||
|
||||
SbBool
|
||||
G4OpenInventorQtExaminerViewer::processSoEvent(const SoEvent* const ev)
|
||||
{
|
||||
|
||||
// FWJ DEBUG
|
||||
// G4cout << "processSoEvent ############" << ++processSoEventCount << G4endl;
|
||||
|
||||
SoCamera *cam = getCamera();
|
||||
const SoType type(ev->getTypeId());
|
||||
|
||||
if (type.isDerivedFrom(SoMouseButtonEvent::getClassTypeId())) {
|
||||
SoMouseButtonEvent * me = (SoMouseButtonEvent *) ev;
|
||||
|
||||
if (currentState == ANIMATION || currentState == REVERSED_ANIMATION
|
||||
|| currentState == PAUSED_ANIMATION) {
|
||||
switch (me->getButton()) {
|
||||
// if (currentState == ANIMATION || currentState == REVERSED_ANIMATION
|
||||
// || currentState == PAUSED_ANIMATION) {
|
||||
|
||||
switch (me->getButton()) {
|
||||
|
||||
case SoMouseButtonEvent::BUTTON4: // Scroll wheel up
|
||||
if (me->getState() == SoButtonEvent::DOWN) {
|
||||
if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
|
||||
float hAngle =
|
||||
((SoPerspectiveCamera *) cam)->heightAngle.getValue();
|
||||
((SoPerspectiveCamera *) cam)->heightAngle = hAngle
|
||||
+ 0.01f;
|
||||
return TRUE;
|
||||
} else if (cam->isOfType(SoOrthographicCamera::getClassTypeId())) {
|
||||
float height =
|
||||
((SoOrthographicCamera *) cam)->height.getValue();
|
||||
((SoOrthographicCamera *) cam)->height = height + 5;
|
||||
return TRUE;
|
||||
}
|
||||
// G4cout << "SCROLL WHEEL UP" << G4endl;
|
||||
zoom(-0.1f);
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
case SoMouseButtonEvent::BUTTON5: // Scroll wheel down
|
||||
if (me->getState() == SoButtonEvent::DOWN) {
|
||||
if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
|
||||
float hAngle =
|
||||
((SoPerspectiveCamera *) cam)->heightAngle.getValue();
|
||||
if (hAngle > 0.01)
|
||||
((SoPerspectiveCamera *) cam)->heightAngle = hAngle
|
||||
- 0.01f;
|
||||
return TRUE;
|
||||
} else if (cam->isOfType(SoOrthographicCamera::getClassTypeId())) {
|
||||
float height =
|
||||
((SoOrthographicCamera *) cam)->height.getValue();
|
||||
if (height > 5)
|
||||
((SoOrthographicCamera *) cam)->height = height - 5;
|
||||
return TRUE;
|
||||
}
|
||||
// G4cout << "SCROLL WHEEL DOWN" << G4endl;
|
||||
zoom(0.1f);
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
// }
|
||||
if (currentState == GENERAL) {
|
||||
|
||||
}
|
||||
|
||||
@@ -80,6 +80,11 @@ void G4OpenInventorQtViewer::Initialise()
|
||||
// parent << G4endl;
|
||||
|
||||
fViewer = new G4OpenInventorQtExaminerViewer(parent, fName, TRUE);
|
||||
|
||||
// FWJ tried this to replace sensors, but it misses some camera changes.
|
||||
// fGroupCameraSensor->detach();
|
||||
// fCameraSensor->detach();
|
||||
// fViewer->addFinishCallback(FinishCB);
|
||||
|
||||
auto UI = G4UImanager::GetUIpointer();
|
||||
auto uiQt = dynamic_cast<G4UIQt*>(UI->GetG4UIWindow());
|
||||
@@ -115,6 +120,7 @@ void G4OpenInventorQtViewer::Initialise()
|
||||
// }
|
||||
|
||||
fViewer->setSize(SbVec2s(width, height));
|
||||
fViewer->setOrigWindowSize(width, height);
|
||||
|
||||
// Add common menu items...
|
||||
|
||||
@@ -282,7 +288,6 @@ void G4OpenInventorQtViewer::SetView()
|
||||
(SbColor((float)b.GetRed(),(float)b.GetGreen(),(float)b.GetBlue()));
|
||||
}
|
||||
|
||||
|
||||
void G4OpenInventorQtViewer::ViewerRender()
|
||||
{
|
||||
if(!fViewer) return;
|
||||
@@ -295,6 +300,13 @@ SoCamera* G4OpenInventorQtViewer::GetCamera () {
|
||||
}
|
||||
|
||||
|
||||
// User interaction finished: update VPs
|
||||
//void G4OpenInventorQtViewer::FinishCB(void* data, SoQtViewer* viewer)
|
||||
//{
|
||||
// G4cout << "FINISHCB CALLED !!!!!" << G4endl;
|
||||
//}
|
||||
|
||||
|
||||
// File menu...
|
||||
|
||||
void G4OpenInventorQtViewer::FileWritePSCB()
|
||||
|
||||
@@ -24,6 +24,11 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
|
||||
// 03-MAY-2021 F.W. Jones: removed the camera sensor which is redundant
|
||||
// since the group node sensor receives all camera motion events and
|
||||
// can update the view parameters, irrespective of any changes to the
|
||||
// camera type.
|
||||
|
||||
#ifdef G4VIS_BUILD_OI_DRIVER
|
||||
|
||||
// this :
|
||||
@@ -62,7 +67,7 @@ G4OpenInventorViewer::G4OpenInventorViewer(
|
||||
,fSoImageWriter(0)
|
||||
,fGL2PSAction(0) //To be set be suclass.
|
||||
,fGroupCameraSensor(0)
|
||||
,fCameraSensor(0)
|
||||
//,fCameraSensor(0)
|
||||
{
|
||||
fVP.SetAutoRefresh(true);
|
||||
fDefaultVP.SetAutoRefresh(true);
|
||||
@@ -123,14 +128,15 @@ G4OpenInventorViewer::G4OpenInventorViewer(
|
||||
fGroupCameraSensor = new SoNodeSensor(GroupCameraSensorCB,this);
|
||||
fGroupCameraSensor->setPriority(0);//Needed in order to do getTriggerNode()
|
||||
fGroupCameraSensor->attach(group);
|
||||
|
||||
fCameraSensor = new SoNodeSensor(CameraSensorCB,this);
|
||||
fCameraSensor->setPriority(0);//Needed in order to do getTriggerNode()
|
||||
// FWJ Upgraded the group sensor so the camera sensor is not needed
|
||||
// fCameraSensor = new SoNodeSensor(CameraSensorCB,this);
|
||||
// fCameraSensor->setPriority(0);//Needed in order to do getTriggerNode()
|
||||
// fCameraSensor->attach(camera);
|
||||
}
|
||||
|
||||
G4OpenInventorViewer::~G4OpenInventorViewer () {
|
||||
fCameraSensor->detach();
|
||||
delete fCameraSensor;
|
||||
// fCameraSensor->detach();
|
||||
// delete fCameraSensor;
|
||||
fGroupCameraSensor->detach();
|
||||
delete fGroupCameraSensor;
|
||||
fSoSelection->unref();
|
||||
@@ -188,8 +194,10 @@ G4bool G4OpenInventorViewer::CompareForKernelVisit(G4ViewParameters& vp) {
|
||||
// If G4OpenInventor ever introduces VAMs, the following might need
|
||||
// changing to a complete comparison, i.e., remove ".size()". See
|
||||
// G4OpenGLStoredViewer::CompareForKernelVisit.
|
||||
(vp.GetVisAttributesModifiers().size() !=
|
||||
fVP.GetVisAttributesModifiers().size())
|
||||
(vp.GetVisAttributesModifiers() !=
|
||||
fVP.GetVisAttributesModifiers()) ||
|
||||
(vp.IsSpecialMeshRendering() !=
|
||||
fVP.IsSpecialMeshRendering())
|
||||
)
|
||||
return true;
|
||||
|
||||
@@ -218,6 +226,10 @@ G4bool G4OpenInventorViewer::CompareForKernelVisit(G4ViewParameters& vp) {
|
||||
(vp.GetExplodeFactor () != fVP.GetExplodeFactor ()))
|
||||
return true;
|
||||
|
||||
if (vp.IsSpecialMeshRendering() &&
|
||||
(vp.GetSpecialMeshVolumes() != fVP.GetSpecialMeshVolumes()))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -382,29 +394,51 @@ void G4OpenInventorViewer::ShowView () {
|
||||
fInteractorManager -> SecondaryLoop ();
|
||||
}
|
||||
|
||||
void G4OpenInventorViewer::GroupCameraSensorCB(void* aThis,SoSensor* aSensor){
|
||||
// FWJ This sensor now performs the fVP updates
|
||||
void G4OpenInventorViewer::GroupCameraSensorCB(void* aThis, SoSensor* aSensor)
|
||||
{
|
||||
G4OpenInventorViewer* This = (G4OpenInventorViewer*)aThis;
|
||||
|
||||
SoNode* node = ((SoNodeSensor*)aSensor)->getTriggerNode();
|
||||
//printf("debug : GroupCameraSensorCB %s\n",
|
||||
//node->getTypeId().getName().getString());
|
||||
// printf("debug : GroupCameraSensorCB %s\n",
|
||||
// node->getTypeId().getName().getString());
|
||||
|
||||
if(node->isOfType(SoCamera::getClassTypeId())) {
|
||||
SoCamera* camera = (SoCamera*)node;
|
||||
|
||||
// FWJ DEBUG
|
||||
// G4cout << " UPDATING fVP FROM CAMERA " << camera << G4endl;
|
||||
SbVec3f direction, up;
|
||||
lookedAt(camera, direction, up);
|
||||
This->fVP.SetViewpointDirection
|
||||
(G4Vector3D(-direction[0], -direction[1], -direction[2]));
|
||||
This->fVP.SetUpVector(G4Vector3D(up[0], up[1], up[2]));
|
||||
|
||||
SbVec3f pos = camera->position.getValue();
|
||||
SbVec3f target = pos + direction * camera->focalDistance.getValue();
|
||||
|
||||
This->fVP.SetCurrentTargetPoint(G4Point3D(target[0], target[1], target[2]));
|
||||
|
||||
// FWJ camera sensor no longer needed
|
||||
// Viewer had changed the camera type,
|
||||
// attach the fCameraSensor to the new camera.
|
||||
SoCamera* camera = (SoCamera*)node;
|
||||
This->fCameraSensor->detach();
|
||||
This->fCameraSensor->attach(camera);
|
||||
// FWJ DEBUG
|
||||
// G4cout << " SWITCHING TO CAMERA " << camera << G4endl;
|
||||
// This->fCameraSensor->detach();
|
||||
// This->fCameraSensor->attach(camera);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* FWJ This sensor is no longer needed
|
||||
void G4OpenInventorViewer::CameraSensorCB(void* aThis,SoSensor* aSensor) {
|
||||
G4OpenInventorViewer* This = (G4OpenInventorViewer*)aThis;
|
||||
|
||||
//printf("debug : CameraSensorCB\n");
|
||||
// printf("debug : CameraSensorCB\n");
|
||||
|
||||
SoNode* node = ((SoNodeSensor*)aSensor)->getTriggerNode();
|
||||
// printf("debug : CameraSensorCB %s\n",
|
||||
// node->getTypeId().getName().getString());
|
||||
|
||||
if(node->isOfType(SoCamera::getClassTypeId())) {
|
||||
SoCamera* camera = (SoCamera*)node;
|
||||
@@ -421,6 +455,7 @@ void G4OpenInventorViewer::CameraSensorCB(void* aThis,SoSensor* aSensor) {
|
||||
This->fVP.SetCurrentTargetPoint(G4Point3D(target[0],target[1],target[2]));
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
void G4OpenInventorViewer::SelectionCB(
|
||||
void* aThis
|
||||
|
||||
@@ -47,9 +47,10 @@
|
||||
#include "moc_G4SoQt.cpp"
|
||||
#endif
|
||||
|
||||
G4SoQt* G4SoQt::instance = NULL;
|
||||
G4SoQt* G4SoQt::instance = NULL;
|
||||
|
||||
static G4bool QtInited = FALSE;
|
||||
|
||||
static G4bool QtInited = FALSE;
|
||||
|
||||
/***************************************************************************/
|
||||
G4SoQt* G4SoQt::getInstance()
|
||||
@@ -58,17 +59,8 @@ G4SoQt* G4SoQt::getInstance()
|
||||
instance = new G4SoQt();
|
||||
}
|
||||
return instance;
|
||||
// return G4SoQt::getInstance(0, NULL, (char*)"Geant4");
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
//G4SoQt* G4SoQt::getInstance(int a_argn, char** a_args, char* a_class)
|
||||
//{
|
||||
// if (instance==NULL) {
|
||||
// instance = new G4SoQt();
|
||||
// }
|
||||
// return instance;
|
||||
//}
|
||||
|
||||
/***************************************************************************/
|
||||
G4SoQt::G4SoQt()
|
||||
@@ -140,20 +132,25 @@ void G4SoQt::FlushAndWaitExecution()
|
||||
// FWJ no, should be done in secondaryLoop()!
|
||||
// SoQt::mainLoop();
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
void G4SoQt::SecondaryLoop()
|
||||
{
|
||||
// FWJ DEBUG
|
||||
if (externalApp) return;
|
||||
|
||||
// FWJ DEBUG
|
||||
// G4cout <<
|
||||
// "ENTERING OIQT VIEWER SECONDARY LOOP" << G4endl;
|
||||
// else
|
||||
|
||||
G4cout <<
|
||||
"ENTERING OIQT VIEWER SECONDARY LOOP... PRESS E KEY TO EXIT" << G4endl;
|
||||
|
||||
SoQt::mainLoop();
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
void G4SoQt::ExitSecondaryLoop()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user