Blame view

app/gui/oven_control/fileprocessgauge.cpp 1.57 KB
1f685a2a5   고영탁   설정 시스템 관리 기능 개발
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
  #include "fileprocessgauge.h"
  #include <QPainter>
  #include <QDebug>
  
  FileProcessGauge::FileProcessGauge(QWidget *parent) : PreheatTempGauge(parent)
  {
      border.load(":/images/gauge/103_usb_graph_01.png");
      indicator.load(":/images/gauge/103_usb_graph_02.png");
      body.load(":/images/gauge/103_usb_graph_03.png");
      min = 0;
      max = 100;
      val = 30;
  }
  
  void FileProcessGauge::paintEvent(QPaintEvent *event){
      QPainter painter(this);
      painter.setBrush(Qt::NoBrush);
      painter.setPen(Qt::NoPen);
      QRect textRect(0,0,72,40);
  
      qreal percentage = (qreal) (val - min) / qMax(max - min, 1);
      percentage = qBound((qreal) 0.0, percentage, (qreal) 1.0);
  
      QRect targetRect(
                  (border.size().width() - body.size().width()) / 2 + textRect.width()/2,
                  (border.size().height() - body.size().height()) / 2 + indicator.size().height()+textRect.height(),
                  body.size().width() * percentage, body.height());
  
      QRect sourceRect(0, 0, body.size().width() * percentage, body.height());
      QFont font;
      font.setFamily("나눔맑은고딕");
      font.setPixelSize(30);
      painter.setFont(font);
      painter.setPen(Qt::white);
      painter.drawPixmap(targetRect, body, sourceRect);
      painter.drawPixmap(textRect.width()/ 2, textRect.height()+indicator.size().height(), border);
      painter.drawPixmap(targetRect.right() - indicator.size().width() / 2, textRect.height(), indicator);
      textRect.setRect(targetRect.right() - textRect.size().width()/2, textRect.top(),72,40);
      painter.drawText(textRect,Qt::AlignCenter, QString("%1%").arg(val));
  }