FEM: Usability and UI improvements for data extraction
Update icons for post data extraction Improve translatability of post data extraction Fix post data extraction commit handling
This commit is contained in:
@@ -39,6 +39,8 @@ import FreeCADGui
|
||||
|
||||
from . import post_visualization as pv
|
||||
|
||||
translate = FreeCAD.Qt.translate
|
||||
|
||||
# a model showing available visualizations and possible extractions
|
||||
# #################################################################
|
||||
|
||||
@@ -50,14 +52,14 @@ def build_new_visualization_tree_model():
|
||||
visualizations = pv.get_registered_visualizations()
|
||||
for vis_name in visualizations:
|
||||
vis_icon = FreeCADGui.getIcon(visualizations[vis_name].icon)
|
||||
vis_item = QtGui.QStandardItem(vis_icon, f"New {vis_name}")
|
||||
vis_item = QtGui.QStandardItem(vis_icon, translate("FEM", "New {}").format(vis_name))
|
||||
vis_item.setFlags(QtGui.Qt.ItemIsEnabled)
|
||||
vis_item.setData(visualizations[vis_name])
|
||||
|
||||
for ext in visualizations[vis_name].extractions:
|
||||
icon = FreeCADGui.getIcon(ext.icon)
|
||||
name = ext.name.removeprefix(vis_name)
|
||||
ext_item = QtGui.QStandardItem(icon, f"with {name}")
|
||||
ext_item = QtGui.QStandardItem(icon, translate("FEM", "with {}").format(name))
|
||||
ext_item.setData(ext)
|
||||
vis_item.appendRow(ext_item)
|
||||
model.appendRow(vis_item)
|
||||
@@ -89,7 +91,7 @@ def build_add_to_visualization_tree_model():
|
||||
for ext in visualizations[vis_type].extractions:
|
||||
icon = FreeCADGui.getIcon(ext.icon)
|
||||
name = ext.name.removeprefix(vis_type)
|
||||
ext_item = QtGui.QStandardItem(icon, f"Add {name}")
|
||||
ext_item = QtGui.QStandardItem(icon, translate("FEM", "Add {}").format(name))
|
||||
ext_item.setData(ext)
|
||||
vis_item.appendRow(ext_item)
|
||||
|
||||
@@ -101,7 +103,7 @@ def build_add_to_visualization_tree_model():
|
||||
def build_post_object_item(post_object, extractions, vis_type):
|
||||
|
||||
# definitely build a item and add the extractions
|
||||
post_item = QtGui.QStandardItem(post_object.ViewObject.Icon, f"From {post_object.Label}")
|
||||
post_item = QtGui.QStandardItem(post_object.ViewObject.Icon, translate("FEM", "From {}").format(post_object.Label))
|
||||
post_item.setFlags(QtGui.Qt.ItemIsEnabled)
|
||||
post_item.setData(post_object)
|
||||
|
||||
@@ -109,7 +111,7 @@ def build_post_object_item(post_object, extractions, vis_type):
|
||||
for ext in extractions:
|
||||
icon = FreeCADGui.getIcon(ext.icon)
|
||||
name = ext.name.removeprefix(vis_type)
|
||||
ext_item = QtGui.QStandardItem(icon, f"add {name}")
|
||||
ext_item = QtGui.QStandardItem(icon, translate("FEM", "add {}").format(name))
|
||||
ext_item.setData(ext)
|
||||
post_item.appendRow(ext_item)
|
||||
|
||||
@@ -268,7 +270,7 @@ class _SummaryWidget(QtGui.QWidget):
|
||||
self.viewButton.hide()
|
||||
|
||||
self.warning = QtGui.QLabel(self)
|
||||
self.warning.full_text = f"{extractor.Label}: Data source not available"
|
||||
self.warning.full_text = translate("FEM", "{}: Data source not available").format(extractor.Label)
|
||||
|
||||
self.rmButton = QtGui.QToolButton(self)
|
||||
self.rmButton.setIcon(QtGui.QIcon.fromTheme("delete"))
|
||||
@@ -462,9 +464,9 @@ class ExtractLinkView(QtGui.QWidget):
|
||||
self._scroll_view.setWidgetResizable(True)
|
||||
|
||||
hbox = QtGui.QHBoxLayout()
|
||||
label = QtGui.QLabel("Data used in:")
|
||||
label = QtGui.QLabel(translate("FEM", "Data used in:"))
|
||||
if not self._is_source:
|
||||
label.setText("Data used from:")
|
||||
label.setText(translate("FEM", "Data used from:"))
|
||||
|
||||
label.setAlignment(QtGui.Qt.AlignBottom)
|
||||
hbox.addWidget(label)
|
||||
@@ -473,19 +475,19 @@ class ExtractLinkView(QtGui.QWidget):
|
||||
if self._is_source:
|
||||
|
||||
self._add = _TreeChoiceButton(build_add_to_visualization_tree_model())
|
||||
self._add.setText("Add data to")
|
||||
self._add.setText(translate("FEM", "Add data to"))
|
||||
self._add.selection.connect(self.addExtractionToVisualization)
|
||||
hbox.addWidget(self._add)
|
||||
|
||||
self._create = _TreeChoiceButton(build_new_visualization_tree_model())
|
||||
self._create.setText("New")
|
||||
self._create.setText(translate("FEM", "New"))
|
||||
self._create.selection.connect(self.newVisualization)
|
||||
hbox.addWidget(self._create)
|
||||
|
||||
else:
|
||||
vis_type = vis.get_visualization_type(self._object)
|
||||
self._add = _TreeChoiceButton(build_add_from_data_tree_model(vis_type))
|
||||
self._add.setText("Add data from")
|
||||
self._add.setText(translate("FEM", "Add data from"))
|
||||
self._add.selection.connect(self.addExtractionToPostObject)
|
||||
hbox.addWidget(self._add)
|
||||
|
||||
|
||||
@@ -95,7 +95,8 @@ class _VisualizationGroupCommand:
|
||||
return 0
|
||||
|
||||
def GetResources(self):
|
||||
return { 'MenuText': 'Data Visualizations', 'ToolTip': 'Different visualizations to show post processing data in'}
|
||||
return { 'MenuText': QtCore.QT_TRANSLATE_NOOP("FEM", 'Data Visualizations'),
|
||||
'ToolTip': QtCore.QT_TRANSLATE_NOOP("FEM", 'Different visualizations to show post processing data in')}
|
||||
|
||||
def IsActive(self):
|
||||
if not FreeCAD.ActiveDocument:
|
||||
@@ -117,7 +118,7 @@ class _VisualizationCommand:
|
||||
|
||||
return {
|
||||
"Pixmap": vis.icon,
|
||||
"MenuText": QtCore.QT_TRANSLATE_NOOP(cmd, f"{self._visualization_type}"),
|
||||
"MenuText": QtCore.QT_TRANSLATE_NOOP(cmd, "Create {}".format(self._visualization_type)),
|
||||
"Accel": "",
|
||||
"ToolTip": QtCore.QT_TRANSLATE_NOOP(cmd, tooltip),
|
||||
"CmdType": "AlterDoc"
|
||||
|
||||
@@ -37,6 +37,8 @@ import FreeCADGui
|
||||
|
||||
from vtkmodules.vtkIOCore import vtkDelimitedTextWriter
|
||||
|
||||
translate = FreeCAD.Qt.translate
|
||||
|
||||
class VtkTableModel(QtCore.QAbstractTableModel):
|
||||
# Simple table model. Only supports single component columns
|
||||
# One can supply a header_names dict to replace the table column names
|
||||
@@ -160,14 +162,14 @@ class VtkTableView(QtGui.QWidget):
|
||||
csv_action = QtGui.QAction(self)
|
||||
csv_action.triggered.connect(self.exportCsv)
|
||||
csv_action.setIcon(FreeCADGui.getIcon("Std_Export"))
|
||||
csv_action.setToolTip("Export to CSV")
|
||||
csv_action.setToolTip(translate("FEM", "Export to CSV"))
|
||||
self.toolbar.addAction(csv_action)
|
||||
|
||||
copy_action = QtGui.QAction(self)
|
||||
copy_action.triggered.connect(self.copyToClipboard)
|
||||
copy_action.setIcon(FreeCADGui.getIcon("edit-copy"))
|
||||
shortcut = QtGui.QKeySequence(QtGui.QKeySequence.Copy)
|
||||
copy_action.setToolTip(f"Copy to clipboard ({shortcut.toString()})")
|
||||
copy_action.setToolTip(translate("FEM", "Copy selection to clipboard ({})".format(shortcut.toString())))
|
||||
copy_action.setShortcut(shortcut)
|
||||
self.toolbar.addAction(copy_action)
|
||||
|
||||
@@ -195,9 +197,9 @@ class VtkTableView(QtGui.QWidget):
|
||||
@QtCore.Slot(bool)
|
||||
def exportCsv(self, state):
|
||||
|
||||
file_path, filter = QtGui.QFileDialog.getSaveFileName(None, "Save as csv file", "", "CSV (*.csv)")
|
||||
file_path, filter = QtGui.QFileDialog.getSaveFileName(None, translate("FEM", "Save as csv file"), "", "CSV (*.csv)")
|
||||
if not file_path:
|
||||
FreeCAD.Console.PrintMessage("CSV file export aborted: no filename selected")
|
||||
FreeCAD.Console.PrintMessage(translate("FEM", "CSV file export aborted: no filename selected"))
|
||||
return
|
||||
|
||||
writer = vtkDelimitedTextWriter()
|
||||
|
||||
Reference in New Issue
Block a user