85 std::ostringstream oss;
86 oss << x/uv <<
" " << y/uv <<
" " << unitName;
97 std::istringstream is(paramString);
117 (
"Accepts (a) RGB triplet. e.g., \".3 .4 .5\", or"
118 "\n (b) string such as \"white\", \"black\", \"grey\", \"red\"...or"
119 "\n (c) an additional number for opacity, e.g., \".3 .4 .5 .6\""
120 "\n or \"grey ! ! .6\" (note \"!\"'s for unused parameters).");
141 const std::size_t iPos0 = 0;
142 if (std::isalpha(redOrString[iPos0])) {
148 G4warn <<
"WARNING: Colour \"" << redOrString
149 <<
"\" not found. Defaulting to " << colour
162 std::istringstream iss(redOrString);
167 G4warn <<
"WARNING: String \"" << redOrString
168 <<
"\" cannot be parsed. Defaulting to " << colour
173 colour =
G4Colour(red,green,blue,opacity);
194 <<
"\n Unit \"" << unit <<
"\" not defined"
201 <<
"\n Unit \"" << unit <<
"\" not a unit of " << category;
202 if (category ==
"Volumic Mass")
G4warn <<
" (density)";
218 G4warn <<
"WARNING: Scene pointer is null."
225 if (!pSceneHandler) {
227 G4warn <<
"WARNING: Scene handler not found." <<
G4endl;
236 if (pScene == pSceneHandler->
GetScene()) {
250 "ERROR: No current viewer - \"/vis/viewer/list\" to see possibilities."
264 "WARNING: For some reason, possibly mentioned above, it has not been"
265 "\n possible to add to the scene."
280 if (sceneHandler && sceneHandler->
GetScene()) {
286 G4warn <<
"Issue /vis/viewer/refresh or flush to see effect."
295 std::vector<G4ViewParameters> viewVector,
296 const G4int nInterpolationPoints,
297 const G4int waitTimePerPointmilliseconds,
300 const G4int safety = (
G4int)viewVector.size()*nInterpolationPoints;
301 G4int safetyCount = 0;
308 if (exportString ==
"export" &&
313 if (waitTimePerPointmilliseconds > 0)
314 std::this_thread::sleep_for(std::chrono::milliseconds(waitTimePerPointmilliseconds));
315 }
while (safetyCount++ < safety);
322 const G4int nInterpolationPoints,
323 const G4int waitTimePerPointmilliseconds,
326 std::vector<G4ViewParameters> viewVector;
327 viewVector.push_back(oldVP);
328 viewVector.push_back(oldVP);
329 viewVector.push_back(newVP);
330 viewVector.push_back(newVP);
335 nInterpolationPoints,
336 waitTimePerPointmilliseconds,
345 const std::vector<std::vector<G4PhysicalVolumeModel::G4PhysicalVolumeNodeID>>& paths)
352 for (
const auto& path: paths) {
353 const auto& touchable = path.back().GetPhysicalVolume();
355 = *(currentViewer->GetApplicableVisAttributes
356 (touchable->GetLogicalVolume()->GetVisAttributes()));
357 auto hiVisAtts = loVisAtts;
359 loVisAtts.SetForceSolid();
361 hiVisAtts.SetForceSolid();
362 auto pvNameCopyNoPath
367 loVP.AddVisAttributesModifier(loVAMColour);
370 loVP.AddVisAttributesModifier(loVAMStyle);
374 hiVP.AddVisAttributesModifier(hiVAMColour);
377 hiVP.AddVisAttributesModifier(hiVAMStyle);
381 std::vector<G4ViewParameters> viewVector;
382 viewVector.push_back(loVP);
383 viewVector.push_back(hiVP);
384 viewVector.push_back(loVP);
385 viewVector.push_back(hiVP);
386 viewVector.push_back(loVP);
387 viewVector.push_back(hiVP);
388 viewVector.push_back(loVP);
389 viewVector.push_back(hiVP);
390 viewVector.push_back(loVP);
391 viewVector.push_back(hiVP);
393 InterpolateViews(currentViewer,viewVector,5);
399 if (fromCmd && toCmd) {
401 for (
G4int i = startLine; i < nGuideEntries; ++i) {
411 if (fromCmd && toCmd) {
413 for (
G4int i = 0; i < nParEntries; ++i) {
426 if (halfX > 0. && halfY > 0. && halfZ > 0.) {
427 const G4Box box(
"vis_extent",halfX,halfY,halfZ);
static G4bool GetColour(const G4String &key, G4Colour &result)
static G4ModelingParameters::PVNameCopyNoPath GetPVNameCopyNoPath(const std::vector< G4PhysicalVolumeNodeID > &)
std::size_t GetParameterEntries() const
const G4String & GetGuidanceLine(G4int i) const
G4UIparameter * GetParameter(G4int i) const
static G4double ValueOf(const char *unitName)
void SetParameter(G4UIparameter *const newParameter)
void SetGuidance(const char *aGuidance)
std::size_t GetGuidanceEntries() const
G4int ApplyCommand(const char *aCommand)
static G4UImanager * GetUIpointer()
static G4bool IsUnitDefined(const G4String &)
static G4double GetValueOf(const G4String &)
static G4String GetCategory(const G4String &)
G4Scene * GetScene() const
const G4String & GetName() const
const G4ViewParameters & GetViewParameters() const
void SetViewParameters(const G4ViewParameters &vp)
G4VSceneHandler * GetSceneHandler() const
static G4double fCurrentTextSize
void G4VisCommandsSceneAddUnsuccessful(G4VisManager::Verbosity verbosity)
static void SetVisManager(G4VisManager *pVisManager)
static G4ViewParameters fExistingVP
static G4Colour fCurrentTextColour
void CopyCameraParameters(G4ViewParameters &target, const G4ViewParameters &from)
static G4VisManager * GetVisManager()
void CheckSceneAndNotifyHandlers(G4Scene *=nullptr)
static std::vector< G4PhysicalVolumesSearchScene::Findings > fCurrrentPVFindingsForField
void ConvertToColour(G4Colour &colour, const G4String &redOrString, G4double green, G4double blue, G4double opacity)
static G4VisManager * fpVisManager
static G4VisExtent fCurrentExtentForField
void DrawExtent(const G4VisExtent &)
void InterpolateToNewView(G4VViewer *currentViewer, const G4ViewParameters &oldVP, const G4ViewParameters &newVP, const G4int nInterpolationPoints=50, const G4int waitTimePerPointmilliseconds=20, const G4String exportString="")
static const G4Colour & GetCurrentTextColour()
static G4bool ConvertToDoublePair(const G4String ¶mString, G4double &xval, G4double &yval)
void RefreshIfRequired(G4VViewer *viewer)
void SetViewParameters(G4VViewer *viewer, const G4ViewParameters &viewParams)
const G4String & ConvertToColourGuidance()
void CopyParametersFrom(const G4UIcommand *fromCmd, G4UIcommand *toCmd)
static G4int fCurrentArrow3DLineSegmentsPerCircle
static G4PhysicalVolumeModel::TouchableProperties fCurrentTouchableProperties
G4bool ProvideValueOfUnit(const G4String &where, const G4String &unit, const G4String &category, G4double &value)
static G4Text::Layout fCurrentTextLayout
static G4bool fThereWasAViewer
static G4double fCurrentLineWidth
void Twinkle(G4VViewer *currentViewer, const G4ViewParameters &baseVP, const std::vector< std::vector< G4PhysicalVolumeModel::G4PhysicalVolumeNodeID > > &paths)
static G4String ConvertToString(G4double x, G4double y, const char *unitName)
static G4Colour fCurrentColour
void CopyGuidanceFrom(const G4UIcommand *fromCmd, G4UIcommand *toCmd, G4int startLine=0)
void InterpolateViews(G4VViewer *currentViewer, std::vector< G4ViewParameters > viewVector, const G4int nInterpolationPoints=50, const G4int waitTimePerPointmilliseconds=20, const G4String exportString="")
void SetViewpointDirection(const G4Vector3D &viewpointDirection)
void SetScaleFactor(const G4Vector3D &scaleFactor)
static G4ViewParameters * CatmullRomCubicSplineInterpolation(const std::vector< G4ViewParameters > &views, G4int nInterpolationPoints=50)
const G4Vector3D & GetScaleFactor() const
void SetCurrentTargetPoint(const G4Point3D ¤tTargetPoint)
const G4Vector3D & GetLightpointDirection() const
void SetFieldHalfAngle(G4double fieldHalfAngle)
const G4Vector3D & GetViewpointDirection() const
const G4Point3D & GetCurrentTargetPoint() const
G4double GetFieldHalfAngle() const
G4double GetZoomFactor() const
void SetDolly(G4double dolly)
const G4Vector3D & GetUpVector() const
void SetZoomFactor(G4double zoomFactor)
void SetUpVector(const G4Vector3D &upVector)
void SetLightpointDirection(const G4Vector3D &lightpointDirection)
void SetLightsMoveWithCamera(G4bool moves)
G4bool IsAutoRefresh() const
G4bool GetLightsMoveWithCamera() const
G4double GetDolly() const
const G4Point3D & GetExtentCenter() const
void Draw(const G4Circle &, const G4Transform3D &objectTransformation=G4Transform3D())
static Verbosity GetVerbosity()
G4bool contains(const G4String &str, std::string_view ss)
Check if a string contains a given substring.