[FEM] CCX Solver and Gmsh Mesh Task Panel Colour output improvements (#13684)
* [FEM] CCX Solver and Gmsh Mesh Task Panel Colour output improvements * [FEM] CCX Solver TP make time code more prominent * [FEM] Gmsh mesh TP make time code more prominent
This commit is contained in:
@@ -31,11 +31,12 @@ __url__ = "https://www.freecad.org"
|
||||
# it is a Gui only module and should only be imported in Gui mode
|
||||
# thus no guard is needed
|
||||
from PySide import QtGui
|
||||
from femtools.femutils import getOutputWinColor
|
||||
|
||||
|
||||
ERROR_COLOR = "red"
|
||||
WARNING_COLOR = "#ffaa00"
|
||||
INFO_COLOR = "blue"
|
||||
ERROR_COLOR = "Error"
|
||||
WARNING_COLOR = "Warning"
|
||||
INFO_COLOR = "Logging"
|
||||
|
||||
|
||||
class ReportDialog(QtGui.QDialog):
|
||||
@@ -71,7 +72,9 @@ class ReportDialog(QtGui.QDialog):
|
||||
text += "%s<br>" % self._getColoredLine(line, ERROR_COLOR)
|
||||
return text
|
||||
|
||||
def _getColoredLine(self, text, color):
|
||||
return '<font color="%s">%s</font>' % (color, text)
|
||||
def _getColoredLine(self, text, outputwin_color_type):
|
||||
return '<font color="{}">{}</font>'.format(
|
||||
getOutputWinColor(outputwin_color_type), text
|
||||
)
|
||||
|
||||
## @}
|
||||
|
||||
@@ -43,6 +43,7 @@ import FreeCADGui
|
||||
import FemGui
|
||||
from femobjects import mesh_gmsh
|
||||
from femtools.femutils import is_of_type
|
||||
from femtools.femutils import getOutputWinColor
|
||||
|
||||
|
||||
class _TaskPanel:
|
||||
@@ -152,11 +153,25 @@ class _TaskPanel:
|
||||
index_order = self.form.cb_order.findText(self.order)
|
||||
self.form.cb_order.setCurrentIndex(index_order)
|
||||
|
||||
def console_log(self, message="", color="#000000"):
|
||||
def console_log(self, message="", outputwin_color_type=None):
|
||||
self.console_message_gmsh = self.console_message_gmsh + (
|
||||
'<font color="#0000FF">{0:4.1f}:</font> <font color="{1}">{2}</font><br>'
|
||||
.format(time.time() - self.Start, color, message)
|
||||
'<font color="{}"><b>{:4.1f}:</b></font> '.format(
|
||||
getOutputWinColor("Logging"), time.time() - self.Start
|
||||
)
|
||||
)
|
||||
if outputwin_color_type:
|
||||
if (
|
||||
outputwin_color_type == "#00AA00"
|
||||
): # Success is not part of output window parameters
|
||||
self.console_message_gmsh += '<font color="{}">{}</font><br>'.format(
|
||||
outputwin_color_type, message
|
||||
)
|
||||
else:
|
||||
self.console_message_gmsh += '<font color="{}">{}</font><br>'.format(
|
||||
getOutputWinColor(outputwin_color_type), message
|
||||
)
|
||||
else:
|
||||
self.console_message_gmsh += message + "<br>"
|
||||
self.form.te_output.setText(self.console_message_gmsh)
|
||||
self.form.te_output.moveCursor(QtGui.QTextCursor.End)
|
||||
|
||||
@@ -231,11 +246,11 @@ class _TaskPanel:
|
||||
if error:
|
||||
FreeCAD.Console.PrintWarning("Gmsh had warnings:\n")
|
||||
FreeCAD.Console.PrintWarning("{}\n".format(error))
|
||||
self.console_log("Gmsh had warnings ...")
|
||||
self.console_log(error, "#FF0000")
|
||||
self.console_log("Gmsh had warnings ...", "Warning")
|
||||
self.console_log(error, "Error")
|
||||
else:
|
||||
FreeCAD.Console.PrintMessage("Clean run of Gmsh\n")
|
||||
self.console_log("Clean run of Gmsh")
|
||||
self.console_log("Clean run of Gmsh", "#00AA00")
|
||||
self.console_log("Gmsh done!")
|
||||
self.form.l_time.setText("Time: {0:4.1f}: ".format(time.time() - self.Start))
|
||||
self.Timer.stop()
|
||||
|
||||
@@ -40,6 +40,7 @@ import FreeCAD
|
||||
import FreeCADGui
|
||||
|
||||
import FemGui
|
||||
from femtools.femutils import getOutputWinColor
|
||||
|
||||
|
||||
def unicode(text, *args):
|
||||
@@ -186,11 +187,25 @@ class _TaskPanel:
|
||||
self.form.rb_buckling_analysis.setChecked(True)
|
||||
return
|
||||
|
||||
def femConsoleMessage(self, message="", color="#000000"):
|
||||
def femConsoleMessage(self, message="", outputwin_color_type=None):
|
||||
self.fem_console_message = self.fem_console_message + (
|
||||
'<font color="#0000FF">{0:4.1f}:</font> <font color="{1}">{2}</font><br>'
|
||||
.format(time.time() - self.Start, color, message)
|
||||
'<font color="{}"><b>{:4.1f}:</b></font> '.format(
|
||||
getOutputWinColor("Logging"), time.time() - self.Start
|
||||
)
|
||||
)
|
||||
if outputwin_color_type:
|
||||
if (
|
||||
outputwin_color_type == "#00AA00"
|
||||
): # Success is not part of output window parameters
|
||||
self.fem_console_message += '<font color="{}">{}</font><br>'.format(
|
||||
outputwin_color_type, message
|
||||
)
|
||||
else:
|
||||
self.fem_console_message += '<font color="{}">{}</font><br>'.format(
|
||||
getOutputWinColor(outputwin_color_type), message
|
||||
)
|
||||
else:
|
||||
self.fem_console_message += message + "<br>"
|
||||
self.form.textEdit_Output.setText(self.fem_console_message)
|
||||
self.form.textEdit_Output.moveCursor(QtGui.QTextCursor.End)
|
||||
|
||||
@@ -201,7 +216,7 @@ class _TaskPanel:
|
||||
# <class 'PySide2.QtCore.QByteArray'>
|
||||
|
||||
if out.isEmpty():
|
||||
self.femConsoleMessage("CalculiX stdout is empty", "#FF0000")
|
||||
self.femConsoleMessage("CalculiX stdout is empty", "Error")
|
||||
return False
|
||||
|
||||
# https://forum.freecad.org/viewtopic.php?f=18&t=39195
|
||||
@@ -231,11 +246,13 @@ class _TaskPanel:
|
||||
|
||||
def calculixError(self, error=""):
|
||||
print("Error() {}".format(error))
|
||||
self.femConsoleMessage("CalculiX execute error: {}".format(error), "#FF0000")
|
||||
self.femConsoleMessage("CalculiX execute error: {}".format(error), "Error")
|
||||
|
||||
def calculixNoError(self):
|
||||
print("CalculiX done without error!")
|
||||
self.femConsoleMessage("CalculiX done without error!", "#00AA00")
|
||||
self.femConsoleMessage(
|
||||
"CalculiX done without error!", "#00AA00"
|
||||
) # Green leaving hard coded
|
||||
|
||||
def calculixStarted(self):
|
||||
# print("calculixStarted()")
|
||||
@@ -250,7 +267,7 @@ class _TaskPanel:
|
||||
elif newState == QtCore.QProcess.ProcessState.NotRunning:
|
||||
self.femConsoleMessage("CalculiX stopped.")
|
||||
else:
|
||||
self.femConsoleMessage("Problems.")
|
||||
self.femConsoleMessage("Problems.", "Error")
|
||||
|
||||
def calculixFinished(self, exitCode, exitStatus):
|
||||
# print("calculixFinished(), exit code: {}".format(exitCode))
|
||||
@@ -326,7 +343,7 @@ class _TaskPanel:
|
||||
self.form.pb_edit_inp.setEnabled(True)
|
||||
self.form.pb_run_ccx.setEnabled(True)
|
||||
else:
|
||||
self.femConsoleMessage("Write .inp file failed!", "#FF0000")
|
||||
self.femConsoleMessage("Write .inp file failed!", "Error")
|
||||
QApplication.restoreOverrideCursor()
|
||||
self.form.l_time.setText("Time: {0:4.1f}: ".format(time.time() - self.Start))
|
||||
|
||||
|
||||
@@ -407,3 +407,13 @@ def expandParentObject():
|
||||
continue
|
||||
for item in items:
|
||||
tree.expandItem(item)
|
||||
|
||||
|
||||
def getOutputWinColor(type):
|
||||
"""
|
||||
type: 'Error', 'Warning', 'Logging', 'Text'
|
||||
"""
|
||||
col_int = FreeCAD.ParamGet(
|
||||
"User parameter:BaseApp/Preferences/OutputWindow"
|
||||
).GetUnsigned("color" + type)
|
||||
return "#{:08X}".format(col_int)[:-2]
|
||||
|
||||
Reference in New Issue
Block a user