Import Geant4 11.0.0 source tree
This commit is contained in:
committed by
Ben Morgan
parent
6399a014b6
commit
80e2389dd8
@@ -0,0 +1,144 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// Guy Barrand 12 October 2021
|
||||
//
|
||||
|
||||
#include "G4PlotterManager.hh"
|
||||
#include "G4ios.hh"
|
||||
|
||||
#include <tools/forit>
|
||||
#include <tools/tokenize>
|
||||
|
||||
#include <tools/xml/xml_style> //it uses expat.
|
||||
|
||||
G4PlotterManager& G4PlotterManager::GetInstance () {
|
||||
static G4PlotterManager s_instance;
|
||||
return s_instance;
|
||||
}
|
||||
|
||||
G4PlotterManager::G4PlotterManager():fMessenger(0) {
|
||||
fMessenger = new Messenger(*this);
|
||||
}
|
||||
|
||||
G4PlotterManager::~G4PlotterManager() {
|
||||
delete fMessenger;
|
||||
}
|
||||
|
||||
G4Plotter& G4PlotterManager::GetPlotter(const G4String& a_name) {
|
||||
tools_vforit(NamedPlotter,fPlotters,it) {
|
||||
if((*it).first==a_name) {
|
||||
return (*it).second;
|
||||
}
|
||||
}
|
||||
fPlotters.push_back(NamedPlotter(a_name,G4Plotter()));
|
||||
return fPlotters.back().second;
|
||||
}
|
||||
|
||||
void G4PlotterManager::List() const {
|
||||
tools_vforcit(NamedPlotter,fPlotters,it) {
|
||||
G4cout << (*it).first << G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
/// styles: //////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
void G4PlotterManager::ListStyles() const {
|
||||
tools_vforcit(NamedStyle,fStyles,it) {
|
||||
G4cout << (*it).first << G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
G4PlotterManager::Style* G4PlotterManager::FindStyle(const G4String& a_name) {
|
||||
tools_vforit(NamedStyle,fStyles,it){
|
||||
if((*it).first==a_name) return &((*it).second);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void G4PlotterManager::SelectStyle(const G4String& a_name) {
|
||||
if(!FindStyle(a_name)) {
|
||||
fStyles.push_back(NamedStyle(a_name,Style()));
|
||||
}
|
||||
fCurrentStyle = a_name;
|
||||
}
|
||||
|
||||
void G4PlotterManager::RemoveStyle(const G4String& a_name) {
|
||||
tools_vforit(NamedStyle,fStyles,it) {
|
||||
if((*it).first==a_name) {
|
||||
fStyles.erase(it);
|
||||
if(fCurrentStyle==a_name) fCurrentStyle.clear();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void G4PlotterManager::PrintStyle(const G4String& a_name) const {
|
||||
tools_vforcit(NamedStyle,fStyles,it) {
|
||||
if((*it).first==a_name) {
|
||||
G4cout << (*it).first << ":" << G4endl;
|
||||
tools_vforcit(StyleItem,(*it).second,its) {
|
||||
G4cout << " " << (*its).first << " " << (*its).second << G4endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void G4PlotterManager::AddStyleParameter(const G4String& a_parameter,const G4String& a_value) {
|
||||
Style* _style = FindStyle(fCurrentStyle);
|
||||
if(!_style) {
|
||||
G4cout << "G4PlotterManager::AddStyleParameter: style " << fCurrentStyle << " not found." << G4endl;
|
||||
return;
|
||||
}
|
||||
tools_vforit(StyleItem,(*_style),it) {
|
||||
if((*it).first==a_parameter) {
|
||||
(*it).second = a_value;
|
||||
return;
|
||||
}
|
||||
}
|
||||
_style->push_back(StyleItem(a_parameter,a_value));
|
||||
}
|
||||
|
||||
void G4PlotterManager::Messenger::SetNewValue(G4UIcommand* a_cmd,G4String a_value) {
|
||||
std::vector<std::string> args;
|
||||
tools::double_quotes_tokenize(a_value,args);
|
||||
if(args.size()!=a_cmd->GetParameterEntries()) return;
|
||||
if(a_cmd==select_style) {
|
||||
fPlotterManager.SelectStyle(args[0]);
|
||||
} else if(a_cmd==add_style_parameter) {
|
||||
fPlotterManager.AddStyleParameter(args[0],args[1]);
|
||||
} else if(a_cmd==remove_style) {
|
||||
fPlotterManager.RemoveStyle(args[0]);
|
||||
} else if(a_cmd==list_styles) {
|
||||
G4cout << "default (embedded)." << G4endl;
|
||||
G4cout << "ROOT_default (embedded)." << G4endl;
|
||||
G4cout << "hippodraw (embedded)." << G4endl;
|
||||
fPlotterManager.ListStyles();
|
||||
} else if(a_cmd==print_style) {
|
||||
fPlotterManager.PrintStyle(args[0]);
|
||||
}
|
||||
}
|
||||
@@ -47,53 +47,6 @@ G4Scene::G4Scene (const G4String& name):
|
||||
|
||||
G4Scene::~G4Scene () {}
|
||||
|
||||
G4bool G4Scene::AddRunDurationModel (G4VModel* pModel, G4bool warn)
|
||||
{
|
||||
std::vector<Model>::const_iterator i;
|
||||
for (i = fRunDurationModelList.begin ();
|
||||
i != fRunDurationModelList.end (); ++i) {
|
||||
if (pModel -> GetGlobalDescription () ==
|
||||
i->fpModel->GetGlobalDescription ()) break;
|
||||
}
|
||||
if (i != fRunDurationModelList.end ()) {
|
||||
if (warn) {
|
||||
G4cout << "G4Scene::AddRunDurationModel: model \""
|
||||
<< pModel -> GetGlobalDescription ()
|
||||
<< "\"\n is already in the run-duration list of scene \""
|
||||
<< fName
|
||||
<< "\"."
|
||||
<< G4endl;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
for (i = fRunDurationModelList.begin ();
|
||||
i != fRunDurationModelList.end (); ++i) {
|
||||
if (pModel -> GetGlobalTag () ==
|
||||
i->fpModel->GetGlobalTag ()) break;
|
||||
}
|
||||
if (i != fRunDurationModelList.end ()) {
|
||||
if (warn) {
|
||||
G4cout
|
||||
<< "G4Scene::AddRunDurationModel: The tag \""
|
||||
<< pModel->GetGlobalTag()
|
||||
<< "\"\n duplicates one already in scene \""
|
||||
<< fName
|
||||
<<
|
||||
"\".\n This may be intended but if not, you may inspect the scene with"
|
||||
"\n \"/vis/scene/list\" and deactivate unwanted models with"
|
||||
"\n \"/vis/scene/activateModel\". Or create a new scene."
|
||||
<< G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
fRunDurationModelList.push_back (Model(pModel));
|
||||
|
||||
CalculateExtent ();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
namespace {
|
||||
void PrintInvalidModel(const G4VModel* model)
|
||||
{
|
||||
@@ -113,8 +66,8 @@ void G4Scene::CalculateExtent ()
|
||||
for (size_t i = 0; i < fRunDurationModelList.size(); i++) {
|
||||
if (fRunDurationModelList[i].fActive) {
|
||||
G4VModel* model = fRunDurationModelList[i].fpModel;
|
||||
if (model -> Validate()) { // Validates and also recomputes extent.
|
||||
const G4VisExtent& thisExtent = model -> GetTransformedExtent ();
|
||||
if (model -> Validate()) {
|
||||
const G4VisExtent& thisExtent = model -> GetExtent ();
|
||||
if (thisExtent != G4VisExtent::GetNullExtent()) {
|
||||
boundingExtentScene.AccrueBoundingExtent(thisExtent);
|
||||
}
|
||||
@@ -127,8 +80,8 @@ void G4Scene::CalculateExtent ()
|
||||
for (size_t i = 0; i < fEndOfEventModelList.size(); i++) {
|
||||
if (fEndOfEventModelList[i].fActive) {
|
||||
G4VModel* model = fEndOfEventModelList[i].fpModel;
|
||||
if (model -> Validate()) { // Validates and also recomputes extent.
|
||||
const G4VisExtent& thisExtent = model -> GetTransformedExtent ();
|
||||
if (model -> Validate()) {
|
||||
const G4VisExtent& thisExtent = model -> GetExtent ();
|
||||
if (thisExtent != G4VisExtent::GetNullExtent()) {
|
||||
boundingExtentScene.AccrueBoundingExtent(thisExtent);
|
||||
}
|
||||
@@ -141,8 +94,8 @@ void G4Scene::CalculateExtent ()
|
||||
for (size_t i = 0; i < fEndOfRunModelList.size(); i++) {
|
||||
if (fEndOfRunModelList[i].fActive) {
|
||||
G4VModel* model = fEndOfRunModelList[i].fpModel;
|
||||
if (model -> Validate()) { // Validates and also recomputes extent.
|
||||
const G4VisExtent& thisExtent = model -> GetTransformedExtent ();
|
||||
if (model -> Validate()) {
|
||||
const G4VisExtent& thisExtent = model -> GetExtent ();
|
||||
if (thisExtent != G4VisExtent::GetNullExtent()) {
|
||||
boundingExtentScene.AccrueBoundingExtent(thisExtent);
|
||||
}
|
||||
@@ -202,6 +155,30 @@ G4bool G4Scene::AddWorldIfEmpty (G4bool warn) {
|
||||
return successful;
|
||||
}
|
||||
|
||||
G4bool G4Scene::AddRunDurationModel (G4VModel* pModel, G4bool warn)
|
||||
{
|
||||
std::vector<Model>::const_iterator i;
|
||||
for (i = fRunDurationModelList.begin ();
|
||||
i != fRunDurationModelList.end (); ++i) {
|
||||
if (pModel -> GetGlobalDescription () ==
|
||||
i->fpModel->GetGlobalDescription ()) break;
|
||||
}
|
||||
if (i != fRunDurationModelList.end ()) {
|
||||
if (warn) {
|
||||
G4cout << "G4Scene::AddRunDurationModel: model \""
|
||||
<< pModel -> GetGlobalDescription ()
|
||||
<< "\"\n is already in the run-duration list of scene \""
|
||||
<< fName
|
||||
<< "\"."
|
||||
<< G4endl;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
fRunDurationModelList.push_back (Model(pModel));
|
||||
CalculateExtent ();
|
||||
return true;
|
||||
}
|
||||
|
||||
G4bool G4Scene::AddEndOfEventModel (G4VModel* pModel, G4bool warn) {
|
||||
G4int i, nModels = fEndOfEventModelList.size ();
|
||||
for (i = 0; i < nModels; i++) {
|
||||
|
||||
@@ -43,7 +43,6 @@
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4Material.hh"
|
||||
#include "G4Polyline.hh"
|
||||
#include "G4Scale.hh"
|
||||
#include "G4Text.hh"
|
||||
#include "G4Circle.hh"
|
||||
#include "G4Square.hh"
|
||||
@@ -456,110 +455,6 @@ void G4VSceneHandler::AddViewerToList (G4VViewer* pViewer) {
|
||||
fViewerList.push_back (pViewer);
|
||||
}
|
||||
|
||||
void G4VSceneHandler::AddPrimitive (const G4Scale& scale) {
|
||||
|
||||
const G4double margin(0.01);
|
||||
// Fractional margin - ensures scale is comfortably inside viewing
|
||||
// volume.
|
||||
const G4double oneMinusMargin (1. - margin);
|
||||
|
||||
const G4VisExtent& sceneExtent = fpScene->GetExtent();
|
||||
|
||||
// Useful constants...
|
||||
const G4double length(scale.GetLength());
|
||||
const G4double halfLength(length / 2.);
|
||||
const G4double tickLength(length / 20.);
|
||||
const G4double piBy2(halfpi);
|
||||
|
||||
// Get size of scene...
|
||||
const G4double xmin = sceneExtent.GetXmin();
|
||||
const G4double xmax = sceneExtent.GetXmax();
|
||||
const G4double ymin = sceneExtent.GetYmin();
|
||||
const G4double ymax = sceneExtent.GetYmax();
|
||||
const G4double zmin = sceneExtent.GetZmin();
|
||||
const G4double zmax = sceneExtent.GetZmax();
|
||||
|
||||
// Create (empty) polylines having the same vis attributes...
|
||||
G4Polyline scaleLine, tick11, tick12, tick21, tick22;
|
||||
G4VisAttributes visAtts(*scale.GetVisAttributes()); // Long enough life.
|
||||
scaleLine.SetVisAttributes(&visAtts);
|
||||
tick11.SetVisAttributes(&visAtts);
|
||||
tick12.SetVisAttributes(&visAtts);
|
||||
tick21.SetVisAttributes(&visAtts);
|
||||
tick22.SetVisAttributes(&visAtts);
|
||||
|
||||
// Add points to the polylines to represent an scale parallel to the
|
||||
// x-axis centred on the origin...
|
||||
G4Point3D r1(G4Point3D(-halfLength, 0., 0.));
|
||||
G4Point3D r2(G4Point3D( halfLength, 0., 0.));
|
||||
scaleLine.push_back(r1);
|
||||
scaleLine.push_back(r2);
|
||||
G4Point3D ticky(0., tickLength, 0.);
|
||||
G4Point3D tickz(0., 0., tickLength);
|
||||
tick11.push_back(r1 + ticky);
|
||||
tick11.push_back(r1 - ticky);
|
||||
tick12.push_back(r1 + tickz);
|
||||
tick12.push_back(r1 - tickz);
|
||||
tick21.push_back(r2 + ticky);
|
||||
tick21.push_back(r2 - ticky);
|
||||
tick22.push_back(r2 + tickz);
|
||||
tick22.push_back(r2 - tickz);
|
||||
G4Point3D textPosition(0., tickLength, 0.);
|
||||
|
||||
// Transform appropriately...
|
||||
|
||||
G4Transform3D transformation;
|
||||
if (scale.GetAutoPlacing()) {
|
||||
G4Transform3D rotation;
|
||||
switch (scale.GetDirection()) {
|
||||
case G4Scale::x:
|
||||
break;
|
||||
case G4Scale::y:
|
||||
rotation = G4RotateZ3D(piBy2);
|
||||
break;
|
||||
case G4Scale::z:
|
||||
rotation = G4RotateY3D(piBy2);
|
||||
break;
|
||||
}
|
||||
G4double sxmid;
|
||||
G4double symid;
|
||||
G4double szmid;
|
||||
sxmid = xmin + oneMinusMargin * (xmax - xmin);
|
||||
symid = ymin + margin * (ymax - ymin);
|
||||
szmid = zmin + oneMinusMargin * (zmax - zmin);
|
||||
switch (scale.GetDirection()) {
|
||||
case G4Scale::x:
|
||||
sxmid -= halfLength;
|
||||
break;
|
||||
case G4Scale::y:
|
||||
symid += halfLength;
|
||||
break;
|
||||
case G4Scale::z:
|
||||
szmid -= halfLength;
|
||||
break;
|
||||
}
|
||||
G4Translate3D translation(sxmid, symid, szmid);
|
||||
transformation = translation * rotation;
|
||||
} else {
|
||||
if (fpModel) transformation = fpModel->GetTransformation();
|
||||
}
|
||||
|
||||
// Draw...
|
||||
// We would like to call BeginPrimitives(transformation) here but
|
||||
// calling BeginPrimitives from within an AddPrimitive is not
|
||||
// allowed! So we have to do our own transformation...
|
||||
AddPrimitive(scaleLine.transform(transformation));
|
||||
AddPrimitive(tick11.transform(transformation));
|
||||
AddPrimitive(tick12.transform(transformation));
|
||||
AddPrimitive(tick21.transform(transformation));
|
||||
AddPrimitive(tick22.transform(transformation));
|
||||
G4Text text(scale.GetAnnotation(),textPosition.transform(transformation));
|
||||
G4VisAttributes va(G4VVisCommand::GetCurrentTextColour());
|
||||
text.SetVisAttributes(va);
|
||||
text.SetScreenSize(scale.GetAnnotationSize());
|
||||
AddPrimitive(text);
|
||||
}
|
||||
|
||||
void G4VSceneHandler::AddPrimitive (const G4Polymarker& polymarker) {
|
||||
switch (polymarker.GetMarkerType()) {
|
||||
default:
|
||||
@@ -596,7 +491,17 @@ void G4VSceneHandler::AddPrimitive (const G4Polymarker& polymarker) {
|
||||
}
|
||||
|
||||
void G4VSceneHandler::RemoveViewerFromList (G4VViewer* pViewer) {
|
||||
fViewerList.remove(pViewer);
|
||||
fViewerList.remove(pViewer); // Does nothing if already removed
|
||||
// And reset current viewer
|
||||
auto visManager = G4VisManager::GetInstance();
|
||||
visManager->SetCurrentViewer(nullptr);
|
||||
}
|
||||
|
||||
|
||||
void G4VSceneHandler::AddPrimitive (const G4Plotter&) {
|
||||
G4cerr << "WARNING: Plotter not implemented for " << fSystem.GetName() << G4endl;
|
||||
G4cerr << " Open a plotter-aware graphics system or remove plotter with" << G4endl;
|
||||
G4cerr << " /vis/scene/removeModel Plotter" << G4endl;
|
||||
}
|
||||
|
||||
void G4VSceneHandler::SetScene (G4Scene* pScene) {
|
||||
@@ -657,7 +562,8 @@ void G4VSceneHandler::RequestPrimitives (const G4VSolid& solid)
|
||||
G4cerr << G4endl;
|
||||
}
|
||||
}
|
||||
} // fallthrough
|
||||
}
|
||||
[[fallthrough]];
|
||||
|
||||
case G4ViewParameters::cloud:
|
||||
{
|
||||
@@ -684,6 +590,25 @@ void G4VSceneHandler::RequestPrimitives (const G4VSolid& solid)
|
||||
}
|
||||
}
|
||||
|
||||
//namespace {
|
||||
// void DrawExtent(const G4VModel* pModel)
|
||||
// {
|
||||
// // Show extent boxes - debug only, OGLSX only (OGLSQt problem?)
|
||||
// if (pModel->GetExtent() != G4VisExtent::GetNullExtent()) {
|
||||
// const auto& extent = pModel->GetExtent();
|
||||
// const auto& centre = extent.GetExtentCenter();
|
||||
// const auto& position = G4Translate3D(centre);
|
||||
// const auto& dx = (extent.GetXmax()-extent.GetXmin())/2.;
|
||||
// const auto& dy = (extent.GetYmax()-extent.GetYmin())/2.;
|
||||
// const auto& dz = (extent.GetZmax()-extent.GetZmin())/2.;
|
||||
// auto visAtts = G4VisAttributes();
|
||||
// visAtts.SetForceWireframe();
|
||||
// G4Box extentBox("Extent",dx,dy,dz);
|
||||
// G4VisManager::GetInstance()->Draw(extentBox,visAtts,position);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
void G4VSceneHandler::ProcessScene()
|
||||
{
|
||||
// Assumes graphics database store has already been cleared if
|
||||
@@ -735,19 +660,11 @@ void G4VSceneHandler::ProcessScene()
|
||||
if(runDurationModelList[i].fActive)
|
||||
{
|
||||
fpModel = runDurationModelList[i].fpModel;
|
||||
// Note: this is not the place to apply the transformation
|
||||
// pModel->GetTransformation(). The model must take care of
|
||||
// the required transformation itself - thus the models components
|
||||
// have already been transformed. The model could receive the
|
||||
// transformation in its constructor, e.g., G4PhysicalVolumeModel, or
|
||||
// handle it in the model's SetTransformation, e.g., in G4AxesModel
|
||||
// (relatively simple) or in G4ArrowModel (quite complicated) - see
|
||||
// G4VModel.hh. This avoids having to transform the components perhaps
|
||||
// multiple times. The reasons for this are mainly to do with how we
|
||||
// implement G4PhysicalVolumeModel.
|
||||
// See also /vis/scene/add/logo.
|
||||
fpModel->SetModelingParameters(pMP);
|
||||
fpModel->DescribeYourselfTo(*this);
|
||||
// To see the extents of each model represented as wireframe boxes,
|
||||
// uncomment the next line and DrawExtent in namespace above
|
||||
// DrawExtent(fpModel);
|
||||
fpModel->SetModelingParameters(0);
|
||||
}
|
||||
}
|
||||
@@ -1074,15 +991,24 @@ void G4VSceneHandler::LoadAtts(const G4Visible& visible, G4AttHolder* holder)
|
||||
}
|
||||
}
|
||||
|
||||
const G4Colour& G4VSceneHandler::GetTextColour (const G4Text& text) {
|
||||
const G4VisAttributes* pVA = text.GetVisAttributes ();
|
||||
if (!pVA) {
|
||||
return G4VVisCommand::GetCurrentTextColour();
|
||||
}
|
||||
const G4Colour& colour = pVA -> GetColour ();
|
||||
const G4Colour& G4VSceneHandler::GetColour () {
|
||||
fpVisAttribs = fpViewer->GetApplicableVisAttributes(fpVisAttribs);
|
||||
const G4Colour& colour = fpVisAttribs -> GetColour ();
|
||||
return colour;
|
||||
}
|
||||
|
||||
const G4Colour& G4VSceneHandler::GetColour (const G4Visible& visible) {
|
||||
auto pVA = visible.GetVisAttributes();
|
||||
if (!pVA) pVA = fpViewer->GetViewParameters().GetDefaultVisAttributes();
|
||||
return pVA->GetColour();
|
||||
}
|
||||
|
||||
const G4Colour& G4VSceneHandler::GetTextColour (const G4Text& text) {
|
||||
auto pVA = text.GetVisAttributes();
|
||||
if (!pVA) pVA = fpViewer->GetViewParameters().GetDefaultTextVisAttributes();
|
||||
return pVA->GetColour();
|
||||
}
|
||||
|
||||
G4double G4VSceneHandler::GetLineWidth(const G4VisAttributes* pVisAttribs)
|
||||
{
|
||||
G4double lineWidth = pVisAttribs->GetLineWidth();
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include "G4VGraphicsSystem.hh"
|
||||
#include "G4VSceneHandler.hh"
|
||||
#include "G4Scene.hh"
|
||||
#include "G4PhysicalVolumeStore.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4Transform3D.hh"
|
||||
#include "G4UImanager.hh"
|
||||
@@ -57,8 +58,8 @@ fNeedKernelVisit (true)
|
||||
else {
|
||||
fName = name;
|
||||
}
|
||||
fShortName = fName (0, fName.find (' '));
|
||||
fShortName.strip ();
|
||||
fShortName = fName.substr(0, fName.find (' '));
|
||||
G4StrUtil::strip(fShortName);
|
||||
|
||||
fVP = G4VisManager::GetInstance()->GetDefaultViewParameters();
|
||||
fDefaultVP = fVP;
|
||||
@@ -70,8 +71,8 @@ G4VViewer::~G4VViewer () {
|
||||
|
||||
void G4VViewer::SetName (const G4String& name) {
|
||||
fName = name;
|
||||
fShortName = fName (0, fName.find (' '));
|
||||
fShortName.strip ();
|
||||
fShortName = fName.substr(0, fName.find (' '));
|
||||
G4StrUtil::strip(fShortName);
|
||||
}
|
||||
|
||||
void G4VViewer::NeedKernelVisit () {
|
||||
@@ -125,10 +126,19 @@ void G4VViewer::SetTouchable
|
||||
{
|
||||
// Set the touchable for /vis/touchable/set/... commands.
|
||||
std::ostringstream oss;
|
||||
const auto& pvStore = G4PhysicalVolumeStore::GetInstance();
|
||||
for (const auto& pvNodeId: fullPath) {
|
||||
oss
|
||||
<< ' ' << pvNodeId.GetPhysicalVolume()->GetName()
|
||||
<< ' ' << pvNodeId.GetCopyNo();
|
||||
const auto& pv = pvNodeId.GetPhysicalVolume();
|
||||
auto iterator = find(pvStore->begin(),pvStore->end(),pv);
|
||||
if (iterator == pvStore->end()) {
|
||||
G4ExceptionDescription ed;
|
||||
ed << "Volume no longer in physical volume store.";
|
||||
G4Exception("G4VViewer::SetTouchable", "visman0501", JustWarning, ed);
|
||||
} else {
|
||||
oss
|
||||
<< ' ' << pvNodeId.GetPhysicalVolume()->GetName()
|
||||
<< ' ' << pvNodeId.GetCopyNo();
|
||||
}
|
||||
}
|
||||
G4UImanager::GetUIpointer()->ApplyCommand("/vis/set/touchable" + oss.str());
|
||||
}
|
||||
|
||||
@@ -48,12 +48,29 @@ G4double G4VVisCommand::fCurrentLineWidth = 1.; // pixels
|
||||
G4PhysicalVolumeModel::TouchableProperties G4VVisCommand::fCurrentTouchableProperties;
|
||||
G4VisExtent G4VVisCommand::fCurrentExtentForField;
|
||||
std::vector<G4PhysicalVolumesSearchScene::Findings> G4VVisCommand::fCurrrentPVFindingsForField;
|
||||
G4bool G4VVisCommand::fThereWasAViewer = false;
|
||||
G4ViewParameters G4VVisCommand::fVPExistingViewer;
|
||||
|
||||
G4VVisCommand::G4VVisCommand () {}
|
||||
|
||||
G4VVisCommand::~G4VVisCommand () {}
|
||||
|
||||
G4VisManager* G4VVisCommand::fpVisManager = 0;
|
||||
G4VisManager* G4VVisCommand::fpVisManager = nullptr;
|
||||
|
||||
G4VisManager* G4VVisCommand::GetVisManager ()
|
||||
{
|
||||
return fpVisManager;
|
||||
}
|
||||
|
||||
void G4VVisCommand::SetVisManager (G4VisManager* pVisManager)
|
||||
{
|
||||
fpVisManager = pVisManager;
|
||||
}
|
||||
|
||||
const G4Colour& G4VVisCommand::GetCurrentTextColour()
|
||||
{
|
||||
return fCurrentTextColour;
|
||||
}
|
||||
|
||||
G4String G4VVisCommand::ConvertToString
|
||||
(G4double x, G4double y, const char * unitName)
|
||||
@@ -284,10 +301,9 @@ void G4VVisCommand::InterpolateViews
|
||||
currentViewer->SetViewParameters(*vp);
|
||||
currentViewer->RefreshView();
|
||||
if (exportString == "export" &&
|
||||
currentViewer->GetName().contains("OpenGL")) {
|
||||
G4StrUtil::contains(currentViewer->GetName(), "OpenGL")) {
|
||||
G4UImanager::GetUIpointer()->ApplyCommand("/vis/ogl/export");
|
||||
}
|
||||
// File-writing viewers need to close the file
|
||||
currentViewer->ShowView();
|
||||
if (waitTimePerPointmilliseconds > 0)
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(waitTimePerPointmilliseconds));
|
||||
@@ -354,3 +370,29 @@ void G4VVisCommand::DrawExtent(const G4VisExtent& extent)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void G4VVisCommand::CopyMostViewParameters
|
||||
(G4ViewParameters& target, const G4ViewParameters& from)
|
||||
{
|
||||
// Copy view parameters except for autoRefresh and background...
|
||||
auto targetAutoRefresh = target.IsAutoRefresh();
|
||||
auto targetBackground = target.GetBackgroundColour();
|
||||
target = from;
|
||||
target.SetAutoRefresh(targetAutoRefresh);
|
||||
target.SetBackgroundColour(targetBackground);
|
||||
}
|
||||
|
||||
void G4VVisCommand::CopyCameraParameters
|
||||
(G4ViewParameters& target, const G4ViewParameters& from)
|
||||
{
|
||||
// Copy view parameters pertaining only to camera
|
||||
target.SetViewpointDirection (from.GetViewpointDirection());
|
||||
target.SetLightpointDirection (from.GetLightpointDirection());
|
||||
target.SetLightsMoveWithCamera(from.GetLightsMoveWithCamera());
|
||||
target.SetUpVector (from.GetUpVector());
|
||||
target.SetFieldHalfAngle (from.GetFieldHalfAngle());
|
||||
target.SetZoomFactor (from.GetZoomFactor());
|
||||
target.SetScaleFactor (from.GetScaleFactor());
|
||||
target.SetCurrentTargetPoint (from.GetCurrentTargetPoint());
|
||||
target.SetDolly (from.GetDolly());
|
||||
}
|
||||
|
||||
@@ -100,7 +100,8 @@ G4ViewParameters::G4ViewParameters ():
|
||||
fDisplayLightFrontT(0.),
|
||||
fDisplayLightFrontRed(0.),
|
||||
fDisplayLightFrontGreen(1.),
|
||||
fDisplayLightFrontBlue(0.)
|
||||
fDisplayLightFrontBlue(0.),
|
||||
fSpecialMeshRendering(false)
|
||||
{
|
||||
// Pick up default no of sides from G4Polyhedron.
|
||||
// Note that this parameter is variously called:
|
||||
@@ -451,6 +452,18 @@ G4String G4ViewParameters::DrawingStyleCommands() const
|
||||
oss << "\n/vis/viewer/set/numberOfCloudPoints "
|
||||
<< fNumberOfCloudPoints;
|
||||
|
||||
oss << "\n/vis/viewer/set/specialMeshRendering ";
|
||||
if (fSpecialMeshRendering) {
|
||||
oss << "true";
|
||||
} else {
|
||||
oss << "false";
|
||||
}
|
||||
|
||||
oss << "\n/vis/viewer/set/specialMeshVolumes";
|
||||
for (const auto& volume : fSpecialMeshVolumes) {
|
||||
oss << ' ' << volume.GetName() << ' ' << volume.GetCopyNo();
|
||||
}
|
||||
|
||||
oss << std::endl;
|
||||
|
||||
return oss.str();
|
||||
|
||||
@@ -254,7 +254,7 @@ G4VisCommandReviewKeptEvents::G4VisCommandReviewKeptEvents ()
|
||||
"\nevent."
|
||||
"\nUseful commands might be:"
|
||||
"\n \"/vis/viewer/...\" to change the view (zoom, set/viewpoint,...)."
|
||||
"\n \"/vis/oglx/printEPS\" to get hard copy."
|
||||
"\n \"/vis/ogl/export\" to get hard copy."
|
||||
"\n \"/vis/open\" to get alternative viewer."
|
||||
"\n \"/vis/abortReviewKeptEvents\", then \"cont[inue]\", to abort.");
|
||||
fpCommand -> SetParameterName("macro-file-name", omitable=true);
|
||||
@@ -352,7 +352,7 @@ void G4VisCommandReviewKeptEvents::SetNewValue (G4UIcommand*, G4String newValue)
|
||||
" Useful commands might be:"
|
||||
"\n \"/vis/scene/add/trajectories\" if not already added."
|
||||
"\n \"/vis/viewer/...\" to change the view (zoom, set/viewpoint,...)."
|
||||
"\n \"/vis/oglx/printEPS\" to get hard copy."
|
||||
"\n \"/vis/ogl/export\" to get hard copy."
|
||||
"\n \"/vis/open\" to get alternative viewer."
|
||||
"\n \"/vis/abortReviewKeptEvents\", then \"cont[inue]\", to abort."
|
||||
<< G4endl;
|
||||
|
||||
@@ -76,7 +76,7 @@ void G4VisCommandDrawTree::SetNewValue(G4UIcommand*, G4String newValue) {
|
||||
// built-in. The HepRApp offline browser also has a tree browser
|
||||
// built in.
|
||||
|
||||
if (!system.contains("Tree")) {
|
||||
if (!G4StrUtil::contains(system, "Tree")) {
|
||||
system = "ATree";
|
||||
}
|
||||
|
||||
@@ -85,6 +85,7 @@ void G4VisCommandDrawTree::SetNewValue(G4UIcommand*, G4String newValue) {
|
||||
G4VSceneHandler* keepSceneHandler = fpVisManager->GetCurrentSceneHandler();
|
||||
G4VViewer* keepViewer = fpVisManager->GetCurrentViewer();
|
||||
G4VisManager::Verbosity keepVisVerbosity = fpVisManager->GetVerbosity();
|
||||
G4bool keepAbleness = fpVisManager->GetConcreteInstance()? true: false;
|
||||
|
||||
G4UImanager* UImanager = G4UImanager::GetUIpointer();
|
||||
G4int keepUIVerbose = UImanager->GetVerboseLevel();
|
||||
@@ -94,8 +95,6 @@ void G4VisCommandDrawTree::SetNewValue(G4UIcommand*, G4String newValue) {
|
||||
newVerbose = 2;
|
||||
UImanager->SetVerboseLevel(newVerbose);
|
||||
|
||||
G4bool keepAbleness = fpVisManager->GetConcreteInstance()? true: false;
|
||||
|
||||
auto errorCode = UImanager->ApplyCommand(G4String("/vis/open " + system));
|
||||
if (errorCode == 0) {
|
||||
if (!keepAbleness) { // Enable temporarily
|
||||
@@ -103,6 +102,7 @@ void G4VisCommandDrawTree::SetNewValue(G4UIcommand*, G4String newValue) {
|
||||
UImanager->ApplyCommand("/vis/enable");
|
||||
fpVisManager->SetVerboseLevel(keepVisVerbosity);
|
||||
}
|
||||
UImanager->ApplyCommand("/vis/viewer/reset");
|
||||
UImanager->ApplyCommand(G4String("/vis/drawVolume " + pvname));
|
||||
UImanager->ApplyCommand("/vis/viewer/flush");
|
||||
if (!keepAbleness) { // Disable again
|
||||
@@ -360,7 +360,8 @@ G4VisCommandOpen::~G4VisCommandOpen() {
|
||||
delete fpCommand;
|
||||
}
|
||||
|
||||
void G4VisCommandOpen::SetNewValue (G4UIcommand* command, G4String newValue) {
|
||||
void G4VisCommandOpen::SetNewValue (G4UIcommand* command, G4String newValue)
|
||||
{
|
||||
G4String systemName, windowSizeHint;
|
||||
std::istringstream is(newValue);
|
||||
is >> systemName >> windowSizeHint;
|
||||
@@ -371,21 +372,42 @@ void G4VisCommandOpen::SetNewValue (G4UIcommand* command, G4String newValue) {
|
||||
fpVisManager->GetVerbosity() >= G4VisManager::confirmations)
|
||||
newVerbose = 2;
|
||||
UImanager->SetVerboseLevel(newVerbose);
|
||||
|
||||
auto errorCode = UImanager->ApplyCommand(G4String("/vis/sceneHandler/create " + systemName));
|
||||
if (errorCode != 0) {
|
||||
if (errorCode) {
|
||||
G4ExceptionDescription ed;
|
||||
ed << "sub-command \"/vis/sceneHandler/create\" failed.";
|
||||
command->CommandFailed(errorCode,ed);
|
||||
goto restore;
|
||||
goto finish;
|
||||
}
|
||||
errorCode = UImanager->ApplyCommand(G4String("/vis/viewer/create ! ! " + windowSizeHint));
|
||||
if (errorCode != 0) {
|
||||
if (errorCode) {
|
||||
G4ExceptionDescription ed;
|
||||
ed << "sub-command \"/vis/viewer/create\" failed.";
|
||||
command->CommandFailed(errorCode,ed);
|
||||
goto restore;
|
||||
goto finish;
|
||||
}
|
||||
restore: UImanager->SetVerboseLevel(keepVerbose);
|
||||
|
||||
finish:
|
||||
if (errorCode) {
|
||||
std::set<G4String> candidates;
|
||||
for (const auto gs: fpVisManager -> GetAvailableGraphicsSystems()) {
|
||||
// Just list nicknames, but exclude FALLBACK nicknames
|
||||
for (const auto& nickname: gs->GetNicknames()) {
|
||||
if (!G4StrUtil::contains(nickname, "FALLBACK")) {
|
||||
candidates.insert(nickname);
|
||||
}
|
||||
}
|
||||
}
|
||||
G4ExceptionDescription ed;
|
||||
ed << "Invoked command has failed - see above. Available graphics systems are (short names):\n ";
|
||||
for (const auto& candidate: candidates) {
|
||||
ed << ' ' << candidate;
|
||||
};
|
||||
command->CommandFailed(errorCode,ed);
|
||||
}
|
||||
|
||||
UImanager->SetVerboseLevel(keepVerbose);
|
||||
}
|
||||
|
||||
////////////// /vis/specify ///////////////////////////////////////
|
||||
|
||||
@@ -59,6 +59,17 @@ void G4VVisCommandGeometrySet::Set
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Recalculate extent of any physical volume model in run duration lists
|
||||
for (const auto& scene : fpVisManager->GetSceneList()) {
|
||||
const auto& runDurationModelList = scene->GetRunDurationModelList();
|
||||
for (const auto& sceneModel : runDurationModelList) {
|
||||
auto model = sceneModel.fpModel;
|
||||
auto pvModel = dynamic_cast<G4PhysicalVolumeModel*>(model);
|
||||
if (pvModel) pvModel->CalculateExtent();
|
||||
}
|
||||
// And re-calculate the scene's extent
|
||||
scene->CalculateExtent();
|
||||
}
|
||||
if (fpVisManager->GetCurrentViewer()) {
|
||||
G4UImanager::GetUIpointer()->ApplyCommand("/vis/scene/notifyHandlers");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,398 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// /vis/plotter commands - Guy Barrand October 2021.
|
||||
|
||||
#include "G4VisCommandsPlotter.hh"
|
||||
|
||||
#include "G4PlotterManager.hh"
|
||||
|
||||
#include <tools/tokenize>
|
||||
|
||||
#include <sstream>
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
////////////// /vis/plotter/create //////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
G4VisCommandPlotterCreate::G4VisCommandPlotterCreate () {
|
||||
fpCommand = new G4UIcommand("/vis/plotter/create", this);
|
||||
fpCommand->SetGuidance("Create a named G4Plotter.");
|
||||
|
||||
G4UIparameter* parameter;
|
||||
parameter = new G4UIparameter("name",'s',false);
|
||||
fpCommand->SetParameter (parameter);
|
||||
}
|
||||
|
||||
G4VisCommandPlotterCreate::~G4VisCommandPlotterCreate () {delete fpCommand;}
|
||||
|
||||
void G4VisCommandPlotterCreate::SetNewValue (G4UIcommand*, G4String newValue)
|
||||
{
|
||||
G4Plotter& _plotter = G4PlotterManager::GetInstance().GetPlotter(newValue);
|
||||
_plotter.Reset();
|
||||
G4Scene* pScene = fpVisManager->GetCurrentScene();
|
||||
if(pScene) CheckSceneAndNotifyHandlers (pScene);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
////////////// /vis/plotter/setLayout ///////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
G4VisCommandPlotterSetLayout::G4VisCommandPlotterSetLayout () {
|
||||
fpCommand = new G4UIcommand("/vis/plotter/setLayout", this);
|
||||
fpCommand->SetGuidance("Set plotter grid layout.");
|
||||
|
||||
G4UIparameter* parameter;
|
||||
parameter = new G4UIparameter("plotter",'s',false);
|
||||
fpCommand->SetParameter (parameter);
|
||||
|
||||
parameter = new G4UIparameter("columns",'i',true);
|
||||
parameter->SetDefaultValue(1);
|
||||
fpCommand->SetParameter (parameter);
|
||||
|
||||
parameter = new G4UIparameter("rows",'i',true);
|
||||
parameter->SetDefaultValue(1);
|
||||
fpCommand->SetParameter (parameter);
|
||||
}
|
||||
|
||||
G4VisCommandPlotterSetLayout::~G4VisCommandPlotterSetLayout () {delete fpCommand;}
|
||||
|
||||
void G4VisCommandPlotterSetLayout::SetNewValue (G4UIcommand*, G4String newValue)
|
||||
{
|
||||
G4String plotter;
|
||||
G4int cols,rows;
|
||||
std::istringstream is(newValue);
|
||||
is >> plotter >> cols >> rows;
|
||||
|
||||
G4Plotter& _plotter = G4PlotterManager::GetInstance().GetPlotter(plotter);
|
||||
_plotter.SetLayout(cols,rows);
|
||||
|
||||
G4Scene* pScene = fpVisManager->GetCurrentScene();
|
||||
if(pScene) CheckSceneAndNotifyHandlers (pScene);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
////////////// /vis/plotter/addStyle ////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
G4VisCommandPlotterAddStyle::G4VisCommandPlotterAddStyle () {
|
||||
fpCommand = new G4UIcommand("/vis/plotter/addStyle", this);
|
||||
fpCommand->SetGuidance("Add a style for a plotter.");
|
||||
fpCommand->SetGuidance("It is applied on all regions/plots of the plotter.");
|
||||
fpCommand->SetGuidance("default, ROOT_default, hippodraw are known embedded styles.");
|
||||
fpCommand->SetGuidance("reset is a keyword used to reset regions style.");
|
||||
|
||||
G4UIparameter* parameter;
|
||||
parameter = new G4UIparameter("plotter",'s',false);
|
||||
fpCommand->SetParameter (parameter);
|
||||
|
||||
parameter = new G4UIparameter("style",'s',true);
|
||||
parameter->SetDefaultValue("default");
|
||||
fpCommand->SetParameter (parameter);
|
||||
}
|
||||
|
||||
G4VisCommandPlotterAddStyle::~G4VisCommandPlotterAddStyle () {delete fpCommand;}
|
||||
|
||||
void G4VisCommandPlotterAddStyle::SetNewValue (G4UIcommand*, G4String newValue)
|
||||
{
|
||||
G4String plotter;
|
||||
G4String style;
|
||||
std::istringstream is(newValue);
|
||||
is >> plotter >> style;
|
||||
|
||||
G4Plotter& _plotter = G4PlotterManager::GetInstance().GetPlotter(plotter);
|
||||
_plotter.AddStyle(style);
|
||||
|
||||
G4Scene* pScene = fpVisManager->GetCurrentScene();
|
||||
if(pScene) CheckSceneAndNotifyHandlers (pScene);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
////////////// /vis/plotter/addRegionStyle //////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
G4VisCommandPlotterAddRegionStyle::G4VisCommandPlotterAddRegionStyle () {
|
||||
fpCommand = new G4UIcommand("/vis/plotter/addRegionStyle", this);
|
||||
fpCommand->SetGuidance("Add a style to be applied on a region.");
|
||||
fpCommand->SetGuidance("default, ROOT_default, hippodraw are known embedded styles.");
|
||||
fpCommand->SetGuidance("reset is a keyword used to reset a region style.");
|
||||
|
||||
G4UIparameter* parameter;
|
||||
parameter = new G4UIparameter("plotter",'s',false);
|
||||
fpCommand->SetParameter (parameter);
|
||||
|
||||
parameter = new G4UIparameter("region",'i',false);
|
||||
//parameter->SetDefaultValue(0);
|
||||
fpCommand->SetParameter (parameter);
|
||||
|
||||
parameter = new G4UIparameter("style",'s',true);
|
||||
parameter->SetDefaultValue("default");
|
||||
fpCommand->SetParameter (parameter);
|
||||
}
|
||||
|
||||
G4VisCommandPlotterAddRegionStyle::~G4VisCommandPlotterAddRegionStyle () {delete fpCommand;}
|
||||
|
||||
void G4VisCommandPlotterAddRegionStyle::SetNewValue (G4UIcommand*, G4String newValue)
|
||||
{
|
||||
G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
|
||||
|
||||
G4String plotter;
|
||||
int region;
|
||||
G4String style;
|
||||
std::istringstream is(newValue);
|
||||
is >> plotter >> region >> style;
|
||||
if(region<0) {
|
||||
if (verbosity >= G4VisManager::errors) {
|
||||
G4cerr << "ERROR: bad region index " << region << "." << G4endl;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
G4Plotter& _plotter = G4PlotterManager::GetInstance().GetPlotter(plotter);
|
||||
_plotter.AddRegionStyle(region,style);
|
||||
|
||||
G4Scene* pScene = fpVisManager->GetCurrentScene();
|
||||
if(pScene) CheckSceneAndNotifyHandlers (pScene);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
////////////// /vis/plotter/addRegionParameter //////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
G4VisCommandPlotterAddRegionParameter::G4VisCommandPlotterAddRegionParameter () {
|
||||
fpCommand = new G4UIcommand("/vis/plotter/addRegionParameter", this);
|
||||
fpCommand->SetGuidance("Add a parameter to be set on a region.");
|
||||
|
||||
G4UIparameter* parameter;
|
||||
parameter = new G4UIparameter("plotter",'s',false);
|
||||
fpCommand->SetParameter (parameter);
|
||||
|
||||
parameter = new G4UIparameter("region",'i',false);
|
||||
fpCommand->SetParameter (parameter);
|
||||
|
||||
parameter = new G4UIparameter("parameter",'s',false);
|
||||
fpCommand->SetParameter (parameter);
|
||||
|
||||
parameter = new G4UIparameter("value",'s',false);
|
||||
fpCommand->SetParameter (parameter);
|
||||
}
|
||||
|
||||
G4VisCommandPlotterAddRegionParameter::~G4VisCommandPlotterAddRegionParameter () {delete fpCommand;}
|
||||
|
||||
void G4VisCommandPlotterAddRegionParameter::SetNewValue (G4UIcommand* command, G4String newValue)
|
||||
{
|
||||
G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
|
||||
|
||||
std::vector<std::string> args;
|
||||
tools::double_quotes_tokenize(newValue, args);
|
||||
if ( args.size() != command->GetParameterEntries() ) { // check consistency.
|
||||
if (verbosity >= G4VisManager::errors) {
|
||||
G4cerr << "ERROR: tokenize value problem." << G4endl;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
std::string plotter = args[0];
|
||||
int region = G4UIcommand::ConvertToInt(args[1].c_str());
|
||||
std::string parameter = args[2];
|
||||
std::string value = args[3];
|
||||
if(region<0) {
|
||||
if (verbosity >= G4VisManager::errors) {
|
||||
G4cerr << "ERROR: bad region index " << region << "." << G4endl;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
G4Plotter& _plotter = G4PlotterManager::GetInstance().GetPlotter(plotter);
|
||||
_plotter.AddRegionParameter(region,parameter,value);
|
||||
|
||||
G4Scene* pScene = fpVisManager->GetCurrentScene();
|
||||
if(pScene) CheckSceneAndNotifyHandlers (pScene);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
////////////// /vis/plotter/clear ///////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
G4VisCommandPlotterClear::G4VisCommandPlotterClear () {
|
||||
fpCommand = new G4UIcommand("/vis/plotter/clear", this);
|
||||
fpCommand->SetGuidance("Remove plottables from all regions.");
|
||||
|
||||
G4UIparameter* parameter;
|
||||
parameter = new G4UIparameter("plotter",'s',false);
|
||||
fpCommand->SetParameter (parameter);
|
||||
}
|
||||
|
||||
G4VisCommandPlotterClear::~G4VisCommandPlotterClear () {delete fpCommand;}
|
||||
|
||||
void G4VisCommandPlotterClear::SetNewValue (G4UIcommand*, G4String newValue)
|
||||
{
|
||||
G4Plotter& _plotter = G4PlotterManager::GetInstance().GetPlotter(newValue);
|
||||
_plotter.Clear();
|
||||
|
||||
G4Scene* pScene = fpVisManager->GetCurrentScene();
|
||||
if(pScene) CheckSceneAndNotifyHandlers (pScene);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
////////////// /vis/plotter/clearRegion /////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
G4VisCommandPlotterClearRegion::G4VisCommandPlotterClearRegion () {
|
||||
fpCommand = new G4UIcommand("/vis/plotter/clearRegion", this);
|
||||
fpCommand->SetGuidance("Remove plottables a region.");
|
||||
|
||||
G4UIparameter* parameter;
|
||||
parameter = new G4UIparameter("plotter",'s',false);
|
||||
fpCommand->SetParameter (parameter);
|
||||
|
||||
parameter = new G4UIparameter("region",'i',false);
|
||||
//parameter->SetDefaultValue(0);
|
||||
fpCommand->SetParameter (parameter);
|
||||
}
|
||||
|
||||
G4VisCommandPlotterClearRegion::~G4VisCommandPlotterClearRegion () {delete fpCommand;}
|
||||
|
||||
void G4VisCommandPlotterClearRegion::SetNewValue (G4UIcommand*, G4String newValue)
|
||||
{
|
||||
G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
|
||||
|
||||
G4String plotter;
|
||||
int region;
|
||||
std::istringstream is(newValue);
|
||||
is >> plotter >> region;
|
||||
if(region<0) {
|
||||
if (verbosity >= G4VisManager::errors) {
|
||||
G4cerr << "ERROR: bad region index " << region << "." << G4endl;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
G4Plotter& _plotter = G4PlotterManager::GetInstance().GetPlotter(plotter);
|
||||
_plotter.ClearRegion(region);
|
||||
|
||||
G4Scene* pScene = fpVisManager->GetCurrentScene();
|
||||
if(pScene) CheckSceneAndNotifyHandlers (pScene);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
////////////// /vis/plotter/list ////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
G4VisCommandPlotterList::G4VisCommandPlotterList () {
|
||||
fpCommand = new G4UIcommand("/vis/plotter/list", this);
|
||||
fpCommand->SetGuidance("List plotters in the scene.");
|
||||
}
|
||||
|
||||
G4VisCommandPlotterList::~G4VisCommandPlotterList () {delete fpCommand;}
|
||||
|
||||
void G4VisCommandPlotterList::SetNewValue (G4UIcommand*, G4String)
|
||||
{
|
||||
G4PlotterManager::GetInstance().List();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
////////////// /vis/plotter/add/h1 //////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
G4VisCommandPlotterAddRegionH1::G4VisCommandPlotterAddRegionH1 () {
|
||||
fpCommand = new G4UIcommand("/vis/plotter/add/h1", this);
|
||||
fpCommand->SetGuidance("Attach a 1D histogram to a plotter region.");
|
||||
|
||||
G4UIparameter* parameter;
|
||||
parameter = new G4UIparameter("histo",'i',false);
|
||||
fpCommand->SetParameter (parameter);
|
||||
|
||||
parameter = new G4UIparameter("plotter",'s',false);
|
||||
fpCommand->SetParameter (parameter);
|
||||
|
||||
parameter = new G4UIparameter("region",'i',true);
|
||||
parameter->SetDefaultValue(0);
|
||||
fpCommand->SetParameter (parameter);
|
||||
}
|
||||
|
||||
G4VisCommandPlotterAddRegionH1::~G4VisCommandPlotterAddRegionH1 () {delete fpCommand;}
|
||||
|
||||
void G4VisCommandPlotterAddRegionH1::SetNewValue (G4UIcommand*, G4String newValue)
|
||||
{
|
||||
G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
|
||||
|
||||
int hid;
|
||||
G4String plotter;
|
||||
int region;
|
||||
std::istringstream is(newValue);
|
||||
is >> hid >> plotter >> region;
|
||||
|
||||
if(region<0) {
|
||||
if (verbosity >= G4VisManager::errors) {
|
||||
G4cerr << "ERROR: bad region index " << region << "." << G4endl;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
G4Plotter& _plotter = G4PlotterManager::GetInstance().GetPlotter(plotter);
|
||||
_plotter.AddRegionH1(region,hid);
|
||||
|
||||
G4Scene* pScene = fpVisManager->GetCurrentScene();
|
||||
if(pScene) CheckSceneAndNotifyHandlers (pScene);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
////////////// /vis/plotter/add/h2 //////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
G4VisCommandPlotterAddRegionH2::G4VisCommandPlotterAddRegionH2 () {
|
||||
fpCommand = new G4UIcommand("/vis/plotter/add/h2", this);
|
||||
fpCommand->SetGuidance("Attach a 2D histogram to a plotter region.");
|
||||
|
||||
G4UIparameter* parameter;
|
||||
parameter = new G4UIparameter("histo",'i',false);
|
||||
fpCommand->SetParameter (parameter);
|
||||
|
||||
parameter = new G4UIparameter("plotter",'s',false);
|
||||
fpCommand->SetParameter (parameter);
|
||||
|
||||
parameter = new G4UIparameter("region",'i',true);
|
||||
parameter->SetDefaultValue(0);
|
||||
fpCommand->SetParameter (parameter);
|
||||
}
|
||||
|
||||
G4VisCommandPlotterAddRegionH2::~G4VisCommandPlotterAddRegionH2 () {delete fpCommand;}
|
||||
|
||||
void G4VisCommandPlotterAddRegionH2::SetNewValue (G4UIcommand*, G4String newValue)
|
||||
{
|
||||
G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
|
||||
|
||||
int hid;
|
||||
G4String plotter;
|
||||
int region;
|
||||
std::istringstream is(newValue);
|
||||
is >> hid >> plotter >> region;
|
||||
|
||||
if(region<0) {
|
||||
if (verbosity >= G4VisManager::errors) {
|
||||
G4cerr << "ERROR: bad region index " << region << "." << G4endl;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
G4Plotter& _plotter = G4PlotterManager::GetInstance().GetPlotter(plotter);
|
||||
_plotter.AddRegionH2(region,hid);
|
||||
|
||||
G4Scene* pScene = fpVisManager->GetCurrentScene();
|
||||
if(pScene) CheckSceneAndNotifyHandlers (pScene);
|
||||
}
|
||||
|
||||
@@ -630,7 +630,7 @@ void G4VisCommandSceneNotifyHandlers::SetNewValue (G4UIcommand*,
|
||||
std::istringstream is (newValue);
|
||||
is >> sceneName >> refresh_flush;
|
||||
G4bool flush = false;
|
||||
if (refresh_flush(0) == 'f') flush = true;
|
||||
if (refresh_flush[0] == 'f') flush = true;
|
||||
|
||||
const G4SceneList& sceneList = fpVisManager -> GetSceneList ();
|
||||
G4SceneHandlerList& sceneHandlerList =
|
||||
@@ -772,6 +772,111 @@ void G4VisCommandSceneNotifyHandlers::SetNewValue (G4UIcommand*,
|
||||
}
|
||||
}
|
||||
|
||||
////////////// /vis/scene/removeModel ////////////////////////////
|
||||
|
||||
G4VisCommandSceneRemoveModel::G4VisCommandSceneRemoveModel () {
|
||||
G4bool omitable;
|
||||
fpCommand = new G4UIcommand ("/vis/scene/removeModel", this);
|
||||
fpCommand -> SetGuidance("Remove model.");
|
||||
fpCommand -> SetGuidance
|
||||
("Attempts to match search string to name of model - use unique sub-string.");
|
||||
fpCommand -> SetGuidance
|
||||
("Use \"/vis/scene/list\" to see model names.");
|
||||
G4UIparameter* parameter;
|
||||
parameter = new G4UIparameter ("search-string", 's', omitable = false);
|
||||
fpCommand -> SetParameter (parameter);
|
||||
}
|
||||
|
||||
G4VisCommandSceneRemoveModel::~G4VisCommandSceneRemoveModel () {
|
||||
delete fpCommand;
|
||||
}
|
||||
|
||||
G4String G4VisCommandSceneRemoveModel::GetCurrentValue(G4UIcommand*) {
|
||||
return "";
|
||||
}
|
||||
|
||||
void G4VisCommandSceneRemoveModel::SetNewValue (G4UIcommand*,
|
||||
G4String newValue) {
|
||||
|
||||
G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
|
||||
|
||||
G4String searchString;
|
||||
std::istringstream is (newValue);
|
||||
is >> searchString;
|
||||
|
||||
G4Scene* pScene = fpVisManager->GetCurrentScene();
|
||||
if (!pScene) {
|
||||
if (verbosity >= G4VisManager::errors) {
|
||||
G4cerr << "ERROR: No current scene. Please create one." << G4endl;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
G4VSceneHandler* pSceneHandler = fpVisManager->GetCurrentSceneHandler();
|
||||
if (!pSceneHandler) {
|
||||
if (verbosity >= G4VisManager::errors) {
|
||||
G4cerr << "ERROR: No current sceneHandler. Please create one." << G4endl;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
G4bool any = false;
|
||||
|
||||
std::vector<G4Scene::Model>& runDurationModelList =
|
||||
pScene->SetRunDurationModelList();
|
||||
for (size_t i = 0; i < runDurationModelList.size(); i++) {
|
||||
const G4String& modelName =
|
||||
runDurationModelList[i].fpModel->GetGlobalDescription();
|
||||
if (modelName.find(searchString) != std::string::npos) {
|
||||
runDurationModelList.erase(runDurationModelList.begin()+i);
|
||||
any = true;
|
||||
if (verbosity >= G4VisManager::warnings) {
|
||||
G4cout << "Model \"" << modelName << "\" removed." << G4endl;
|
||||
}
|
||||
break; // Allow only one model at a time to be removed.
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<G4Scene::Model>& endOfEventModelList =
|
||||
pScene->SetEndOfEventModelList();
|
||||
for (size_t i = 0; i < endOfEventModelList.size(); i++) {
|
||||
const G4String& modelName =
|
||||
endOfEventModelList[i].fpModel->GetGlobalDescription();
|
||||
if (modelName.find(searchString) != std::string::npos) {
|
||||
endOfEventModelList.erase(endOfEventModelList.begin()+i);
|
||||
any = true;
|
||||
if (verbosity >= G4VisManager::warnings) {
|
||||
G4cout << "Model \"" << modelName << "\" removed." << G4endl;
|
||||
}
|
||||
break; // Allow only one model at a time to be removed.
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<G4Scene::Model>& endOfRunModelList =
|
||||
pScene->SetEndOfRunModelList();
|
||||
for (size_t i = 0; i < endOfRunModelList.size(); i++) {
|
||||
const G4String& modelName =
|
||||
endOfRunModelList[i].fpModel->GetGlobalDescription();
|
||||
if (modelName.find(searchString) != std::string::npos) {
|
||||
endOfRunModelList.erase(endOfRunModelList.begin()+i);
|
||||
any = true;
|
||||
if (verbosity >= G4VisManager::warnings) {
|
||||
G4cout << "Model \"" << modelName << "\" removed." << G4endl;
|
||||
}
|
||||
break; // Allow only one model at a time to be removed.
|
||||
}
|
||||
}
|
||||
|
||||
if (!any) {
|
||||
if (verbosity >= G4VisManager::warnings) {
|
||||
G4cout << "WARNING: No match found." << G4endl;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
CheckSceneAndNotifyHandlers (pScene);
|
||||
}
|
||||
|
||||
////////////// /vis/scene/select ///////////////////////////////////////
|
||||
|
||||
G4VisCommandSceneSelect::G4VisCommandSceneSelect () {
|
||||
@@ -874,7 +979,7 @@ void G4VisCommandSceneShowExtents::SetNewValue (G4UIcommand*, G4String) {
|
||||
G4cout << "\n Active: ";
|
||||
else G4cout << "\n Inactive: ";
|
||||
G4VModel* pModel = pCurrentScene -> GetRunDurationModelList()[i].fpModel;
|
||||
const G4VisExtent& transformedExtent = pModel -> GetTransformedExtent();
|
||||
const G4VisExtent& transformedExtent = pModel -> GetExtent();
|
||||
G4cout << pModel -> GetGlobalDescription ()
|
||||
<< "\n" << transformedExtent;
|
||||
DrawExtent(transformedExtent);
|
||||
@@ -889,7 +994,7 @@ void G4VisCommandSceneShowExtents::SetNewValue (G4UIcommand*, G4String) {
|
||||
G4cout << "\n Active: ";
|
||||
else G4cout << "\n Inactive: ";
|
||||
G4VModel* pModel = pCurrentScene -> GetEndOfEventModelList()[i].fpModel;
|
||||
const G4VisExtent& transformedExtent = pModel -> GetTransformedExtent();
|
||||
const G4VisExtent& transformedExtent = pModel -> GetExtent();
|
||||
G4cout << pModel -> GetGlobalDescription ()
|
||||
<< "\n" << transformedExtent;
|
||||
DrawExtent(transformedExtent);
|
||||
@@ -904,7 +1009,7 @@ void G4VisCommandSceneShowExtents::SetNewValue (G4UIcommand*, G4String) {
|
||||
G4cout << "\n Active: ";
|
||||
else G4cout << "\n Inactive: ";
|
||||
G4VModel* pModel = pCurrentScene -> GetEndOfRunModelList()[i].fpModel;
|
||||
const G4VisExtent& transformedExtent = pModel -> GetTransformedExtent();
|
||||
const G4VisExtent& transformedExtent = pModel -> GetExtent();
|
||||
G4cout << pModel -> GetGlobalDescription ()
|
||||
<< "\n" << transformedExtent;
|
||||
DrawExtent(transformedExtent);
|
||||
|
||||
@@ -40,10 +40,10 @@
|
||||
#include "G4MagneticFieldModel.hh"
|
||||
#include "G4PSHitsModel.hh"
|
||||
#include "G4TrajectoriesModel.hh"
|
||||
#include "G4ScaleModel.hh"
|
||||
#include "G4TextModel.hh"
|
||||
#include "G4ArrowModel.hh"
|
||||
#include "G4AxesModel.hh"
|
||||
#include "G4PlotterModel.hh"
|
||||
#include "G4PhysicalVolumesSearchScene.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
@@ -78,6 +78,7 @@
|
||||
#include "G4PhysicalConstants.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4GeneralParticleSourceData.hh"
|
||||
#include "G4PlotterManager.hh"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
@@ -245,7 +246,7 @@ G4VisCommandSceneAddArrow2D::Arrow2D::Arrow2D
|
||||
}
|
||||
|
||||
void G4VisCommandSceneAddArrow2D::Arrow2D::operator()
|
||||
(G4VGraphicsScene& sceneHandler, const G4Transform3D&, const G4ModelingParameters*)
|
||||
(G4VGraphicsScene& sceneHandler, const G4ModelingParameters*)
|
||||
{
|
||||
sceneHandler.BeginPrimitives2D();
|
||||
sceneHandler.AddPrimitive(fShaftPolyline);
|
||||
@@ -433,9 +434,9 @@ void G4VisCommandSceneAddDate::SetNewValue (G4UIcommand*, G4String newValue)
|
||||
is.getline(remainder, NREMAINDER);
|
||||
dateString += remainder;
|
||||
G4Text::Layout layout = G4Text::right;
|
||||
if (layoutString(0) == 'l') layout = G4Text::left;
|
||||
else if (layoutString(0) == 'c') layout = G4Text::centre;
|
||||
else if (layoutString(0) == 'r') layout = G4Text::right;
|
||||
if (layoutString[0] == 'l') layout = G4Text::left;
|
||||
else if (layoutString[0] == 'c') layout = G4Text::centre;
|
||||
else if (layoutString[0] == 'r') layout = G4Text::right;
|
||||
|
||||
Date* date = new Date(fpVisManager, size, x, y, layout, dateString);
|
||||
G4VModel* model =
|
||||
@@ -458,7 +459,7 @@ void G4VisCommandSceneAddDate::SetNewValue (G4UIcommand*, G4String newValue)
|
||||
}
|
||||
|
||||
void G4VisCommandSceneAddDate::Date::operator()
|
||||
(G4VGraphicsScene& sceneHandler, const G4Transform3D&, const G4ModelingParameters*)
|
||||
(G4VGraphicsScene& sceneHandler, const G4ModelingParameters*)
|
||||
{
|
||||
G4String time;
|
||||
if (fDate == "-") {
|
||||
@@ -675,9 +676,9 @@ void G4VisCommandSceneAddEventID::SetNewValue (G4UIcommand*, G4String newValue)
|
||||
is >> size >> x >> y >> layoutString;
|
||||
|
||||
G4Text::Layout layout = G4Text::right;
|
||||
if (layoutString(0) == 'l') layout = G4Text::left;
|
||||
else if (layoutString(0) == 'c') layout = G4Text::centre;
|
||||
else if (layoutString(0) == 'r') layout = G4Text::right;
|
||||
if (layoutString[0] == 'l') layout = G4Text::left;
|
||||
else if (layoutString[0] == 'c') layout = G4Text::centre;
|
||||
else if (layoutString[0] == 'r') layout = G4Text::right;
|
||||
|
||||
// For End of Event (only for reviewing kept events one by one)
|
||||
EventID* eoeEventID
|
||||
@@ -713,7 +714,7 @@ void G4VisCommandSceneAddEventID::SetNewValue (G4UIcommand*, G4String newValue)
|
||||
}
|
||||
|
||||
void G4VisCommandSceneAddEventID::EventID::operator()
|
||||
(G4VGraphicsScene& sceneHandler, const G4Transform3D&, const G4ModelingParameters* mp)
|
||||
(G4VGraphicsScene& sceneHandler, const G4ModelingParameters* mp)
|
||||
{
|
||||
G4RunManager* runManager = G4RunManagerFactory::GetMasterRunManager();
|
||||
if(!runManager)
|
||||
@@ -863,7 +864,7 @@ fExtent(xmin,xmax,ymin,ymax,zmin,zmax)
|
||||
{}
|
||||
|
||||
void G4VisCommandSceneAddExtent::Extent::operator()
|
||||
(G4VGraphicsScene&, const G4Transform3D&, const G4ModelingParameters*)
|
||||
(G4VGraphicsScene&, const G4ModelingParameters*)
|
||||
{}
|
||||
|
||||
////////////// /vis/scene/add/frame ///////////////////////////////////////
|
||||
@@ -926,7 +927,7 @@ void G4VisCommandSceneAddFrame::SetNewValue (G4UIcommand*, G4String newValue)
|
||||
}
|
||||
|
||||
void G4VisCommandSceneAddFrame::Frame::operator()
|
||||
(G4VGraphicsScene& sceneHandler, const G4Transform3D&, const G4ModelingParameters*)
|
||||
(G4VGraphicsScene& sceneHandler, const G4ModelingParameters*)
|
||||
{
|
||||
G4Polyline frame;
|
||||
frame.push_back(G4Point3D( fSize, fSize, 0.));
|
||||
@@ -1148,7 +1149,7 @@ G4VisCommandSceneAddLine::Line::Line
|
||||
}
|
||||
|
||||
void G4VisCommandSceneAddLine::Line::operator()
|
||||
(G4VGraphicsScene& sceneHandler, const G4Transform3D&, const G4ModelingParameters*)
|
||||
(G4VGraphicsScene& sceneHandler, const G4ModelingParameters*)
|
||||
{
|
||||
sceneHandler.BeginPrimitives();
|
||||
sceneHandler.AddPrimitive(fPolyline);
|
||||
@@ -1233,7 +1234,7 @@ G4VisCommandSceneAddLine2D::Line2D::Line2D
|
||||
}
|
||||
|
||||
void G4VisCommandSceneAddLine2D::Line2D::operator()
|
||||
(G4VGraphicsScene& sceneHandler, const G4Transform3D&, const G4ModelingParameters*)
|
||||
(G4VGraphicsScene& sceneHandler, const G4ModelingParameters*)
|
||||
{
|
||||
sceneHandler.BeginPrimitives2D();
|
||||
sceneHandler.AddPrimitive(fPolyline);
|
||||
@@ -1320,8 +1321,7 @@ void G4VisCommandSceneAddLocalAxes::SetNewValue (G4UIcommand*,
|
||||
if (5.*length < lengthMax) length *= 5.;
|
||||
else if (2.*length < lengthMax) length *= 2.;
|
||||
|
||||
const auto& axesModel = new G4AxesModel(0.,0.,0.,length);
|
||||
axesModel->SetTransformation(transform);
|
||||
const auto& axesModel = new G4AxesModel(0.,0.,0.,length,transform);
|
||||
axesModel->SetGlobalTag("LocalAxesModel");
|
||||
std::ostringstream oss; oss
|
||||
<< "Local Axes for " << findings.fpFoundPV->GetName()
|
||||
@@ -1626,11 +1626,11 @@ void G4VisCommandSceneAddLogo::SetNewValue (G4UIcommand*, G4String newValue) {
|
||||
}
|
||||
|
||||
G4double userHeight, red, green, blue, xmid, ymid, zmid;
|
||||
G4String userHeightUnit, direction, auto_manual, positionUnit;
|
||||
G4String userHeightUnit, direction, placement, positionUnit;
|
||||
std::istringstream is (newValue);
|
||||
is >> userHeight >> userHeightUnit >> direction
|
||||
>> red >> green >> blue
|
||||
>> auto_manual
|
||||
>> placement
|
||||
>> xmid >> ymid >> zmid >> positionUnit;
|
||||
|
||||
G4double height = userHeight;
|
||||
@@ -1656,13 +1656,13 @@ void G4VisCommandSceneAddLogo::SetNewValue (G4UIcommand*, G4String newValue) {
|
||||
else if (vp.z() > vp.x() && vp.z() > vp.y()) logoDirection = Z;
|
||||
else if (vp.z() < vp.x() && vp.z() < vp.y()) logoDirection = minusZ;
|
||||
}
|
||||
else if (direction(0) == 'x') logoDirection = X;
|
||||
else if (direction(0) == 'y') logoDirection = Y;
|
||||
else if (direction(0) == 'z') logoDirection = Z;
|
||||
else if (direction(0) == '-') {
|
||||
if (direction(1) == 'x') logoDirection = minusX;
|
||||
else if (direction(1) == 'y') logoDirection = minusY;
|
||||
else if (direction(1) == 'z') logoDirection = minusZ;
|
||||
else if (direction[0] == 'x') logoDirection = X;
|
||||
else if (direction[0] == 'y') logoDirection = Y;
|
||||
else if (direction[0] == 'z') logoDirection = Z;
|
||||
else if (direction[0] == '-') {
|
||||
if (direction[1] == 'x') logoDirection = minusX;
|
||||
else if (direction[1] == 'y') logoDirection = minusY;
|
||||
else if (direction[1] == 'z') logoDirection = minusZ;
|
||||
} else {
|
||||
if (verbosity >= G4VisManager::errors) {
|
||||
G4cerr << "ERROR: Unrecogniseed direction: \""
|
||||
@@ -1671,7 +1671,7 @@ void G4VisCommandSceneAddLogo::SetNewValue (G4UIcommand*, G4String newValue) {
|
||||
}
|
||||
}
|
||||
|
||||
G4bool autoPlacing = false; if (auto_manual == "auto") autoPlacing = true;
|
||||
G4bool autoPlacing = false; if (placement == "auto") autoPlacing = true;
|
||||
// Parameters read and interpreted.
|
||||
|
||||
// Current scene extent
|
||||
@@ -1802,19 +1802,16 @@ void G4VisCommandSceneAddLogo::SetNewValue (G4UIcommand*, G4String newValue) {
|
||||
G4VisAttributes visAtts(G4Colour(red, green, blue));
|
||||
visAtts.SetForceSolid(true); // Always solid.
|
||||
|
||||
G4Logo* logo = new G4Logo(height,visAtts);
|
||||
G4Logo* logo = new G4Logo(height,visAtts,transform);
|
||||
G4VModel* model =
|
||||
new G4CallbackModel<G4VisCommandSceneAddLogo::G4Logo>(logo);
|
||||
model->SetType("G4Logo");
|
||||
model->SetGlobalTag("G4Logo");
|
||||
model->SetGlobalDescription("G4Logo: " + newValue);
|
||||
model->SetTransformation(transform);
|
||||
// Note: it is the responsibility of the model to act upon this, but
|
||||
// the extent is in local coordinates...
|
||||
G4double& h = height;
|
||||
G4double h2 = h/2.;
|
||||
G4VisExtent extent(-h,h,-h2,h2,-h2,h2);
|
||||
model->SetExtent(extent);
|
||||
model->SetExtent(extent.Transform(transform));
|
||||
// This extent gets "added" to existing scene extent in
|
||||
// AddRunDurationModel below.
|
||||
const G4String& currentSceneName = pScene -> GetName ();
|
||||
@@ -1838,8 +1835,7 @@ void G4VisCommandSceneAddLogo::SetNewValue (G4UIcommand*, G4String newValue) {
|
||||
}
|
||||
|
||||
G4VisCommandSceneAddLogo::G4Logo::G4Logo
|
||||
(G4double height, const G4VisAttributes& visAtts):
|
||||
fVisAtts(visAtts)
|
||||
(G4double height, const G4VisAttributes& visAtts, const G4Transform3D& transform)
|
||||
{
|
||||
const G4double& h = height;
|
||||
const G4double h2 = 0.5 * h; // Half height.
|
||||
@@ -1884,8 +1880,9 @@ G4VisCommandSceneAddLogo::G4Logo::G4Logo
|
||||
G4Box bG("bG",w2,ro2,d2);
|
||||
G4UnionSolid logoG("logoG",&tG,&bG,G4Translate3D(ri+w2,-ro2,0.));
|
||||
fpG = logoG.CreatePolyhedron();
|
||||
fpG->SetVisAttributes(&fVisAtts);
|
||||
fpG->SetVisAttributes(visAtts);
|
||||
fpG->Transform(G4Translate3D(-0.55*h,0.,0.));
|
||||
fpG->Transform(transform);
|
||||
|
||||
// 4...
|
||||
G4Box b1("b1",h2,h2,d2);
|
||||
@@ -1908,8 +1905,9 @@ G4VisCommandSceneAddLogo::G4Logo::G4Logo
|
||||
fp4 = new G4Polyhedron();
|
||||
fp4->createPolyhedron(nNodes,nFaces,xyz,faces);
|
||||
*/
|
||||
fp4->SetVisAttributes(&fVisAtts);
|
||||
fp4->SetVisAttributes(visAtts);
|
||||
fp4->Transform(G4Translate3D(0.55*h,0.,0.));
|
||||
fp4->Transform(transform);
|
||||
}
|
||||
|
||||
G4VisCommandSceneAddLogo::G4Logo::~G4Logo() {
|
||||
@@ -1918,8 +1916,8 @@ G4VisCommandSceneAddLogo::G4Logo::~G4Logo() {
|
||||
}
|
||||
|
||||
void G4VisCommandSceneAddLogo::G4Logo::operator()
|
||||
(G4VGraphicsScene& sceneHandler, const G4Transform3D& transform, const G4ModelingParameters*) {
|
||||
sceneHandler.BeginPrimitives(transform);
|
||||
(G4VGraphicsScene& sceneHandler, const G4ModelingParameters*) {
|
||||
sceneHandler.BeginPrimitives();
|
||||
sceneHandler.AddPrimitive(*fpG);
|
||||
sceneHandler.AddPrimitive(*fp4);
|
||||
sceneHandler.EndPrimitives();
|
||||
@@ -1977,9 +1975,9 @@ void G4VisCommandSceneAddLogo2D::SetNewValue (G4UIcommand*, G4String newValue)
|
||||
std::istringstream is(newValue);
|
||||
is >> size >> x >> y >> layoutString;
|
||||
G4Text::Layout layout = G4Text::right;
|
||||
if (layoutString(0) == 'l') layout = G4Text::left;
|
||||
else if (layoutString(0) == 'c') layout = G4Text::centre;
|
||||
else if (layoutString(0) == 'r') layout = G4Text::right;
|
||||
if (layoutString[0] == 'l') layout = G4Text::left;
|
||||
else if (layoutString[0] == 'c') layout = G4Text::centre;
|
||||
else if (layoutString[0] == 'r') layout = G4Text::right;
|
||||
|
||||
Logo2D* logo2D = new Logo2D(fpVisManager, size, x, y, layout);
|
||||
G4VModel* model =
|
||||
@@ -2002,7 +2000,7 @@ void G4VisCommandSceneAddLogo2D::SetNewValue (G4UIcommand*, G4String newValue)
|
||||
}
|
||||
|
||||
void G4VisCommandSceneAddLogo2D::Logo2D::operator()
|
||||
(G4VGraphicsScene& sceneHandler, const G4Transform3D&, const G4ModelingParameters*)
|
||||
(G4VGraphicsScene& sceneHandler, const G4ModelingParameters*)
|
||||
{
|
||||
G4Text text("Geant4", G4Point3D(fX, fY, 0.));
|
||||
text.SetScreenSize(fSize);
|
||||
@@ -2158,7 +2156,22 @@ G4VisCommandSceneAddScale::G4VisCommandSceneAddScale () {
|
||||
fpCommand -> SetGuidance
|
||||
("If \"placement\" is \"auto\", scale is placed at bottom left of current view."
|
||||
"\n Otherwise placed at (xmid,ymid,zmid).");
|
||||
fpCommand -> SetGuidance (G4Scale::GetGuidanceString());
|
||||
fpCommand -> SetGuidance
|
||||
("An annotated line in the specified direction with tick marks at the"
|
||||
"\nend. If autoPlacing is true it is required to be centred at the"
|
||||
"\nfront, right, bottom corner of the world space, comfortably outside"
|
||||
"\nthe existing bounding box/sphere so that existing objects do not"
|
||||
"\nobscure it. Otherwise it is required to be drawn with mid-point at"
|
||||
"\n(xmid, ymid, zmid)."
|
||||
"\n"
|
||||
"\nThe auto placing algorithm is (approx):"
|
||||
"\n x = xmin + (1 + comfort) * (xmax - xmin);"
|
||||
"\n y = ymin - comfort * (ymax - ymin);"
|
||||
"\n z = zmin + (1 + comfort) * (zmax - zmin);"
|
||||
"\n if direction == x then (x - length,y,z) to (x,y,z);"
|
||||
"\n if direction == y then (x,y,z) to (x,y + length,z);"
|
||||
"\n if direction == z then (x,y,z - length) to (x,y,z);"
|
||||
);
|
||||
G4UIparameter* parameter;
|
||||
parameter = new G4UIparameter ("length", 'd', omitable = true);
|
||||
parameter->SetDefaultValue (1.);
|
||||
@@ -2228,11 +2241,11 @@ void G4VisCommandSceneAddScale::SetNewValue (G4UIcommand*, G4String newValue) {
|
||||
}
|
||||
|
||||
G4double userLength, red, green, blue, xmid, ymid, zmid;
|
||||
G4String userLengthUnit, direction, auto_manual, positionUnit;
|
||||
G4String userLengthUnit, direction, placement, positionUnit;
|
||||
std::istringstream is (newValue);
|
||||
is >> userLength >> userLengthUnit >> direction
|
||||
>> red >> green >> blue
|
||||
>> auto_manual
|
||||
>> placement
|
||||
>> xmid >> ymid >> zmid >> positionUnit;
|
||||
|
||||
G4double length = userLength;
|
||||
@@ -2251,9 +2264,9 @@ void G4VisCommandSceneAddScale::SetNewValue (G4UIcommand*, G4String newValue) {
|
||||
G4double unit = G4UIcommand::ValueOf(positionUnit);
|
||||
xmid *= unit; ymid *= unit; zmid *= unit;
|
||||
|
||||
G4Scale::Direction scaleDirection (G4Scale::x);
|
||||
if (direction(0) == 'y') scaleDirection = G4Scale::y;
|
||||
if (direction(0) == 'z') scaleDirection = G4Scale::z;
|
||||
Scale::Direction scaleDirection (Scale::x);
|
||||
if (direction[0] == 'y') scaleDirection = Scale::y;
|
||||
if (direction[0] == 'z') scaleDirection = Scale::z;
|
||||
|
||||
G4VViewer* pViewer = fpVisManager->GetCurrentViewer();
|
||||
if (!pViewer) {
|
||||
@@ -2274,22 +2287,22 @@ void G4VisCommandSceneAddScale::SetNewValue (G4UIcommand*, G4String newValue) {
|
||||
if (direction == "auto") { // Takes cue from viewer.
|
||||
if (std::abs(vp.x()) > std::abs(vp.y()) &&
|
||||
std::abs(vp.x()) > std::abs(vp.z())) { // x viewpoint
|
||||
if (std::abs(up.y()) > std::abs(up.z())) scaleDirection = G4Scale::z;
|
||||
else scaleDirection = G4Scale::y;
|
||||
if (std::abs(up.y()) > std::abs(up.z())) scaleDirection = Scale::z;
|
||||
else scaleDirection = Scale::y;
|
||||
}
|
||||
else if (std::abs(vp.y()) > std::abs(vp.x()) &&
|
||||
std::abs(vp.y()) > std::abs(vp.z())) { // y viewpoint
|
||||
if (std::abs(up.x()) > std::abs(up.z())) scaleDirection = G4Scale::z;
|
||||
else scaleDirection = G4Scale::x;
|
||||
if (std::abs(up.x()) > std::abs(up.z())) scaleDirection = Scale::z;
|
||||
else scaleDirection = Scale::x;
|
||||
}
|
||||
else if (std::abs(vp.z()) > std::abs(vp.x()) &&
|
||||
std::abs(vp.z()) > std::abs(vp.y())) { // z viewpoint
|
||||
if (std::abs(up.y()) > std::abs(up.x())) scaleDirection = G4Scale::x;
|
||||
else scaleDirection = G4Scale::y;
|
||||
if (std::abs(up.y()) > std::abs(up.x())) scaleDirection = Scale::x;
|
||||
else scaleDirection = Scale::y;
|
||||
}
|
||||
}
|
||||
|
||||
G4bool autoPlacing = false; if (auto_manual == "auto") autoPlacing = true;
|
||||
G4bool autoPlacing = false; if (placement == "auto") autoPlacing = true;
|
||||
// Parameters read and interpreted.
|
||||
|
||||
// Useful constants, etc...
|
||||
@@ -2315,16 +2328,17 @@ void G4VisCommandSceneAddScale::SetNewValue (G4UIcommand*, G4String newValue) {
|
||||
<< G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
// Test existing scene for room...
|
||||
G4bool room = true;
|
||||
switch (scaleDirection) {
|
||||
case G4Scale::x:
|
||||
case Scale::x:
|
||||
if (freeLengthFraction * (xmax - xmin) < length) room = false;
|
||||
break;
|
||||
case G4Scale::y:
|
||||
case Scale::y:
|
||||
if (freeLengthFraction * (ymax - ymin) < length) room = false;
|
||||
break;
|
||||
case G4Scale::z:
|
||||
case Scale::z:
|
||||
if (freeLengthFraction * (zmax - zmin) < length) room = false;
|
||||
break;
|
||||
}
|
||||
@@ -2348,22 +2362,8 @@ void G4VisCommandSceneAddScale::SetNewValue (G4UIcommand*, G4String newValue) {
|
||||
}
|
||||
}
|
||||
|
||||
// Let's go ahead a construct a scale and a scale model. Since the
|
||||
// placing is done here, this G4Scale is *not* auto-placed...
|
||||
G4Scale scale(length, annotation, scaleDirection,
|
||||
false, xmid, ymid, zmid,
|
||||
fCurrentTextSize);
|
||||
G4VisAttributes visAttr(G4Colour(red, green, blue));
|
||||
scale.SetVisAttributes(visAttr);
|
||||
G4VModel* model = new G4ScaleModel(scale);
|
||||
G4String globalDescription = model->GetGlobalDescription();
|
||||
globalDescription += " (" + newValue + ")";
|
||||
model->SetGlobalDescription(globalDescription);
|
||||
|
||||
// Now figure out the extent...
|
||||
//
|
||||
// From the G4Scale.hh:
|
||||
//
|
||||
// This creates a representation of annotated line in the specified
|
||||
// direction with tick marks at the end. If autoPlacing is true it
|
||||
// is required to be centred at the front, right, bottom corner of
|
||||
@@ -2379,8 +2379,6 @@ void G4VisCommandSceneAddScale::SetNewValue (G4UIcommand*, G4String newValue) {
|
||||
// if direction == y then (x,y,z) to (x,y + length,z)
|
||||
// if direction == z then (x,y,z - length) to (x,y,z)
|
||||
//
|
||||
// End of clip from G4Scale.hh:
|
||||
//
|
||||
// Implement this in two parts. Here, use the scale's extent to
|
||||
// "expand" the scene's extent. Then rendering - in
|
||||
// G4VSceneHandler::AddPrimitive(const G4Scale&) - simply has to
|
||||
@@ -2395,7 +2393,7 @@ void G4VisCommandSceneAddScale::SetNewValue (G4UIcommand*, G4String newValue) {
|
||||
const G4double yComfort = comfort * (ymax - ymin);
|
||||
const G4double zComfort = comfort * (zmax - zmin);
|
||||
switch (scaleDirection) {
|
||||
case G4Scale::x:
|
||||
case Scale::x:
|
||||
if (vp.z() > 0.) {
|
||||
sxmid = xmax + xComfort;
|
||||
symid = ymin - yComfort;
|
||||
@@ -2406,7 +2404,7 @@ void G4VisCommandSceneAddScale::SetNewValue (G4UIcommand*, G4String newValue) {
|
||||
szmid = zmax + zComfort;
|
||||
}
|
||||
break;
|
||||
case G4Scale::y:
|
||||
case Scale::y:
|
||||
if (vp.x() > 0.) {
|
||||
sxmid = xmin - xComfort;
|
||||
symid = ymax + yComfort;
|
||||
@@ -2417,7 +2415,7 @@ void G4VisCommandSceneAddScale::SetNewValue (G4UIcommand*, G4String newValue) {
|
||||
szmid = zmin - zComfort;
|
||||
}
|
||||
break;
|
||||
case G4Scale::z:
|
||||
case Scale::z:
|
||||
if (vp.x() > 0.) {
|
||||
sxmid = xmax + xComfort;
|
||||
symid = ymin - yComfort;
|
||||
@@ -2431,78 +2429,47 @@ void G4VisCommandSceneAddScale::SetNewValue (G4UIcommand*, G4String newValue) {
|
||||
}
|
||||
}
|
||||
|
||||
/* Old code - kept for future reference.
|
||||
G4double sxmid(xmid), symid(ymid), szmid(zmid);
|
||||
if (autoPlacing) {
|
||||
sxmid = xmin + onePlusComfort * (xmax - xmin);
|
||||
symid = ymin - comfort * (ymax - ymin);
|
||||
szmid = zmin + onePlusComfort * (zmax - zmin);
|
||||
switch (scaleDirection) {
|
||||
case G4Scale::x:
|
||||
sxmid -= halfLength;
|
||||
break;
|
||||
case G4Scale::y:
|
||||
symid += halfLength;
|
||||
break;
|
||||
case G4Scale::z:
|
||||
szmid -= halfLength;
|
||||
break;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/* sxmin, etc., not actually used. Comment out to prevent compiler
|
||||
warnings but keep in case need in future. Extract transform and
|
||||
scaleExtent into reduced code below.
|
||||
G4double sxmin(sxmid), sxmax(sxmid);
|
||||
G4double symin(symid), symax(symid);
|
||||
G4double szmin(szmid), szmax(szmid);
|
||||
G4Transform3D transform;
|
||||
G4VisExtent scaleExtent;
|
||||
const G4double h = halfLength;
|
||||
const G4double t = h/5.;
|
||||
G4VisExtent scaleExtent(-h,h,-t,t,-t,t);
|
||||
switch (scaleDirection) {
|
||||
case G4Scale::x:
|
||||
sxmin = sxmid - halfLength;
|
||||
sxmax = sxmid + halfLength;
|
||||
scaleExtent = G4VisExtent(-halfLength,halfLength,0,0,0,0);
|
||||
case Scale::x:
|
||||
break;
|
||||
case G4Scale::y:
|
||||
symin = symid - halfLength;
|
||||
symax = symid + halfLength;
|
||||
case Scale::y:
|
||||
transform = G4RotateZ3D(halfpi);
|
||||
scaleExtent = G4VisExtent(0,0,-halfLength,halfLength,0,0);
|
||||
break;
|
||||
case G4Scale::z:
|
||||
szmin = szmid - halfLength;
|
||||
szmax = szmid + halfLength;
|
||||
case Scale::z:
|
||||
transform = G4RotateY3D(halfpi);
|
||||
scaleExtent = G4VisExtent(0,0,0,0,-halfLength,halfLength);
|
||||
break;
|
||||
}
|
||||
*/
|
||||
G4Transform3D transform;
|
||||
G4VisExtent scaleExtent;
|
||||
switch (scaleDirection) {
|
||||
case G4Scale::x:
|
||||
scaleExtent = G4VisExtent(-halfLength,halfLength,0,0,0,0);
|
||||
break;
|
||||
case G4Scale::y:
|
||||
transform = G4RotateZ3D(halfpi);
|
||||
scaleExtent = G4VisExtent(0,0,-halfLength,halfLength,0,0);
|
||||
break;
|
||||
case G4Scale::z:
|
||||
transform = G4RotateY3D(halfpi);
|
||||
scaleExtent = G4VisExtent(0,0,0,0,-halfLength,halfLength);
|
||||
break;
|
||||
}
|
||||
transform = G4Translate3D(sxmid,symid,szmid) * transform;
|
||||
///////// G4VisExtent scaleExtent(sxmin, sxmax, symin, symax, szmin, szmax);
|
||||
scaleExtent = scaleExtent.Transform(transform);
|
||||
|
||||
model->SetTransformation(transform);
|
||||
// Note: it is the responsibility of the model to act upon this, but
|
||||
// the extent is in local coordinates...
|
||||
G4Colour colour(red, green, blue);
|
||||
if (direction == "auto") {
|
||||
switch (scaleDirection) {
|
||||
case Scale::x:
|
||||
colour = G4Colour::Red();
|
||||
break;
|
||||
case Scale::y:
|
||||
colour = G4Colour::Green();
|
||||
break;
|
||||
case Scale::z:
|
||||
colour = G4Colour::Blue();
|
||||
break;
|
||||
}
|
||||
}
|
||||
G4VisAttributes visAttr(colour);
|
||||
|
||||
Scale* scale = new Scale
|
||||
(visAttr, length, transform,
|
||||
annotation, fCurrentTextSize, colour);
|
||||
G4VModel* model = new G4CallbackModel<Scale>(scale);
|
||||
model->SetType("Scale");
|
||||
model->SetGlobalTag("Scale");
|
||||
model->SetGlobalDescription("Scale: " + newValue);
|
||||
model->SetExtent(scaleExtent);
|
||||
// This extent gets "added" to existing scene extent in
|
||||
// AddRunDurationModel below.
|
||||
|
||||
const G4String& currentSceneName = pScene -> GetName ();
|
||||
G4bool successful = pScene -> AddRunDurationModel (model, warn);
|
||||
@@ -2523,6 +2490,68 @@ void G4VisCommandSceneAddScale::SetNewValue (G4UIcommand*, G4String newValue) {
|
||||
CheckSceneAndNotifyHandlers (pScene);
|
||||
}
|
||||
|
||||
G4VisCommandSceneAddScale::Scale::Scale
|
||||
(const G4VisAttributes& visAtts,
|
||||
G4double length, const G4Transform3D& transform,
|
||||
const G4String& annotation, G4double annotationSize,
|
||||
const G4Colour& annotationColour):
|
||||
fVisAtts(visAtts)
|
||||
{
|
||||
// Useful constants...
|
||||
const G4double halfLength(length / 2.);
|
||||
const G4double tickLength(length / 20.);
|
||||
|
||||
// Create (empty) polylines having the same vis attributes...
|
||||
// (OK to pass address since fVisAtts is long lived.)
|
||||
fScaleLine.SetVisAttributes(&fVisAtts);
|
||||
fTick11.SetVisAttributes(&fVisAtts);
|
||||
fTick12.SetVisAttributes(&fVisAtts);
|
||||
fTick21.SetVisAttributes(&fVisAtts);
|
||||
fTick22.SetVisAttributes(&fVisAtts);
|
||||
|
||||
// Add points to the polylines to represent a scale parallel to the
|
||||
// x-axis centred on the origin...
|
||||
G4Point3D r1(G4Point3D(-halfLength, 0., 0.));
|
||||
G4Point3D r2(G4Point3D( halfLength, 0., 0.));
|
||||
fScaleLine.push_back(r1);
|
||||
fScaleLine.push_back(r2);
|
||||
G4Point3D ticky(0., tickLength, 0.);
|
||||
G4Point3D tickz(0., 0., tickLength);
|
||||
fTick11.push_back(r1 + ticky);
|
||||
fTick11.push_back(r1 - ticky);
|
||||
fTick12.push_back(r1 + tickz);
|
||||
fTick12.push_back(r1 - tickz);
|
||||
fTick21.push_back(r2 + ticky);
|
||||
fTick21.push_back(r2 - ticky);
|
||||
fTick22.push_back(r2 + tickz);
|
||||
fTick22.push_back(r2 - tickz);
|
||||
// ...and transform to chosen position and orientation
|
||||
fScaleLine.transform(transform);
|
||||
fTick11.transform(transform);
|
||||
fTick12.transform(transform);
|
||||
fTick21.transform(transform);
|
||||
fTick22.transform(transform);
|
||||
// Similarly for annotation
|
||||
G4Point3D textPosition(0., tickLength, 0.);
|
||||
textPosition.transform(transform);
|
||||
fText = G4Text(annotation,textPosition);
|
||||
fText.SetVisAttributes(annotationColour);
|
||||
fText.SetScreenSize(annotationSize);
|
||||
}
|
||||
|
||||
void G4VisCommandSceneAddScale::Scale::operator()
|
||||
(G4VGraphicsScene& sceneHandler,const G4ModelingParameters*)
|
||||
{
|
||||
// Draw...
|
||||
sceneHandler.BeginPrimitives();
|
||||
sceneHandler.AddPrimitive(fScaleLine);
|
||||
sceneHandler.AddPrimitive(fTick11);
|
||||
sceneHandler.AddPrimitive(fTick12);
|
||||
sceneHandler.AddPrimitive(fTick21);
|
||||
sceneHandler.AddPrimitive(fTick22);
|
||||
sceneHandler.AddPrimitive(fText);
|
||||
sceneHandler.EndPrimitives();
|
||||
}
|
||||
|
||||
////////////// /vis/scene/add/text //////////////////////////////////
|
||||
|
||||
@@ -2716,8 +2745,8 @@ G4VisCommandSceneAddText2D::G4Text2D::G4Text2D(const G4Text& text):
|
||||
{}
|
||||
|
||||
void G4VisCommandSceneAddText2D::G4Text2D::operator()
|
||||
(G4VGraphicsScene& sceneHandler, const G4Transform3D& transform, const G4ModelingParameters*) {
|
||||
sceneHandler.BeginPrimitives2D(transform);
|
||||
(G4VGraphicsScene& sceneHandler, const G4ModelingParameters*) {
|
||||
sceneHandler.BeginPrimitives2D();
|
||||
sceneHandler.AddPrimitive(fText);
|
||||
sceneHandler.EndPrimitives2D();
|
||||
}
|
||||
@@ -3297,3 +3326,49 @@ void G4VisCommandSceneAddVolume::SetNewValue (G4UIcommand*,
|
||||
|
||||
CheckSceneAndNotifyHandlers(pScene);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
////////////// /vis/scene/add/plotter ///////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
G4VisCommandSceneAddPlotter::G4VisCommandSceneAddPlotter () {
|
||||
fpCommand = new G4UIcommand("/vis/scene/add/plotter", this);
|
||||
fpCommand -> SetGuidance ("Add a plotter to current scene.");
|
||||
|
||||
G4UIparameter* parameter;
|
||||
parameter = new G4UIparameter ("plotter", 's',false);
|
||||
fpCommand->SetParameter(parameter);
|
||||
}
|
||||
|
||||
G4VisCommandSceneAddPlotter::~G4VisCommandSceneAddPlotter () {delete fpCommand;}
|
||||
|
||||
G4String G4VisCommandSceneAddPlotter::GetCurrentValue (G4UIcommand*) {return "";}
|
||||
|
||||
void G4VisCommandSceneAddPlotter::SetNewValue (G4UIcommand*, G4String newValue)
|
||||
{
|
||||
G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
|
||||
G4bool warn(verbosity >= G4VisManager::warnings);
|
||||
|
||||
G4Scene* pScene = fpVisManager->GetCurrentScene();
|
||||
if (!pScene) {
|
||||
if (verbosity >= G4VisManager::errors) {
|
||||
G4cerr << "ERROR: No current scene. Please create one." << G4endl;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
G4Plotter& _plotter = G4PlotterManager::GetInstance().GetPlotter(newValue);
|
||||
|
||||
G4VModel* model = new G4PlotterModel(_plotter);
|
||||
|
||||
const G4String& currentSceneName = pScene -> GetName ();
|
||||
G4bool successful = pScene -> AddRunDurationModel (model, warn);
|
||||
if (successful) {
|
||||
if (verbosity >= G4VisManager::confirmations) {
|
||||
G4cout << "Arrow has been added to scene \"" << currentSceneName << "\"." << G4endl;
|
||||
}
|
||||
}
|
||||
else G4VisCommandsSceneAddUnsuccessful(verbosity);
|
||||
|
||||
CheckSceneAndNotifyHandlers (pScene);
|
||||
}
|
||||
|
||||
|
||||
@@ -153,10 +153,11 @@ G4VisCommandSceneHandlerCreate::G4VisCommandSceneHandlerCreate (): fId (0) {
|
||||
const G4String& name = gs -> GetName ();
|
||||
candidates += name + ' ';
|
||||
for (const auto& nickname: gs -> GetNicknames ()) {
|
||||
if (G4StrUtil::contains(nickname, "FALLBACK")) continue;
|
||||
if (nickname != name) candidates += nickname + ' ';
|
||||
}
|
||||
}
|
||||
candidates = candidates.strip ();
|
||||
G4StrUtil::strip(candidates);
|
||||
parameter -> SetParameterCandidates(candidates);
|
||||
fpCommand -> SetParameter (parameter);
|
||||
parameter = new G4UIparameter
|
||||
@@ -223,14 +224,14 @@ void G4VisCommandSceneHandlerCreate::SetNewValue (G4UIcommand* command,
|
||||
G4bool found = false;
|
||||
for (iGS = 0; iGS < nSystems; iGS++) {
|
||||
const auto& gs = gsl[iGS];
|
||||
if (graphicsSystem.compareTo(gs->GetName(), G4String::ignoreCase) == 0) {
|
||||
if (G4StrUtil::icompare(graphicsSystem, gs->GetName()) == 0) {
|
||||
found = true;
|
||||
break; // Match found
|
||||
} else {
|
||||
const auto& nicknames = gs->GetNicknames();
|
||||
for (size_t i = 0; i < nicknames.size(); ++i) {
|
||||
const auto& nickname = nicknames[i];
|
||||
if (graphicsSystem.compareTo (nickname, G4String::ignoreCase) == 0) {
|
||||
if (G4StrUtil::icompare(graphicsSystem, nickname) == 0) {
|
||||
found = true;
|
||||
break; // Match found
|
||||
}
|
||||
@@ -247,7 +248,7 @@ void G4VisCommandSceneHandlerCreate::SetNewValue (G4UIcommand* command,
|
||||
for (const auto gs: fpVisManager -> GetAvailableGraphicsSystems()) {
|
||||
// Just list nicknames, but exclude FALLBACK nicknames
|
||||
for (const auto& nickname: gs->GetNicknames()) {
|
||||
if (!nickname.contains("FALLBACK")) {
|
||||
if (!G4StrUtil::contains(nickname, "FALLBACK")) {
|
||||
candidates.insert(nickname);
|
||||
}
|
||||
}
|
||||
@@ -278,7 +279,7 @@ void G4VisCommandSceneHandlerCreate::SetNewValue (G4UIcommand* command,
|
||||
const auto& nicknames = gsl[iGS]->GetNicknames();
|
||||
for (size_t i = 0; i < nicknames.size(); ++i) {
|
||||
const auto& nickname = nicknames[i];
|
||||
if (fallbackNickname.compareTo (nickname, G4String::ignoreCase) == 0) {
|
||||
if (G4StrUtil::icompare(fallbackNickname, nickname) == 0) {
|
||||
fallback = true;
|
||||
break; // Match found
|
||||
}
|
||||
@@ -312,18 +313,6 @@ void G4VisCommandSceneHandlerCreate::SetNewValue (G4UIcommand* command,
|
||||
<< G4endl;
|
||||
}
|
||||
|
||||
// Set current graphics system in preparation for
|
||||
// creating scene handler.
|
||||
fpVisManager -> SetCurrentGraphicsSystem (pSystem);
|
||||
if (verbosity >= G4VisManager::confirmations) {
|
||||
G4cout << "Graphics system set to "
|
||||
<< pSystem -> GetName ()
|
||||
<< " ("
|
||||
<< pSystem -> GetNickname ()
|
||||
<< ')'
|
||||
<< G4endl;
|
||||
}
|
||||
|
||||
// Now deal with name of scene handler.
|
||||
G4String nextName = NextName ();
|
||||
if (newName == "") {
|
||||
@@ -345,6 +334,24 @@ void G4VisCommandSceneHandlerCreate::SetNewValue (G4UIcommand* command,
|
||||
}
|
||||
}
|
||||
|
||||
// If there is an existing viewer, store its view parameters
|
||||
if (fpVisManager->GetCurrentViewer()) {
|
||||
fThereWasAViewer = true;
|
||||
fVPExistingViewer = fpVisManager->GetCurrentViewer()->GetViewParameters();
|
||||
}
|
||||
|
||||
// Set current graphics system in preparation for
|
||||
// creating scene handler.
|
||||
fpVisManager -> SetCurrentGraphicsSystem (pSystem);
|
||||
if (verbosity >= G4VisManager::confirmations) {
|
||||
G4cout << "Graphics system set to "
|
||||
<< pSystem -> GetName ()
|
||||
<< " ("
|
||||
<< pSystem -> GetNickname ()
|
||||
<< ')'
|
||||
<< G4endl;
|
||||
}
|
||||
|
||||
//Create scene handler.
|
||||
fpVisManager -> CreateSceneHandler (newName);
|
||||
if (fpVisManager -> GetCurrentSceneHandler () -> GetName () != newName) {
|
||||
@@ -364,8 +371,15 @@ void G4VisCommandSceneHandlerCreate::SetNewValue (G4UIcommand* command,
|
||||
if (verbosity >= G4VisManager::confirmations)
|
||||
G4cout << "New scene handler \"" << newName << "\" created." << G4endl;
|
||||
|
||||
if (fpVisManager -> GetCurrentScene ())
|
||||
G4UImanager::GetUIpointer () -> ApplyCommand ("/vis/sceneHandler/attach");
|
||||
if (fpVisManager -> GetCurrentScene ()) {
|
||||
auto errorCode = G4UImanager::GetUIpointer () -> ApplyCommand ("/vis/sceneHandler/attach");
|
||||
if (errorCode) {
|
||||
G4ExceptionDescription ed;
|
||||
ed << "sub-command \"/vis/sceneHandler/attach\" failed.";
|
||||
command->CommandFailed(errorCode,ed);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////// /vis/sceneHandler/list ///////////////////////////////////////
|
||||
|
||||
@@ -416,7 +416,7 @@ void G4VisCommandSetTouchable::SetNewValue (G4UIcommand*, G4String newValue)
|
||||
{
|
||||
G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
|
||||
|
||||
if (newValue.isNull()) {
|
||||
if (newValue.empty()) {
|
||||
fCurrentTouchableProperties = G4PhysicalVolumeModel::TouchableProperties();
|
||||
if (verbosity >= G4VisManager::confirmations) {
|
||||
G4cout <<
|
||||
|
||||
@@ -301,8 +301,8 @@ void G4VisCommandsTouchable::SetNewValue
|
||||
G4Polyhedron* polyhedron =
|
||||
properties.fpTouchablePV->GetLogicalVolume()->GetSolid()->GetPolyhedron();
|
||||
G4cout << "\nLocal polyhedron coordinates:\n" << *polyhedron;
|
||||
G4Transform3D* transform = tempPVModel.GetCurrentTransform();
|
||||
polyhedron->Transform(*transform);
|
||||
const G4Transform3D& transform = tempPVModel.GetCurrentTransform();
|
||||
polyhedron->Transform(transform);
|
||||
G4cout << "\nGlobal polyhedron coordinates:\n" << *polyhedron;
|
||||
} else {
|
||||
G4cout << "Touchable not found." << G4endl;
|
||||
@@ -382,8 +382,7 @@ void G4VisCommandsTouchable::SetNewValue
|
||||
G4double length = std::pow(10,intLog10LengthMax);
|
||||
if (5.*length < lengthMax) length *= 5.;
|
||||
else if (2.*length < lengthMax) length *= 2.;
|
||||
G4AxesModel axesModel(0.,0.,0.,length);
|
||||
axesModel.SetTransformation(transform);
|
||||
G4AxesModel axesModel(0.,0.,0.,length,transform);
|
||||
axesModel.SetGlobalTag("LocalAxesModel");
|
||||
axesModel.DescribeYourselfTo(*fpVisManager->GetCurrentSceneHandler());
|
||||
|
||||
|
||||
@@ -610,8 +610,8 @@ void G4VisCommandViewerClone::SetNewValue (G4UIcommand*, G4String newValue) {
|
||||
originalName += c;
|
||||
while (is.get(c) && c != ' ') {originalName += c;}
|
||||
}
|
||||
originalName = originalName.strip (G4String::both, ' ');
|
||||
originalName = originalName.strip (G4String::both, '"');
|
||||
G4StrUtil::strip(originalName, ' ');
|
||||
G4StrUtil::strip(originalName, '"');
|
||||
|
||||
G4VViewer* originalViewer = fpVisManager -> GetViewer (originalName);
|
||||
if (!originalViewer) {
|
||||
@@ -632,8 +632,8 @@ void G4VisCommandViewerClone::SetNewValue (G4UIcommand*, G4String newValue) {
|
||||
cloneName += c;
|
||||
while (is.get(c) && c != ' ') {cloneName += c;}
|
||||
}
|
||||
cloneName = cloneName.strip (G4String::both, ' ');
|
||||
cloneName = cloneName.strip (G4String::both, '"');
|
||||
G4StrUtil::strip(cloneName, ' ');
|
||||
G4StrUtil::strip(cloneName, '"');
|
||||
|
||||
G4bool errorWhileNaming = false;
|
||||
if (cloneName == "none") {
|
||||
@@ -873,16 +873,7 @@ void G4VisCommandViewerCopyViewFrom::SetNewValue (G4UIcommand*, G4String newValu
|
||||
|
||||
// Copy camera-specific view parameters
|
||||
G4ViewParameters vp = currentViewer->GetViewParameters();
|
||||
const G4ViewParameters& fromVP = fromViewer->GetViewParameters();
|
||||
vp.SetViewpointDirection (fromVP.GetViewpointDirection());
|
||||
vp.SetLightpointDirection (fromVP.GetLightpointDirection());
|
||||
vp.SetLightsMoveWithCamera(fromVP.GetLightsMoveWithCamera());
|
||||
vp.SetUpVector (fromVP.GetUpVector());
|
||||
vp.SetFieldHalfAngle (fromVP.GetFieldHalfAngle());
|
||||
vp.SetZoomFactor (fromVP.GetZoomFactor());
|
||||
vp.SetScaleFactor (fromVP.GetScaleFactor());
|
||||
vp.SetCurrentTargetPoint (fromVP.GetCurrentTargetPoint());
|
||||
vp.SetDolly (fromVP.GetDolly());
|
||||
CopyCameraParameters(vp, fromViewer->GetViewParameters());
|
||||
SetViewParameters(currentViewer, vp);
|
||||
|
||||
if (verbosity >= G4VisManager::confirmations) {
|
||||
@@ -979,8 +970,8 @@ void G4VisCommandViewerCreate::SetNewValue (G4UIcommand* command, G4String newVa
|
||||
newName += c;
|
||||
while (is.get(c) && c != ' ') {newName += c;}
|
||||
}
|
||||
newName = newName.strip (G4String::both, ' ');
|
||||
newName = newName.strip (G4String::both, '"');
|
||||
G4StrUtil::strip(newName, ' ');
|
||||
G4StrUtil::strip(newName, '"');
|
||||
|
||||
// Now get window size hint...
|
||||
is >> windowSizeHintString;
|
||||
@@ -1041,6 +1032,17 @@ void G4VisCommandViewerCreate::SetNewValue (G4UIcommand* command, G4String newVa
|
||||
}
|
||||
}
|
||||
|
||||
// If there was an existing viewer, use its view parameters
|
||||
if (fThereWasAViewer) {
|
||||
// OK, we're going to use its view parameters below
|
||||
} else {
|
||||
// There wasn't one...but if there now is...
|
||||
if (fpVisManager->GetCurrentViewer()) {
|
||||
fThereWasAViewer = true;
|
||||
fVPExistingViewer = fpVisManager->GetCurrentViewer()->GetViewParameters();
|
||||
}
|
||||
}
|
||||
|
||||
// WindowSizeHint and XGeometryString are picked up from the vis
|
||||
// manager in the G4VViewer constructor. In G4VisManager, after Viewer
|
||||
// creation, we will store theses parameters in G4ViewParameters.
|
||||
@@ -1048,7 +1050,13 @@ void G4VisCommandViewerCreate::SetNewValue (G4UIcommand* command, G4String newVa
|
||||
fpVisManager -> CreateViewer (newName,windowSizeHintString);
|
||||
|
||||
G4VViewer* newViewer = fpVisManager -> GetCurrentViewer ();
|
||||
|
||||
if (newViewer && newViewer -> GetName () == newName) {
|
||||
if (fThereWasAViewer) {
|
||||
G4ViewParameters vp = newViewer->GetViewParameters();
|
||||
CopyMostViewParameters(vp, fVPExistingViewer);
|
||||
fpVisManager->GetCurrentViewer()->SetViewParameters(vp);
|
||||
}
|
||||
if (verbosity >= G4VisManager::confirmations) {
|
||||
G4cout << "New viewer \"" << newName << "\" created." << G4endl;
|
||||
}
|
||||
@@ -1344,7 +1352,7 @@ void G4VisCommandViewerInterpolate::SetNewValue (G4UIcommand*, G4String newValue
|
||||
// Assume user has specified a Unix "glob" pattern in leaf
|
||||
// Default pattern is *.g4view, which translates to ^.*\\.g4view
|
||||
// Convert pattern into a regexp
|
||||
G4String regexp_pattern('^');
|
||||
G4String regexp_pattern("^");
|
||||
for (size_t i = 0; i < pattern.length(); ++i) {
|
||||
if (pattern[i] == '.') {
|
||||
regexp_pattern += "\\.";
|
||||
@@ -1918,7 +1926,7 @@ void G4VisCommandViewerSave::SetNewValue (G4UIcommand*, G4String newValue) {
|
||||
WriteCommands(G4cout,vp,stp);
|
||||
} else {
|
||||
// Write to file - but add extension if not prescribed
|
||||
if (!filename.contains('.')) {
|
||||
if (!G4StrUtil::contains(filename, '.')) {
|
||||
// No extension supplied - add .g4view
|
||||
filename += ".g4view";
|
||||
}
|
||||
|
||||
@@ -697,11 +697,8 @@ void G4VisCommandsViewerSet::SetNewValue
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Copy view parameters except for autoRefresh...
|
||||
G4bool currentAutoRefresh =
|
||||
currentViewer->GetViewParameters().IsAutoRefresh();
|
||||
vp = fromViewer->GetViewParameters();
|
||||
vp.SetAutoRefresh(currentAutoRefresh);
|
||||
// Copy view parameters except for autoRefresh and background...
|
||||
CopyMostViewParameters(vp, fromViewer->GetViewParameters());
|
||||
// Concatenate any private vis attributes modifiers...
|
||||
const std::vector<G4ModelingParameters::VisAttributesModifier>*
|
||||
privateVAMs = fromViewer->GetPrivateVisAttributesModifiers();
|
||||
@@ -1182,9 +1179,9 @@ void G4VisCommandsViewerSet::SetNewValue
|
||||
std::istringstream is (newValue);
|
||||
is >> choice >> x >> y >> z >> unit >> nx >> ny >> nz;
|
||||
G4int iSelector = -1;
|
||||
if (choice.compareTo("off",G4String::ignoreCase) == 0 ||
|
||||
if (G4StrUtil::icompare(choice, "off") == 0 ||
|
||||
!G4UIcommand::ConvertToBool(choice)) iSelector = 0;
|
||||
if (choice.compareTo("on",G4String::ignoreCase) == 0 ||
|
||||
if (G4StrUtil::icompare(choice, "on") == 0 ||
|
||||
G4UIcommand::ConvertToBool(choice)) iSelector = 1;
|
||||
if (iSelector < 0) {
|
||||
if (verbosity >= G4VisManager::errors) {
|
||||
@@ -1234,7 +1231,7 @@ void G4VisCommandsViewerSet::SetNewValue
|
||||
|
||||
else if (command == fpCommandSpecialMeshVolumes) {
|
||||
std::vector<G4ModelingParameters::PVNameCopyNo> requestedMeshes;
|
||||
if (newValue.isNull()) {
|
||||
if (newValue.empty()) {
|
||||
vp.SetSpecialMeshVolumes(requestedMeshes); // Empty list
|
||||
} else {
|
||||
// Algorithm from Josuttis p.476.
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include "G4VisCommandsSet.hh"
|
||||
#include "G4VisCommandsScene.hh"
|
||||
#include "G4VisCommandsSceneAdd.hh"
|
||||
#include "G4VisCommandsPlotter.hh"
|
||||
#include "G4VisCommandsSceneHandler.hh"
|
||||
#include "G4VisCommandsTouchable.hh"
|
||||
#include "G4VisCommandsTouchableSet.hh"
|
||||
@@ -189,8 +190,10 @@ G4VisManager::G4VisManager (const G4String& verbosityString):
|
||||
|
||||
// Make top level command directory...
|
||||
// Vis commands should *not* be broadcast to threads (2nd argument).
|
||||
G4UIcommand* directory = new G4UIdirectory ("/vis/",false);
|
||||
auto directory = new G4UIdirectory ("/vis/",false);
|
||||
directory -> SetGuidance ("Visualization commands.");
|
||||
// Request commands in name order
|
||||
directory -> Sort(); // Ordering propagates to sub-directories
|
||||
fDirectoryList.push_back (directory);
|
||||
|
||||
// Instantiate *basic* top level commands so that they can be used
|
||||
@@ -206,7 +209,6 @@ G4VisManager::~G4VisManager()
|
||||
{
|
||||
G4UImanager* UImanager = G4UImanager::GetUIpointer();
|
||||
UImanager->SetCoutDestination(nullptr);
|
||||
fpInstance = 0;
|
||||
size_t i;
|
||||
for (i = 0; i < fSceneList.size (); ++i) {
|
||||
delete fSceneList[i];
|
||||
@@ -236,6 +238,7 @@ G4VisManager::~G4VisManager()
|
||||
delete fpHitFilterMgr;
|
||||
delete fpTrajFilterMgr;
|
||||
delete fpTrajDrawModelMgr;
|
||||
fpInstance = 0;
|
||||
}
|
||||
|
||||
G4VisManager* G4VisManager::GetInstance () {
|
||||
@@ -512,6 +515,7 @@ void G4VisManager::RegisterMessengers () {
|
||||
RegisterMessenger(new G4VisCommandSceneEndOfRunAction);
|
||||
RegisterMessenger(new G4VisCommandSceneList);
|
||||
RegisterMessenger(new G4VisCommandSceneNotifyHandlers);
|
||||
RegisterMessenger(new G4VisCommandSceneRemoveModel);
|
||||
RegisterMessenger(new G4VisCommandSceneSelect);
|
||||
RegisterMessenger(new G4VisCommandSceneShowExtents);
|
||||
|
||||
@@ -536,6 +540,7 @@ void G4VisManager::RegisterMessengers () {
|
||||
RegisterMessenger(new G4VisCommandSceneAddLogo);
|
||||
RegisterMessenger(new G4VisCommandSceneAddLogo2D);
|
||||
RegisterMessenger(new G4VisCommandSceneAddMagneticField);
|
||||
RegisterMessenger(new G4VisCommandSceneAddPlotter);
|
||||
RegisterMessenger(new G4VisCommandSceneAddPSHits);
|
||||
RegisterMessenger(new G4VisCommandSceneAddScale);
|
||||
RegisterMessenger(new G4VisCommandSceneAddText);
|
||||
@@ -544,6 +549,17 @@ void G4VisManager::RegisterMessengers () {
|
||||
RegisterMessenger(new G4VisCommandSceneAddUserAction);
|
||||
RegisterMessenger(new G4VisCommandSceneAddVolume);
|
||||
|
||||
RegisterMessenger(new G4VisCommandPlotterCreate);
|
||||
RegisterMessenger(new G4VisCommandPlotterSetLayout);
|
||||
RegisterMessenger(new G4VisCommandPlotterAddStyle);
|
||||
RegisterMessenger(new G4VisCommandPlotterAddRegionStyle);
|
||||
RegisterMessenger(new G4VisCommandPlotterAddRegionParameter);
|
||||
RegisterMessenger(new G4VisCommandPlotterClear);
|
||||
RegisterMessenger(new G4VisCommandPlotterClearRegion);
|
||||
RegisterMessenger(new G4VisCommandPlotterList);
|
||||
RegisterMessenger(new G4VisCommandPlotterAddRegionH1);
|
||||
RegisterMessenger(new G4VisCommandPlotterAddRegionH2);
|
||||
|
||||
directory = new G4UIdirectory ("/vis/sceneHandler/");
|
||||
directory -> SetGuidance ("Operations on Geant4 scene handlers.");
|
||||
fDirectoryList.push_back (directory);
|
||||
@@ -955,12 +971,6 @@ void G4VisManager::Draw (const G4Polymarker& polymarker,
|
||||
DrawT (polymarker, objectTransform);
|
||||
}
|
||||
|
||||
void G4VisManager::Draw (const G4Scale& scale,
|
||||
const G4Transform3D& objectTransform)
|
||||
{
|
||||
DrawT (scale, objectTransform);
|
||||
}
|
||||
|
||||
void G4VisManager::Draw (const G4Square& square,
|
||||
const G4Transform3D& objectTransform)
|
||||
{
|
||||
@@ -1306,12 +1316,17 @@ void G4VisManager::GeometryHasChanged () {
|
||||
<< "\n Use \"/vis/scene/add/volume\" or create a new scene."
|
||||
<< G4endl;
|
||||
}
|
||||
fpSceneHandler->ClearTransientStore();
|
||||
fpSceneHandler->ClearStore();
|
||||
fpViewer->NeedKernelVisit();
|
||||
fpViewer->SetView();
|
||||
fpViewer->ClearView();
|
||||
fpViewer->FinishView();
|
||||
// Clean up
|
||||
if (fpSceneHandler) {
|
||||
fpSceneHandler->ClearTransientStore();
|
||||
fpSceneHandler->ClearStore();
|
||||
if (fpViewer) {
|
||||
fpViewer->NeedKernelVisit();
|
||||
fpViewer->SetView();
|
||||
fpViewer->ClearView();
|
||||
fpViewer->FinishView();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1570,6 +1585,13 @@ void G4VisManager::SetCurrentSceneHandler (G4VSceneHandler* pSceneHandler) {
|
||||
|
||||
void G4VisManager::SetCurrentViewer (G4VViewer* pViewer) {
|
||||
fpViewer = pViewer;
|
||||
if (fpViewer == nullptr) {
|
||||
if (fVerbosity >= confirmations) {
|
||||
G4cout << "G4VisManager::SetCurrentViewer: current viewer pointer zeroed "
|
||||
<< G4endl;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (fVerbosity >= confirmations) {
|
||||
G4cout << "G4VisManager::SetCurrentViewer: viewer now "
|
||||
<< pViewer -> GetName ()
|
||||
@@ -2132,7 +2154,7 @@ void G4VisManager::EndOfEvent ()
|
||||
|
||||
G4int maxNumberOfKeptEvents = fpScene->GetMaxNumberOfKeptEvents();
|
||||
|
||||
if (maxNumberOfKeptEvents > 0 &&
|
||||
if (maxNumberOfKeptEvents >= 0 &&
|
||||
fNKeepRequests >= maxNumberOfKeptEvents) {
|
||||
|
||||
fEventKeepingSuspended = true;
|
||||
@@ -2343,9 +2365,8 @@ void G4VisManager::ResetTransientsDrawnFlags()
|
||||
}
|
||||
|
||||
G4String G4VisManager::ViewerShortName (const G4String& viewerName) const {
|
||||
G4String viewerShortName (viewerName);
|
||||
viewerShortName = viewerShortName (0, viewerShortName.find (' '));
|
||||
return viewerShortName.strip ();
|
||||
G4String viewerShortName = viewerName.substr(0, viewerName.find (' '));
|
||||
return G4StrUtil::strip_copy(viewerShortName);
|
||||
}
|
||||
|
||||
G4VViewer* G4VisManager::GetViewer (const G4String& viewerName) const {
|
||||
@@ -2388,15 +2409,15 @@ G4String G4VisManager::VerbosityString(Verbosity verbosity) {
|
||||
|
||||
G4VisManager::Verbosity
|
||||
G4VisManager::GetVerbosityValue(const G4String& verbosityString) {
|
||||
G4String ss(verbosityString); ss.toLower();
|
||||
G4String ss = G4StrUtil::to_lower_copy(verbosityString);
|
||||
Verbosity verbosity;
|
||||
if (ss(0) == 'q') verbosity = quiet;
|
||||
else if (ss(0) == 's') verbosity = startup;
|
||||
else if (ss(0) == 'e') verbosity = errors;
|
||||
else if (ss(0) == 'w') verbosity = warnings;
|
||||
else if (ss(0) == 'c') verbosity = confirmations;
|
||||
else if (ss(0) == 'p') verbosity = parameters;
|
||||
else if (ss(0) == 'a') verbosity = all;
|
||||
if (ss[0] == 'q') verbosity = quiet;
|
||||
else if (ss[0] == 's') verbosity = startup;
|
||||
else if (ss[0] == 'e') verbosity = errors;
|
||||
else if (ss[0] == 'w') verbosity = warnings;
|
||||
else if (ss[0] == 'c') verbosity = confirmations;
|
||||
else if (ss[0] == 'p') verbosity = parameters;
|
||||
else if (ss[0] == 'a') verbosity = all;
|
||||
else {
|
||||
G4int intVerbosity;
|
||||
std::istringstream is(ss);
|
||||
|
||||
Reference in New Issue
Block a user