43#include <Inventor/nodes/SoSelection.h>
45#include <Inventor/Xt/SoXt.h>
48#include <Inventor/Xt/viewers/SoXtFlyViewer.h>
50#include <X11/StringDefs.h>
56#include <Xm/CascadeB.h>
57#include <Xm/RowColumn.h>
99 if(sgeometry.empty()) {
100 G4cout <<
"ERROR: Geometry string \""
102 <<
"\" is empty. Using \"600x600\"."
106 snprintf(s,32,
"%dx%d",width,height);
115 shellName +=
"_shell";
117 XtSetArg(args[0],XtNgeometry,XtNewString(sgeometry.c_str()));
118 XtSetArg(args[1],XtNborderWidth,0);
119 XtSetArg(args[2],XtNtitle,XtNewString(wName.c_str()));
120 fShell = XtAppCreateShell(shellName.c_str(),
"Inventor",
121 topLevelShellWidgetClass,
147 {Widget menu = fViewer->
getMenu();
149 AddButton(menu,
"Write PS (gl2ps)",PostScriptCbk);
150 AddButton(menu,
"Write PDF (gl2ps)", PDFCbk);
151 AddButton(menu,
"Write PS (pixmap)",PixmapPostScriptCbk);
152 AddButton(menu,
"Write IV",WriteInventorCbk);
153 AddButton(menu,
"Escape",EscapeCbk);}
155 {Widget menu = AddMenu(menuBar,
"Etc",
"Etc");
156 AddButton(menu,
"Erase detector",EraseDetectorCbk);
157 AddButton(menu,
"Erase event",EraseEventCbk);
158 AddButton(menu,
"Set solid",SetSolidCbk);
160 AddButton(menu,
"Set (G4) reduced wire frame",SetReducedWireFrameCbk);
161 AddButton(menu,
"Set (G4) full wire frame",SetFullWireFrameCbk);
162 AddButton(menu,
"Visible mothers + invisible daughters",SetPreviewCbk);
163 AddButton(menu,
"Visible mothers + visible daughters",SetPreviewAndFullCbk);
164 AddButton(menu,
"Update scene",UpdateSceneCbk);
165 AddButton(menu,
"Scene graph stats",SceneGraphStatisticsCbk);
168 {Widget menu = AddMenu(menuBar,
"Help",
"Help");
169 AddButton(menu,
"Controls",HelpCbk);}
173 XtSetArg(args[0],XmNtopAttachment ,XmATTACH_WIDGET);
174 XtSetArg(args[1],XmNtopWidget ,menuBar);
175 XtSetArg(args[2],XmNleftAttachment ,XmATTACH_FORM);
176 XtSetArg(args[3],XmNrightAttachment ,XmATTACH_FORM);
177 XtSetArg(args[4],XmNbottomAttachment,XmATTACH_FORM);
178 XtSetValues(fViewer->getWidget(),args,5);
180 fHelpForm = XmCreateFormDialog(fShell,(
char*)
"help",NULL,0);
181 XtSetArg(args[0],XmNleftAttachment ,XmATTACH_FORM);
182 XtSetArg(args[1],XmNrightAttachment ,XmATTACH_FORM);
183 XtSetArg(args[2],XmNbottomAttachment,XmATTACH_FORM);
184 Widget cancel = XmCreatePushButton(fHelpForm,(
char*)
"helpCancel",args,3);
185 XtAddCallback(cancel,XmNactivateCallback,HelpCancelCbk,(XtPointer)
this);
186 XtManageChild(cancel);
187 XtSetArg(args[0],XmNtopAttachment ,XmATTACH_FORM);
188 XtSetArg(args[1],XmNleftAttachment ,XmATTACH_FORM);
189 XtSetArg(args[2],XmNrightAttachment ,XmATTACH_FORM);
190 XtSetArg(args[3],XmNbottomAttachment,XmATTACH_WIDGET);
191 XtSetArg(args[4],XmNbottomWidget ,cancel);
192 fHelpText = XmCreateScrolledText(fHelpForm,(
char*)
"helpText",args,5);
193 XtManageChild(fHelpText);
199 if(str!=0) wName = str;
210 fViewer->setSize(SbVec2s(width,height));
213 const SbViewportRegion& vpRegion = fViewer->getViewportRegion();
220 fViewer->saveHomePosition();
221 fViewer->setTitle(
fName);
229 fViewer->setTransparencyType(SoGLRenderAction::SORTED_OBJECT_ADD);
235 fViewer->setSceneGraph(0);
240 if(fShell) XtDestroyWidget(fShell);
246 fViewer->saveHomePosition();
254 fViewer->setBackgroundColor
265 if(!fViewer)
return 0;
266 return fViewer->getCamera();
269Widget G4OpenInventorXtExtendedViewer::AddMenu(
276 Widget menu = XmCreatePulldownMenu(aMenuBar,(
char*)aName.c_str(),NULL,0);
280 XmStringLtoRCreate((
char*)aLabel.c_str(),(
char*)XmSTRING_DEFAULT_CHARSET);
281 XtSetArg (args[0],XmNlabelString,cps);
282 XtSetArg (args[1],XmNsubMenuId,menu);
283 Widget widget = XmCreateCascadeButton(aMenuBar,(
char*)aName.c_str(),args,2);
285 XtManageChild(widget);
288void G4OpenInventorXtExtendedViewer::AddButton (
291,XtCallbackProc aCallback
294 Widget widget = XmCreatePushButton(aMenu,(
char*)aLabel.c_str(),NULL,0);
295 XtManageChild(widget);
296 XtAddCallback(widget,XmNactivateCallback,aCallback,(XtPointer)
this);
299void G4OpenInventorXtExtendedViewer::HelpCancelCbk(
300 Widget,XtPointer aData,XtPointer) {
302 XtUnmanageChild(This->fHelpForm);
310void G4OpenInventorXtExtendedViewer::EscapeCbk(
311 Widget,XtPointer aData,XtPointer) {
317void G4OpenInventorXtExtendedViewer::EscapeFromKeyboardCbk(
void* o) {
322void G4OpenInventorXtExtendedViewer::PostScriptCbk(
323 Widget,XtPointer aData,XtPointer) {
326 SbBool superimpState =
327 This->fViewer->getSuperimpositionEnabled(This->fViewer->superimposition);
328 This->fViewer->setSuperimpositionEnabled(This->fViewer->superimposition,
332 This->fViewer->setSuperimpositionEnabled(This->fViewer->superimposition,
335void G4OpenInventorXtExtendedViewer::PDFCbk(
336 Widget,XtPointer aData,XtPointer) {
339 SbBool superimpState =
340 This->fViewer->getSuperimpositionEnabled(This->fViewer->superimposition);
341 This->fViewer->setSuperimpositionEnabled(This->fViewer->superimposition,
345 This->fViewer->setSuperimpositionEnabled(This->fViewer->superimposition,
349void G4OpenInventorXtExtendedViewer::PixmapPostScriptCbk(
350 Widget,XtPointer aData,XtPointer) {
355void G4OpenInventorXtExtendedViewer::SceneGraphStatisticsCbk(
356 Widget,XtPointer aData,XtPointer) {
361void G4OpenInventorXtExtendedViewer::WriteInventorCbk(
362 Widget,XtPointer aData,XtPointer) {
367void G4OpenInventorXtExtendedViewer::EraseDetectorCbk(
368 Widget,XtPointer aData,XtPointer) {
373void G4OpenInventorXtExtendedViewer::EraseEventCbk(
374 Widget,XtPointer aData,XtPointer) {
379void G4OpenInventorXtExtendedViewer::SetSolidCbk(
380 Widget,XtPointer aData,XtPointer) {
385void G4OpenInventorXtExtendedViewer::SetWireFrameCbk(
386 Widget,XtPointer aData,XtPointer) {
391void G4OpenInventorXtExtendedViewer::SetReducedWireFrameCbk(
392 Widget,XtPointer aData,XtPointer) {
397void G4OpenInventorXtExtendedViewer::SetFullWireFrameCbk(
398 Widget,XtPointer aData,XtPointer) {
403void G4OpenInventorXtExtendedViewer::UpdateSceneCbk(
404 Widget,XtPointer aData,XtPointer) {
409void G4OpenInventorXtExtendedViewer::SetPreviewCbk(
410 Widget,XtPointer aData,XtPointer) {
415void G4OpenInventorXtExtendedViewer::SetPreviewAndFullCbk(
416 Widget,XtPointer aData,XtPointer) {
421void G4OpenInventorXtExtendedViewer::HelpCbk(
422 Widget,XtPointer aData,XtPointer) {
424 XtManageChild(This->fHelpForm);
425 XmTextSetString(This->fHelpText,(
char*)This->
Help().c_str());
G4GLOB_DLL std::ostream G4cout
G4double GetGreen() const
G4String Help(const G4String &topic="controls")
void WriteInventor(const G4String &file="g4out.iv")
SoSelection * fSoSelection
void WritePostScript(const G4String &file="g4out.ps")
void Escape()
Menu items callbacks /////////////////////////////////////////////////////.
void SceneGraphStatistics()
G4VInteractorManager * fInteractorManager
void WritePixmapPostScript(const G4String &file="g4out.ps")
static void SelectionCB(void *, SoPath *)
void WritePDF(const G4String &file="g4out.pdf")
void SetReducedWireFrame(bool)
Geant4_SoGL2PSAction * fGL2PSAction
void addEscapeCallback(void(*cb)(void *), void *)
virtual void ViewerRender()
virtual SoCamera * GetCamera()
virtual ~G4OpenInventorXtExtendedViewer()
virtual void FinishView()
G4OpenInventorXtExtendedViewer(G4OpenInventorSceneHandler &scene, const G4String &name="")
void SetCreatedInteractor(G4Interactor)
virtual void FlushAndWaitExecution()=0
G4Interactor GetParentInteractor()
char * GetCreationString()
void RemoveShell(G4Interactor)
void AddShell(G4Interactor)
const G4String & GetXGeometryString() const
unsigned int GetWindowSizeHintX() const
const G4Colour & GetBackgroundColour() const
static Verbosity GetVerbosity()