File: drmpsdframe.cpp

package info (click to toggle)
qsstv 9.5.8-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 10,928 kB
  • sloc: cpp: 47,579; makefile: 4
file content (71 lines) | stat: -rw-r--r-- 1,869 bytes parent folder | download | duplicates (6)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include "drmpsdframe.h"
#include "ui_drmpsdframe.h"
#include <QPainter>
#include "drm.h"
#include "math.h"

#define PSDRANGE 70.
#define PSDLOW  0.

drmPSDFrame::drmPSDFrame(QWidget *parent) :
  QFrame(parent),
  ui(new Ui::drmPSDFrame)
{
  ui->setupUi(this);
}

drmPSDFrame::~drmPSDFrame()
{
  delete ui;
}

void drmPSDFrame::paintEvent (QPaintEvent *e)
{
    int i,x1,x2,y1,y2;
    float y;
    QPainter qpainter (this);

    //qpainter.drawRect (contentsRect());
    qpainter.setPen (QPen (Qt::blue, 1));
    qpainter.drawLine (contentsRect().x()+contentsRect().width()/2, contentsRect().y(), contentsRect().x()+contentsRect().width()/2,contentsRect().y()+contentsRect().height());
    qpainter.drawLine (contentsRect().x(), contentsRect().y()+contentsRect().height()/2, contentsRect().x()+contentsRect().width(),contentsRect().y()+contentsRect().height()/2);
    // draw PSD Info
    x1=0;
    y1=contentsRect().height();
    for(i=0;i<PSDSPAN/4;i++)
    {
        y=psd[i]-PSDLOW;
        if (y>PSDRANGE) y=PSDRANGE;
        y2=contentsRect().height()-rint((y/PSDRANGE) *(float)contentsRect().height());
        x2=(i*contentsRect().width())/(PSDSPAN/4);
        qpainter.drawLine(x1,y1,x2,y2);
        x1=x2;y1=y2;
    }
       qpainter.setPen (QPen (Qt::red, 1));
       x1=0;
       y1=contentsRect().height();
       for(i=0;i<PSDSPAN/4;i++)
       {
           y=cpsd[i]-PSDLOW;
           if (y>PSDRANGE) y=PSDRANGE;
           y2=contentsRect().height()-rint((y/PSDRANGE) *(float)contentsRect().height());
           x2=(i*contentsRect().width())/(PSDSPAN/4);
           qpainter.drawLine(x1,y1,x2,y2);
           x1=x2;y1=y2;
       }

  QFrame::paintEvent(e);
 }

void drmPSDFrame::setPSD()
{
   for(int i=0;i<PSDSPAN/4;i++)
    {
        psdArray[i]=psd[i];
    }
   for(int i=0;i<PSDSPAN/4;i++)
    {
        psdCArray[i]=cpsd[i];
    }
   update();
}