| 127 | } |
| 128 | |
| 129 | void PolyQtAnnotation::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, |
| 130 | QWidget *widget) { |
| 131 | if (_annotation) { |
| 132 | QColor lineColor = this->getDrawingColor(); |
| 133 | QColor fillColor = this->getDrawingColor(); |
| 134 | fillColor.setAlphaF(0.3); |
| 135 | _currentLoD = option->levelOfDetailFromTransform(painter->worldTransform()); |
| 136 | std::vector<Point> coords = _annotation->getCoordinates(); |
| 137 | if (coords.size() > 1) { |
| 138 | if (isSelected()) { |
| 139 | painter->setPen(QPen(QBrush(lineColor.lighter(150)), _lineAnnotationSelectedThickness / _currentLoD)); |
| 140 | } |
| 141 | else { |
| 142 | painter->setPen(QPen(QBrush(lineColor), _lineThickness / _currentLoD)); |
| 143 | } |
| 144 | if (_type == "spline") { |
| 145 | painter->drawPolyline(_polys); |
| 146 | if (_fill) { |
| 147 | QPainterPath path; |
| 148 | path.addPolygon(_polys); |
| 149 | painter->fillPath(path, QBrush(fillColor)); |
| 150 | } |
| 151 | } |
| 152 | else { |
| 153 | painter->drawPath(_currentPath); |
| 154 | if (_fill) { |
| 155 | painter->fillPath(_currentPath, QBrush(fillColor)); |
| 156 | } |
| 157 | } |
| 158 | } |
| 159 | if (isSelected()) { |
| 160 | if (QtAnnotation::annotationColorForRects) { |
| 161 | painter->setPen(QPen(QBrush(lineColor.lighter(150)), 3 * _lineThickness / _currentLoD, Qt::PenStyle::SolidLine, Qt::PenCapStyle::SquareCap)); |
| 162 | } |
| 163 | else { |
| 164 | painter->setPen(QPen(QBrush(_rectColor.lighter(150)), 3 * _lineThickness / _currentLoD, Qt::PenStyle::SolidLine, Qt::PenCapStyle::SquareCap)); |
| 165 | } |
| 166 | } |
| 167 | else { |
| 168 | if (QtAnnotation::annotationColorForRects) { |
| 169 | painter->setPen(QPen(QBrush(lineColor), 3 * _lineThickness / _currentLoD, Qt::PenStyle::SolidLine, Qt::PenCapStyle::SquareCap)); |
| 170 | } else { |
| 171 | painter->setPen(QPen(QBrush(_rectColor), 3 * _lineThickness / _currentLoD, Qt::PenStyle::SolidLine, Qt::PenCapStyle::SquareCap)); |
| 172 | } |
| 173 | } |
| 174 | for (unsigned int i = 0; i < coords.size(); ++i) { |
| 175 | if (i == _activeSeedPoint) { |
| 176 | painter->save(); |
| 177 | painter->setPen(QPen(QBrush(_rectSelectedColor), 3 * _lineAnnotationSelectedThickness / _currentLoD, Qt::PenStyle::SolidLine, Qt::PenCapStyle::SquareCap)); |
| 178 | painter->drawPoint(this->mapFromScene(coords[i].getX()*_scale, coords[i].getY()*_scale)); |
| 179 | painter->restore(); |
| 180 | } |
| 181 | else { |
| 182 | painter->drawPoint(this->mapFromScene(coords[i].getX()*_scale, coords[i].getY()*_scale)); |
| 183 | } |
| 184 | } |
| 185 | } |
| 186 | } |
nothing calls this directly
no test coverage detected