Skip to content

Commit 5deed78

Browse files
committed
[chore] Modify data type of poly in label data
Note: - From QPolygon to QPolygonF
1 parent a8406bb commit 5deed78

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

AutoAnnotationTool/datasaver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ void DataSaver::LoadData(int mode)
171171
labelCollector()->appendData(tmpRect, label);
172172
}
173173
else if(shapeType == "polygon"){
174-
QPolygon tmpPoly;
174+
QPolygonF tmpPoly;
175175
for (const auto& point : pointArray) {
176176
QJsonArray pointArray = point.toArray();
177177
QPointF polyPoint(pointArray[0].toDouble() / labelCollector()->getFactorScaled(),

AutoAnnotationTool/labelcollector.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ void LabelCollector::paint(QPainter *painter){
5858

5959
// Draw result point
6060
painter->setPen(m_penVec.at(2));
61-
QVector<QPoint>::iterator pointIter;
61+
QVector<QPointF>::iterator pointIter;
6262
int dataIdx = std::distance(m_dataVec.begin(),iter);
6363
for(pointIter=(*iter)->poly.begin();pointIter!=(*iter)->poly.end();pointIter++){
6464
int pointIdx = std::distance((*iter)->poly.begin(),pointIter);
@@ -261,7 +261,7 @@ void LabelCollector::mouseMoveEvent(QMouseEvent *event)
261261
m_lastPoint = event->localPos();
262262
PosBoundaryCheck(m_lastPoint);
263263
if(polySelectResult.isSelect){
264-
m_dataVec.at(polySelectResult.boxIdx)->poly.setPoint(polySelectResult.polyIdx, m_lastPoint.toPoint());
264+
m_dataVec.at(polySelectResult.boxIdx)->poly[polySelectResult.polyIdx] = m_lastPoint;
265265
}
266266
else if(!polySelectResult.isSelect && rectCornerSelectResult.isSelect){
267267
switch (rectCornerSelectResult.corner){
@@ -442,8 +442,8 @@ void LabelCollector::GetPolygonSelectResult(QPointF currentPos)
442442
PolygonSelectResult res;
443443
QVector<LabelData*>::iterator it;
444444
for(it=m_dataVec.begin(); it!=m_dataVec.end(); it++){
445-
QPolygon checkedPoly = ((*it)->poly);
446-
QPolygon::iterator polyIter;
445+
QPolygonF checkedPoly = ((*it)->poly);
446+
QPolygonF::iterator polyIter;
447447
for(polyIter = checkedPoly.begin(); polyIter != checkedPoly.end(); polyIter++){
448448
if(DistanceBetween2Point(*polyIter,currentPos) < thresDistance){
449449
polySelectResult.boxIdx = std::distance(m_dataVec.begin(), it);
@@ -574,15 +574,15 @@ void LabelCollector::appendData(QRectF rect, QString labelClass)
574574
emit postItemAppended();
575575
}
576576

577-
void LabelCollector::appendData(QPolygon poly, QString labelClass)
577+
void LabelCollector::appendData(QPolygonF poly, QString labelClass)
578578
{
579579
emit preItemAppended();
580580
LabelData *tmp = new LabelData(poly, labelClass);
581581
m_dataVec.push_back(tmp);
582582
emit postItemAppended();
583583
}
584584

585-
void LabelCollector::appendData(QRectF rect, QPolygon poly, QString labelClass)
585+
void LabelCollector::appendData(QRectF rect, QPolygonF poly, QString labelClass)
586586
{
587587
emit preItemAppended();
588588
LabelData *tmp = new LabelData(rect, poly, labelClass);

AutoAnnotationTool/labelcollector.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ public slots:
6666
public slots:
6767
void appendData(QRectF rect);
6868
void appendData(QRectF rect, QString labelClass);
69-
void appendData(QPolygon poly, QString labelClass);
70-
void appendData(QRectF rect, QPolygon poly, QString labelClass);
69+
void appendData(QPolygonF poly, QString labelClass);
70+
void appendData(QRectF rect, QPolygonF poly, QString labelClass);
7171

7272
void setFileIdx(int fileIdx);
7373

AutoAnnotationTool/labeldata.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ struct LabelData{
1212
labelClass(""), rect(m_rect), penIdx(0), isSelect(false){}
1313
LabelData(const QRectF &m_rect, const QString m_labelClass):
1414
labelClass(m_labelClass), rect(m_rect), penIdx(0), isSelect(false){}
15-
LabelData(const QPolygon &m_poly, const QString m_labelClass):
15+
LabelData(const QPolygonF &m_poly, const QString m_labelClass):
1616
labelClass(m_labelClass), poly(m_poly), penIdx(0), isSelect(false){}
17-
LabelData(const QRectF &m_rect, const QPolygon &m_poly, const QString m_labelClass):
17+
LabelData(const QRectF &m_rect, const QPolygonF &m_poly, const QString m_labelClass):
1818
labelClass(m_labelClass), rect(m_rect), poly(m_poly), penIdx(0), isSelect(false){}
1919
LabelData(const LabelData &e)
2020
{
2121
labelClass = e.labelClass;
2222
penIdx = e.penIdx;
2323
rect = e.rect;
2424
isSelect = e.isSelect;
25-
poly = QPolygon(e.poly);
25+
poly = QPolygonF(e.poly);
2626
}
2727
~LabelData()
2828
{
@@ -31,7 +31,7 @@ struct LabelData{
3131
int penIdx; //0: normal, 1:highlight
3232
bool isSelect;
3333
QRectF rect;
34-
QPolygon poly; // record scaled point show in GUI
34+
QPolygonF poly; // record scaled point show in GUI
3535
};
3636

3737
#endif // LABELDATA_H

0 commit comments

Comments
 (0)