diff --git a/src/Model/Geometry/ProfileXYZ.py b/src/Model/Geometry/ProfileXYZ.py index 043f43b5d7e98d0bb44670a615343bc719c9c0fd..bd9dec94060ab9307027bb177fd1cd59653c5176 100644 --- a/src/Model/Geometry/ProfileXYZ.py +++ b/src/Model/Geometry/ProfileXYZ.py @@ -109,10 +109,11 @@ class ProfileXYZ(Profile): index: The index of new profile. Returns: - Nothing. + The new point. """ point = PointXYZ(0., 0., 0.) self._points.insert(index, point) + return point def filter_isnan(self, lst): """Returns the input list without 'nan' element diff --git a/src/View/ASubWindow.py b/src/View/ASubWindow.py index 03b0f9f3db0f33dcbe72729d3a15484076ed7f73..a47a839a6b561674f4c07e8fc5250b3d0beffa10 100644 --- a/src/View/ASubWindow.py +++ b/src/View/ASubWindow.py @@ -1,6 +1,9 @@ # -*- coding: utf-8 -*- import os +import csv + +from io import StringIO from PyQt5.QtCore import Qt @@ -21,6 +24,29 @@ class WindowToolKit(object): def __init__(self, parent=None): super(WindowToolKit, self).__init__() + def parseClipboardTable(self): + clip = QApplication.clipboard() + mime = clip.mimeData() + # print(mime.formats()) + data = mime.data('text/plain').data().decode() + + has_header = csv.Sniffer().has_header(data) + print(f"header? {has_header}") + + header = [] + values = [] + + stream = StringIO(data) + rows = csv.reader(stream, delimiter='\t') + for l, row in enumerate(rows): + if has_header and l == 0: + header = row.copy() + continue + + values.append(row) + + return header, values + def file_dialog(self, select_file=True, callback=lambda x: None): """Open a new file dialog and send result to callback function diff --git a/src/View/Geometry/GeometryWindow.py b/src/View/Geometry/GeometryWindow.py index 8a6929b1cda11c49f61d5393b6dddc892aeee82f..3818b2b3fbb09711b32386c5eab50362ae4d68fa 100644 --- a/src/View/Geometry/GeometryWindow.py +++ b/src/View/Geometry/GeometryWindow.py @@ -3,7 +3,6 @@ import os import pathlib import sys -import csv import time from copy import deepcopy diff --git a/src/View/Geometry/Profile/ProfileUndoCommand.py b/src/View/Geometry/Profile/ProfileUndoCommand.py index 0797c6a530d37464ffff6aafaf627fe573d1d4f9..7036d6613311a844e280a3ef0a61d795b3451e5d 100644 --- a/src/View/Geometry/Profile/ProfileUndoCommand.py +++ b/src/View/Geometry/Profile/ProfileUndoCommand.py @@ -53,12 +53,16 @@ class AddCommand(QUndoCommand): self._profile = profile self._index = index + self._point = None def undo(self): - self._profile.delete(self._index) + self._profile.delete([self._index]) def redo(self): - self._profile.insert(self._index) + if self._point is None: + self._point = self._profile.insert(self._index) + else: + self._profile.insert_point(self._index, self._point) class DelCommand(QUndoCommand): def __init__(self, profile, rows): diff --git a/src/View/Geometry/Profile/ProfileWindow.py b/src/View/Geometry/Profile/ProfileWindow.py index e84751e0a61eaacff55ad6c9d5773a8a71d4d73d..d17d98d0212b216457114c27f1f6838912ed7b7c 100644 --- a/src/View/Geometry/Profile/ProfileWindow.py +++ b/src/View/Geometry/Profile/ProfileWindow.py @@ -143,6 +143,7 @@ class ProfileWindow(QMainWindow): else: row = self.index_selected_row() self._model.insert_row(row + 1) + self.update_plot() def delete_row(self): rows = sorted( @@ -155,6 +156,7 @@ class ProfileWindow(QMainWindow): if len(rows) > 0: self._model.remove_rows(rows) + self.update_plot() def sort_X_ascending(self): self._model.sort('x', order=Qt.AscendingOrder)