Commit d610dfef authored by Pierre-Antoine Rouby's avatar Pierre-Antoine Rouby
Browse files

ASubWindow, geometry: Prepare copy/paste from other source and minor change.

Showing with 36 additions and 4 deletions
+36 -4
......@@ -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
......
# -*- 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
......
......@@ -3,7 +3,6 @@
import os
import pathlib
import sys
import csv
import time
from copy import deepcopy
......
......@@ -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):
......
......@@ -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)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment