mirror of https://gitlab.com/pamhyr/pamhyr2
ASubWindow, geometry: Prepare copy/paste from other source and minor change.
parent
36bd08a422
commit
d610dfef7e
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue