本文整理汇总了C++中KoPathShape::snapData方法的典型用法代码示例。如果您正苦于以下问题:C++ KoPathShape::snapData方法的具体用法?C++ KoPathShape::snapData怎么用?C++ KoPathShape::snapData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KoPathShape
的用法示例。
在下文中一共展示了KoPathShape::snapData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testExtensionSnap
void TestSnapStrategy::testExtensionSnap()
{
//bool ExtensionSnapStrategy::snap(const QPointF &mousePosition, KoSnapProxy * proxy, qreal maxSnapDistance)
ExtensionSnapStrategy toTest;
const QPointF paramMousePos;
MockShapeController fakeShapeControllerBase;
MockCanvas fakeKoCanvasBase(&fakeShapeControllerBase);
KoSnapGuide aKoSnapGuide(&fakeKoCanvasBase);
KoSnapProxy paramProxy(&aKoSnapGuide);
qreal paramSnapDistance = 0;
bool didSnap = toTest.snap(paramMousePos, ¶mProxy, paramSnapDistance);
QVERIFY(!didSnap);
//Second test case - testing the snap by providing ShapeManager with a shape that has snap points and a path
//fakeShapeOne needs at least one subpath that is open in order to change the values of minDistances
//which in turn opens the path where it is possible to get a true bool value back from the snap function
// KoPathPointIndex openSubpath(const KoPathPointIndex &pointIndex); in KoPathShape needs to be called
ExtensionSnapStrategy toTestTwo;
const QPointF paramMousePosTwo;
MockShapeController fakeShapeControllerBaseTwo;
MockCanvas fakeKoCanvasBaseTwo(&fakeShapeControllerBaseTwo);
KoShapeManager *fakeShapeManager = fakeKoCanvasBaseTwo.shapeManager();
KoPathShape fakeShapeOne;
QList<QPointF> firstSnapPointList;
firstSnapPointList.push_back(QPointF(1,2));
firstSnapPointList.push_back(QPointF(2,2));
firstSnapPointList.push_back(QPointF(3,2));
firstSnapPointList.push_back(QPointF(4,2));
qreal paramSnapDistanceTwo = 4;
fakeShapeOne.snapData().setSnapPoints(firstSnapPointList);
fakeShapeOne.isVisible(true);
QPointF firstPoint(0,2);
QPointF secondPoint(1,2);
QPointF thirdPoint(2,3);
QPointF fourthPoint(3,4);
fakeShapeOne.moveTo(firstPoint);
fakeShapeOne.lineTo(secondPoint);
fakeShapeOne.lineTo(thirdPoint);
fakeShapeOne.lineTo(fourthPoint);
fakeShapeManager->addShape(&fakeShapeOne);
KoSnapGuide aKoSnapGuideTwo(&fakeKoCanvasBaseTwo);
KoSnapProxy paramProxyTwo(&aKoSnapGuideTwo);
bool didSnapTwo = toTest.snap(paramMousePosTwo, ¶mProxyTwo, paramSnapDistanceTwo);
QVERIFY(didSnapTwo);
}
示例2: testExtensionDecoration
void TestSnapStrategy::testExtensionDecoration()
{
//Tests the decoration is exercised by providing it with path
//fakeShapeOne needs at least one subpath that is open in order to change the values of minDistances
//which in turn opens the path where it is possible to get a true bool value back from the snap function
// KoPathPointIndex openSubpath(const KoPathPointIndex &pointIndex); in KoPathShape needs to be called
ExtensionSnapStrategy toTestTwo;
const QPointF paramMousePosTwo;
MockShapeController fakeShapeControllerBaseTwo;
MockCanvas fakeKoCanvasBaseTwo(&fakeShapeControllerBaseTwo);
KoShapeManager *fakeShapeManager = fakeKoCanvasBaseTwo.shapeManager();
KoPathShape fakeShapeOne;
QList<QPointF> firstSnapPointList;
firstSnapPointList.push_back(QPointF(1,2));
firstSnapPointList.push_back(QPointF(2,2));
firstSnapPointList.push_back(QPointF(3,2));
firstSnapPointList.push_back(QPointF(4,2));
qreal paramSnapDistanceTwo = 4;
fakeShapeOne.snapData().setSnapPoints(firstSnapPointList);
fakeShapeOne.isVisible(true);
QPointF firstPoint(0,2);
QPointF secondPoint(1,2);
QPointF thirdPoint(2,3);
QPointF fourthPoint(3,4);
fakeShapeOne.moveTo(firstPoint);
fakeShapeOne.lineTo(secondPoint);
fakeShapeOne.lineTo(thirdPoint);
fakeShapeOne.lineTo(fourthPoint);
fakeShapeManager->addShape(&fakeShapeOne);
KoSnapGuide aKoSnapGuideTwo(&fakeKoCanvasBaseTwo);
KoSnapProxy paramProxyTwo(&aKoSnapGuideTwo);
toTestTwo.snap(paramMousePosTwo, ¶mProxyTwo, paramSnapDistanceTwo);
const KoViewConverter aConverter;
QPainterPath resultingDecoration = toTestTwo.decoration(aConverter);
QPointF resultDecorationLastPoint = resultingDecoration.currentPosition();
QVERIFY( resultDecorationLastPoint == QPointF(0,2) );
}