git-svn-id: svn://db.shs.com.ru/libs@385 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -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<double> 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;
|
||||
}
|
||||
|
||||
@@ -64,6 +64,8 @@ public:
|
||||
void readX(PIByteArray & ba);
|
||||
void writeX(PIByteArray & ba);
|
||||
|
||||
PIVector<double> history;
|
||||
|
||||
protected:
|
||||
bool calculate(PIEvaluator * e, PIVector<const CDType * > stack = PIVector<const CDType * >());
|
||||
PIVariantTypes::Enum parseEnumComment(PIString c);
|
||||
@@ -77,7 +79,6 @@ protected:
|
||||
double value_d;
|
||||
int value_i;
|
||||
bool value_b, calculated, x_enabled;
|
||||
PIVector<double> history;
|
||||
PIVector<double> avg_h;
|
||||
int avg_size;
|
||||
XMode mode_;
|
||||
|
||||
13
qcd_utils/pult/cdgraphic.cpp
Normal file
13
qcd_utils/pult/cdgraphic.cpp
Normal file
@@ -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);
|
||||
}
|
||||
31
qcd_utils/pult/cdgraphic.h
Normal file
31
qcd_utils/pult/cdgraphic.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifndef CDGRAPHIC_H
|
||||
#define CDGRAPHIC_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "ui_cdgraphic.h"
|
||||
#include <pistring.h>
|
||||
|
||||
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
|
||||
154
qcd_utils/pult/cdgraphic.ui
Normal file
154
qcd_utils/pult/cdgraphic.ui
Normal file
@@ -0,0 +1,154 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CDGraphicWidget</class>
|
||||
<widget class="QWidget" name="CDGraphicWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>470</width>
|
||||
<height>380</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>CD Pult</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="layoutMain">
|
||||
<item>
|
||||
<widget class="Graphic" name="graphic">
|
||||
<property name="buttons">
|
||||
<set>Graphic::Autofit|Graphic::BorderInputs|Graphic::Clear|Graphic::Configure|Graphic::CursorAxis|Graphic::Fullscreen|Graphic::Legend|Graphic::OnlyExpandY|Graphic::Pause|Graphic::Save</set>
|
||||
</property>
|
||||
<property name="borderInputsVisible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="statusVisible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="historySize">
|
||||
<double>100.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widgetConfig" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>History:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="EvalSpinBox" name="evalHistory">
|
||||
<property name="value">
|
||||
<double>100.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>1</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Visible:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="EvalSpinBox" name="evalVisible">
|
||||
<property name="value">
|
||||
<double>-1.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>1</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Graphic</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>graphic.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>EvalSpinBox</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>evalspinbox.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>evalHistory</sender>
|
||||
<signal>valueChanged(double)</signal>
|
||||
<receiver>graphic</receiver>
|
||||
<slot>setHistorySize(double)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>148</x>
|
||||
<y>363</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>156</x>
|
||||
<y>297</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>evalVisible</sender>
|
||||
<signal>valueChanged(double)</signal>
|
||||
<receiver>graphic</receiver>
|
||||
<slot>setMaxVisibleTime(double)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>345</x>
|
||||
<y>361</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>342</x>
|
||||
<y>337</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
@@ -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<int> 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<PIString, PIVector<double> > & data) {
|
||||
for (int i = 0; i < x_list.size_s(); ++i) {
|
||||
PIString sp = CDCore::pathToString(x_list[i]);
|
||||
const PIVector<double> & 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<Graphic*>(o) && o)
|
||||
while (!qobject_cast<CDGraphicWidget*>(o) && o)
|
||||
o = o->parent();
|
||||
return qobject_cast<Graphic*>(o);
|
||||
return qobject_cast<CDGraphicWidget*>(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<PIString, PIVector<double> > data;
|
||||
X.lock();
|
||||
PIVector<PIDeque<int> > x_list = X.enabledList();
|
||||
PIVector<double> ch;
|
||||
piForeachC (PIDeque<int> & 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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <QDockWidget>
|
||||
#include <QMenu>
|
||||
#include "ui_cdgraphics.h"
|
||||
#include "cdgraphic.h"
|
||||
#include <pistring.h>
|
||||
|
||||
namespace CDUtils {
|
||||
@@ -24,13 +25,14 @@ public:
|
||||
GDockWidget(QString title = QString(), QMainWindow * p = 0);
|
||||
|
||||
void addX(const CDUtils::CDType & t);
|
||||
void drawX(const PIMap<PIString, PIVector<double> > & 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<QAction*> dactions;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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<int> buildPath() const;
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user