From b1167a86e7d48d4deb428d5567a435621d6a6f8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=B5=D0=BB=D0=B8=D0=BF=D0=B5=D0=BD=D0=BA=D0=BE=20?= =?UTF-8?q?=D0=98=D0=B2=D0=B0=D0=BD?= Date: Wed, 23 May 2018 13:24:41 +0000 Subject: [PATCH] git-svn-id: svn://db.shs.com.ru/libs@385 a8b55f48-bf90-11e4-a774-851b48703e85 --- cd_utils/cdutils_types.cpp | 9 +- cd_utils/cdutils_types.h | 3 +- qcd_utils/pult/cdgraphic.cpp | 13 +++ qcd_utils/pult/cdgraphic.h | 31 +++++++ qcd_utils/pult/cdgraphic.ui | 154 ++++++++++++++++++++++++++++++++++ qcd_utils/pult/cdgraphics.cpp | 62 +++++++++----- qcd_utils/pult/cdgraphics.h | 6 +- qcd_utils/qcd_model.cpp | 2 +- qcd_utils/qcd_model.h | 2 +- qcd_utils/qcd_view.cpp | 1 + 10 files changed, 255 insertions(+), 28 deletions(-) create mode 100644 qcd_utils/pult/cdgraphic.cpp create mode 100644 qcd_utils/pult/cdgraphic.h create mode 100644 qcd_utils/pult/cdgraphic.ui diff --git a/cd_utils/cdutils_types.cpp b/cd_utils/cdutils_types.cpp index 88b4c2a..050f0c4 100644 --- a/cd_utils/cdutils_types.cpp +++ b/cd_utils/cdutils_types.cpp @@ -126,11 +126,13 @@ void CDType::readX(PIByteArray & ba) { case X_Current: ba >> value_d; break; - case X_All_Avg: - ba >> history; + case X_All_Avg: { + PIVector ah; + ba >> ah; + history << ah; if (!history.isEmpty()) value_d = history.back(); - break; + } break; default: break; } value_i = value_d; @@ -146,6 +148,7 @@ void CDType::writeX(PIByteArray & ba) { break; case X_All_Avg: ba << history; + history.clear(); break; default: break; } diff --git a/cd_utils/cdutils_types.h b/cd_utils/cdutils_types.h index 5a84b6c..a1997a2 100644 --- a/cd_utils/cdutils_types.h +++ b/cd_utils/cdutils_types.h @@ -64,6 +64,8 @@ public: void readX(PIByteArray & ba); void writeX(PIByteArray & ba); + PIVector history; + protected: bool calculate(PIEvaluator * e, PIVector stack = PIVector()); PIVariantTypes::Enum parseEnumComment(PIString c); @@ -77,7 +79,6 @@ protected: double value_d; int value_i; bool value_b, calculated, x_enabled; - PIVector history; PIVector avg_h; int avg_size; XMode mode_; diff --git a/qcd_utils/pult/cdgraphic.cpp b/qcd_utils/pult/cdgraphic.cpp new file mode 100644 index 0000000..1e5d099 --- /dev/null +++ b/qcd_utils/pult/cdgraphic.cpp @@ -0,0 +1,13 @@ +#include "cdgraphic.h" +#include "cdutils_core.h" +#include "cdutils_x.h" +#include "graphic.h" +#include "piqt.h" + +using namespace CDUtils; + + +CDGraphicWidget::CDGraphicWidget(QWidget * p): QWidget(p), Ui::CDGraphicWidget() { + setupUi(this); + graphic->setGraphicsCount(0); +} diff --git a/qcd_utils/pult/cdgraphic.h b/qcd_utils/pult/cdgraphic.h new file mode 100644 index 0000000..ae02a18 --- /dev/null +++ b/qcd_utils/pult/cdgraphic.h @@ -0,0 +1,31 @@ +#ifndef CDGRAPHIC_H +#define CDGRAPHIC_H + +#include +#include "ui_cdgraphic.h" +#include + +namespace CDUtils { + class CDType; + class CDSection; +} + +class Graphic; + + +class CDGraphicWidget: public QWidget, public Ui::CDGraphicWidget { + Q_OBJECT +public: + CDGraphicWidget(QWidget * p = 0); + + +private: + +private slots: + +signals: + +}; + + +#endif // CDGRAPHIC_H diff --git a/qcd_utils/pult/cdgraphic.ui b/qcd_utils/pult/cdgraphic.ui new file mode 100644 index 0000000..705199c --- /dev/null +++ b/qcd_utils/pult/cdgraphic.ui @@ -0,0 +1,154 @@ + + + CDGraphicWidget + + + + 0 + 0 + 470 + 380 + + + + CD Pult + + + + + + Graphic::Autofit|Graphic::BorderInputs|Graphic::Clear|Graphic::Configure|Graphic::CursorAxis|Graphic::Fullscreen|Graphic::Legend|Graphic::OnlyExpandY|Graphic::Pause|Graphic::Save + + + false + + + false + + + 100.000000000000000 + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + History: + + + + + + + 100.000000000000000 + + + + + + + Qt::Horizontal + + + + 1 + 20 + + + + + + + + Visible: + + + + + + + -1.000000000000000 + + + + + + + Qt::Horizontal + + + + 1 + 20 + + + + + + + + + + + + Graphic + QFrame +
graphic.h
+
+ + EvalSpinBox + QWidget +
evalspinbox.h
+
+
+ + + + evalHistory + valueChanged(double) + graphic + setHistorySize(double) + + + 148 + 363 + + + 156 + 297 + + + + + evalVisible + valueChanged(double) + graphic + setMaxVisibleTime(double) + + + 345 + 361 + + + 342 + 337 + + + + +
diff --git a/qcd_utils/pult/cdgraphics.cpp b/qcd_utils/pult/cdgraphics.cpp index ae54c17..fe93f85 100644 --- a/qcd_utils/pult/cdgraphics.cpp +++ b/qcd_utils/pult/cdgraphics.cpp @@ -27,14 +27,9 @@ GDockWidget::GDockWidget(QString title, QMainWindow * p): QDockWidget(title, p) dactions << a; menu_x = new QMenu(this); menu_x->setTitle(trUtf8("Remove X")); - graphic = new Graphic(); - graphic->setGraphicsCount(0); - graphic->setBorderInputsVisible(false); - graphic->setLegendVisible(true); - graphic->setStatusVisible(false); - graphic->setButtons(graphic->buttons() & ~(Graphic::Grid | Graphic::OnlyExpandX | Graphic::Close)); - graphic->viewport()->setAcceptDrops(true); - graphic->viewport()->installEventFilter(this); + graphic = new CDGraphicWidget(); + graphic->graphic->viewport()->setAcceptDrops(true); + graphic->graphic->viewport()->installEventFilter(this); setWidget(graphic); } @@ -44,9 +39,20 @@ void GDockWidget::addX(const CDType & t) { PIDeque xp = t.path(); if (x_list.contains(xp)) return; x_list << xp; - int gind = graphic->graphicsCount(); - graphic->setGraphicsCount(gind + 1); - graphic->setGraphicName(PI2QString(t.pathString().join(".")), gind); + int gind = graphic->graphic->graphicsCount(); + graphic->graphic->setGraphicsCount(gind + 1); + graphic->graphic->setGraphicName(PI2QString(t.pathString().join(".")), gind); +} + + +void GDockWidget::drawX(const PIMap > & data) { + for (int i = 0; i < x_list.size_s(); ++i) { + PIString sp = CDCore::pathToString(x_list[i]); + const PIVector & ch(data[sp]); + for (int j = 0; j < ch.size_s(); ++j) + graphic->graphic->addPoint(ch[j], i, false); + } + graphic->graphic->updateGraphics(); } @@ -81,12 +87,13 @@ bool GDockWidget::eventFilter(QObject * o, QEvent * e) { void GDockWidget::contextMenuEvent(QContextMenuEvent * e) { + if (graphic->graphic->underMouse()) return; qDeleteAll(menu_x->actions()); menu_x->clear(); - for (int i = 0; i < graphic->graphicsCount(); ++i) { + for (int i = 0; i < graphic->graphic->graphicsCount(); ++i) { QPixmap icon(da->iconSize()); - icon.fill(graphic->graphic(i).pen.color()); - QAction * a = new QAction(QIcon(icon), graphic->graphic(i).name, this); + icon.fill(graphic->graphic->graphic(i).pen.color()); + QAction * a = new QAction(QIcon(icon), graphic->graphic->graphic(i).name, this); a->setData(i); connect(a, SIGNAL(triggered(bool)), this, SLOT(removeX())); menu_x->addAction(a); @@ -102,11 +109,11 @@ void GDockWidget::contextMenuEvent(QContextMenuEvent * e) { } -Graphic * GDockWidget::viewportGraphic(QObject * o) const { +CDGraphicWidget * GDockWidget::viewportGraphic(QObject * o) const { if (!o) return 0; - while (!qobject_cast(o) && o) + while (!qobject_cast(o) && o) o = o->parent(); - return qobject_cast(o); + return qobject_cast(o); } @@ -124,7 +131,7 @@ void GDockWidget::removeX() { int ind = a->data().toInt(); if (ind < 0 || ind >= x_list.size_s()) return; x_list.remove(ind); - graphic->removeGraphic(ind); + graphic->graphic->removeGraphic(ind); } @@ -165,7 +172,22 @@ void CDGraphics::addGraphic() { void CDGraphics::receivedX() { - + PIMap > data; + X.lock(); + PIVector > x_list = X.enabledList(); + PIVector ch; + piForeachC (PIDeque & p, x_list) { + CDType & t(X[p]); + if (t.xmode() == CDType::X_Current) + ch.resize(1, t.toDouble()); + else + ch = t.history; + t.history.clear(); + data[CDCore::pathToString(t.path())] = ch; + } + X.unlock(); + foreach (GDockWidget * d, docks) + d->drawX(data); } @@ -184,7 +206,7 @@ void CDGraphics::on_buttonAdd_clicked() { void CDGraphics::on_buttonClear_clicked() { foreach (GDockWidget * d, docks) - d->graphic->clear(); + d->graphic->graphic->clear(); } diff --git a/qcd_utils/pult/cdgraphics.h b/qcd_utils/pult/cdgraphics.h index 3bbde11..c0dbdaf 100644 --- a/qcd_utils/pult/cdgraphics.h +++ b/qcd_utils/pult/cdgraphics.h @@ -5,6 +5,7 @@ #include #include #include "ui_cdgraphics.h" +#include "cdgraphic.h" #include namespace CDUtils { @@ -24,13 +25,14 @@ public: GDockWidget(QString title = QString(), QMainWindow * p = 0); void addX(const CDUtils::CDType & t); + void drawX(const PIMap > & data); - Graphic * graphic; + CDGraphicWidget * graphic; private: bool eventFilter(QObject * o, QEvent * e); void contextMenuEvent(QContextMenuEvent * e); - Graphic * viewportGraphic(QObject * o) const; + CDGraphicWidget * viewportGraphic(QObject * o) const; QMenu * menu, * menu_x; QList dactions; diff --git a/qcd_utils/qcd_model.cpp b/qcd_utils/qcd_model.cpp index 86a66ed..dca3ae4 100644 --- a/qcd_utils/qcd_model.cpp +++ b/qcd_utils/qcd_model.cpp @@ -87,7 +87,7 @@ QVariant CDItem::data(int column, int role) const { } -QVariant CDItem::value(CDType t, int role) const { +QVariant CDItem::value(CDType & t, int role) const { if (t.type() == "f") return t.toDouble(); if (t.type() == "n") return t.toInt(); if (t.type() == "b") return t.toBool(); diff --git a/qcd_utils/qcd_model.h b/qcd_utils/qcd_model.h index f5e28c5..9325df8 100644 --- a/qcd_utils/qcd_model.h +++ b/qcd_utils/qcd_model.h @@ -39,7 +39,7 @@ public: CDItem(CDUtils::Interface * interface, int _index, CDItemType type, CDItem * parent); ~CDItem(); QVariant data(int column, int role) const; - QVariant value(CDUtils::CDType t, int role) const; + QVariant value(CDUtils::CDType & t, int role) const; bool setData(int column, const QVariant & value); CDItemType itemType() const {return type_;} PIDeque buildPath() const; diff --git a/qcd_utils/qcd_view.cpp b/qcd_utils/qcd_view.cpp index 5c99b86..6a06422 100644 --- a/qcd_utils/qcd_view.cpp +++ b/qcd_utils/qcd_view.cpp @@ -300,6 +300,7 @@ void CDView::cd_receivedX() { //piCout << t.path(); if (t.cd_type() != CDType::cdX) continue; update(model_->indexByPath(t.path(), cValue)); + //qDebug() << "val" << model_->data(model_->indexByPath(t.path(), cValue), Qt::DisplayRole).toDouble(); } X.unlock(); emit receivedX();