From 8d9b44c89dd2b876c68403779e163ede9fdd80b1 Mon Sep 17 00:00:00 2001
From: Jdrezen <jeremie.drezen@gmail.com>
Date: Mon, 17 May 2021 13:02:44 +0200
Subject: [PATCH] Ajout d'une classe PanelLimitedPlotChart

---
 pyAmakIHM/classes/controleur.py            |  3 ++
 pyAmakIHM/classes/fenetre.py               | 10 ++++++
 pyAmakIHM/classes/panelLimitedPlotChart.py | 38 ++++++++++++++++++++++
 3 files changed, 51 insertions(+)
 create mode 100644 pyAmakIHM/classes/panelLimitedPlotChart.py

diff --git a/pyAmakIHM/classes/controleur.py b/pyAmakIHM/classes/controleur.py
index 61e975c..7c62993 100644
--- a/pyAmakIHM/classes/controleur.py
+++ b/pyAmakIHM/classes/controleur.py
@@ -124,6 +124,9 @@ class Controleur:
     def addPlotChart(self, name : str) -> int:
         return self.__fenetre.addPlotChart(name)
 
+    def addLimitedPlotChart(self, name : str, limit) -> int:
+        return self.__fenetre.addLimitedPlotChart(name, limit)
+
     """
     Set the drawing policy to the curve of the plot chart identified by idCurve and id
     """
diff --git a/pyAmakIHM/classes/fenetre.py b/pyAmakIHM/classes/fenetre.py
index 076b177..0d637c4 100644
--- a/pyAmakIHM/classes/fenetre.py
+++ b/pyAmakIHM/classes/fenetre.py
@@ -11,6 +11,7 @@ from pyAmakIHM.classes.panelCommandes import PanelCommandes
 from pyAmakIHM.classes.panelVue import PanelVue
 from pyAmakIHM.classes.panelBarChart import PanelBarChart
 from pyAmakIHM.classes.panelPlotChart import PanelPlotChart
+from pyAmakIHM.classes.panelLimitedPlotChart import PanelLimitedPlotChart
 from tkinter import ttk, Tk
 
 
@@ -163,6 +164,15 @@ class Fenetre :
         self.__onglet.add(self.__panelGraphiques[length],text = name)
         return (length)
 
+    def addLimitedPlotChart(self, name : str, limit) -> int:
+        length = len(self.__panelGraphiques)
+        self.__panelGraphiques.append(PanelLimitedPlotChart(self.__onglet,length, limit))
+
+        self.__panelGraphiques[length].attach(self)
+        self.__onglet.add(self.__panelGraphiques[length],text = name)
+        return (length)
+
+
     """
     Set the drawing policy to the curve of the plot chart identified by idCurve and id
     """
diff --git a/pyAmakIHM/classes/panelLimitedPlotChart.py b/pyAmakIHM/classes/panelLimitedPlotChart.py
new file mode 100644
index 0000000..d14178d
--- /dev/null
+++ b/pyAmakIHM/classes/panelLimitedPlotChart.py
@@ -0,0 +1,38 @@
+"""
+Class PanelLimitedPlotChart
+"""
+
+from pyAmakIHM.classes.panelPlotChart import PanelPlotChart
+
+class PanelLimitedPlotChart(PanelPlotChart):
+    """
+    Class PanelLimitedPlotChart
+    """
+
+    def __init__(
+            self,
+            root,
+            id,
+            limit
+    ) :
+        super().__init__(root, id)
+
+        self.__limit = limit
+        self.__limited = False
+
+    def addPoint(self, id : int, x : int, y : int):
+        self.__axis.clear()
+        self.__xAxis[id].append(x)
+        self.__yAxis[id].append(y)
+
+        if(self.__limited):
+            del self.__xAxis[0]
+            del self.__yAxis[0]
+
+        else:
+            self.__limited = self.isLimited()
+
+        self.__rebuild()
+
+    def isLimited(self):
+        return len(self.__xAxis) > self.__limit
-- 
GitLab