Import Geant4 11.3.0 source tree

This commit is contained in:
Gabriele Cosmo
2024-12-06 11:11:40 +01:00
parent e58e650b32
commit 32390e802b
1984 changed files with 98713 additions and 83996 deletions
+34
View File
@@ -6,6 +6,40 @@ It must **not** be used as a substitute for writing good git commit messages!
-------------------------------------------------------------------------------
## 2024-10-25 John Allison (interfaces-V11-02-10)
- G4UIQt.cc:
- G4UIQt::FilterOutput(): Fix compilation error, see Bug Report 2633.
- Use .data().
## 2024-10-22 John Allison (interfaces-V11-02-09)
- G4UIQt.cc:
- G4UIQt::NewSceneTreeItemTreeWidget::ActWithAnInteger:
- Allow larger integers in widget response.
## 2024-10-17 John Allison (interfaces-V11-02-08)
- G4UIQt.cc:
- Fix case of opacity==0 for touchables.
- Normally the sceneTreeItem will be updated when the scene is processed after the above
commands, but if the user sets the opacity to zero, G4PhysicalVolumeModel does not
transmit it (this is because some users set the opacity to zero to make a volume
invisible - perhaps they should use the visibility flag, but hey-ho).
By design, the sceneTreeItem remains, so it can still be interacted with, but
the colour will not be updated, so we do it here.
if (newColour.GetAlpha() == 0.) {
sceneTreeItem->AccessVisAttributes().SetColour(newColour);
}
## 2024-07-15 Gabriele Cosmo (interfaces-V11-02-07)
- Fixed reported Coverity defects, use consistently 'const G4String&' to
avoid implicit copy.
## 2024-07-10 Guy Barrand (interfaces-V11-02-06)
- G4UIWin32.cc: in ConvertNewLines(), replace:
str.replace(index, 2, "\r\n");
by:
str.replace(index, 1, "\r\n");
It fixes a "swallow of first character" bug in the G4cout output WS_EX_CLIENTEDGE widget.
## 2024-05-30 Guy Barrand (interfaces-V11-02-05)
- G4UIQt.cc: Qt6: modifications to avoid the G4QTabWidget::paintEvent logic
and have the "ApplyCommand(/vis/viewer/select)" logic done on the
@@ -61,7 +61,7 @@ class G4VInteractiveSession
virtual void ClearMenu();
virtual void UpdateSceneTree(const G4SceneTreeItem&);
void AddInteractor(G4String, G4Interactor);
G4Interactor GetInteractor(G4String);
G4Interactor GetInteractor(const G4String&);
const std::map<G4String, OutputStyle>& GetOutputStyles() const;
protected:
@@ -254,7 +254,7 @@ G4bool GetValues(G4String newValue, G4int paramn, G4String* params)
return false;
}
params[i] = token;
params[i] = std::move(token);
tok = strtok(nullptr, " ");
}
+1 -1
View File
@@ -550,7 +550,7 @@ void G4UItcsh::CompleteCommand()
input += (vpath + stream);
if (nMatch == 0) input += strtail;
commandLine = input;
commandLine = std::move(input);
cursorPosition = G4int(commandLine.length() + 1);
}
+1 -1
View File
@@ -216,7 +216,7 @@ G4String G4UIterminal::GetCommand(const char* msg)
//////////////////////////////////////////////////
{
G4String newCommand = shell->GetCommandLineString(msg);
G4String nullString = "";
const G4String& nullString = "";
G4String nC = G4StrUtil::lstrip_copy(newCommand);
+12 -12
View File
@@ -43,9 +43,9 @@ G4VBasicShell::~G4VBasicShell() = default;
G4String G4VBasicShell::ModifyToFullPathCommand(const char* aCommandLine) const
{
G4String rawCommandLine = aCommandLine;
const G4String& rawCommandLine = aCommandLine;
if (rawCommandLine.empty() || rawCommandLine[0] == '\0') return rawCommandLine;
G4String commandLine = G4StrUtil::strip_copy(rawCommandLine);
const G4String& commandLine = G4StrUtil::strip_copy(rawCommandLine);
G4String commandString;
G4String parameterString;
size_t i = commandLine.find(' ');
@@ -66,7 +66,7 @@ G4String G4VBasicShell::GetCurrentWorkingDirectory() const { return currentDirec
G4bool G4VBasicShell::ChangeDirectory(const char* newDir)
{
G4String newPrefix = G4StrUtil::strip_copy(newDir);
const G4String& newPrefix = G4StrUtil::strip_copy(newDir);
G4String newDirectory = ModifyPath(newPrefix);
if (newDirectory.back() != '/') {
@@ -75,7 +75,7 @@ G4bool G4VBasicShell::ChangeDirectory(const char* newDir)
if (FindDirectory(newDirectory.c_str()) == nullptr) {
return false;
}
currentDirectory = newDirectory;
currentDirectory = std::move(newDirectory);
return true;
}
@@ -105,10 +105,10 @@ G4UIcommandTree* G4VBasicShell::FindDirectory(const char* dirName) const
G4UIcommand* G4VBasicShell::FindCommand(const char* commandName) const
{
G4String commandLine = G4StrUtil::strip_copy(commandName);
const G4String& commandLine = G4StrUtil::strip_copy(commandName);
G4String commandString;
size_t i = commandLine.find(' ');
std::size_t i = commandLine.find(' ');
if (i != std::string::npos) {
commandString = commandLine.substr(0, i);
}
@@ -116,7 +116,7 @@ G4UIcommand* G4VBasicShell::FindCommand(const char* commandName) const
commandString = commandLine;
}
G4String targetCom = ModifyPath(commandString);
const G4String& targetCom = ModifyPath(commandString);
return G4UImanager::GetUIpointer()->GetTree()->FindPath(targetCom);
}
@@ -181,10 +181,10 @@ G4String G4VBasicShell::ModifyPath(const G4String& tempPath) const
////////////////////////////////////////////
G4String G4VBasicShell::Complete(const G4String& commandName)
{
G4String rawCommandLine = commandName;
G4String commandLine = G4StrUtil::strip_copy(rawCommandLine);
const G4String& rawCommandLine = commandName;
const G4String& commandLine = G4StrUtil::strip_copy(rawCommandLine);
size_t i = commandLine.find(' ');
std::size_t i = commandLine.find(' ');
if (i != std::string::npos)
return rawCommandLine; // Already entering parameters,
// assume command path is correct.
@@ -322,7 +322,7 @@ void G4VBasicShell::ChangeDirectoryCommand(const G4String& newCommand)
prefix = "/";
}
else {
G4String aNewPrefix = newCommand.substr(3, newCommand.length() - 3);
const G4String& aNewPrefix = newCommand.substr(3, newCommand.length() - 3);
prefix = G4StrUtil::strip_copy(aNewPrefix);
}
if (! ChangeDirectory(prefix)) {
@@ -337,7 +337,7 @@ void G4VBasicShell::ListDirectory(const G4String& newCommand) const
targetDir = GetCurrentWorkingDirectory();
}
else {
G4String newPrefix = newCommand.substr(3, newCommand.length() - 3);
const G4String& newPrefix = newCommand.substr(3, newCommand.length() - 3);
targetDir = G4StrUtil::strip_copy(newPrefix);
}
G4UIcommandTree* commandTree = FindDirectory(targetDir);
@@ -70,7 +70,7 @@ void G4VInteractiveSession::AddInteractor(G4String a_name, G4Interactor a_intera
}
/***************************************************************************/
G4Interactor G4VInteractiveSession::GetInteractor(G4String a_name)
G4Interactor G4VInteractiveSession::GetInteractor(const G4String& a_name)
{
G4interactor_map::iterator it;
if ((it = interactors.find(a_name)) == interactors.end()) return nullptr;
+2 -2
View File
@@ -247,9 +247,9 @@ void G4VUIshell::ListCommand(const G4String& dir, const G4String& candidate) con
}
// check "vcmd" is directory?
G4String inputpath = vpath + vcmd;
const G4String& inputpath = vpath + vcmd;
if (! vcmd.empty()) {
G4String tmpstr = inputpath + "/";
const G4String& tmpstr = inputpath + "/";
if (GetCommandTree(tmpstr) != nullptr) {
vpath = tmpstr;
vcmd = "";
@@ -105,7 +105,7 @@ class G4QTabWidget : public QTabWidget
class G4UIOutputString
{
public:
G4UIOutputString(QString text, G4String thread = "", G4String outputstream = "info");
G4UIOutputString(const QString& text, const G4String& thread = "", const G4String& outputstream = "info");
inline QString GetOutputList() { return " all info warning error "; };
QString fText;
G4String fThread;
@@ -115,7 +115,7 @@ class G4UIOutputString
class G4UIDockWidget : public QDockWidget
{
public:
G4UIDockWidget(QString txt);
G4UIDockWidget(const QString& txt);
void closeEvent(QCloseEvent*) override;
};
@@ -244,7 +244,7 @@ class G4UIQt : public QObject, public G4VBasicShell, public G4VInteractiveSessio
public:
~G4UIQt() override;
void Prompt(G4String);
void Prompt(const G4String&);
void SessionTerminate();
void PauseSessionStart(const G4String&) override;
G4int ReceiveG4debug(const G4String&) override;
@@ -253,7 +253,7 @@ public:
// G4String GetCommand(Widget);
private:
void SecondaryLoop(G4String); // a VIRER
void SecondaryLoop(const G4String&); // a VIRER
void CreateHelpWidget();
void InitHelpTreeAndVisParametersWidget();
void FillHelpTree();
@@ -307,7 +307,7 @@ public:
G4UIDockWidget* CreateUITabWidget();
void CreateViewerWidget();
void OpenHelpTreeOnCommand(const QString&);
QString GetShortCommandPath(QString);
QString GetShortCommandPath(QString&);
QString GetLongCommandPath(QTreeWidgetItem*);
G4bool IsGUICommand(const G4UIcommand*);
G4bool CreateVisCommandGroupAndToolBox(G4UIcommand*, QWidget*, G4int, G4bool isDialog);
@@ -321,7 +321,7 @@ public:
QString FilterOutput(const G4UIOutputString&, const QString&, const QString&);
G4String GetThreadPrefix();
G4bool CheckG4EnvironmentVariable(char* txt, char* version);
QStandardItemModel* CreateCompleterModel(G4String aCmd);
QStandardItemModel* CreateCompleterModel(const G4String& aCmd);
void CreateEmptyViewerPropertiesWidget();
void CreateEmptyPickInfosWidget();
@@ -138,7 +138,7 @@ class G4UIWin32 : public G4VBasicShell, public G4VInteractiveSession
static G4String GetToolTips(G4int);
G4String GetHelpTreeToolTips(HTREEITEM);
static G4String ConvertNewLines(G4String);
static G4String ConvertNewLines(const G4String&);
void HelpTreeDoubleClick(HTREEITEM);
@@ -151,7 +151,7 @@ class G4UIWin32 : public G4VBasicShell, public G4VInteractiveSession
G4bool InitHelpTreeItems();
HTREEITEM AddItemToHelpTree(LPTSTR, HTREEITEM = TVI_ROOT);
static G4String GetShortCommandPath(G4String);
static G4String GetShortCommandPath(const G4String&);
LPSTR GetItemPath(HTREEITEM);
void CreateHelpTree(HTREEITEM, G4UIcommandTree*);
@@ -80,7 +80,7 @@ class G4UIXm : public G4VBasicShell, public G4VInteractiveSession
// Ex : AddButton("my_menu","Run","/run/beamOn 1");
void AddButton(const char*, const char*, const char*);
void Prompt(G4String);
void Prompt(const G4String&);
void SessionTerminate();
virtual void PauseSessionStart(const G4String&);
virtual G4int ReceiveG4debug(const G4String&);
@@ -89,7 +89,7 @@ class G4UIXm : public G4VBasicShell, public G4VInteractiveSession
G4String GetCommand(Widget);
private:
void SecondaryLoop(G4String);
void SecondaryLoop(const G4String&);
G4bool GetHelpChoice(G4int&);
void ExitHelp() const;
static void CommandEnteredCallback(Widget, XtPointer, XtPointer);
@@ -97,9 +97,9 @@ G4UIExecutive::G4UIExecutive(G4int argc, char** argv, const G4String& type)
// 3rd priority : refer $HOME/.g4session
if (selected == kNone) {
G4String appinput = argv[0];
const G4String& appinput = argv[0];
G4String appname = "";
size_t islash = appinput.find_last_of("/\\");
std::size_t islash = appinput.find_last_of("/\\");
if (islash == G4String::npos)
appname = appinput;
else
@@ -224,7 +224,7 @@ void G4UIExecutive::SelectSessionByFile(const G4String& appname)
while (fsession.good()) {
if (fsession.eof()) break;
fsession.getline(linebuf, BUFSIZE);
G4String aline = G4StrUtil::strip_copy(linebuf);
const G4String& aline = G4StrUtil::strip_copy(linebuf);
if (aline[0] == '#') continue;
if (aline.empty()) continue;
if (iline == 1)
@@ -235,7 +235,7 @@ void G4UIExecutive::SelectSessionByFile(const G4String& appname)
G4String aname = aline.substr(0, idx);
idx = aline.find_first_not_of(' ', idx);
if (idx == G4String::npos) break;
G4String sname = aline.substr(idx, aline.size() - idx);
const G4String& sname = aline.substr(idx, aline.size() - idx);
sessionMap[aname] = sname;
}
iline++;
@@ -247,7 +247,7 @@ void G4UIExecutive::SelectSessionByFile(const G4String& appname)
if (it != sessionMap.end())
stype = sessionMap[appname];
else
stype = default_session;
stype = std::move(default_session);
G4StrUtil::to_lower(stype);
// select session...
+20 -9
View File
@@ -1687,7 +1687,8 @@ void G4UIQt::SceneTreeItemDoubleClicked(QTreeWidgetItem* item)
if (sceneTreeItem->GetType() != G4SceneTreeItem::touchable) return;
auto oldQColor = ConvertG4ColourToQColor(sceneTreeItem->GetVisAttributes().GetColour());
auto newQColor = QColorDialog::getColor(oldQColor, fNewSceneTreeItemTreeWidget, "", QColorDialog::ShowAlphaChannel);
auto newQColor = QColorDialog::getColor
(oldQColor, fNewSceneTreeItemTreeWidget, "", QColorDialog::ShowAlphaChannel);
if (!newQColor.isValid()) return;
if (newQColor == oldQColor) return;
@@ -1698,6 +1699,16 @@ void G4UIQt::SceneTreeItemDoubleClicked(QTreeWidgetItem* item)
auto uiMan = G4UImanager::GetUIpointer();
uiMan->ApplyCommand("/vis/set/touchable" + sceneTreeItem->GetPVPath());
uiMan->ApplyCommand("/vis/touchable/set/colour " + oss.str());
// Normally the sceneTreeItem will be updated when the scene is processed after the above
// commands, but if the user sets the opacity to zero, G4PhysicalVolumeModel does not
// transmit it (this is because some users set the opacity to zero to make a volume
// invisible - perhaps they should use the visibility flag, but hey-ho).
// By design, the sceneTreeItem remains, so it can still be interacted with, but
// the colour will not be updated, so we do it here.
if (newColour.GetAlpha() == 0.) {
sceneTreeItem->AccessVisAttributes().SetColour(newColour);
}
}
void G4UIQt::SceneTreeItemExpanded(QTreeWidgetItem* item)
@@ -1901,7 +1912,7 @@ void G4UIQt::NewSceneTreeItemTreeWidget::ActWithAnInteger
{
G4bool ok = true;
auto newValue = QInputDialog::getInt(this, action.c_str(), action.c_str(),
0, 0, 999, 1, &ok);
0, 0, 9999999, 1, &ok);
if (ok) {
auto uiMan = G4UImanager::GetUIpointer();
uiMan->ApplyCommand("/vis/set/touchable" + sceneTreeItem->GetPVPath());
@@ -2420,7 +2431,7 @@ G4UIsession* G4UIQt::SessionStart()
/** Display the prompt in the prompt area
@param aPrompt : string to display as the promt label
*/
void G4UIQt::Prompt(G4String aPrompt)
void G4UIQt::Prompt(const G4String& aPrompt)
{
if (aPrompt == nullptr) return;
@@ -2460,7 +2471,7 @@ void G4UIQt::PauseSessionStart(const G4String& aState)
Begin the secondary loop
@param a_prompt : label to display as the prompt label
*/
void G4UIQt::SecondaryLoop(G4String aPrompt)
void G4UIQt::SecondaryLoop(const G4String& aPrompt)
{
if (aPrompt == nullptr) return;
@@ -4078,7 +4089,7 @@ void G4UIQt::UpdateCommandCompleter()
fCompleter->popup()->installEventFilter(this);
}
QStandardItemModel* G4UIQt::CreateCompleterModel(G4String aCmd)
QStandardItemModel* G4UIQt::CreateCompleterModel(const G4String& aCmd)
{
QList<QStandardItem*> dirModelList;
QList<QStandardItem*> commandModelList;
@@ -4529,7 +4540,7 @@ QString G4UIQt::FilterOutput(
const G4UIOutputString& output, const QString& currentThread, const QString& filter)
{
#ifdef G4MULTITHREADED
if ((currentThread == "All") || (currentThread == output.fThread)) {
if ((currentThread == "All") || (currentThread == output.fThread.data())) {
#else
if (currentThread == "") {
#endif
@@ -4795,7 +4806,7 @@ QMultiMap<G4int, QString> G4UIQt::LookForHelpStringInChildTree(
}
#endif
QString G4UIQt::GetShortCommandPath(QString commandPath)
QString G4UIQt::GetShortCommandPath(QString& commandPath)
{
if (commandPath.indexOf("/") == 0) {
commandPath = commandPath.right(commandPath.size() - 1);
@@ -5449,7 +5460,7 @@ G4QTabWidget::G4QTabWidget()
{}
#endif
G4UIOutputString::G4UIOutputString(QString text, G4String origine, G4String outputStream)
G4UIOutputString::G4UIOutputString(const QString& text, const G4String& origine, const G4String& outputStream)
: fText(text), fThread(origine)
{
if (! GetOutputList().contains(QString(" ") + outputStream + " ")) {
@@ -5549,7 +5560,7 @@ void G4QTabWidget::paintEvent(QPaintEvent*)
}
#endif
G4UIDockWidget::G4UIDockWidget(QString txt) : QDockWidget(txt) {}
G4UIDockWidget::G4UIDockWidget(const QString& txt) : QDockWidget(txt) {}
void G4UIDockWidget::closeEvent(QCloseEvent* aEvent)
{
@@ -1034,14 +1034,14 @@ G4String G4UIWin32::GetHelpTreeToolTips(HTREEITEM item)
/****************************************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
G4String G4UIWin32::ConvertNewLines(G4String a_string)
G4String G4UIWin32::ConvertNewLines(const G4String& a_string)
{
// Geant4 uses UNIX's style for new lines (\n)
// we must convert them to Windows' style (\r\n)
G4String str = std::move(a_string);
size_t index = str.find("\n", 0);
G4String str = a_string;
std::size_t index = str.find("\n", 0);
while (index < str.length()) {
str.replace(index, 2, "\r\n");
str.replace(index, 1, "\r\n");
// Advance index forward so the next iteration doesn't pick it up as well.
index = str.find("\n", index + 2);
}
@@ -1306,9 +1306,9 @@ HTREEITEM G4UIWin32::AddItemToHelpTree(LPTSTR lpszItem, HTREEITEM aParent)
/****************************************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
G4String G4UIWin32::GetShortCommandPath(G4String commandPath)
G4String G4UIWin32::GetShortCommandPath(const G4String& commandPath)
{
G4String str = std::move(commandPath);
G4String str = commandPath;
if (str.find_last_of("/") == (str.size() - 1)) str = str.erase(str.size() - 1, 1);
@@ -172,7 +172,7 @@ G4UIsession* G4UIXm::SessionStart()
return this;
}
/***************************************************************************/
void G4UIXm::Prompt(G4String aPrompt)
void G4UIXm::Prompt(const G4String& aPrompt)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
@@ -204,7 +204,7 @@ void G4UIXm::PauseSessionStart(const G4String& a_state)
}
}
/***************************************************************************/
void G4UIXm::SecondaryLoop(G4String a_prompt)
void G4UIXm::SecondaryLoop(const G4String& a_prompt)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{