294{
296
298 if (pViewer == nullptr) {
299 G4cout <<
"G4VtkMessenger::SetNewValue: No current viewer.\n"
300 <<
"\"/vis/open\", or similar, to get one." <<
G4endl;
301 return;
302 }
303
304 auto* pVtkViewer =
dynamic_cast<G4VtkViewer*
>(pViewer);
305 if (pVtkViewer == nullptr) {
306 G4cout <<
"G4VtkMessenger::SetNewValue: Current viewer is not of type VTK. \n"
307 <<
"(It is \"" << pViewer->
GetName() <<
"\".)\n"
308 <<
"Use \"/vis/viewer/select\" or \"/vis/open\"." <<
G4endl;
309 return;
310 }
311
312 if (command == fpCommandClearNonG4) {
315
317 }
318 else if (command == fpCommandExport) {
320
321 std::istringstream iss(newValue);
322 iss >> format >>
name;
323
324 if (format == "jpg" || format == "tiff" || format == "png" || format == "bmp" || format == "pnm"
325 || format == "ps")
326 pVtkViewer->ExportScreenShot(name, format);
327 else if (format == "obj")
328 pVtkViewer->ExportOBJScene(name);
329 else if (format == "vrml")
330 pVtkViewer->ExportVRMLScene(name);
331 else if (format == "vtp")
332 pVtkViewer->ExportVTPScene(name);
333 else if (format == "gltf")
334 pVtkViewer->ExportGLTFScene(name);
335 else
336 G4cout <<
"Unknown /vis/vtk/export file format" <<
G4endl;
337 }
338 else if (command == fpCommandExportCutter) {
339 std::istringstream iss(newValue);
340
342 iss >> fileName;
343 pVtkViewer->ExportVTPCutter(fileName);
344 }
345 else if (command == fpCommandWarnings) {
347 vtkObject::GlobalWarningDisplayOn();
348 }
349 else {
350 vtkObject::GlobalWarningDisplayOff();
351 }
352 }
353 else if (command == fpCommandHUD) {
355 pVtkViewer->EnableHUD();
356 }
357 else {
358 pVtkViewer->DisableHUD();
359 }
360 }
361 else if (command == fpCameraOrientation) {
364 pVtkViewer->EnableCameraOrientationWidget();
365 }
366 else {
367 pVtkViewer->DisableCameraOrientationWidget();
368 }
369 }
370 else if (command == fpCommandDebugPrint) {
371 pVtkViewer->Print();
372 }
373 else if (command == fpCommandPolyhedronPipeline) {
375
376 std::istringstream iss(newValue);
377
379 iss >> pipelineType;
380
381 pVtkViewer->SetPolyhedronPipeline(pipelineType);
382 }
383 else if (command == fpCommandImageOverlay) {
385
387 G4double imageBottomLeft[2] = {0, 0};
389 G4double worldBottomLeft[2] = {0, 0};
392 G4double translation[3] = {0, 0, 0};
394
395 std::istringstream iss(newValue);
396
397 iss >> fileName >> imageBottomLeft[0] >> imageBottomLeft[1] >> imageTopRight[0]
398 >> imageTopRight[1] >> worldBottomLeft[0] >> worldBottomLeft[1] >> worldTopRight[0]
399 >> worldTopRight[1] >> rotation[0] >> rotation[1] >> rotation[2] >> translation[0]
400 >> translation[1] >> translation[2] >>
alpha;
401
402 pVtkViewer->AddImageOverlay(fileName, alpha, imageBottomLeft, worldBottomLeft, imageTopRight,
403 worldTopRight, rotation, translation);
404 }
405 else if (command == fpCommandGeometryOverlay) {
407
412 G4double colour[3] = {0.5, 0.5, 0.5};
415
416 std::istringstream iss(newValue);
417
418 iss >> fileName
419 >> scale[0] >> scale[1] >> scale[2]
420 >> rotation[0] >> rotation[1] >> rotation[2]
421 >> translation[0] >> translation[1] >> translation[2]
422 >>
alpha >> representation;
423
425 pVtkViewer->AddGeometryOverlay(fileName, colour, alpha, representation,
426 scale, rotation, translation);
427 }
428
429
430 else if (command == fpCommandClipper) {
431 pVtkViewer->EnableClipper(
G4Plane3D(),
true);
432 }
433 else if (command == fpCommandCutter) {
434 pVtkViewer->EnableCutter(
G4Plane3D(),
true);
435 }
436 else if (command == fpCommandShadow) {
437 pVtkViewer->EnableShadows();
438 }
439 else if (command == fpCommandInteractorStart) {
440 pVtkViewer->StartInteractor();
441 }
442}
HepGeom::Plane3D< G4double > G4Plane3D
G4GLOB_DLL std::ostream G4cout
static G4bool ConvertToBool(const char *st)
const G4String & GetName() const
G4VSceneHandler * GetSceneHandler() const
G4VViewer * GetCurrentViewer() const
static G4VisManager * GetInstance()
G4VtkStore & GetTransientStore()
const char * name(G4int ptype)