Skip to content

Commit 8aedfd3

Browse files
committed
Labelling - Store Annotation position (3D renderer)
1 parent 3dcd259 commit 8aedfd3

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

modules/Labelling/iAAnnotationTool.cpp

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,9 @@ std::vector<iAAnnotation> const& iAAnnotationTool::annotations() const
434434
namespace
435435
{
436436
const QString PrjAnnotation("Annotation%1");
437+
const QString PrjAnnPos("Annotation%1Position");
437438
const QString FieldSeparator("|");
439+
const QString ArraySeparator(",");
438440
const int NumFields = 5;
439441
QString toString(iAAnnotation const& a)
440442
{
@@ -496,6 +498,13 @@ void iAAnnotationTool::loadState(QSettings& projectFile, QString const& fileName
496498
{
497499
auto a = fromString(projectFile.value(PrjAnnotation.arg(annIdx), "").toString());
498500
addAnnotation(a);
501+
auto aPos = projectFile.value(PrjAnnPos.arg(annIdx), "").toString();
502+
if (!aPos.isEmpty()) {
503+
auto pos = stringToVector<std::vector<double>, double>(aPos, ArraySeparator);
504+
dynamic_cast<vtkCaptionRepresentation*>(
505+
m_ui->m_vtkAnnotateData[a.m_id].m_caption3D->GetRepresentation())
506+
->SetPosition(pos.data());
507+
}
499508
++annIdx;
500509
}
501510
m_nextID = annIdx;
@@ -510,10 +519,15 @@ void iAAnnotationTool::saveState(QSettings& projectFile, QString const& fileName
510519
{
511520
Q_UNUSED(fileName);
512521
auto const& annList = annotations();
513-
size_t annIdx = 0;
514-
for (auto const& a : annList)
522+
for (size_t a = 0; a<annList.size(); a++)
515523
{
516-
projectFile.setValue(PrjAnnotation.arg(annIdx++), toString(a));
524+
auto const& annotation = annList[a];
525+
auto & vtkData = m_ui->m_vtkAnnotateData.at(annotation.m_id);
526+
projectFile.setValue(PrjAnnPos.arg(a),
527+
arrayToString<double>(
528+
dynamic_cast<vtkCaptionRepresentation*>(vtkData.m_caption3D->GetRepresentation())->GetPosition(), 2,
529+
ArraySeparator));
530+
projectFile.setValue(PrjAnnotation.arg(a), toString(annotation));
517531
}
518532
}
519533

0 commit comments

Comments
 (0)