Import Geant4 10.7.1 source tree
This commit is contained in:
@@ -16,6 +16,31 @@ committal in the CVS repository !
|
||||
* Reverse chronological order (last date on top), please *
|
||||
----------------------------------------------------------
|
||||
|
||||
26 January 2020 John Allison (interfaces-V10-06-12)
|
||||
- G4UIQt.cc: Get colour and background from OS.
|
||||
o Instead of fixed background <span style='background:#EEEEEE...
|
||||
use <span style='background:" + pal.highlight().color().name()...
|
||||
o This picks up colour from the OS and even allows for change of
|
||||
OS display style, e.g., dark mode on MacOS.
|
||||
|
||||
20 January 2020 John Allison
|
||||
- G4UIQt.cc: Fix bug in command-line-echo highlighting whereby there
|
||||
could be a crash in some circumstances.
|
||||
o Use <span> instead of <div> in HTML wrappers.
|
||||
|
||||
16 January 2020 John Allison
|
||||
- Requires intercoms-V10-07-00.
|
||||
- Introduce choice of output styles:
|
||||
o /gui/outputStyle
|
||||
<cout|cerr|warnings|errors|all>
|
||||
<fixed|proportional>
|
||||
<highlight|no-highlight>
|
||||
o Highlighting applies to the echoed command line if echoing is
|
||||
requested with /control/verbose > 0.
|
||||
|
||||
29 December 2020 John Allison
|
||||
- G4UIQt.cc: Use 12pt Courier for G4UIQt output window.
|
||||
|
||||
29 November 2020 Gabriele Cosmo (interfaces-V10-06-11)
|
||||
- G4UIQt.cc: protected MT code within G4MULTITHREADED in workaround
|
||||
introduced previously.
|
||||
|
||||
@@ -147,6 +147,11 @@ public: // With description
|
||||
// Third argument is the Geant4 command executed when the button is fired.
|
||||
// Fourth argument is the path to the icon file if "user_icon" selected
|
||||
// Ex : AddButton("change background color","../background.xpm"," /vis/viewer/set/background");
|
||||
void OutputStyle (const char*,const char*,const char*);
|
||||
// Specify an output style
|
||||
// First argument destination (cout cerr warnings errors all)
|
||||
// Second argument is the style (fixed proportional)
|
||||
// Third argument highlights commands if "highlight" (and if /control/verbose > 0)
|
||||
|
||||
void DefaultIcons(bool aVal);
|
||||
// Enable/Disable the default icon ToolBar in Qt
|
||||
@@ -376,6 +381,10 @@ private:
|
||||
bool fPickSelected;
|
||||
bool fZoomInSelected;
|
||||
bool fZoomOutSelected;
|
||||
struct G4UIQtStyle {
|
||||
G4bool fixed, highlight;
|
||||
};
|
||||
std::map<G4String,G4UIQtStyle> fOutputStyles;
|
||||
|
||||
private Q_SLOTS :
|
||||
void ExitSession();
|
||||
|
||||
@@ -212,6 +212,14 @@ G4UIQt::G4UIQt (
|
||||
}
|
||||
CreateIcons();
|
||||
|
||||
// Set default output styles
|
||||
for (const auto& destination: {"cout","cerr","warnings","errors"}) {
|
||||
G4UIQtStyle defaultStyle;
|
||||
defaultStyle.fixed = true;
|
||||
defaultStyle.highlight = true;
|
||||
fOutputStyles[destination] = defaultStyle;
|
||||
}
|
||||
|
||||
fMainWindow = new QMainWindow();
|
||||
fMainWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
@@ -2025,10 +2033,34 @@ G4int G4UIQt::ReceiveG4cout (
|
||||
#endif
|
||||
std::cout << aString;
|
||||
|
||||
QStringList newStr;
|
||||
G4String aStringWithStyle;
|
||||
// aString has a \n on the end (maybe it comes from G4endl or from the
|
||||
// Enter key on the command line) - ignore it. That’s why
|
||||
// i < aString.length() - 1
|
||||
// But other \n need to be translated to an HTML newline.
|
||||
// Similarly, spaces need to be translated to an HTML "non-breaking space".
|
||||
// Tabs (\t) are more tricky since the number of equivalent spaces depends
|
||||
// on how many characters precede it. Probably needs an HTML table. For now
|
||||
// we replace \t with four spaces.
|
||||
for (size_t i = 0; i < aString.length() - 1; ++i) {
|
||||
if (aString[i] == '\n') {
|
||||
aStringWithStyle += "<br>";
|
||||
} else if (aString[i] == ' ') {
|
||||
aStringWithStyle += " ";
|
||||
} else if (aString[i] == '\t') {
|
||||
aStringWithStyle += " ";
|
||||
} else {
|
||||
aStringWithStyle += aString[i];
|
||||
}
|
||||
}
|
||||
if (fOutputStyles["cout"].fixed) {
|
||||
aStringWithStyle = "<span style='font-family:courier;'>" + aStringWithStyle + "</span>";
|
||||
} else {
|
||||
aStringWithStyle = "<span>" + aStringWithStyle + "</span>";
|
||||
}
|
||||
|
||||
// Add to string
|
||||
G4UIOutputString txt = G4UIOutputString(QString((char*)aString.data()).trimmed(),GetThreadPrefix());
|
||||
G4UIOutputString txt = G4UIOutputString(QString((char*)aStringWithStyle.data()),GetThreadPrefix());
|
||||
fG4OutputString.push_back(txt);
|
||||
|
||||
#ifdef G4MULTITHREADED
|
||||
@@ -2040,6 +2072,17 @@ G4int G4UIQt::ReceiveG4cout (
|
||||
if (result.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
G4UImanager* UI = G4UImanager::GetUIpointer();
|
||||
if (fOutputStyles["cout"].highlight) {
|
||||
if (!UI->IsLastCommandOutputTreated() ) {
|
||||
QPalette pal;
|
||||
result = QString("<span style='background:") + pal.link().color().name() + ";'> </span>"
|
||||
+ "<span style='background:" + pal.highlight().color().name() +";'> " + result + "</span>";
|
||||
}
|
||||
}
|
||||
UI->SetLastCommandOutputTreated();
|
||||
|
||||
fCoutTBTextArea->append(result);
|
||||
fCoutTBTextArea->ensureCursorVisible ();
|
||||
|
||||
@@ -2075,11 +2118,35 @@ G4int G4UIQt::ReceiveG4cerr (
|
||||
#endif
|
||||
std::cerr << aString;
|
||||
|
||||
QStringList newStr;
|
||||
G4String aStringWithStyle;
|
||||
// aString has a \n on the end (maybe it comes from G4endl or from the
|
||||
// Enter key on the command line) - ignore it. That’s why
|
||||
// i < aString.length() - 1
|
||||
// But other \n need to be translated to an HTML newline.
|
||||
// Similarly, spaces need to be translated to an HTML "non-breaking space".
|
||||
// Tabs (\t) are more tricky since the number of equivalent spaces depends
|
||||
// on how many characters precede it. Probably needs an HTML table. For now
|
||||
// we replace \t with four spaces.
|
||||
for (size_t i = 0; i < aString.length() - 1; ++i) {
|
||||
if (aString[i] == '\n') {
|
||||
aStringWithStyle += "<br>";
|
||||
} else if (aString[i] == ' ') {
|
||||
aStringWithStyle += " ";
|
||||
} else if (aString[i] == '\t') {
|
||||
aStringWithStyle += " ";
|
||||
} else {
|
||||
aStringWithStyle += aString[i];
|
||||
}
|
||||
}
|
||||
if (fOutputStyles["cerr"].fixed) {
|
||||
aStringWithStyle = "<span style='font-family:courier;'>" + aStringWithStyle + "</span>";
|
||||
} else {
|
||||
aStringWithStyle = "<span>" + aStringWithStyle + "</span>";
|
||||
}
|
||||
|
||||
// Add to string
|
||||
|
||||
G4UIOutputString txt = G4UIOutputString(QString((char*)aString.data()).trimmed(),
|
||||
G4UIOutputString txt = G4UIOutputString(QString((char*)aStringWithStyle.data()).trimmed(),
|
||||
GetThreadPrefix(),
|
||||
"error");
|
||||
fG4OutputString.push_back(txt);
|
||||
@@ -2502,6 +2569,25 @@ void G4UIQt::AddIcon(const char* aLabel, const char* aIconFile, const char* aCom
|
||||
}
|
||||
|
||||
|
||||
void G4UIQt::OutputStyle (const char* destination,const char* style,const char* highlight)
|
||||
{
|
||||
// Specify an output style
|
||||
// First argument destination (cout cerr warnings errors all)
|
||||
// Second argument is the style (fixed proportional)
|
||||
// Third argument highlights commands if "highlight" (and if /control/verbose > 0)
|
||||
G4String uiQtDestination(destination);
|
||||
G4UIQtStyle uiQtStyle;
|
||||
if (G4String(style) == "fixed") uiQtStyle.fixed = true; else uiQtStyle.fixed = false;
|
||||
if (G4String(highlight) == "highlight") uiQtStyle.highlight = true; else uiQtStyle.highlight = false;
|
||||
if (uiQtDestination == "all") {
|
||||
for (auto& i: fOutputStyles) {
|
||||
i.second = uiQtStyle;
|
||||
}
|
||||
} else {
|
||||
fOutputStyles[uiQtDestination] = uiQtStyle;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void G4UIQt::ActivateCommand(
|
||||
G4String newCommand
|
||||
|
||||
@@ -48,6 +48,7 @@ private:
|
||||
G4UIcommand* addIcon;
|
||||
G4UIcommand* defaultIcons;
|
||||
G4UIcommand* sys;
|
||||
G4UIcommand* outputStyle;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -51,6 +51,7 @@ class G4VInteractiveSession
|
||||
virtual void AddButton (const char*,const char*,const char*);
|
||||
virtual void AddIcon (const char*,const char*,const char*,const char*);
|
||||
virtual void DefaultIcons (bool);
|
||||
virtual void OutputStyle (const char*,const char*,const char*);
|
||||
void AddInteractor(G4String,G4Interactor);
|
||||
G4Interactor GetInteractor(G4String);
|
||||
|
||||
|
||||
@@ -130,12 +130,31 @@ G4InteractorMessenger::G4InteractorMessenger (
|
||||
parameter->SetDefaultValue("");
|
||||
sys->SetParameter (parameter);
|
||||
|
||||
// /gui/outputStyle :
|
||||
outputStyle = new G4UIcommand("/gui/outputStyle",this);
|
||||
outputStyle->SetGuidance("Set output style.");
|
||||
outputStyle->SetGuidance("Highlights commands if requested and if /control/verbose > 0.");
|
||||
parameter = new G4UIparameter("destination",'s',true); // Omitable
|
||||
parameter->SetParameterCandidates("cout cerr warnings errors all");
|
||||
parameter->SetDefaultValue("all");
|
||||
outputStyle->SetParameter (parameter);
|
||||
parameter = new G4UIparameter("type",'s',true); // Omitable
|
||||
parameter->SetParameterCandidates("fixed proportional");
|
||||
parameter->SetDefaultValue("fixed");
|
||||
outputStyle->SetParameter (parameter);
|
||||
parameter = new G4UIparameter("highlight",'s',true); // Omitable
|
||||
parameter->SetParameterCandidates("highlight no-highlight");
|
||||
parameter->SetDefaultValue("highlight");
|
||||
outputStyle->SetParameter (parameter);
|
||||
}
|
||||
|
||||
G4InteractorMessenger::~G4InteractorMessenger()
|
||||
{
|
||||
delete addButton;
|
||||
delete outputStyle;
|
||||
delete sys;
|
||||
delete defaultIcons;
|
||||
delete addIcon;
|
||||
delete addButton;
|
||||
delete addMenu;
|
||||
delete interactorDirectory;
|
||||
}
|
||||
@@ -159,6 +178,8 @@ void G4InteractorMessenger::SetNewValue (
|
||||
} else if(command==sys) {
|
||||
int rc = system((const char*)params[0]);
|
||||
if ( rc < 0 ){ }
|
||||
} else if(command==outputStyle) {
|
||||
session->OutputStyle((const char*)params[0],(const char*)params[1],(const char*)params[2]);
|
||||
}
|
||||
}
|
||||
delete [] params;
|
||||
|
||||
@@ -61,6 +61,11 @@ void G4VInteractiveSession::AddIcon (const char*,const char*,const char*,const c
|
||||
{
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
void G4VInteractiveSession::OutputStyle(const char*,const char*,const char*)
|
||||
{
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
void G4VInteractiveSession::AddInteractor (G4String a_name,
|
||||
G4Interactor a_interactor)
|
||||
|
||||
Reference in New Issue
Block a user