Pymecavideo 8.0
Étude cinématique à l'aide de vidéos
etatsMain.py
1# -*- coding: utf-8 -*-
2
3"""
4 etatsMain, a module for pymecavideo:
5 a program to track moving points in a video frameset
6
7 Copyright (C) 2023 Georges Khaznadar <georgesk@debian.org>
8
9 This program is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
21"""
22
23from PyQt6.QtCore import Qt, QObject, pyqtSignal
24from PyQt6.QtWidgets import QMessageBox
25
26import os
27
28from vecteur import vecteur
29from etats import Etats_Base
30
31class Etats(Etats_Base):
32 """
33 Une classe qui permet de définir les états pour le pointageWidget
34 debut, A, AB, B, C, D, E : voir le fichier etats_pymecavideo.html
35 """
36
37 def __init__(self):
38 Etats_Base.__init__(self)
39 return
40
41 def changeEtat(self, etat):
42 """
43 changement d'état : fait ce qu'il faut faire au niveau de la fenêtre
44 principale puis renvoie aux autres widgets actifs
45 """
46 self.setStatus("")
47 self.etat_ancienetat_ancien = self.etat # conserve pour plus tard
48 self.etat = etat
49 self.dbg.p(1, f"========> État précédent = {self.etat_ancien}. État suivant = {self.etat}")
50 if self.etat not in self.etats:
51 raise Exception(
52 f"L'état doit être {', '.join(self.etats)}, or il est « {repr(self.etat)} »")
53 if etat == "debut":
54 for obj in self.actionDefaire, self.actionRefaire, \
55 self.actionCopier_dans_le_presse_papier, \
56 self.menuE_xporter_vers, \
57 self.actionSaveData :
58
59 obj.setEnabled(False)
60 self.actionExemples.setEnabled(True)
61 self.tabWidget.setEnabled(True)
62 # organisation des onglets
63 self.tabWidget.setCurrentIndex(0) # montre l'onglet video
64 for i in range(1,4):
65 self.tabWidget.setTabEnabled(i, False) # autres onglets inactifs
66
67 # autorise le redimensionnement de la fenêtre principale
68 self.OKRedimensionnement.emit()
69
70 elif etat == "A":
71 if self.pointage.filename is None: return
72 self.setWindowTitle(self.tr("Pymecavideo : {filename}").format(
73 filename = os.path.basename(self.pointage.filename)))
74 if not self.pointage.echelle_image:
75 # sans échelle, on peut redimensionner la fenêtre
76 self.OKRedimensionnement.emit()
77 for obj in self.menuE_xporter_vers, self.actionSaveData, \
78 self.actionCopier_dans_le_presse_papier:
79 obj.setEnabled(True)
80 for i in 1, 2, 3:
81 self.tabWidget.setTabEnabled(i, False)
82
83 self.affiche_statut.emit(
84 self.tr("Veuillez choisir une image (et définir l'échelle)"))
85 self.montre_vitesses = False
86 self.egalise_origine()
87 self.init_variables(self.pointage.filename)
88
89 elif etat == "AB":
90 for obj in self.actionCopier_dans_le_presse_papier, \
91 self.menuE_xporter_vers, self.actionSaveData :
92 obj.setEnabled(False)
93 self.affiche_statut.emit(self.tr("Pointage Automatique"))
94 QMessageBox.information(
95 None, "Capture Automatique",
96 self.tr("""\
97Veuillez sélectionner un cadre autour du ou des objets que vous voulez suivre ;
98Vous pouvez arrêter à tout moment la capture en appuyant sur le bouton STOP""",
99 None))
100
101 pass
102 elif etat == "B":
103 pass
104 elif etat == "C":
105 for obj in self.actionCopier_dans_le_presse_papier, \
106 self.menuE_xporter_vers, self.actionSaveData:
107 obj.setEnabled(False)
108
109 elif etat == "D":
110 # tous les onglets sont actifs
111 if self.pointage:
112 for i in 1, 2, 3:
113 self.tabWidget.setTabEnabled(i, True)
114 # mise à jour des menus
115 self.actionSaveData.setEnabled(True)
116 self.actionCopier_dans_le_presse_papier.setEnabled(True)
117
118 elif etat == "E":
119 for i in 1, 2, 3:
120 self.tabWidget.setTabEnabled(i, False)
121
122 self.affiche_statut.emit("")
123 for widget in self.pointage, self.trajectoire, self.coord, self.graph:
124 widget.changeEtat(etat)
125 return
Une classe qui permet de définir les états pour le pointageWidget debut, A, AB, B,...
Definition: etatsMain.py:35
def changeEtat(self, etat)
changement d'état : fait ce qu'il faut faire au niveau de la fenêtre principale puis renvoie aux autr...
Definition: etatsMain.py:45
Une classe qui permet de définir les états pour le pointageWidget debut, A, AB, B,...
Definition: etats.py:30