mirror of https://gitlab.com/pamhyr/pamhyr2
geometry: Fix some guidelines display.
parent
a45e43a2ca
commit
1fb42a73fa
|
|
@ -8,7 +8,7 @@ from copy import deepcopy
|
||||||
from operator import itemgetter
|
from operator import itemgetter
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
|
|
||||||
from tools import flatten
|
from tools import flatten, timer
|
||||||
|
|
||||||
from Model.Geometry.Profile import Profile
|
from Model.Geometry.Profile import Profile
|
||||||
from Model.Geometry.ProfileXYZ import ProfileXYZ
|
from Model.Geometry.ProfileXYZ import ProfileXYZ
|
||||||
|
|
@ -167,10 +167,13 @@ class Reach:
|
||||||
|
|
||||||
# Guidelines
|
# Guidelines
|
||||||
|
|
||||||
|
@timer
|
||||||
def _compute_guidelines_cache(self, guide_set, named_points,
|
def _compute_guidelines_cache(self, guide_set, named_points,
|
||||||
complete, incomplete):
|
complete, incomplete):
|
||||||
# Reset guide lines cache
|
# Reset guide lines cache
|
||||||
self._guidelines = {}
|
self._guidelines = {}
|
||||||
|
self._complete_guidelines = complete.copy()
|
||||||
|
self._incomplete_guidelines = incomplete.copy()
|
||||||
self._guidelines_is_valid = len(incomplete) == 0
|
self._guidelines_is_valid = len(incomplete) == 0
|
||||||
|
|
||||||
# Make a list of point for each guideline
|
# Make a list of point for each guideline
|
||||||
|
|
@ -189,6 +192,7 @@ class Reach:
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@timer
|
||||||
def compute_guidelines(self):
|
def compute_guidelines(self):
|
||||||
"""Compute reach guideline and check if is valid for all profiles
|
"""Compute reach guideline and check if is valid for all profiles
|
||||||
|
|
||||||
|
|
@ -229,9 +233,9 @@ class Reach:
|
||||||
|
|
||||||
return (complete, incomplete)
|
return (complete, incomplete)
|
||||||
|
|
||||||
def _map_guidelines_points(self, func, _filter=None):
|
def _map_guidelines_points(self, func, full=False):
|
||||||
if len(self._guidelines) == 0:
|
if len(self._guidelines) == 0:
|
||||||
_ = compute_guidelines()
|
_ = self.compute_guidelines()
|
||||||
|
|
||||||
return list(
|
return list(
|
||||||
# Map for each guideline
|
# Map for each guideline
|
||||||
|
|
@ -243,13 +247,17 @@ class Reach:
|
||||||
self._guidelines[k],
|
self._guidelines[k],
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
self._guidelines if not _filter else filter(
|
# Get only guide lines if FULL False
|
||||||
_filter,
|
self._guidelines if full else filter(
|
||||||
|
lambda x: x in self._complete_guidelines,
|
||||||
self._guidelines
|
self._guidelines
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def _complete_filter(self, gl):
|
||||||
|
return gl in self._complete_guidelines
|
||||||
|
|
||||||
def get_guidelines_x(self):
|
def get_guidelines_x(self):
|
||||||
return self._map_guidelines_points(lambda p: p.x)
|
return self._map_guidelines_points(lambda p: p.x)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@ import sys
|
||||||
import csv
|
import csv
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
from tools import timer
|
||||||
|
|
||||||
from PyQt5 import QtWidgets
|
from PyQt5 import QtWidgets
|
||||||
from PyQt5.QtCore import (
|
from PyQt5.QtCore import (
|
||||||
QModelIndex, Qt, QSettings, pyqtSlot,
|
QModelIndex, Qt, QSettings, pyqtSlot,
|
||||||
|
|
@ -220,9 +222,12 @@ class GeometryWindow(QMainWindow, WindowToolKit):
|
||||||
self.list_second_window = []
|
self.list_second_window = []
|
||||||
self.list_row = []
|
self.list_row = []
|
||||||
|
|
||||||
|
@timer
|
||||||
def graphic_1(self):
|
def graphic_1(self):
|
||||||
self.ui.canvas_1.axes.cla()
|
self.ui.canvas_1.axes.cla()
|
||||||
self.ui.canvas_1.axes.grid(color='grey', linestyle='--', linewidth=0.5)
|
self.ui.canvas_1.axes.grid(color='grey', linestyle='--', linewidth=0.5)
|
||||||
|
|
||||||
|
# Axes
|
||||||
self.ui.canvas_1.axes.set_xlabel(
|
self.ui.canvas_1.axes.set_xlabel(
|
||||||
_translate("MainWindow_reach", "X (m)"), color='green', fontsize=12
|
_translate("MainWindow_reach", "X (m)"), color='green', fontsize=12
|
||||||
)
|
)
|
||||||
|
|
@ -230,13 +235,17 @@ class GeometryWindow(QMainWindow, WindowToolKit):
|
||||||
_translate("MainWindow_reach", "Y (m)"), color='green', fontsize=12
|
_translate("MainWindow_reach", "Y (m)"), color='green', fontsize=12
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Draw line for each profile
|
||||||
self.line_xy = [
|
self.line_xy = [
|
||||||
self.ui.canvas_1.axes.plot(x, y, color='r', lw=1.,
|
self.ui.canvas_1.axes.plot(
|
||||||
markersize=3, marker='+')
|
x, y,
|
||||||
|
color='r', lw=1.,
|
||||||
|
markersize=3, marker='+'
|
||||||
|
)
|
||||||
for x, y in zip(self._reach.get_x(), self._reach.get_y())
|
for x, y in zip(self._reach.get_x(), self._reach.get_y())
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# Guide lines
|
||||||
self.x_complete = self._reach.get_guidelines_x()
|
self.x_complete = self._reach.get_guidelines_x()
|
||||||
self.y_complete = self._reach.get_guidelines_y()
|
self.y_complete = self._reach.get_guidelines_y()
|
||||||
|
|
||||||
|
|
|
||||||
16
src/tools.py
16
src/tools.py
|
|
@ -23,10 +23,10 @@ def display_timers():
|
||||||
global _timers
|
global _timers
|
||||||
global _calls
|
global _calls
|
||||||
|
|
||||||
print(" +--Timers----------------------------------------+")
|
print(" +---------------------------------------------------------Timers--+")
|
||||||
for func in _timers:
|
for func in _timers:
|
||||||
print(f" | {func:<15} | {_timers[func]:>10.6f} sec | {_calls[func]:>5} calls |")
|
print(f" | {func:<32} | {_timers[func]:>10.6f} sec | {_calls[func]:>5} calls |")
|
||||||
print(" +------------------------------------------------+")
|
print(" +-----------------------------------------------------------------+")
|
||||||
|
|
||||||
def timer(func):
|
def timer(func):
|
||||||
"""Function wrapper to register function runtime"""
|
"""Function wrapper to register function runtime"""
|
||||||
|
|
@ -39,12 +39,12 @@ def timer(func):
|
||||||
end_time = time.perf_counter()
|
end_time = time.perf_counter()
|
||||||
run_time = end_time - start_time
|
run_time = end_time - start_time
|
||||||
|
|
||||||
if func.__name__ not in _timers:
|
if func.__qualname__ not in _timers:
|
||||||
_timers[func.__name__] = 0
|
_timers[func.__qualname__] = 0
|
||||||
_calls[func.__name__] = 0
|
_calls[func.__qualname__] = 0
|
||||||
|
|
||||||
_timers[func.__name__] += run_time
|
_timers[func.__qualname__] += run_time
|
||||||
_calls[func.__name__] += 1
|
_calls[func.__qualname__] += 1
|
||||||
|
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue