如何用颜色填充地图画布中的三角形? Qgis 3.3

时间:2018-10-30 09:59:28

标签: c++ qt qgis

我有3分(QPointF)和QgsRubberBand(PolygonGeometry),在其中我添加了这3分。结果如图所示

enter image description here

该三角形具有非常细的白线。我想用颜色填充三角形。我期望setFillColor()方法可以做到,但事实并非如此。我该怎么做才能用给定的颜色填充多边形?

橡皮筋在类构造函数中声明为:

  

cameraFOV =新的QgsRubberBand(mapCanvas,   QgsWkbTypes :: PolygonGeometry);

这是我用来显示三角形的代码:

void MapObject::setFovAngle(double angle){
    cameraFOV->reset();
    QPointF FOVLeftCorner = QPointF(mapOwnPosition.x() + 5000 * qSin(targetingDirection-angle/2), mapOwnPosition.y() + 5000 * qCos(targetingDirection-angle/2));
    QPointF FOVRightCorner = QPointF(mapOwnPosition.x() + 5000 * qSin(targetingDirection+angle/2), mapOwnPosition.y() + 5000 * qCos(targetingDirection+angle/2));
    cameraFOV->addPoint(mapOwnPosition);
    cameraFOV->addPoint(FOVLeftCorner);
    cameraFOV->addPoint(FOVRightCorner);
    cameraFOV->closePoints();
    cameraFOV->setColor(QColor(255,255,255, 128));
    cameraFOV->setFillColor(QColor(0,0,0, 128));
    cameraFOV->show();
}

我该怎么做才能用颜色填充三角形?

0 个答案:

没有答案