28 setFlag( QGraphicsItem::ItemIsSelectable,
true );
98 return QSizeF( 0, 0 );
103 prepareGeometryChange();
104 double halfSymbolSize = 0.0;
114 mBoundingRect = QRectF( xMinPos, yMinPos, xMaxPos - xMinPos, yMaxPos - yMinPos );
129 QList<QLineF> segmentList;
133 double minEdgeDist = DBL_MAX;
134 int minEdgeIndex = -1;
139 for (
int i = 0; i < 4; ++i )
141 QLineF currentSegment = segmentList.at( i );
143 double currentMinDist = origin.
sqrDistToSegment( currentSegment.x1(), currentSegment.y1(), currentSegment.x2(), currentSegment.y2(), currentMinDistPoint );
144 if ( currentMinDist < minEdgeDist )
147 minEdgePoint = currentMinDistPoint;
148 minEdgeDist = currentMinDist;
149 minEdge = currentSegment;
153 if ( minEdgeIndex < 0 )
159 double segmentPointWidth = 10;
162 QPointF minEdgeEnd = minEdge.p2();
164 if ( sqrt( minEdgePoint.
sqrDist( minEdgeEnd.x(), minEdgeEnd.y() ) ) < segmentPointWidth )
177 p->setPen( framePen );
179 p->setBrush( frameBrush );
180 p->setRenderHint( QPainter::Antialiasing,
true );
183 for (
int i = 0; i < 4; ++i )
185 QLineF currentSegment =
segment( i );
186 poly << currentSegment.p1();
190 poly << QPointF( 0, 0 );
193 poly << currentSegment.p2();
195 p->drawPolygon( poly );
235 if ( data( 0 ).toString() ==
"composer" )
240 double handlerSize = 10;
241 p->setPen( Qt::NoPen );
242 p->setBrush( QColor( 200, 200, 210, 120 ) );
272 double dx = directionPoint.x() - startPoint.x();
273 double dy = directionPoint.y() - startPoint.y();
274 double length = sqrt( dx * dx + dy * dy );
275 double scaleFactor = distance / length;
276 return QPointF( startPoint.x() + dx * scaleFactor, startPoint.y() + dy * scaleFactor );
281 QPointF itemPos = mapFromScene( pos );
283 int cursorSensitivity = 7;
285 if ( qAbs( itemPos.x() ) < cursorSensitivity && qAbs( itemPos.y() ) < cursorSensitivity )
290 bool left, right, up, down;
300 else if ( right && up )
304 else if ( left && down )
308 else if ( right && down )
340 switch ( moveAction )
343 return Qt::ArrowCursor;
346 return Qt::SizeAllCursor;
349 return Qt::SizeVerCursor;
352 return Qt::SizeHorCursor;
355 return Qt::SizeFDiagCursor;
358 return Qt::SizeBDiagCursor;
360 return Qt::ArrowCursor;
376 double dpmm =
mMapCanvas->logicalDpiX() / 25.4;
382 if ( itemElem.isNull() )
386 QDomElement annotationElem = doc.createElement(
"AnnotationItem" );
392 annotationElem.setAttribute(
"frameWidth",
mFrameSize.width() );
393 annotationElem.setAttribute(
"frameHeight",
mFrameSize.height() );
394 QPointF canvasPos = pos();
395 annotationElem.setAttribute(
"canvasPosX", canvasPos.x() );
396 annotationElem.setAttribute(
"canvasPosY", canvasPos.y() );
398 annotationElem.setAttribute(
"frameColor",
mFrameColor.name() );
401 annotationElem.setAttribute(
"visible", isVisible() );
405 if ( !symbolElem.isNull() )
407 annotationElem.appendChild( symbolElem );
410 itemElem.appendChild( annotationElem );
415 if ( annotationElem.isNull() )
420 pos.setX( annotationElem.attribute(
"canvasPosX",
"0" ).toDouble() );
421 pos.setY( annotationElem.attribute(
"canvasPosY",
"0" ).toDouble() );
424 mapPos.
setX( annotationElem.attribute(
"mapPosX",
"0" ).toDouble() );
425 mapPos.
setY( annotationElem.attribute(
"mapPosY",
"0" ).toDouble() );
427 mFrameBorderWidth = annotationElem.attribute(
"frameBorderWidth",
"0.5" ).toDouble();
428 mFrameColor.setNamedColor( annotationElem.attribute(
"frameColor",
"#000000" ) );
430 mFrameBackgroundColor.setAlpha( annotationElem.attribute(
"frameBackgroundColorAlpha",
"255" ).toInt() );
431 mFrameSize.setWidth( annotationElem.attribute(
"frameWidth",
"50" ).toDouble() );
432 mFrameSize.setHeight( annotationElem.attribute(
"frameHeight",
"50" ).toDouble() );
436 setVisible( annotationElem.attribute(
"visible",
"1" ).toInt() );
439 QDomElement symbolElem = annotationElem.firstChildElement(
"symbol" );
440 if ( !symbolElem.isNull() )