Blame view

app/gui/oven_control/autocookwindow.cpp 22.4 KB
99b8066f4   김태훈   V0.1.1
1
2
  #include "autocookwindow.h"
  #include "ui_autocookwindow.h"
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
3
  #include "keepwarmpopup.h"
f588aa273   김태훈   부가 기능 로직 추가
4
5
6
  #include "cookhistory.h"
  #include "confirmpopup.h"
  #include "favoritenamepopup.h"
2bfd3a050   김태훈   환경 설정 대응
7
  #include "stringer.h"
bbd7d8f29   김태훈   버튼 음향 추가
8
  #include "soundplayer.h"
e00c6a2a9   김태훈   기능 추가 구현
9
10
11
  #include "configwindow.h"
  #include "washwindow.h"
  #include "mainwindow.h"
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
12
13
  
  AutoCookWindow::AutoCookWindow(QWidget *parent, Cook cook) :
99b8066f4   김태훈   V0.1.1
14
15
      QMainWindow(parent),
      ui(new Ui::AutoCookWindow),
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
16
      cook(cook)
99b8066f4   김태훈   V0.1.1
17
18
  {
      ui->setupUi(this);
99b8066f4   김태훈   V0.1.1
19
      ui->clockContainer->setParent(ui->upperStack);
6f96c947a   김태훈   GUI 0.1.4
20
      setAttribute(Qt::WA_DeleteOnClose);
99b8066f4   김태훈   V0.1.1
21
f588aa273   김태훈   부가 기능 로직 추가
22
23
24
25
      if (!this->cook.isLoaded())
          this->cook.load();
  
      autocook = AutoCook(this->cook);
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
26
27
28
      processSelected = false;
  
      setupUi();
99b8066f4   김태훈   V0.1.1
29
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
30
31
      Oven *oven = Oven::getInstance();
      connect(oven, SIGNAL(changed(Oven*)), SLOT(updateView()));
99b8066f4   김태훈   V0.1.1
32
33
34
35
  
      returnToCurrentStepTimer.setSingleShot(true);
      returnToCurrentStepTimer.setInterval(3000);
      connect(&returnToCurrentStepTimer, SIGNAL(timeout()), SLOT(returnToCurrentStep()));
99b8066f4   김태훈   V0.1.1
36
37
38
      showCurrentHumidityTimer.setSingleShot(true);
      showCurrentHumidityTimer.setInterval(3000);
      connect(&showCurrentHumidityTimer, SIGNAL(timeout()), SLOT(showCurrentHumidity()));
99b8066f4   김태훈   V0.1.1
39
40
41
      showCurrentTempTimer.setSingleShot(true);
      showCurrentTempTimer.setInterval(3000);
      connect(&showCurrentTempTimer, SIGNAL(timeout()), SLOT(showCurrentTemp()));
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
42
43
      connect(&checkCookTimer, SIGNAL(timeout()), SLOT(checkCook()));
      checkCookTimer.start(100);
d66d7f5b4   김태훈   GUI 버전 0.1.2
44
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
45
      connect(&checkProcessTimer, SIGNAL(timeout()), SLOT(checkProcess()));
f588aa273   김태훈   부가 기능 로직 추가
46
47
48
49
50
51
52
53
54
55
  
      AutoCookSetting setting;
      setting.type = cook.type;
      setting.root = cook.root;
      setting.name = cook.name;
  
      for (int i = 0; i < 5; i++)
          setting.configs[i] = cook.configs[i].current;
  
      CookHistory::record(setting);
2bfd3a050   김태훈   환경 설정 대응
56
bbd7d8f29   김태훈   버튼 음향 추가
57
58
      foreach (QPushButton *button, findChildren<QPushButton *>())
          connect(button, &QPushButton::pressed, SoundPlayer::playClick);
2bfd3a050   김태훈   환경 설정 대응
59
60
      connect(&updateViewTimer, SIGNAL(timeout()), SLOT(updateView()));
      updateViewTimer.start(100);
99b8066f4   김태훈   V0.1.1
61
62
63
64
65
66
67
68
69
  }
  
  AutoCookWindow::~AutoCookWindow()
  {
      delete ui;
  }
  
  void AutoCookWindow::setupUi()
  {
05f2a7552   김태훈   image 관리 구조 변경
70
71
72
      steamModeIcon.load(":/images/cook_mode/small_steam.png");
      dryModeIcon.load(":/images/cook_mode/small_dryheat.png");
      combiModeIcon.load(":/images/cook_mode/small_combi.png");
6f96c947a   김태훈   GUI 0.1.4
73
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
74
75
      ui->cookTypeIcon->setPixmap(Define::icon(cook.type));
      ui->selectCookButton->setText(cook.name);
99b8066f4   김태훈   V0.1.1
76
a366f320c   김태훈   자동 요리 후속 공정 동작 개선
77
      ui->stepIndicator->setMaximum(cook.steps.size() - 1);
99b8066f4   김태훈   V0.1.1
78
79
80
81
82
83
84
85
86
87
  
      ui->cookStepAnimation->start(300);
  
      ui->humidityGauge->setMinimum(0);
      ui->humidityGauge->setMaximum(100);
      ui->humidityGauge->setValue(0);
  
      ui->heatGauge->setMinimum(30);
      ui->heatGauge->setMaximum(300);
      ui->heatGauge->setValue(30);
05f2a7552   김태훈   image 관리 구조 변경
88
89
90
91
92
93
94
95
96
      ui->openDoorAnimation->load(":/images/animation/door_01.png");
      ui->openDoorAnimation->load(":/images/animation/door_02.png");
      ui->openDoorAnimation->load(":/images/animation/door_03.png");
      ui->openDoorAnimation->load(":/images/animation/door_04.png");
      ui->openDoorAnimation->load(":/images/animation/door_05.png");
      ui->openDoorAnimation->load(":/images/animation/door_06.png");
      ui->openDoorAnimation->load(":/images/animation/door_07.png");
      ui->openDoorAnimation->load(":/images/animation/door_08.png");
      ui->openDoorAnimation->load(":/images/animation/door_09.png");
6f96c947a   김태훈   GUI 0.1.4
97
98
99
      ui->openDoorAnimation->start(300);
      ui->openDoorAnimation->hide();
      ui->openDoorArrow->hide();
05f2a7552   김태훈   image 관리 구조 변경
100
101
102
103
104
105
106
107
108
      ui->closeDoorAnimation->load(":/images/animation/door_09.png");
      ui->closeDoorAnimation->load(":/images/animation/door_08.png");
      ui->closeDoorAnimation->load(":/images/animation/door_07.png");
      ui->closeDoorAnimation->load(":/images/animation/door_06.png");
      ui->closeDoorAnimation->load(":/images/animation/door_05.png");
      ui->closeDoorAnimation->load(":/images/animation/door_04.png");
      ui->closeDoorAnimation->load(":/images/animation/door_03.png");
      ui->closeDoorAnimation->load(":/images/animation/door_02.png");
      ui->closeDoorAnimation->load(":/images/animation/door_01.png");
6f96c947a   김태훈   GUI 0.1.4
109
110
111
      ui->closeDoorAnimation->start(300);
      ui->closeDoorAnimation->hide();
      ui->closeDoorArrow->hide();
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
112
113
114
115
116
117
      lastViewCookMode = Define::InvalidMode;
      lastViewCookType = Define::Invalid;
      lastViewCoreTemp = 999;
      lastViewDoorType = Define::Invalid;
      lastViewTime = 0;
      lastViewStepIndex = -1;
7d0288172   김태훈   기능 추가 구현
118
119
      lastViewTemp = 999;
      lastViewHumidity = 999;
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
120
121
122
      selectedStepIndex = 0;
      showingCurrentHumidity = false;
      showingCurrentTemp = false;
99b8066f4   김태훈   V0.1.1
123
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
124
      if (autocook.cook.processes.isEmpty())
99b8066f4   김태훈   V0.1.1
125
      {
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
126
127
128
129
130
          ui->processTitleLabel->hide();
          ui->processTypeLabel->hide();
          ui->processButton_1->hide();
          ui->processButton_2->hide();
          ui->processButton_3->hide();
99b8066f4   김태훈   V0.1.1
131
132
133
      }
      else
      {
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
134
135
136
          QString typeText;
          QSignalMapper *sm = NULL;
          for (int i = 0; i < 3; i++)
99b8066f4   김태훈   V0.1.1
137
          {
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
138
139
              QPushButton *pb;
              switch (i)
99b8066f4   김태훈   V0.1.1
140
141
              {
              case 0:
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
142
                  pb = ui->processButton_1;
99b8066f4   김태훈   V0.1.1
143
144
                  break;
              case 1:
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
145
                  pb = ui->processButton_2;
99b8066f4   김태훈   V0.1.1
146
147
                  break;
              case 2:
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
148
                  pb = ui->processButton_3;
99b8066f4   김태훈   V0.1.1
149
150
                  break;
              }
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
151
              if (i < autocook.cook.processes.size())
99b8066f4   김태훈   V0.1.1
152
              {
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
153
154
155
156
157
158
159
160
161
162
163
                  if (sm == NULL)
                  {
                      sm = new QSignalMapper(this);
                      connect(sm, SIGNAL(mapped(int)), SLOT(startProcess(int)));
                  }
  
                  Define::Process process = autocook.cook.processes[i];
  
                  QString text = Define::name(process);
                  if (typeText.isEmpty())
                      typeText = text;
6f96c947a   김태훈   GUI 0.1.4
164
                  else
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
165
166
167
168
169
170
171
172
173
174
175
176
177
178
                      typeText += ", " + text;
  
                  QString styleSheet = QString("QPushButton { border-image: url(%1) } QPushButton:pressed { border-image: url(%2) }")
                          .arg(Define::icon(process))
                          .arg(Define::iconOverlay(process));
  
                  pb->setStyleSheet(styleSheet);
  
                  sm->setMapping(pb, (int) process);
                  connect(pb, SIGNAL(clicked()), sm, SLOT(map()));
              }
              else
              {
                  pb->hide();
99b8066f4   김태훈   V0.1.1
179
180
              }
          }
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
181
          ui->processTypeLabel->setText(typeText);
99b8066f4   김태훈   V0.1.1
182
      }
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
183
184
  
      ui->processContainer->hide();
f588aa273   김태훈   부가 기능 로직 추가
185
      ui->doorStepLabel->hide();
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
186
187
  
      updateView();
99b8066f4   김태훈   V0.1.1
188
  }
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
189
  void AutoCookWindow::updateView()
99b8066f4   김태훈   V0.1.1
190
  {
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
191
      Oven *oven = Oven::getInstance();
2bfd3a050   김태훈   환경 설정 대응
192
      if (!autocook.done())
99b8066f4   김태훈   V0.1.1
193
      {
2bfd3a050   김태훈   환경 설정 대응
194
195
          int remainingTime = qMax(0, autocook.msecs());
          ui->timeLabel->setText(Stringer::remainingTime(remainingTime));
99b8066f4   김태훈   V0.1.1
196
      }
99b8066f4   김태훈   V0.1.1
197
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
198
199
200
201
      int coreTemp = oven->currentInterTemp();
      if (coreTemp != lastViewCoreTemp)
      {
          lastViewCoreTemp = coreTemp;
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
202
          if (cook.isCoreTempValid())
2bfd3a050   김태훈   환경 설정 대응
203
              ui->interTempLabel->setText(Stringer::temperature(coreTemp, cook.coreTemp(), Stringer::fontSize14));
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
204
          else
2bfd3a050   김태훈   환경 설정 대응
205
              ui->interTempLabel->setText(Stringer::temperature(coreTemp, Stringer::fontSize14));
99b8066f4   김태훈   V0.1.1
206
      }
99b8066f4   김태훈   V0.1.1
207
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
208
      if (autocook.done())
99b8066f4   김태훈   V0.1.1
209
      {
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
210
211
212
213
          if (!oven->door())
          {
              if (ui->openDoorAnimation->isHidden())
                  ui->openDoorAnimation->show();
6f96c947a   김태훈   GUI 0.1.4
214
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
215
216
217
218
219
220
221
222
223
224
              if (ui->openDoorArrow->isHidden())
                  ui->openDoorArrow->show();
  
              if (ui->closeDoorAnimation->isVisible())
                  ui->closeDoorAnimation->hide();
  
              if (ui->closeDoorArrow->isVisible())
                  ui->closeDoorArrow->hide();
          }
          else
6f96c947a   김태훈   GUI 0.1.4
225
          {
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
226
227
228
229
230
231
232
233
234
235
236
              if (ui->openDoorAnimation->isVisible())
                  ui->openDoorAnimation->hide();
  
              if (ui->openDoorArrow->isVisible())
                  ui->openDoorArrow->hide();
  
              if (ui->closeDoorAnimation->isVisible())
                  ui->closeDoorAnimation->hide();
  
              if (ui->closeDoorArrow->isVisible())
                  ui->closeDoorArrow->hide();
6f96c947a   김태훈   GUI 0.1.4
237
          }
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
238
239
240
  
          if (ui->processContainer->isHidden())
              ui->processContainer->show();
99b8066f4   김태훈   V0.1.1
241
      }
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
242
243
244
245
      else if (autocook.isWaitingDoorOpened() && !oven->door())
      {
          if (ui->openDoorAnimation->isHidden())
              ui->openDoorAnimation->show();
99b8066f4   김태훈   V0.1.1
246
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
247
248
          if (ui->openDoorArrow->isHidden())
              ui->openDoorArrow->show();
99b8066f4   김태훈   V0.1.1
249
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
250
251
          if (ui->closeDoorAnimation->isVisible())
              ui->closeDoorAnimation->hide();
99b8066f4   김태훈   V0.1.1
252
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
253
254
          if (ui->closeDoorArrow->isVisible())
              ui->closeDoorArrow->hide();
99b8066f4   김태훈   V0.1.1
255
      }
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
256
257
258
259
      else if (!autocook.isWaitingDoorOpened() && oven->door())
      {
          if (ui->openDoorAnimation->isVisible())
              ui->openDoorAnimation->hide();
99b8066f4   김태훈   V0.1.1
260
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
261
262
          if (ui->openDoorArrow->isVisible())
              ui->openDoorArrow->hide();
99b8066f4   김태훈   V0.1.1
263
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
264
265
          if (ui->closeDoorAnimation->isHidden())
              ui->closeDoorAnimation->show();
99b8066f4   김태훈   V0.1.1
266
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
267
268
269
270
271
272
273
          if (ui->closeDoorArrow->isHidden())
              ui->closeDoorArrow->show();
      }
      else
      {
          if (ui->openDoorAnimation->isVisible())
              ui->openDoorAnimation->hide();
99b8066f4   김태훈   V0.1.1
274
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
275
276
          if (ui->openDoorArrow->isVisible())
              ui->openDoorArrow->hide();
99b8066f4   김태훈   V0.1.1
277
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
278
279
          if (ui->closeDoorAnimation->isVisible())
              ui->closeDoorAnimation->hide();
99b8066f4   김태훈   V0.1.1
280
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
281
282
283
          if (ui->closeDoorArrow->isVisible())
              ui->closeDoorArrow->hide();
      }
99b8066f4   김태훈   V0.1.1
284
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
285
286
287
288
      if (autocook.cook.steps[autocook.currentStepIndex].type == Define::Preheat)
      {
          if (ui->preheatIcon->isHidden())
              ui->preheatIcon->show();
6f96c947a   김태훈   GUI 0.1.4
289
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
290
291
          if (ui->preheatLabel->isHidden())
              ui->preheatLabel->show();
6f96c947a   김태훈   GUI 0.1.4
292
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
293
294
295
296
297
298
299
300
          if (ui->preheatGauge->isHidden())
              ui->preheatGauge->show();
  
          ui->preheatGauge->setMaximum(autocook.cook.steps[autocook.currentStepIndex].temp);
          ui->preheatGauge->setMinimum(autocook.startTemp);
          ui->preheatGauge->setValue(oven->currentTemp());
      }
      else
99b8066f4   김태훈   V0.1.1
301
      {
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
302
303
          if (ui->preheatIcon->isVisible())
              ui->preheatIcon->hide();
d66d7f5b4   김태훈   GUI 버전 0.1.2
304
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
305
306
          if (ui->preheatLabel->isVisible())
              ui->preheatLabel->hide();
6f96c947a   김태훈   GUI 0.1.4
307
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
308
309
          if (ui->preheatGauge->isVisible())
              ui->preheatGauge->hide();
99b8066f4   김태훈   V0.1.1
310
      }
99b8066f4   김태훈   V0.1.1
311
b13e23ee4   김태훈   자동 요리 수정
312
313
314
315
316
317
318
      if (selectedStepIndex != autocook.currentStepIndex)
      {
          if (!returnToCurrentStepTimer.isActive())
          {
              selectedStepIndex = autocook.currentStepIndex;
          }
      }
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
319
      if (selectedStepIndex != lastViewStepIndex)
99b8066f4   김태훈   V0.1.1
320
      {
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
321
          lastViewStepIndex = selectedStepIndex;
a366f320c   김태훈   자동 요리 후속 공정 동작 개선
322
          ui->stepIndicator->setCurrentIndex(selectedStepIndex);
d66d7f5b4   김태훈   GUI 버전 0.1.2
323
      }
99b8066f4   김태훈   V0.1.1
324
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
325
326
      CookStep showingStep = autocook.cook.steps[selectedStepIndex];
      if (Define::classify(showingStep.type) == Define::DoorClass)
99b8066f4   김태훈   V0.1.1
327
      {
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
328
329
          if (ui->cookStepIcon->isVisible())
              ui->cookStepIcon->hide();
d66d7f5b4   김태훈   GUI 버전 0.1.2
330
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
          if (ui->cookStepLabel->isVisible())
              ui->cookStepLabel->hide();
  
          if (ui->cookModeIcon->isVisible())
              ui->cookModeIcon->hide();
  
          if (ui->humidityGauge->isVisible())
              ui->humidityGauge->hide();
  
          if (ui->humidityGaugeButton->isVisible())
              ui->humidityGaugeButton->hide();
  
          if (ui->humidityLabel->isVisible())
              ui->humidityLabel->hide();
  
          if (ui->heatGauge->isVisible())
              ui->heatGauge->hide();
  
          if (ui->heatGaugeButton->isVisible())
              ui->heatGaugeButton->hide();
  
          if (ui->heatLabel->isVisible())
              ui->heatLabel->hide();
  
          if (ui->doorStepLabel->isHidden())
              ui->doorStepLabel->show();
  
          if (ui->cookStepAnimation->isHidden())
              ui->cookStepAnimation->show();
  
          if (showingStep.type != lastViewDoorType)
99b8066f4   김태훈   V0.1.1
362
          {
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
363
              lastViewDoorType = showingStep.type;
d66d7f5b4   김태훈   GUI 버전 0.1.2
364
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
              ui->doorStepLabel->setText(Define::name(showingStep.type));
              ui->cookStepAnimation->clear();
              switch (showingStep.type)
              {
              case Define::PutThermometer:
                  ui->doorStepLabel->setText("중심 온도계 삽입");
                  ui->cookStepAnimation->load(":/images/animation/thermometer_01.png");
                  ui->cookStepAnimation->load(":/images/animation/thermometer_02.png");
                  ui->cookStepAnimation->setGeometry((900-210)/2, 800, 210, 307);
                  ui->cookStepAnimation->start(300);
                  break;
              case Define::Load:
                  ui->doorStepLabel->setText("식재료 적재");
                  ui->cookStepAnimation->load(":/images/animation/load_01.png");
                  ui->cookStepAnimation->load(":/images/animation/load_02.png");
                  ui->cookStepAnimation->load(":/images/animation/load_03.png");
                  ui->cookStepAnimation->load(":/images/animation/load_04.png");
                  ui->cookStepAnimation->load(":/images/animation/load_03.png");
                  ui->cookStepAnimation->load(":/images/animation/load_02.png");
                  ui->cookStepAnimation->load(":/images/animation/load_01.png");
                  ui->cookStepAnimation->setGeometry((900-264)/2, 800, 264, 307);
                  ui->cookStepAnimation->start(300);
                  break;
              case Define::Cut:
                  ui->doorStepLabel->setText("자르기");
                  ui->cookStepAnimation->load(":/images/animation/cut_01.png");
                  ui->cookStepAnimation->load(":/images/animation/cut_02.png");
                  ui->cookStepAnimation->load(":/images/animation/cut_03.png");
                  ui->cookStepAnimation->setGeometry((900-264)/2, 800, 264, 307);
                  ui->cookStepAnimation->start(300);
                  break;
              case Define::Pour:
                  ui->doorStepLabel->setText("물 붓기");
                  ui->cookStepAnimation->load(":/images/animation/pour_01.png");
                  ui->cookStepAnimation->load(":/images/animation/pour_02.png");
                  ui->cookStepAnimation->load(":/images/animation/pour_03.png");
                  ui->cookStepAnimation->load(":/images/animation/pour_04.png");
                  ui->cookStepAnimation->setGeometry((900-264)/2, 800, 264, 307);
                  ui->cookStepAnimation->start(300);
                  break;
              default:
                  ui->doorStepLabel->hide();
                  ui->cookStepAnimation->hide();
99b8066f4   김태훈   V0.1.1
408
409
410
              }
          }
      }
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
411
      else
6f96c947a   김태훈   GUI 0.1.4
412
      {
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
          if (ui->doorStepLabel->isVisible())
              ui->doorStepLabel->hide();
  
          if (ui->cookStepAnimation->isVisible())
              ui->cookStepAnimation->hide();
  
          if (ui->cookStepIcon->isHidden())
              ui->cookStepIcon->show();
  
          if (ui->cookStepLabel->isHidden())
              ui->cookStepLabel->show();
  
          if (ui->cookModeIcon->isHidden())
              ui->cookModeIcon->show();
  
          if (ui->humidityGauge->isHidden())
              ui->humidityGauge->show();
  
          if (ui->humidityGaugeButton->isHidden())
              ui->humidityGaugeButton->show();
  
          if (ui->humidityLabel->isHidden())
              ui->humidityLabel->show();
  
          if (ui->heatGauge->isHidden())
              ui->heatGauge->show();
  
          if (ui->heatGaugeButton->isHidden())
              ui->heatGaugeButton->show();
  
          if (ui->heatLabel->isHidden())
              ui->heatLabel->show();
  
          if (showingStep.type != lastViewCookType)
6f96c947a   김태훈   GUI 0.1.4
447
          {
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
448
              lastViewCookType = showingStep.type;
6f96c947a   김태훈   GUI 0.1.4
449
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
450
451
              ui->cookStepIcon->setPixmap(Define::icon(showingStep.type));
              ui->cookStepLabel->setText(Define::name(showingStep.type));
6f96c947a   김태훈   GUI 0.1.4
452
          }
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
453
454
  
          if (showingStep.mode != lastViewCookMode)
6f96c947a   김태훈   GUI 0.1.4
455
          {
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
456
              lastViewCookMode = showingStep.mode;
6f96c947a   김태훈   GUI 0.1.4
457
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
458
459
460
461
462
463
464
465
466
467
468
469
470
471
              switch (showingStep.mode)
              {
              case Define::SteamMode:
                  ui->cookModeIcon->setPixmap(steamModeIcon);
                  break;
              case Define::CombiMode:
                  ui->cookModeIcon->setPixmap(combiModeIcon);
                  break;
              case Define::DryMode:
                  ui->cookModeIcon->setPixmap(dryModeIcon);
                  break;
              case Define::InvalidClass:
                  ui->cookModeIcon->hide();
                  break;
6f96c947a   김태훈   GUI 0.1.4
472
473
              }
          }
d66d7f5b4   김태훈   GUI 버전 0.1.2
474
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
475
476
477
478
479
          int humidity;
          if (showingCurrentHumidity)
              humidity = oven->currentHumidity();
          else
              humidity = showingStep.humidity;
99b8066f4   김태훈   V0.1.1
480
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
481
482
483
484
          if (humidity != lastViewHumidity)
          {
              lastViewHumidity = humidity;
              ui->humidityLabel->setText(QString("%1%").arg(humidity));
ecfb5801a   김태훈   디버깅 요청 사항 반영
485
              ui->humidityGauge->setValue(humidity);
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
486
          }
99b8066f4   김태훈   V0.1.1
487
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
488
489
490
491
492
          int temp;
          if (showingCurrentTemp)
              temp = oven->currentTemp();
          else
              temp = showingStep.temp;
99b8066f4   김태훈   V0.1.1
493
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
494
495
496
          if (temp != lastViewTemp)
          {
              lastViewTemp = temp;
2bfd3a050   김태훈   환경 설정 대응
497
              ui->heatLabel->setText(Stringer::temperature(temp));
ecfb5801a   김태훈   디버깅 요청 사항 반영
498
              ui->heatGauge->setValue(temp);
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
499
          }
99b8066f4   김태훈   V0.1.1
500
501
502
503
504
      }
  }
  
  void AutoCookWindow::checkCook()
  {
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
505
506
      int lastStepIndex = autocook.currentStepIndex;
      if (autocook.advance())
99b8066f4   김태훈   V0.1.1
507
      {
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
508
509
510
511
512
          if (lastStepIndex != autocook.currentStepIndex)
              selectedStepIndex = autocook.currentStepIndex;
  
          if (autocook.done())
              checkCookTimer.stop();
99b8066f4   김태훈   V0.1.1
513
514
515
516
      }
  
      updateView();
  }
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
517
  void AutoCookWindow::startProcess(int process)
99b8066f4   김태훈   V0.1.1
518
  {
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
519
520
      if (processSelected)
          return;
99b8066f4   김태훈   V0.1.1
521
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
522
      processSelected = true;
99b8066f4   김태훈   V0.1.1
523
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
524
525
526
527
528
529
      Define::Process p = (Define::Process) process;
      switch (p)
      {
      case Define::CookAgain:
      {
          close();
99b8066f4   김태훈   V0.1.1
530
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
531
532
533
534
          AutoCookWindow *w = new AutoCookWindow(parentWidget(), cook);
          w->setWindowModality(Qt::WindowModal);
          w->showFullScreen();
          w->raise();
99b8066f4   김태훈   V0.1.1
535
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
536
537
538
539
540
          break;
      }
      case Define::MakeCrisper:
      {
          selectedProcess = (Define::Process) process;
99b8066f4   김태훈   V0.1.1
541
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
542
          CookStep &step = autocook.cook.steps[autocook.cook.steps.size() - 1];
99b8066f4   김태훈   V0.1.1
543
a366f320c   김태훈   자동 요리 후속 공정 동작 개선
544
545
546
547
548
549
550
551
552
553
554
          CookStep newStep = step;
          newStep.type = Define::MakeCrispy;
          newStep.humidity = 0;
          newStep.temp += 10;
          newStep.time = 0;
          newStep.humidification = 0;
          newStep.dehumidification = 0;
          autocook.cook.steps.append(newStep);
          autocook.currentStepIndex = autocook.cook.steps.size() - 1;
          ui->stepIndicator->setMaximum(autocook.cook.steps.size() - 1);
          returnToCurrentStep();
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
555
          Oven *oven = Oven::getInstance();
a366f320c   김태훈   자동 요리 후속 공정 동작 개선
556
          oven->setHumidity(0);
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
557
558
          oven->setTemp(step.temp + 10);
          oven->startCooking();
99b8066f4   김태훈   V0.1.1
559
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
560
561
562
563
564
565
566
          checkProcessTimer.start(100);
          break;
      }
      case Define::KeepWarm:
      {
          processSelected = false;
          selectedProcess = (Define::Process) process;
99b8066f4   김태훈   V0.1.1
567
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
568
569
570
571
572
          KeepWarmPopup *p = new KeepWarmPopup(this);
          p->showFullScreen();
          p->raise();
          break;
      }
1f7568d7e   김태훈   컴파일 경고 제거
573
574
      default:
          return;
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
575
      }
99b8066f4   김태훈   V0.1.1
576
  }
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
577
  void AutoCookWindow::checkProcess()
99b8066f4   김태훈   V0.1.1
578
  {
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
579
580
      if (!processSelected)
          return;
99b8066f4   김태훈   V0.1.1
581
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
582
583
584
585
586
587
      switch (selectedProcess)
      {
      case Define::MakeCrisper:
      {
          Oven *oven = Oven::getInstance();
          if (oven->currentTemp() >= oven->temp())
99b8066f4   김태훈   V0.1.1
588
          {
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
589
590
              oven->stopCooking();
              checkProcessTimer.stop();
a366f320c   김태훈   자동 요리 후속 공정 동작 개선
591
              processSelected = false;
99b8066f4   김태훈   V0.1.1
592
          }
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
593
594
595
596
          break;
      }
      default:
          break;
99b8066f4   김태훈   V0.1.1
597
      }
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
598
599
  
      updateView();
99b8066f4   김태훈   V0.1.1
600
  }
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
601
  void AutoCookWindow::returnToCurrentStep()
99b8066f4   김태훈   V0.1.1
602
  {
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
603
604
605
      selectedStepIndex = autocook.currentStepIndex;
      showingDifferentStep = false;
      updateView();
99b8066f4   김태훈   V0.1.1
606
  }
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
607
  void AutoCookWindow::showCurrentHumidity()
99b8066f4   김태훈   V0.1.1
608
  {
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
609
610
611
      showingCurrentHumidity = true;
      updateView();
  }
99b8066f4   김태훈   V0.1.1
612
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
613
614
615
616
  void AutoCookWindow::showCurrentTemp()
  {
      showingCurrentTemp = true;
      updateView();
99b8066f4   김태훈   V0.1.1
617
  }
f588aa273   김태훈   부가 기능 로직 추가
618
619
620
621
622
623
624
625
626
627
628
  void AutoCookWindow::addFavorite()
  {
      AutoCookSetting s;
      s.type = cook.type;
      s.root = cook.root;
      for (int i = 0; i < 5; i++)
          s.configs[i] = cook.configs[i].current;
  
      FavoriteNamePopup *p = new FavoriteNamePopup(this, s);
      p->showFullScreen();
  }
e00c6a2a9   김태훈   기능 추가 구현
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
  void AutoCookWindow::jumpConfig()
  {
      Oven::getInstance()->stop();
  
      ConfigWindow *w = new ConfigWindow(MainWindow::getInstance());
      w->setWindowModality(Qt::WindowModal);
      w->showFullScreen();
      w->raise();
  
      MainWindow::jump(w);
  }
  
  void AutoCookWindow::jumpWash()
  {
      Oven::getInstance()->stop();
  
      WashWindow *w = new WashWindow(MainWindow::getInstance());
      w->setWindowModality(Qt::WindowModal);
      w->showFullScreen();
      w->raise();
  
      MainWindow::jump(w);
  }
7d0288172   김태훈   기능 추가 구현
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
  void AutoCookWindow::on_selectCookButton_clicked()
  {
  
  }
  
  void AutoCookWindow::on_homeButton_clicked()
  {
      Oven::getInstance()->stop();
  
      MainWindow::killChild();
  }
  
  void AutoCookWindow::on_configCookButton_clicked()
  {
  
  }
99b8066f4   김태훈   V0.1.1
668
669
670
671
672
673
674
  void AutoCookWindow::on_humidityGaugeButton_pressed()
  {
      showCurrentHumidityTimer.start();
  }
  
  void AutoCookWindow::on_humidityGaugeButton_released()
  {
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
675
676
      if (showCurrentHumidityTimer.isActive())
          showCurrentHumidityTimer.stop();
99b8066f4   김태훈   V0.1.1
677
618320ecd   김태훈   불필요한 UI 갱신 제거
678
679
680
681
682
      if (showingCurrentHumidity)
      {
          showingCurrentHumidity = false;
          updateView();
      }
99b8066f4   김태훈   V0.1.1
683
684
685
686
687
688
689
690
691
  }
  
  void AutoCookWindow::on_heatGaugeButton_pressed()
  {
      showCurrentTempTimer.start();
  }
  
  void AutoCookWindow::on_heatGaugeButton_released()
  {
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
692
693
      if (showCurrentTempTimer.isActive())
          showCurrentTempTimer.stop();
99b8066f4   김태훈   V0.1.1
694
618320ecd   김태훈   불필요한 UI 갱신 제거
695
696
697
698
699
      if (showingCurrentTemp)
      {
          showingCurrentTemp = false;
          updateView();
      }
99b8066f4   김태훈   V0.1.1
700
  }
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
701
702
  void AutoCookWindow::on_showPrevStepButton_clicked()
  {
b13e23ee4   김태훈   자동 요리 수정
703
      returnToCurrentStepTimer.start();
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
704
705
706
707
708
      if (selectedStepIndex > 0)
      {
          selectedStepIndex--;
          updateView();
      }
99b8066f4   김태훈   V0.1.1
709
  }
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
710
  void AutoCookWindow::on_showNextStepButton_clicked()
99b8066f4   김태훈   V0.1.1
711
  {
b13e23ee4   김태훈   자동 요리 수정
712
      returnToCurrentStepTimer.start();
a366f320c   김태훈   자동 요리 후속 공정 동작 개선
713
      if (selectedStepIndex + 1 < autocook.cook.steps.size())
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
714
715
716
717
      {
          selectedStepIndex++;
          updateView();
      }
99b8066f4   김태훈   V0.1.1
718
  }
f588aa273   김태훈   부가 기능 로직 추가
719
e00c6a2a9   김태훈   기능 추가 구현
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
  void AutoCookWindow::on_backButton_clicked()
  {
      Oven::getInstance()->stop();
      close();
  }
  
  void AutoCookWindow::on_configButton_clicked()
  {
      if (autocook.done())
      {
          ConfigWindow *w = new ConfigWindow(MainWindow::getInstance());
          w->setWindowModality(Qt::WindowModal);
          w->showFullScreen();
          w->raise();
  
          MainWindow::jump(w);
      }
      else
      {
          ConfirmPopup *p = new ConfirmPopup(this, tr("요리가 중단되고 환경 설정 모드로 들어갑니다. 진행할까요?"));
          p->showFullScreen();
  
          connect(p, SIGNAL(accepted()), SLOT(jumpConfig()));
      }
  }
f588aa273   김태훈   부가 기능 로직 추가
745
746
747
748
749
750
751
752
753
754
  void AutoCookWindow::on_favoritesButton_clicked()
  {
      if (!autocook.done())
          return;
  
      ConfirmPopup *p = new ConfirmPopup(this, tr("즐겨찾기 항목에 추가하시겠습니까?"));
      p->showFullScreen();
  
      connect(p, SIGNAL(accepted()), SLOT(addFavorite()));
  }
e00c6a2a9   김태훈   기능 추가 구현
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
  
  void AutoCookWindow::on_washButton_clicked()
  {
      if (autocook.done())
      {
          WashWindow *w = new WashWindow(MainWindow::getInstance());
          w->setWindowModality(Qt::WindowModal);
          w->showFullScreen();
          w->raise();
  
          MainWindow::jump(w);
      }
      else
      {
          ConfirmPopup *p = new ConfirmPopup(this, tr("요리가 중단되고 자동 세척 모드로 들어갑니다. 진행할까요?"));
          p->showFullScreen();
  
          connect(p, SIGNAL(accepted()), SLOT(jumpWash()));
      }
  }
  
  void AutoCookWindow::on_helpButton_clicked()
  {
  
  }