Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4OpenInventorXtExtendedViewer Class Reference

#include <G4OpenInventorXtExtendedViewer.hh>

+ Inheritance diagram for G4OpenInventorXtExtendedViewer:

Public Member Functions

virtual void FinishView ()
 
virtual void SetView ()
 
 G4OpenInventorXtExtendedViewer (G4OpenInventorSceneHandler &scene, const G4String &name="")
 
void Initialise ()
 
virtual ~G4OpenInventorXtExtendedViewer ()
 
- Public Member Functions inherited from G4OpenInventorViewer
virtual void DrawView ()
 
virtual void ShowView ()
 
virtual void ClearView ()
 
virtual void KernelVisitDecision ()
 
 G4OpenInventorViewer (G4OpenInventorSceneHandler &scene, const G4String &name="")
 
virtual ~G4OpenInventorViewer ()
 
- Public Member Functions inherited from G4VViewer
 G4VViewer (G4VSceneHandler &, G4int id, const G4String &name="")
 
virtual ~G4VViewer ()
 
virtual void ResetView ()
 
void RefreshView ()
 
std::vector< G4ThreeVectorComputeFlyThrough (G4Vector3D *)
 
SceneTreeSceneAccessSceneTreeScene ()
 
G4SceneTreeItemAccessSceneTree ()
 
void UpdateGUISceneTree ()
 
const G4StringGetName () const
 
const G4StringGetShortName () const
 
void SetName (const G4String &)
 
G4int GetViewId () const
 
G4VSceneHandlerGetSceneHandler () const
 
const G4ViewParametersGetViewParameters () const
 
const G4ViewParametersGetDefaultViewParameters () const
 
G4double GetKernelVisitElapsedTimeSeconds () const
 
virtual const std::vector< G4ModelingParameters::VisAttributesModifier > * GetPrivateVisAttributesModifiers () const
 
void SetViewParameters (const G4ViewParameters &vp)
 
void SetDefaultViewParameters (const G4ViewParameters &vp)
 
const G4VisAttributesGetApplicableVisAttributes (const G4VisAttributes *) const
 
void SetNeedKernelVisit (G4bool need)
 
void NeedKernelVisit ()
 
void ProcessView ()
 

Protected Member Functions

virtual void ViewerRender ()
 
virtual SoCamera * GetCamera ()
 
- Protected Member Functions inherited from G4OpenInventorViewer
void Escape ()
 Menu items callbacks /////////////////////////////////////////////////////.
 
void WritePostScript (const G4String &file="g4out.ps")
 
void WritePDF (const G4String &file="g4out.pdf")
 
void WritePixmapPostScript (const G4String &file="g4out.ps")
 
void WriteInventor (const G4String &file="g4out.iv")
 
void SceneGraphStatistics ()
 
void EraseDetector ()
 
void EraseEvent ()
 
void SetPreviewAndFull ()
 
void SetPreview ()
 
void SetSolid ()
 
void SetWireFrame ()
 
void SetReducedWireFrame (bool)
 
void UpdateScene ()
 
G4String Help (const G4String &topic="controls")
 
- Protected Member Functions inherited from G4VViewer
void SetTouchable (const std::vector< G4PhysicalVolumeModel::G4PhysicalVolumeNodeID > &fullPath)
 
void TouchableSetVisibility (const std::vector< G4PhysicalVolumeModel::G4PhysicalVolumeNodeID > &fullPath, G4bool visibility)
 
void TouchableSetColour (const std::vector< G4PhysicalVolumeModel::G4PhysicalVolumeNodeID > &fullPath, const G4Colour &)
 

Additional Inherited Members

- Static Protected Member Functions inherited from G4OpenInventorViewer
static void SelectionCB (void *, SoPath *)
 
- Protected Attributes inherited from G4OpenInventorViewer
G4OpenInventorSceneHandlerfG4OpenInventorSceneHandler
 
G4VInteractorManagerfInteractorManager
 
SoSelection * fSoSelection
 
Geant4_SoImageWriter * fSoImageWriter
 
Geant4_SoGL2PSAction * fGL2PSAction
 
SoNodeSensor * fGroupCameraSensor
 
- Protected Attributes inherited from G4VViewer
G4VSceneHandlerfSceneHandler
 
G4int fViewId
 
G4String fName
 
G4String fShortName
 
G4ViewParameters fVP
 
G4ViewParameters fDefaultVP
 
G4double fKernelVisitElapsedTimeSeconds = 999.
 
SceneTreeScene fSceneTreeScene
 
G4SceneTreeItem fSceneTree
 
G4bool fNeedKernelVisit
 

Detailed Description

Definition at line 43 of file G4OpenInventorXtExtendedViewer.hh.

Constructor & Destructor Documentation

◆ G4OpenInventorXtExtendedViewer()

G4OpenInventorXtExtendedViewer::G4OpenInventorXtExtendedViewer ( G4OpenInventorSceneHandler & scene,
const G4String & name = "" )

Definition at line 71 of file G4OpenInventorXtExtendedViewer.cc.

74:G4OpenInventorViewer (sceneHandler, name)
75,fShell(0)
76,fViewer(0)
77,fHelpForm(0)
78,fHelpText(0)
79{
81 G4cout << "Window name: " << fName << G4endl;
82}
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
G4OpenInventorViewer(G4OpenInventorSceneHandler &scene, const G4String &name="")
G4String fName
Definition G4VViewer.hh:255
static Verbosity GetVerbosity()

◆ ~G4OpenInventorXtExtendedViewer()

G4OpenInventorXtExtendedViewer::~G4OpenInventorXtExtendedViewer ( )
virtual

Definition at line 232 of file G4OpenInventorXtExtendedViewer.cc.

232 {
233 if(fShell) fInteractorManager->RemoveShell(fShell);
234 if(fViewer) {
235 fViewer->setSceneGraph(0);
236 //FIXME : SGI : the below "delete" block things.
237 //FIXME : CoinXt : the below "delete" crashe in ~SoXtRenderArea.
238 //FIXME : delete fViewer;
239 }
240 if(fShell) XtDestroyWidget(fShell);
241}
G4VInteractorManager * fInteractorManager
void RemoveShell(G4Interactor)

Member Function Documentation

◆ FinishView()

void G4OpenInventorXtExtendedViewer::FinishView ( void )
virtual

Reimplemented from G4VViewer.

Definition at line 243 of file G4OpenInventorXtExtendedViewer.cc.

243 {
244 if(!fViewer) return;
245 fViewer->viewAll();
246 fViewer->saveHomePosition();
247}

◆ GetCamera()

SoCamera * G4OpenInventorXtExtendedViewer::GetCamera ( )
protectedvirtual

Implements G4OpenInventorViewer.

Definition at line 264 of file G4OpenInventorXtExtendedViewer.cc.

264 {
265 if(!fViewer) return 0;
266 return fViewer->getCamera();
267}

◆ Initialise()

void G4OpenInventorXtExtendedViewer::Initialise ( )
virtual

Reimplemented from G4VViewer.

Definition at line 85 of file G4OpenInventorXtExtendedViewer.cc.

85 {
86
87 G4String wName = fName;
88
89 Widget parent = (Widget)fInteractorManager->GetParentInteractor ();
90 // G4cout << "DEBUG G4OpenInventorXtExtendedViewer: parent = " << parent << G4endl;
91 int width = 600;
92 int height = 600;
93
94 if(!parent) {
95 // Check if user has specified an X-Windows-type geometry string...
96 char s[32];
97
98 G4String sgeometry = fVP.GetXGeometryString();
99 if(sgeometry.empty()) {
100 G4cout << "ERROR: Geometry string \""
101 << sgeometry
102 << "\" is empty. Using \"600x600\"."
103 << G4endl;
104 width = 600;
105 height = 600;
106 snprintf(s,32,"%dx%d",width,height);
107 sgeometry = s;
108 } else {
109 width = fVP.GetWindowSizeHintX();
110 height = fVP.GetWindowSizeHintX();
111 }
112
113 //Create a shell window :
114 G4String shellName = wName;
115 shellName += "_shell";
116 Arg args[10];
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,
122 SoXt::getDisplay(),
123 args,3);
124
125 // G4cout << "DEBUG CREATING THE VIEWER WITH CREATED SHELL = " << fShell << G4endl;
126 fViewer = new G4OpenInventorXtExaminerViewer(fShell, wName.c_str(), TRUE);
127 fViewer->addEscapeCallback(EscapeFromKeyboardCbk, (void *)this);
128
129 // FWJ (viewpoints don't work with this!)
130 // fViewer->setAutoClipping((SbBool)0);
131
132 //XtSetArg(args[0],XmNtopAttachment ,XmATTACH_FORM);
133 //XtSetArg(args[1],XmNleftAttachment ,XmATTACH_FORM);
134 //XtSetArg(args[2],XmNrightAttachment ,XmATTACH_FORM);
135 //XtSetArg(args[3],XmNbottomAttachment,XmATTACH_FORM);
136 //Widget form = XmCreateForm (fShell,(char*)"form",args,4);
137 //XtManageChild (form);
138
139 Widget menuBar = fViewer->getMenuBar();
140
141 //XtSetArg(args[0],XmNtopAttachment ,XmATTACH_FORM);
142 //XtSetArg(args[1],XmNleftAttachment ,XmATTACH_FORM);
143 //XtSetArg(args[2],XmNrightAttachment ,XmATTACH_FORM);
144 //Widget menuBar = XmCreateMenuBar (form,(char*)"menuBar",args,3);
145 //XtManageChild(menuBar);
146
147 {Widget menu = fViewer->getMenu();
148 //{Widget menu = AddMenu(menuBar,"File","File");
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);}
154
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);
159/* AddButton(menu,"Set (G4) wire frame",SetWireFrameCbk);*/
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);
166 }
167
168 {Widget menu = AddMenu(menuBar,"Help","Help");
169 AddButton(menu,"Controls",HelpCbk);}
170
171 //fViewer = new SoXtExaminerViewer(form,wName.c_str(),TRUE);
172
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);
179
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);
194
196
197 } else {
199 if(str!=0) wName = str;
200 // G4cout << "DEBUG CREATING THE VIEWER WITH parent = " << parent << G4endl;
201 fViewer = new G4OpenInventorXtExaminerViewer(parent, wName.c_str(), TRUE);
202 }
203
204 // Use our own SelectionCB for the Xt viewer to allow for abbreviated output
205 // when picking a trajectory
206 fSoSelection->removeSelectionCallback(G4OpenInventorViewer::SelectionCB,
207 this);
208// fSoSelection->addSelectionCallback(SelectionCB, this);
209
210 fViewer->setSize(SbVec2s(width,height));
211
212 // Have a GL2PS render action :
213 const SbViewportRegion& vpRegion = fViewer->getViewportRegion();
214 fGL2PSAction = new SoGL2PSAction(vpRegion);
215 fViewer->setGLRenderAction(fGL2PSAction);
216
217 // Else :
218 fViewer->setSceneGraph(fSoSelection);
219 fViewer->viewAll();
220 fViewer->saveHomePosition();
221 fViewer->setTitle(fName);
222 fViewer->show();
223 if(fShell) {
224 SoXt::show(fShell);
226 }
227 fInteractorManager->SetCreatedInteractor (fViewer -> getWidget());
228 // TJR added:
229 fViewer->setTransparencyType(SoGLRenderAction::SORTED_OBJECT_ADD);
230}
#define SoGL2PSAction
static void SelectionCB(void *, SoPath *)
Geant4_SoGL2PSAction * fGL2PSAction
void addEscapeCallback(void(*cb)(void *), void *)
void SetCreatedInteractor(G4Interactor)
virtual void FlushAndWaitExecution()=0
void AddShell(G4Interactor)
G4ViewParameters fVP
Definition G4VViewer.hh:257
const G4String & GetXGeometryString() const
unsigned int GetWindowSizeHintX() const
#define TRUE
Definition globals.hh:41

◆ SetView()

void G4OpenInventorXtExtendedViewer::SetView ( )
virtual

Reimplemented from G4OpenInventorViewer.

Definition at line 249 of file G4OpenInventorXtExtendedViewer.cc.

249 {
251 if(!fViewer) return;
252 // Background.
254 fViewer->setBackgroundColor
255 (SbColor((float)b.GetRed(),(float)b.GetGreen(),(float)b.GetBlue()));
256}
G4double GetBlue() const
Definition G4Colour.hh:154
G4double GetRed() const
Definition G4Colour.hh:152
G4double GetGreen() const
Definition G4Colour.hh:153
const G4Colour & GetBackgroundColour() const

◆ ViewerRender()

void G4OpenInventorXtExtendedViewer::ViewerRender ( )
protectedvirtual

Implements G4OpenInventorViewer.

Definition at line 259 of file G4OpenInventorXtExtendedViewer.cc.

259 {
260 if(!fViewer) return;
261 fViewer->render();
262}

The documentation for this class was generated from the following files: