graph gui almost done

This commit is contained in:
Djalim Simaila 2023-04-25 12:48:05 +02:00
parent ac4f4410a2
commit dc412bb8e8
7 changed files with 364 additions and 244 deletions

1
app.py
View File

@ -1,5 +1,4 @@
import sys import sys
from PyQt5 import uic
from PyQt5.QtWidgets import QApplication from PyQt5.QtWidgets import QApplication
from utils.gui.pyqt.main_window.MainWindow import MainWindow from utils.gui.pyqt.main_window.MainWindow import MainWindow

View File

@ -0,0 +1,13 @@
import vispy.plot as vp
import numpy as np
from utils.files.input import ScannedObject
class CrossSection2DCanvas:
def __init__(self,x_values:list, y_values:list,title:str):
color = (0.3, 0.5, 0.8)
self.canvas = vp.Fig(show=False,size=(500, 500))
line = self.canvas[0,0].plot(np.column_stack((x_values,y_values)), symbol='o', width=0,
face_color=color + (0.02,), edge_color=None,
marker_size=8,title=title)
line.set_gl_state(depth_test=False)

View File

@ -0,0 +1,30 @@
from vispy import scene
from vispy.scene.visuals import Mesh
from vispy.visuals.filters import ShadingFilter, WireframeFilter
from vispy.scene import SceneCanvas
from utils.files.input import ScannedObject
import numpy as np
class Mesh3DCanvas:
def __init__(self,obj:ScannedObject):
vertices = np.asarray(obj.get_vertices())
faces = np.asarray(obj.get_faces())
self.canvas = scene.SceneCanvas(keys='interactive', bgcolor='white',size=(400, 400))
view = self.canvas.central_widget.add_view()
view.camera = 'arcball'
view.camera.depth_value = 1e3
mesh = Mesh(vertices, faces, color=(.5, .7, .5, 1))
view.add(mesh)
wireframe_filter = WireframeFilter(width=0)
shading_filter = ShadingFilter(shininess=0)
mesh.attach(wireframe_filter)
mesh.attach(shading_filter)
def attach_headlight(view):
light_dir = (0, 1, 0, 0)
shading_filter.light_dir = light_dir[:3]
initial_light_dir = view.camera.transform.imap(light_dir)
@view.scene.transform.changed.connect
def on_transform_change(event):
transform = view.camera.transform
shading_filter.light_dir = transform.map(initial_light_dir)[:3]
attach_headlight(view)

View File

@ -1,116 +1,12 @@
import time
import os import os
from PyQt5 import QtWidgets from PyQt5 import QtWidgets
from PyQt5.QtCore import QThread, pyqtSignal, QObject from PyQt5.QtCore import QThread, pyqtSignal, QObject
from PyQt5.QtWidgets import QFileDialog from PyQt5.QtWidgets import QFileDialog
from main import get_discrete_data, get_raw_data
from utils.files.output import save_output_file, format_data
from utils.files.input import ScannedObject from utils.files.input import ScannedObject
from utils.math.position_manipulation import verticalise
from utils.gui.pyqt.main_window.UI_MainWindow import Ui_MainWindow from utils.gui.pyqt.main_window.UI_MainWindow import Ui_MainWindow
from utils.gui.pyqt.main_window.Workers.AnalyseWorker import AnalyseWorker
def analyse(file_path:str,output_path:str, output_file_prefix:str, delta_z:float,set_status,update_ui,set_weight): from utils.gui.pyqt.main_window.Canvas.Mesh3DCanvas import Mesh3DCanvas
""" from utils.gui.pyqt.main_window.Canvas.CrossSection2DCanvas import CrossSection2DCanvas
Run the analyse
Args:
file_path (str): Path to the file to analyse
output_path (str): Path to the output folder
delta_z (float): Delta z to use
set_status (function): Function to set the status
update_ui (function): Function to update the ui
set_weight (function): Function to set the weight
"""
set_status("Loading file...")
obj = ScannedObject.from_obj_file(file_path)
update_ui(5)
set_status("Verticalising object...")
verticalise(obj)
update_ui(5)
set_status("Normalising object...")
obj.normalise()
update_ui(5)
set_weight(70)
set_status("Calculating raw data...")
raw_data = get_raw_data(obj, 6,delta_z,update_ui)
set_status("Calculating discrete data...")
discrete_data = get_discrete_data(obj, 6,delta_z,update_ui)
set_weight(100)
set_status("Saving data...")
save_output_file(f'{output_path}/{output_file_prefix}_delta_{delta_z}_analyse_brute.txt',
format_data(raw_data,
'\t',
["X (en mm)",
"Y (en mm)",
"Z (en mm)",
"teta (en rad)",
"rayon (en mm)",
"Xi-Xmoy",
"Yi-Ymoy"] ))
update_ui(10)
save_output_file(f'{output_path}/{output_file_prefix}_delta_{delta_z}_analyse_rayon.txt',
format_data(discrete_data,
'\t',
["X moy (en mm)",
"Y moy (en mm)",
"Z moy (en mm)",
"Delta z(en mm)",
"Rayon moyen (en mm)",
"Rayon ecart type (en mm)"] ))
update_ui(100)
set_status("Done !")
class Worker(QObject):
"""
Worker to run the analyse in a thread
"""
finished = pyqtSignal()
progress = pyqtSignal(int)
status = pyqtSignal(str)
def __init__(self, objpath,output_path,output_file_prefix,delta_z):
super().__init__()
self.objpath = objpath
self.delta_z = delta_z
self.output_path = output_path
self.output_file_prefix = output_file_prefix
self.progress_value = 0
self.progress_weight = 100
def run(self):
"""
Run the analyse
"""
analyse(self.objpath,
self.output_path,
self.output_file_prefix,
self.delta_z,
self.set_status,
self.update_progress,
self.set_weight)
self.finished.emit()
def set_status(self, status:str):
"""
Set the weight of the progress bar
"""
self.status.emit(status)
def set_weight(self, weight):
"""
Set the weight of the progress bar
"""
self.progress_weight = weight
def update_progress(self, percent):
"""
Update the progress bar
"""
self.progress_value += int(percent/100*self.progress_weight)
self.progress.emit(self.progress_value)
class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
""" """
Main window of the application Main window of the application
@ -124,7 +20,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
self.start_analyse_button.clicked.connect(self.start_analyse) self.start_analyse_button.clicked.connect(self.start_analyse)
self.input_file_choose_btn.clicked.connect(self.select_file) self.input_file_choose_btn.clicked.connect(self.select_file)
self.output_folder_choose_btn.clicked.connect(self.select_folder) self.output_folder_choose_btn.clicked.connect(self.select_folder)
#CanvasWrapper(ScannedObject.from_obj_file("/Users/djalim/Documents/DevStuff/AnalyseMorphologique/datasets/Barette/1 - BARETTE.obj")).canvas.native
self.completed = 0 self.completed = 0
def select_file(self): def select_file(self):
@ -155,7 +51,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
# Create the thread to run the analyse # Create the thread to run the analyse
self.thread = QThread() self.thread = QThread()
self.worker = Worker(self.input_file_path.toPlainText(), self.worker = AnalyseWorker(self.input_file_path.toPlainText(),
self.output_folder_path.toPlainText(), self.output_folder_path.toPlainText(),
self.output_file_prefix.text(), self.output_file_prefix.text(),
self.discretisation_value_selector.value()) self.discretisation_value_selector.value())
@ -165,8 +61,9 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
# Start # Start
self.thread.started.connect(self.worker.run) self.thread.started.connect(self.worker.run)
# Progress # Progress
self.worker.progress.connect(self.update_progress_bar)
self.worker.status.connect(self.set_status) self.worker.status.connect(self.set_status)
self.worker.progress.connect(self.update_progress_bar)
self.worker.render.connect(self.show_graph)
# Finished # Finished
self.worker.finished.connect(self.finish_analyse) self.worker.finished.connect(self.finish_analyse)
self.worker.finished.connect(self.thread.quit) self.worker.finished.connect(self.thread.quit)
@ -183,12 +80,20 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
""" """
self.status_text.setText(status) self.status_text.setText(status)
def show_graph(self, obj:ScannedObject):
"""
Show the graph
"""
self.slot0.addWidget(Mesh3DCanvas(obj).canvas.native)
self.slot1.addWidget(CrossSection2DCanvas(obj.get_x(),obj.get_z(),"Coupe X").canvas.native)
self.slot2.addWidget(CrossSection2DCanvas(obj.get_y(),obj.get_z(),"Coupe Y").canvas.native)
def finish_analyse(self): def finish_analyse(self):
""" """
Finish the analyse Finish the analyse
""" """
self.start_analyse_button.setEnabled(True) self.start_analyse_button.setEnabled(True)
def check_input_file(self): def check_input_file(self):
""" """
Check if the input file is valid Check if the input file is valid

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>529</width> <width>1067</width>
<height>567</height> <height>517</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -15,114 +15,166 @@
</property> </property>
<widget class="QWidget" name="centralwidget"> <widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0"> <item row="1" column="0">
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QHBoxLayout" name="horizontalLayout_4">
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout"> <widget class="QWidget" name="MainSettings" native="true">
<item> <property name="enabled">
<widget class="QLabel" name="input_file_label">
<property name="text">
<string>Chemin du fichier .obj</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="input_file_choose_btn">
<property name="text">
<string>Choisir le fichier</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QPlainTextEdit" name="input_file_path"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="output_folder_label">
<property name="text">
<string>Repertoire de sortie</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="output_folder_choose_btn">
<property name="text">
<string>Choisir le repertoire</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QPlainTextEdit" name="output_folder_path"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="output_file_prefix_label">
<property name="text">
<string>Préfix du fichier de sortie</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="output_file_prefix"/>
</item>
</layout>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="discretisation_label">
<property name="text">
<string>Discretisation (en mm)</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="discretisation_value_selector">
<property name="minimum">
<double>0.000000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QProgressBar" name="analyse_progress_bar">
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QCheckBox" name="show_graph_checkbox">
<property name="text">
<string>afficher les graphes</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="start_analyse_button">
<property name="text">
<string>Analyser le fichier</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="status_text">
<property name="readOnly">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="minimumSize">
<size>
<width>331</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>518</width>
<height>16777215</height>
</size>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<layout class="QVBoxLayout" name="MainSettingsLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="input_file_label">
<property name="text">
<string>Chemin du fichier .obj</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="input_file_choose_btn">
<property name="text">
<string>Choisir le fichier</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QPlainTextEdit" name="input_file_path"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="output_folder_label">
<property name="text">
<string>Repertoire de sortie</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="output_folder_choose_btn">
<property name="text">
<string>Choisir le repertoire</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QPlainTextEdit" name="output_folder_path"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="output_file_prefix_label">
<property name="text">
<string>Préfix du fichier de sortie</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="output_file_prefix"/>
</item>
</layout>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="discretisation_label">
<property name="text">
<string>Discretisation (en mm)</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="discretisation_value_selector">
<property name="minimum">
<double>0.000000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QProgressBar" name="analyse_progress_bar">
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QCheckBox" name="show_graph_checkbox">
<property name="text">
<string>afficher les graphes</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="start_analyse_button">
<property name="text">
<string>Analyser le fichier</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="status_text">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="Graphs" native="true">
<property name="minimumSize">
<size>
<width>700</width>
<height>0</height>
</size>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<layout class="QGridLayout" name="GraphsLayout">
<item row="0" column="0">
<layout class="QGridLayout" name="slot0"/>
</item>
<item row="2" column="0">
<layout class="QGridLayout" name="slot2"/>
</item>
<item row="0" column="1">
<layout class="QGridLayout" name="slot1"/>
</item>
<item row="2" column="1">
<layout class="QGridLayout" name="solt3"/>
</item>
</layout>
</item>
</layout>
</widget> </widget>
</item> </item>
</layout> </layout>
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QStatusBar" name="statusbar"/>
</widget> </widget>
<resources/> <resources/>
<connections/> <connections/>

View File

@ -14,73 +14,102 @@ from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object): class Ui_MainWindow(object):
def setupUi(self, MainWindow): def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow") MainWindow.setObjectName("MainWindow")
MainWindow.resize(529, 567) MainWindow.resize(1067, 517)
self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget") self.centralwidget.setObjectName("centralwidget")
self.gridLayout = QtWidgets.QGridLayout(self.centralwidget) self.gridLayout = QtWidgets.QGridLayout(self.centralwidget)
self.gridLayout.setObjectName("gridLayout") self.gridLayout.setObjectName("gridLayout")
self.verticalLayout = QtWidgets.QVBoxLayout() self.horizontalLayout_4 = QtWidgets.QHBoxLayout()
self.verticalLayout.setObjectName("verticalLayout") self.horizontalLayout_4.setObjectName("horizontalLayout_4")
self.MainSettings = QtWidgets.QWidget(self.centralwidget)
self.MainSettings.setEnabled(True)
self.MainSettings.setMinimumSize(QtCore.QSize(331, 0))
self.MainSettings.setMaximumSize(QtCore.QSize(518, 16777215))
self.MainSettings.setObjectName("MainSettings")
self.gridLayout_2 = QtWidgets.QGridLayout(self.MainSettings)
self.gridLayout_2.setObjectName("gridLayout_2")
self.MainSettingsLayout = QtWidgets.QVBoxLayout()
self.MainSettingsLayout.setObjectName("MainSettingsLayout")
self.horizontalLayout = QtWidgets.QHBoxLayout() self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout") self.horizontalLayout.setObjectName("horizontalLayout")
self.input_file_label = QtWidgets.QLabel(self.centralwidget) self.input_file_label = QtWidgets.QLabel(self.MainSettings)
self.input_file_label.setObjectName("input_file_label") self.input_file_label.setObjectName("input_file_label")
self.horizontalLayout.addWidget(self.input_file_label) self.horizontalLayout.addWidget(self.input_file_label)
self.input_file_choose_btn = QtWidgets.QPushButton(self.centralwidget) self.input_file_choose_btn = QtWidgets.QPushButton(self.MainSettings)
self.input_file_choose_btn.setObjectName("input_file_choose_btn") self.input_file_choose_btn.setObjectName("input_file_choose_btn")
self.horizontalLayout.addWidget(self.input_file_choose_btn) self.horizontalLayout.addWidget(self.input_file_choose_btn)
self.verticalLayout.addLayout(self.horizontalLayout) self.MainSettingsLayout.addLayout(self.horizontalLayout)
self.input_file_path = QtWidgets.QPlainTextEdit(self.centralwidget) self.input_file_path = QtWidgets.QPlainTextEdit(self.MainSettings)
self.input_file_path.setObjectName("input_file_path") self.input_file_path.setObjectName("input_file_path")
self.verticalLayout.addWidget(self.input_file_path) self.MainSettingsLayout.addWidget(self.input_file_path)
self.horizontalLayout_2 = QtWidgets.QHBoxLayout() self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.horizontalLayout_2.setObjectName("horizontalLayout_2")
self.output_folder_label = QtWidgets.QLabel(self.centralwidget) self.output_folder_label = QtWidgets.QLabel(self.MainSettings)
self.output_folder_label.setObjectName("output_folder_label") self.output_folder_label.setObjectName("output_folder_label")
self.horizontalLayout_2.addWidget(self.output_folder_label) self.horizontalLayout_2.addWidget(self.output_folder_label)
self.output_folder_choose_btn = QtWidgets.QPushButton(self.centralwidget) self.output_folder_choose_btn = QtWidgets.QPushButton(self.MainSettings)
self.output_folder_choose_btn.setObjectName("output_folder_choose_btn") self.output_folder_choose_btn.setObjectName("output_folder_choose_btn")
self.horizontalLayout_2.addWidget(self.output_folder_choose_btn) self.horizontalLayout_2.addWidget(self.output_folder_choose_btn)
self.verticalLayout.addLayout(self.horizontalLayout_2) self.MainSettingsLayout.addLayout(self.horizontalLayout_2)
self.output_folder_path = QtWidgets.QPlainTextEdit(self.centralwidget) self.output_folder_path = QtWidgets.QPlainTextEdit(self.MainSettings)
self.output_folder_path.setObjectName("output_folder_path") self.output_folder_path.setObjectName("output_folder_path")
self.verticalLayout.addWidget(self.output_folder_path) self.MainSettingsLayout.addWidget(self.output_folder_path)
self.horizontalLayout_3 = QtWidgets.QHBoxLayout() self.horizontalLayout_3 = QtWidgets.QHBoxLayout()
self.horizontalLayout_3.setObjectName("horizontalLayout_3") self.horizontalLayout_3.setObjectName("horizontalLayout_3")
self.output_file_prefix_label = QtWidgets.QLabel(self.centralwidget) self.output_file_prefix_label = QtWidgets.QLabel(self.MainSettings)
self.output_file_prefix_label.setObjectName("output_file_prefix_label") self.output_file_prefix_label.setObjectName("output_file_prefix_label")
self.horizontalLayout_3.addWidget(self.output_file_prefix_label) self.horizontalLayout_3.addWidget(self.output_file_prefix_label)
self.output_file_prefix = QtWidgets.QLineEdit(self.centralwidget) self.output_file_prefix = QtWidgets.QLineEdit(self.MainSettings)
self.output_file_prefix.setObjectName("output_file_prefix") self.output_file_prefix.setObjectName("output_file_prefix")
self.horizontalLayout_3.addWidget(self.output_file_prefix) self.horizontalLayout_3.addWidget(self.output_file_prefix)
self.verticalLayout.addLayout(self.horizontalLayout_3) self.MainSettingsLayout.addLayout(self.horizontalLayout_3)
self.discretisation_label = QtWidgets.QLabel(self.centralwidget) self.discretisation_label = QtWidgets.QLabel(self.MainSettings)
self.discretisation_label.setObjectName("discretisation_label") self.discretisation_label.setObjectName("discretisation_label")
self.verticalLayout.addWidget(self.discretisation_label, 0, QtCore.Qt.AlignHCenter) self.MainSettingsLayout.addWidget(self.discretisation_label, 0, QtCore.Qt.AlignHCenter)
self.discretisation_value_selector = QtWidgets.QDoubleSpinBox(self.centralwidget) self.discretisation_value_selector = QtWidgets.QDoubleSpinBox(self.MainSettings)
self.discretisation_value_selector.setMinimum(0.0) self.discretisation_value_selector.setMinimum(0.0)
self.discretisation_value_selector.setProperty("value", 1.0) self.discretisation_value_selector.setProperty("value", 1.0)
self.discretisation_value_selector.setObjectName("discretisation_value_selector") self.discretisation_value_selector.setObjectName("discretisation_value_selector")
self.verticalLayout.addWidget(self.discretisation_value_selector) self.MainSettingsLayout.addWidget(self.discretisation_value_selector)
self.analyse_progress_bar = QtWidgets.QProgressBar(self.centralwidget) self.analyse_progress_bar = QtWidgets.QProgressBar(self.MainSettings)
self.analyse_progress_bar.setProperty("value", 0) self.analyse_progress_bar.setProperty("value", 0)
self.analyse_progress_bar.setObjectName("analyse_progress_bar") self.analyse_progress_bar.setObjectName("analyse_progress_bar")
self.verticalLayout.addWidget(self.analyse_progress_bar) self.MainSettingsLayout.addWidget(self.analyse_progress_bar)
self.show_graph_checkbox = QtWidgets.QCheckBox(self.centralwidget) self.show_graph_checkbox = QtWidgets.QCheckBox(self.MainSettings)
self.show_graph_checkbox.setObjectName("show_graph_checkbox") self.show_graph_checkbox.setObjectName("show_graph_checkbox")
self.verticalLayout.addWidget(self.show_graph_checkbox, 0, QtCore.Qt.AlignHCenter) self.MainSettingsLayout.addWidget(self.show_graph_checkbox, 0, QtCore.Qt.AlignHCenter)
self.start_analyse_button = QtWidgets.QPushButton(self.centralwidget) self.start_analyse_button = QtWidgets.QPushButton(self.MainSettings)
self.start_analyse_button.setObjectName("start_analyse_button") self.start_analyse_button.setObjectName("start_analyse_button")
self.verticalLayout.addWidget(self.start_analyse_button) self.MainSettingsLayout.addWidget(self.start_analyse_button)
self.status_text = QtWidgets.QLineEdit(self.centralwidget) self.status_text = QtWidgets.QLineEdit(self.MainSettings)
self.status_text.setReadOnly(True) self.status_text.setReadOnly(True)
self.status_text.setObjectName("status_text") self.status_text.setObjectName("status_text")
self.verticalLayout.addWidget(self.status_text) self.MainSettingsLayout.addWidget(self.status_text)
self.gridLayout.addLayout(self.verticalLayout, 0, 0, 1, 1) self.gridLayout_2.addLayout(self.MainSettingsLayout, 0, 0, 1, 1)
self.horizontalLayout_4.addWidget(self.MainSettings)
self.Graphs = QtWidgets.QWidget(self.centralwidget)
self.Graphs.setMinimumSize(QtCore.QSize(700, 0))
self.Graphs.setObjectName("Graphs")
self.gridLayout_3 = QtWidgets.QGridLayout(self.Graphs)
self.gridLayout_3.setObjectName("gridLayout_3")
self.GraphsLayout = QtWidgets.QGridLayout()
self.GraphsLayout.setObjectName("GraphsLayout")
self.slot0 = QtWidgets.QGridLayout()
self.slot0.setObjectName("slot0")
self.GraphsLayout.addLayout(self.slot0, 0, 0, 1, 1)
self.slot2 = QtWidgets.QGridLayout()
self.slot2.setObjectName("slot2")
self.GraphsLayout.addLayout(self.slot2, 2, 0, 1, 1)
self.slot1 = QtWidgets.QGridLayout()
self.slot1.setObjectName("slot1")
self.GraphsLayout.addLayout(self.slot1, 0, 1, 1, 1)
self.solt3 = QtWidgets.QGridLayout()
self.solt3.setObjectName("solt3")
self.GraphsLayout.addLayout(self.solt3, 2, 1, 1, 1)
self.gridLayout_3.addLayout(self.GraphsLayout, 0, 0, 1, 1)
self.horizontalLayout_4.addWidget(self.Graphs)
self.gridLayout.addLayout(self.horizontalLayout_4, 1, 0, 1, 1)
MainWindow.setCentralWidget(self.centralwidget) MainWindow.setCentralWidget(self.centralwidget)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow) self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow)

View File

@ -0,0 +1,92 @@
from PyQt5.QtCore import pyqtSignal, QObject
from utils.files.input import ScannedObject
from utils.files.output import save_output_file, format_data
from utils.math.position_manipulation import verticalise
from utils.data_processing.data_processing import get_discrete_data, get_raw_data
class AnalyseWorker(QObject):
"""
Worker to run the analyse in a thread
"""
finished = pyqtSignal()
render = pyqtSignal(ScannedObject)
progress = pyqtSignal(int)
status = pyqtSignal(str)
def __init__(self, objpath,output_path,output_file_prefix,delta_z):
super().__init__()
self.objpath = objpath
self.delta_z = delta_z
self.output_path = output_path
self.output_file_prefix = output_file_prefix
self.progress_value = 0
self.progress_weight = 100
def run(self):
"""
Run the analyse
"""
self.set_status("Loading file...")
obj = ScannedObject.from_obj_file(self.objpath)
self.update_progress(5)
self.set_status("Verticalising object...")
verticalise(obj)
self.update_progress(5)
self.set_status("Normalising object...")
obj.normalise()
self.update_progress(5)
self.render.emit(obj)
self.set_weight(70)
self.set_status("Calculating raw data...")
raw_data = get_raw_data(obj, 6,self.delta_z,self.update_progress)
self.set_status("Calculating discrete data...")
discrete_data = get_discrete_data(obj, 6,self.delta_z,self.update_progress)
self.set_weight(100)
self.set_status("Saving data...")
save_output_file(f'{self.output_path}/{self.output_file_prefix}_delta_{self.delta_z}_analyse_brute.txt',
format_data(raw_data,
'\t',
["X (en mm)",
"Y (en mm)",
"Z (en mm)",
"teta (en rad)",
"rayon (en mm)",
"Xi-Xmoy",
"Yi-Ymoy"] ))
self.update_progress(10)
save_output_file(f'{self.output_path}/{self.output_file_prefix}_delta_{self.delta_z}_analyse_rayon.txt',
format_data(discrete_data,
'\t',
["X moy (en mm)",
"Y moy (en mm)",
"Z moy (en mm)",
"Delta z(en mm)",
"Rayon moyen (en mm)",
"Rayon ecart type (en mm)"] ))
self.update_progress(100)
self.set_status("Done !")
self.finished.emit()
def set_status(self, status:str):
"""
Set the weight of the progress bar
"""
self.status.emit(status)
def set_weight(self, weight):
"""
Set the weight of the progress bar
"""
self.progress_weight = weight
def update_progress(self, percent):
"""
Update the progress bar
"""
self.progress_value += int(percent/100*self.progress_weight)
self.progress.emit(self.progress_value)