本文整理汇总了C++中Marker::handleWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ Marker::handleWidth方法的具体用法?C++ Marker::handleWidth怎么用?C++ Marker::handleWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Marker
的用法示例。
在下文中一共展示了Marker::handleWidth方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: color
//.........这里部分代码省略.........
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)
r = high->toDouble();
else
r = low->toDouble();
}
}
int y = yMap.transform(r);
p->drawLine (x, y, x2, y);
p->drawText(x, y - 1, QString::number(td * 100) + "% - " + QString::number(r));
QPolygon array;
array.putPoints(0, 4, x, y - 4, x, y + 4, x2, y + 4, x2, y - 4);
ret->appendSelectionArea(QRegion(array));
}
}
// draw the low line
int y = yMap.transform(low->toDouble());
p->drawLine (x, y, x2, y);
Strip strip;
QString ts;
strip.strip(low->toDouble(), 4, ts);
p->drawText(x, y - 1, "0% - " + ts);
// store the selectable area the low line occupies
QPolygon array;
array.putPoints(0, 4, x, y - 4, x, y + 4, x2, y + 4, x2, y - 4);
ret->appendSelectionArea(QRegion(array));
// draw the high line
int y2 = yMap.transform(high->toDouble());
p->drawLine (x, y2, x2, y2);
strip.strip(high->toDouble(), 4, ts);
p->drawText(x, y2 - 1, "100% - " + ts);
// store the selectable area the high line occupies
array.clear();
array.putPoints(0, 4, x, y2 - 4, x, y2 + 4, x2, y2 + 4, x2, y2 - 4);
ret->appendSelectionArea(QRegion(array));
if (ret->selected())
{
int handleWidth = ret->handleWidth();
ret->clearGrabHandles();
//top left corner
ret->appendGrabHandle(QRegion(x, y2 - (handleWidth / 2),
handleWidth,
handleWidth,
QRegion::Rectangle));
p->fillRect(x,
y2 - (handleWidth / 2),
handleWidth,
handleWidth,
color);
//bottom right corner
ret->appendGrabHandle(QRegion(x2, y - (handleWidth / 2),
handleWidth,
handleWidth,
QRegion::Rectangle));
p->fillRect(x2,
y - (handleWidth / 2),
handleWidth,
handleWidth,
color);
}
return 1;
}
示例2: 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;
}
示例3: 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,
//.........这里部分代码省略.........