本文整理汇总了C++中Point2D::selected方法的典型用法代码示例。如果您正苦于以下问题:C++ Point2D::selected方法的具体用法?C++ Point2D::selected怎么用?C++ Point2D::selected使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Point2D
的用法示例。
在下文中一共展示了Point2D::selected方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mousePressEvent
void Viewport::mousePressEvent(QMouseEvent * event) {
int x = event->x();
int y = event->y();
Point2D * point = pointInPosition(x,y);
if(event->button() == Qt::LeftButton) { // Clic gauche
// Un point ne peut etre cree que s'il ne se superpose pas a un autre.
// De plus, si des points sont presents dans le viewport, il faut que le point actuellement selectionne soit le premier point de la
// trajectoire ou le dernier.
if(point == NULL && (selectedPoint == &(points.front()) || selectedPoint == &(points.back()) || selectedPoint == NULL)) {
if(selectedPoint == &(points.back())){
addPoint(x,y,END);
this->repaint();
enterTime(&(points.back()));
} else {
addPoint(x,y,BEGIN);
this->repaint();
enterTime(&(points.front()));
}
}
} else if(event->button() == Qt::RightButton) { // Clic droit
if(point != NULL && !point->selected())
selectNewPoint(point);
} else if(event->button() == Qt::MidButton) { // Clic du milieu
if(point != NULL && point->selected())
movingPoint = point;
}
this->repaint();
}
示例2: drawPoint
void ViewportPainter::drawPoint(Point2D & point) {
if(point.getTime() != "-1") {
QString text("t = " + point.getTime());
QRect rect(point.x()+TEXT_OFFSET_X, point.y()-TEXT_OFFSET_Y,10*text.length()+2*TEXT_MARGIN,15+2*TEXT_MARGIN);
this->setBrush(QColor(255, 255, 255, 255));
this->drawRect(rect);
this->drawText(rect,Qt::AlignHCenter|Qt::AlignVCenter,text);
}
if(point.selected())
this->setBrush(QColor(255, 0, 0, 255));
else
this->setBrush(QColor(255, 248, 133, 255));
this->drawEllipse(point.x()-POINT_SIZE/2,point.y()-POINT_SIZE/2,POINT_SIZE,POINT_SIZE);
}