Skip to content

Commit 3965647

Browse files
committed
Fix unit tests and add unit tests for path helper
1 parent 11da16d commit 3965647

14 files changed

+140
-23
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,7 @@ perf.data*
6767

6868
# clion
6969
*.idea
70-
*.idea/
70+
*.idea/
71+
72+
# misc
73+
.directory

src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ set(KIMAGEANNOTATOR_SRCS
6161
${CMAKE_CURRENT_SOURCE_DIR}/annotations/items/helper/TextCursor.cpp
6262
${CMAKE_CURRENT_SOURCE_DIR}/annotations/items/helper/CapsLockStatusChecker.cpp
6363
${CMAKE_CURRENT_SOURCE_DIR}/annotations/items/helper/NumberRectHelper.cpp
64-
${CMAKE_CURRENT_SOURCE_DIR}/annotations/items/helper/ShapeHelper.cpp
64+
${CMAKE_CURRENT_SOURCE_DIR}/annotations/items/helper/AnnotationShapeCreator.cpp
6565
${CMAKE_CURRENT_SOURCE_DIR}/annotations/undo/AddCommand.cpp
6666
${CMAKE_CURRENT_SOURCE_DIR}/annotations/undo/DeleteCommand.cpp
6767
${CMAKE_CURRENT_SOURCE_DIR}/annotations/undo/MoveCommand.cpp

src/annotations/items/AnnotationArrow.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ void AnnotationArrow::updateShape()
4040
QLineF shaft(*mLine);
4141
shaft.setLength(shaft.length() - 5);
4242

43-
auto arrow = ShapeHelper::createArrowHead(properties()->width() / 2);
44-
arrow = ShapeHelper::translate(arrow, mLine->p2(), -mLine->angle());
43+
auto arrow = AnnotationShapeCreator::createArrowHead(properties()->width() / 2);
44+
arrow = AnnotationShapeCreator::translate(arrow, mLine->p2(), -mLine->angle());
4545

4646
QPainterPath path(shaft.p1());
4747
path.lineTo(shaft.p2());

src/annotations/items/AnnotationArrow.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#define KIMAGEANNOTATOR_ANNOTATIONARROW_H
2222

2323
#include "src/annotations/items/AbstractAnnotationLine.h"
24-
#include "src/annotations/items/helper/ShapeHelper.h"
24+
#include "src/annotations/items/helper/AnnotationShapeCreator.h"
2525

2626
namespace kImageAnnotator {
2727

src/annotations/items/AnnotationDoubleArrow.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ void AnnotationDoubleArrow::updateShape()
4343
shaft.setPoints(shaft.p2(), shaft.p1());
4444
shaft.setLength(shaft.length() - 5);
4545

46-
auto arrow = ShapeHelper::createArrowHead(properties()->width() / 2);
47-
auto startArrowHead = ShapeHelper::translate(arrow, mLine->p2(), -mLine->angle());
48-
auto endArrowHead = ShapeHelper::translate(arrow, mLine->p1(), -mLine->angle() + 180);
46+
auto arrow = AnnotationShapeCreator::createArrowHead(properties()->width() / 2);
47+
auto startArrowHead = AnnotationShapeCreator::translate(arrow, mLine->p2(), -mLine->angle());
48+
auto endArrowHead = AnnotationShapeCreator::translate(arrow, mLine->p1(), -mLine->angle() + 180);
4949

5050
QPainterPath path(shaft.p1());
5151
path.lineTo(shaft.p2());

src/annotations/items/AnnotationNumberPointer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ void AnnotationNumberPointer::updateShape()
7676
mRect->moveCenter(mLine->p1());
7777
BaseAnnotationNumber::updateRect(mRect, textProperties()->font());
7878

79-
auto pointer = ShapeHelper::createPointer(mRect->width() * 0.7, mLine->length());
80-
auto finishedPointer = ShapeHelper::translate(pointer, mLine->p2(), -mLine->angle());
79+
auto pointer = AnnotationShapeCreator::createPointer(mRect->width() * 0.7, mLine->length());
80+
auto finishedPointer = AnnotationShapeCreator::translate(pointer, mLine->p2(), -mLine->angle());
8181

8282
QPainterPath path(mLine->p1());
8383
path.setFillRule(Qt::WindingFill);

src/annotations/items/AnnotationNumberPointer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
#include "src/annotations/items/AbstractAnnotationLine.h"
2424
#include "src/annotations/items/BaseAnnotationNumber.h"
25-
#include "src/annotations/items/helper/ShapeHelper.h"
25+
#include "src/annotations/items/helper/AnnotationShapeCreator.h"
2626
#include "src/annotations/properties/AnnotationTextProperties.h"
2727

2828
namespace kImageAnnotator {

src/annotations/items/helper/ShapeHelper.cpp renamed to src/annotations/items/helper/AnnotationShapeCreator.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
* Boston, MA 02110-1301, USA.
1818
*/
1919

20-
#include "ShapeHelper.h"
20+
#include "AnnotationShapeCreator.h"
2121

2222
namespace kImageAnnotator {
2323

24-
QPolygonF ShapeHelper::createPointer(qreal width, qreal length)
24+
QPolygonF AnnotationShapeCreator::createPointer(qreal width, qreal length)
2525
{
2626
QPointF p0(0, 0);
2727
QPointF p1(-length, width / 2);
@@ -31,7 +31,7 @@ QPolygonF ShapeHelper::createPointer(qreal width, qreal length)
3131
return pointer << p0 << p1 << p2 << p0;
3232
}
3333

34-
QPolygonF ShapeHelper::createArrowHead(int scaleFactor)
34+
QPolygonF AnnotationShapeCreator::createArrowHead(int scaleFactor)
3535
{
3636
auto arrowHeadLength = 15 + scaleFactor;
3737
auto arrowHeadWidth = 5 + scaleFactor;
@@ -46,7 +46,7 @@ QPolygonF ShapeHelper::createArrowHead(int scaleFactor)
4646
return arrow << p0 << p1 << p2 << p3 << p0;
4747
}
4848

49-
QPolygonF ShapeHelper::translate(const QPolygonF &shape, const QPointF &pos, qreal angle)
49+
QPolygonF AnnotationShapeCreator::translate(const QPolygonF &shape, const QPointF &pos, qreal angle)
5050
{
5151
return QTransform().translate(pos.x(), pos.y()).rotate(angle).map(shape);
5252
}

src/annotations/items/helper/ShapeHelper.h renamed to src/annotations/items/helper/AnnotationShapeCreator.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@
1717
* Boston, MA 02110-1301, USA.
1818
*/
1919

20-
#ifndef KIMAGEANNOTATOR_SHAPEHELPER_H
21-
#define KIMAGEANNOTATOR_SHAPEHELPER_H
20+
#ifndef KIMAGEANNOTATOR_ANNOTATIONSHAPECREATOR_H
21+
#define KIMAGEANNOTATOR_ANNOTATIONSHAPECREATOR_H
2222

2323
#include <QPolygonF>
2424
#include <QTransform>
2525

2626
namespace kImageAnnotator {
2727

28-
class ShapeHelper
28+
class AnnotationShapeCreator
2929
{
3030
public:
3131
static QPolygonF createPointer(qreal width, qreal length);
@@ -35,4 +35,4 @@ class ShapeHelper
3535

3636
} // namespace kImageAnnotator
3737

38-
#endif //KIMAGEANNOTATOR_SHAPEHELPER_H
38+
#endif //KIMAGEANNOTATOR_ANNOTATIONSHAPECREATOR_H

src/annotations/items/helper/NumberRectHelper.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
* Boston, MA 02110-1301, USA.
1818
*/
1919

20-
#ifndef NUMBERRECTHELPER_H
21-
#define NUMBERRECTHELPER_H
20+
#ifndef KIMAGEANNOTATOR_NUMBERRECTHELPER_H
21+
#define KIMAGEANNOTATOR_NUMBERRECTHELPER_H
2222

2323
#include <QString>
2424
#include <QSizeF>
@@ -41,4 +41,4 @@ class NumberRectHelper
4141

4242
} // namespace kImageAnnotator
4343

44-
#endif //NUMBERRECTHELPER_H
44+
#endif //KIMAGEANNOTATOR_NUMBERRECTHELPER_H

0 commit comments

Comments
 (0)