Commit d60a1318 authored by Valentin Platzgummer's avatar Valentin Platzgummer

changing class structure

parent c8170647
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.4
import QtQuick.Dialogs 1.2
import QtQuick.Extras 1.4
import QtQuick.Layouts 1.2
import QtQuick 2.0
import QGroundControl 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.Vehicle 1.0
import QGroundControl.Controls 1.0
import QGroundControl.FactControls 1.0
import QGroundControl.Palette 1.0
import QGroundControl.FlightMap 1.0
Item {
// Editor for Operating Area items
Rectangle {
id: _root
height: visible ? (editorColumn.height + (_margin * 2)) : 0
width: availableWidth
color: qgcPal.windowShadeDark
radius: _radius
// The following properties must be available up the hierarchy chain
//property real availableWidth ///< Width for control
//property var areaItem ///< Mission Item for editor
property real _margin: ScreenTools.defaultFontPixelWidth / 2
property real _fieldWidth: ScreenTools.defaultFontPixelWidth * 10.5
property var polyline: areaItem.polyline
property var operatingPolygon: areaItem.polygon
property bool initNecesarry: true
function editPolyline(){
polyline.setInteractive(true);
}
QGCPalette { id: qgcPal; colorGroupEnabled: true }
Column {
id: editorColumn
anchors.margins: _margin
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
spacing: _margin
SectionHeader {
id: scanHeader
text: qsTr("Settings")
}
Column {
anchors.left: parent.left
anchors.right: parent.right
spacing: _margin
visible: scanHeader.checked
GridLayout {
anchors.left: parent.left
anchors.right: parent.right
columnSpacing: _margin
rowSpacing: _margin
columns: 2
QGCLabel {
text: qsTr("Bottom Layer Altitude")
}
FactTextField {
fact: areaItem.bottomLayerAltitude
Layout.fillWidth: true
}
QGCLabel { text: qsTr("Number of Layers") }
FactTextField {
fact: areaItem.numberOfLayers
Layout.fillWidth: true
}
QGCLabel { text: qsTr("Layer Distance") }
FactTextField {
fact: areaItem.layerDistance
Layout.fillWidth: true
}
}
Item {
height: ScreenTools.defaultFontPixelHeight / 2
width: 1
}
} // Column - Scan
SectionHeader {
id: polylineHeader
text: qsTr("Gateway Poly Line")
}
QGCButton {
id: polylineEditor
anchors.topMargin: _margin / 2
anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 2
anchors.rightMargin: ScreenTools.defaultFontPixelWidth
text: "Edit Polyline"
onClicked: editPolyline()
}
SectionHeader {
id: statsHeader
text: qsTr("Statistics")
}
Grid {
columns: 2
columnSpacing: ScreenTools.defaultFontPixelWidth
visible: statsHeader.checked
/*QGCLabel { text: qsTr("Layers") }
QGCLabel { text: areaItem.layers.valueString }*/
}
} // Column
} // Rectangle
}
#include "WimaController.h"
#include "MissionController.h"
WimaController::WimaController(QObject *parent) :
QObject (parent)
,_planView (true)
,_visualItems (new QmlObjectListModel(parent))
{
connect(this, &WimaController::currentPolygonIndexChanged, this, &WimaController::recalcPolygonInteractivity);
}
void WimaController::setMasterController(PlanMasterController *masterC)
{
_masterController = masterC;
emit masterControllerChanged();
}
void WimaController::setMissionController(MissionController *missionC)
{
_missionController = missionC;
emit missionControllerChanged();
}
void WimaController::setCurrentPolygonIndex(int index)
{
if(index >= 0 && index < _visualItems->count() && index != _currentPolygonIndex){
_currentPolygonIndex = index;
emit currentPolygonIndexChanged(index);
}
}
void WimaController::addGlobalMeasurementArea()
{
WimaGlobalMeasurementPolygon* newPoly = new WimaGlobalMeasurementPolygon(this);
_visualItems->append(newPoly);
int newIndex = _visualItems->count()-1;
_currentPolygonIndex = newIndex;
emit currentPolygonIndexChanged(newIndex);
emit visualItemsChanged();
}
void WimaController::removeArea(int index)
{
if(index >= 0 && index < _visualItems->count()){
_visualItems->removeAt(index);
emit visualItemsChanged();
if(_currentPolygonIndex >= _visualItems->count()){
setCurrentPolygonIndex(_visualItems->count() - 1);
}else{
recalcPolygonInteractivity(_currentPolygonIndex);
}
}else{
qWarning("Index out of bounds!");
}
}
void WimaController::addServiceArea()
{
resetAllIsCurrentPolygon();
WimaServicePolygon* newPoly = new WimaServicePolygon(this);
newPoly->setInteractive(true);
_visualItems->append(newPoly);
emit visualItemsChanged();
}
void WimaController::startMission()
{
}
void WimaController::abortMission()
{
}
void WimaController::pauseMission()
{
}
void WimaController::resumeMission()
{
}
void WimaController::saveMission()
{
}
void WimaController::loadMission()
{
}
void WimaController::recalcVehicleCorridor()
{
}
void WimaController::recalcVehicleMeasurementAreas()
{
}
void WimaController::recalcAll()
{
}
void WimaController::recalcPolygonInteractivity(int index)
{
resetAllIsCurrentPolygon();
WimaPolygon* interactivePoly = qobject_cast<WimaPolygon*>(_visualItems->get(index));
interactivePoly->setInteractive(true);
}
void WimaController::resetAllIsCurrentPolygon()
{
int itemCount = _visualItems->count();
for (int i = 0; i < itemCount; i++) {
WimaPolygon* iteratorPoly = qobject_cast<WimaPolygon*>(_visualItems->get(i));
iteratorPoly->setInteractive(false);
}
}
#include "WimaGlobalMeasurementPolygon.h"
const char* WimaGlobalMeasurementPolygon::settingsGroup = "OperatingArea";
const char* WimaGlobalMeasurementPolygon::bottomLayerAltitudeName = "BottomLayerAltitude";
const char* WimaGlobalMeasurementPolygon::numberOfLayersName = "NumberOfLayers";
const char* WimaGlobalMeasurementPolygon::layerDistanceName = "LayerDistance";
WimaGlobalMeasurementPolygon::WimaGlobalMeasurementPolygon(QObject *parent)
: WimaPolygon (parent)
, _metaDataMap (FactMetaData::createMapFromJsonFile(QStringLiteral(":/json/WimaGlobalMeasurementPolygon.SettingsGroup.json"), this /* QObject parent */))
, _bottomLayerAltitude (settingsGroup, _metaDataMap[bottomLayerAltitudeName])
, _numberOfLayers (settingsGroup, _metaDataMap[numberOfLayersName])
, _layerDistance (settingsGroup, _metaDataMap[layerDistanceName])
, _vehicleList (new QmlObjectListModel(this))
, _vehiclePolygons (new QmlObjectListModel(this))
{
this->setObjectName("Operating Area");
_polyline.bindPolygon(this->polygon());
}
WimaGlobalMeasurementPolygon::WimaGlobalMeasurementPolygon(QGCMapPolygon *other, QObject *parent)
: WimaPolygon (other, parent)
, _metaDataMap (FactMetaData::createMapFromJsonFile(QStringLiteral(":/json/WimaGlobalMeasurementPolygon.SettingsGroup.json"), this /* QObject parent */))
, _bottomLayerAltitude (settingsGroup, _metaDataMap[bottomLayerAltitudeName])
, _numberOfLayers (settingsGroup, _metaDataMap[numberOfLayersName])
, _layerDistance (settingsGroup, _metaDataMap[layerDistanceName])
, _vehicleList (new QmlObjectListModel(this))
, _vehiclePolygons (new QmlObjectListModel(this))
{
this->setObjectName("Operating Area");
_polyline.bindPolygon(this->polygon());
}
void WimaGlobalMeasurementPolygon::addVehicle(Vehicle *vehicle)
{
if(vehicle != nullptr){
_vehicleList->append(vehicle);
emit vehicleListChanged();
}
}
void WimaGlobalMeasurementPolygon::removeVehicle(int vehicleIndex)
{
if(vehicleIndex >= 0 && vehicleIndex < _vehicleList->count()){
_vehicleList->removeAt(vehicleIndex);
emit vehicleListChanged();
}
}
void WimaGlobalMeasurementPolygon::recalculatesubPolygons()
{
int vehicleCount = _vehicleList->count();
QScopedPointer<QList<QGCMapPolygon*>> listQGCPoly(this->splitPolygonArea(vehicleCount));
int polyCount = listQGCPoly->size();
_vehiclePolygons->clear();
for(int i = 0; i < polyCount; i++){
WimaVehicleMeasurementPolygon* subPoly = new WimaVehicleMeasurementPolygon(listQGCPoly->takeAt(i), this);
_vehiclePolygons->append(subPoly);
}
}
void WimaGlobalMeasurementPolygon::removeAllVehicles()
{
int count = _vehicleList->count();
if(count > 0){
do{
_vehicleList->removeAt(0);
count--;
}while(count > 0);
emit vehicleListChanged();
}
}
void WimaGlobalMeasurementPolygon::addVehiclePolygon()
{
_vehiclePolygons->append(new WimaVehicleMeasurementPolygon(this));
emit vehiclePolygonsChanged();
}
void WimaGlobalMeasurementPolygon::removeVehiclePolygon(int polygonIndex)
{
if(polygonIndex >= 0 && polygonIndex < _vehiclePolygons->count()){
_vehiclePolygons->removeAt(polygonIndex);
emit vehiclePolygonsChanged();
}else {
qWarning("Index out of bounds!");
}
}
void WimaGlobalMeasurementPolygon::removeVehiclePolygon(WimaVehicleMeasurementPolygon *wimaPolygon)
{
if(wimaPolygon != nullptr){
QObject* removedPolygon = _vehiclePolygons->removeOne(wimaPolygon);
if(removedPolygon){
emit vehiclePolygonsChanged();
}else {
qWarning("Polygon not inside polygon list.");
}
}else {
qWarning("Not a valid Polygon.");
}
}
#pragma once
#include <QObject>
#include "Vehicle.h"
class WimaServicePolygon;
class WimaVehicleCorridor;
class WimaVehicleMeasurementPolygon;
class WimaVehicle : public QObject
{
Q_OBJECT
public:
WimaVehicle(QObject* parent);
Vehicle* vehicle (void) const { return _vehicle;}
WimaServicePolygon* servicePolygon (void) const { return _servicePolygon;}
WimaVehicleCorridor* vehicleCorridor (void) const { return _vehicleCorridor;}
WimaVehicleMeasurementPolygon* measurementPolygon (void) const { return _measurementPolygon;}
void setVehicle (Vehicle* vehicle);
void setServicePolygon (WimaServicePolygon* servicePolygon);
void setVehicleCorridor (WimaVehicleCorridor* vehicleCorridor);
void setMeasurementPolygon (WimaVehicleMeasurementPolygon* measurementPolygon);
private:
Vehicle* _vehicle;
WimaServicePolygon* _servicePolygon;
WimaVehicleCorridor* _vehicleCorridor;
WimaVehicleMeasurementPolygon* _measurementPolygon;
};
#include "WimaArea.h"
WimaArea::WimaArea()
{
}
#ifndef WIMAAREA_H
#define WIMAAREA_H
class WimaArea
{
public:
WimaArea();
};
#endif // WIMAAREA_H
\ No newline at end of file
#include "WimaController.h"
WimaController::WimaController(QObject *parent) : QObject(parent)
{
}
#ifndef WIMACONTROLLER_H
#define WIMACONTROLLER_H
#include <QObject>
class WimaController : public QObject
{
Q_OBJECT
public:
explicit WimaController(QObject *parent = nullptr);
signals:
public slots:
};
#endif // WIMACONTROLLER_H
\ No newline at end of file
#include "WimaGOperationArea.h"
WimaGOperationArea::WimaGOperationArea()
{
}
#ifndef WIMAGOPERATIONAREA_H
#define WIMAGOPERATIONAREA_H
class WimaGOperationArea
{
public:
WimaGOperationArea();
};
#endif // WIMAGOPERATIONAREA_H
\ No newline at end of file
#include "WimaServiceArea.h"
WimaServiceArea::WimaServiceArea()
{
}
#ifndef WIMASERVICEAREA_H
#define WIMASERVICEAREA_H
class WimaServiceArea
{
public:
WimaServiceArea();
};
#endif // WIMASERVICEAREA_H
\ No newline at end of file
#include "WimaTrackerPolyline.h"
WimaTrackerPolyline::WimaTrackerPolyline()
{
}
#ifndef WIMATRACKERPOLYLINE_H
#define WIMATRACKERPOLYLINE_H
class WimaTrackerPolyline
{
public:
WimaTrackerPolyline();
};
#endif // WIMATRACKERPOLYLINE_H
\ No newline at end of file
#include "WimaVCorridor.h"
WimaVCorridor::WimaVCorridor()
{
}
#ifndef WIMAVCORRIDOR_H
#define WIMAVCORRIDOR_H
class WimaVCorridor
{
public:
WimaVCorridor();
};
#endif // WIMAVCORRIDOR_H
\ No newline at end of file
#include "WimaVehicle.h"
WimaVehicle::WimaVehicle()
{
}
#ifndef WIMAVEHICLE_H
#define WIMAVEHICLE_H
class WimaVehicle
{
public:
WimaVehicle();
};
#endif // WIMAVEHICLE_H
\ No newline at end of file
#include "WimaGlobalMeasurementPolygonEditor.h"
WimaGlobalMeasurementPolygonEditor::WimaGlobalMeasurementPolygonEditor(QObject *parent)
: QAbstractItemModel(parent)
{
}
QVariant WimaGlobalMeasurementPolygonEditor::headerData(int section, Qt::Orientation orientation, int role) const
{
// FIXME: Implement me!
}
QModelIndex WimaGlobalMeasurementPolygonEditor::index(int row, int column, const QModelIndex &parent) const
{
// FIXME: Implement me!
}
QModelIndex WimaGlobalMeasurementPolygonEditor::parent(const QModelIndex &index) const
{
// FIXME: Implement me!
}
int WimaGlobalMeasurementPolygonEditor::rowCount(const QModelIndex &parent) const
{
if (!parent.isValid())
return 0;
// FIXME: Implement me!
}
int WimaGlobalMeasurementPolygonEditor::columnCount(const QModelIndex &parent) const
{
if (!parent.isValid())
return 0;
// FIXME: Implement me!
}
QVariant WimaGlobalMeasurementPolygonEditor::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
// FIXME: Implement me!
return QVariant();
}
#ifndef WIMAGLOBALMEASUREMENTPOLYGONEDITOR_H
#define WIMAGLOBALMEASUREMENTPOLYGONEDITOR_H
#include <QAbstractItemModel>
class WimaGlobalMeasurementPolygonEditor : public QAbstractItemModel
{
Q_OBJECT
public:
explicit WimaGlobalMeasurementPolygonEditor(QObject *parent = nullptr);
// Header:
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
// Basic functionality:
QModelIndex index(int row, int column,
const QModelIndex &parent = QModelIndex()) const override;
QModelIndex parent(const QModelIndex &index) const override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
private:
};
#endif // WIMAGLOBALMEASUREMENTPOLYGONEDITOR_H
\ No newline at end of file
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtLocation 5.3
import QtPositioning 5.3
import QGroundControl 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.Palette 1.0
import QGroundControl.Controls 1.0
import QGroundControl.FlightMap 1.0
/// Wima Global Measurement Area visuals
Item {
id: _root
property var map ///< Map control to place item in
property var qgcView ///< QGCView to use for popping dialogs
property var areaItem: object
property var _polygon: areaItem.polygon
property var subPolylines: areaItem.subPolylines
property var subPolygons: areaItem.subPolygons
signal clicked(int sequenceNumber)
/// Add an initial 4 sided polygon if there is none
function _addInitialPolygon() {
if (_polygon.count < 3) {
// Initial polygon is inset to take 2/3rds space
var rect = Qt.rect(map.centerViewport.x, map.centerViewport.y, map.centerViewport.width, map.centerViewport.height)
rect.x += (rect.width * 0.25) / 2
rect.y += (rect.height * 0.25) / 2
rect.width *= 0.75
rect.height *= 0.75
var centerCoord = map.toCoordinate(Qt.point(rect.x + (rect.width / 2), rect.y + (rect.height / 2)), false /* clipToViewPort */)
var topLeftCoord = map.toCoordinate(Qt.point(rect.x, rect.y), false /* clipToViewPort */)
var topRightCoord = map.toCoordinate(Qt.point(rect.x + rect.width, rect.y), false /* clipToViewPort */)
var bottomLeftCoord = map.toCoordinate(Qt.point(rect.x, rect.y + rect.height), false /* clipToViewPort */)
var bottomRightCoord = map.toCoordinate(Qt.point(rect.x + rect.width, rect.y + rect.height), false /* clipToViewPort */)
// Adjust polygon to max size
var maxSize = 100
var halfWidthMeters = Math.min(topLeftCoord.distanceTo(topRightCoord), maxSize) / 2
var halfHeightMeters = Math.min(topLeftCoord.distanceTo(bottomLeftCoord), maxSize) / 2
topLeftCoord = centerCoord.atDistanceAndAzimuth(halfWidthMeters, -90).atDistanceAndAzimuth(halfHeightMeters, 0)
topRightCoord = centerCoord.atDistanceAndAzimuth(halfWidthMeters, 90).atDistanceAndAzimuth(halfHeightMeters, 0)
bottomLeftCoord = centerCoord.atDistanceAndAzimuth(halfWidthMeters, -90).atDistanceAndAzimuth(halfHeightMeters, 180)
bottomRightCoord = centerCoord.atDistanceAndAzimuth(halfWidthMeters, 90).atDistanceAndAzimuth(halfHeightMeters, 180)
_polygon.appendVertex(topLeftCoord)
_polygon.appendVertex(topRightCoord)
_polygon.appendVertex(bottomRightCoord)
_polygon.appendVertex(bottomLeftCoord)
}
}
function _addInitialPolyline() {
if (subPolylines.count < 1) {
areaItem.addSubPolyline()
console.log("SubPolylines count: ", subPolylines.count)
var newPolyline = subPolylines.get(0)
newPolyline.appendVertex(_polygon.vertexCoordinate(0))
newPolyline.appendVertex(_polygon.vertexCoordinate(1))
}
}
Component.onCompleted: {
_addInitialPolygon()
_addInitialPolyline()// always call _addInitialPolyline() after _addInitialPolygon()
}
Component.onDestruction: {
}
QGCMapPolygonVisuals {
qgcView: _root.qgcView
mapControl: map
mapPolygon: _polygon
borderWidth: 1
borderColor: "black"
interiorColor: "green"
interiorOpacity: 0.25
}
Repeater {
model: subPolylines
delegate: QGCMapPolylineVisuals {
qgcView: _root.qgcView
mapControl: map
mapPolyline: object
lineWidth: 4
lineColor: interactive ? "yellow" : "white"
}
}
}
import QtQuick 2.0
Item {
}
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtLocation 5.3
import QtPositioning 5.3
import QGroundControl 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.Palette 1.0
import QGroundControl.Controls 1.0
import QGroundControl.FlightMap 1.0
/// Wima Global Measurement Area visuals
Item {
id: _root
property var map ///< Map control to place item in
property var qgcView ///< QGCView to use for popping dialogs
property var _missionItem: object
property var _polygon: object.polygon
signal clicked(int sequenceNumber)
/// Add an initial 4 sided polygon if there is none
function _addInitialPolygon() {
if (_polygon.count < 3) {
// Initial polygon is inset to take 2/3rds space
var rect = Qt.rect(map.centerViewport.x, map.centerViewport.y, map.centerViewport.width, map.centerViewport.height)
rect.x += (rect.width * 0.25) / 2
rect.y += (rect.height * 0.25) / 2
rect.width *= 0.25
rect.height *= 0.25
var centerCoord = map.toCoordinate(Qt.point(rect.x + (rect.width / 2), rect.y + (rect.height / 2)), false /* clipToViewPort */)
var topLeftCoord = map.toCoordinate(Qt.point(rect.x, rect.y), false /* clipToViewPort */)
var topRightCoord = map.toCoordinate(Qt.point(rect.x + rect.width, rect.y), false /* clipToViewPort */)
var bottomLeftCoord = map.toCoordinate(Qt.point(rect.x, rect.y + rect.height), false /* clipToViewPort */)
var bottomRightCoord = map.toCoordinate(Qt.point(rect.x + rect.width, rect.y + rect.height), false /* clipToViewPort */)
// Adjust polygon to max size
var maxSize = 100
var halfWidthMeters = Math.min(topLeftCoord.distanceTo(topRightCoord), maxSize) / 2
var halfHeightMeters = Math.min(topLeftCoord.distanceTo(bottomLeftCoord), maxSize) / 2
topLeftCoord = centerCoord.atDistanceAndAzimuth(halfWidthMeters, -90).atDistanceAndAzimuth(halfHeightMeters, 0)
topRightCoord = centerCoord.atDistanceAndAzimuth(halfWidthMeters, 90).atDistanceAndAzimuth(halfHeightMeters, 0)
bottomLeftCoord = centerCoord.atDistanceAndAzimuth(halfWidthMeters, -90).atDistanceAndAzimuth(halfHeightMeters, 180)
bottomRightCoord = centerCoord.atDistanceAndAzimuth(halfWidthMeters, 90).atDistanceAndAzimuth(halfHeightMeters, 180)
_polygon.appendVertex(topLeftCoord)
_polygon.appendVertex(topRightCoord)
_polygon.appendVertex(bottomRightCoord)
_polygon.appendVertex(bottomLeftCoord)
}
}
Component.onCompleted: {
_addInitialPolygon()
}
Component.onDestruction: {
}
QGCMapPolygonVisuals {
qgcView: _root.qgcView
mapControl: map
mapPolygon: _polygon
interactive: _missionItem.isCurrentPolygon
borderWidth: 1
borderColor: "black"
interiorColor: "yellow"
interiorOpacity: 0.25
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment