本文整理汇总了C++中Marker::plot方法的典型用法代码示例。如果您正苦于以下问题:C++ Marker::plot方法的具体用法?C++ Marker::plot怎么用?C++ Marker::plot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Marker
的用法示例。
在下文中一共展示了Marker::plot方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
int
MarkerTLine::highLow (PluginData *pd)
{
if (! pd->data)
return 0;
Marker *tline = (Marker *) pd->data;
Entity *e = tline->settings();
PlotDateScaleDraw *dsd = (PlotDateScaleDraw *) tline->plot()->axisScaleDraw(QwtPlot::xBottom);
if (! dsd)
return 1;
QVariant *date = e->get(QString("date"));
if (! date)
return 0;
QVariant *date2 = e->get(QString("date2"));
if (! date2)
return 0;
QVariant *price = e->get(QString("price"));
if (! price)
return 0;
QVariant *price2 = e->get(QString("price2"));
if (! price2)
return 0;
int x = dsd->dateToX(date->toDateTime());
if (x >= pd->start && x <= pd->end)
{
pd->high = price->toDouble();
double t = price2->toDouble();
if (t > pd->high)
pd->high = t;
pd->low = price->toDouble();
if (t < pd->low)
pd->low = t;
return 1;
}
int x2 = dsd->dateToX(date2->toDateTime());
if (x2 >= pd->start && x2 <= pd->end)
{
pd->high = price->toDouble();
double t = price2->toDouble();
if (t > pd->high)
pd->high = t;
pd->low = price->toDouble();
if (t < pd->low)
pd->low = t;
return 1;
}
return 1;
}
示例2: switch
int
MarkerSell::move (PluginData *pd)
{
if (! pd->data)
return 0;
Marker *sell = (Marker *) pd->data;
switch (pd->status)
{
case PlotStatus::_MOVE:
{
Entity *e = sell->settings();
QVariant *price = e->get(QString("price"));
if (! price)
return 0;
QVariant *date = e->get(QString("date"));
if (! date)
return 0;
QwtScaleMap map = sell->plot()->canvasMap(QwtPlot::xBottom);
int x = map.invTransform((double) pd->point.x());
if (! g_symbol)
return 0;
Bar *tbar = g_symbol->bar(x);
if (! tbar)
return 0;
date->setValue(tbar->date());
map = sell->plot()->canvasMap(QwtPlot::yRight);
price->setValue(map.invTransform((double) pd->point.y()));
sell->setModified(TRUE);
sell->plot()->replot();
break;
}
default:
break;
}
return 1;
}
示例3: color
int
MarkerSell::draw (QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRect &, void *m)
{
Marker *sell = (Marker *) m;
Entity *e = sell->settings();
PlotDateScaleDraw *dsd = (PlotDateScaleDraw *) sell->plot()->axisScaleDraw(QwtPlot::xBottom);
QVariant *date = e->get(QString("date"));
if (! date)
{
qDebug() << "MarkerSell::draw: date missing";
return 0;
}
int x = xMap.transform(dsd->dateToX(date->toDateTime()));
if (x == -1)
return 1;
QVariant *price = e->get(QString("price"));
if (! price)
{
qDebug() << "MarkerSell::draw: price missing";
return 0;
}
int y = yMap.transform(price->toDouble());
QVariant *tset = e->get(QString("color"));
if (! tset)
{
qDebug() << "MarkerSell::draw: color missing";
return 0;
}
QColor color(tset->toString());
p->setBrush(color);
QPolygon arrow;
arrow.putPoints(0, 7, x, y,
x + 5, y - 5,
x + 2, y - 5,
x + 2, y - 11,
x - 2, y - 11,
x - 2, y - 5,
x - 5, y - 5);
p->drawPolygon(arrow, Qt::OddEvenFill);
sell->clearSelectionArea();
sell->appendSelectionArea(QRegion(arrow));
int handleWidth = sell->handleWidth();
if (sell->selected())
{
sell->clearGrabHandles();
sell->appendGrabHandle(QRegion(x - (handleWidth / 2),
y - handleWidth,
handleWidth,
handleWidth,
QRegion::Rectangle));
p->fillRect(x - (handleWidth / 2),
y + (handleWidth / 2),
handleWidth,
handleWidth,
color);
}
return 1;
}
示例4: color
int
MarkerRetracement::draw (QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRect &, void *m)
{
Marker *ret = (Marker *) m;
Entity *e = ret->settings();
QVariant *date = e->get(QString("date"));
if (! date)
return 0;
QVariant *date2 = e->get(QString("date2"));
if (! date2)
return 0;
QVariant *high = e->get(QString("high"));
if (! high)
return 0;
QVariant *low = e->get(QString("low"));
if (! low)
return 0;
QVariant *tset = e->get(QString("color"));
if (! tset)
return 0;
QColor color(tset->toString());
QVariant *extend = e->get(QString("extend"));
if (! extend)
return 0;
QVariant *l1 = e->get(QString("level1"));
if (! l1)
return 0;
QVariant *l2 = e->get(QString("level2"));
if (! l2)
return 0;
QVariant *l3 = e->get(QString("level3"));
if (! l3)
return 0;
QVariant *l4 = e->get(QString("level4"));
if (! l4)
return 0;
QVariant *l5 = e->get(QString("level5"));
if (! l5)
return 0;
QVariant *l6 = e->get(QString("level6"));
if (! l6)
return 0;
PlotDateScaleDraw *dsd = (PlotDateScaleDraw *) ret->plot()->axisScaleDraw(QwtPlot::xBottom);
int x = xMap.transform(dsd->dateToX(date->toDateTime()));
QDateTime dt = date2->toDateTime();
if (extend->toBool())
{
int s, e;
g_symbol->startEndRange(s, e);
Bar *bar = g_symbol->bar(e);
if (! bar)
return 0;
dt = bar->date();
}
int x2 = xMap.transform(dsd->dateToX(dt));
p->setPen(color);
ret->clearSelectionArea();
QList<double> lineList;
lineList.append(l1->toDouble());
lineList.append(l2->toDouble());
lineList.append(l3->toDouble());
lineList.append(l4->toDouble());
lineList.append(l5->toDouble());
lineList.append(l6->toDouble());
for (int loop = 0; loop < lineList.size(); loop++)
{
double td = lineList.at(loop);
if (td != 0)
{
double range = high->toDouble() - low->toDouble();
double r = 0;
if (td < 0)
r = low->toDouble() + (range * td);
else
{
if (td > 0)
r = low->toDouble() + (range * td);
else
{
if (td < 0)
//.........这里部分代码省略.........
示例5: signalMessage
int
MarkerRetracement::click (PluginData *pd)
{
if (! pd->data)
return 0;
Marker *m = (Marker *) pd->data;
switch (pd->status)
{
case PlotStatus::_SELECTED:
{
switch (pd->button)
{
case Qt::LeftButton:
{
int grab = m->isGrabSelected(pd->point);
if (grab)
{
pd->status = PlotStatus::_MOVE;
if (grab == 2)
pd->status = PlotStatus::_MOVE2;
return 1;
}
if (! m->isSelected(pd->point))
{
pd->status = PlotStatus::_NONE;
m->setSelected(FALSE);
Plot *tplot = (Plot *) m->plot();
tplot->unselectMarker();
m->plot()->replot();
return 1;
}
break;
}
case Qt::RightButton:
{
Plot *p = (Plot *) m->plot();
p->showMarkerMenu();
break;
}
default:
break;
}
break;
}
case PlotStatus::_MOVE:
case PlotStatus::_CREATE_MOVE:
{
switch (pd->button)
{
case Qt::LeftButton:
if (pd->status == PlotStatus::_CREATE_MOVE)
{
pd->status = PlotStatus::_MOVE2;
emit signalMessage(tr("Select lowest ending point..."));
return 1;
}
pd->status = PlotStatus::_SELECTED;
return 1;
default:
break;
}
break;
}
case PlotStatus::_MOVE2:
{
switch (pd->button)
{
case Qt::LeftButton:
pd->status = PlotStatus::_SELECTED;
return 1;
default:
break;
}
break;
}
default: // _None
{
switch (pd->button)
{
case Qt::LeftButton:
{
if (m->isSelected(pd->point))
{
pd->status = PlotStatus::_SELECTED;
m->setSelected(TRUE);
Plot *tplot = (Plot *) m->plot();
tplot->selectMarker(m->ID());
m->plot()->replot();
return 1;
}
//.........这里部分代码省略.........
示例6: switch
int
MarkerRetracement::move (PluginData *pd)
{
if (! pd->data)
return 0;
Marker *m = (Marker *) pd->data;
Entity *e = m->settings();
switch (pd->status)
{
case PlotStatus::_MOVE:
case PlotStatus::_CREATE_MOVE:
{
QVariant *date = e->get(QString("date"));
if (! date)
return 0;
QVariant *date2 = e->get(QString("date2"));
if (! date2)
return 0;
QVariant *high = e->get(QString("high"));
if (! high)
return 0;
QVariant *low = e->get(QString("low"));
if (! low)
return 0;
QwtScaleMap map = m->plot()->canvasMap(QwtPlot::xBottom);
int x = map.invTransform((double) pd->point.x());
Bar *bar = g_symbol->bar(x);
if (! bar)
return 0;
date->setValue(bar->date());
map = m->plot()->canvasMap(QwtPlot::yRight);
high->setValue(map.invTransform((double) pd->point.y()));
if (pd->status == PlotStatus::_CREATE_MOVE)
{
date2->setValue(bar->date());
low->setValue(high->toDouble());
}
m->plot()->replot();
m->setModified(TRUE);
break;
}
case PlotStatus::_MOVE2:
{
QVariant *date2 = e->get(QString("date2"));
if (! date2)
return 0;
QVariant *low = e->get(QString("low"));
if (! low)
return 0;
QwtScaleMap map = m->plot()->canvasMap(QwtPlot::xBottom);
int x = map.invTransform((double) pd->point.x());
Bar *bar = g_symbol->bar(x);
if (! bar)
return 0;
date2->setValue(bar->date());
map = m->plot()->canvasMap(QwtPlot::yRight);
low->setValue(map.invTransform((double) pd->point.y()));
m->plot()->replot();
m->setModified(TRUE);
break;
}
default:
break;
}
return 1;
}
示例7: color
int
MarkerTLine::draw (QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRect &, void *m)
{
Marker *tline = (Marker *) m;
Entity *e = tline->settings();
QVariant *date = e->get(QString("date"));
if (! date)
return 0;
QVariant *date2 = e->get(QString("date2"));
if (! date2)
return 0;
QVariant *price = e->get(QString("price"));
if (! price)
return 0;
QVariant *price2 = e->get(QString("price2"));
if (! price2)
return 0;
QVariant *tset = e->get(QString("color"));
if (! tset)
return 0;
QColor color(tset->toString());
QVariant *extend = e->get(QString("extend"));
if (! extend)
return 0;
PlotDateScaleDraw *dsd = (PlotDateScaleDraw *) tline->plot()->axisScaleDraw(QwtPlot::xBottom);
int x = xMap.transform(dsd->dateToX(date->toDateTime()));
int x2 = xMap.transform(dsd->dateToX(date2->toDateTime()));
int y = yMap.transform(price->toDouble());
int y2 = yMap.transform(price2->toDouble());
p->setPen(color);
p->drawLine (x, y, x2, y2);
// save old values;
int tx2 = x2;
int ty2 = y2;
int tx = x;
int ty = y;
if (extend->toBool())
{
int ydiff = y - y2;
int xdiff = x2 - x;
if (xdiff > 0)
{
while (x2 < p->window().width())
{
x = x2;
y = y2;
x2 = x2 + xdiff;
y2 = y2 - ydiff;
p->drawLine (x, y, x2, y2);
}
}
}
// store the selectable area the line occupies
tline->clearSelectionArea();
QPolygon array;
array.putPoints(0, 4, tx, ty - 4, tx, ty + 4, x2, y2 + 4, x2, y2 - 4);
tline->appendSelectionArea(QRegion(array));
if (tline->selected())
{
int handleWidth = tline->handleWidth();
tline->clearGrabHandles();
tline->appendGrabHandle(QRegion(tx,
ty - (handleWidth / 2),
handleWidth,
handleWidth,
QRegion::Rectangle));
p->fillRect(tx,
ty - (handleWidth / 2),
handleWidth,
handleWidth,
color);
tline->appendGrabHandle(QRegion(tx2,
ty2 - (handleWidth / 2),
handleWidth,
handleWidth,
QRegion::Rectangle));
p->fillRect(tx2,
ty2 - (handleWidth / 2),
handleWidth,
handleWidth,
//.........这里部分代码省略.........
示例8: switch
int
MarkerTLine::move (PluginData *pd)
{
if (! pd->data)
return 0;
Marker *tline = (Marker *) pd->data;
Entity *e = tline->settings();
switch (pd->status)
{
case PlotStatus::_MOVE:
case PlotStatus::_CREATE_MOVE:
{
QVariant *price = e->get(QString("price"));
if (! price)
return 0;
QVariant *date = e->get(QString("date"));
if (! date)
return 0;
QVariant *price2 = e->get(QString("price2"));
if (! price2)
return 0;
QVariant *date2 = e->get(QString("date2"));
if (! date2)
return 0;
QwtScaleMap map = tline->plot()->canvasMap(QwtPlot::xBottom);
int x = map.invTransform((double) pd->point.x());
Bar *bar = g_symbol->bar(x);
if (! bar)
return 0;
date->setValue(bar->date());
map = tline->plot()->canvasMap(QwtPlot::yRight);
price->setValue(map.invTransform((double) pd->point.y()));
if (pd->status == PlotStatus::_CREATE_MOVE)
{
date2->setValue(bar->date());
price2->setValue(price->toDouble());
}
tline->plot()->replot();
tline->setModified(TRUE);
break;
}
case PlotStatus::_MOVE2:
{
QVariant *price2 = e->get(QString("price2"));
if (! price2)
return 0;
QVariant *date2 = e->get(QString("date2"));
if (! date2)
return 0;
QwtScaleMap map = tline->plot()->canvasMap(QwtPlot::xBottom);
int x = map.invTransform((double) pd->point.x());
Bar *bar = g_symbol->bar(x);
if (! bar)
return 0;
date2->setValue(bar->date());
map = tline->plot()->canvasMap(QwtPlot::yRight);
price2->setValue(map.invTransform((double) pd->point.y()));
tline->plot()->replot();
tline->setModified(TRUE);
break;
}
default:
break;
}
return 1;
}