Blame view

app/gui/oven_control/autocookwindow.cpp 21.3 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"
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
7
8
  
  AutoCookWindow::AutoCookWindow(QWidget *parent, Cook cook) :
99b8066f4   김태훈   V0.1.1
9
10
      QMainWindow(parent),
      ui(new Ui::AutoCookWindow),
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
11
      cook(cook)
99b8066f4   김태훈   V0.1.1
12
13
  {
      ui->setupUi(this);
99b8066f4   김태훈   V0.1.1
14
      ui->clockContainer->setParent(ui->upperStack);
6f96c947a   김태훈   GUI 0.1.4
15
      setAttribute(Qt::WA_DeleteOnClose);
99b8066f4   김태훈   V0.1.1
16
f588aa273   김태훈   부가 기능 로직 추가
17
18
19
20
      if (!this->cook.isLoaded())
          this->cook.load();
  
      autocook = AutoCook(this->cook);
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
21
22
23
      processSelected = false;
  
      setupUi();
99b8066f4   김태훈   V0.1.1
24
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
25
26
      Oven *oven = Oven::getInstance();
      connect(oven, SIGNAL(changed(Oven*)), SLOT(updateView()));
99b8066f4   김태훈   V0.1.1
27
28
29
30
  
      returnToCurrentStepTimer.setSingleShot(true);
      returnToCurrentStepTimer.setInterval(3000);
      connect(&returnToCurrentStepTimer, SIGNAL(timeout()), SLOT(returnToCurrentStep()));
99b8066f4   김태훈   V0.1.1
31
32
33
      showCurrentHumidityTimer.setSingleShot(true);
      showCurrentHumidityTimer.setInterval(3000);
      connect(&showCurrentHumidityTimer, SIGNAL(timeout()), SLOT(showCurrentHumidity()));
99b8066f4   김태훈   V0.1.1
34
35
36
      showCurrentTempTimer.setSingleShot(true);
      showCurrentTempTimer.setInterval(3000);
      connect(&showCurrentTempTimer, SIGNAL(timeout()), SLOT(showCurrentTemp()));
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
37
38
      connect(&checkCookTimer, SIGNAL(timeout()), SLOT(checkCook()));
      checkCookTimer.start(100);
d66d7f5b4   김태훈   GUI 버전 0.1.2
39
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
40
      connect(&checkProcessTimer, SIGNAL(timeout()), SLOT(checkProcess()));
f588aa273   김태훈   부가 기능 로직 추가
41
42
43
44
45
46
47
48
49
50
  
      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);
99b8066f4   김태훈   V0.1.1
51
52
53
54
55
56
57
58
59
  }
  
  AutoCookWindow::~AutoCookWindow()
  {
      delete ui;
  }
  
  void AutoCookWindow::setupUi()
  {
05f2a7552   김태훈   image 관리 구조 변경
60
61
62
      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
63
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
64
65
      ui->cookTypeIcon->setPixmap(Define::icon(cook.type));
      ui->selectCookButton->setText(cook.name);
99b8066f4   김태훈   V0.1.1
66
a366f320c   김태훈   자동 요리 후속 공정 동작 개선
67
      ui->stepIndicator->setMaximum(cook.steps.size() - 1);
99b8066f4   김태훈   V0.1.1
68
69
70
71
72
73
74
75
76
77
  
      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 관리 구조 변경
78
79
80
81
82
83
84
85
86
      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
87
88
89
      ui->openDoorAnimation->start(300);
      ui->openDoorAnimation->hide();
      ui->openDoorArrow->hide();
05f2a7552   김태훈   image 관리 구조 변경
90
91
92
93
94
95
96
97
98
      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
99
100
101
      ui->closeDoorAnimation->start(300);
      ui->closeDoorAnimation->hide();
      ui->closeDoorArrow->hide();
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
102
103
104
105
106
107
108
109
110
      lastViewCookMode = Define::InvalidMode;
      lastViewCookType = Define::Invalid;
      lastViewCoreTemp = 999;
      lastViewDoorType = Define::Invalid;
      lastViewTime = 0;
      lastViewStepIndex = -1;
      selectedStepIndex = 0;
      showingCurrentHumidity = false;
      showingCurrentTemp = false;
99b8066f4   김태훈   V0.1.1
111
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
112
      if (autocook.cook.processes.isEmpty())
99b8066f4   김태훈   V0.1.1
113
      {
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
114
115
116
117
118
          ui->processTitleLabel->hide();
          ui->processTypeLabel->hide();
          ui->processButton_1->hide();
          ui->processButton_2->hide();
          ui->processButton_3->hide();
99b8066f4   김태훈   V0.1.1
119
120
121
      }
      else
      {
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
122
123
124
          QString typeText;
          QSignalMapper *sm = NULL;
          for (int i = 0; i < 3; i++)
99b8066f4   김태훈   V0.1.1
125
          {
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
126
127
              QPushButton *pb;
              switch (i)
99b8066f4   김태훈   V0.1.1
128
129
              {
              case 0:
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
130
                  pb = ui->processButton_1;
99b8066f4   김태훈   V0.1.1
131
132
                  break;
              case 1:
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
133
                  pb = ui->processButton_2;
99b8066f4   김태훈   V0.1.1
134
135
                  break;
              case 2:
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
136
                  pb = ui->processButton_3;
99b8066f4   김태훈   V0.1.1
137
138
                  break;
              }
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
139
              if (i < autocook.cook.processes.size())
99b8066f4   김태훈   V0.1.1
140
              {
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
141
142
143
144
145
146
147
148
149
150
151
                  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
152
                  else
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
153
154
155
156
157
158
159
160
161
162
163
164
165
166
                      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
167
168
              }
          }
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
169
          ui->processTypeLabel->setText(typeText);
99b8066f4   김태훈   V0.1.1
170
      }
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
171
172
  
      ui->processContainer->hide();
f588aa273   김태훈   부가 기능 로직 추가
173
      ui->doorStepLabel->hide();
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
174
175
  
      updateView();
99b8066f4   김태훈   V0.1.1
176
  }
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
177
  void AutoCookWindow::updateView()
99b8066f4   김태훈   V0.1.1
178
  {
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
179
180
181
182
183
184
185
      Oven *oven = Oven::getInstance();
  
      QString spanFontSize11("<span style=\"font-size:11pt\">%1</span>");
      QString spanFontSize9("<span style=\"font-size:9pt\">%1</span>");
  
      int remainingTime = qMax(0, autocook.remainingTime());
      if (remainingTime != lastViewTime)
99b8066f4   김태훈   V0.1.1
186
      {
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
          lastViewTime = remainingTime;
  
          QString hour = spanFontSize11.arg("시간");
          QString min = spanFontSize11.arg("분");
          QString sec = spanFontSize11.arg("초");
  
          if (remainingTime >= 3600)
              ui->timeLabel->setText(QString("%1%2 %3%4")
                                     .arg(remainingTime / 3600)
                                     .arg(hour)
                                     .arg((remainingTime % 3600) / 60, 2, 10, QLatin1Char('0'))
                                     .arg(min));
          else if (remainingTime >= 60)
              ui->timeLabel->setText(QString("%1%2 %3%4")
                                     .arg(remainingTime / 60)
                                     .arg(min)
                                     .arg(remainingTime % 60, 2, 10, QLatin1Char('0'))
                                     .arg(sec));
          else
              ui->timeLabel->setText(QString("%1%2")
                                     .arg(remainingTime)
                                     .arg(sec));
99b8066f4   김태훈   V0.1.1
209
      }
99b8066f4   김태훈   V0.1.1
210
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
211
212
213
214
      int coreTemp = oven->currentInterTemp();
      if (coreTemp != lastViewCoreTemp)
      {
          lastViewCoreTemp = coreTemp;
99b8066f4   김태훈   V0.1.1
215
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
216
217
218
219
220
          QString coreTempLabel = QString::number(coreTemp);
          if (cook.isCoreTempValid())
              coreTempLabel += spanFontSize11.arg("℃ / " + QString::number(cook.coreTemp())) + spanFontSize9.arg("℃");
          else
              coreTempLabel += spanFontSize11.arg("℃");
99b8066f4   김태훈   V0.1.1
221
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
222
          ui->interTempLabel->setText(coreTempLabel);
99b8066f4   김태훈   V0.1.1
223
      }
99b8066f4   김태훈   V0.1.1
224
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
225
      if (autocook.done())
99b8066f4   김태훈   V0.1.1
226
      {
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
227
228
229
230
          if (!oven->door())
          {
              if (ui->openDoorAnimation->isHidden())
                  ui->openDoorAnimation->show();
6f96c947a   김태훈   GUI 0.1.4
231
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
232
233
234
235
236
237
238
239
240
241
              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
242
          {
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
243
244
245
246
247
248
249
250
251
252
253
              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
254
          }
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
255
256
257
  
          if (ui->processContainer->isHidden())
              ui->processContainer->show();
99b8066f4   김태훈   V0.1.1
258
      }
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
259
260
261
262
      else if (autocook.isWaitingDoorOpened() && !oven->door())
      {
          if (ui->openDoorAnimation->isHidden())
              ui->openDoorAnimation->show();
99b8066f4   김태훈   V0.1.1
263
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
264
265
          if (ui->openDoorArrow->isHidden())
              ui->openDoorArrow->show();
99b8066f4   김태훈   V0.1.1
266
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
267
268
          if (ui->closeDoorAnimation->isVisible())
              ui->closeDoorAnimation->hide();
99b8066f4   김태훈   V0.1.1
269
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
270
271
          if (ui->closeDoorArrow->isVisible())
              ui->closeDoorArrow->hide();
99b8066f4   김태훈   V0.1.1
272
      }
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
273
274
275
276
      else if (!autocook.isWaitingDoorOpened() && oven->door())
      {
          if (ui->openDoorAnimation->isVisible())
              ui->openDoorAnimation->hide();
99b8066f4   김태훈   V0.1.1
277
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
278
279
          if (ui->openDoorArrow->isVisible())
              ui->openDoorArrow->hide();
99b8066f4   김태훈   V0.1.1
280
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
281
282
          if (ui->closeDoorAnimation->isHidden())
              ui->closeDoorAnimation->show();
99b8066f4   김태훈   V0.1.1
283
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
284
285
286
287
288
289
290
          if (ui->closeDoorArrow->isHidden())
              ui->closeDoorArrow->show();
      }
      else
      {
          if (ui->openDoorAnimation->isVisible())
              ui->openDoorAnimation->hide();
99b8066f4   김태훈   V0.1.1
291
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
292
293
          if (ui->openDoorArrow->isVisible())
              ui->openDoorArrow->hide();
99b8066f4   김태훈   V0.1.1
294
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
295
296
          if (ui->closeDoorAnimation->isVisible())
              ui->closeDoorAnimation->hide();
99b8066f4   김태훈   V0.1.1
297
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
298
299
300
          if (ui->closeDoorArrow->isVisible())
              ui->closeDoorArrow->hide();
      }
99b8066f4   김태훈   V0.1.1
301
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
302
303
304
305
      if (autocook.cook.steps[autocook.currentStepIndex].type == Define::Preheat)
      {
          if (ui->preheatIcon->isHidden())
              ui->preheatIcon->show();
6f96c947a   김태훈   GUI 0.1.4
306
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
307
308
          if (ui->preheatLabel->isHidden())
              ui->preheatLabel->show();
6f96c947a   김태훈   GUI 0.1.4
309
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
310
311
312
313
314
315
316
317
          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
318
      {
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
319
320
          if (ui->preheatIcon->isVisible())
              ui->preheatIcon->hide();
d66d7f5b4   김태훈   GUI 버전 0.1.2
321
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
322
323
          if (ui->preheatLabel->isVisible())
              ui->preheatLabel->hide();
6f96c947a   김태훈   GUI 0.1.4
324
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
325
326
          if (ui->preheatGauge->isVisible())
              ui->preheatGauge->hide();
99b8066f4   김태훈   V0.1.1
327
      }
99b8066f4   김태훈   V0.1.1
328
b13e23ee4   김태훈   자동 요리 수정
329
330
331
332
333
334
335
      if (selectedStepIndex != autocook.currentStepIndex)
      {
          if (!returnToCurrentStepTimer.isActive())
          {
              selectedStepIndex = autocook.currentStepIndex;
          }
      }
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
336
      if (selectedStepIndex != lastViewStepIndex)
99b8066f4   김태훈   V0.1.1
337
      {
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
338
          lastViewStepIndex = selectedStepIndex;
a366f320c   김태훈   자동 요리 후속 공정 동작 개선
339
          ui->stepIndicator->setCurrentIndex(selectedStepIndex);
d66d7f5b4   김태훈   GUI 버전 0.1.2
340
      }
99b8066f4   김태훈   V0.1.1
341
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
342
343
      CookStep showingStep = autocook.cook.steps[selectedStepIndex];
      if (Define::classify(showingStep.type) == Define::DoorClass)
99b8066f4   김태훈   V0.1.1
344
      {
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
345
346
          if (ui->cookStepIcon->isVisible())
              ui->cookStepIcon->hide();
d66d7f5b4   김태훈   GUI 버전 0.1.2
347
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
          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
379
          {
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
380
              lastViewDoorType = showingStep.type;
d66d7f5b4   김태훈   GUI 버전 0.1.2
381
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
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
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
              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
425
426
427
              }
          }
      }
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
428
      else
6f96c947a   김태훈   GUI 0.1.4
429
      {
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
          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
464
          {
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
465
              lastViewCookType = showingStep.type;
6f96c947a   김태훈   GUI 0.1.4
466
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
467
468
              ui->cookStepIcon->setPixmap(Define::icon(showingStep.type));
              ui->cookStepLabel->setText(Define::name(showingStep.type));
6f96c947a   김태훈   GUI 0.1.4
469
          }
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
470
471
  
          if (showingStep.mode != lastViewCookMode)
6f96c947a   김태훈   GUI 0.1.4
472
          {
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
473
              lastViewCookMode = showingStep.mode;
6f96c947a   김태훈   GUI 0.1.4
474
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
475
476
477
478
479
480
481
482
483
484
485
486
487
488
              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
489
490
              }
          }
d66d7f5b4   김태훈   GUI 버전 0.1.2
491
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
492
493
494
495
496
          int humidity;
          if (showingCurrentHumidity)
              humidity = oven->currentHumidity();
          else
              humidity = showingStep.humidity;
99b8066f4   김태훈   V0.1.1
497
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
498
499
500
501
          if (humidity != lastViewHumidity)
          {
              lastViewHumidity = humidity;
              ui->humidityLabel->setText(QString("%1%").arg(humidity));
ecfb5801a   김태훈   디버깅 요청 사항 반영
502
              ui->humidityGauge->setValue(humidity);
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
503
          }
99b8066f4   김태훈   V0.1.1
504
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
505
506
507
508
509
          int temp;
          if (showingCurrentTemp)
              temp = oven->currentTemp();
          else
              temp = showingStep.temp;
99b8066f4   김태훈   V0.1.1
510
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
511
512
513
514
          if (temp != lastViewTemp)
          {
              lastViewTemp = temp;
              ui->heatLabel->setText(QString("%1℃").arg(temp));
ecfb5801a   김태훈   디버깅 요청 사항 반영
515
              ui->heatGauge->setValue(temp);
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
516
          }
99b8066f4   김태훈   V0.1.1
517
518
519
520
521
      }
  }
  
  void AutoCookWindow::checkCook()
  {
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
522
523
      int lastStepIndex = autocook.currentStepIndex;
      if (autocook.advance())
99b8066f4   김태훈   V0.1.1
524
      {
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
525
526
527
528
529
          if (lastStepIndex != autocook.currentStepIndex)
              selectedStepIndex = autocook.currentStepIndex;
  
          if (autocook.done())
              checkCookTimer.stop();
99b8066f4   김태훈   V0.1.1
530
531
532
533
      }
  
      updateView();
  }
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
534
  void AutoCookWindow::startProcess(int process)
99b8066f4   김태훈   V0.1.1
535
  {
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
536
537
      if (processSelected)
          return;
99b8066f4   김태훈   V0.1.1
538
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
539
      processSelected = true;
99b8066f4   김태훈   V0.1.1
540
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
541
542
543
544
545
546
      Define::Process p = (Define::Process) process;
      switch (p)
      {
      case Define::CookAgain:
      {
          close();
99b8066f4   김태훈   V0.1.1
547
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
548
549
550
551
          AutoCookWindow *w = new AutoCookWindow(parentWidget(), cook);
          w->setWindowModality(Qt::WindowModal);
          w->showFullScreen();
          w->raise();
99b8066f4   김태훈   V0.1.1
552
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
553
554
555
556
557
          break;
      }
      case Define::MakeCrisper:
      {
          selectedProcess = (Define::Process) process;
99b8066f4   김태훈   V0.1.1
558
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
559
          CookStep &step = autocook.cook.steps[autocook.cook.steps.size() - 1];
99b8066f4   김태훈   V0.1.1
560
a366f320c   김태훈   자동 요리 후속 공정 동작 개선
561
562
563
564
565
566
567
568
569
570
571
          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   김태훈   자동 요리 관련 로직 전면 재작성
572
          Oven *oven = Oven::getInstance();
a366f320c   김태훈   자동 요리 후속 공정 동작 개선
573
          oven->setHumidity(0);
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
574
575
          oven->setTemp(step.temp + 10);
          oven->startCooking();
99b8066f4   김태훈   V0.1.1
576
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
577
578
579
580
581
582
583
          checkProcessTimer.start(100);
          break;
      }
      case Define::KeepWarm:
      {
          processSelected = false;
          selectedProcess = (Define::Process) process;
99b8066f4   김태훈   V0.1.1
584
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
585
586
587
588
589
590
          KeepWarmPopup *p = new KeepWarmPopup(this);
          p->showFullScreen();
          p->raise();
          break;
      }
      }
99b8066f4   김태훈   V0.1.1
591
  }
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
592
  void AutoCookWindow::checkProcess()
99b8066f4   김태훈   V0.1.1
593
  {
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
594
595
      if (!processSelected)
          return;
99b8066f4   김태훈   V0.1.1
596
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
597
598
599
600
601
602
      switch (selectedProcess)
      {
      case Define::MakeCrisper:
      {
          Oven *oven = Oven::getInstance();
          if (oven->currentTemp() >= oven->temp())
99b8066f4   김태훈   V0.1.1
603
          {
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
604
605
              oven->stopCooking();
              checkProcessTimer.stop();
a366f320c   김태훈   자동 요리 후속 공정 동작 개선
606
              processSelected = false;
99b8066f4   김태훈   V0.1.1
607
          }
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
608
609
610
611
          break;
      }
      default:
          break;
99b8066f4   김태훈   V0.1.1
612
      }
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
613
614
  
      updateView();
99b8066f4   김태훈   V0.1.1
615
  }
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
616
  void AutoCookWindow::returnToCurrentStep()
99b8066f4   김태훈   V0.1.1
617
  {
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
618
619
620
      selectedStepIndex = autocook.currentStepIndex;
      showingDifferentStep = false;
      updateView();
99b8066f4   김태훈   V0.1.1
621
  }
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
622
  void AutoCookWindow::showCurrentHumidity()
99b8066f4   김태훈   V0.1.1
623
  {
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
624
625
626
      showingCurrentHumidity = true;
      updateView();
  }
99b8066f4   김태훈   V0.1.1
627
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
628
629
630
631
  void AutoCookWindow::showCurrentTemp()
  {
      showingCurrentTemp = true;
      updateView();
99b8066f4   김태훈   V0.1.1
632
  }
f588aa273   김태훈   부가 기능 로직 추가
633
634
635
636
637
638
639
640
641
642
643
  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();
  }
99b8066f4   김태훈   V0.1.1
644
645
646
647
648
649
650
  void AutoCookWindow::on_humidityGaugeButton_pressed()
  {
      showCurrentHumidityTimer.start();
  }
  
  void AutoCookWindow::on_humidityGaugeButton_released()
  {
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
651
652
      if (showCurrentHumidityTimer.isActive())
          showCurrentHumidityTimer.stop();
99b8066f4   김태훈   V0.1.1
653
618320ecd   김태훈   불필요한 UI 갱신 제거
654
655
656
657
658
      if (showingCurrentHumidity)
      {
          showingCurrentHumidity = false;
          updateView();
      }
99b8066f4   김태훈   V0.1.1
659
660
661
662
663
664
665
666
667
  }
  
  void AutoCookWindow::on_heatGaugeButton_pressed()
  {
      showCurrentTempTimer.start();
  }
  
  void AutoCookWindow::on_heatGaugeButton_released()
  {
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
668
669
      if (showCurrentTempTimer.isActive())
          showCurrentTempTimer.stop();
99b8066f4   김태훈   V0.1.1
670
618320ecd   김태훈   불필요한 UI 갱신 제거
671
672
673
674
675
      if (showingCurrentTemp)
      {
          showingCurrentTemp = false;
          updateView();
      }
99b8066f4   김태훈   V0.1.1
676
  }
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
677
  void AutoCookWindow::on_backButton_clicked()
99b8066f4   김태훈   V0.1.1
678
  {
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
679
680
681
      Oven::getInstance()->stop();
      close();
  }
99b8066f4   김태훈   V0.1.1
682
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
683
684
  void AutoCookWindow::on_showPrevStepButton_clicked()
  {
b13e23ee4   김태훈   자동 요리 수정
685
      returnToCurrentStepTimer.start();
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
686
687
688
689
690
      if (selectedStepIndex > 0)
      {
          selectedStepIndex--;
          updateView();
      }
99b8066f4   김태훈   V0.1.1
691
  }
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
692
  void AutoCookWindow::on_showNextStepButton_clicked()
99b8066f4   김태훈   V0.1.1
693
  {
b13e23ee4   김태훈   자동 요리 수정
694
      returnToCurrentStepTimer.start();
a366f320c   김태훈   자동 요리 후속 공정 동작 개선
695
      if (selectedStepIndex + 1 < autocook.cook.steps.size())
6a81d38e4   김태훈   자동 요리 관련 로직 전면 재작성
696
697
698
699
      {
          selectedStepIndex++;
          updateView();
      }
99b8066f4   김태훈   V0.1.1
700
  }
f588aa273   김태훈   부가 기능 로직 추가
701
702
703
704
705
706
707
708
709
710
711
  
  void AutoCookWindow::on_favoritesButton_clicked()
  {
      if (!autocook.done())
          return;
  
      ConfirmPopup *p = new ConfirmPopup(this, tr("즐겨찾기 항목에 추가하시겠습니까?"));
      p->showFullScreen();
  
      connect(p, SIGNAL(accepted()), SLOT(addFavorite()));
  }