|
5
|
1 |
/* |
|
8
|
2 |
* This file is part of the TraKERS\Middleware package. |
|
|
3 |
* |
|
|
4 |
* (c) IRI <http://www.iri.centrepompidou.fr/> |
|
|
5 |
* |
|
|
6 |
* For the full copyright and license information, please view the LICENSE_MIDDLEWARE |
|
|
7 |
* file that was distributed with this source code. |
|
|
8 |
*/ |
|
|
9 |
|
|
|
10 |
/* |
|
5
|
11 |
* Projet : TraKERS |
|
|
12 |
* Module : MIDDLEWARE |
|
|
13 |
* Sous-Module : Debug |
|
|
14 |
* Classe : DebugParameters |
|
|
15 |
* |
|
|
16 |
* Auteur : alexandre.bastien@iri.centrepompidou.fr |
|
|
17 |
* |
|
|
18 |
* Fonctionnalités : Code source attaché à la fenêtre de paramétrage du Middleware. |
|
|
19 |
* Celui-ci permet de charger/sauvegarder les paramètres stockés dans KinectMain. |
|
|
20 |
*/ |
|
|
21 |
|
|
|
22 |
using System; |
|
|
23 |
using System.Collections.Generic; |
|
|
24 |
using System.Linq; |
|
|
25 |
using System.Text; |
|
|
26 |
using System.Windows; |
|
|
27 |
using System.Windows.Controls; |
|
|
28 |
using System.Windows.Data; |
|
|
29 |
using System.Windows.Documents; |
|
|
30 |
using System.Windows.Input; |
|
|
31 |
using System.Windows.Media; |
|
|
32 |
using System.Windows.Media.Imaging; |
|
|
33 |
using System.Windows.Shapes; |
|
|
34 |
using Trakers.Tracking; |
|
|
35 |
using System.Reflection; |
|
|
36 |
using System.Resources; |
|
|
37 |
|
|
|
38 |
namespace Trakers.Debug |
|
|
39 |
{ |
|
|
40 |
/// <summary> |
|
|
41 |
/// Interaction logic for DebugParameters.xaml |
|
|
42 |
/// </summary> |
|
|
43 |
public partial class DebugParameters : Window |
|
|
44 |
{ |
|
|
45 |
//Membre d'accès à KinectMain. |
|
|
46 |
private KinectMain kinectMain; |
|
|
47 |
private ResourceManager rm; |
|
|
48 |
|
|
|
49 |
/* |
|
|
50 |
* Constructeur : On ouvre la fenêtre et on charge les paramètres. |
|
|
51 |
*/ |
|
|
52 |
public DebugParameters(KinectMain _kinectMain) |
|
|
53 |
{ |
|
|
54 |
rm = new ResourceManager("Trakers.Properties.resources", Assembly.GetExecutingAssembly()); |
|
|
55 |
kinectMain = _kinectMain; |
|
|
56 |
InitializeComponent(); |
|
|
57 |
getParameters(); |
|
|
58 |
} |
|
|
59 |
|
|
|
60 |
/* |
|
|
61 |
* Permet de charger les paramètres depuis KinectMain et les affiche dans la fenêtre de paramétrage. |
|
|
62 |
*/ |
|
|
63 |
public void getParameters() |
|
|
64 |
{ |
|
|
65 |
searchMinDistanceTB.Text = kinectMain.getMinDistHands().ToString(); |
|
|
66 |
searchMaxDistanceTB.Text = kinectMain.getMaxDistHands().ToString(); |
|
11
|
67 |
minDistanceTB.Text = kinectMain.getMinDist().ToString(); |
|
|
68 |
maxDistanceTB.Text = kinectMain.getMaxDist().ToString(); |
|
|
69 |
zeroPointTB.Text = kinectMain.getZeroPoint().ToString(); |
|
5
|
70 |
connexionHostTB.Text = kinectMain.getConnexionHost(); |
|
|
71 |
connexionPortTB.Text = kinectMain.getConnexionPort().ToString(); |
|
|
72 |
timerElapsingTB.Text = kinectMain.getTimerElapsing().ToString(); |
|
11
|
73 |
imagesToShowTB.Text = kinectMain.getImagesToShow().ToString(); |
|
13
|
74 |
takenPointsTB.Text = kinectMain.getTakenPoints().ToString(); |
|
|
75 |
directionChangeTresholdXYTB.Text = kinectMain.getTakenPoints().ToString(); |
|
|
76 |
directionChangeTresholdZTB.Text = kinectMain.getTakenPoints().ToString(); |
|
5
|
77 |
} |
|
|
78 |
|
|
|
79 |
/* |
|
|
80 |
* Permet de sauvegarder les paramètres de la fenêtre de paramétrage vers KinectMain. |
|
|
81 |
*/ |
|
|
82 |
public void setParameters() |
|
|
83 |
{ |
|
|
84 |
try |
|
|
85 |
{ |
|
|
86 |
ExceptionInParametersLbl.Content = ""; |
|
|
87 |
|
|
|
88 |
float minDistHands = float.Parse(searchMinDistanceTB.Text); |
|
|
89 |
float maxDistHands = float.Parse(searchMaxDistanceTB.Text); |
|
11
|
90 |
float minDist = float.Parse(minDistanceTB.Text); |
|
|
91 |
float maxDist = float.Parse(maxDistanceTB.Text); |
|
|
92 |
float zeroPoint = float.Parse(zeroPointTB.Text); |
|
5
|
93 |
int connexionPort = int.Parse(connexionPortTB.Text); |
|
|
94 |
int timerElapsing = int.Parse(timerElapsingTB.Text); |
|
11
|
95 |
int imagesToShow = int.Parse(imagesToShowTB.Text); |
|
13
|
96 |
int takenPoints = int.Parse(takenPointsTB.Text); |
|
|
97 |
int directionChangeTresholdXY = int.Parse(directionChangeTresholdXYTB.Text); |
|
|
98 |
float directionChangeTresholdZ = float.Parse(directionChangeTresholdZTB.Text); |
|
5
|
99 |
|
|
6
|
100 |
if (maxDistHands <= 0f || minDistHands <= 0f || maxDistHands > maxDist || minDistHands > maxDist || |
|
|
101 |
minDistHands >= maxDistHands || zeroPoint < maxDistHands || minDistHands < minDist || |
|
13
|
102 |
zeroPoint >= maxDist || connexionPort < 0 || timerElapsing < 0 || imagesToShow < 1 || |
|
|
103 |
takenPoints <= 0 || directionChangeTresholdXY < 0 || directionChangeTresholdZ < 0) |
|
5
|
104 |
{ |
|
|
105 |
ExceptionInParametersLbl.Content = rm.GetString("loadParametersIncorrect"); |
|
|
106 |
} |
|
|
107 |
else |
|
|
108 |
{ |
|
|
109 |
kinectMain.setMinDistHands(minDistHands); |
|
|
110 |
kinectMain.setMaxDistHands(maxDistHands); |
|
11
|
111 |
kinectMain.setMinDist(minDist); |
|
|
112 |
kinectMain.setMaxDist(maxDist); |
|
|
113 |
kinectMain.setZeroPoint(zeroPoint); |
|
5
|
114 |
kinectMain.setConnexionHost(connexionHostTB.Text); |
|
|
115 |
kinectMain.setConnexionPort(connexionPort); |
|
|
116 |
kinectMain.setTimerElapsing(timerElapsing); |
|
11
|
117 |
kinectMain.setImagesToShow(imagesToShow); |
|
13
|
118 |
kinectMain.setTakenPoints(takenPoints); |
|
|
119 |
kinectMain.setDirectionChangeTresholdXY(directionChangeTresholdXY); |
|
|
120 |
kinectMain.setDirectionChangeTresholdZ(directionChangeTresholdZ); |
|
5
|
121 |
|
|
|
122 |
kinectMain.updateParameters(); |
|
11
|
123 |
ExceptionInParametersLbl.Content = null; |
|
5
|
124 |
} |
|
|
125 |
} |
|
|
126 |
catch (Exception) |
|
|
127 |
{ |
|
|
128 |
//S'il y a eu un problème de parsing (i.e si l'utilisateur a entré une mauvaise valeur), |
|
|
129 |
//Alors on affiche l'erreur, puis on recharge les paramètres précédents. |
|
|
130 |
ExceptionInParametersLbl.Content = rm.GetString("loadParametersFail"); |
|
|
131 |
getParameters(); |
|
|
132 |
} |
|
|
133 |
} |
|
|
134 |
|
|
|
135 |
/* |
|
|
136 |
* Méthode attachée à l'événement click sur le bouton de validation de la fenêtre de paramétrage. |
|
|
137 |
* Les données sont sauvegardées vers KinectMain, puis rechargées dans la fenêtre. |
|
|
138 |
*/ |
|
|
139 |
private void Button_Click(object sender, RoutedEventArgs e) |
|
|
140 |
{ |
|
|
141 |
setParameters(); |
|
|
142 |
} |
|
|
143 |
} |
|
|
144 |
} |