mirror of
https://forge.apps.education.fr/blender-edutech/jumeaux-numeriques.git
synced 2024-01-27 06:56:18 +01:00
77 lines
2.3 KiB
Python
77 lines
2.3 KiB
Python
import bge # Bibliothèque Blender Game Engine (UPBGE)
|
|
import sys
|
|
import matplotlib
|
|
matplotlib.use('Qt5Agg')
|
|
|
|
rom PyQt5 import QtCore, QtGui, QtWidgets
|
|
|
|
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg, NavigationToolbar2QT as NavigationToolbar
|
|
from matplotlib.figure import Figure
|
|
|
|
###############################################################################
|
|
# twin_plot.py
|
|
# @title: Visualisation des données
|
|
# @project: Blender-EduTech
|
|
# @lang: fr
|
|
# @authors: Philippe Roy <philippe.roy@ac-grenoble.fr>
|
|
# @copyright: Copyright (C) 2023 Philippe Roy
|
|
# @license: GNU GPL
|
|
###############################################################################
|
|
|
|
# UPBGE scene
|
|
scene = bge.logic.getCurrentScene()
|
|
|
|
# Récupérer le brochage du jumeau réel
|
|
# system=importlib.import_module(scene.objects['Doc']['system']) # Système
|
|
# pin_config = system.get_pin_config()
|
|
|
|
###############################################################################
|
|
# Fenêtre avec la Toobar
|
|
###############################################################################
|
|
|
|
class MplCanvas(FigureCanvasQTAgg):
|
|
|
|
def __init__(self, parent=None, width=5, height=4, dpi=100):
|
|
fig = Figure(figsize=(width, height), dpi=dpi)
|
|
self.axes = fig.add_subplot(111)
|
|
super(MplCanvas, self).__init__(fig)
|
|
|
|
|
|
class MainWindow(QtWidgets.QMainWindow):
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
super(MainWindow, self).__init__(*args, **kwargs)
|
|
|
|
sc = MplCanvas(self, width=5, height=4, dpi=100)
|
|
sc.axes.plot([0,1,2,3,4], [10,1,20,3,40])
|
|
|
|
# Create toolbar, passing canvas as first parament, parent (self, the MainWindow) as second.
|
|
toolbar = NavigationToolbar(sc, self)
|
|
|
|
layout = QtWidgets.QVBoxLayout()
|
|
layout.addWidget(toolbar)
|
|
layout.addWidget(sc)
|
|
|
|
# Create a placeholder widget to hold our toolbar and canvas.
|
|
widget = QtWidgets.QWidget()
|
|
widget.setLayout(layout)
|
|
self.setCentralWidget(widget)
|
|
|
|
self.show()
|
|
|
|
###############################################################################
|
|
# Visualisation
|
|
###############################################################################
|
|
|
|
|
|
##
|
|
# Test
|
|
##
|
|
|
|
def test():
|
|
|
|
# FIXME : mettre le multithreading
|
|
# app = QtWidgets.QApplication(sys.argv)
|
|
w = MainWindow()
|
|
# app.exec_()
|