WimaTrackerPolyline.h 2.18 KB
Newer Older
1
#pragma once
2

3 4 5
#include <QObject>
#include "WimaArea.h"
#include "QGCMapPolyline.h"
6

7 8

class WimaTrackerPolyline : public QGCMapPolyline
9
{
10
    Q_OBJECT
11
public:
12 13 14 15 16 17 18 19 20 21 22 23 24 25
    WimaTrackerPolyline(QObject *parent = nullptr);
    WimaTrackerPolyline(QGCMapPolyline *other, QObject *parent = nullptr);

    Q_PROPERTY(int                      startVertexIndex    READ startVertexIndex   WRITE setStartVertexIndex   NOTIFY startVertexIndexChanged)
    Q_PROPERTY(int                      endVertexIndex      READ endVertexIndex     WRITE setEndVertexIndex     NOTIFY endVertexIndexChanged)

    // Property accessors
    int                     startVertexIndex    (void) const { return _startVertexIndex;}
    int                     endVertexIndex      (void) const { return _endVertexIndex;}


    //Property setters
    Q_INVOKABLE  void       bindPolygon             (WimaArea* polygon);
    Q_INVOKABLE  void       unbindPolygon           ();
26
    Q_INVOKABLE  void       swapEndPoints           ();
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
    Q_INVOKABLE  void       setStartVertexIndex     (int PolygonVertexIndex);
    Q_INVOKABLE  void       setEndVertexIndex       (int PolygonVertexIndex);

    // Methodes
    // calls updateEndVertex() if VertexIndex == _endVertexIndex, calls updateStartVertex() if VertexIndex == _startVertexIndex, or
    // calls both if VertexIndex != _endVertexIndex && VertexIndex != _startVertexIndex
    Q_INVOKABLE  void       snapVertex            (int VertexIndex);
    // snaps the end vertex to the closest coordinate of _boundArea when called
                 void       snapEndVertex         ();
    // snaps the start vertex to the closest coordinate of _boundArea when called
                 void       snapStartVertex       ();





signals:
    void startVertexIndexChanged    (void);
    void endVertexIndexChanged      (void);

public slots:
    void recalcPolyline(void);

private:
    WimaArea*                   _boundArea;
    // this->vertexCoordinate(this->count()-1) and _boundArea->vertexCoordinate(_startVertexIndex) are linked
    int                         _startVertexIndex;
    // this->vertexCoordinate(0) and _boundArea->vertexCoordinate(_endVertexIndex) are linked
    int                         _endVertexIndex;

57 58
};