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

mesh
Pierre-Antoine Rouby 2023-04-26 14:46:48 +02:00
parent 36bd08a422
commit d610dfef7e
5 changed files with 36 additions and 4 deletions

View File

@ -109,10 +109,11 @@ class ProfileXYZ(Profile):
index: The index of new profile. index: The index of new profile.
Returns: Returns:
Nothing. The new point.
""" """
point = PointXYZ(0., 0., 0.) point = PointXYZ(0., 0., 0.)
self._points.insert(index, point) self._points.insert(index, point)
return point
def filter_isnan(self, lst): def filter_isnan(self, lst):
"""Returns the input list without 'nan' element """Returns the input list without 'nan' element

View File

@ -1,6 +1,9 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import os import os
import csv
from io import StringIO
from PyQt5.QtCore import Qt from PyQt5.QtCore import Qt
@ -21,6 +24,29 @@ class WindowToolKit(object):
def __init__(self, parent=None): def __init__(self, parent=None):
super(WindowToolKit, self).__init__() 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): def file_dialog(self, select_file=True, callback=lambda x: None):
"""Open a new file dialog and send result to callback function """Open a new file dialog and send result to callback function

View File

@ -3,7 +3,6 @@
import os import os
import pathlib import pathlib
import sys import sys
import csv
import time import time
from copy import deepcopy from copy import deepcopy

View File

@ -53,12 +53,16 @@ class AddCommand(QUndoCommand):
self._profile = profile self._profile = profile
self._index = index self._index = index
self._point = None
def undo(self): def undo(self):
self._profile.delete(self._index) self._profile.delete([self._index])
def redo(self): 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): class DelCommand(QUndoCommand):
def __init__(self, profile, rows): def __init__(self, profile, rows):

View File

@ -143,6 +143,7 @@ class ProfileWindow(QMainWindow):
else: else:
row = self.index_selected_row() row = self.index_selected_row()
self._model.insert_row(row + 1) self._model.insert_row(row + 1)
self.update_plot()
def delete_row(self): def delete_row(self):
rows = sorted( rows = sorted(
@ -155,6 +156,7 @@ class ProfileWindow(QMainWindow):
if len(rows) > 0: if len(rows) > 0:
self._model.remove_rows(rows) self._model.remove_rows(rows)
self.update_plot()
def sort_X_ascending(self): def sort_X_ascending(self):
self._model.sort('x', order=Qt.AscendingOrder) self._model.sort('x', order=Qt.AscendingOrder)