continual indicator

This commit is contained in:
Kizarm 2024-11-14 15:12:23 +01:00
parent 14f2f78947
commit 2b0f2ae36e
2 changed files with 15 additions and 0 deletions

View file

@ -19,6 +19,7 @@ static const double ChannelsSteps [] = {
static constexpr double REF_Y = 3.3; // maximum napětí převodníku static constexpr double REF_Y = 3.3; // maximum napětí převodníku
static constexpr double MAX_Y = double (1 << 12); // 12. bit rozlišení - 4096 steps static constexpr double MAX_Y = double (1 << 12); // 12. bit rozlišení - 4096 steps
static constexpr double HALF_Y = 0.5 * MAX_Y; static constexpr double HALF_Y = 0.5 * MAX_Y;
static constexpr double QSCL_Y = 0.5 * HALF_Y;
static constexpr double STEP_Y = REF_Y / MAX_Y; // jeden krok ve Voltech static constexpr double STEP_Y = REF_Y / MAX_Y; // jeden krok ve Voltech
static constexpr unsigned T_SIZE = 1u << 10; static constexpr unsigned T_SIZE = 1u << 10;
static constexpr unsigned T_MASK = T_SIZE - 1u; static constexpr unsigned T_MASK = T_SIZE - 1u;
@ -40,6 +41,7 @@ DisplayWidget::DisplayWidget(QWidget * p) : QWidget(p), pcol(), ACopy(), BCopy()
for (QPointF & e : ChA) { const QPointF p (n++, 0); e = p; } for (QPointF & e : ChA) { const QPointF p (n++, 0); e = p; }
n = 0; n = 0;
for (QPointF & e : ChB) { const QPointF p (n++, 0); e = p; } for (QPointF & e : ChB) { const QPointF p (n++, 0); e = p; }
m_continual = false;
} }
DisplayWidget::~DisplayWidget() { DisplayWidget::~DisplayWidget() {
} }
@ -158,6 +160,7 @@ void DisplayWidget::resizeEvent(QResizeEvent * event) {
void DisplayWidget::paintEvent(QPaintEvent * event) { void DisplayWidget::paintEvent(QPaintEvent * event) {
QPainter p (this); QPainter p (this);
p.drawImage(event->rect(), background); p.drawImage(event->rect(), background);
drawCurrent(p);
QPen pa (pcol.colA, 2); QPen pa (pcol.colA, 2);
QPen pb (pcol.colB, 2); QPen pb (pcol.colB, 2);
p.setPen(pb); p.setPen(pb);
@ -169,6 +172,14 @@ void DisplayWidget::paintEvent(QPaintEvent * event) {
ma.translate(0, m_offset.a - HALF_Y); ma.translate(0, m_offset.a - HALF_Y);
p.drawPolyline (ma.map(ChA)); p.drawPolyline (ma.map(ChA));
} }
void DisplayWidget::drawCurrent(QPainter & p) {
if (!m_continual) return;
const QPen pen (QColor(192,192,192));
p.setPen (pen);
QLineF vl (QPointF(m_timeCount, -QSCL_Y), QPointF(m_timeCount, +QSCL_Y));
p.drawLine (m_forward.map (vl)); // Stávající poloha v kontinuálním módu
}
void DisplayWidget::setTrigger(TrigerSettings * ts) { void DisplayWidget::setTrigger(TrigerSettings * ts) {
m_ts = ts; m_ts = ts;
} }
@ -184,6 +195,7 @@ void DisplayWidget::reloadData () {
const size_t Amin = Alen < T_SIZE ? Alen : T_SIZE; const size_t Amin = Alen < T_SIZE ? Alen : T_SIZE;
const size_t Bmin = Blen < T_SIZE ? Blen : T_SIZE; const size_t Bmin = Blen < T_SIZE ? Blen : T_SIZE;
if ((Alen == 1u) and (Blen == 1u)) { // kontinuální mód if ((Alen == 1u) and (Blen == 1u)) { // kontinuální mód
m_continual = true;
const QPointF pta (m_timeCount, ACopy [0]), ptb (m_timeCount, BCopy [0]); const QPointF pta (m_timeCount, ACopy [0]), ptb (m_timeCount, BCopy [0]);
ChA[m_timeCount] = pta; ChA[m_timeCount] = pta;
ChB[m_timeCount] = ptb; ChB[m_timeCount] = ptb;
@ -191,6 +203,7 @@ void DisplayWidget::reloadData () {
m_timeCount &= T_MASK; m_timeCount &= T_MASK;
return; return;
} }
m_continual = false;
for (unsigned n=0u; n<Amin; n++) { for (unsigned n=0u; n<Amin; n++) {
QPointF & p = ChA [n]; QPointF & p = ChA [n];
p.setY (ACopy [n]); p.setY (ACopy [n]);

View file

@ -45,6 +45,7 @@ class DisplayWidget : public QWidget {
MARKER_VOLT_B, MARKER_VOLT_B,
} marker_type; } marker_type;
unsigned m_timeCount; unsigned m_timeCount;
bool m_continual;
public: public:
explicit DisplayWidget (QWidget * p); explicit DisplayWidget (QWidget * p);
virtual ~DisplayWidget (); virtual ~DisplayWidget ();
@ -68,6 +69,7 @@ class DisplayWidget : public QWidget {
signals: signals:
void SettingsChanged (int n); void SettingsChanged (int n);
protected: protected:
void drawCurrent (QPainter & p);
void drawBackground (); void drawBackground ();
void reloadData (); void reloadData ();
void reloadMatrix (const QSize & sz); void reloadMatrix (const QSize & sz);