git-svn-id: svn://db.shs.com.ru/libs@385 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user