Files
qt-migration-legatus/qt6-after/qt6-migrated-legatus/Lts/Viewer/SituationMap/FunctionDialog/function_dialog.cpp
T
torstenandCopilot 124fbb4de8 Fix Qt6 deprecated APIs: QCheckBox::checkStateChanged, ExploratoryLocationViewshed
- Replace QCheckBox::stateChanged with checkStateChanged in:
  - lts_dialog.cpp
  - simple_esri_layer.cpp (2 occurrences)
  - layer_control_widget.cpp
  - symbol_dialog.cpp
- Replace LocationViewshed with ExploratoryLocationViewshed (ArcGIS SDK v300):
  - viewshed_analysis.h/.cpp
  - ViewshedLocation.h/.cpp
  - function_dialog.cpp (include)
- Update ViewshedLocation member variable type to ExploratoryLocationViewshed

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-10-13 14:41:33 +02:00

8907 lines
315 KiB
C++
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* @RDE_HEADER@
* FunctionDialog
* $Id$
* $HeadURL$
* $Author$
*/
// Own
#include "function_dialog.h"
#include "simple_esri_layer.h"
#include <Map/map_notifier.h>
#include <Map/location_display.h>
#include <Map/measurement.h>
#include <Map/viewshed.h>
#include <Map/coord_translation_functor.h>
#include <MapImpl/layer_control_widget.h>
#include <MapImpl/map_impl.h>
#include <MapImpl/layer_factory_impl.h>
#include <MapImpl/grid_impl.h>
#include <MapImpl/coordinate_translation.h>
#include <MapImpl/layer_factory_impl.h>
#include <Map/situation_map_utils.h>
#include <Symbology/symbol_dictionary.h>
#include <Symbology/symbol_properties.h>
#include <Symbology/sidc_codec.h>
#include <SymbologyGui/base_symbol_lookup_dialog.h>
#include <Symbology/sidc_builder_base.h>
#include <Map/object_factory.h>
#include <Map/bounding_box.h>
#include <Map/overview_map_handler.h>
#include <Map/object_indicator.h>
#include <Map/viewshed.h>
#include <Map/sight_fan.h>
#include <MathUtils/math_const.h>
#include <MathUtils/geometry_engine.h>
#include <Map/overlay_handler.h>
#include <MapObjects/map_object_indicator.h>
#include <MapObjects/polygon.h>
#include <MapObjects/polyline.h>
#include <MapObjects/text.h>
#include <MapObjects/geometry.h>
#include <MapObjects/participant.h>
#include <MapObjects/area_fire.h>
#include <MapObjects/building_outline.h>
#include <MapObjects/biological_agent.h>
#include <MapObjects/chemical_agent.h>
#include <MapObjects/cube.h>
#include <MapObjects/danger_area.h>
#include <MapObjects/functional_area.h>
#include <MapObjects/geo_image.h>
#include <MapObjects/hit_line.h>
#include <MapObjects/line_of_sight.h>
#include <MapObjects/mine.h>
#include <MapObjects/mine_field.h>
#include <MapObjects/nuclear_agent.h>
#include <MapObjects/single_fire.h>
#include <MapObjects/sound_area.h>
#include <MathUtils/simple_helper.h>
#include <Rubberbands/rubberband_factory.h>
#include <SituationMap/Common/resource_path.h>
// Portal
#include <Portal/portal.h>
#include <LtsCoordTrans/lts_coord_trans.h>
#include <LtsWidgets/lts_drag_icon.h>
#include <assert.h>
// RME LocalServer
#ifdef USE_LOCAL_SERVER
# include <LocalSrv/local_server.h>
#endif // USE_LOCAL_SERVER
// ESRI
#include <Map.h>
//#include <ArcGISRuntime.h>
#include <Envelope.h>
#include <MapGraphicsView.h>
#include <SceneGraphicsView.h>
//#include <CoordinateConversion.h>
#include <GraphicsOverlay.h>
#include <TextSymbol.h>
#include <SimpleMarkerSymbol.h>
#include <SimpleFillSymbol.h>
#include <PictureMarkerSymbol.h>
#include <Point.h>
#include <PolylineBuilder.h>
#include <PolygonBuilder.h>
//#include <MultiPath.h>
#include <GeometryEngine.h>
#include <SimpleRenderer.h>
#include <UniqueValueRenderer.h>
#include <Raster.h>
#include <RasterLayer.h>
#include <AnalysisOverlay.h>
#include <ExploratoryLocationViewshed.h>
// 3D
#include <SimpleMarkerSceneSymbol.h>
#include <ModelSceneSymbol.h>
// Qt
#include <QCoreApplication>
#include <utility>
#include <QDir>
#include <QTimer>
#include <QDialog>
#include <QFormLayout>
#include <QGridLayout>
#include <QLabel>
#include <QPushButton>
#include <QCheckBox>
#include <QTabWidget>
#include <QMessageBox>
#include <QLineEdit>
#include <QComboBox>
#include <QPainter>
#include <QProgressDialog>
#include <QTreeView>
#include <QDial>
#include <QRect>
#include <QMap>
#include <QGraphicsProxyWidget>
#include <QThread>
#include <QFileDialog>
#include <QElapsedTimer>
#include <iostream>
void appendQPointF(SituationMap::PositionCont &posCont, const QPointF &point)
{
posCont.append(SituationMap::Point3D::fromQPointF(point));
}
void drawEllipse(Esri::ArcGISRuntime::GraphicsOverlay *graphicsLayer,
const Esri::ArcGISRuntime::Point &mapPoint,
const double &semiAxis1Length,
const double &semiAxis2Length,
const double &maxSegmentLength,
const QColor &color)
{
Esri::ArcGISRuntime::GeodesicEllipseParameters ePara;
ePara.setGeometryType(Esri::ArcGISRuntime::GeometryType::Polygon);
// 1
ePara.setMaxSegmentLength(maxSegmentLength);
// 2
Esri::ArcGISRuntime::Point normalizedPt =
Esri::ArcGISRuntime::GeometryEngine::normalizeCentralMeridian(mapPoint);
ePara.setCenter(normalizedPt);
// 3, 4
ePara.setSemiAxis1Length(semiAxis1Length);
ePara.setSemiAxis2Length(semiAxis2Length);
// 5
ePara.setAxisDirection(/*axisDirection*/90);
// Unit???????
Esri::ArcGISRuntime::Geometry ellipseGeometry = Esri::ArcGISRuntime::GeometryEngine::ellipseGeodesic(ePara);
if (ellipseGeometry.isEmpty())
qWarning() << " There was an error computing the geodesic ellipse. Try a different segment length.";
else
{
Esri::ArcGISRuntime::Polygon polygon(ellipseGeometry);
QColor fillColor = color;
fillColor.setAlpha(150);
Esri::ArcGISRuntime::Graphic *ellipseGraphic = new Esri::ArcGISRuntime::Graphic();
ellipseGraphic->setGeometry(polygon);
Esri::ArcGISRuntime::SimpleFillSymbol ellipseSymbol(Esri::ArcGISRuntime::SimpleFillSymbolStyle::Solid, fillColor);
ellipseGraphic->setSymbol(&ellipseSymbol);
graphicsLayer->graphics()->append(ellipseGraphic);
// for (int count = 0; count < ellipse.pointCount(); count++)
// {
// EsriRuntimeQt::Graphic *pointGraphic =
// new EsriRuntimeQt::Graphic(ellipse.point(count), EsriRuntimeQt::SimpleMarkerSymbol(color, 3));
// graphicsLayer->graphics()->append(pointGraphic);
// }
}
}
namespace SituationMap
{
static LtsCoordTrans::UtmCoordinate s_basePoint;
static OperatorMapSettings & s_operatorMapSettings()
{
static OperatorMapSettings operatorMapSettings;
return operatorMapSettings;
}
class FunctionDialog::Private
{
public:
static QHash<Map *, FunctionDialog *> s_activeFunctionDialogMap;
static void cleanupActiveFunctionDialogMap()
{
s_activeFunctionDialogMap.clear();
}
Private() = default;
~Private() = default;
// ESRI data:
Esri::ArcGISRuntime::Map *m_esriMap = nullptr;
Esri::ArcGISRuntime::GeoView *m_mapGeoView = nullptr;
Esri::ArcGISRuntime::GraphicsOverlay *m_graphicsLayer = nullptr;
Esri::ArcGISRuntime::GraphicsOverlay *m_graphicsLayerDict = nullptr;
// OWN data:
RenderingMode m_renderMode = RenderingMode::Dynamic;
SituationMap::Map *m_mapInterface = nullptr;
SituationMap::MapImpl *m_mapImpl = nullptr;
QLabel *m_lbMapPosition = nullptr;
QLabel *m_lbPixelSize = nullptr;
QPushButton *m_pbDump = nullptr;
QPushButton *m_pbGrid = nullptr;
QPushButton *m_pbVisibility = nullptr;
QPushButton *m_pbVisibilityTechn = nullptr;
QPushButton *m_pbVisibilityTact = nullptr;
QPushButton *m_pbSelected = nullptr;
QPushButton *m_pbPicking = nullptr;
QList<UniqueMapId> m_objectsWithBoundingBox;
QPushButton *m_pbBoundingBox = nullptr;
QPushButton *m_pbBB2 = nullptr;
QPushButton *m_pbPickByArea = nullptr;
QDial *m_dialMapRotation = nullptr;
float getMapRotation()
{
float rotationAngle = 1.0;
if (m_dialMapRotation)
rotationAngle = m_dialMapRotation->value();
return rotationAngle;
}
QSlider *m_slSymbolSize = nullptr;
float getScale()
{
float scale = 1.0f;
if (m_slSymbolSize)
scale = m_slSymbolSize->value() / 100.0f;
return scale;
}
QSlider *m_slSymbolOpacity = nullptr;
float getSymbolOpacity()
{
float opac = 1.0f;
if (m_slSymbolOpacity)
opac = m_slSymbolOpacity->value() / 100.0f;
return opac;
}
QSlider *m_slDrawOrder = nullptr;
int getDrawOrder()
{
int drawOrder = 1;
if (m_slDrawOrder)
drawOrder = m_slDrawOrder->value();
return drawOrder;
}
QPushButton *m_pbOverviewMap = nullptr;
QPushButton *m_pbBackupOms = nullptr;
QPushButton *m_pbRestoreOms = nullptr;
QPushButton *m_pbRemove = nullptr;
QPushButton *m_pbRemoveAll = nullptr;
QPushButton *m_pbClose = nullptr;
QTabWidget *m_tabwidget = nullptr;
SimpleEsriLayer *m_simpleEsriLayer = nullptr;
int m_simpleEsriLayerIndex = -1;
LayerControlWidget *m_layerControlWidget = nullptr;
int m_layerControlIndex = -1;
// Performance:
QLineEdit *m_layerPerf_leLayer = nullptr;
QLineEdit *m_layerPerf_leObject = nullptr;
QLineEdit *m_layerPerf_leRadius = nullptr;
QCheckBox *m_layerPerf_cbText = nullptr;
// Tools/Viewshed
QLineEdit *m_viewshedDistance = nullptr;
QLineEdit *m_sightFanObserverHeight = nullptr;
QLineEdit *m_sightFanTargetHeight = nullptr;
bool m_visibility = true;
bool m_visibilityTechn = true;
bool m_visibilityTact = true;
bool m_selected = false;
bool m_pickable = true;
QLineEdit *m_leSidc = nullptr;
QComboBox *m_cbMultiPointSidc = nullptr;
Esri::ArcGISRuntime::TextSymbol *m_textSymbolMultiPointSidc = nullptr;
Esri::ArcGISRuntime::Graphic *m_tsGraphicMultiPointSidc = nullptr;
QComboBox *m_cbRubSidc = nullptr;
QPointF m_objectBasePoint = QPointF(0, 0);
// Graphics3D
struct object3D_data
{
std::shared_ptr<Esri::ArcGISRuntime::Graphic> m_graphic;
Esri::ArcGISRuntime::Point m_position;
};
QVector<object3D_data> m_impactCircleSphere;
QVector<object3D_data> m_impactCone;
QVector<object3D_data> m_3dModel;
QVector<object3D_data> m_impactConeViaUniqueValueRenderer;
//
static void clearMapObjectPtr(RefPointer<SituationMap::AbstractMapObject> mapObj)
{
if (mapObj)
mapObj->removeMySelf();
}
RefPointer<SituationMap::Polygon> m_polygon;
RefPointer<SituationMap::Polyline> m_polyline;
RefPointer<SituationMap::Text> m_text;
//
RefPointer<SituationMap::Participant> m_participant;
RefPointer<SituationMap::AreaFire> m_areaFire;
RefPointer<SituationMap::BuildingOutline> m_building;
RefPointer<SituationMap::BiologicalAgent> m_bAgent;
RefPointer<SituationMap::ChemicalAgent> m_cAgent;
RefPointer<SituationMap::Cube> m_cube;
RefPointer<SituationMap::DangerArea> m_dangerArea;
RefPointer<SituationMap::FunctionalArea> m_functionalArea;
RefPointer<SituationMap::GeoImage> m_geoImage;
RefPointer<SituationMap::SoundArea> m_soundArea;
RefPointer<SituationMap::HitLine> m_hitLine;
RefPointer<SituationMap::LineOfSight> m_lineOfSight;
RefPointer<SituationMap::Mine> m_mine;
RefPointer<SituationMap::MineField> m_mineField;
RefPointer<SituationMap::NuclearAgent> m_nuclearAgent;
RefPointer<SituationMap::NuclearAgent> m_virtualSingleMineAgent;
RefPointer<SituationMap::SingleFire> m_singleFire;
RefPointer<SituationMap::Polyline> m_basePoint;
const QList< RefPointer<AbstractMapObject> > getObjList()
{
QList<RefPointer<AbstractMapObject> > objList =
m_mapInterface->objectFactory().getAllObjects();
return objList;
}
}; // class FunctionDialog::Private
QHash<Map *, FunctionDialog *> FunctionDialog::Private::s_activeFunctionDialogMap;
//-----------------------------------------------------------------------------
FunctionDialog::FunctionDialog(Esri::ArcGISRuntime::Map *esriMap,
Esri::ArcGISRuntime::MapGraphicsView *esriView,
QWidget *parent)
: QWidget(parent)
, d(new Private)
{
qDebug() << LOGFUNCTION << " BEGIN";
this->setObjectName(QLatin1String("SituationMapFunctionDialog"));
d->m_esriMap = esriMap;
d->m_mapGeoView = esriView;
qDebug() << LOGFUNCTION << " BEGIN";
init();
}
FunctionDialog::FunctionDialog(Map *map)
: QWidget(nullptr)
, d(new Private)
{
qDebug() << LOGFUNCTION << " BEGIN";
this->setObjectName(QLatin1String("SituationMapFunctionDialog"));
d->m_mapInterface = map;
d->m_mapImpl = dynamic_cast<MapImpl *>(d->m_mapInterface);
if (d->m_mapImpl)
{
d->m_esriMap = d->m_mapImpl->getEsriMap();
d->m_mapGeoView = d->m_mapImpl->getEsriGeoView();
// define
QLatin1String layerName("FunctionDialog");
d->m_renderMode = RenderingMode::Dynamic;
// prepare
LayerFactoryImpl &layerFactory = d->m_mapImpl->layerFactoryImpl();
layerFactory.addOperationalLayer(layerName, layerName, d->m_renderMode);
// create corresponding layer:
d->m_graphicsLayer = layerFactory.getGraphicsLayer(layerName);
d->m_graphicsLayerDict = layerFactory.getGraphicsLayerDict(layerName);
}
init();
connect(map, &Map::beginDestroy, this, &FunctionDialog::onDestroyed);
FunctionDialog::Private::s_activeFunctionDialogMap[d->m_mapInterface] = this;
qAddPostRoutine(FunctionDialog::Private::cleanupActiveFunctionDialogMap);
}
FunctionDialog::~FunctionDialog()
{
qDebug() << LOGFUNCTION << " END";
FunctionDialog::Private::s_activeFunctionDialogMap.remove(d->m_mapInterface);
delete d;
}
void FunctionDialog::onDestroyed()
{
qDebug() << LOGFUNCTION << " commit suicide";
delete this;
}
void FunctionDialog::addButtonToMap(Map *map, bool isVisible)
{
if (!map || !map->getQGraphicsView())
{
qWarning() << LOGFUNCTION << " no map!!!";
std::cerr << LOGFUNCTION << " no map!!!" << std::endl;
return;
}
// create button:
QPushButton *pbFunctionDialog = new QPushButton(QLatin1String("FunctionDialog"));
pbFunctionDialog->setObjectName(QLatin1String("QPushButton-FunctionDialog"));
pbFunctionDialog->setAttribute(Qt::WA_AcceptTouchEvents);
// add button
// MapImpl *mapImpl = static_cast<MapImpl*>();
// EsriRuntimeQt::MapGraphicsView *mapGraphicsView = mapImpl->getEsriMapGraphicsView();
// Bug iOSQz-000005 'QGraphicsProxyWidget will crash'
// Adding a widget will let the application crash
// Workaround: 'proxy->setOpacity(0.99);'
QGraphicsProxyWidget *proxy = map->getQGraphicsView()->scene()->addWidget(pbFunctionDialog);
proxy->setOpacity(0.99);
// enable/disable button
pbFunctionDialog->setStyleSheet(QLatin1String("QPushButton {background-color: red;}"));
pbFunctionDialog->setEnabled(false);
QPointer<MapNotifier> mapNotifier = map->createMapNotifier();
if (mapNotifier)
{
connect(mapNotifier.data(), &MapNotifier::mapReadyAndSymbolDictionaryLoaded, map, [pbFunctionDialog] ()
{
pbFunctionDialog->setStyleSheet(QLatin1String("QPushButton {background-color: gray;}"));
pbFunctionDialog->setEnabled(true);
});
mapNotifier->run();
}
pbFunctionDialog->setVisible(isVisible);
// add action to button
// c++11 -> lambda :-)
connect(pbFunctionDialog, &QPushButton::clicked, map, [map]()
{
// Keep multiple MapWidget in mind!
if (!FunctionDialog::Private::s_activeFunctionDialogMap.contains(map))
FunctionDialog::Private::s_activeFunctionDialogMap[map] = new SituationMap::FunctionDialog(map);
SituationMap::FunctionDialog *functionDialog = FunctionDialog::Private::s_activeFunctionDialogMap[map];
// // map->getQGraphicsView()->scene()->addWidget(functionDialog); // just for testing
functionDialog->raise();
functionDialog->show();
functionDialog->move(100, 100);
}, Qt::QueuedConnection);
}
void FunctionDialog::init()
{
setAttribute(Qt::WA_DeleteOnClose);
s_basePoint = LtsCoordTrans::UtmCoordinate::fromMgrs(QLatin1String("32UMD000000000000")); // Bremen 32UMD000000000000
// s_basePoint = LtsCoordTrans::UtmCoordinate::fromMgrs(QLatin1String("32TNT000000000000")); //
// s_basePoint = LtsCoordTrans::UtmCoordinate::fromMgrs(QLatin1String("32UPD000000000000")); // Salchau 32UPD000000000000
qWarning() << " s_basePoint: "
<< " x=" << s_basePoint.x
<< " y=" << s_basePoint.y;
qint64 myPid = QCoreApplication::applicationPid();
QString symType(QLatin1String("noSymType"));
if (d->m_mapImpl)
symType = toString(d->m_mapImpl->symbologyType());
QString title = QStringLiteral("FunctionDialog (symType=%1) (Rendering=%2) (pid=%3)")
.arg(symType, toString(d->m_renderMode))
.arg(myPid);
setWindowTitle(title);
QHBoxLayout *layout = new QHBoxLayout(this);
QVBoxLayout *leftLayout = new QVBoxLayout();
layout->addLayout(leftLayout);
QPushButton *pbToBremen = new QPushButton(QLatin1String("Center to Bremen"), this);
leftLayout->addWidget(pbToBremen);
connect(pbToBremen, &QPushButton::clicked, this, [this]()
{
if (d->m_mapImpl->isReady())
d->m_mapImpl->setCenterPoint(QPointF(0.155, 0.925));
});
QComboBox *cbCenterTo = new QComboBox(this);
leftLayout->addWidget(cbCenterTo);
QVariant data;
data.setValue(QPointF(0.155, 0.925));
cbCenterTo->addItem(QStringLiteral("Bremen"), data);
data.setValue(QPointF(0.158, 0.928));
cbCenterTo->addItem(QStringLiteral("Schnoeggersburg"), data);
data.setValue(QPointF(0.155, 0.925));
cbCenterTo->addItem(QStringLiteral("AHTC"), data);
connect(cbCenterTo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, [this, cbCenterTo](int)
{
if (!d->m_mapImpl->isReady())
return;
QPointF p = cbCenterTo->currentData().toPointF();
d->m_mapImpl->setCenterPoint(p);
});
d->m_lbMapPosition = new QLabel;
leftLayout->addWidget(d->m_lbMapPosition);
d->m_lbPixelSize = new QLabel;
leftLayout->addWidget(d->m_lbPixelSize);
d->m_tabwidget = new QTabWidget();
leftLayout->addWidget(d->m_tabwidget);
// make connection to receive mouse position signals
connect(d->m_mapInterface, &Map::mouseWindowPositionChanged, this, &FunctionDialog::onMouseWindowPositionChanged);
connect(d->m_mapInterface, &Map::mouseMapPositionChanged , this, &FunctionDialog::onMouseMapPositionChanged);
connect(d->m_mapInterface, &Map::mouseGeoPositionChanged , this, &FunctionDialog::onMouseGeoPositionChanged);
connect(d->m_mapInterface, &Map::extentChanged, this, &FunctionDialog::onExtendChanged, Qt::QueuedConnection);
//-----------------------------------
// Visibility
//-----------------------------------
QVBoxLayout *vBoxLayout = new QVBoxLayout();
layout->addLayout(vBoxLayout);
if (d->m_mapImpl)
{
d->m_pbGrid = new QPushButton(QLatin1String("Grid"));
if (d->m_mapImpl->grid().isVisible())
d->m_pbGrid->setText(QLatin1String("Grid is ON "));
else
d->m_pbGrid->setText(QLatin1String("Grid is OFF"));
vBoxLayout->addWidget(d->m_pbGrid);
connect(d->m_pbGrid, &QPushButton::clicked, this, &FunctionDialog::onToggleGrid);
}
d->m_pbVisibility = new QPushButton(QLatin1String("Visibility"));
if (d->m_visibility)
d->m_pbVisibility->setText(QLatin1String("Visibility is ON "));
else
d->m_pbVisibility->setText(QLatin1String("Visibility is OFF"));
vBoxLayout->addWidget(d->m_pbVisibility);
connect(d->m_pbVisibility, &QPushButton::clicked, this, &FunctionDialog::onToggleVisibility);
d->m_pbVisibilityTechn = new QPushButton(QLatin1String("VisiTechn."));
if (d->m_visibilityTechn)
d->m_pbVisibilityTechn->setText(QLatin1String("VisiTechn is ON "));
else
d->m_pbVisibilityTechn->setText(QLatin1String("Visibility is OFF"));
vBoxLayout->addWidget(d->m_pbVisibilityTechn);
connect(d->m_pbVisibilityTechn, &QPushButton::clicked, this, &FunctionDialog::onToggleVisibilityTechn);
d->m_pbVisibilityTact = new QPushButton(QLatin1String("VisiTact."));
if (d->m_visibilityTact)
d->m_pbVisibilityTact->setText(QLatin1String("VisiTact is ON "));
else
d->m_pbVisibilityTact->setText(QLatin1String("VisiTact is OFF"));
vBoxLayout->addWidget(d->m_pbVisibilityTact);
connect(d->m_pbVisibilityTact, &QPushButton::clicked, this, &FunctionDialog::onToggleVisibilityTact);
d->m_pbSelected = new QPushButton(QLatin1String("Selection"));
if (d->m_selected)
d->m_pbSelected->setText(QLatin1String("Selection is ON "));
else
d->m_pbSelected->setText(QLatin1String("Selection is OFF"));
vBoxLayout->addWidget(d->m_pbSelected);
connect(d->m_pbSelected, &QPushButton::clicked, this, &FunctionDialog::onToggleSelection);
d->m_pbPicking = new QPushButton(QLatin1String("Picking"));
if (d->m_pickable)
d->m_pbPicking->setText(QLatin1String("Picking is ON "));
else
d->m_pbPicking->setText(QLatin1String("Picking is OFF"));
vBoxLayout->addWidget(d->m_pbPicking);
connect(d->m_pbPicking, &QPushButton::clicked, this, &FunctionDialog::onTogglePicking);
d->m_pbBoundingBox = new QPushButton(QLatin1String("BoundingBox is ON "));
if (d->m_objectsWithBoundingBox.isEmpty())
d->m_pbBoundingBox->setText(QLatin1String("BoundingBox is OFF"));
else
d->m_pbBoundingBox->setText(QLatin1String("BoundingBox is ON"));
vBoxLayout->addWidget(d->m_pbBoundingBox);
connect(d->m_pbBoundingBox, &QPushButton::clicked, this, &FunctionDialog::onToggleBoundingBox);
d->m_pbBB2 = new QPushButton(QLatin1String("BB2"));
vBoxLayout->addWidget(d->m_pbBB2);
connect(d->m_pbBB2, &QPushButton::clicked, this, &FunctionDialog::onToggleBB2);
d->m_pbPickByArea = new QPushButton(QLatin1String("pick by area"));
vBoxLayout->addWidget(d->m_pbPickByArea);
connect(d->m_pbPickByArea, &QPushButton::clicked, this, [this]()
{
d->m_mapInterface->pickMapObjectsArea();
});
// picking:
connect(d->m_mapInterface, &Map::mapObjectsPickedByArea, this, [](const SituationMap::Map::RefPointerMapObjectList & mapObjList)
{
qCritical() << " GUI is not available anymore, moved to AdapterDds.";
QList<UniqueMapId> uniqueMapIds;
uniqueMapIds.reserve(mapObjList.size());
for (RefPointer<AbstractMapObject> mapObj : mapObjList)
{
uniqueMapIds.append(mapObj->uniqueMapId());
qCritical() << " mapObjectsPickedByArea: " << mapObj->uniqueMapId()
<< " , mapObj->debugInfo: " << mapObj->debugInfo();
}
});
vBoxLayout->addWidget(new QLabel(QLatin1String("MapRotation:")));
QPushButton *pbMapRotation = new QPushButton(QLatin1String("MapRotation to 0"));
pbMapRotation->setToolTip(QLatin1String("reset rotation"));
vBoxLayout->addWidget(pbMapRotation);
d->m_dialMapRotation = new QDial();
d->m_dialMapRotation->setMinimum(-180);
d->m_dialMapRotation->setMaximum(180);
d->m_dialMapRotation->setValue(0);
// d->m_dialMapRotation->setTickInterval(10);
d->m_dialMapRotation->setSingleStep(10);
vBoxLayout->addWidget(d->m_dialMapRotation);
connect(d->m_dialMapRotation, &QSlider::valueChanged, this, &FunctionDialog::onMapRotationChanged);
// enable 'reset'
connect(pbMapRotation, &QPushButton::pressed, this, [this]()
{
d->m_dialMapRotation->setValue(0); // reset
});
QLabel *lbSymScale = new QLabel(QLatin1String("SymSize:"));
vBoxLayout->addWidget(lbSymScale);
d->m_slSymbolSize = new QSlider(Qt::Horizontal);
d->m_slSymbolSize->setMinimum(5);
d->m_slSymbolSize->setMaximum(500);
d->m_slSymbolSize->setValue(100);
d->m_slSymbolSize->setTickInterval(50);
d->m_slSymbolSize->setSingleStep(1);
vBoxLayout->addWidget(d->m_slSymbolSize);
connect(d->m_slSymbolSize, &QSlider::valueChanged, this, &FunctionDialog::onSymbolSizeChanged);
QLabel *lbSymOpacity = new QLabel(QLatin1String("SymOpacity:"));
vBoxLayout->addWidget(lbSymOpacity);
d->m_slSymbolOpacity = new QSlider(Qt::Horizontal);
d->m_slSymbolOpacity->setMinimum(10);
d->m_slSymbolOpacity->setMaximum(90);
d->m_slSymbolOpacity->setValue(50);
d->m_slSymbolOpacity->setTickInterval(10);
d->m_slSymbolOpacity->setSingleStep(10);
vBoxLayout->addWidget(d->m_slSymbolOpacity);
connect(d->m_slSymbolOpacity, &QSlider::valueChanged, this, &FunctionDialog::onSymbolOpacityChanged);
QLabel *lbDrawOrder = new QLabel(QLatin1String("DrawOrder:"));
vBoxLayout->addWidget(lbDrawOrder);
d->m_slDrawOrder = new QSlider(Qt::Horizontal);
d->m_slDrawOrder->setMinimum(-100);
d->m_slDrawOrder->setMaximum(100);
d->m_slDrawOrder->setValue(0);
d->m_slDrawOrder->setTickInterval(1);
d->m_slDrawOrder->setSingleStep(1);
vBoxLayout->addWidget(d->m_slDrawOrder);
connect(d->m_slDrawOrder, &QSlider::valueChanged, this, &FunctionDialog::onDrawOrderChanged);
//-----------------------------------
vBoxLayout->addStretch();
d->m_pbOverviewMap = new QPushButton(QLatin1String("OverviewMap on/off"));
vBoxLayout->addWidget(d->m_pbOverviewMap);
connect(d->m_pbOverviewMap, &QPushButton::clicked, this, &FunctionDialog::onOverviewMap);
//-----------------------------------
// Operator Map Settings
//-----------------------------------
d->m_pbBackupOms = new QPushButton(QLatin1String("backup Operator Map Settings"));
vBoxLayout->addWidget(d->m_pbBackupOms);
connect(d->m_pbBackupOms, &QPushButton::clicked, this, &FunctionDialog::onBackupOms);
d->m_pbRestoreOms = new QPushButton(QLatin1String("restore Operator Map Settings"));
vBoxLayout->addWidget(d->m_pbRestoreOms);
connect(d->m_pbRestoreOms, &QPushButton::clicked, this, &FunctionDialog::onRestoreOms);
//-----------------------------------
// Remove
//-----------------------------------
d->m_pbRemove = new QPushButton(QLatin1String("Remove couple"));
vBoxLayout->addWidget(d->m_pbRemove);
connect(d->m_pbRemove, &QPushButton::clicked, this, &FunctionDialog::onRemove);
d->m_pbRemoveAll = new QPushButton(QLatin1String("Remove ALL"));
vBoxLayout->addWidget(d->m_pbRemoveAll);
connect(d->m_pbRemoveAll, &QPushButton::clicked, this, &FunctionDialog::onRemoveAll);
//-----------------------------------
// Dump
//-----------------------------------
d->m_pbDump = new QPushButton(QLatin1String("Dump (ESRI)"));
vBoxLayout->addWidget(d->m_pbDump);
connect(d->m_pbDump, &QPushButton::clicked, this, &FunctionDialog::onDump);
// Screenshot
QPushButton *pbScreenshot = new QPushButton(QLatin1String("Screenshot - grab()"));
vBoxLayout->addWidget(pbScreenshot);
connect(pbScreenshot, &QPushButton::clicked, this, []()
{
QString imageName = QDir::tempPath() + QLatin1String("/sitMapScreenshot.png");
qWarning() << " save to '" << imageName << "'... ToDo.";
});
// toPdf
QPushButton *pbToPdf = new QPushButton(QLatin1String("toPdf"));
vBoxLayout->addWidget(pbToPdf);
connect(pbToPdf, &QPushButton::clicked, this, &FunctionDialog::onToPdf);
//-----------------------------------
// Quit
//-----------------------------------
d->m_pbClose = new QPushButton(QLatin1String("Close"));
vBoxLayout->addWidget(d->m_pbClose, 2);
// c++11 -> lambda :-)
connect(d->m_pbClose, &QPushButton::clicked, this, &FunctionDialog::close);
//-----------------------------------
// Tabs
//-----------------------------------
this->addSimpleLayerTab();
this->addLogicalLayerTab();
this->addLayerPerformanceTab();
this->addGraphicsTab();
this->addGraphics3DTab();
this->addMessageTab();
this->addMapObjectTab();
this->addRubberbandTab();
this->addRubberband3DTab();
this->addToolsTab();
this->addViewshedTab();
this->addOverlayPlanTab();
this->addIconRenderTab();
this->addPortalTab();
this->addMovePointLuxemburgTab();
// this->addYourTab();
// c++11 -> lambda :-)
connect(d->m_tabwidget, &QTabWidget::currentChanged, this, [this]()
{
int curIdx = d->m_tabwidget->currentIndex();
if (curIdx == d->m_simpleEsriLayerIndex)
d->m_simpleEsriLayer->updatePanel();
else if (curIdx == d->m_layerControlIndex)
d->m_layerControlWidget->updatePanel();
});
d->m_tabwidget->setCurrentIndex(7);
// Access symbolDictionary to create the dictionary at beginning
if (d->m_mapImpl)
d->m_mapImpl->symbolDictionary();
}
void FunctionDialog::setGraphicsLayer(Esri::ArcGISRuntime::GraphicsOverlay *graphicsLayer)
{
d->m_graphicsLayer = graphicsLayer;
}
void FunctionDialog::setMapPositionString(const QString &mapPosition)
{
if (d->m_lbMapPosition)
d->m_lbMapPosition->setText(mapPosition);
}
void FunctionDialog::setPixelSizeString(const QString &text)
{
if (d->m_lbPixelSize)
d->m_lbPixelSize->setText(text);
}
void FunctionDialog::addMapPositionString(const QString &mapPosition)
{
if (d->m_lbMapPosition)
d->m_lbMapPosition->setText(d->m_lbMapPosition->text() + mapPosition);
}
void FunctionDialog::addSimpleLayerTab()
{
QWidget *w = new QWidget();
QVBoxLayout *mainLayout = new QVBoxLayout(w);
if (!d->m_simpleEsriLayer)
{
Esri::ArcGISRuntime::MapGraphicsView *mapGraphicsView =
dynamic_cast<Esri::ArcGISRuntime::MapGraphicsView *>(d->m_mapGeoView);
if (mapGraphicsView)
d->m_simpleEsriLayer = new SimpleEsriLayer(this, mapGraphicsView);
}
mainLayout->addWidget(d->m_simpleEsriLayer);
mainLayout->addStretch();
d->m_simpleEsriLayerIndex = d->m_tabwidget->addTab(w, QLatin1String("SimpleLayer"));
}
void FunctionDialog::addLogicalLayerTab()
{
QWidget *w = new QWidget();
QVBoxLayout *mainLayout = new QVBoxLayout(w);
if (!d->m_layerControlWidget)
{
d->m_layerControlWidget = new LayerControlWidget(this, d->m_mapInterface,
true, // enableLayer
true, // enableBaseMap
QLatin1String("LC-FunctionDialog"));
}
mainLayout->addWidget(d->m_layerControlWidget);
mainLayout->addStretch();
d->m_layerControlIndex = d->m_tabwidget->addTab(w, QLatin1String("LogicalLayer"));
}
void FunctionDialog::addLayerPerformanceTab()
{
QWidget *w = new QWidget();
QVBoxLayout *mainLayout = new QVBoxLayout(w);
QGridLayout *layout = new QGridLayout();
mainLayout->addLayout(layout);
mainLayout->addStretch();
d->m_tabwidget->addTab(w, QLatin1String("LayerPerf."));
QLabel *lb;
//
lb = new QLabel(QLatin1String("# of Layer"));
layout->addWidget(lb, 0, 0);
d->m_layerPerf_leLayer = new QLineEdit(QLatin1String("1"));
d->m_layerPerf_leLayer->setPlaceholderText(QLatin1String("# of Layer"));
d->m_layerPerf_leLayer->setToolTip(d->m_layerPerf_leLayer->placeholderText());
layout->addWidget(d->m_layerPerf_leLayer, 1, 0);
//
lb = new QLabel(QLatin1String("# of Objects (total)"));
layout->addWidget(lb, 0, 1);
d->m_layerPerf_leObject = new QLineEdit(QLatin1String("1000"));
d->m_layerPerf_leObject->setPlaceholderText(QLatin1String("# of Objects"));
d->m_layerPerf_leObject->setToolTip(d->m_layerPerf_leObject->placeholderText());
layout->addWidget(d->m_layerPerf_leObject, 1, 1);
//
lb = new QLabel(QLatin1String("radius"));
layout->addWidget(lb, 0, 2);
d->m_layerPerf_leRadius = new QLineEdit(QLatin1String("100"));
d->m_layerPerf_leRadius->setPlaceholderText(QLatin1String("radius"));
d->m_layerPerf_leRadius->setToolTip(d->m_layerPerf_leRadius->placeholderText());
layout->addWidget(d->m_layerPerf_leRadius, 1, 2);
//
lb = new QLabel(QLatin1String("with Text"));
layout->addWidget(lb, 0, 3);
d->m_layerPerf_cbText = new QCheckBox;
d->m_layerPerf_cbText->setToolTip(QLatin1String("with Text"));
layout->addWidget(d->m_layerPerf_cbText, 1, 3);
QPushButton *pbStart = new QPushButton(QLatin1String("generate Layer"));
layout->addWidget(pbStart);
connect(pbStart, &QPushButton::clicked, this, &FunctionDialog::onLayerPerfCreateLayer);
}
void FunctionDialog::addGraphicsTab()
{
QWidget *w = new QWidget();
QVBoxLayout *mainLayout = new QVBoxLayout(w);
QGridLayout *layout = new QGridLayout();
mainLayout->addLayout(layout);
mainLayout->addStretch();
d->m_tabwidget->addTab(w, QLatin1String("Graphics"));
QPushButton *pbGraphics = new QPushButton(QLatin1String("generate Graphics"));
layout->addWidget(pbGraphics);
connect(pbGraphics, &QPushButton::clicked, this, &FunctionDialog::onGenerateGraphics);
QPushButton *pbGenerateCube = new QPushButton(QLatin1String("generate/destroy Cube"));
layout->addWidget(pbGenerateCube);
connect(pbGenerateCube, &QPushButton::clicked, this, &FunctionDialog::onGenerateCube);
QPushButton *pbGenerateCubeArray = new QPushButton(QLatin1String("generate/destroy CubeArray"));
layout->addWidget(pbGenerateCubeArray);
connect(pbGenerateCubeArray, &QPushButton::clicked, this, &FunctionDialog::onGenerateCubeArray);
QPushButton *pbGenerateStackedCubes = new QPushButton(QLatin1String("generate stacked Cubes"));
layout->addWidget(pbGenerateStackedCubes);
connect(pbGenerateStackedCubes, &QPushButton::clicked, this, &FunctionDialog::onGenerateStackedCubes);
QPushButton *pbGraphicsKristenStrandford = new QPushButton(QLatin1String("generate Graphics - KristenStrandford"));
layout->addWidget(pbGraphicsKristenStrandford);
connect(pbGraphicsKristenStrandford, &QPushButton::clicked, this, &FunctionDialog::onGenerateGraphicsKristenStrandford);
}
void FunctionDialog::addGraphics3DTab()
{
QWidget *w = new QWidget();
QVBoxLayout *mainLayout = new QVBoxLayout(w);
QGridLayout *layout = new QGridLayout();
mainLayout->addLayout(layout);
mainLayout->addStretch();
d->m_tabwidget->addTab(w, QLatin1String("Graphics 3D"));
//
// Sphere (Kugel) - RENDERER
{
QPushButton *pbGraphics = new QPushButton(QLatin1String("generate 3D-Graphic Sphere RENDERER"));
layout->addWidget(pbGraphics);
connect(pbGraphics, &QPushButton::clicked, this, &FunctionDialog::onGenerate3DGraphicSphereRENDERER);
QSlider *slOpcacity = new QSlider(Qt::Horizontal);
slOpcacity->setMinimum(0);
slOpcacity->setMaximum(100);
layout->addWidget(slOpcacity);
connect(slOpcacity, &QSlider::valueChanged, this, &FunctionDialog::onSphereOpacityChangedRENDERER);
QSlider *slZValue = new QSlider(Qt::Horizontal);
slZValue->setMinimum(-150);
slZValue->setMaximum(150);
layout->addWidget(slZValue);
connect(slZValue, &QSlider::valueChanged, this, &FunctionDialog::onSphereZValueChanged);
}
//
// Sphere (Kugel)
{
QPushButton *pbGraphics = new QPushButton(QLatin1String("generate 3D-Graphic Sphere"));
layout->addWidget(pbGraphics);
connect(pbGraphics, &QPushButton::clicked, this, &FunctionDialog::onGenerate3DGraphicSphere);
QSlider *slOpcacity = new QSlider(Qt::Horizontal);
slOpcacity->setMinimum(0);
slOpcacity->setMaximum(100);
layout->addWidget(slOpcacity);
connect(slOpcacity, &QSlider::valueChanged, this, &FunctionDialog::onSphereOpacityChanged);
QSlider *slZValue = new QSlider(Qt::Horizontal);
slZValue->setMinimum(-150);
slZValue->setMaximum(150);
layout->addWidget(slZValue);
connect(slZValue, &QSlider::valueChanged, this, &FunctionDialog::onSphereZValueChanged);
}
//
// Cone (Kegel)
{
QPushButton *pbCone = new QPushButton(QLatin1String("generate 3D-Graphic Cone"));
layout->addWidget(pbCone);
connect(pbCone, &QPushButton::clicked, this, &FunctionDialog::onGenerate3DGraphicCone);
QSlider *slOpcacity = new QSlider(Qt::Horizontal);
slOpcacity->setMinimum(0);
slOpcacity->setMaximum(100);
layout->addWidget(slOpcacity);
connect(slOpcacity, &QSlider::valueChanged, this, &FunctionDialog::onConeOpacityChanged);
QSlider *slZValue = new QSlider(Qt::Horizontal);
slZValue->setMinimum(-150);
slZValue->setMaximum(150);
layout->addWidget(slZValue);
connect(slZValue, &QSlider::valueChanged, this, &FunctionDialog::onConeZValueChanged);
QSlider *slHeading = new QSlider(Qt::Horizontal);
slHeading->setMinimum(-180);
slHeading->setMaximum(180);
layout->addWidget(slHeading);
connect(slHeading, &QSlider::valueChanged, this, &FunctionDialog::onConeHeadingChanged);
QSlider *slRoll = new QSlider(Qt::Horizontal);
slRoll->setMinimum(-180);
slRoll->setMaximum(180);
layout->addWidget(slRoll);
connect(slRoll, &QSlider::valueChanged, this, &FunctionDialog::onConeRollChanged);
QSlider *slPitch = new QSlider(Qt::Horizontal);
slPitch->setMinimum(-180);
slPitch->setMaximum(180);
layout->addWidget(slPitch);
connect(slPitch, &QSlider::valueChanged, this, &FunctionDialog::onConePitchChanged);
}
//
// 3D Model
{
QPushButton *pbGraphics = new QPushButton(QLatin1String("place 3D model (symbol and graphic)"));
layout->addWidget(pbGraphics);
connect(pbGraphics, &QPushButton::clicked, this, &FunctionDialog::on3dModel);
// QSlider *slOpcacity = new QSlider(Qt::Horizontal);
// slOpcacity->setMinimum(0);
// slOpcacity->setMaximum(100);
// layout->addWidget(slOpcacity);
// connect(slOpcacity, &QSlider::valueChanged, this, &FunctionDialog::onSphereOpacityChangedRENDERER);
QSlider *slZValue = new QSlider(Qt::Horizontal);
slZValue->setMinimum(-150);
slZValue->setMaximum(150);
layout->addWidget(slZValue);
connect(slZValue, &QSlider::valueChanged, this, &FunctionDialog::on3dModelZValueChanged);
}
//
// Cones via UniqueValueRenderer
{
QPushButton *pbGraphics = new QPushButton(QStringLiteral("Cones via UniqueValueRenderer"));
layout->addWidget(pbGraphics);
connect(pbGraphics, &QPushButton::clicked, this, &FunctionDialog::onGenerate3DGraphicConeUniqueValueRenderer);
// QSlider *slOpcacity = new QSlider(Qt::Horizontal);
// slOpcacity->setMinimum(0);
// slOpcacity->setMaximum(100);
// layout->addWidget(slOpcacity);
// connect(slOpcacity, &QSlider::valueChanged, this, &FunctionDialog::onSphereOpacityChangedRENDERER);
// QSlider *slZValue = new QSlider(Qt::Horizontal);
// slZValue->setMinimum(-150);
// slZValue->setMaximum(150);
// layout->addWidget(slZValue);
// connect(slZValue, &QSlider::valueChanged, this, &FunctionDialog::on3dModelZValueChanged);
}
}
QSet<QString> listOfPointSidcs_Internal()
{
QSet<QString> sidcs;
sidcs += AdvancedSymbology::SidcCodec::encodeComplete(AdvancedSymbology::SymbologyType::APP6D, "10011500002102000000"); // mine_impl
sidcs += AdvancedSymbology::SidcCodec::encodeComplete(AdvancedSymbology::SymbologyType::APP6D, "10012500002108000000"); // single_fire_impl
sidcs += AdvancedSymbology::SidcCodec::encodeComplete(AdvancedSymbology::SymbologyType::APP6D, "10012500002707050000"); // 25270705 -> Protection Areas : Minefield : Dummy
// SymbolSet 01 == air
sidcs += AdvancedSymbology::SidcCodec::encodeComplete(AdvancedSymbology::SymbologyType::APP6D, "10030100001101000000"); // differs in APP6(D)
sidcs += AdvancedSymbology::SidcCodec::encodeComplete(AdvancedSymbology::SymbologyType::APP6D, "10030100001201000000");
// SymbolSet 10 == Land Unit
sidcs += AdvancedSymbology::SidcCodec::encodeComplete(AdvancedSymbology::SymbologyType::APP6D, "10031000001100000000");
sidcs += AdvancedSymbology::SidcCodec::encodeComplete(AdvancedSymbology::SymbologyType::APP6D, "10031000001101000000");
sidcs += AdvancedSymbology::SidcCodec::encodeComplete(AdvancedSymbology::SymbologyType::APP6D, "10031000001102000000");
sidcs += AdvancedSymbology::SidcCodec::encodeComplete(AdvancedSymbology::SymbologyType::APP6D, "10031000001103000000");
sidcs += AdvancedSymbology::SidcCodec::encodeComplete(AdvancedSymbology::SymbologyType::APP6D, "10031000001104000000");
sidcs += AdvancedSymbology::SidcCodec::encodeComplete(AdvancedSymbology::SymbologyType::APP6D, "10031000001105000000");
sidcs += AdvancedSymbology::SidcCodec::encodeComplete(AdvancedSymbology::SymbologyType::APP6D, "10031000001106000000");
// SymbolSet 15 == Land Equipment
sidcs += AdvancedSymbology::SidcCodec::encodeComplete(AdvancedSymbology::SymbologyType::APP6D, "10031500001110000000"); // baseSymbolCode = 15 111000 Missle Launcher
sidcs += AdvancedSymbology::SidcCodec::encodeComplete(AdvancedSymbology::SymbologyType::APP6D, "10031500001100000000");
sidcs += AdvancedSymbology::SidcCodec::encodeComplete(AdvancedSymbology::SymbologyType::APP6D, "10031500001101000000");
sidcs += AdvancedSymbology::SidcCodec::encodeComplete(AdvancedSymbology::SymbologyType::APP6D, "10031500001101010000");
sidcs += AdvancedSymbology::SidcCodec::encodeComplete(AdvancedSymbology::SymbologyType::APP6D, "10031500001101020000");
sidcs += AdvancedSymbology::SidcCodec::encodeComplete(AdvancedSymbology::SymbologyType::APP6D, "10031500001101030000");
sidcs += AdvancedSymbology::SidcCodec::encodeComplete(AdvancedSymbology::SymbologyType::APP6D, "10011000001213030000"); // Movement and Maneuver : Reconnaissance 10 121303 (FULL_FRAME, but no real MainIcon)
sidcs += AdvancedSymbology::SidcCodec::encodeComplete(AdvancedSymbology::SymbologyType::APP6D, "10031500001202000000"); // Vehicle : Tank 15 120200
// Guez-IEDs
sidcs += AdvancedSymbology::SidcCodec::encodeComplete(AdvancedSymbology::SymbologyType::APP6D, "10011500002104000000"); // LAND MINE - IED
sidcs += AdvancedSymbology::SidcCodec::encodeComplete(AdvancedSymbology::SymbologyType::APP6D, "10013500001202000000"); // Weapon - IED
sidcs += AdvancedSymbology::SidcCodec::encodeComplete(AdvancedSymbology::SymbologyType::APP6D, "10014000001103000000"); // IED SUICIDE BOMBER (OHNE ZickZack)
sidcs += AdvancedSymbology::SidcCodec::encodeComplete(AdvancedSymbology::SymbologyType::APP6D, "10014000001103010000"); // IED SUICIDE BOMBER (MIT ZickZack)
// ^
sidcs += AdvancedSymbology::SidcCodec::encodeComplete(AdvancedSymbology::SymbologyType::APP6D, "10014000001103040000"); // IED suicide bomber
sidcs += AdvancedSymbology::SidcCodec::encodeComplete(AdvancedSymbology::SymbologyType::APP6D, "10014000001101110000"); // BOOBY TRAP (replaced by 'IED suicide bomber')
return sidcs;
}
QSet<QString> listOfLineSidcs_Internal()
{
QSet<QString> sidcs;
sidcs += AdvancedSymbology::SidcCodec::encodeComplete(AdvancedSymbology::SymbologyType::APP6D, "10032500001406030000"); // hit_line_impl
sidcs += AdvancedSymbology::SidcCodec::encodeComplete(AdvancedSymbology::SymbologyType::APP6D, "10012500001402000000"); // 25140200_6 == "Maneuver Lines : Line of Contact" (no key8-Entry)
#ifdef SYM_PROTECTION_AREAS_BECOMES_LINE
sidcs += AdvancedSymbology::SidcCodec::encodeComplete(AdvancedSymbology::SymbologyType::APP6D, "10012500002711000000"); // Control Measure: Protection Areas :
sidcs += AdvancedSymbology::SidcCodec::encodeComplete(AdvancedSymbology::SymbologyType::APP6D, "10012500002713000000"); // Control Measure: Protection Areas : Assult Crossing (former GeometryType::area, now GeometryType::Line)
sidcs += AdvancedSymbology::SidcCodec::encodeComplete(AdvancedSymbology::SymbologyType::APP6D, "10012500002714000000"); // Control Measure: Protection Areas : Bridge
#endif // SYM_PROTECTION_AREAS_BECOMES_LINE
return sidcs;
}
QSet<QString> listOfAreaSidcs_Internal()
{
QSet<QString> sidcs;
sidcs += AdvancedSymbology::SidcCodec::encodeComplete(AdvancedSymbology::SymbologyType::APP6D, "10012500002408010000"); // area_fire_impl
sidcs += AdvancedSymbology::SidcCodec::encodeComplete(AdvancedSymbology::SymbologyType::APP6D, "10012500002717000000"); // biological_agent_impl
sidcs += AdvancedSymbology::SidcCodec::encodeComplete(AdvancedSymbology::SymbologyType::APP6D, "10042500002701000000"); // building_outline_impl
sidcs += AdvancedSymbology::SidcCodec::encodeComplete(AdvancedSymbology::SymbologyType::APP6D, "10012500002718000000"); // chemical_agent_impl
sidcs += AdvancedSymbology::SidcCodec::encodeComplete(AdvancedSymbology::SymbologyType::APP6D, "10012500001511000000"); // danger_area_impl
// sidcs += AdvancedSymbology::SidcCodec::encodeComplete(AdvancedSymbology::SymbologyType::APP6D,"10012500002707010000"); // MineField
sidcs += AdvancedSymbology::SidcCodec::encodeComplete(AdvancedSymbology::SymbologyType::APP6D, "10012500002707060000"); // mine_field_impl
sidcs += AdvancedSymbology::SidcCodec::encodeComplete(AdvancedSymbology::SymbologyType::APP6D, "10012500002719000000"); // nuclear_agent_impl
#ifndef SYM_PROTECTION_AREAS_BECOMES_LINE
sidcs += AdvancedSymbology::SidcCodec::encodeComplete(AdvancedSymbology::SymbologyType::APP6D, "10012500002711000000"); // Control Measure: Protection Areas :
sidcs += AdvancedSymbology::SidcCodec::encodeComplete(AdvancedSymbology::SymbologyType::APP6D, "10012500002713000000"); // Control Measure: Protection Areas : Assult Crossing (former GeometryType::area, now GeometryType::Line)
sidcs += AdvancedSymbology::SidcCodec::encodeComplete(AdvancedSymbology::SymbologyType::APP6D, "10012500002714000000"); // Control Measure: Protection Areas : Bridge
#endif // SYM_PROTECTION_AREAS_BECOMES_LINE
return sidcs;
}
QSet<QString> listOfPlanEditorSidcs_Internal()
{
QSet<QString> sidcs;
sidcs += AdvancedSymbology::SidcCodec::encodeBaseSymbolCode(AdvancedSymbology::SymbologyType::APP6D, "25342300");
sidcs += AdvancedSymbology::SidcCodec::encodeBaseSymbolCode(AdvancedSymbology::SymbologyType::APP6D, "25140500");
sidcs += AdvancedSymbology::SidcCodec::encodeBaseSymbolCode(AdvancedSymbology::SymbologyType::APP6D, "25152100");
sidcs += AdvancedSymbology::SidcCodec::encodeBaseSymbolCode(AdvancedSymbology::SymbologyType::APP6D, "25141400");
sidcs += AdvancedSymbology::SidcCodec::encodeBaseSymbolCode(AdvancedSymbology::SymbologyType::APP6D, "25141700");
sidcs += AdvancedSymbology::SidcCodec::encodeBaseSymbolCode(AdvancedSymbology::SymbologyType::APP6D, "25290500");
sidcs += AdvancedSymbology::SidcCodec::encodeBaseSymbolCode(AdvancedSymbology::SymbologyType::APP6D, "25270503");
sidcs += AdvancedSymbology::SidcCodec::encodeBaseSymbolCode(AdvancedSymbology::SymbologyType::APP6D, "25341900");
sidcs += AdvancedSymbology::SidcCodec::encodeBaseSymbolCode(AdvancedSymbology::SymbologyType::APP6D, "25270504");
sidcs += AdvancedSymbology::SidcCodec::encodeBaseSymbolCode(AdvancedSymbology::SymbologyType::APP6D, "25230100");
sidcs += AdvancedSymbology::SidcCodec::encodeBaseSymbolCode(AdvancedSymbology::SymbologyType::APP6D, "25271100");
sidcs += AdvancedSymbology::SidcCodec::encodeBaseSymbolCode(AdvancedSymbology::SymbologyType::APP6D, "25341500");
sidcs += AdvancedSymbology::SidcCodec::encodeBaseSymbolCode(AdvancedSymbology::SymbologyType::APP6D, "25241202");
sidcs += AdvancedSymbology::SidcCodec::encodeBaseSymbolCode(AdvancedSymbology::SymbologyType::APP6D, "25241602");
sidcs += AdvancedSymbology::SidcCodec::encodeBaseSymbolCode(AdvancedSymbology::SymbologyType::APP6D, "25340800");
sidcs += AdvancedSymbology::SidcCodec::encodeBaseSymbolCode(AdvancedSymbology::SymbologyType::APP6D, "25270502");
sidcs += AdvancedSymbology::SidcCodec::encodeBaseSymbolCode(AdvancedSymbology::SymbologyType::APP6D, "25342201");
sidcs += AdvancedSymbology::SidcCodec::encodeBaseSymbolCode(AdvancedSymbology::SymbologyType::APP6D, "25271204");
sidcs += AdvancedSymbology::SidcCodec::encodeBaseSymbolCode(AdvancedSymbology::SymbologyType::APP6D, "25240103");
sidcs += AdvancedSymbology::SidcCodec::encodeBaseSymbolCode(AdvancedSymbology::SymbologyType::APP6D, "25240802");
sidcs += AdvancedSymbology::SidcCodec::encodeBaseSymbolCode(AdvancedSymbology::SymbologyType::APP6D, "25270501");
sidcs += AdvancedSymbology::SidcCodec::encodeBaseSymbolCode(AdvancedSymbology::SymbologyType::APP6D, "25271600");
return sidcs;
}
void FunctionDialog::addMessageTab()
{
QWidget *w = new QWidget();
QVBoxLayout *mainLayout = new QVBoxLayout(w);
QGridLayout *layout = new QGridLayout();
mainLayout->addLayout(layout);
mainLayout->addStretch();
d->m_tabwidget->addTab(w, QLatin1String("Message"));
//-----------------------------------
QPushButton *pbAddCivilSymbols = new QPushButton(QLatin1String("add civil symbols"));
layout->addWidget(pbAddCivilSymbols);
connect(pbAddCivilSymbols, &QPushButton::clicked, this, &FunctionDialog::onAddCivilSymbols);
//-----------------------------------
QPushButton *pbMessage = new QPushButton(QLatin1String("generate Message"));
layout->addWidget(pbMessage);
connect(pbMessage, &QPushButton::clicked, this, &FunctionDialog::onMessage);
//-----------------------------------
QPushButton *pbSelectMessage = new QPushButton(QLatin1String("select Message"));
layout->addWidget(pbSelectMessage);
connect(pbSelectMessage, &QPushButton::clicked, this, &FunctionDialog::onMessageSelect);
//-----------------------------------
QPushButton *pbSymbolOverview = new QPushButton(QLatin1String("overviewESRI - wait!!!"));
layout->addWidget(pbSymbolOverview);
// c++11 -> lambda :-)
connect(pbSymbolOverview, &QPushButton::clicked, this, []()
{
AdvancedSymbology::Gui::BaseSymbolLookupDialog *bslDlg =
AdvancedSymbology::Gui::BaseSymbolLookupDialog::showInstance();
QSet<QString> sidcs;
sidcs += listOfPointSidcs_Internal();
sidcs += listOfLineSidcs_Internal();
sidcs += listOfAreaSidcs_Internal();
sidcs += listOfPlanEditorSidcs_Internal();
QSet<QString> baseSidcs;
baseSidcs.reserve(sidcs.size());
for(const auto &item : std::as_const(sidcs))
{
QString res = AdvancedSymbology::SidcBuilderBase::concreteSidcToBaseSymbolCode(item);
if (res.isEmpty())
baseSidcs.insert(item);
else
baseSidcs.insert(res);
} // for
bslDlg->setValidBaseSymbolCodes(baseSidcs);
bslDlg->show();
});
//-----------------------------------
QPushButton *pbAddSymbol = new QPushButton(QLatin1String("add symbol from File"));
layout->addWidget(pbAddSymbol);
connect(pbAddSymbol, &QPushButton::clicked, this, &FunctionDialog::onAddSymbol);
//-----------------------------------
QGridLayout *someParticipantLayout = new QGridLayout();
someParticipantLayout->setObjectName(QLatin1String("SomeParticipantsLayout"));
layout->addLayout(someParticipantLayout, layout->rowCount(), 0);
QPushButton *pbSomeParticipants = new QPushButton(QLatin1String("Aggregation-Participants"));
someParticipantLayout->addWidget(pbSomeParticipants, 0, 0);
connect(pbSomeParticipants, &QPushButton::clicked, this, &FunctionDialog::onSomeParticipants);
QSlider *slAggregationModifier = new QSlider(Qt::Horizontal);
slAggregationModifier->setTickInterval(10);
slAggregationModifier->setSingleStep(10);
someParticipantLayout->addWidget(slAggregationModifier, 0, 1);
connect(slAggregationModifier, &QSlider::valueChanged, this, [this, slAggregationModifier]()
{
const int counter = 6;
int scaleMin = 80000;
int scaleMax = 500;
int interval = (scaleMin - scaleMax) / counter;
LayerFactory &layerFac = d->m_mapInterface->layerFactory();
int newVal = 0;
for (int i = 1; i <= counter; ++i)
{
const QString &layername = QStringLiteral("Participants_%1").arg(i);
LayerParameter layerPara = layerFac.layerParameter(layername);
// double minScale = 0; ///< big value (e.g. 10000000) limiting zoomOut 1:10000000 -> 0.0000001 ; '0' without function
// double maxScale = 0; ///< small value (e.g. 1000) limiting zoomIn 1:1000 -> 0.001 ; '0' without function
layerPara.maxScale = newVal;
newVal = scaleMax + interval * i;
double userVal = slAggregationModifier->value() / 100.0;
newVal += interval * userVal;
newVal = std::min(newVal, scaleMin);
newVal = std::max(newVal, scaleMax);
layerPara.minScale = newVal;
if (i == counter)
layerPara.minScale = 0;
qWarning() << LOGFUNCTION << " layer: " << layername << " -> "
<< " userVal=" << userVal
<< " max=" << layerPara.maxScale
<< " min=" << layerPara.minScale;
layerFac.setLayerParameter(layername, layerPara);
} // for
});
slAggregationModifier->setMinimum(-200);
slAggregationModifier->setMaximum(200);
slAggregationModifier->setValue(0);
//-----------------------------------
// createParticipantButton
//-----------------------------------
QGridLayout *participantLayout = new QGridLayout();
participantLayout->setObjectName(QLatin1String("participantLayout"));
layout->addLayout(participantLayout, layout->rowCount(), 0);
d->m_leSidc = new QLineEdit();
switch (d->m_mapInterface->symbologyType())
{
case AdvancedSymbology::SymbologyType::None:
d->m_leSidc->setText(AdvancedSymbology::SidcCodec::encodeCivilEts("StelleBerRaum"));
d->m_leSidc->setToolTip(QStringLiteral("<html> <p><b> symbols added \?\? </b></p></html>"));
d->m_leSidc->setToolTipDuration(1000);
break;
case AdvancedSymbology::SymbologyType::APP6B:
case AdvancedSymbology::SymbologyType::MIL2525C:
d->m_leSidc->setText( AdvancedSymbology::SidcCodec::encodeComplete( d->m_mapInterface->symbologyType(), "SFGPUCD---D-") );
break;
case AdvancedSymbology::SymbologyType::APP6D:
case AdvancedSymbology::SymbologyType::MIL2525D:
d->m_leSidc->setText(AdvancedSymbology::SidcCodec::encodeComplete(AdvancedSymbology::SymbologyType::MIL2525D, "10011501001202000000")); // 10015000001202000000 -> 15 120200 LandEquip, Tank
d->m_leSidc->setText(AdvancedSymbology::SidcCodec::encodeComplete(AdvancedSymbology::SymbologyType::MIL2525D, "10011001001110000000")); // 10031000001110000000 -> 10 111000 LandUnits, CommandAndControl Signal
d->m_leSidc->setText(AdvancedSymbology::SidcCodec::encodeCivilEts("Pers_FW_BerFue"));
// d->m_leSidc->setText(AdvancedSymbology::SidcCodec::encodeCivilEts("ETS_PersFueAllg"));
break;
}
d->m_leSidc->setObjectName(QLatin1String("SIDC"));
QFont f = d->m_leSidc->font();
f.setPixelSize(20);
d->m_leSidc->setFont(f);
participantLayout->addWidget(d->m_leSidc, 0, 0);
connect(d->m_leSidc, &QLineEdit::textChanged, this, [this]()
{
if (d->m_leSidc->text().length() > 20)
d->m_leSidc->setStyleSheet(QLatin1String("QLineEdit#SIDC { background-color: red; color: #000; }"));
else
d->m_leSidc->setStyleSheet(QLatin1String("QLineEdit#SIDC { background-color: white; color: #000; }"));
});
QPushButton *pbCreatePart = new QPushButton(QLatin1String("createParticipant!! \n symbols added?"));
pbCreatePart->setToolTip(d->m_leSidc->toolTip());
participantLayout->addWidget(pbCreatePart, 0, 1);
connect(pbCreatePart, &QPushButton::clicked, this, &FunctionDialog::onParticipantCreate);
} /* FunctionDialog::addMessageTab */
void FunctionDialog::addMapObjectTab()
{
QWidget *w = new QWidget();
QVBoxLayout *mainLayout = new QVBoxLayout(w);
QGridLayout *layout = new QGridLayout();
mainLayout->addLayout(layout);
mainLayout->addStretch();
d->m_tabwidget->addTab(w, QLatin1String("Map Objects (Factory)"));
//-----------------------------------
// createPolygonButton
//-----------------------------------
QPushButton *pbPolygon = new QPushButton(QLatin1String("create Polygon"));
layout->addWidget(pbPolygon);
connect(pbPolygon, &QPushButton::clicked,
this, &FunctionDialog::onPolygonCreate);
//-----------------------------------
// createPolylineButton
//-----------------------------------
QPushButton *pbPolyline = new QPushButton(QLatin1String("create Polyline"));
layout->addWidget(pbPolyline);
connect(pbPolyline, &QPushButton::clicked,
this, &FunctionDialog::onPolylineCreate);
//-----------------------------------
// createTextButton
//-----------------------------------
QPushButton *pbText = new QPushButton(QLatin1String("create Text"));
layout->addWidget(pbText);
connect(pbText, &QPushButton::clicked,
this, &FunctionDialog::onTextCreate);
//-----------------------------------
// createMapObjectIndicatorButton
//-----------------------------------
QPushButton *pbMapObjectIndicator = new QPushButton(QLatin1String("create MapObjectIndicator"));
layout->addWidget(pbMapObjectIndicator);
connect(pbMapObjectIndicator, &QPushButton::clicked,
this, &FunctionDialog::onMapObjectIndicatorCreate);
//-----------------------------------
// createBuildingOutlineButton
//-----------------------------------
QPushButton *pbCreateBuilding = new QPushButton(QLatin1String("create Building"));
layout->addWidget(pbCreateBuilding);
connect(pbCreateBuilding, &QPushButton::clicked,
this, &FunctionDialog::onBuildingCreate);
//-----------------------------------
// createBAgentButton
//-----------------------------------
QPushButton *pbCreateBAgent = new QPushButton(QLatin1String("create B-Agent"));
layout->addWidget(pbCreateBAgent);
connect(pbCreateBAgent, &QPushButton::clicked,
this, &FunctionDialog::onBiologicalAgentCreate);
//-----------------------------------
// createCAgentButton
//-----------------------------------
QPushButton *pbCreateCAgent = new QPushButton(QLatin1String("create C-Agent"));
layout->addWidget(pbCreateCAgent);
connect(pbCreateCAgent, &QPushButton::clicked,
this, &FunctionDialog::onChemicalAgentCreate);
//-----------------------------------
// createDangerAreaButton
//-----------------------------------
QPushButton *createDangerAreaButton = new QPushButton(QLatin1String("create DangerArea"));
layout->addWidget(createDangerAreaButton);
connect(createDangerAreaButton, &QPushButton::clicked,
this, &FunctionDialog::onDangerAreaCreate);
//-----------------------------------
// createDangerAreaButton
//-----------------------------------
QPushButton *createFunctionalAreaButton = new QPushButton(QLatin1String("create FunctionalArea"));
layout->addWidget(createFunctionalAreaButton);
connect(createFunctionalAreaButton, &QPushButton::clicked,
this, &FunctionDialog::onFunctionalAreaCreate);
//-----------------------------------
// createAreaFireButton
//-----------------------------------
QPushButton *createAreaFireButton = new QPushButton(QLatin1String("create AreaFire"));
layout->addWidget(createAreaFireButton);
connect(createAreaFireButton, &QPushButton::clicked,
this, &FunctionDialog::onAreaFireCreate);
//-----------------------------------
// createSingleFireButton
//-----------------------------------
QPushButton *createSingleFireButton = new QPushButton(QLatin1String("create SingleFire"));
layout->addWidget(createSingleFireButton);
connect(createSingleFireButton, &QPushButton::clicked,
this, &FunctionDialog::onSingleFireCreate);
//-----------------------------------
// createChargeEffectButton
//-----------------------------------
QPushButton *createChargeEffectButton = new QPushButton(QLatin1String("create Charge Effect"));
layout->addWidget(createChargeEffectButton);
connect(createChargeEffectButton, &QPushButton::clicked,
this, &FunctionDialog::onChargeEffectCreate);
//-----------------------------------
// createMineButton
//-----------------------------------
QPushButton *createMineButton = new QPushButton(QLatin1String("create Mine"));
layout->addWidget(createMineButton);
connect(createMineButton, &QPushButton::clicked,
this, &FunctionDialog::onMineCreate);
//-----------------------------------
// createMineButton
//-----------------------------------
QPushButton *createMineFieldButton = new QPushButton(QLatin1String("create MineField"));
layout->addWidget(createMineFieldButton);
connect(createMineFieldButton, &QPushButton::clicked,
this, &FunctionDialog::onMineFieldCreate);
//-----------------------------------
// createNuclearButton
//-----------------------------------
QPushButton *createNuclearButton = new QPushButton(QLatin1String("create Nuclear"));
layout->addWidget(createNuclearButton);
connect(createNuclearButton, &QPushButton::clicked,
this, &FunctionDialog::onNuclearCreate);
//-----------------------------------
// createVirtualSingleMineButton
//-----------------------------------
QPushButton *createVirtualSingleMineButton = new QPushButton(QLatin1String("create Virtual Single Mine"));
layout->addWidget(createVirtualSingleMineButton);
connect(createVirtualSingleMineButton, &QPushButton::clicked,
this, &FunctionDialog::onBoobyTrapCreate);
//-----------------------------------
// createHitLineButton
//-----------------------------------
QHBoxLayout *hBox = new QHBoxLayout();
layout->addLayout(hBox, 99, 0);
QPushButton *createHitLineButton = new QPushButton(QLatin1String("create HitLine"));
hBox->addWidget(createHitLineButton);
connect(createHitLineButton, &QPushButton::clicked,
this, &FunctionDialog::onHitLineCreate);
QPushButton *hitLineRotate = new QPushButton(QLatin1String("rotate HitLine"));
hBox->addWidget(hitLineRotate);
connect(hitLineRotate, &QPushButton::clicked, this, [this]()
{
if (d->m_hitLine)
{
static int i = 0;
const QPointF &start = d->m_hitLine->startPoint().toPointF();
QPointF end = d->m_hitLine->endPoint().toPointF();
MathUtils::rotatePoint(end, start, 10);
Point3D start3D = Point3D::fromQPointF(start);
Point3D end3D = Point3D::fromQPointF(end);
end3D.rz() += i*10;
i++;
qCritical() << " Hitline: z = " << end3D.z();
d->m_hitLine->setStartAndEndPoint(start3D,
end3D);
d->m_hitLine->updateView();
}
});
//-----------------------------------
// createLineOfSightLine
//-----------------------------------
QPushButton *createLosLineButton = new QPushButton(QLatin1String("create LineOfSightLinge"));
layout->addWidget(createLosLineButton);
connect(createLosLineButton, &QPushButton::clicked,
this, &FunctionDialog::onLineOfSightLineCreate);
//-----------------------------------
// createGeoImage
//-----------------------------------
QPushButton *createGeoImageButton = new QPushButton(QLatin1String("create GeoImage \n(handled on signal 'mapObjectsClicked'?)"));
layout->addWidget(createGeoImageButton);
connect(createGeoImageButton, &QPushButton::clicked,
this, &FunctionDialog::onGeoImageCreate);
// similar to the application:
connect(d->m_mapInterface, &SituationMap::Map::mapObjectsClicked,
this, &FunctionDialog::onMapObjectClicked);
//-----------------------------------
// createSoundArea
//-----------------------------------
QPushButton *createSoundAreaButton = new QPushButton(QLatin1String("create SoundArea"));
layout->addWidget(createSoundAreaButton);
connect(createSoundAreaButton, &QPushButton::clicked,
this, &FunctionDialog::onSoundAreaCreate);
//-----------------------------------
// createMapObjectIndicatorButton
//-----------------------------------
QPushButton *pbCube = new QPushButton(QLatin1String("create cube"));
layout->addWidget(pbCube);
connect(pbCube, &QPushButton::clicked,
this, &FunctionDialog::onCubeCreate);
//-----------------------------------
// ???
//-----------------------------------
//-----------------------------------
// createShowBasePoint
//-----------------------------------
QPushButton *createShowBasePointButton = new QPushButton(QLatin1String("ShowBasePoint"));
layout->addWidget(createShowBasePointButton);
connect(createShowBasePointButton, &QPushButton::clicked,
this, &FunctionDialog::onShowBasePoint);
//-----------------------------------
// createPolizeiButton
//-----------------------------------
QPushButton *createPolizeiButton = new QPushButton(QLatin1String("create Polizei"));
layout->addWidget(createPolizeiButton);
connect(createPolizeiButton, &QPushButton::clicked,
this, &FunctionDialog::onShowPolizei);
}
void FunctionDialog::addRubberband3DTab()
{
QWidget *w = new QWidget();
QGridLayout *layout = new QGridLayout(w);
d->m_tabwidget->addTab(w, QLatin1String("Rubberband3D"));
QPushButton *pbPointFtRubberband = new QPushButton(QLatin1String("Point Feature Rubberband"), w);
pbPointFtRubberband->setToolTip(QString());
layout->addWidget(pbPointFtRubberband, 0, 0);
connect(pbPointFtRubberband, &QPushButton::clicked, this, [this]()
{
RB::RubberbandPointFeature3D *rubberband = d->m_mapInterface->rubberbandFactory().create3D<RB::RubberbandPointFeature3D>();
if (nullptr != rubberband)
{
rubberband->setAutoDelete(true);
QObject::connect(rubberband, &RB::RubberbandBase::apply, this, &FunctionDialog::onRubberband3DApply);
QObject::connect(rubberband, &RB::RubberbandBase::abort, this, &FunctionDialog::onRubberband3DAbort);
}
else
qWarning() << "Creating rubberband failed.";
});
QPushButton *pbMultiPointFtRubberband = new QPushButton(QLatin1String("Multi Point Feature Rubberband - Polyline"), w);
pbMultiPointFtRubberband->setToolTip(QStringLiteral("Create 3D polyline rubberband"));
layout->addWidget(pbMultiPointFtRubberband, 1, 0);
connect(pbMultiPointFtRubberband, &QPushButton::clicked, this, [this]()
{
RB::RubberbandMultiPointFeature3D *rubberband = d->m_mapInterface->rubberbandFactory().create3D<RB::RubberbandMultiPointFeature3D>();
if (nullptr != rubberband)
{
rubberband->setAutoDelete(true);
QObject::connect(rubberband, &RB::RubberbandBase::apply, this, &FunctionDialog::onRubberband3DApply);
QObject::connect(rubberband, &RB::RubberbandBase::abort, this, &FunctionDialog::onRubberband3DAbort);
}
else qWarning() << "Creating rubberband failed.";
});
QPushButton *pbMultiPointFtClosedRubberband = new QPushButton(QLatin1String("Multi Point Feature Rubberband - Polygon"), w);
pbMultiPointFtClosedRubberband->setToolTip(QStringLiteral("Create 3D polygon rubberband"));
layout->addWidget(pbMultiPointFtClosedRubberband, 2, 0);
connect(pbMultiPointFtClosedRubberband, &QPushButton::clicked, this, [this]()
{
RB::RubberbandMultiPointFeature3D *rubberband = d->m_mapInterface->rubberbandFactory().create3D<RB::RubberbandMultiPointFeature3D>();
if (nullptr != rubberband)
{
rubberband->setAutoDelete(true);
rubberband->enableClosed(true);
QObject::connect(rubberband, &RB::RubberbandBase::apply, this, &FunctionDialog::onRubberband3DApply);
QObject::connect(rubberband, &RB::RubberbandBase::abort, this, &FunctionDialog::onRubberband3DAbort);
}
else qWarning() << "Creating rubberband failed.";
});
QPushButton *pbMultiPointFtCircleRubberband = new QPushButton(QLatin1String("Multi Point Feature Rubberband - Circle"), w);
pbMultiPointFtCircleRubberband->setToolTip(QStringLiteral("Create 3D circle rubberband"));
layout->addWidget(pbMultiPointFtCircleRubberband, 3, 0);
connect(pbMultiPointFtCircleRubberband, &QPushButton::clicked, this, [this]()
{
RB::RubberbandMultiPointFeature3D *rubberband = d->m_mapInterface->rubberbandFactory().create3D<RB::RubberbandMultiPointFeature3D>();
if (nullptr != rubberband)
{
rubberband->setAutoDelete(true);
rubberband->enableCircular(true);
QObject::connect(rubberband, &RB::RubberbandBase::apply, this, &FunctionDialog::onRubberband3DApply);
QObject::connect(rubberband, &RB::RubberbandBase::abort, this, &FunctionDialog::onRubberband3DAbort);
}
else qWarning() << "Creating rubberband failed.";
});
} // void FunctionDialog::addRubberband3DTab()
void FunctionDialog::onRubberband3DApply(RB::RubberbandBase *)
{
qDebug() << LOGFUNCTION;
} // void FunctionDialog::onRubberband3DApply(RB::RubberbandBase *)
void FunctionDialog::onRubberband3DAbort(RB::RubberbandBase *)
{
qDebug() << LOGFUNCTION;
} // void FunctionDialog::onRubberband3DAbort(RB::RubberbandBase *)
void inline getSectorStartEnd(double angle, double rotation, double &aStartRad, double &aEndRad)
{
const double rotationMath = SituationMap::MathUtils::getAngleDegree2Math(rotation);//rotation < 90. ? std::fabs(rotation - 90) : std::fabs(360 - rotation + 90) ; // 12uhr ist 0° | rotation Math counter clockwise
// angle sectorStart
{
double val = rotationMath - angle / 2.;
aStartRad = val > 0 ? val : val + 360; // return the positive angle of the value
aStartRad = (aStartRad > 360. ? std::fmod(aStartRad, 360) : aStartRad) * LtsCoordTrans::deg2rad(); // convert to rad
}
// angle sectorEnd
{
aEndRad = rotationMath + angle / 2.;
aEndRad = (aEndRad > 360. ? std::fmod(aEndRad, 360) : aEndRad) * LtsCoordTrans::deg2rad();
}
}
void FunctionDialog::addRubberbandTab()
{
QWidget *w = new QWidget();
QGridLayout *layout = new QGridLayout(w);
d->m_tabwidget->addTab(w, QLatin1String("Rubberband"));
//-----------------------------------
// create symbol type edit line
//-----------------------------------
QGridLayout *rubberbandLayout = new QGridLayout();
rubberbandLayout->setObjectName(QLatin1String("rubberbandLayout"));
layout->addLayout(rubberbandLayout, layout->rowCount(), 0);
d->m_cbRubSidc = new QComboBox(w);
d->m_cbRubSidc -> setObjectName(QLatin1String("SIDC Rubberband"));
AdvancedSymbology::SymbolDictionary &dict = d->m_mapImpl->symbolDictionary();
switch (d->m_mapImpl->symbologyType())
{
case AdvancedSymbology::SymbologyType::MIL2525D:
{
// following works, but uses lambda.
// Therefore switch to SymbolResultWatcherComboxBox...
// QString sidc = QLatin1String("10051000001213030000"); // 01011000001213030000 -> LandUnits, Observer, Motorized
// AdvancedSymbology::SymbolResultWatcher *watcher = new AdvancedSymbology::SymbolResultWatcher(d->m_cbRubSidc);
// connect(watcher, &AdvancedSymbology::SymbolResultWatcher::resultReady, [this, watcher]()
// {
// qWarning() << " lamdbadYYYYYYY" << watcher;
// QSharedPointer<AdvancedSymbology::SymbolResult> symResult = watcher->symbolResult();
// if (! symResult)
// return; // should NEVER happen! (Which object should have triggered the signal???)
// int idx = d->m_cbRubSidc->findData( QVariant::fromValue(watcher) );
// const SymbolImage &symImage = symResult->symbolImage();
// d->m_cbRubSidc->setItemIcon(idx, QPixmap::fromImage(symImage.image()) );
// });
// d->m_cbRubSidc->addItem(sidc, QVariant::fromValue(watcher) );
// watcher->setResult(dict.findSymbol(sidc));
QStringList sidcs;
sidcs += AdvancedSymbology::SidcCodec::encodeCivilEts("Pers_FW_BerFue"); // ETS
sidcs += AdvancedSymbology::SidcCodec::encodeComplete( AdvancedSymbology::SymbologyType::MIL2525D, "10051000001213030000"); // 01011000001213030000 -> LandUnits, Observer, Motorized
sidcs += AdvancedSymbology::SidcCodec::encodeComplete( AdvancedSymbology::SymbologyType::MIL2525D, "10031500001202000000"); // 01015000001202000000 -> 15 120200 LandEquip, Tank
sidcs += AdvancedSymbology::SidcCodec::encodeComplete( AdvancedSymbology::SymbologyType::MIL2525D, "10031500001110000000"); // 10031500001110000000 -> 15 111000 Missle Launcher
sidcs += AdvancedSymbology::SidcCodec::encodeComplete( AdvancedSymbology::SymbologyType::MIL2525D, "10032500002701000000"); // 25270100
sidcs += AdvancedSymbology::SidcCodec::encodeComplete( AdvancedSymbology::SymbologyType::MIL2525D, "10032500002718000000"); // 25271800
// For Hanna :
sidcs += AdvancedSymbology::SidcCodec::encodeComplete( AdvancedSymbology::SymbologyType::MIL2525D, "10011500001101000000"); // 15 110100 Soldier (rifle)
sidcs += AdvancedSymbology::SidcCodec::encodeComplete( AdvancedSymbology::SymbologyType::MIL2525D, "10011500001102000000"); // Soldier MG
sidcs += AdvancedSymbology::SidcCodec::encodeComplete( AdvancedSymbology::SymbologyType::MIL2525D, "10011500001202000000"); // Tank
sidcs += AdvancedSymbology::SidcCodec::encodeComplete( AdvancedSymbology::SymbologyType::MIL2525D, "10011500131202000000"); // Tank BT
sidcs += AdvancedSymbology::SidcCodec::encodeComplete( AdvancedSymbology::SymbologyType::MIL2525D, "10011500001408000000"); // Utility Vehicle CROSS-COUNTRY
sidcs += AdvancedSymbology::SidcCodec::encodeComplete( AdvancedSymbology::SymbologyType::MIL2525D, "10011000131211000000"); // Infantry
sidcs += AdvancedSymbology::SidcCodec::encodeComplete( AdvancedSymbology::SymbologyType::MIL2525D, "10011000131215000000"); // Sniper
// : For Hanna
// FLOT
sidcs += AdvancedSymbology::SidcCodec::encodeComplete( AdvancedSymbology::SymbologyType::MIL2525D, "10012500001401010000"); // 10032500001401030000 -> 24 140103 Maneuver Lines Direction of Attack
sidcs += AdvancedSymbology::SidcCodec::encodeComplete( AdvancedSymbology::SymbologyType::MIL2525D, "10012500001401020000"); // 10032500001401030000 -> 24 140103 Maneuver Lines Direction of Attack
sidcs += AdvancedSymbology::SidcCodec::encodeComplete( AdvancedSymbology::SymbologyType::MIL2525D, "10012500001401030000"); // 10032500001401030000 -> 24 140103 Maneuver Lines Direction of Attack
sidcs += AdvancedSymbology::SidcCodec::encodeComplete( AdvancedSymbology::SymbologyType::MIL2525D, "10012500001401040000"); // 10032500001401030000 -> 24 140103 Maneuver Lines Direction of Attack
sidcs += AdvancedSymbology::SidcCodec::encodeComplete( AdvancedSymbology::SymbologyType::MIL2525D, "10032500001401010000"); // 10032500001401030000 -> 24 140103 Maneuver Lines Direction of Attack
sidcs += AdvancedSymbology::SidcCodec::encodeComplete( AdvancedSymbology::SymbologyType::MIL2525D, "10032500001401020000"); // 10032500001401030000 -> 24 140103 Maneuver Lines Direction of Attack
sidcs += AdvancedSymbology::SidcCodec::encodeComplete( AdvancedSymbology::SymbologyType::MIL2525D, "10032500001401030000"); // 10032500001401030000 -> 24 140103 Maneuver Lines Direction of Attack
sidcs += AdvancedSymbology::SidcCodec::encodeComplete( AdvancedSymbology::SymbologyType::MIL2525D, "10032500001401040000"); // 10032500001401030000 -> 24 140103 Maneuver Lines Direction of Attack
sidcs += AdvancedSymbology::SidcCodec::encodeComplete( AdvancedSymbology::SymbologyType::MIL2525D, "10042500001401010000"); // 10032500001401030000 -> 24 140103 Maneuver Lines Direction of Attack
sidcs += AdvancedSymbology::SidcCodec::encodeComplete( AdvancedSymbology::SymbologyType::MIL2525D, "10042500001401020000"); // 10032500001401030000 -> 24 140103 Maneuver Lines Direction of Attack
sidcs += AdvancedSymbology::SidcCodec::encodeComplete( AdvancedSymbology::SymbologyType::MIL2525D, "10042500001401030000"); // 10032500001401030000 -> 24 140103 Maneuver Lines Direction of Attack
sidcs += AdvancedSymbology::SidcCodec::encodeComplete( AdvancedSymbology::SymbologyType::MIL2525D, "10042500001401040000"); // 10032500001401030000 -> 24 140103 Maneuver Lines Direction of Attack
sidcs += AdvancedSymbology::SidcCodec::encodeComplete( AdvancedSymbology::SymbologyType::MIL2525D, "10062500001401010000"); // 10032500001401030000 -> 24 140103 Maneuver Lines Direction of Attack
sidcs += AdvancedSymbology::SidcCodec::encodeComplete( AdvancedSymbology::SymbologyType::MIL2525D, "10062500001401020000"); // 10032500001401030000 -> 24 140103 Maneuver Lines Direction of Attack
sidcs += AdvancedSymbology::SidcCodec::encodeComplete( AdvancedSymbology::SymbologyType::MIL2525D, "10042500001401030000"); // 10032500001401030000 -> 24 140103 Maneuver Lines Direction of Attack
sidcs += AdvancedSymbology::SidcCodec::encodeComplete( AdvancedSymbology::SymbologyType::MIL2525D, "10042500001401040000"); // 10032500001401030000 -> 24 140103 Maneuver Lines Direction of Attack
for (const auto &sidc : std::as_const(sidcs))
{
QSharedPointer<AdvancedSymbology::SymbolResultWatcherComboxBox> srwCb(new AdvancedSymbology::SymbolResultWatcherComboxBox(d->m_cbRubSidc));
d->m_cbRubSidc->addItem(sidc, QVariant::fromValue(srwCb));
//AdvancedSymbology::SymbolResultWatcherComboxBox *srwCb;
//d->m_cbRubSidc->addItem(sidc, QVariant::fromValue(srwCb = new AdvancedSymbology::SymbolResultWatcherComboxBox(d->m_cbRubSidc)));
srwCb->setSymbolResult(dict.fetchSymbol(sidc));
}
}
break;
case AdvancedSymbology::SymbologyType::MIL2525C:
{
// Check Quartz
// Point Feature
// d->m_cbRubSidc -> addItem(QPixmap::fromImage(dict.symbolImageBySidc(sidc = QLatin1String("SFGPUCD---"), 64)), sidc);
// d->m_cbRubSidc -> addItem(QPixmap::fromImage(dict.symbolImageBySidc(sidc = QLatin1String("SUGPEWSM--"), 64)), sidc);
// d->m_cbRubSidc -> addItem(QPixmap::fromImage(dict.symbolImageBySidc(sidc = QLatin1String("GFGPGPWA--"), 64)), sidc);
d->m_cbRubSidc->insertSeparator(d->m_cbRubSidc->maxCount());
// Line Feature
// d->m_cbRubSidc -> addItem(QPixmap::fromImage(dict.symbolImageBySidc(sidc = QLatin1String("GFGPOLAA--"), 64)), sidc);
// d->m_cbRubSidc -> addItem(QPixmap::fromImage(dict.symbolImageBySidc(sidc = QLatin1String("GFMPOGL---"), 64)), sidc);
// d->m_cbRubSidc -> addItem(QPixmap::fromImage(dict.symbolImageBySidc(sidc = QLatin1String("GFMPOWCT--"), 64)), sidc);
// d->m_cbRubSidc -> addItem(QPixmap::fromImage(dict.symbolImageBySidc(sidc = QLatin1String("GFMPOWU---"), 64)), sidc);
// d->m_cbRubSidc -> addItem(QPixmap::fromImage(dict.symbolImageBySidc(sidc = QLatin1String("GFMPOADC--"), 64)), sidc);
// d->m_cbRubSidc -> addItem(QPixmap::fromImage(dict.symbolImageBySidc(sidc = QLatin1String("GFMPOEB---"), 64)), sidc);
// d->m_cbRubSidc -> addItem(QPixmap::fromImage(dict.symbolImageBySidc(sidc = QLatin1String("GFGPSLA---"), 64)), sidc);
// d->m_cbRubSidc -> addItem(QPixmap::fromImage(dict.symbolImageBySidc(sidc = QLatin1String("GFGPOLKGM-"), 64)), sidc);
// d->m_cbRubSidc -> addItem(QPixmap::fromImage(dict.symbolImageBySidc(sidc = QLatin1String("GFMPOFG---"), 64)), sidc);
// d->m_cbRubSidc -> addItem(QPixmap::fromImage(dict.symbolImageBySidc(sidc = QLatin1String("GHGPOLAGM-"), 64)), sidc);
// d->m_cbRubSidc -> addItem(QPixmap::fromImage(dict.symbolImageBySidc(sidc = QLatin1String("GHMPBDI---"), 64)), sidc);
// d->m_cbRubSidc -> addItem(QPixmap::fromImage(dict.symbolImageBySidc(sidc = QLatin1String("GHMPBCR---"), 64)), sidc);
d->m_cbRubSidc->insertSeparator(d->m_cbRubSidc->maxCount());
// Area Feature
// d->m_cbRubSidc -> addItem(QPixmap::fromImage(dict.symbolImageBySidc(sidc = QLatin1String("GFGPPM----"), 64)), sidc);
// d->m_cbRubSidc -> addItem(QPixmap::fromImage(dict.symbolImageBySidc(sidc = QLatin1String("GHMPOFA---"), 64)), sidc);
// d->m_cbRubSidc -> addItem(QPixmap::fromImage(dict.symbolImageBySidc(sidc = QLatin1String("GHMPOGF---"), 64)), sidc);
} break;
case AdvancedSymbology::SymbologyType::APP6B:
{
// Point Feature
// d->m_cbRubSidc -> addItem(QPixmap::fromImage(dict.symbolImageBySidc(sidc = QLatin1String("SFGPUCD---"), 64)), sidc);
// d->m_cbRubSidc -> addItem(QPixmap::fromImage(dict.symbolImageBySidc(sidc = QLatin1String("SUGPEWSM--"), 64)), sidc);
// d->m_cbRubSidc -> addItem(QPixmap::fromImage(dict.symbolImageBySidc(sidc = QLatin1String("GFOPID----"), 64)), sidc);
// d->m_cbRubSidc -> addItem(QPixmap::fromImage(dict.symbolImageBySidc(sidc = QLatin1String("SNGPUCRH--"), 64)), sidc);
d->m_cbRubSidc->insertSeparator(d->m_cbRubSidc->maxCount());
// Line Feature
// d->m_cbRubSidc -> addItem(QPixmap::fromImage(dict.symbolImageBySidc(sidc = QLatin1String("GFCPMOLAM-"), 64)), sidc);
// d->m_cbRubSidc -> addItem(QPixmap::fromImage(dict.symbolImageBySidc(sidc = QLatin1String("GFCPMOLDS-"), 64)), sidc);
// d->m_cbRubSidc -> addItem(QPixmap::fromImage(dict.symbolImageBySidc(sidc = QLatin1String("GFCPMOLDM-"), 64)), sidc);
// d->m_cbRubSidc -> addItem(QPixmap::fromImage(dict.symbolImageBySidc(sidc = QLatin1String("GHCPMOLI--"), 64)), sidc);
d->m_cbRubSidc->insertSeparator(d->m_cbRubSidc->maxCount());
// Area Feature
// d->m_cbRubSidc -> addItem(QPixmap::fromImage(dict.symbolImageBySidc(sidc = QLatin1String("GFCPMGASF-"), 64)), sidc);
// d->m_cbRubSidc -> addItem(QPixmap::fromImage(dict.symbolImageBySidc(sidc = QLatin1String("GFCPMDM---"), 64)), sidc);
// d->m_cbRubSidc -> addItem(QPixmap::fromImage(dict.symbolImageBySidc(sidc = QLatin1String("GFCPMDN---"), 64)), sidc);
} break;
case AdvancedSymbology::SymbologyType::APP6D:
// empty
break;
case AdvancedSymbology::SymbologyType::None:
// try civil (ETS_xxx
// d->m_cbRubSidc -> addItem(QPixmap::fromImage(dict.symbolImageBySidc(sidc = QLatin1String("ETS_StelleBerRaum"), 64)), sidc);
break;
} // switch (d->m_map->symbologyType())
QFont f = d->m_cbRubSidc->font();
f.setPixelSize(16);
d->m_cbRubSidc->setFont(f);
d->m_cbRubSidc->setIconSize(QSize(32, 32));
d->m_cbRubSidc->setEditable(true);
// connect(d->m_cbRubSidc, &QComboBox::editTextChanged, [=](const QString & text)
// {
// QVariant decoration = this->d->m_cbRubSidc->currentData( Qt::DecorationRole );
// AdvancedSymbology::SymbolDictionary & dict = this->d->m_mapImpl->symbolDictionary();
// if (dict.contains(text))
// {
// const QPixmap & icon = QPixmap::fromImage(dict.symbolImageBySidc(text,64));
// // why isn't there write excess to currentData??
// }
//// else; // why isn't there write excess to currentData??
// } );
rubberbandLayout->addWidget(d->m_cbRubSidc, 0, 0, 2, 2);
connect(d->m_cbRubSidc, &QComboBox::currentTextChanged, this, [this]()
{
if (d->m_cbRubSidc->currentText().length() > 15)
d->m_cbRubSidc->setStyleSheet(QLatin1String("QLineEdit#SIDC { background-color: red; color: #000; }"));
else
d->m_cbRubSidc->setStyleSheet(QLatin1String("QLineEdit#SIDC { background-color: white; color: #000; }"));
}); /* connect */
QPushButton *pbCreatePointSymbol = new QPushButton(QLatin1String("Create Point Symbol"), w);
pbCreatePointSymbol->setToolTip(d->m_leSidc->toolTip());
rubberbandLayout->addWidget(pbCreatePointSymbol, 0, 2);
connect(pbCreatePointSymbol, &QPushButton::clicked,
this , &FunctionDialog::onParticipantGetPosition);
QPushButton *pbCreateRubberband = new QPushButton(QLatin1String("Create Rubberband"), w);
pbCreateRubberband->setToolTip(d->m_leSidc->toolTip());
rubberbandLayout->addWidget(pbCreateRubberband, 1, 2);
connect(pbCreateRubberband, &QPushButton::clicked, this, [this]()
{
RB::Rubberband *rubberband = d->m_mapInterface->rubberbandFactory().createSymbol(d->m_cbRubSidc->currentText());
if (rubberband == nullptr)
qWarning() << "Creating rubberband failed, may be wrong sidc (" << d->m_cbRubSidc->currentText() << ")";
else
{
QObject::connect(rubberband, &RB::Rubberband::apply, this, &FunctionDialog::onRubberbandApply);
QObject::connect(rubberband, &RB::Rubberband::abort, this, &FunctionDialog::onRubberbandAbort);
}
});
unsigned int rubberbandTests = 2;
QPushButton *pbTestPointClusterRubber = new QPushButton(QLatin1String("Test PointCluster Rubberband"), w);
rubberbandLayout->addWidget(pbTestPointClusterRubber, rubberbandTests++, 0);
connect(pbTestPointClusterRubber, &QPushButton::clicked, this, [this]()
{
RB::RubberbandPointCluster *rubberband = d->m_mapInterface->rubberbandFactory().create<RB::RubberbandPointCluster>();
if (rubberband == nullptr)
qWarning() << "Creating rubberband point cluster failed";
else
{
QObject::connect(rubberband, &RB::Rubberband::apply, this, &FunctionDialog::onRubberbandApply);
QObject::connect(rubberband, &RB::Rubberband::abort, this, &FunctionDialog::onRubberbandAbort);
}
});
//--------------------------------------
QPushButton *pbTestMultiPointRubber = new QPushButton(QLatin1String("Multipoint RB"), w);
rubberbandLayout->addWidget(pbTestMultiPointRubber, rubberbandTests++, 0);
connect(pbTestMultiPointRubber, &QPushButton::clicked, this, [this]()
{
RB::RubberbandMultiPointFeature *rubberband = d->m_mapInterface->rubberbandFactory().create<RB::RubberbandMultiPointFeature>();
if (rubberband == nullptr)
qWarning() << "Creating rubberband multi points feature failed";
else
{
rubberband -> enableClosed(false);
rubberband -> minimumPointCount(3);
rubberband -> maximumPointCount(6);
rubberband -> maximumLength(20000); // will not be checked for closed lines
rubberband -> maximumSegmentLength(5000);
QObject::connect(rubberband, &RB::Rubberband::apply, this, &FunctionDialog::onRubberbandApply);
QObject::connect(rubberband, &RB::Rubberband::abort, this, &FunctionDialog::onRubberbandAbort);
}
});
//--------------------------------------
QPushButton *pbTestMultiEllipseRubber = new QPushButton(QLatin1String("MultiEllipse RB (BoobyTrap) from Scratch"), w);
rubberbandLayout->addWidget(pbTestMultiEllipseRubber, rubberbandTests++, 0);
connect(pbTestMultiEllipseRubber, &QPushButton::clicked, this, [this]()
{
// FIRST RubberbandMultiEllipseFeature
RB::RubberbandMultiEllipseFeature *rubberband = d->m_mapInterface->rubberbandFactory().create<RB::RubberbandMultiEllipseFeature>();
if (rubberband == nullptr)
qWarning() << "Creating rubberband multi CIRCLE feature failed";
else
{
rubberband->minimumRadiusCount(2);
rubberband->maximumRadiusCount(2);
using RWC = RB::RubberbandMultiEllipseFeature::RadiusWithContraints;
RWC radiusWithContraints1(0, 750, 1250);
RWC radiusWithContraints2(0, 1750, 2250);
rubberband->prepareFixedNumberOfRadiiWithConstraints({radiusWithContraints1, radiusWithContraints2});
#define CIRCLE_CONTRAINT
#ifdef CIRCLE_CONTRAINT
rubberband->constrainQuadratic(true);
#endif
//rubberband -> maximumLength(20000); // will not be checked for closed lines
//rubberband -> maximumSegmentLength(5000);
QObject::connect(rubberband, &RB::Rubberband::apply, this, &FunctionDialog::onRubberbandApply);
QObject::connect(rubberband, &RB::Rubberband::abort, this, &FunctionDialog::onRubberbandAbort);
}
});
//--------------------------------------
QPushButton *pbTestMultiEllipseRubberPreDefined = new QPushButton(QLatin1String("MultiEllipse RB (BoobyTrap) predefined Start"), w);
rubberbandLayout->addWidget(pbTestMultiEllipseRubberPreDefined, rubberbandTests++, 0);
connect(pbTestMultiEllipseRubberPreDefined, &QPushButton::clicked, this, [this]()
{
RB::RubberbandMultiEllipseFeature *rubberbandForPreperation = d->m_mapInterface->rubberbandFactory().create<RB::RubberbandMultiEllipseFeature>();
if (rubberbandForPreperation == nullptr)
qWarning() << "Creating rubberband multi CIRCLE feature failed";
else
{
// start with GUEZ-typical BoobyTrap:
QPointF centerOfMapView = d->m_mapInterface->centerPoint();
Q_UNUSED(centerOfMapView);
//const QVector<QPointF> radii( { {1000, 1000}, {1500, 1500} } );
// rubberband->setCenterAndRadii(centerOfMapView, RB::CoordinateSystem::Geo, radii);
// rubberbandForPreperation->prepareFixedNumberOfRadii(radii);
RB::RubberbandMultiEllipseFeature::RadiusWithContraints radiusWithContraints1(1000, 1000, 1000);
RB::RubberbandMultiEllipseFeature::RadiusWithContraints radiusWithContraints2(3000, 2750, 3250);
rubberbandForPreperation->prepareFixedNumberOfRadiiWithConstraints({radiusWithContraints1, radiusWithContraints2});
rubberbandForPreperation->constrainQuadratic(true);
rubberbandForPreperation->enableSector(true);
double aStartRad=0, aEndRad=0;
double angle = 90;
double rot = 0;
getSectorStartEnd(angle, rot, aStartRad, aEndRad);
rubberbandForPreperation->setSectorStart(std::sin(aStartRad), std::cos(aStartRad));
rubberbandForPreperation->setSectorEnd(std::sin(aEndRad), std::cos(aEndRad));
rubberbandForPreperation->setSectorAngleFixed(true);
QObject::connect(rubberbandForPreperation, &RB::Rubberband::apply, this, &FunctionDialog::onRubberbandApply);
QObject::connect(rubberbandForPreperation, &RB::Rubberband::abort, this, &FunctionDialog::onRubberbandAbort);
}
});
QPushButton *pbTestMultiPointFillRubber = new QPushButton(QLatin1String("Filled Multipoint RB"), w);
rubberbandLayout->addWidget(pbTestMultiPointFillRubber, rubberbandTests++, 0);
connect(pbTestMultiPointFillRubber, &QPushButton::clicked, this, [this]()
{
RB::RubberbandMultiPointFeature *rubberband = d->m_mapInterface->rubberbandFactory().create<RB::RubberbandMultiPointFeature>();
if (rubberband == nullptr)
qWarning() << "Creating filled rubberband multi points feature failed";
else
{
rubberband -> enableClosed(true);
rubberband -> setFillColor(QColor(QLatin1String("teal")));
rubberband -> maximumLength(20000); // will not be checked for closed lines
rubberband -> maximumSegmentLength(5000);
QObject::connect(rubberband, &RB::Rubberband::apply, this, &FunctionDialog::onRubberbandApply);
QObject::connect(rubberband, &RB::Rubberband::abort, this, &FunctionDialog::onRubberbandAbort);
}
});
QPushButton *pbTestSmoothLineRubber = new QPushButton(QLatin1String("Smooth Line RB"), w);
rubberbandLayout->addWidget(pbTestSmoothLineRubber, rubberbandTests++, 0);
connect(pbTestSmoothLineRubber, &QPushButton::clicked, this, [this]()
{
RB::RubberbandSmoothLine *rubberband = d->m_mapInterface->rubberbandFactory().create<RB::RubberbandSmoothLine>();
if (rubberband == nullptr)
qWarning() << "Creating rubberband smooth line failed";
else
{
QObject::connect(rubberband, &RB::Rubberband::apply, this, &FunctionDialog::onRubberbandApply);
QObject::connect(rubberband, &RB::Rubberband::abort, this, &FunctionDialog::onRubberbandAbort);
}
});
QPushButton *pbTestSmoothFillRubber = new QPushButton(QLatin1String("Filled Smooth Line RB"), w);
rubberbandLayout->addWidget(pbTestSmoothFillRubber, rubberbandTests++, 0);
connect(pbTestSmoothFillRubber, &QPushButton::clicked, this, [this]()
{
RB::RubberbandSmoothLine *rubberband = d->m_mapInterface->rubberbandFactory().create<RB::RubberbandSmoothLine>();
if (rubberband == nullptr)
qWarning() << "Creating filled rubberband smooth line failed";
else
{
rubberband->enableClosed(true);
rubberband->setFillColor(QColor(QLatin1String("olive")));
QObject::connect(rubberband, &RB::Rubberband::apply, this, &FunctionDialog::onRubberbandApply);
QObject::connect(rubberband, &RB::Rubberband::abort, this, &FunctionDialog::onRubberbandAbort);
}
});
QPushButton *pbTestCorridorRubber = new QPushButton(QLatin1String("Corridor RB(Boundary)"), w);
rubberbandLayout->addWidget(pbTestCorridorRubber, rubberbandTests++, 0);
connect(pbTestCorridorRubber, &QPushButton::clicked, this, [this]()
{
RB::RubberbandCorridor *rubberband = d->m_mapInterface->rubberbandFactory().create<RB::RubberbandCorridor>();
if (rubberband == nullptr)
qWarning() << "Creating rubberband corridors failed";
else
{
QObject::connect(rubberband, &RB::Rubberband::apply, this, &FunctionDialog::onRubberbandApply);
QObject::connect(rubberband, &RB::Rubberband::abort, this, &FunctionDialog::onRubberbandAbort);
}
});
pbTestCorridorRubber = new QPushButton(QLatin1String("Corridor RB (Centerl., W = 50000)"), w);
rubberbandLayout->addWidget(pbTestCorridorRubber, rubberbandTests++, 0);
connect(pbTestCorridorRubber, &QPushButton::clicked, this, [this]()
{
RB::RubberbandCorridor *rubberband = d->m_mapInterface->rubberbandFactory().create(RB::RubberbandCorridor::InputMode::InputCenterLine, 50000);
if (rubberband == nullptr)
qWarning() << "Creating rubberband corridors failed";
else
{
rubberband->setCorridorFillColor(QColor(QLatin1String("orange")));
rubberband -> minimumPointCount(3);
rubberband -> maximumPointCount(6);
rubberband -> minimumCorridorWidth(400);
rubberband -> maximumCorridorWidth(1000);
rubberband -> maximumLength(7000);
rubberband -> maximumSegmentLength(2000);
QObject::connect(rubberband, &RB::Rubberband::apply, this, &FunctionDialog::onRubberbandApply);
QObject::connect(rubberband, &RB::Rubberband::abort, this, &FunctionDialog::onRubberbandAbort);
}
});
QPushButton *pbTestSquareRubber = new QPushButton(QLatin1String("Square RB"), w);
rubberbandLayout->addWidget(pbTestSquareRubber, rubberbandTests++, 0);
connect(pbTestSquareRubber, &QPushButton::clicked, this, [this]()
{
RB::RubberbandRectangle *rubberband = d->m_mapInterface->rubberbandFactory().create<RB::RubberbandRectangle>();
if (rubberband == nullptr)
qWarning() << "Creating rubberband rectangle failed";
else
{
rubberband->constrainQuadratic(true);
QObject::connect(rubberband, &RB::Rubberband::apply, this, &FunctionDialog::onRubberbandApply);
QObject::connect(rubberband, &RB::Rubberband::abort, this, &FunctionDialog::onRubberbandAbort);
}
});
QPushButton *pbTestRectangleRubber = new QPushButton(QLatin1String("Rectangle RB"), w);
rubberbandLayout->addWidget(pbTestRectangleRubber, rubberbandTests++, 0);
connect(pbTestRectangleRubber, &QPushButton::clicked, this, [this]()
{
RB::RubberbandRectangle *rubberband = d->m_mapInterface->rubberbandFactory().create<SituationMap::RB::RubberbandRectangle>();
if (rubberband == nullptr)
qWarning() << "Creating rubberband rectangle failed";
else
{
rubberband->minWidth(5000);
rubberband->maxWidth(2000000);
rubberband->minHeight(5000);
rubberband->maxHeight(1000000);
QObject::connect(rubberband, &RB::Rubberband::apply, this, &FunctionDialog::onRubberbandApply);
QObject::connect(rubberband, &RB::Rubberband::abort, this, &FunctionDialog::onRubberbandAbort);
}
});
QPushButton *pbTestRectangleOrthoRubber = new QPushButton(QLatin1String("Rectangle Ortho RB"), w);
rubberbandLayout->addWidget(pbTestRectangleOrthoRubber, rubberbandTests++, 0);
connect(pbTestRectangleOrthoRubber, &QPushButton::clicked, this, [this]()
{
RB::RubberbandRectangle *rubberband = d->m_mapInterface->rubberbandFactory().create<SituationMap::RB::RubberbandRectangle>();
if (rubberband == nullptr)
qWarning() << "Creating rubberband rectangle failed";
else
{
rubberband->constrainOrthogonal(true);
QObject::connect(rubberband, &RB::Rubberband::apply, this, &FunctionDialog::onRubberbandApply);
QObject::connect(rubberband, &RB::Rubberband::abort, this, &FunctionDialog::onRubberbandAbort);
}
});
QPushButton *pbTestRectangleParameter = new QPushButton(QLatin1String("Rectangle Parameter"), w);
rubberbandLayout->addWidget(pbTestRectangleParameter, rubberbandTests++, 0);
connect(pbTestRectangleParameter, &QPushButton::clicked, this, [this]()
{
RB::RubberbandRectangle *rubberband = d->m_mapInterface->rubberbandFactory().create<SituationMap::RB::RubberbandRectangle>();
if (rubberband == nullptr)
qWarning() << "Creating rubberband rectangle failed";
else
{
SituationMap::CoordTranslationFunctor *cf = d->m_mapInterface->coordTranslationFunctor();
QPointF bottomLeft = d->m_mapInterface->centerPoint();
if (cf) bottomLeft = cf->geographicToMap(bottomLeft);
rubberband->buildRectangleRelativeToBottomLeftCorner(bottomLeft, 3000, 1500, QPoint(-1, 0), SituationMap::RB::CoordinateSystem::Map);
QObject::connect(rubberband, &RB::Rubberband::apply, this, &FunctionDialog::onRubberbandApply);
QObject::connect(rubberband, &RB::Rubberband::abort, this, &FunctionDialog::onRubberbandAbort);
}
});
QPushButton *pbTestEllipseRubber = new QPushButton(QLatin1String("Ellipse RB"), w);
rubberbandLayout->addWidget(pbTestEllipseRubber, rubberbandTests++, 0);
connect(pbTestEllipseRubber, &QPushButton::clicked, this, [this]()
{
d->m_mapInterface->rubberbandFactory().allowMultipleRubberbands(true);
RB::RubberbandEllipse *rubberband = d->m_mapInterface->rubberbandFactory().create<RB::RubberbandEllipse>();
d->m_mapInterface->rubberbandFactory().allowMultipleRubberbands(false);
if (rubberband == nullptr)
qWarning() << "Creating rubberband ellipse failed";
else
{
if (rubberband->rubberbandIsAlive())
{
QObject::connect(rubberband, &RB::Rubberband::apply, this, &FunctionDialog::onRubberbandApply);
QObject::connect(rubberband, &RB::Rubberband::abort, this, &FunctionDialog::onRubberbandAbort);
}
else
{
qWarning() << "Creating rubberband ellipse is not alive";
rubberband->deleteMySelf();
}
}
});
QPushButton *pbTestArrowRubber = new QPushButton(QLatin1String("Arrow RB"), w);
rubberbandLayout->addWidget(pbTestArrowRubber, rubberbandTests++, 0);
connect(pbTestArrowRubber, &QPushButton::clicked, this, [this]()
{
d->m_mapInterface->rubberbandFactory().allowMultipleRubberbands(true);
RB::RubberbandArrow *rubberband = d->m_mapInterface->rubberbandFactory().create<RB::RubberbandArrow>();
d->m_mapInterface->rubberbandFactory().allowMultipleRubberbands(false);
if (rubberband == nullptr)
qWarning() << "Creating rubberband arrow failed";
else
{
if (rubberband->rubberbandIsAlive())
{
QObject::connect(rubberband, &RB::Rubberband::apply, this, &FunctionDialog::onRubberbandApply);
QObject::connect(rubberband, &RB::Rubberband::abort, this, &FunctionDialog::onRubberbandAbort);
}
else
{
qWarning() << "Creating rubberband arrow is not alive";
rubberband->deleteMySelf();
}
}
});
QPushButton *pbTestFreeHdRubber = new QPushButton(QLatin1String("Freehand RB"), w);
rubberbandLayout->addWidget(pbTestFreeHdRubber, rubberbandTests++, 0);
connect(pbTestFreeHdRubber, &QPushButton::clicked, this, [this]()
{
RB::RubberbandFreeHand *rubberband = d->m_mapInterface->rubberbandFactory().create<RB::RubberbandFreeHand>();
if (rubberband == nullptr)
qWarning() << "Creating rubberband freehand failed";
else
{
rubberband->setFillColor(QColor(0, 0, 0, 0));
if (rubberband->rubberbandIsAlive())
{
QObject::connect(rubberband, &RB::Rubberband::apply, this, &FunctionDialog::onRubberbandApply);
QObject::connect(rubberband, &RB::Rubberband::abort, this, &FunctionDialog::onRubberbandAbort);
}
else
{
qWarning() << "Creating rubberband freehand is not alive";
rubberband->deleteMySelf();
}
}
});
rubberbandTests = 2;
QPushButton *pbTestRubberDefineArrow = new QPushButton(QLatin1String("Define Arrow"), w);
rubberbandLayout->addWidget(pbTestRubberDefineArrow, rubberbandTests++, 1);
connect(pbTestRubberDefineArrow, &QPushButton::clicked, this, &FunctionDialog::onRubberbandDefineArrow);
QPushButton *pbTestRubberDefineEllipse = new QPushButton(QLatin1String("Define Ellipse"), w);
rubberbandLayout->addWidget(pbTestRubberDefineEllipse, rubberbandTests++, 1);
connect(pbTestRubberDefineEllipse, &QPushButton::clicked, this, &FunctionDialog::onRubberbandDefineEllipse);
QPushButton *pbTestRubberCoordinates = new QPushButton(QLatin1String("RB Coordinates"), w);
rubberbandLayout->addWidget(pbTestRubberCoordinates, rubberbandTests++, 1);
connect(pbTestRubberCoordinates, &QPushButton::clicked, this, &FunctionDialog::onRubberbandCheckCoordinates);
QPushButton *pbTestRectCoordinates = new QPushButton(QLatin1String("Rectangle Coord."), w);
rubberbandLayout->addWidget(pbTestRectCoordinates, rubberbandTests++, 1);
connect(pbTestRectCoordinates, &QPushButton::clicked, this, &FunctionDialog::onRectCheckCoordinates);
QPushButton *pbTestRubberStateSelect = new QPushButton(QLatin1String("State Select RB"), w);
rubberbandLayout->addWidget(pbTestRubberStateSelect, rubberbandTests++, 1);
connect(pbTestRubberStateSelect, &QPushButton::clicked, this, &FunctionDialog::onRubberbandStateSelect);
QPushButton *pbTestRubberDefineBoobyTrap = new QPushButton(QLatin1String("BoobyTrap Sector RB"), w);
rubberbandLayout->addWidget(pbTestRubberDefineBoobyTrap, rubberbandTests++, 1);
connect(pbTestRubberDefineBoobyTrap, &QPushButton::clicked, this, &FunctionDialog::onRubberbandBoobyTrapSector);
rubberbandTests = 2;
QPushButton *pbTestTowInOneRubberband = new QPushButton(QLatin1String("TwoInOne"), w);
rubberbandLayout->addWidget(pbTestTowInOneRubberband, rubberbandTests++, 3);
connect(pbTestTowInOneRubberband, &QPushButton::clicked, this, &FunctionDialog::onRubberbandTwoInOne);
} /* FunctionDialog::addRubberbandTab */
void FunctionDialog::onRubberbandApply(RB::RubberbandBase *rubberband)
{
qCritical() << LOGFUNCTION << " rubberband = " << rubberband;
RB::RubberbandPointFeature *rubberbandPoint = dynamic_cast<RB::RubberbandPointFeature *>(rubberband);
RB::RubberbandPointCluster *rubberbandClust = dynamic_cast<RB::RubberbandPointCluster *>(rubberband);
RB::RubberbandRectangle *rubberbandRect = dynamic_cast<RB::RubberbandRectangle *>(rubberband);
RB::RubberbandEllipse *rubberbandElli = dynamic_cast<RB::RubberbandEllipse *>(rubberband);
RB::RubberbandMultiPointFeature *rubberbandMFeat = dynamic_cast<RB::RubberbandMultiPointFeature *>(rubberband);
RB::RubberbandMultiEllipseFeature *rubberbandMEllipseFeat = dynamic_cast<RB::RubberbandMultiEllipseFeature *>(rubberband);
RB::RubberbandCorridor *rubberbandCorr = dynamic_cast<RB::RubberbandCorridor *>(rubberband);
RB::RubberbandSmoothLine *rubberbandSmooth = dynamic_cast<RB::RubberbandSmoothLine *>(rubberband);
RB::RubberbandArrow *rubberbandArrow = dynamic_cast<RB::RubberbandArrow *>(rubberband);
RB::RubberbandFreeHand *rubberbandFreehand = dynamic_cast<RB::RubberbandFreeHand *>(rubberband);
if (rubberbandPoint) qCritical() << LOGFUNCTION << "point feature rubberband";
if (rubberbandClust) qCritical() << LOGFUNCTION << "point cluster rubberband";
if (rubberbandRect) qCritical() << LOGFUNCTION << "rectangle rubberband";
if (rubberbandElli) qCritical() << LOGFUNCTION << "ellipse rubberband";
if (rubberbandFreehand) qCritical() << LOGFUNCTION << "freehand rubberband";
if (rubberbandMEllipseFeat) qCritical() << LOGFUNCTION << "multiCircle rubberband";
if (rubberbandMFeat)
{
if (rubberbandCorr) qDebug() << LOGFUNCTION << "corridor rubberband";
else if (rubberbandSmooth) qDebug() << LOGFUNCTION << "smooth line rubberband";
else qDebug() << LOGFUNCTION << "multi point feature rubberband";
}
qCritical() << LOGFUNCTION << " Count of Coordinates " << rubberband->coordinateCount();
if (rubberbandMEllipseFeat)
{
QPointF centerCoord = rubberbandMEllipseFeat->centerCoordinate(RB::CoordinateSystem::Map);
const QVector<QPointF> &radii = rubberbandMEllipseFeat->radii();
qCritical() << LOGFUNCTION << " FIRST centerCoord " << centerCoord << ", radii = " << radii;
qCritical() << LOGFUNCTION << " FIRST Sector sectorStart " << rubberbandMEllipseFeat->sectorStart();
qCritical() << LOGFUNCTION << " FIRST Sector sectorEnd " << rubberbandMEllipseFeat->sectorEnd();
qCritical() << LOGFUNCTION << " FIRST Sector sectorStartDegMath " << rubberbandMEllipseFeat->sectorStartDegMath();
qCritical() << LOGFUNCTION << " FIRST Sector sectorEndDegMath " << rubberbandMEllipseFeat->sectorEndDegMath();
RB::RubberbandMultiEllipseFeature *rubberbandReCreate = d->m_mapInterface->rubberbandFactory().create<RB::RubberbandMultiEllipseFeature>();
if (!rubberbandReCreate)
qWarning() << "Creating rubberband multi CIRCLE feature failed";
else
{
rubberbandReCreate->setAutoDelete(true);
#ifdef CIRCLE_CONTRAINT
rubberbandReCreate->constrainQuadratic(true);
#endif
QVector<RB::RubberbandMultiEllipseFeature::RadiusWithContraints> radiiWithConstraints;
radiiWithConstraints.reserve(2);
for (const QPointF &item: std::as_const(radii))
{
RB::RubberbandMultiEllipseFeature::RadiusWithContraints radiusWC;
radiusWC.m_radius = item.x();
radiusWC.m_minRadius = radiusWC.m_radius-250;
radiusWC.m_maxRadius = radiusWC.m_radius+250;
radiiWithConstraints.append(radiusWC);
}
rubberbandReCreate->setCenterAndRadii2(centerCoord, RB::CoordinateSystem::Map,
radiiWithConstraints);
QList<double> rotation = {0, 45, 90, -45, 180, 270, 315, 360};
double angle = 90; // oeffnungsWinkel
double rot = rotation.at(0); // clockwise
double aStartRad=0, aEndRad=0;
getSectorStartEnd(angle, rot, aStartRad, aEndRad);
// qCritical()<< "[FORWARD] rotation: " << rot
// << ", angle start: "<< aStartRad << "[rad] (" << (aStartRad*LtsCoordTrans::rad2deg()) << "[deg])"
// << ", angle end: "<< aEndRad << "[rad] (" << (aEndRad*LtsCoordTrans::rad2deg()) << "[deg])";
rubberbandReCreate->setSectorStart(std::sin(aStartRad), std::cos(aStartRad));
rubberbandReCreate->setSectorEnd(std::sin(aEndRad), std::cos(aEndRad));
rubberbandReCreate->setSectorAngleFixed(true);
QObject::connect(rubberbandReCreate, &RB::Rubberband::apply, this, [](RB::RubberbandBase *rubberband)
{
RB::RubberbandMultiEllipseFeature *rubberbandMCircleFeat = dynamic_cast<RB::RubberbandMultiEllipseFeature *>(rubberband);
if (!rubberbandMCircleFeat)
return;
QPointF centerCoord = rubberbandMCircleFeat->centerCoordinate(RB::CoordinateSystem::Map);
const QVector<QPointF> &radii = rubberbandMCircleFeat->radii();
qCritical() << LOGFUNCTION << " SECOND centerCoord " << centerCoord << ", radii = " << radii;
qCritical() << LOGFUNCTION << " SECOND Sector sectorStart " << rubberbandMCircleFeat->sectorStart();
qCritical() << LOGFUNCTION << " SECOND Sector sectorEnd " << rubberbandMCircleFeat->sectorEnd();
});
//// QObject::connect(rubberband, &RB::Rubberband::apply, this, &FunctionDialog::onRubberbandApply);
//// QObject::connect(rubberband, &RB::Rubberband::abort, this, &FunctionDialog::onRubberbandAbort);
}
}
QVector<QPointF> vertexList = rubberband->coordinateVector();
bool constrainQuad = false;
bool constrainOrtho = false;
if (rubberbandRect)
{
constrainQuad = rubberbandRect->constrainQuadratic();
constrainOrtho = rubberbandRect->constrainOrthogonal();
QPointF geoPoint = rubberband->singleCoordinate(0, RB::CoordinateSystem::Geo);
qDebug() << LOGFUNCTION << "Rectangle center : geo coordinate " << geoPoint;
qDebug() << LOGFUNCTION << "Vertexlist sim coordinates " << vertexList;
d->m_mapInterface->geoCoordinateToViewPortWindowPoint(geoPoint);
}
else
{
for (unsigned int i = 0; i < rubberband->coordinateCount(); ++i)
{
QPointF geoPoint = rubberband->singleCoordinate(i, RB::CoordinateSystem::Geo);
qDebug() << LOGFUNCTION << " " << i << " geo coordinate " << geoPoint;
}
}
if (rubberbandFreehand)
{
rubberband->deleteMySelf();
return;
}
if (rubberbandCorr)
{
QVector<QPointF> bufferVertexList;
if (rubberbandCorr->bufferPolygon(bufferVertexList, RB::CoordinateSystem::Map))
{
static SituationMap::RefPointer<SituationMap::Polygon> bufferPolygon;
if (bufferPolygon.valid()) bufferPolygon->removeMySelf();
bufferPolygon = d->m_mapInterface->objectFactory().create<SituationMap::Polygon>(QStringLiteral("FunctionDialog"), QStringLiteral("BufferPolygon"));
if (bufferPolygon.valid())
{
bufferPolygon->setIdentifier(QLatin1String("BufferPolygon"));
bufferPolygon->setVisibility(true);
QColor magenta(Qt::magenta);
QColor magentaAlpha(Qt::magenta);
magentaAlpha.setAlpha(100);
bufferPolygon->setLineStyle(LineStyle(magenta, 2, LinePattern::Solid));
bufferPolygon->setFillStyle(FillStyle(magentaAlpha, FillPattern::Solid));
SituationMap::PositionCont posCont;
posCont.reserve(bufferVertexList.size());
for (const auto &bufferPoint : std::as_const(bufferVertexList))
{
posCont << Point3D::fromQPointF(bufferPoint);
qDebug() << fixed << qSetRealNumberPrecision(2) << LOGFUNCTION << "buffer coordinate : " << bufferPoint ;
}
bufferPolygon->setPositionsTranslated(posCont); // use map coordinates to print the coordinate values
bufferPolygon->updateView();
QTimer::singleShot(10000, this, [this]()
{
if (bufferPolygon.valid()) bufferPolygon->removeMySelf();
bufferPolygon = nullptr;
this->update();
});
}
else qDebug() << LOGFUNCTION << " creating polygon to visualize buffer polygon failed";
}
else qWarning() << LOGFUNCTION << "RubberbandCorridor::bufferPolygon failed";
}
static QString rubberTypeLabel;
auto slotFunc = [ = ](RB::RubberbandBase * rubberband)
{
qDebug() << LOGFUNCTION << "end of " << rubberTypeLabel << " rubberband";
qDebug() << LOGFUNCTION << "Vertexlist sim coordinates " << rubberband->coordinateVector();
for (unsigned int i = 0; i < rubberband->coordinateCount(); ++i)
{
QPointF simPoint = rubberband->singleCoordinate(i, RB::CoordinateSystem::Geo);
qDebug() << LOGFUNCTION << " " << i << " sim coordinate " << simPoint;
}
rubberband->deleteMySelf();
};
if (rubberbandRect)
{
if (rubberbandElli)
{
rubberTypeLabel = QLatin1String("ellpise");
if (rubberbandElli->hasSector())
{
double rotation=0;
double openAngle = 0;
getRotationAndAngle(rubberbandElli->sectorStart(),rubberbandElli->sectorEnd(), rotation, openAngle);
}
rubberbandRect = d->m_mapInterface->rubberbandFactory().create<RB::RubberbandEllipse>();
}
else
{
rubberTypeLabel = QLatin1String("rectangle");
rubberbandRect = d->m_mapInterface->rubberbandFactory().create<RB::RubberbandRectangle>();
}
if (rubberbandRect == nullptr)
qWarning() << "Creating rubberband " << rubberTypeLabel << " failed";
else
{
rubberbandRect -> setCoordinateVector(vertexList);
rubberbandRect -> constrainQuadratic(constrainQuad);
rubberbandRect -> constrainOrthogonal(constrainOrtho);
rubberbandRect -> setDrawColor(QColor(QLatin1String("blue")));
connect(rubberbandRect, &RB::Rubberband::apply, slotFunc);
connect(rubberbandRect, &RB::Rubberband::abort, slotFunc);
}
}
bool mRbands = d->m_mapInterface->rubberbandFactory().allowMultipleRubberbands();
d->m_mapInterface->rubberbandFactory().allowMultipleRubberbands(true);
{
if (rubberbandMFeat)
{
RB::RubberbandMultiPointFeature *rbandMPF = nullptr;
if (rubberbandCorr)
{
RB::RubberbandCorridor *rbandCorr = d->m_mapInterface->rubberbandFactory().create(rubberbandCorr->isEnabledInputBoundary() ? RB::RubberbandCorridor::InputMode::InputBoundary
: RB::RubberbandCorridor::InputMode::InputCenterLine);
if (rbandCorr != nullptr)
{
if (rubberbandCorr->isEnabledInputBoundary())
{
rbandCorr->setCoordinateVector(vertexList);
// rbandCorr->setDrawColor(QColor(QLatin1String("blue")));
// rbandCorr->setCorridorFillColor(QColor(QLatin1String("aqua")));
}
else
{
rbandCorr->setCoordinateVectorWidth(vertexList, rubberbandCorr->corridorWidth());
// rbandCorr->setDrawColor(QColor(QLatin1String("blue")));
// rbandCorr->setCorridorFillColor(QColor(QLatin1String("red")));
}
rubberTypeLabel = QLatin1String("corridor");
connect(rbandCorr, &RB::Rubberband::apply, slotFunc);
connect(rbandCorr, &RB::Rubberband::abort, slotFunc);
}
else qWarning() << "Creating rubberband corridor failed";
}
else if (rubberbandSmooth)
{
RB::RubberbandSmoothLine *rbandSmooth = d->m_mapInterface->rubberbandFactory().create<RB::RubberbandSmoothLine>();
if (rbandSmooth != nullptr)
{
rbandMPF = rbandSmooth;
rubberTypeLabel = QLatin1String("smooth line");
}
else qWarning() << "Creating rubberband smooth line failed";
}
else if (rubberbandArrow)
{
RB::RubberbandArrow *rbandArrow = d->m_mapInterface->rubberbandFactory().create<RB::RubberbandArrow>();
if (rbandArrow != nullptr)
{
rbandArrow->setCoordinateVectorArrow(vertexList, rubberbandArrow->arrowHalfWidth(), rubberbandArrow->arrowLength());
rbandArrow->setDrawColor(QColor(QLatin1String("purple")));
rubberTypeLabel = QLatin1String("arrow");
connect(rbandArrow, &RB::Rubberband::apply, slotFunc);
connect(rbandArrow, &RB::Rubberband::abort, slotFunc);
}
else qWarning() << "Creating rubberband arrow failed";
}
else
{
rbandMPF = d->m_mapInterface->rubberbandFactory().create<RB::RubberbandMultiPointFeature>();
rubberTypeLabel = QLatin1String("multi point feature");
if (rbandMPF == nullptr)
qWarning() << "Creating rubberband multi point feature failed";
}
if (rbandMPF != nullptr)
{
rbandMPF -> setCoordinateVector(vertexList);
rbandMPF -> enableClosed(rubberbandMFeat->isClosedEnabled());
rbandMPF -> setDrawColor(QColor(QLatin1String("maroon")));
rbandMPF -> setFillColor(QColor(QLatin1String("lime")));
rbandMPF -> setPreviewSidc(rubberbandMFeat->previewSidc());
connect(rbandMPF, &RB::Rubberband::apply, slotFunc);
connect(rbandMPF, &RB::Rubberband::abort, slotFunc);
}
}
if (rubberbandClust)
{
RB::RubberbandPointCluster *rbandClust = d->m_mapInterface->rubberbandFactory().create<RB::RubberbandPointCluster>();
if (rbandClust == nullptr)
qWarning() << "Creating rubberband point cluster failed";
else
{
rbandClust -> setCoordinateVector(vertexList);
rbandClust -> setPreviewSidc(rubberbandClust->previewSidc());
rubberTypeLabel = QLatin1String("point cluster");
connect(rbandClust, &RB::Rubberband::apply, slotFunc);
connect(rbandClust, &RB::Rubberband::abort, slotFunc);
}
}
}
d->m_mapInterface->rubberbandFactory().allowMultipleRubberbands(mRbands);
rubberband->deleteMySelf();
} // FunctionDialog::onRubberbandApply
void FunctionDialog::onRubberbandAbort(RB::RubberbandBase *rubberband)
{
qDebug() << LOGFUNCTION;
rubberband->deleteMySelf();
} // FunctionDialog::onRubberbandAbort
void FunctionDialog::onRubberbandDefineEllipse()
{
static QVector<QPointF> vertexList;
if (vertexList.isEmpty())
{
vertexList << s_basePoint.geographic(d->m_objectBasePoint + QPointF(36042.4, 38162.5))
<< s_basePoint.geographic(d->m_objectBasePoint + QPointF(302120, -46643.1))
<< s_basePoint.geographic(d->m_objectBasePoint + QPointF(244876, -224735))
<< s_basePoint.geographic(d->m_objectBasePoint + QPointF(-21201.4, -139929));
}
SituationMap::RB::RubberbandEllipse *rubberband = d->m_mapInterface->rubberbandFactory().create<SituationMap::RB::RubberbandEllipse>();
if (rubberband == nullptr)
qWarning() << LOGFUNCTION << "Creating rubberband failed";
else
{
rubberband->setCoordinateVector(vertexList);
auto slotFunc = [ = ](RB::RubberbandBase * rubberband)
{
rubberband->deleteMySelf();
};
connect(rubberband, &RB::Rubberband::apply, slotFunc);
connect(rubberband, &RB::Rubberband::abort, slotFunc);
}
}
void FunctionDialog::getRotationAndAngle(const QPointF &sectStart, const QPointF &sectEnd, double &rotationDegOut, double &openAngleDegOut)
{
double startAngle = SituationMap::MathUtils::getMathAngle(sectStart) * LtsCoordTrans::rad2deg();
double endAngle = SituationMap::MathUtils::getMathAngle(sectEnd) * LtsCoordTrans::rad2deg();
// get start angle value in deg
{
startAngle = startAngle > 0 ? startAngle : (360 - startAngle);
startAngle = startAngle < 360 ? startAngle : std::fmod(startAngle,360.);
}
// get end angle value in deg
{
endAngle = endAngle > 0 ? endAngle : (360 - endAngle);
}
// get angle value in deg
{
if ( startAngle > endAngle)
openAngleDegOut = 360 + (endAngle - startAngle);
else
openAngleDegOut = endAngle - startAngle;
}
// get rotation angle north (in deg) orientated 0° North(12h)
{
rotationDegOut = SituationMap::MathUtils::getAngleDegree2North((startAngle + (openAngleDegOut/2.)));
}
//qCritical()<<" sDeg:"<<startAngle<<"°, eDeg:"<<endAngle<<"°, rotationDeg:"<<rotationDeg<<"°, angleDeg:["<<openAngleDeg<<"°]";
}
void FunctionDialog::onRubberbandBoobyTrapSector()
{
d->m_mapInterface->rubberbandFactory().allowMultipleRubberbands(true);
RB::RubberbandEllipse *rubberband = d->m_mapInterface->rubberbandFactory().create<RB::RubberbandEllipse>();
d->m_mapInterface->rubberbandFactory().allowMultipleRubberbands(false);
if (rubberband == nullptr)
qWarning() << "Creating rubberband BoobyTrap failed";
else
{
if (rubberband->rubberbandIsAlive())
{
rubberband->constrainQuadratic(true);
rubberband->enableSector(true);
QList<double> rotation = QList<double>()<<0<<45<<90<<-45<<180<<270<<315<<360;
double angle = 90;
double rot = rotation.at(0);
double aStartRad=0, aEndRad=0;
getSectorStartEnd(angle, rot, aStartRad, aEndRad);
// qCritical()<<"[FORWARD] rotation: "<<rot<<" angle start: "<<aStartRad<<" angle end: "<<aEndRad
// <<"[deg] s : "<<(aStartRad*LtsCoordTrans::rad2deg())<<" e: "<<(aEndRad*LtsCoordTrans::rad2deg());
rubberband->setSectorStart(std::sin(aStartRad), std::cos(aStartRad));
rubberband->setSectorEnd(std::sin(aEndRad), std::cos(aEndRad));
QObject::connect(rubberband, &RB::Rubberband::apply, this, &FunctionDialog::onRubberbandApply);
QObject::connect(rubberband, &RB::Rubberband::abort, this, &FunctionDialog::onRubberbandAbort);
}
else
{
qWarning() << "Creating rubberband BoobyTrap is not alive";
rubberband->deleteMySelf();
}
}
} /* FunctionDialog::onRubberbandDefineEllipse */
void FunctionDialog::onRubberbandDefineArrow()
{
static QVector<QPointF> vertexList;
if (vertexList.isEmpty())
{
vertexList << s_basePoint.geographic(d->m_objectBasePoint + QPointF(36042.4, 38162.5))
<< s_basePoint.geographic(d->m_objectBasePoint + QPointF(302120, -46643.1))
<< s_basePoint.geographic(d->m_objectBasePoint + QPointF(244876, -224735))
<< s_basePoint.geographic(d->m_objectBasePoint + QPointF(-21201.4, -139929));
}
SituationMap::RB::RubberbandArrow *rubberband = d->m_mapInterface->rubberbandFactory().create<SituationMap::RB::RubberbandArrow>();
if (rubberband == nullptr)
qWarning() << LOGFUNCTION << "Creating rubberband failed";
else
{
rubberband->setCoordinateVector(vertexList);
auto slotFunc = [ = ](RB::RubberbandBase * rubberband)
{
rubberband->deleteMySelf();
};
connect(rubberband, &RB::Rubberband::apply, slotFunc);
connect(rubberband, &RB::Rubberband::abort, slotFunc);
}
} /* FunctionDialog::onRubberbandDefineEllipse */
void FunctionDialog::onRubberbandCheckCoordinates()
{
static QVector<QPointF> vertexList;
if (vertexList.isEmpty())
{
vertexList << s_basePoint.geographic(d->m_objectBasePoint + QPointF(-338163, 168551))
<< s_basePoint.geographic(d->m_objectBasePoint + QPointF(154770, 168551))
<< s_basePoint.geographic(d->m_objectBasePoint + QPointF(154770, -71025))
<< s_basePoint.geographic(d->m_objectBasePoint + QPointF(-338163, -71025))
<< s_basePoint.geographic(d->m_objectBasePoint + QPointF(36042.4, 38162.5))
<< s_basePoint.geographic(d->m_objectBasePoint + QPointF(302120, -46643.1))
<< s_basePoint.geographic(d->m_objectBasePoint + QPointF(244876, -224735))
<< s_basePoint.geographic(d->m_objectBasePoint + QPointF(-21201.4, -139929));
}
if (d->m_mapImpl->coordTranslationFunctor())
{
bool ok = true;
for (const QPointF &p : std::as_const(vertexList))
{
const QPointF p1(d->m_mapImpl->coordTranslationFunctor()->geographicToMap(p));
const QPointF p2(d->m_mapImpl->coordTranslationFunctor()->mapToGeographic(p1));
if ((fabs(p2.x() - p.x()) > 1) || (fabs(p2.y() - p.y()) > 1))
{
ok = false;
#ifdef LTS_DEBUG
assert(false);
#endif
}
}
if (!ok)
qWarning() << LOGFUNCTION << "CoordTranslationFunctor is to inaccurate.";
}
auto slotFunc = [ = ](RB::RubberbandBase * rubberband)
{
bool ok = true;
if (((unsigned int)vertexList.size()) == rubberband->coordinateCount())
{
for (unsigned int i = 0; i < rubberband->coordinateCount(); ++i)
{
QPointF simPoint = rubberband->singleCoordinate(i);
QPointF p = vertexList[i];
if ((fabs(simPoint.x() - p.x()) > d->m_mapImpl->pixelSizeMeter()) || (fabs(simPoint.y() - p.y()) > d->m_mapImpl->pixelSizeMeter()))
{
ok = false;
#ifdef LTS_DEBUG
assert(false);
#endif
}
}
}
else qWarning() << LOGFUNCTION << "Rubberband coordinates are modified by user, skip coordinate test.";
rubberband->deleteMySelf();
if (!ok)
qWarning() << LOGFUNCTION << "Rubberband coordinates may be changed without editing.";
};
RB::RubberbandMultiPointFeature *rband = d->m_mapInterface->rubberbandFactory().create<RB::RubberbandMultiPointFeature>();
if (rband == nullptr)
qWarning() << "Creating rubberband multi point failed";
else
{
rband->setCoordinateVector(vertexList);
connect(rband, &RB::Rubberband::apply, slotFunc);
connect(rband, &RB::Rubberband::abort, slotFunc);
}
} /* FunctionDialog::onRubberbandCheckCoordinates */
#include "state_icon_a.xpm"
#include "state_icon_b.xpm"
#include "state_icon_c.xpm"
void FunctionDialog::onRubberbandStateSelect()
{
static QVector<QPointF> vertexList;
if (vertexList.isEmpty())
{
vertexList << s_basePoint.geographic(d->m_objectBasePoint + QPointF(-338163, 168551))
<< s_basePoint.geographic(d->m_objectBasePoint + QPointF(154770, 168551))
<< s_basePoint.geographic(d->m_objectBasePoint + QPointF(154770, -71025))
<< s_basePoint.geographic(d->m_objectBasePoint + QPointF(-338163, -71025))
<< s_basePoint.geographic(d->m_objectBasePoint + QPointF(36042.4, 38162.5))
<< s_basePoint.geographic(d->m_objectBasePoint + QPointF(302120, -46643.1))
<< s_basePoint.geographic(d->m_objectBasePoint + QPointF(244876, -224735))
<< s_basePoint.geographic(d->m_objectBasePoint + QPointF(-21201.4, -139929));
}
RB::RubberbandStateSelect *rband = d->m_mapInterface->rubberbandFactory().create<RB::RubberbandStateSelect>();
if (rband)
{
rband -> setHandleFillColor(QColor(0, 0, 0, 0));
rband -> setHandleSelectionColor(QColor(255, 0, 0, 100));
QVector<RB::RubberbandStateSelect::State> stateVector;
QVector<RB::RubberbandStateSelect::StateItem> itemVector;
stateVector << RB::RubberbandStateSelect::State('A', QLatin1String("Test State A"), QPixmap(stateIconA_xpm))
<< RB::RubberbandStateSelect::State('B', QLatin1String("Test State B"), QPixmap(stateIconB_xpm))
<< RB::RubberbandStateSelect::State('C', QLatin1String("Test State C"), QPixmap(stateIconC_xpm));
quint32 id = 815;
itemVector.reserve(vertexList.size());
for (const QPointF &p : std::as_const(vertexList))
{
itemVector << RB::RubberbandStateSelect::StateItem(id, QStringLiteral("Item %1").arg(id), p, 'A');
++id;
}
if (rband->setStateItems(stateVector, itemVector))
{
auto slotFunc = [ = ](RB::RubberbandBase * rubberband)
{
rubberband->deleteMySelf();
};
connect(rband, &RB::Rubberband::apply, slotFunc);
connect(rband, &RB::Rubberband::abort, slotFunc);
}
else
{
rband->deleteMySelf();
qWarning() << "Setting item states to rubberband state select failed.";
}
}
else
qWarning() << "Creating rubberband state select";
} /* FunctionDialog::onRubberbandStateSelect */
void FunctionDialog::onRubberbandTwoInOne()
{
qCritical() << " onRubberbandTwoInOne...";
d->m_mapInterface->rubberbandFactory().allowMultipleRubberbands(false);
static QVector<QPointF> s_vertexList;
s_vertexList.clear();
const auto onApply2 = [](RB::RubberbandBase *rubberband) -> void
{
qCritical() << " onRubberbandTwoInOne onApply 2 ";
RB::RubberbandEllipse *rubberbandElli = dynamic_cast<RB::RubberbandEllipse *>(rubberband);
if (!rubberband)
{
qCritical() << " onRubberbandTwoInOne dynamic_cast failed";
return;
}
if (!rubberbandElli)
{
qCritical() << " onRubberbandTwoInOne no Rubberband!";
return;
}
QVector<QPointF> coordinateVector = rubberbandElli->coordinateVector();
qCritical() << " onRubberbandTwoInOne coordinateVector = " << coordinateVector;
QVector<QPointF> data = rubberbandElli->rectangleVerticies();
const LtsCoordTrans::UtmCoordinate p0(LtsCoordTrans::UtmCoordinate::fromGeographic(data.at(0)));
const LtsCoordTrans::UtmCoordinate p1(LtsCoordTrans::UtmCoordinate::fromGeographic(data.at(2), p0.zone));
const double radius = fabs((p0.x - p1.x) / 2);
qCritical() << " onRubberbandTwoInOne radius 2 = " << radius;
}; // onApply2
const auto onApply1 = [this, onApply2](RB::RubberbandBase *rubberband) -> void
{
qCritical() << " onRubberbandTwoInOne onApply 1 ";
RB::RubberbandMultiEllipseFeature *rubberbandElli = dynamic_cast<RB::RubberbandMultiEllipseFeature *>(rubberband);
if (!rubberband)
{
qCritical() << " onRubberbandTwoInOne dynamic_cast failed";
return;
}
QPointF centerCoord = rubberbandElli->centerCoordinate(RB::CoordinateSystem::Map);
const QVector<QPointF> &radii = rubberbandElli->radii();
qCritical() << LOGFUNCTION << " FRIST centerCoord " << centerCoord
<< " - radii = " << radii;
double radiusMax = radii.last().x();
// 'save' for following rubberband:
s_vertexList = rubberbandElli->coordinateVector();
//
// create SECOND RB
//
QTimer::singleShot(250, this, [this, onApply2, radiusMax]
{
RB::RubberbandEllipse *rubberband2 = d->m_mapInterface->rubberbandFactory().create<RB::RubberbandEllipse>();
if (rubberband2->rubberbandIsAlive())
{
QObject::connect(rubberband2, &RB::Rubberband::apply, onApply2);
QObject::connect(rubberband2, &RB::Rubberband::abort, this, &FunctionDialog::onRubberbandAbort);
}
else
{
qWarning() << "Creating rubberband 2 ellipse is not alive";
rubberband2->deleteMySelf();
}
rubberband2->setAutoDelete(true);
rubberband2->buildFromRectangleParamter(s_vertexList.first(),
radiusMax * 2, radiusMax * 2,
QPointF(1, 0));
// rubberband2->setCoordinateVector(s_vertexList);
rubberband2->minWidth(2*radiusMax);
rubberband2->maxWidth(2*radiusMax);
rubberband2->minHeight(2*radiusMax);
rubberband2->maxHeight(2*radiusMax);
rubberband2->enableSector(true);
rubberband2->setSectorAngleFixed(true);
rubberband2->setSectorStart(0.75,0.75);
rubberband2->setSectorEnd(0.75,-0.75);
rubberband2->constrainQuadratic(true);
// rubberband2->constrainOrthogonal(true);
rubberband2->setLineHandleWidth(2);
});
}; // onApply1
//
// 'main'
//
RB::RubberbandMultiEllipseFeature *rubberband = d->m_mapInterface->rubberbandFactory().create<RB::RubberbandMultiEllipseFeature>();
d->m_mapInterface->rubberbandFactory().allowMultipleRubberbands(true);
if (!rubberband)
qWarning() << "Creating rubberband ellipse failed";
else
{
rubberband->setAutoDelete(true);
rubberband->minimumRadiusCount(2);
rubberband->maximumRadiusCount(2);
rubberband->constrainQuadratic(true);
if (rubberband->rubberbandIsAlive())
{
QObject::connect(rubberband, &RB::Rubberband::apply, onApply1);
QObject::connect(rubberband, &RB::Rubberband::abort, this, &FunctionDialog::onRubberbandAbort);
}
else
{
qWarning() << "Creating rubberband 1 ellipse is not alive";
rubberband->deleteMySelf();
}
}
}
void FunctionDialog::onRectCheckCoordinates()
{
static QVector<QPointF> vertexList;
if (vertexList.isEmpty())
{
vertexList << s_basePoint.geographic(d->m_objectBasePoint + QPointF(-338163, 168551))
<< s_basePoint.geographic(d->m_objectBasePoint + QPointF(154770, 168551))
<< s_basePoint.geographic(d->m_objectBasePoint + QPointF(154770, -71025))
<< s_basePoint.geographic(d->m_objectBasePoint + QPointF(-338163, -71025));
}
auto slotFunc = [ = ](RB::RubberbandBase * rubberband)
{
bool ok = true;
RB::RubberbandRectangle *rband = dynamic_cast<RB::RubberbandRectangle *>(rubberband);
if (rband == nullptr) return;
QVector<QPointF> rectangleCoords = rband->rectangleVerticies();
for (int i = 0; i < rectangleCoords.size(); ++i)
{
const QPointF &simPoint = rectangleCoords[i];
const QPointF &p = vertexList[i];
if ((fabs(simPoint.x() - p.x()) > d->m_mapImpl->pixelSizeMeter()) || (fabs(simPoint.y() - p.y()) > d->m_mapImpl->pixelSizeMeter()))
ok = false;
}
if (!rband->rectangleIsValid())
qWarning() << LOGFUNCTION << "Rectangle rubberband has been initialized with invalid coordinates";
else
{
if (!ok) qWarning() << LOGFUNCTION << "Rubberband coordinates changed without editing.";
}
rubberband->deleteMySelf();
}; // slotFunc
RB::RubberbandRectangle *rband = d->m_mapInterface->rubberbandFactory().create<RB::RubberbandRectangle>();
if (rband == nullptr)
qWarning() << "Creating rubberband rectangle failed";
else
{
rband->setCoordinateVector(vertexList);
connect(rband, &RB::Rubberband::apply, slotFunc);
connect(rband, &RB::Rubberband::abort, slotFunc);
}
} /* FunctionDialog::onRectCheckCoordinates */
void FunctionDialog::addToolsTab()
{
QWidget *w = new QWidget();
QVBoxLayout *mainLayout = new QVBoxLayout(w);
QGridLayout *layout = new QGridLayout();
mainLayout->addLayout(layout);
mainLayout->addStretch();
d->m_tabwidget->addTab(w, QLatin1String("Tools - ObjIndicator, measure, Location"));
//-----------------------------------
// createObjectIndicator
//-----------------------------------
QPushButton *pbObjectIndicator = new QPushButton(QLatin1String("Object Indicator"));
layout->addWidget(pbObjectIndicator);
connect(pbObjectIndicator, &QPushButton::clicked,
this, &FunctionDialog::onObjectIndicator);
//-----------------------------------
// createMeasurementButton
//-----------------------------------
QPushButton *pbCreateMeasurement = new QPushButton(QLatin1String("measure length"));
layout->addWidget(pbCreateMeasurement);
connect(pbCreateMeasurement, &QPushButton::clicked,
this, &FunctionDialog::onMeasureLength);
//-----------------------------------
// LocationDisplay
//-----------------------------------
QGridLayout *locationDisplayLayout = new QGridLayout();
locationDisplayLayout->setObjectName(QLatin1String("LocationDisplayLayout"));
layout->addLayout(locationDisplayLayout, layout->rowCount(), 0);
//-----------------------------------
// startLocationDisplay
//-----------------------------------
QPushButton *pbstartLocationDisplay = new QPushButton(QLatin1String("start LocationDisplay"));
locationDisplayLayout->addWidget(pbstartLocationDisplay, 0, 0);
connect(pbstartLocationDisplay, &QPushButton::clicked,
this, &FunctionDialog::onStartLocationDisplay);
//-----------------------------------
// stopLocationDisplay
//-----------------------------------
QPushButton *pbstopLocationDisplay = new QPushButton(QLatin1String("stop LocationDisplay"));
locationDisplayLayout->addWidget(pbstopLocationDisplay, 0, 1);
connect(pbstopLocationDisplay, &QPushButton::clicked,
this, &FunctionDialog::onStopLocationDisplay);
}
void FunctionDialog::addViewshedTab()
{
QWidget *w = new QWidget();
QVBoxLayout *mainLayout = new QVBoxLayout(w);
QGridLayout *layout = new QGridLayout();
mainLayout->addLayout(layout);
mainLayout->addStretch();
d->m_tabwidget->addTab(w, QLatin1String("Tool Viewshed"));
//-----------------------------------
// createViewshedButtons
//-----------------------------------
QPushButton *pbLoadFile = new QPushButton(QLatin1String(" pbLoadFile"));
layout->addWidget(pbLoadFile);
connect(pbLoadFile, &QPushButton::clicked,
this, &FunctionDialog::onLoadFile);
#ifdef USE_LOCAL_SERVER
{
QPushButton *pbStartLocalService = new QPushButton(QLatin1String(" Start LocalService"));
layout->addWidget(pbStartLocalService);
connect(pbStartLocalService, &QPushButton::clicked,
this, &FunctionDialog::onStartLocalService);
pbStartLocalService->setStyleSheet(QLatin1String("QPushButton {background-color: gray;}"));
QPushButton *pbStopLocalService = new QPushButton(QLatin1String(" Stop LocalService"));
layout->addWidget(pbStopLocalService);
connect(pbStopLocalService, &QPushButton::clicked,
this, &FunctionDialog::onStopLocalService);
QPushButton *pbStartViewshedSvc = new QPushButton(QLatin1String(" Start ViewshedSvc"));
layout->addWidget(pbStartViewshedSvc);
connect(pbStartViewshedSvc, &QPushButton::clicked,
this, &FunctionDialog::onStartViewshedSvc);
pbStartViewshedSvc->setStyleSheet(QLatin1String("QPushButton {background-color: gray;}"));
QPushButton *pbStopViewshedSvc = new QPushButton(QLatin1String(" Stop ViewshedSvc"));
layout->addWidget(pbStopViewshedSvc);
connect(pbStopViewshedSvc, &QPushButton::clicked,
this, &FunctionDialog::onStopViewshedSvc);
}
if (!d->m_viewshedDistance)
{
d->m_viewshedDistance = new QLineEdit(this);
layout->addWidget(d->m_viewshedDistance);
d->m_viewshedDistance->setText(QLatin1String("5123"));
}
QPushButton *pbCreateViewshedIF = new QPushButton(QLatin1String("create viewshed interactive - at Interface"));
layout->addWidget(pbCreateViewshedIF);
connect(pbCreateViewshedIF, &QPushButton::clicked,
this, &FunctionDialog::onViewshedInteractive);
QPushButton *pbCreateViewshedEsri = new QPushButton(QLatin1String("create viewshed - ESRI"));
layout->addWidget(pbCreateViewshedEsri);
connect(pbCreateViewshedEsri, &QPushButton::clicked,
this, &FunctionDialog::onViewshed);
#endif // USE_LOCAL_SERVER
QPushButton *pbCreateViewshed = new QPushButton(QLatin1String("create viewshed - SightFan"));
layout->addWidget(pbCreateViewshed);
connect(pbCreateViewshed, &QPushButton::clicked,
this, &FunctionDialog::onViewshedSightFan);
QFormLayout * sightFanLayout = new QFormLayout();
mainLayout->addLayout(sightFanLayout);
if (!d->m_sightFanObserverHeight)
{
d->m_sightFanObserverHeight = new QLineEdit(this);
d->m_sightFanTargetHeight = new QLineEdit(this);
d->m_sightFanObserverHeight->setValidator(new QDoubleValidator(d->m_sightFanObserverHeight));
d->m_sightFanTargetHeight->setValidator(new QDoubleValidator(d->m_sightFanTargetHeight));
d->m_sightFanObserverHeight->setText(QStringLiteral("2.0"));
d->m_sightFanTargetHeight->setText(QStringLiteral("2.0"));
QPushButton *pbCreateSightFan = new QPushButton(QStringLiteral("Create Sight Fan"), this);
connect(pbCreateSightFan, &QPushButton::clicked, this, &FunctionDialog::onSightFan );
sightFanLayout->addRow(QStringLiteral("Target Height"), d->m_sightFanObserverHeight);
sightFanLayout->addRow(QStringLiteral("Observer Height"), d->m_sightFanTargetHeight);
sightFanLayout->addWidget(pbCreateSightFan);
}
}
void SituationMap::FunctionDialog::addOverlayPlanTab()
{
QWidget *w = new QWidget();
QVBoxLayout *mainLayout = new QVBoxLayout(w);
QGridLayout *layout = new QGridLayout();
mainLayout->addLayout(layout);
mainLayout->addStretch();
d->m_tabwidget->addTab(w, QLatin1String("Overlay/Plan"));
const auto slOverlays = {
QLatin1String("myplan"),
QLatin1String("myplan2")
};
int row = 0;
int key = 4711;
// layout->addWidget(new QLabel(QLatin1String("onOff")), row, 0);
// layout->addWidget(new QLabel(QLatin1String("load plan")), row, 1);
// layout->addWidget(new QLabel(QLatin1String("remove plan")), row, 2);
for (const auto &overlayName : slOverlays)
{
++key;
++row;
int col = 0;
QCheckBox *cbPlan = new QCheckBox(overlayName);
cbPlan->setProperty("key", key);
layout->addWidget(cbPlan, row, col);
connect(cbPlan, &QPushButton::clicked,
this, &FunctionDialog::onOverlayVisiChanged);
++col;
QPushButton *pbLoadPlan = new QPushButton(QLatin1String("load ") + overlayName);
pbLoadPlan->setProperty("name", overlayName);
pbLoadPlan->setProperty("key", key);
layout->addWidget(pbLoadPlan, row, 1);
connect(pbLoadPlan, &QPushButton::clicked,
this, &FunctionDialog::onLoadPlan);
++col;
QPushButton *pbRemovePlan = new QPushButton(QLatin1String("remove ") + overlayName);
pbRemovePlan->setProperty("key", key);
layout->addWidget(pbRemovePlan, row, 2);
connect(pbRemovePlan, &QPushButton::clicked,
this, &FunctionDialog::onRemovePlan);
} // Q_FOREACH
// Remove all
++row;
QPushButton *pbRemoveAll = new QPushButton(QLatin1String("Remove all overlays"));
layout->addWidget(pbRemoveAll, row, 0);
connect(pbRemoveAll, &QPushButton::clicked,
this, &FunctionDialog::onRemoveAllPlans);
}
void FunctionDialog::addIconRenderTab()
{
QWidget *w = new QWidget();
QVBoxLayout *mainLayout = new QVBoxLayout(w);
QGridLayout *layout = new QGridLayout();
mainLayout->addLayout(layout);
mainLayout->addStretch();
d->m_tabwidget->addTab(w, QLatin1String("Icon Demo"));
//-----------------------------------
// create button
//-----------------------------------
LtsWidgets::LtsDragIcon *dummyIcon = new LtsWidgets::LtsDragIcon(this);
layout->addWidget(dummyIcon);
dummyIcon->setText(QLatin1String("dummyIcon"));
QImage dummyImage(100, 100, QImage::Format_ARGB32);
{
dummyImage.fill(Qt::transparent);
QPainter painter(&dummyImage);
painter.setBrush(QBrush(Qt::gray));
painter.setPen(Qt::NoPen);
painter.drawEllipse(dummyImage.rect());
painter.setPen(QPen(Qt::red));
painter.drawText(dummyImage.rect(), Qt::AlignCenter, QLatin1String("dummyIcon"));
painter.end();
}
dummyIcon->setIcon(QIcon(QPixmap::fromImage(dummyImage)));
// show template-based approach :
// (is executed by FunctionDialog::addIconRenderTab() )
{
// AdvancedSymbology::SymbolResultWatcherQWidgetBase *dummyIconSibling =
// new AdvancedSymbology::SymbolResultWatcherQWidget<LtsWidgets::LtsDragIcon>(dummyIcon);
QSharedPointer<AdvancedSymbology::SymbolResultWatcherQWidgetBase> dummyIconSibling (new AdvancedSymbology::SymbolResultWatcherQWidget<LtsWidgets::LtsDragIcon>(dummyIcon));
AdvancedSymbology::SymbolDictionary &dict = d->m_mapImpl->symbolDictionary();
const QString sidc(AdvancedSymbology::SidcCodec::encodeComplete( AdvancedSymbology::SymbologyType::MIL2525D, "10051000001213030000"));
// option a
// dummyIconSibling->setSymbolResult(dict.findPreview(sidc));
// option b
AdvancedSymbology::SymbolDataToRender symDataToRender(sidc);
symDataToRender.injury = AdvancedSymbology::Injury::TotalKill;
symDataToRender.injuryColor = Qt::blue;
dummyIconSibling->setSymbolResult(dict.findImage(symDataToRender));
// option c
// dummyIconSibling->setSymbolResult(dict.findBaseSymbol(sidc));
}
// : show template-based approach
}
void FunctionDialog::addPortalTab()
{
qDebug() << LOGFUNCTION ;
QWidget *w = new QWidget();
QVBoxLayout *mainLayout = new QVBoxLayout(w);
QGridLayout *layout = new QGridLayout();
mainLayout->addLayout(layout);
mainLayout->addStretch();
d->m_tabwidget->addTab(w, QLatin1String("Portal"));
//-----------------------------------
// create button
//-----------------------------------
QPushButton *pbLoadPortal = new QPushButton(QLatin1String("load Portal"));
layout->addWidget(pbLoadPortal);
connect(pbLoadPortal, &QPushButton::clicked, this, &FunctionDialog::onPortal);
}
void FunctionDialog::addMovePointLuxemburgTab()
{
qDebug() << LOGFUNCTION ;
QWidget *w = new QWidget();
QVBoxLayout *mainLayout = new QVBoxLayout(w);
QGridLayout *layout = new QGridLayout();
mainLayout->addLayout(layout);
mainLayout->addStretch();
d->m_tabwidget->addTab(w, QLatin1String("MovePoint"));
//-----------------------------------
// create button
//-----------------------------------
QPushButton *pbMovePoint = new QPushButton(QLatin1String("MovePoint"));
layout->addWidget(pbMovePoint);
connect(pbMovePoint, &QPushButton::clicked, this, &FunctionDialog::onMovePoint);
}
void FunctionDialog::onPortal()
{
Portal *portal = new Portal(this);
bool init = portal->init();
qCritical() << " portal.init = " << init;
// bool fetchData = portal->fetchData();
// qCritical() << " portal.fetchData = " << fetchData;
}
void FunctionDialog::onMovePoint()
{
const int incrementX = 1000;
qCritical() << " move marker from Center to left (arcording UTM), incrementX [m]:" << incrementX;
const QPointF centerGeo = d->m_mapImpl->centerPoint();
const LtsCoordTrans::UtmCoordinate centerUtm = LtsCoordTrans::UtmCoordinate::fromGeographic(centerGeo);
qCritical() << "center " << centerGeo
<< " # utm " << centerUtm.x << " ; " << centerUtm.y<< " # utm " << centerUtm.mgrs();
PositionCont posContIncrement;
posContIncrement.reserve(10);
for (int i=0; i< 10; ++i)
{
LtsCoordTrans::UtmCoordinate movedCoord = centerUtm;
movedCoord.x -= i*incrementX;
qCritical() << qSetRealNumberPrecision(8) << " # UTM " << movedCoord.x << " ; " << movedCoord.y << " # utm " << movedCoord.mgrs();
{
LtsCoordTrans::UtmCoordinate reverse = LtsCoordTrans::UtmCoordinate::fromGeographic(movedCoord.geographic());
qCritical() << qSetRealNumberPrecision(8) << " # rev " << reverse.x << " ; " << reverse.y << " # utm " << reverse.mgrs();
// diff zw. movedCoord & reverse:
QPointF diff = movedCoord.geographic() - reverse.geographic();
qCritical() << qSetRealNumberPrecision(8) << " diff " << diff;
}
appendQPointF(posContIncrement, movedCoord.geographic());
}
qCritical() << " reCreate Coord every step **********+";
// reCreate Coord every step
PositionCont posContRelative;
posContRelative.reserve(10);
LtsCoordTrans::UtmCoordinate incrementedCoord = centerUtm;
QPointF geo = incrementedCoord.geographic();
for (int i=0; i< 10; ++i)
{
LtsCoordTrans::UtmCoordinate coord = LtsCoordTrans::UtmCoordinate::fromGeographic(geo);
qCritical() << qSetRealNumberPrecision(8) << " # UTM " << coord.x << " ; " << coord.y << " # utm " << coord.mgrs();
appendQPointF(posContRelative, geo);
coord.x -= incrementX;
geo = coord.geographic();
}
{
RefPointer<SituationMap::Polyline> polyline;
polyline = d->m_mapInterface->objectFactory().
create<SituationMap::Polyline>(QLatin1String("AES"), QLatin1String("PolyLINE_Lux1Increment"));
if (!polyline)
{
qDebug() << LOGFUNCTION << " no object";
return;
}
polyline->setIdentifier(QLatin1String("Polyline-Luxemburg"));
LineStyle lineStyle(Qt::red, 5, LinePattern::Solid);
polyline->setLineStyle(lineStyle);
polyline->setPositions(posContIncrement);
bool success = polyline->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
}
{
RefPointer<SituationMap::Polyline> polyline;
polyline = d->m_mapInterface->objectFactory().
create<SituationMap::Polyline>(QLatin1String("AES"), QLatin1String("PolyLINE_Lux2Relative"));
if (!polyline)
{
qDebug() << LOGFUNCTION << " no object";
return;
}
polyline->setIdentifier(QLatin1String("Polyline-Luxemburg"));
LineStyle lineStyle(Qt::blue, 2, LinePattern::Dash);
polyline->setLineStyle(lineStyle);
polyline->setPositions(posContRelative);
bool success = polyline->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
}
}
void FunctionDialog::onPolygonCreate()
{
qDebug() << LOGFUNCTION ;
// create and set debugInfo for debugging:
d->clearMapObjectPtr(RefPointer<AbstractMapObject>(d->m_polygon));
d->m_polygon = d->m_mapInterface->objectFactory().
create<SituationMap::Polygon>(QLatin1String("AES"), QLatin1String("PolyGON_Id"));
if (!d->m_polygon)
{
qDebug() << LOGFUNCTION << " no object";
return;
}
d->m_polygon->setIdentifier(QLatin1String("Polygon-NotOutLined"));
d->m_polygon->setVisibility(d->m_visibility);
d->m_polygon->setVisibility(SituationMap::ObjectAppearance::Technical, d->m_visibilityTechn);
d->m_polygon->setVisibility(SituationMap::ObjectAppearance::Tactical, d->m_visibilityTact);
d->m_polygon->setSelected(d->m_selected);
TextStyle textStyle(Qt::magenta);
LineStyle lineStyle(Qt::blue, 2, LinePattern::Solid);
FillStyle fillStyle(Qt::red, FillPattern::ForwardDiagonal);
d->m_polygon->setTextStyle(textStyle);
d->m_polygon->setLineStyle(lineStyle);
d->m_polygon->setFillStyle(fillStyle);
// set additional values:
SituationMap::PositionCont posCont;
QPointF offset = d->m_objectBasePoint + QPointF(90000, 150000);
int extent = 100000;
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(0, 0)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(0, 0)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(-extent / 2, extent / 2)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(0, extent)));
std::cout << " posCont=" << posCont.size() << std::endl;
d->m_polygon->setPositions(posCont);
bool success = d->m_polygon->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
success = d->m_polygon->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
std::cout << " Polygon success = " << success << std::endl;
std::cout << " Polygon dump: " << (*d->m_polygon) << std::endl;
// QTimer* timer = new QTimer(this);
// connect(timer, &QTimer::timeout, this, &FunctionDialog::onDangerAreaUpdate);
// timer->setSingleShot(true);
// timer->start(2000);
}
void FunctionDialog::onPolylineCreate()
{
qDebug() << LOGFUNCTION ;
// create and set debugInfo for debugging:
d->clearMapObjectPtr(RefPointer<AbstractMapObject>(d->m_polyline));
d->m_polyline = d->m_mapInterface->objectFactory().
create<SituationMap::Polyline>(QLatin1String("AES"), QLatin1String("PolyLINE_Id"));
if (!d->m_polyline)
{
qDebug() << LOGFUNCTION << " no object";
return;
}
d->m_polyline->setIdentifier(QLatin1String("Polyline-NotOutLined"));
d->m_polyline->setVisibility(d->m_visibility);
d->m_polyline->setVisibility(SituationMap::ObjectAppearance::Technical, d->m_visibilityTechn);
d->m_polyline->setVisibility(SituationMap::ObjectAppearance::Tactical, d->m_visibilityTact);
d->m_polyline->setSelected(d->m_selected);
TextStyle textStyle(Qt::darkGreen);
LineStyle lineStyle(Qt::red, 5, LinePattern::Solid);
FillStyle fillStyle(Qt::blue, FillPattern::DiagonalCross);
d->m_polyline->setTextStyle(textStyle);
d->m_polyline->setLineStyle(lineStyle);
// set additional values:
SituationMap::PositionCont posCont;
QPointF offset = d->m_objectBasePoint + QPointF(100000, 150000);
int extent = 100000;
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(0, extent)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(extent / 2, extent / 2)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(0, 0)));
std::cout << " posCont=" << posCont.size() << std::endl;
d->m_polyline->setPositions(posCont);
bool success = d->m_polyline->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
success = d->m_polyline->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
std::cout << " Polyline success = " << success << std::endl;
std::cout << " Polyline dump: " << (*d->m_polyline) << std::endl;
QTimer *timer = new QTimer(this);
connect(timer, &QTimer::timeout, this, &FunctionDialog::onPolylineUpdate);
timer->setSingleShot(true);
timer->start(2000);
}
void FunctionDialog::onPolylineUpdate()
{
qDebug() << LOGFUNCTION ;
if (!d->m_polyline)
{
qDebug() << LOGFUNCTION << " no object anymore";
return;
}
d->m_polyline->setArrowHeadStart(true);
d->m_polyline->setArrowHeadEnd(true);
bool success = d->m_polyline->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
}
void FunctionDialog::onTextCreate()
{
qDebug() << LOGFUNCTION ;
// create and set debugInfo for debugging:
d->clearMapObjectPtr(RefPointer<AbstractMapObject>(d->m_text));
d->m_text = d->m_mapInterface->objectFactory().
create<SituationMap::Text>(QLatin1String("AES"), QLatin1String("TextId"));
if (!d->m_text)
{
qDebug() << LOGFUNCTION << " no object";
return;
}
d->m_text->setIdentifier(QLatin1String("Text-NotOutLined\nNewLineForPatrick"));
d->m_text->setVisibility(d->m_visibility);
// d->m_polyline->setVisibility(SituationMap::ObjectAppearance::Technical, d->m_visibilityTechn);
// d->m_polyline->setVisibility(SituationMap::ObjectAppearance::Tactical, d->m_visibilityTact);
d->m_text->setSelected(d->m_selected);
TextStyle textStyle(Qt::darkRed);
d->m_text->setTextStyle(textStyle);
// set additional values:
QPointF origin = d->m_objectBasePoint + QPointF(90000, 120000);
std::cout << " origin=" << origin << std::endl;
origin = s_basePoint.geographic(origin);
d->m_text->setOrigin(Point3D::fromQPointF(origin));
bool success = d->m_text->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
success = d->m_text->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
std::cout << " Text success = " << success << std::endl;
std::cout << " Text dump: " << (*d->m_text) << std::endl;
QTimer *timer = new QTimer(this);
connect(timer, &QTimer::timeout, this, &FunctionDialog::onTextUpdate);
timer->setSingleShot(true);
timer->start(2000);
}
void FunctionDialog::onTextUpdate()
{
qDebug() << LOGFUNCTION ;
if (!d->m_text)
{
qDebug() << LOGFUNCTION << " no object anymore";
return;
}
d->m_text->rTextStyle().setFontFamily(QLatin1String("Palatino")); // which values are valid?????????
d->m_text->rTextStyle().setHorizontalAlignment(HorizontalAlignment::Left);
std::cout << " Text dump: " << (*d->m_text) << std::endl;
bool success = d->m_text->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
}
void FunctionDialog::onMapObjectIndicatorCreate()
{
qDebug() << LOGFUNCTION ;
static SituationMap::UniqueMapId uniqueId = SituationMap::INVALID_MAP_ID;
if (uniqueId == SituationMap::INVALID_MAP_ID)
{
qDebug() << LOGFUNCTION << " create......";
// create and set debugInfo for debugging:
RefPointer<SituationMap::MapObjectIndicator> moIndi
= d->m_mapInterface->objectFactory().
create<SituationMap::MapObjectIndicator>(QLatin1String("Participants"), QLatin1String("MapObjectIndicatorId"));
if (!moIndi)
{
qDebug() << LOGFUNCTION << " no object";
return;
}
uniqueId = moIndi->uniqueMapId();
moIndi->setIdentifier(QLatin1String("MapObjectIndicator"));
moIndi->setVisibility(true); // was maybe invisible...
moIndi->setMapObjectToPointTo(1);
bool success = moIndi->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
success = moIndi->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
}
else
{
qDebug() << LOGFUNCTION << " remove...... (uId=" << uniqueId << ")";
RefPointer<SituationMap::MapObjectIndicator> moIndi =
d->m_mapInterface->objectFactory().get<SituationMap::MapObjectIndicator>(uniqueId);
if (moIndi.valid())
{
qDebug() << LOGFUNCTION << " removeMySelf: " << uniqueId;
moIndi->removeMySelf();
}
}
}
void FunctionDialog::onLayerPerfCreateLayer()
{
qDebug() << LOGFUNCTION ;
int layerCount = d->m_layerPerf_leLayer->text().toInt();
int objCount = d->m_layerPerf_leObject->text().toInt();
int objPerLayer = objCount / layerCount;
int radius = d->m_layerPerf_leRadius->text().toInt();
bool withText = d->m_layerPerf_cbText->isChecked();
qDebug() << LOGFUNCTION << " LayerCount =" << layerCount;
qDebug() << LOGFUNCTION << " objCount =" << objCount;
qDebug() << LOGFUNCTION << " -> ObjPerLayer =" << objPerLayer;
qDebug() << LOGFUNCTION << " radius =" << radius;
qDebug() << LOGFUNCTION << " withText =" << withText;
QStringList layerNames;
LayerFactory &layerFac = d->m_mapImpl->layerFactory();
//
// create operational layer:
//
layerNames.reserve(layerCount - 1);
for (int i = 1; i <= layerCount; ++i)
layerNames << QStringLiteral("LayerPerformance_%1").arg(i);
for (const auto &layerName : std::as_const(layerNames))
layerFac.addOperationalLayer(layerName, layerName);
//
// force creation of techn. Layer:
// create on object per layer:
//
qDebug() << LOGFUNCTION << " Create ...";
// B-Agent -> GraphicsLayer only
for (int i = 0; i < layerCount; ++i)
{
QString layername = layerNames[i];
for (int j = 0; j < objPerLayer; ++j)
{
QString debugIdStr = QStringLiteral("DebugId_L%1_Obj%2").arg(i).arg(j);
if (j % 100 == 0)
std::cerr << LOGFUNCTION
<< " Layer = " << i
<< " Obj = " << j << std::endl;
#define BAGENT
#ifdef BAGENT
RefPointer<SituationMap::BiologicalAgent> bAgent
= d->m_mapInterface->objectFactory().
create<SituationMap::BiologicalAgent>(layername, debugIdStr);
if (!bAgent)
{
qDebug() << LOGFUNCTION << " no object";
abort();
// return;
}
// QPointF center = d->m_objectBasePoint + QPointF(10 * j, 10 * i);
QPointF center = d->m_mapImpl->centerPoint();
bAgent->setOrigin(Point3D::fromQPointF(center));
bAgent->setRadius(radius);
bAgent->setVisibility(d->m_visibility);
bAgent->setVisibility(SituationMap::ObjectAppearance::Technical, d->m_visibilityTechn);
bAgent->setVisibility(SituationMap::ObjectAppearance::Tactical, d->m_visibilityTact);
// if ( ( j%10 == 0) || ( (i==(layerCount-1)) && (j==(objPerLayer-1)) ) )
{
if (withText)
bAgent->setIdentifier(debugIdStr);
}
bAgent->updateView();
#else
RefPointer<SituationMap::Participant> part
= d->m_mapInterface->objectFactory().
create<SituationMap::Participant>(layername, debugIdStr);
if (!part)
{
qDebug() << LOGFUNCTION << " no object";
abort();
return;
}
QPointF center = d->m_objectBasePoint + QPointF(1000 * j, 1000 * i);
SituationMap::SymbolData symData;
symData.m_sidc = "SFGPUCD---";
part->setSymbol(symData);
part->setOrigin(center);
// if ( ( j%10 == 0) || ( (i==(layerCount-1)) && (j==(objPerLayer-1)) ) )
{
if (withText)
part->setIdentifier(debugIdStr);
}
part->updateView();
#endif
}
} // for
std::cerr << LOGFUNCTION << " Create ... DONE" << std::endl;
std::cerr << LOGFUNCTION << " LayerCount =" << layerCount << std::endl;
std::cerr << LOGFUNCTION << " objCount =" << objCount << std::endl;
std::cerr << LOGFUNCTION << " -> ObjPerLayer =" << objPerLayer << std::endl;
std::cerr << LOGFUNCTION << " radius =" << radius << std::endl;
std::cerr << LOGFUNCTION << " withText =" << withText << std::endl;
} /* FunctionDialog::onLayerPerfCreateLayer */
void FunctionDialog::onGenerateGraphics()
{
//
//
// Pay Attention to the current RenderingMode!!!!!!!!!!!!!!!!!!
//
//
static bool done = false;
if (done)
{
qWarning() << "already done";
return;
}
else
done = true;
if (d->m_graphicsLayer)
{
qWarning() << "generate graphics";
// SurfacePlacement::Draped is default on V100.0
//d->m_graphicsLayer->setSceneProperties(Esri::ArcGISRuntime::LayerSceneProperties(Esri::ArcGISRuntime::SurfacePlacement::Draped));
const Esri::ArcGISRuntime::SpatialReference &sr = d->m_mapImpl->getEsriSpatialReference();
#define TEXT_WKT
#ifdef TEXT_WKT
{
double i = 1000000; // Meter
QString wkText = QLatin1String("GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137,298.257223563]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.017453292519943295]]");
/*
"PROJCS[\"WGS_1984_Web_Mercator_Auxiliary_Sphere\",\
GEOGCS[\"GCS_WGS_1984\",\
DATUM[\"D_WGS_1984\",\
SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],\
PRIMEM[\"Greenwich\",0.0],\
UNIT[\"Degree\",0.0174532925199433]],\
PROJECTION[\"Mercator_Auxiliary_Sphere\"],\
PARAMETER[\"False_Easting\",0.0],\
PARAMETER[\"False_Northing\",0.0],\
PARAMETER[\"Central_Meridian\",0.0],\
PARAMETER[\"Standard_Parallel_1\",0.0],\
PARAMETER[\"Auxiliary_Sphere_Type\",0.0],\
UNIT[\"Meter\",1.0]]\"");
*/
const Esri::ArcGISRuntime::SpatialReference wgs84(wkText);
// \brief Projects the given point from EPSG:4326 (WGS-84) to the output spatial reference.
// \param[in] x The x coordinate of the point.
// \param[in] y The y coordinate of the point.
// \param[in] sr The spatial reference to which to project the point.
// \return The projected point.
const Esri::ArcGISRuntime::Viewpoint &vp =
d->m_mapGeoView->currentViewpoint(Esri::ArcGISRuntime::ViewpointType::CenterAndScale);
const Esri::ArcGISRuntime::Point &mapCenter = static_cast<Esri::ArcGISRuntime::Point>(vp.targetGeometry());
const Esri::ArcGISRuntime::Point &bremenPoint = mapCenter;
// bremenPoint = Esri::ArcGISRuntime::GeometryEngine::project( Esri::ArcGISRuntime::Point(8.897803, 53.054957, Esri::ArcGISRuntime::SpatialReference(4326)), sr);
// myWKT :
QLatin1String myWkt(
"PROJCS[\"WGS_1984_Web_Mercator_Auxiliary_Sphere\",\
GEOGCS[\"GCS_WGS_1984\",\
DATUM[\"D_WGS_1984\",\
SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],\
PRIMEM[\"Greenwich\",0.0],\
UNIT[\"Degree\",0.0174532925199433]],\
PROJECTION[\"Mercator_Auxiliary_Sphere\"],\
PARAMETER[\"False_Easting\",1000000.0],\
PARAMETER[\"False_Northing\",1000000.0],\
PARAMETER[\"Central_Meridian\",0.0],\
PARAMETER[\"Standard_Parallel_1\",0.0],\
PARAMETER[\"Auxiliary_Sphere_Type\",0.0],\
UNIT[\"Meter\",1.0]]\"");
Esri::ArcGISRuntime::Point myPoint(i, i, Esri::ArcGISRuntime::SpatialReference(myWkt));
// bremenPoint = EsriRuntimeQt::GeometryEngine::project(myPoint, sr);
// : myWKT
// Esri::ArcGISRuntime::Point(lon, lat)
Esri::ArcGISRuntime::Point marseille(5.371113, 43.283954, 0, sr);
Esri::ArcGISRuntime::Point nullPoint(0, 0, 0, sr);
// nullPoint = marseille;
Esri::ArcGISRuntime::SimpleMarkerSymbol redCircle(Esri::ArcGISRuntime::SimpleMarkerSymbolStyle::Circle, Qt::red, 20);
Esri::ArcGISRuntime::Graphic *graphic1 = new Esri::ArcGISRuntime::Graphic(nullPoint, &redCircle);
d->m_graphicsLayer->graphics()->append(graphic1);
Esri::ArcGISRuntime::SimpleMarkerSymbol blueCircle(Esri::ArcGISRuntime::SimpleMarkerSymbolStyle::Circle, Qt::blue, 10);
Esri::ArcGISRuntime::Graphic *myGraphic = new Esri::ArcGISRuntime::Graphic(bremenPoint, &blueCircle);
d->m_graphicsLayer->graphics()->append(myGraphic);
Esri::ArcGISRuntime::PolylineBuilder builder(sr);
builder.addPoint(nullPoint);
builder.addPoint(Esri::ArcGISRuntime::Point(bremenPoint.x(), bremenPoint.y(), 100, bremenPoint.spatialReference()));
Esri::ArcGISRuntime::SimpleLineSymbol lineSym(Esri::ArcGISRuntime::SimpleLineSymbolStyle::Solid, QColor("green"), 5);
Esri::ArcGISRuntime::Graphic *graphicPolyline = new Esri::ArcGISRuntime::Graphic(builder.toGeometry(), &lineSym);
d->m_graphicsLayer->graphics()->append(graphicPolyline);
}
#else // WKT
{
//-----------------------------------
// LINE
//-----------------------------------
EsriRuntimeQt::Point point11(0, 0, sr);
EsriRuntimeQt::Point point12(i, i, sr);
EsriRuntimeQt::SimpleMarkerSymbol blueCircle(Qt::blue, 8, EsriRuntimeQt::SimpleMarkerSymbolStyle::Circle);
EsriRuntimeQt::Graphic *graphic1 = new EsriRuntimeQt::Graphic(point12, blueCircle);
d->m_graphicsLayer->addGraphic(graphic1);
EsriRuntimeQt::LIST_OF_POINTS lop;
lop.append(point11);
lop.append(point12);
EsriRuntimeQt::Polyline polyline(QList<EsriRuntimeQt::LIST_OF_POINTS>() << lop);
EsriRuntimeQt::SimpleLineSymbol lineSym;
EsriRuntimeQt::Graphic *graphicPolyline = new EsriRuntimeQt::Graphic(polyline, lineSym);
d->m_graphicsLayer->addGraphic(graphicPolyline);
//-----------------------------------
// CIRCLE
//-----------------------------------
int radius = sqrt(2.0 * pow(i, 2)); // Meter
drawEllipse(d->m_graphicsLayer, point11, radius, radius, 5000.0, QColor(230, 139, 200));
// MOVE (GeometryEngine::geodesicMovePoints)
QList<EsriRuntimeQt::Point> plIN, plOUT;
plIN << point11;
int wkid = sr.wkid();
EsriRuntimeQt::Unit *unit = EsriRuntimeQt::Unit::create(wkid);
qWarning() << "geodesicMovePoints"
<< " wkid=" << wkid
// << " unit = " << unit->name()
;
plOUT = EsriRuntimeQt::GeometryEngine::geodesicMovePoints(plIN,
sqrt(2.0 * pow(i, 2)),
45.0,
// nullptr
unit
);
EsriRuntimeQt::SimpleMarkerSymbol greenDot(Qt::green, 20, EsriRuntimeQt::SimpleMarkerSymbolStyle::Triangle);
greenDot.setAngle(10);
EsriRuntimeQt::Graphic *graphicMoved = new EsriRuntimeQt::Graphic(plOUT.at(0), greenDot);
d->m_graphicsLayer->addGraphic(graphicMoved);
//-----------------------------------
// CIRCLE II
//-----------------------------------
{
int radius = 10400; // Meter
drawEllipse(d->m_graphicsLayer, point12, radius, radius, radius / 20, Qt::yellow);
}
//-----------------------------------
// IMAGE
//-----------------------------------
int widthPixel = 100;
QImage image(widthPixel, widthPixel, QImage::Format_ARGB32);
image.fill(qRgba(0, 0, 0, 0));
QPainter p;
QPen pen(Qt::yellow);
pen.setWidth(5);
p.begin(&image);
p.setPen(pen);
p.drawLine(QPointF(0, 0), QPointF(100, 100));
p.end();
bool success = image.save(QLatin1String("/tmp/dummy.png"));
qWarning() << " success = " << success;
EsriRuntimeQt::PictureMarkerSymbol pms(image);
EsriRuntimeQt::Point origin(20000, 20000, d->m_graphicsLayer->spatialReference());
EsriRuntimeQt::Graphic *graphic = new EsriRuntimeQt::Graphic(origin, pms);
qint64 gid = d->m_graphicsLayer->addGraphic(graphic);
qWarning() << " gid = " << gid;
//-----------------------------------
// TEXT
//-----------------------------------
EsriRuntimeQt::TextSymbol textSymbol;
textSymbol.setText(QLatin1String("Mein Langer Text"));
textSymbol.setTextColor(QColor(255, 0, 0));
textSymbol.setSize(20.0);
textSymbol.setTextOutlineWidth(1.0);
textSymbol.setTextOutlineColor(QColor(255, 0, 0));
textSymbol.setHorizontalAlignment(EsriRuntimeQt::HorizontalAlignment::Left);
textSymbol.setVerticalAlignment(EsriRuntimeQt::VerticalAlignment::Middle);
// 2. Graphic
EsriRuntimeQt::Geometry originGeometry(point11);
EsriRuntimeQt::Graphic *textGraphic = new EsriRuntimeQt::Graphic(originGeometry,
textSymbol);
// 3. add graphic
qint64 gidText = d->m_graphicsLayer->addGraphic(textGraphic);
qWarning() << " gidText = " << gidText;
}
#endif // WKT
}
else
{
qWarning() << "no m_graphicsLayer";
QMessageBox msgBox;
msgBox.setText(QLatin1String("no m_graphicsLayer"));
msgBox.exec();
}
}
Esri::ArcGISRuntime::Graphic *FunctionDialog::createCube(const PositionCont &mapPosCont,
int baseHeight,
double objHeight,
const QString &partyNameValue)
{
if (!d->m_graphicsLayer)
{
qCritical() << " no m_graphicsLayer";
return nullptr;
}
const Esri::ArcGISRuntime::SpatialReference &sr = d->m_mapImpl->getEsriSpatialReference();
Esri::ArcGISRuntime::PolygonBuilder builder(sr, this);
for (const auto &coord : mapPosCont)
{
Esri::ArcGISRuntime::Point pnt (coord.x(), coord.y(), baseHeight);
builder.addPoint(pnt);
qCritical() << " coord=" << pnt;
}
Esri::ArcGISRuntime::Polygon poly(builder.toGeometry());
const int maxSegmentLength = 100;
Esri::ArcGISRuntime::Geometry geometry = Esri::ArcGISRuntime::GeometryEngine::densifyGeodetic(poly,
maxSegmentLength,
Esri::ArcGISRuntime::LinearUnit::meters(),
Esri::ArcGISRuntime::GeodeticCurveType::Geodesic);
Esri::ArcGISRuntime::Graphic *graphic = new Esri::ArcGISRuntime::Graphic(this);
graphic->setGeometry(geometry);
QVariantMap att = graphic->attributes()->attributesMap();
att[QLatin1String("height")] = QString::number(objHeight);
qCritical() << " height=" << att[QLatin1String("height")];
if (!partyNameValue.isEmpty())
att[QLatin1String("PartyName")] = partyNameValue;
graphic->attributes()->setAttributesMap(att);
return graphic;
}
void FunctionDialog::onGenerateCube()
{
static Esri::ArcGISRuntime::Graphic *s_graphic = nullptr;
if (s_graphic)
{
qWarning() << "removing...";
if (d->m_graphicsLayer && d->m_graphicsLayer->graphics())
d->m_graphicsLayer->graphics()->removeOne(s_graphic);
s_graphic->deleteLater();
s_graphic = nullptr;
return;
}
d->m_graphicsLayer->setSceneProperties(Esri::ArcGISRuntime::LayerSceneProperties(Esri::ArcGISRuntime::SurfacePlacement::Relative));
// Renderer
QColor col = Qt::red;
col.setAlphaF(0.5);
Esri::ArcGISRuntime::SimpleFillSymbol *sls =
new Esri::ArcGISRuntime::SimpleFillSymbol(Esri::ArcGISRuntime::SimpleFillSymbolStyle::Solid, col, this);
qCritical() << " USE RENDERER";
Esri::ArcGISRuntime::SimpleRenderer *renderer = new Esri::ArcGISRuntime::SimpleRenderer(sls, this);
Esri::ArcGISRuntime::RendererSceneProperties props = renderer->sceneProperties();
props.setExtrusionMode(Esri::ArcGISRuntime::ExtrusionMode::BaseHeight);
props.setExtrusionExpression(QLatin1String("[height]"));
renderer->setSceneProperties(props);
d->m_graphicsLayer->setRenderer(renderer);
// Esri::ArcGISRuntime::GraphicsOverlay *gOverlay = d->m_mapImpl->getGraphicsLayer3DExtrusion(QLatin1String("AES"));
// qCritical() << " USE RENDERER gOverlay " << gOverlay;
// gOverlay->setRenderer(renderer);
qCritical() << " USE RENDERER" << (int) props.extrusionMode();
// Geometry
int sizeX = 1500;
int sizeY = 50;
SituationMap::PositionCont posCont;
LtsCoordTrans::UtmCoordinate local_basePoint;
// local_basePoint = LtsCoordTrans::UtmCoordinate::fromMgrs(QLatin1String("32UNE000000000000")); // Bremen 32UMD000000000000
local_basePoint = s_basePoint;
QPointF offset = d->m_objectBasePoint + QPointF(91000, 77000);
appendQPointF(posCont, local_basePoint.geographic(offset + QPointF(-sizeX, -sizeY))); // ul
appendQPointF(posCont, local_basePoint.geographic(offset + QPointF(-sizeX, sizeY)));
appendQPointF(posCont, local_basePoint.geographic(offset + QPointF( sizeX, sizeY)));
appendQPointF(posCont, local_basePoint.geographic(offset + QPointF( sizeX, -sizeY)));
SituationMap::PositionsTranslated posTrans;
posTrans.setCoordTransFunctor(d->m_mapImpl->coordTranslationFunctor());
posTrans.setPositions(posCont);
SituationMap::PositionCont posContTrans = posTrans.positionsTranslated();
s_graphic = createCube(posContTrans, 10, 50);
d->m_graphicsLayer->graphics()->append(s_graphic);
}
void FunctionDialog::onGenerateCubeArray()
{
if (!d->m_graphicsLayer)
{
qCritical() << " no m_graphicsLayer";
return;
}
if (d->m_mapImpl->mode() != Mode::Mode_3D)
return;
d->m_graphicsLayer->setSceneProperties(Esri::ArcGISRuntime::LayerSceneProperties(Esri::ArcGISRuntime::SurfacePlacement::Relative));
// Renderer
{
QColor col = Qt::red;
col.setAlphaF(0.25);
Esri::ArcGISRuntime::SimpleFillSymbol *sls =
new Esri::ArcGISRuntime::SimpleFillSymbol(Esri::ArcGISRuntime::SimpleFillSymbolStyle::Solid, col, this);
qCritical() << " USE RENDERER";
Esri::ArcGISRuntime::SimpleRenderer *renderer = new Esri::ArcGISRuntime::SimpleRenderer(sls, this);
Esri::ArcGISRuntime::RendererSceneProperties props = renderer->sceneProperties();
props.setExtrusionMode(Esri::ArcGISRuntime::ExtrusionMode::BaseHeight);
props.setExtrusionExpression(QLatin1String("[height]"));
renderer->setSceneProperties(props);
d->m_graphicsLayer->setRenderer(renderer);
}
const Esri::ArcGISRuntime::SpatialReference &sr = d->m_mapImpl->getEsriSpatialReference();
const Esri::ArcGISRuntime::Viewpoint &vp =
d->m_mapGeoView->currentViewpoint(Esri::ArcGISRuntime::ViewpointType::CenterAndScale);
const Esri::ArcGISRuntime::Point &mapCenter = static_cast<Esri::ArcGISRuntime::Point>(vp.targetGeometry());
Esri::ArcGISRuntime::Graphic *clipGraphic = nullptr;
{
const double clipOffset = 0.0085;
Esri::ArcGISRuntime::PolygonBuilder builder(sr, this);
builder.addPoint(mapCenter.x(), mapCenter.y());
builder.addPoint(mapCenter.x()-clipOffset, mapCenter.y() + clipOffset);
builder.addPoint(mapCenter.x()+clipOffset, mapCenter.y() + clipOffset);
clipGraphic = new Esri::ArcGISRuntime::Graphic(builder.toGeometry(), this);
// Esri::ArcGISRuntime::SimpleLineSymbol *sls =
// new Esri::ArcGISRuntime::SimpleLineSymbol(Esri::ArcGISRuntime::SimpleLineSymbolStyle::Solid, Qt::yellow, 5, this);
// clipGraphic->setSymbol(sls);
QVariantMap att = clipGraphic->attributes()->attributesMap();
att[QLatin1String("height")] = QString::number(2);
clipGraphic->attributes()->setAttributesMap(att);
d->m_graphicsLayer->graphics()->append(clipGraphic);
}
QElapsedTimer elapsedTimer;
elapsedTimer.start();
const int maxRow = 10;
const int maxColumn = 10;
const double offsetSize = 0.001;
Esri::ArcGISRuntime::PartCollection partCollection(sr);
for (int row=0; row<maxRow; ++row)
{
for (int col=0; col<maxColumn; ++col)
{
double offsetRow = row * offsetSize;
double offsetCol = col * offsetSize;
Esri::ArcGISRuntime::Point bottomLeft(mapCenter.x() + offsetRow,
mapCenter.y() + offsetCol);
Esri::ArcGISRuntime::PolygonBuilder polylineBuilder(sr, this);
polylineBuilder.addPoint(bottomLeft.x() + 0, bottomLeft.y() + 0);
polylineBuilder.addPoint(bottomLeft.x() + offsetSize, bottomLeft.y() + 0);
polylineBuilder.addPoint(bottomLeft.x() + offsetSize, bottomLeft.y() + offsetSize);
polylineBuilder.addPoint(bottomLeft.x() + 0, bottomLeft.y() + offsetSize);
// Esri::ArcGISRuntime::Graphic *graphic = new Esri::ArcGISRuntime::Graphic(polylineBuilder.toGeometry(), this);
// QVariantMap att = graphic->attributes()->attributesMap();
// att[QLatin1String("height")] = QString::number(10);
// graphic->attributes()->setAttributesMap(att);
// d->m_graphicsLayer->graphics()->append(graphic);
Esri::ArcGISRuntime::Geometry clippedGeometry = Esri::ArcGISRuntime::GeometryEngine::intersection(polylineBuilder.toPolygon(),
clipGraphic->geometry());
// qCritical() << " cg" << clippedGeometry.toJson();
if (!clippedGeometry.isEmpty())
{
Esri::ArcGISRuntime::Polygon poly(clippedGeometry);
const Esri::ArcGISRuntime::ImmutablePointCollection pc = poly.parts().part(0).points();
Esri::ArcGISRuntime::Part part(sr);
for (const Esri::ArcGISRuntime::Point &pnt : pc)
part.addPoint(pnt);
// part.addPoint(bottomLeft.x() + 0, bottomLeft.y() + 0);
// part.addPoint(bottomLeft.x() + offsetSize, bottomLeft.y() + 0);
// part.addPoint(bottomLeft.x() + offsetSize, bottomLeft.y() + offsetSize);
// part.addPoint(bottomLeft.x() + 0, bottomLeft.y() + offsetSize);
partCollection.addPart(&part);
}
} // for
} // for
Esri::ArcGISRuntime::Graphic *multiPartGraphic = new Esri::ArcGISRuntime::Graphic(this);
Esri::ArcGISRuntime::PolygonBuilder builder(sr, this);
builder.setParts(&partCollection);
const Esri::ArcGISRuntime::Polygon &multipartPolygon = builder.toPolygon();
multiPartGraphic->setGeometry(multipartPolygon);
int msec = elapsedTimer.elapsed();
qCritical() << " XYZ took [msec]: " << msec;
QVariantMap att = multiPartGraphic->attributes()->attributesMap();
att[QLatin1String("height")] = QString::number(10);
multiPartGraphic->attributes()->setAttributesMap(att);
d->m_graphicsLayer->graphics()->append(multiPartGraphic);
// Esri::ArcGISRuntime::SimpleLineSymbol *sls =
// new Esri::ArcGISRuntime::SimpleLineSymbol(Esri::ArcGISRuntime::SimpleLineSymbolStyle::Solid, Qt::green, 5, this);
// graphic->setSymbol(sls);
}
void FunctionDialog::onGenerateStackedCubes()
{
if (!d->m_graphicsLayer)
{
qCritical() << " no m_graphicsLayer";
return;
}
d->m_graphicsLayer->setSceneProperties(Esri::ArcGISRuntime::LayerSceneProperties(Esri::ArcGISRuntime::SurfacePlacement::DrapedFlat));
// RenderingMode::Dynamic: ok, for V100.0 ; V100.1
// RenderingMode::Static: no Height in V100.1
// Renderer
qCritical() << " USE UniqueValueRenderer";
Esri::ArcGISRuntime::SimpleFillSymbol *sls;
const QVector<QString> partyList = {
QLatin1String("red"),
QLatin1String("blue"),
QLatin1String("green")
};
QList<Esri::ArcGISRuntime::UniqueValue*> uvList;
for (const auto &party : partyList)
{
QColor col(party);
// col.setAlphaF(0.3); // ---> set opacity of complete layer!!!???!!!
sls = new Esri::ArcGISRuntime::SimpleFillSymbol(Esri::ArcGISRuntime::SimpleFillSymbolStyle::Solid, col, this);
Esri::ArcGISRuntime::UniqueValue *uv =
new Esri::ArcGISRuntime::UniqueValue(party,
QStringLiteral("Party '%1'").arg(party),
QVariantList() << party, sls, this);
uvList.append(uv);
} // Q_FOREACH
sls = new Esri::ArcGISRuntime::SimpleFillSymbol(Esri::ArcGISRuntime::SimpleFillSymbolStyle::Solid, Qt::white, this);
Esri::ArcGISRuntime::UniqueValueRenderer* uniqueRenderer =
new Esri::ArcGISRuntime::UniqueValueRenderer(QLatin1String("UnknownParty"),
sls, // default
QStringList() << QLatin1String("PartyName"),
uvList, this);
Esri::ArcGISRuntime::RendererSceneProperties props = uniqueRenderer->sceneProperties();
props.setExtrusionMode(Esri::ArcGISRuntime::ExtrusionMode::BaseHeight);
props.setExtrusionExpression(QLatin1String("[height]"));
uniqueRenderer->setSceneProperties(props);
d->m_graphicsLayer->setRenderer(uniqueRenderer);
// Geometry
const auto centerPoints = {
d->m_objectBasePoint + QPointF(92400, 78600),
d->m_objectBasePoint + QPointF(92450, 78600),
d->m_objectBasePoint + QPointF(92450, 78675),
d->m_objectBasePoint + QPointF(93069, 78331)
};
SituationMap::PositionCont posCont;
for (const QPointF &centerPoint : centerPoints)
{
double sizeX = 10;
double sizeY = sizeX;
for (int i=0; i<3; ++i)
{
sizeX -= 0.01;
sizeY -= 0.01;
posCont.clear();
posCont.reserve(4);
appendQPointF(posCont, s_basePoint.geographic(centerPoint + QPointF(-sizeX, -sizeY))); // ul
appendQPointF(posCont, s_basePoint.geographic(centerPoint + QPointF(-sizeX, sizeY)));
appendQPointF(posCont, s_basePoint.geographic(centerPoint + QPointF( sizeX, sizeY)));
appendQPointF(posCont, s_basePoint.geographic(centerPoint + QPointF( sizeX, -sizeY)));
SituationMap::PositionsTranslated posTrans;
posTrans.setCoordTransFunctor(d->m_mapImpl->coordTranslationFunctor());
posTrans.setPositions(posCont);
SituationMap::PositionCont posContTrans = posTrans.positionsTranslated();
const QString &partyNameValue = partyList[i];
Esri::ArcGISRuntime::Graphic *graphic = createCube(posContTrans, 1000, 1+i, partyNameValue);
d->m_graphicsLayer->graphics()->append(graphic);
} // for
} // Q_FOREACH
}
void FunctionDialog::onGenerateGraphicsKristenStrandford()
{
static bool done = false;
if (done)
{
qWarning() << "already done";
return;
}
else
done = true;
if (d->m_graphicsLayer)
{
qWarning() << "onGenerateGraphicsKristenStrandford";
// SurfacePlacement::Draped is default on V100.0
d->m_graphicsLayer->setSceneProperties(Esri::ArcGISRuntime::LayerSceneProperties(Esri::ArcGISRuntime::SurfacePlacement::Absolute));
const Esri::ArcGISRuntime::SpatialReference &sr = d->m_mapImpl->getEsriSpatialReference();
const Esri::ArcGISRuntime::Viewpoint &vp =
d->m_mapGeoView->currentViewpoint(Esri::ArcGISRuntime::ViewpointType::CenterAndScale);
const Esri::ArcGISRuntime::Point &mapCenter = static_cast<Esri::ArcGISRuntime::Point>(vp.targetGeometry());
Esri::ArcGISRuntime::Point myLocation = Esri::ArcGISRuntime::Point(mapCenter.x(), mapCenter.y(), 1000, sr);
Esri::ArcGISRuntime::Point skyLocation = Esri::ArcGISRuntime::Point(mapCenter.x(), mapCenter.y(), 99999, sr);
qCritical() << " myLocation=" << myLocation.toJson() << " z=" << myLocation.z();;
qCritical() << " skyLocation=" << skyLocation.toJson() << " z=" << skyLocation.z();
Esri::ArcGISRuntime::PolygonBuilder polylineBuilder(sr, this);
polylineBuilder.addPoint(myLocation);
polylineBuilder.addPoint(skyLocation);
Esri::ArcGISRuntime::SimpleLineSymbol *sls =
new Esri::ArcGISRuntime::SimpleLineSymbol(Esri::ArcGISRuntime::SimpleLineSymbolStyle::Solid, Qt::red, 5, this);
Esri::ArcGISRuntime::Graphic *lineGraphic = new Esri::ArcGISRuntime::Graphic(polylineBuilder.toGeometry(), this);
//#define USE_RENDERER
#ifdef USE_RENDERER
qCritical() << " USE RENDERER";
d->m_graphicsLayer->setRenderer(new Esri::ArcGISRuntime::SimpleRenderer(sls, this));
#else
qCritical() << " USE no RENDERER";
lineGraphic->setSymbol(sls);
#endif // USE_RENDERER
d->m_graphicsLayer->graphics()->append(lineGraphic);
}
}
void FunctionDialog::onGenerateUniqueVaueRendererMountingPoints()
{
qCritical() << " onGenerateUniqueVaueRendererMountingPoints";
static QString s_prefix(QStringLiteral("MyXXXXXXXXXXXXXXXXXXXX_VeryLongPrefix_"));
qCritical() << " USE UniqueValueRenderer";
Esri::ArcGISRuntime::SimpleMarkerSymbol *sms;
const QVector<QString> partyList = {
QStringLiteral("red"),
QStringLiteral("blue"),
QStringLiteral("blue"),
QStringLiteral("green")
};
QList<Esri::ArcGISRuntime::UniqueValue*> uvList;
for (const auto &party : partyList)
{
QColor col(party);
sms = new Esri::ArcGISRuntime::SimpleMarkerSymbol(Esri::ArcGISRuntime::SimpleMarkerSymbolStyle::Diamond, col, 20, this);
// QString value = party;
QString value = s_prefix+party;
qCritical() << " XXXXXX value '" << value << "'";
Esri::ArcGISRuntime::UniqueValue *uv =
new Esri::ArcGISRuntime::UniqueValue(party,
QStringLiteral("Party '%1'").arg(party),
QVariantList() << value, sms, this);
uvList.append(uv);
} // Q_FOREACH
// default:
sms = new Esri::ArcGISRuntime::SimpleMarkerSymbol(Esri::ArcGISRuntime::SimpleMarkerSymbolStyle::X, Qt::white, 15, this);
Esri::ArcGISRuntime::UniqueValueRenderer* uniqueRenderer =
new Esri::ArcGISRuntime::UniqueValueRenderer(QStringLiteral("UnknownParty"),
sms, // default
QStringList() << QStringLiteral("MountingPointFieldName"),
uvList, this);
uniqueRenderer->setObjectName(QStringLiteral("UniqueValueRenderer_onGenerateUniqueVaueRendererMountingPoints"));
d->m_graphicsLayer->setRenderer(uniqueRenderer);
const auto centerPoints = {
d->m_objectBasePoint + QPointF(91400, 78600),
d->m_objectBasePoint + QPointF(92450, 78600),
d->m_objectBasePoint + QPointF(92450, 78675),
d->m_objectBasePoint + QPointF(93069, 78331)
};
for (const QPointF &pppp : centerPoints)
{
QPointF originSim = d->m_objectBasePoint + pppp;
QPointF originGeo = s_basePoint.geographic(originSim);
SituationMap::PositionCont posCont;
posCont.append(Point3D::fromQPointF(originGeo));
SituationMap::PositionsTranslated posTrans;
posTrans.setCoordTransFunctor(d->m_mapImpl->coordTranslationFunctor());
posTrans.setPositions(posCont);
SituationMap::PositionCont posContTrans = posTrans.positionsTranslated();
Point3D p3D = posContTrans.first();
Esri::ArcGISRuntime::Point newPnt(p3D.x(),
p3D.y(),
p3D.z());
Esri::ArcGISRuntime::Graphic *graphic = new Esri::ArcGISRuntime::Graphic();
graphic->setGeometry(newPnt);
d->m_graphicsLayer->graphics()->append(graphic);
QVariantMap rawAttributes = graphic->attributes()->attributesMap();
rawAttributes[QStringLiteral("MountingPointFieldName")] = QString(s_prefix+QStringLiteral("blue"));
graphic->attributes()->setAttributesMap(rawAttributes);
qCritical() << " XXXXX set rawAttributes " << rawAttributes;
}
return;
}
void FunctionDialog::onGenerate3DGraphicSphereRENDERER()
{
int instances = 1000;
qCritical() << " onGenerate3DGraphicSphereRENDERER, instances=" << instances;
// setup Renderer
// Renderer
QColor col = Qt::green;
col.setAlphaF(0.5);
Esri::ArcGISRuntime::SimpleMarkerSceneSymbol *sym =
Esri::ArcGISRuntime::SimpleMarkerSceneSymbol::sphere(col, 25, Esri::ArcGISRuntime::SceneSymbolAnchorPosition::Center);
Q_UNUSED(sym);
// symbol
static QString resourcePath = SituationMap::getResourcePath() + QDir::separator() + QStringLiteral("3Dmodels") + QDir::separator();
QUrl url = QUrl(resourcePath + QString(QStringLiteral("SPD/buildings/Bruecke_20m/Bruecke_20m.dae"))); // modelled horizontal
// QUrl url(QStringLiteral("/tmp/Halbkugel.fbx"));
const float scale = 4.0;
Esri::ArcGISRuntime::ModelSceneSymbol *modelSceneSymbol =
new Esri::ArcGISRuntime::ModelSceneSymbol(url, scale); // url, scale
modelSceneSymbol->setHeading(45);
modelSceneSymbol->setRoll(115);
modelSceneSymbol->setPitch(75);
modelSceneSymbol->setColor(Qt::red);
// Esri::ArcGISRuntime::Symbol* symbol = sym;
Esri::ArcGISRuntime::Symbol* symbol = modelSceneSymbol;
qCritical() << " USE RENDERER";
Esri::ArcGISRuntime::SimpleRenderer *renderer = new Esri::ArcGISRuntime::SimpleRenderer(symbol, this);
d->m_graphicsLayer->setRenderer(renderer);
//-----------------------------------------------------
//-----------------------------------------------------
//-----------------------------------------------------
const Esri::ArcGISRuntime::Viewpoint &vp =
d->m_mapGeoView->currentViewpoint(Esri::ArcGISRuntime::ViewpointType::CenterAndScale);
const Esri::ArcGISRuntime::Point &mapCenter = static_cast<Esri::ArcGISRuntime::Point>(vp.targetGeometry());
MEMORY_LOG() << " START";
if (!d->m_impactCircleSphere.isEmpty())
{
qCritical() << " onGenerate3DGraphicSphereRENDERER DESTROY " << instances;
for (Private::object3D_data &data : d->m_impactCircleSphere)
d->m_graphicsLayer->graphics()->removeOne(data.m_graphic.get());
d->m_impactCircleSphere.clear();
}
else
{
if (d->m_mapImpl->mode() != Mode::Mode_3D)
return;
int i = 0;
d->m_impactCircleSphere.resize(instances);
for (Private::object3D_data &data : d->m_impactCircleSphere)
{
data.m_position = Esri::ArcGISRuntime::Point(mapCenter.x(), mapCenter.y()+ (0.001 * i));
++i;
data.m_graphic = std::shared_ptr<Esri::ArcGISRuntime::Graphic>(new Esri::ArcGISRuntime::Graphic(data.m_position));
// static int myGraphicCnt = 0; connect(data.m_graphic.get(), &QObject::destroyed, [] () { qCritical() << " myGraphic destroyed cnt=" << ++myGraphicCnt; });
d->m_graphicsLayer->graphics()->append(data.m_graphic.get());
} // for
}
MEMORY_LOG() << " END";
}
void FunctionDialog::onSphereOpacityChangedRENDERER(int opacityValue)
{
// update Renderer:
Esri::ArcGISRuntime::Renderer* myRenderer = d->m_graphicsLayer->renderer();
if (!myRenderer)
return;
Esri::ArcGISRuntime::SimpleRenderer *simpleRenderer = dynamic_cast<Esri::ArcGISRuntime::SimpleRenderer *>(myRenderer);
if (!simpleRenderer)
return;
// Symbol
Esri::ArcGISRuntime::Symbol* mySymbol = simpleRenderer->symbol();
if (!mySymbol)
return;
Esri::ArcGISRuntime::SimpleMarkerSceneSymbol *sym = dynamic_cast<Esri::ArcGISRuntime::SimpleMarkerSceneSymbol *>(mySymbol);
if (!sym)
return;
QColor col = Qt::green;
col.setAlphaF(opacityValue/100.0);
sym->setColor(col);
// Esri::ArcGISRuntime::SimpleMarkerSceneSymbol *sym =
// Esri::ArcGISRuntime::SimpleMarkerSceneSymbol::sphere(col, 10, Esri::ArcGISRuntime::SceneSymbolAnchorPosition::Center);
// simpleRenderer->setSymbol(sym);
}
void FunctionDialog::onGenerate3DGraphicSphere()
{
int instances = 1000;
qCritical() << " onGenerate3DGraphicSphere, instances=" << instances;
const Esri::ArcGISRuntime::Viewpoint &vp =
d->m_mapGeoView->currentViewpoint(Esri::ArcGISRuntime::ViewpointType::CenterAndScale);
const Esri::ArcGISRuntime::Point &mapCenter = static_cast<Esri::ArcGISRuntime::Point>(vp.targetGeometry());
MEMORY_LOG() << " START";
if (!d->m_impactCircleSphere.isEmpty())
{
qCritical() << " onGenerate3DGraphicSphere DESTROY " << instances;
for (Private::object3D_data &data : d->m_impactCircleSphere)
d->m_graphicsLayer->graphics()->removeOne(data.m_graphic.get());
d->m_impactCircleSphere.clear();
return;
}
else
{
d->m_impactCircleSphere.resize(instances);
int i = 0;
for (Private::object3D_data &data : d->m_impactCircleSphere)
{
data.m_position = Esri::ArcGISRuntime::Point(mapCenter.x(), mapCenter.y()+ (0.00001 * i));
++i;
if (d->m_mapImpl->mode() == Mode::Mode_2D)
{
data.m_graphic = std::shared_ptr<Esri::ArcGISRuntime::Graphic>(new Esri::ArcGISRuntime::Graphic(data.m_position));
Esri::ArcGISRuntime::SimpleMarkerSymbol redCircle(Esri::ArcGISRuntime::SimpleMarkerSymbolStyle::Circle, Qt::red, 10);
data.m_graphic->setSymbol(&redCircle);
d->m_graphicsLayer->graphics()->append(data.m_graphic.get());
}
else if (d->m_mapImpl->mode() == Mode::Mode_3D)
{
// SimpleMarkerSceneSymbol(SimpleMarkerSceneSymbolStyle style, const QColor& color, double height, double width, double depth, SceneSymbolAnchorPosition anchorPosition, QObject* parent = nullptr);
QColor col = Qt::red;
col.setAlphaF(0.5);
data.m_graphic = std::shared_ptr<Esri::ArcGISRuntime::Graphic>(new Esri::ArcGISRuntime::Graphic(data.m_position));
// static int myGraphicCnt = 0; connect(data.m_graphic.get(), &QObject::destroyed, [] () { qCritical() << " myGraphic destroyed cnt=" << ++myGraphicCnt; });
Esri::ArcGISRuntime::SimpleMarkerSceneSymbol *sym =
Esri::ArcGISRuntime::SimpleMarkerSceneSymbol::sphere(col, 25, Esri::ArcGISRuntime::SceneSymbolAnchorPosition::Center, data.m_graphic.get());
// static int mySymbolCnt = 0; connect(sym, &QObject::destroyed, [] () { qCritical() << " sphere destroyed cnt=" << ++mySymbolCnt; });
data.m_graphic->setSymbol(sym);
d->m_graphicsLayer->graphics()->append(data.m_graphic.get());
}
} // for
}
MEMORY_LOG() << " END";
}
void FunctionDialog::onSphereOpacityChanged(int opacityValue)
{
for (Private::object3D_data &data : d->m_impactCircleSphere)
{
Esri::ArcGISRuntime::SimpleMarkerSceneSymbol *sym = dynamic_cast<Esri::ArcGISRuntime::SimpleMarkerSceneSymbol*>(data.m_graphic->symbol());
if (!sym)
return;
QColor col = sym->color();
col.setAlphaF(opacityValue/100.0);
sym->setColor(col);
data.m_graphic->setSymbol(sym);
} // for
}
void FunctionDialog::onSphereZValueChanged(int ZValue)
{
qCritical() << " onSphereZValueChanged -> " << ZValue;
for (Private::object3D_data &data : d->m_impactCircleSphere)
{
Esri::ArcGISRuntime::Point newPnt(data.m_position.x(),
data.m_position.y(),
data.m_position.z()+ZValue);
data.m_graphic->setGeometry(newPnt);
} // for
}
//
// 3DGraphic Cone
//
void FunctionDialog::onGenerate3DGraphicCone()
{
int instances = 1000;
qCritical() << " onGenerate3DGraphicCone, instances=" << instances;
const Esri::ArcGISRuntime::Viewpoint &vp =
d->m_mapGeoView->currentViewpoint(Esri::ArcGISRuntime::ViewpointType::CenterAndScale);
const Esri::ArcGISRuntime::Point &mapCenter = static_cast<Esri::ArcGISRuntime::Point>(vp.targetGeometry());
MEMORY_LOG() << " START";
if (!d->m_impactCone.isEmpty())
{
qCritical() << " onGenerate3DGraphicCone DESTROY " << instances;
for (Private::object3D_data &data : d->m_impactCone)
d->m_graphicsLayer->graphics()->removeOne(data.m_graphic.get());
d->m_impactCone.clear();
}
else
{
d->m_impactCone.resize(instances);
int i = 0;
for (Private::object3D_data &data : d->m_impactCone)
{
data.m_position = Esri::ArcGISRuntime::Point(mapCenter.x(), mapCenter.y()+ (0.001 * i));
++i;
if (d->m_mapImpl->mode() == Mode::Mode_2D)
{
Esri::ArcGISRuntime::SimpleMarkerSymbol redCircle(Esri::ArcGISRuntime::SimpleMarkerSymbolStyle::Circle, Qt::red, 10);
Esri::ArcGISRuntime::Graphic *myGraphic = new Esri::ArcGISRuntime::Graphic(data.m_position, &redCircle);
d->m_graphicsLayer->graphics()->append(myGraphic);
}
else if (d->m_mapImpl->mode() == Mode::Mode_3D)
{
// SimpleMarkerSceneSymbol(SimpleMarkerSceneSymbolStyle style, const QColor& color, double height, double width, double depth, SceneSymbolAnchorPosition anchorPosition, QObject* parent = nullptr);
QColor col = Qt::red;
col.setAlphaF(0.5);
if (!data.m_graphic)
{
data.m_graphic = std::shared_ptr<Esri::ArcGISRuntime::Graphic>(new Esri::ArcGISRuntime::Graphic(data.m_position));
Esri::ArcGISRuntime::SimpleMarkerSceneSymbol *sym =
Esri::ArcGISRuntime::SimpleMarkerSceneSymbol::cone(col, 2, 1.0, data.m_graphic.get()); // color, diameter, height
data.m_graphic->setSymbol(sym);
d->m_graphicsLayer->graphics()->append(data.m_graphic.get());
}
// update values:
data.m_graphic->setGeometry(data.m_position);
}
} // for
}
MEMORY_LOG() << " END";
}
void FunctionDialog::onConeOpacityChanged(int opacityValue)
{
for (Private::object3D_data &data : d->m_impactCone)
{
if (!data.m_graphic)
return;
Esri::ArcGISRuntime::SimpleMarkerSceneSymbol *sym = dynamic_cast<Esri::ArcGISRuntime::SimpleMarkerSceneSymbol*>(data.m_graphic->symbol());
if (!sym)
return;
QColor col = sym->color();
col.setAlphaF(opacityValue/100.0);
sym->setColor(col);
data.m_graphic->setSymbol(sym);
} // for
}
void FunctionDialog::onConeZValueChanged(int ZValue)
{
qCritical() << " onConeZValueChanged -> " << ZValue;
for (Private::object3D_data &data : d->m_impactCone)
{
if (!data.m_graphic)
return;
Esri::ArcGISRuntime::Point newPnt(data.m_position.x(),
data.m_position.y(),
data.m_position.z()+ZValue);
data.m_graphic->setGeometry(newPnt);
}
}
void FunctionDialog::onConeHeadingChanged(float angle)
{
qCritical() << " onConeHeadingChanged -> " << angle;
for (Private::object3D_data &data : d->m_impactCone)
{
if (!data.m_graphic)
return;
Esri::ArcGISRuntime::SimpleMarkerSceneSymbol *sym = dynamic_cast<Esri::ArcGISRuntime::SimpleMarkerSceneSymbol*>(data.m_graphic->symbol());
if (!sym)
return;
sym->setHeading(angle);
data.m_graphic->setSymbol(sym);
} // for
}
void FunctionDialog::onConeRollChanged(float angle)
{
qCritical() << " onConeRollChanged -> " << angle;
for (Private::object3D_data &data : d->m_impactCone)
{
if (!data.m_graphic)
return;
Esri::ArcGISRuntime::SimpleMarkerSceneSymbol *sym = dynamic_cast<Esri::ArcGISRuntime::SimpleMarkerSceneSymbol*>(data.m_graphic->symbol());
if (!sym)
return;
sym->setRoll(angle);
data.m_graphic->setSymbol(sym);
} // for
}
void FunctionDialog::onConePitchChanged(float angle)
{
qCritical() << " onConePitchChanged -> " << angle;
for (Private::object3D_data &data : d->m_impactCone)
{
Esri::ArcGISRuntime::SimpleMarkerSceneSymbol *sym = dynamic_cast<Esri::ArcGISRuntime::SimpleMarkerSceneSymbol*>(data.m_graphic->symbol());
if (!sym)
return;
sym->setPitch(angle);
data.m_graphic->setSymbol(sym);
} // for
}
void FunctionDialog::on3dModel()
{
int instances = 100;
// Graphic:
const Esri::ArcGISRuntime::Viewpoint &vp =
d->m_mapGeoView->currentViewpoint(Esri::ArcGISRuntime::ViewpointType::CenterAndScale);
const Esri::ArcGISRuntime::Point &mapCenter = static_cast<Esri::ArcGISRuntime::Point>(vp.targetGeometry());
MEMORY_LOG() << " START";
// symbol
static QString resourcePath = SituationMap::getResourcePath() + QDir::separator() + QStringLiteral("3Dmodels") + QDir::separator();
QUrl url = QUrl(resourcePath + QString(QStringLiteral("SPD/buildings/Bruecke_20m/Bruecke_20m.dae"))); // modelled horizontal
const float scale = 2.0;
Esri::ArcGISRuntime::ModelSceneSymbol *modelSceneSymbol =
new Esri::ArcGISRuntime::ModelSceneSymbol(url, scale); // url, scale
if (!d->m_3dModel.isEmpty())
{
qCritical() << " on3dModel DESTROY " << instances;
for (Private::object3D_data &data : d->m_3dModel)
d->m_graphicsLayer->graphics()->removeOne(data.m_graphic.get());
d->m_3dModel.clear();
}
else
{
d->m_3dModel.resize(instances);
int i = 0;
for (Private::object3D_data &data : d->m_3dModel)
{
if (d->m_mapImpl->mode() != Mode::Mode_3D)
return;
data.m_position = Esri::ArcGISRuntime::Point(mapCenter.x(), mapCenter.y()+ (0.001 * i));
++i;
if (!data.m_graphic)
{
data.m_graphic = std::shared_ptr<Esri::ArcGISRuntime::Graphic>(new Esri::ArcGISRuntime::Graphic(data.m_position));
data.m_graphic->setSymbol(modelSceneSymbol);
d->m_graphicsLayer->graphics()->append(data.m_graphic.get());
}
// update values:
data.m_graphic->setGeometry(data.m_position);
} // for
}
MEMORY_LOG() << " END";
}
void FunctionDialog::on3dModelZValueChanged(int ZValue)
{
qCritical() << " on3dModelZValueChanged -> " << ZValue;
for (Private::object3D_data &data : d->m_3dModel)
{
if (!data.m_graphic)
return;
Esri::ArcGISRuntime::Point newPnt(data.m_position.x(),
data.m_position.y(),
data.m_position.z()+ZValue);
data.m_graphic->setGeometry(newPnt);
}
}
void FunctionDialog::onGenerate3DGraphicConeUniqueValueRenderer()
{
qCritical() << " onGenerate3DGraphicConeUniqueValueRenderer";
MEMORY_LOG() << " START";
const QString layernameAES(QStringLiteral("AES"));
LayerFactoryImpl &layerFactory = d->m_mapImpl->layerFactoryImpl();
Esri::ArcGISRuntime::GraphicsOverlay *graphicsLayer = layerFactory.getGraphicsLayer(layernameAES);
if (!d->m_impactConeViaUniqueValueRenderer.isEmpty())
{
qCritical() << " onGenerate3DGraphicConeUniqueValueRenderer DESTROY " << d->m_impactConeViaUniqueValueRenderer.size();
for (Private::object3D_data &data : d->m_impactConeViaUniqueValueRenderer)
graphicsLayer->graphics()->removeOne(data.m_graphic.get());
d->m_impactConeViaUniqueValueRenderer.clear();
MEMORY_LOG() << " START";
return;
}
QVector<LayerFactory::UniqueValueDataAesCentral::TYPE> typeVec;
typeVec << LayerFactory::UniqueValueDataAesCentral::TYPE::CONE;
typeVec << LayerFactory::UniqueValueDataAesCentral::TYPE::SPHERE;
QVector<QColor> colVec;
colVec << Qt::darkMagenta << Qt::darkGreen;
QVector<float> radiuss;
radiuss << 10 << 1 << 2.5 << 5 << 10 << 20;
colVec.first().setAlpha(128);
// init
// Assume that typically the layer does not have a renderer:
if (graphicsLayer->renderer())
{
qCritical() << " onGenerate3DGraphicConeUniqueValueRenderer, there is already a renderer assigned: " << graphicsLayer->renderer()->objectName();
} else {
QVector<LayerFactory::UniqueValueDataAesCentral> uvCont;
for (const LayerFactory::UniqueValueDataAesCentral::TYPE &type : std::as_const(typeVec))
{
for (const QColor &col : std::as_const(colVec))
{
for (float radius : std::as_const(radiuss))
{
LayerFactory::UniqueValueDataAesCentral uvd;
QString singleVal;
// V100.8: order seems to be relevant. Keep alphabetical;
singleVal = QString(QStringLiteral("Impact_Color_%1")).arg(col.name());
uvd.values.append(singleVal);
singleVal = QString(QStringLiteral("Impact_Radius_%1")).arg(radius);
uvd.values.append(singleVal);
singleVal = QString(QStringLiteral("Impact_Type_%1")).arg(LayerFactory::toString(type));
uvd.values.append(singleVal);
uvd.type = type;
uvd.col = col;
uvd.radius = radius;
uvd.height = uvd.radius;
uvCont.append(uvd);
} // for
} // for
} // for
QStringList fieldnames;
// V100.8: order seems to be relevant. keep alphabetical
fieldnames.append(QString(QStringLiteral("IMPACT_COLOR")));
fieldnames.append(QString(QStringLiteral("IMPACT_RADIUS")));
fieldnames.append(QString(QStringLiteral("IMPACT_TYPE")));
bool success =
d->m_mapInterface->layerFactory().assignUniqueValueRendererAesCentral(layernameAES,
fieldnames,
uvCont);
qCritical() << " onGenerate3DGraphicConeUniqueValueRenderer, success=" << success;
}
// create graphics:
{
qCritical() << " onGenerate3DGraphicConeUniqueValueRenderer, setup Instances...";
// Graphic:
const Esri::ArcGISRuntime::Viewpoint &vp =
d->m_mapGeoView->currentViewpoint(Esri::ArcGISRuntime::ViewpointType::CenterAndScale);
const Esri::ArcGISRuntime::Point &mapCenter = static_cast<Esri::ArcGISRuntime::Point>(vp.targetGeometry());
d->m_impactConeViaUniqueValueRenderer.clear();
int n = 0;
while (++n < 500)
radiuss.append(20);
int k = 0;
for (const QColor &col : std::as_const(colVec))
{
int i = 0;
for (float radius : std::as_const(radiuss))
{
Private::object3D_data data;
data.m_position = Esri::ArcGISRuntime::Point(mapCenter.x() + (0.001 * k), mapCenter.y() + (0.001 * i));
data.m_graphic = std::shared_ptr<Esri::ArcGISRuntime::Graphic>(new Esri::ArcGISRuntime::Graphic(data.m_position));
QVariantMap attribMap;
QString attribValue;
attribValue = QString(QStringLiteral("Impact_Color_%1")).arg(col.name());
attribMap.insert(QStringLiteral("IMPACT_COLOR"), attribValue);
attribValue = QString(QStringLiteral("Impact_Radius_%1")).arg(radius);
attribMap.insert(QStringLiteral("IMPACT_RADIUS"), attribValue);
LayerFactory::UniqueValueDataAesCentral::TYPE type{LayerFactory::UniqueValueDataAesCentral::TYPE::CONE};
if (i%2)
type = LayerFactory::UniqueValueDataAesCentral::TYPE::SPHERE;
attribValue = QString(QStringLiteral("Impact_Type_%1")).arg(LayerFactory::toString(type));
attribMap.insert(QStringLiteral("IMPACT_TYPE"), attribValue);
// SceneProperties: HEADING, PITCH, ROLL
attribMap.insert(QStringLiteral("HEADING"), ((10*i)%360) );
attribMap.insert(QStringLiteral("PITCH"), ((30*i)%360));
attribMap.insert(QStringLiteral("ROLL"), ((30*i)%360));
// qCritical() << " attribMap " << attribMap;
data.m_graphic->attributes()->setAttributesMap(attribMap);
graphicsLayer->graphics()->append(data.m_graphic.get());
d->m_impactConeViaUniqueValueRenderer.append(data);
++i;
} // for
++k;
} // for
qCritical() << " onGenerate3DGraphicConeUniqueValueRenderer, setup Instances..." << d->m_impactConeViaUniqueValueRenderer.size();
}
MEMORY_LOG() << " END";
}
void FunctionDialog::onAddCivilSymbols()
{
AdvancedSymbology::SymbolDictionary &dict = d->m_mapImpl->symbolDictionary();
int files = dict.addEtsSymbols(QLatin1String(":/advancedSymbology/CivilSymbols"));
qWarning() << LOGFUNCTION << " dict.addCivilSymbols() = " << files;
AdvancedSymbology::SymbolProperties symProps;
dict.insertXmlTestSymbol(symProps);
qWarning() << LOGFUNCTION << " dict.insertXmlTestSymbol (sidc=" << symProps.sidc() << ")";
}
void FunctionDialog::onMessage()
{
/*
QString messageId = QLatin1String("mySpecialId");
if (d->m_messageGroupLayer)
{
EsriRuntimeQt::SpatialReference sr = d->m_esriMap->spatialReference();
//create and process message, adding it to the map
EsriRuntimeQt::Message message;
message.setProperty(QLatin1String("_id"), messageId);
message.setProperty(QLatin1String("_type"), QLatin1String("position_report"));
message.setProperty(QLatin1String("_action"), QLatin1String("update"));
EsriRuntimeQt::Point mapPoint(0, 0, sr);
QString ctrlPoints = QString::number(mapPoint.x(), 'f') + QLatin1Char(',') + QString::number(mapPoint.y(), 'f');
message.setProperty(QLatin1String("_control_points"), ctrlPoints);
// 123456789012345
// message.setProperty(QLatin1String("sic"), "SFGPUSAC-------");
message.setProperty(QLatin1String("sic"), QLatin1String("GFGPOPP-------X"));
message.setProperty(QLatin1String("_wkid"), QString::number(d->m_esriMap->spatialReference().wkid()));
message.setProperty(QLatin1String("uniquedesignation"), QLatin1String("MySymbolName"));
qDebug() << "message = " << message.toString();
if (d->m_messageGroupLayer->messageProcessor()->processMessage(message))
{
qDebug() << "message processed OK" ;
qDebug() << "message = '" << message.toString() << "'";
messageId = message.messageId();
}
else
qWarning() << "message processed NOT OK" ;
QList<EsriRuntimeQt::Layer *> layerList = d->m_messageGroupLayer->getLayers();
for ( auto layer, layerList)
qDebug() << "MessageGroupLayer consists of layer " << static_cast<int>(layer->type());
}
else
{
qWarning() << "no messageGroupLayer";
QMessageBox msgBox;
msgBox.setText(QLatin1String("no messageGroupLayer"));
msgBox.exec();
}
*/
}
void FunctionDialog::onMessageSelect()
{
/*
QString messageId = QLatin1String("mySpecialId");
if (d->m_messageGroupLayer)
{
static bool select = true;
EsriRuntimeQt::Message message;
// arcGIS 10.2.6: createSelectMessage generates a wrong message
// -> wrong : .. {_action,highlight}...
// -> correct: .. {_action,select}...
// message = EsriRuntimeQt::MessageHelper::createSelectMessage(EsriRuntimeQt::SymbolDictionaryType::Mil2525C,
// messageId,
// QLatin1String("position_report"),
// true);
message.setMessageId(messageId);
message.setProperty(QLatin1String("_type"), QLatin1String("position_report"));
if (select)
message.setProperty(QLatin1String("_action"), QLatin1String("select"));
else
message.setProperty(QLatin1String("_action"), QLatin1String("un-select"));
// toggle
select = ! select;
qDebug() << "message = " << message.toString();
if (d->m_messageGroupLayer->messageProcessor()->processMessage(message))
qDebug() << "createSelectMessage processed OK" ;
else
qWarning() << "createSelectMessage processed NOT OK" ;
}
else
{
qWarning() << "no messageGroupLayer or messageId.isEmpty";
QMessageBox msgBox;
msgBox.setText(QLatin1String("no messageGroupLayer"));
msgBox.exec();
}
*/
}
void FunctionDialog::onAddSymbol()
{
QString fileNameAndPath = QFileDialog::getOpenFileName(this, tr("Add Symbol"),
QLatin1String("/tmp"),
tr("Images (*.png)"));
QImage symImg(fileNameAndPath);
QFileInfo fi(fileNameAndPath);
const QString &baseName = fi.baseName();
AdvancedSymbology::SymbolProperties symProps;
symProps.setName(baseName);
symProps.setKey(baseName);
if ( d->m_mapImpl->symbolDictionary().setEtsSymbol(4711, baseName, symProps, symImg) )
qDebug() << " insertExtraSymbol ok";
else
qCritical() << " insertExtraSymbol failed";
}
void FunctionDialog::onSomeParticipants()
{
//
// place participants
//
QStringList sidcs;
// 1=Team/Crew, 2=Squad, 3=Section, 4=Platoon, 5=Company, 6=Battalion
// 12345678||
sidcs += AdvancedSymbology::SidcCodec::encodeComplete( AdvancedSymbology::SymbologyType::MIL2525D, "10031500111202000000"); // 01015000001202000000 -> 15 120200 LandEquip, Tank
sidcs += AdvancedSymbology::SidcCodec::encodeComplete( AdvancedSymbology::SymbologyType::MIL2525D, "10031500121202000000"); // 01015000001202000000 -> 15 120200 LandEquip, Tank
sidcs += AdvancedSymbology::SidcCodec::encodeComplete( AdvancedSymbology::SymbologyType::MIL2525D, "10031500131202000000"); // 01015000001202000000 -> 15 120200 LandEquip, Tank
sidcs += AdvancedSymbology::SidcCodec::encodeComplete( AdvancedSymbology::SymbologyType::MIL2525D, "10031500141202000000"); // 01015000001202000000 -> 15 120200 LandEquip, Tank
sidcs += AdvancedSymbology::SidcCodec::encodeComplete( AdvancedSymbology::SymbologyType::MIL2525D, "10031500151202000000"); // 01015000001202000000 -> 15 120200 LandEquip, Tank
sidcs += AdvancedSymbology::SidcCodec::encodeComplete( AdvancedSymbology::SymbologyType::MIL2525D, "10031500161202000000"); // 01015000001202000000 -> 15 120200 LandEquip, Tank
int counter = 0;
for (const QString &sidc : std::as_const(sidcs))
{
++counter;
const QString &layername = QStringLiteral("Participants_%1").arg(counter);
// set additional values:
SituationMap::SymbolData symData;
symData.sidc = sidc;
// create and set debugInfo for debugging:
const QString &debugInfo = layername;
RefPointer<SituationMap::Participant> participant =
d->m_mapInterface->objectFactory().
create<SituationMap::Participant>(layername, debugInfo);
if (!participant)
{
qDebug() << LOGFUNCTION << " no object";
return;
}
symData.color = Qt::red; // Will be overwritten via partyId.
symData.size = 2;
participant->setSymbol(symData);
participant->setTextModifier(Participant::TextModifier::T_UniqueDesignation, layername.right(1));
// QPointF(92750, 80525) -> Rennplatz - Bremen
const QPointF &origin = s_basePoint.geographic(QPointF(90000 + counter * 100, 80000 + counter * 100));
participant->setOrigin(Point3D::fromQPointF(origin));
participant->updateView();
}
}
void FunctionDialog::onParticipantGetPosition()
{
qWarning() << LOGFUNCTION << "XXXXXXXXXX";
if (d->m_participant)
{
d->m_participant->removeMySelf();
d->m_participant.reset();
}
// if (d->m_mapGeoView)
{
// AdvancedSymbology::SymbolDictionary &dict = d->m_mapImpl->symbolDictionary();
QString sidc(AdvancedSymbology::SidcCodec::encodeComplete( AdvancedSymbology::SymbologyType::MIL2525C, "SFGPUCD---MR"));
if ((d->m_cbRubSidc)
// && (d->m_cbRubSidc->currentText().length() <= 15) // civil symbols:
)
sidc = d->m_cbRubSidc->currentText();
// if (!dict.contains(sidc))
// {
// qWarning() << "sidc not found";
// return;
// }
// const QImage &symbolImage = dict.symbolImageBySidc(sidc, 32);
// if (symbolImage.isNull())
// {
// qWarning() << "symbolImageBySidc failed";
// return;
// }
RB::RubberbandPointFeature *rubberband = d->m_mapInterface->rubberbandFactory().create<RB::RubberbandPointFeature>();
if (!rubberband)
{
qWarning() << "Creating rubberband to get participant position failed";
return;
}
rubberband->maximumPointCount(1); // rubberband will finish after first mouse click
// rubberband->connectPreviewPixmap(QPixmap::fromImage(symbolImage));
rubberband->setUserData(new QString(sidc));
rubberband->setPreviewSidc(sidc);
connect(rubberband, &RB::RubberbandPointFeature::apply, this, &FunctionDialog::onParticipantGetPositionApplied);
connect(rubberband, &RB::RubberbandPointFeature::abort, rubberband, &RB::Rubberband::deleteMySelf);
}
} /* FunctionDialog::onParticipantGetPosition */
void FunctionDialog::onParticipantGetPositionApplied(RB::RubberbandBase *rubberband)
{
qDebug() << LOGFUNCTION;
if (! rubberband)
{
qWarning() << LOGFUNCTION << " no rubberband anymore!!!";
return;
}
const QPointF &rubberCoord = rubberband->singleCoordinate();
QString *p_sidc = reinterpret_cast<QString *>(rubberband->userData());
if (! p_sidc)
{
qWarning() << LOGFUNCTION << " no sidc anymore!!!";
return;
}
if (! this->createParticipant(Point3D::fromQPointF(rubberCoord),
QLatin1String("ParticipantRubberbandTab"))
)
qWarning() << LOGFUNCTION << " createParticipant (ParticipantRubberbandTab) failed";
SymbolData symData;
symData.sidc = *p_sidc;
d->m_participant->setSymbol(symData);
bool success = d->m_participant->updateView();
qWarning() << LOGFUNCTION << " success (setMovementTrack) =" << success;
// cleanup
delete p_sidc;
rubberband->setUserData(nullptr);
rubberband -> deleteMySelf();
}
bool FunctionDialog::createParticipant(const Point3D &origin,
const QString &debugInfo)
{
qDebug() << LOGFUNCTION << " debugInfo='" << debugInfo << "'";
if (d->m_participant)
{
d->m_participant->removeMySelf();
d->m_participant.reset();
}
// create and set debugInfo for debugging:
d->m_participant = d->m_mapInterface->objectFactory().
create<SituationMap::Participant>(QLatin1String("Participants"), debugInfo);
if (!d->m_participant)
{
qDebug() << LOGFUNCTION << " no object";
return false;
}
d->m_participant->setOrigin(origin);
return true;
}
void FunctionDialog::onParticipantCreate()
{
qDebug() << LOGFUNCTION ;
if (d->m_participant)
{
d->m_participant->removeMySelf();
d->m_participant.reset();
}
// QPointF origin = d->m_objectBasePoint + QPointF( -150000, -150000 );
QPointF originSim = d->m_objectBasePoint + QPointF(88000, 76000);
QPointF originGeo = s_basePoint.geographic(originSim);
QString sidc;
if (d->m_leSidc)
{
QString text = d->m_leSidc->text();
// if (text.length() <= 15) // do not check regarding civil symbols
sidc = text;
}
qWarning() << LOGFUNCTION << " sidc=" << sidc;
bool success = this->createParticipant(Point3D::fromQPointF(originGeo),
QLatin1String("ParticipantMessageTab"));
d->m_participant->setTextModifier(Participant::TextModifier::EF_ReinforcedReduced, QLatin1String("EF_ReinforcedReduced"));
d->m_participant->setTextModifier(Participant::TextModifier::M_HigherFormation, QLatin1String("M_HigherFormation"));
d->m_participant->setTextModifier(Participant::TextModifier::T_UniqueDesignation, QLatin1String("T_UniqueDesignation"));
d->m_participant->setTextModifier(Participant::TextModifier::W_DateTimeGroup, QLatin1String("W_DateTimeGroup"));
d->m_participant->setVisibility(d->m_visibility);
// d->m_participant->setVisibility(SituationMap::ObjectAppearance::Technical, false); // no sense
SymbolData symData;
symData.sidc = sidc;
symData.color = Qt::cyan; // Will be overwritten via partyId.
// symData.size = 0.5;
d->m_participant->setSymbol(symData);
d->m_participant->setPartyId(4);
d->m_participant->setScale(d->getScale());
// d->m_participant->setInjury(Injury::MobilityKill, QColor(Qt::red) ); // QColor() to use the correct signature!
// d->m_participant->setInjury(Injury::TotalKill, 3);
// d->m_participant->setManipulation(true);
// d->m_participant->setBiteError(true);
// d->m_participant->setUseLightColor(true);
// d->m_participant->setNbcProtection(true);
// d->m_participant->setMarked(true);
// d->m_participant->setRanges(QVector<int>() << 8000 << 10000);
if (! success)
{
qWarning() << LOGFUNCTION << " createParticipant (ParticipantMessageTab) failed";
return;
}
// MovementTrack:
d->m_participant->setMovementTrackEnabled(true);
// d->m_participant->setMovementTrackVisibility(true); // visible = true = default
PositionCont intialMovementTrack;
Point3D ppp;
ppp = Point3D::fromQPointF(s_basePoint.geographic(originSim + QPointF(-500, -500)));
ppp.setZ(100);
qCritical() << " ppp=" << ppp.x() << " ; " << ppp.y() << " ; "<< ppp.z();
intialMovementTrack << ppp;
ppp = Point3D::fromQPointF(s_basePoint.geographic(originSim + QPointF(-500, 500)));
ppp.setZ(50);
qCritical() << " ppp=" << ppp.x() << " ; " << ppp.y() << " ; "<< ppp.z();
intialMovementTrack << ppp;
d->m_participant->setMovementTrack(intialMovementTrack);
// DirectionIndicator:
{
Participant::DirectionIndicatorData directionIndicatorData ;
directionIndicatorData.color = Qt::black;
directionIndicatorData.directionDegree = 22;
directionIndicatorData.lineStyle = Qt::SolidLine;
directionIndicatorData.lineWidth = 1;
d->m_participant->setDirectionIndicator(0, directionIndicatorData);
directionIndicatorData.directionDegree = 45;
directionIndicatorData.lineStyle = Qt::DashLine;
directionIndicatorData.lineWidth = 2;
d->m_participant->setDirectionIndicator(1, directionIndicatorData);
directionIndicatorData.directionDegree = 90;
directionIndicatorData.lineStyle = Qt::DashDotDotLine;
directionIndicatorData.lineWidth = 3;
d->m_participant->setDirectionIndicator(2, directionIndicatorData);
}
// Designation:
{
Participant::DesignationData designationData;
designationData.spotLocation.rx() = 0.155; //spotLocation.lon();
designationData.spotLocation.ry() = 0.926; //spotLocation.lat();
designationData.code = 123;
d->m_participant->setDesignations({designationData});
}
success = d->m_participant->updateView();
qWarning() << LOGFUNCTION << " success =" << success;
QTimer *timer = new QTimer(this);
connect(timer, &QTimer::timeout, this, &FunctionDialog::onParticipantUpdate);
timer->setSingleShot(true);
timer->start(2000);
}
void FunctionDialog::onParticipantUpdate()
{
qDebug() << LOGFUNCTION ;
if (!d->m_participant)
{
qDebug() << LOGFUNCTION << " no object anymore";
return;
}
// move
QPointF origin = s_basePoint.geographic(QPointF(93064, 78331));
d->m_participant->setOrigin(Point3D(origin.x(), origin.y(), 100.2345));
d->m_participant->setRanges(QVector<int>() << 50 << 150 << 350 << 500 << 1000 << 1800);
d->m_participant->setRangesVisibility(true);
d->m_participant->setInjury(Injury::TotalKill, QColor(Qt::blue));
d->m_participant->setAdditionalSymbol(SituationMap::AdditionalSymbolType::NbcProtection, true);
d->m_participant->setAdditionalSymbol(SituationMap::AdditionalSymbolType::Manipulation, true);
d->m_participant->setAdditionalSymbol(SituationMap::AdditionalSymbolType::NoPosition, true);
d->m_participant->setAdditionalSymbol(SituationMap::AdditionalSymbolType::BiteError, true);
d->m_participant->setTextModifier(Participant::TextModifier::EF_ReinforcedReduced, QLatin1String("+ "));
SymbolData symData = d->m_participant->symbol();
symData.color = Qt::magenta; // Will be overwritten via partyId (if partyId != -1)
symData.size = 1.0;
d->m_participant->setSymbol(symData);
d->m_participant->setPartyId(4);
d->m_participant->setMarked(true);
// Designation:
{
Participant::DesignationData designationData;
designationData.spotLocation.rx() = 0; //spotLocation.lon();
designationData.spotLocation.ry() = 0; //spotLocation.lat();
designationData.code = 123;
d->m_participant->setDesignations({designationData});
}
bool success = d->m_participant->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
success = d->m_participant->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
// //-----------------------------------
// // second participant near to the first one:
// //-----------------------------------
// Participant* secondPart = d->m_mapImpl->createParticipant();
//
// if (!secondPart)
// {
// qDebug() << LOGFUNCTION << " no object";
// return;
// }
//
// // Set objId for debugging:
// secondPart->setObjId("secondParticipant");
//
// secondPart->setSymbol(d->m_participant->symbol());
// secondPart->setOrigin( d->m_participant->origin() + QPointF(1000, 1000) );
//
// // update view
// success = secondPart->updateView() && success;
//
// if (success)
// qDebug() << LOGFUNCTION << " secondParticipant updateView OK" ;
// else
// qDebug() << LOGFUNCTION << " secondParticipant updateView NOT OK" ;
}
void FunctionDialog::onBuildingCreate()
{
qDebug() << LOGFUNCTION ;
// create and set debugInfo for debugging:
d->clearMapObjectPtr(RefPointer<AbstractMapObject>(d->m_building));
d->m_building = d->m_mapInterface->objectFactory().
create<SituationMap::BuildingOutline>(QLatin1String("AES"), QLatin1String("BuildingOutlineId2"));
if (!d->m_building)
{
qDebug() << LOGFUNCTION << " no object";
return;
}
d->m_building->setIdentifier(QLatin1String("Building"));
d->m_building->setVisibility(d->m_visibility);
d->m_building->setVisibility(SituationMap::ObjectAppearance::Technical, d->m_visibilityTechn);
d->m_building->setVisibility(SituationMap::ObjectAppearance::Tactical, d->m_visibilityTact);
d->m_building->setSelected(d->m_selected);
d->m_building->rTextStyle().setTextColor(Qt::magenta);
d->m_building->rTextStyle().setSize(30);
// d->m_building->rTextStyle().setAngle(-90); // -90 -> north
d->m_building->rTextStyle().setAntiAliased(true);
d->m_building->rTextStyle().setItalic(true);
d->m_building->rTextStyle().setHorizontalAlignment(HorizontalAlignment::Justify);
d->m_building->rTextStyle().setVerticalAlignment(VerticalAlignment::BaseLine);
d->m_building->rFillStyle().setFillColor(QColor(Qt::darkGray));
// set additional values:
SituationMap::PositionCont posCont;
// QPointF offset = d->m_objectBasePoint + QPointF(50000, 50000);
// int extent = 30000;
// posCont << offset - QPointF(0, 0);
// posCont << offset - QPointF(extent, 0);
// posCont << offset - QPointF(extent, extent);
// posCont << offset - QPointF(0, extent);
if (true)
{
// Bt56
appendQPointF(posCont, s_basePoint.geographic(QPointF(93064 , 78331)));
appendQPointF(posCont, s_basePoint.geographic(QPointF(93069.9, 78337.8)));
appendQPointF(posCont, s_basePoint.geographic(QPointF(93076.8, 78331.8)));
appendQPointF(posCont, s_basePoint.geographic(QPointF(93070.9, 78325)));
}
else
{
// Salchau
appendQPointF(posCont, s_basePoint.geographic(QPointF(75000.0 , 13000)));
appendQPointF(posCont, s_basePoint.geographic(QPointF(75000.0 , 13100)));
appendQPointF(posCont, s_basePoint.geographic(QPointF(75100.0 , 13100)));
appendQPointF(posCont, s_basePoint.geographic(QPointF(75100.0 , 13000)));
}
std::cout << " posCont=" << posCont << std::endl;
d->m_building->setPositions(posCont);
d->m_building->setMarker(posCont[0]);
// update view
bool success = d->m_building->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
success = d->m_building->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
std::cout << " building dump: " << (*d->m_building) << std::endl;
QTimer *timer = new QTimer(this);
connect(timer, &QTimer::timeout, this, &FunctionDialog::onBuildingUpdate);
timer->setSingleShot(true);
timer->start(2000);
}
void FunctionDialog::onBuildingUpdate()
{
if (!d->m_building)
{
qDebug() << LOGFUNCTION << " no object anymore";
return;
}
qDebug() << LOGFUNCTION << " update Values.." ;
d->m_building->setIdentifier(d->m_building->identifier() + QLatin1String("Update"));
d->m_building->rTextStyle().setAngle(-45); // -45 -> north/east
d->m_building->setMarker(Point3D());
// Bt56
SituationMap::PositionCont posCont;
appendQPointF(posCont, s_basePoint.geographic(QPointF(93064 , 78331)));
appendQPointF(posCont, s_basePoint.geographic(QPointF(93069.9, 78337.8)));
appendQPointF(posCont, s_basePoint.geographic(QPointF(93076.8, 78331.8)));
appendQPointF(posCont, s_basePoint.geographic(QPointF(93100.9, 78300)));
appendQPointF(posCont, s_basePoint.geographic(QPointF(93070.9, 78325)));
d->m_building->setPositions(posCont);
d->m_building->rLineStyle().setLineColor(Qt::red);
d->m_building->rLineStyle().setLineWidth(6);
d->m_building->rLineStyle().setLinePattern(LinePattern::DashDotDot);
d->m_building->rFillStyle().setFillColor(Qt::yellow);
d->m_building->rFillStyle().setFillPattern(FillPattern::DiagonalCross);
bool success = d->m_building->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
success = d->m_building->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
}
void FunctionDialog::onBiologicalAgentCreate()
{
qDebug() << LOGFUNCTION ;
// create and set debugInfo for debugging:
d->clearMapObjectPtr(RefPointer<AbstractMapObject>(d->m_bAgent));
d->m_bAgent = d->m_mapInterface->objectFactory().
create<SituationMap::BiologicalAgent>(QLatin1String("AES"), QLatin1String("B-AgentId"));
if (!d->m_bAgent)
{
qDebug() << LOGFUNCTION << " no object";
return;
}
d->m_bAgent->setIdentifier(QLatin1String("My BiologicalAgent\nNext Line-OutLined"));
d->m_bAgent->setVisibility(d->m_visibility);
d->m_bAgent->setVisibility(SituationMap::ObjectAppearance::Technical, d->m_visibilityTechn);
d->m_bAgent->setVisibility(SituationMap::ObjectAppearance::Tactical, d->m_visibilityTact);
d->m_bAgent->setSelected(d->m_selected);
d->m_bAgent->rTextStyle().setTextColor(Qt::magenta);
d->m_bAgent->rTextStyle().setSize(30);
d->m_bAgent->rTextStyle().setBold(true);
d->m_bAgent->rTextStyle().setHorizontalAlignment(HorizontalAlignment::Left);
d->m_bAgent->rTextStyle().setHorizontalAlignment(HorizontalAlignment::Justify);
d->m_bAgent->rTextStyle().setVerticalAlignment(VerticalAlignment::Top);
LineStyle lineStyle(Qt::cyan, 5, LinePattern::Solid);
FillStyle fillStyle(Qt::blue, FillPattern::Solid);
d->m_bAgent->setLineStyle(lineStyle);
d->m_bAgent->setFillStyle(fillStyle);
d->m_bAgent->setPartyId(3); // Will overwrite line/fillcolor
d->m_bAgent->setAesState(AesEffectState::Unknown); // != Unknown will overwrite fillPattern
// QPointF center = d->m_objectBasePoint + QPointF(100000, 100000);
QPointF center = d->m_mapImpl->centerPoint();
qWarning() << LOGFUNCTION << " xxxxxxxxxx center=" << center;
// center = s_basePoint.geographic(center);
d->m_bAgent->setOrigin(Point3D::fromQPointF(center));
d->m_bAgent->setRadius(10000);
// Extrusion
d->m_bAgent->setExtrusionHeight(5);
// if setExtrusionColorName is not set, the partyId is used as fallback
// see -> AbstractMapObjectImpl::updateGraphicalObjectExtrusion()
//
// d->m_bAgent->setExtrusionColorName( QColor(Qt::green).name() );
bool success = d->m_bAgent->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
success = d->m_bAgent->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
std::cout << " B-Agent dump: " << (*d->m_bAgent) << std::endl;
QTimer *timer = new QTimer(this);
connect(timer, &QTimer::timeout, this, &FunctionDialog::onBiologicalAgentUpdate);
timer->setSingleShot(true);
timer->start(2000);
}
void FunctionDialog::onBiologicalAgentUpdate()
{
if (!d->m_bAgent)
{
qDebug() << LOGFUNCTION << " no object anymore";
return;
}
if (d->m_mapImpl->mode() == Mode::Mode_2D)
d->m_bAgent->setIdentifier(d->m_bAgent->identifier() + QLatin1String("Upd"));
// modify geometry:
// d->m_bAgent->setOrigin(d->m_bAgent->origin() + Point3D(500, 500, .0));
d->m_bAgent->setRadius(d->m_bAgent->radius() + 50);
LineStyle lineStyle(Qt::red, 6, LinePattern::DashDotDot);
FillStyle fillStyle(Qt::magenta, FillPattern::DiagonalCross);
d->m_bAgent->setLineStyle(lineStyle);
d->m_bAgent->setFillStyle(fillStyle);
d->m_bAgent->setPartyId(4); // Will overwrite line/fillcolor
d->m_bAgent->setAesState(AesEffectState::Prepared); // != Unknown will overwrite fillPattern
SymbolData symData = d->m_bAgent->symbol();
switch (d->m_mapImpl->symbologyType())
{
case AdvancedSymbology::SymbologyType::APP6D:
case AdvancedSymbology::SymbologyType::MIL2525D:
break;
case AdvancedSymbology::SymbologyType::MIL2525C:
symData.sidc = QLatin1String("GUMPNB----"); // only to test modify of sidc
break;
case AdvancedSymbology::SymbologyType::APP6B:
symData.sidc = QLatin1String("GUCPBWC---"); // only to test modify of sidc
break;
case AdvancedSymbology::SymbologyType::None:
// empty
break;
} // switch
d->m_bAgent->setSymbol(symData);
bool success = d->m_bAgent->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
success = d->m_bAgent->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
}
void FunctionDialog::onChemicalAgentCreate()
{
qDebug() << LOGFUNCTION ;
// create and set debugInfo for debugging:
d->clearMapObjectPtr(RefPointer<AbstractMapObject>(d->m_cAgent));
d->m_cAgent = d->m_mapInterface->objectFactory().
create<SituationMap::ChemicalAgent>(QLatin1String("AES"), QLatin1String("C-AgentId"));
if (!d->m_cAgent)
{
qDebug() << LOGFUNCTION << " no object";
return;
}
d->m_cAgent->setIdentifier(QLatin1String("My ChemicalAgent-OutLined"));
d->m_cAgent->setVisibility(d->m_visibility);
d->m_cAgent->setVisibility(SituationMap::ObjectAppearance::Technical, d->m_visibilityTechn);
d->m_cAgent->setVisibility(SituationMap::ObjectAppearance::Tactical, d->m_visibilityTact);
d->m_cAgent->setSelected(d->m_selected);
LineStyle lineStyle(Qt::cyan, 5, LinePattern::Solid);
FillStyle fillStyle(Qt::blue, FillPattern::Null);
d->m_cAgent->setLineStyle(lineStyle);
d->m_cAgent->setFillStyle(fillStyle);
d->m_cAgent->setPartyId(4); // Will overwrite line/fillcolor
d->m_cAgent->setAesState(AesEffectState::Unknown); // != Unknown will overwrite fillPattern
QPointF center = d->m_objectBasePoint + QPointF(90000, 100100);
center = s_basePoint.geographic(center);
d->m_cAgent->setOrigin(Point3D::fromQPointF(center));
d->m_cAgent->setRadius(1000);
bool success = d->m_cAgent->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
success = d->m_cAgent->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
std::cout << " C-Agent dump: " << (*d->m_cAgent) << std::endl;
}
void FunctionDialog::onCubeCreate()
{
qDebug() << LOGFUNCTION ;
d->clearMapObjectPtr(RefPointer<AbstractMapObject>(d->m_cube));
const QString &layernameForCubes = d->m_mapInterface->layerFactory().layernameForCubes();
d->m_cube = d->m_mapInterface->objectFactory().
create<SituationMap::Cube>(layernameForCubes, QLatin1String("CubeID"));
if (!d->m_cube)
{
qDebug() << LOGFUNCTION << " no object";
return;
}
// set additional values:
SituationMap::PositionCont posCont;
QPointF offset = d->m_objectBasePoint + QPointF(92500, 79000);
int extent = 1000;
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF( 0, 0)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(extent, 0)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(extent, extent)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF( 0, extent)));
std::cout << " posCont=" << posCont.size() << std::endl;
d->m_cube->setPositions(posCont);
d->m_cube->setHeight(123456);
d->m_cube->setPartyId(1);
d->m_cube->setDrawOrder(234);
bool success = d->m_cube->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
success = d->m_cube->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
}
void FunctionDialog::onDangerAreaCreate()
{
qDebug() << LOGFUNCTION ;
// create and set debugInfo for debugging:
d->clearMapObjectPtr(RefPointer<AbstractMapObject>(d->m_dangerArea));
d->m_dangerArea = d->m_mapInterface->objectFactory().
create<SituationMap::DangerArea>(QLatin1String("AES"), QLatin1String("DangerAreaId"));
if (!d->m_dangerArea)
{
qDebug() << LOGFUNCTION << " no object";
return;
}
d->m_dangerArea->setIdentifier(QLatin1String("DangerArea-NotOutLined"));
d->m_dangerArea->setVisibility(d->m_visibility);
d->m_dangerArea->setVisibility(SituationMap::ObjectAppearance::Technical, d->m_visibilityTechn);
d->m_dangerArea->setVisibility(SituationMap::ObjectAppearance::Tactical, d->m_visibilityTact);
d->m_dangerArea->setSelected(d->m_selected);
TextStyle textStyle(Qt::yellow);
textStyle.setTextOutlineColor(Qt::white);
textStyle.setTextOutlineWidth(0.5);
LineStyle lineStyle(Qt::yellow, 5, LinePattern::Solid);
FillStyle fillStyle(Qt::blue, FillPattern::DiagonalCross);
d->m_dangerArea->setTextStyle(textStyle);
d->m_dangerArea->setLineStyle(lineStyle);
d->m_dangerArea->setFillStyle(fillStyle);
// set additional values:
SituationMap::PositionCont posCont;
QPointF offset = d->m_objectBasePoint + QPointF(150000, 150000);
int extent = 100000;
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF( 0, 0)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(extent, 0)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(extent, extent)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(extent / 2, extent / 2)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF( 0, extent)));
std::cout << " posCont=" << posCont.size() << std::endl;
d->m_dangerArea->setPositions(posCont);
bool success = d->m_dangerArea->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
success = d->m_dangerArea->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
std::cout << " DangerArea success = " << success << std::endl;
std::cout << " DangerArea dump: " << (*d->m_dangerArea) << std::endl;
QTimer *timer = new QTimer(this);
connect(timer, &QTimer::timeout, this, &FunctionDialog::onDangerAreaUpdate);
timer->setSingleShot(true);
timer->start(2000);
}
void FunctionDialog::onDangerAreaUpdate()
{
if (!d->m_dangerArea)
{
qDebug() << LOGFUNCTION << " no object anymore";
return;
}
d->m_dangerArea->setIdentifier(d->m_dangerArea->identifier() + QLatin1String("Update"));
d->m_dangerArea->rLineStyle().setLineWidth(4);
d->m_dangerArea->rFillStyle().setFillPattern(FillPattern::Null);
d->m_dangerArea->setPartyId(2); // Will overwrite line/fillcolor
// move
QPointF offset(d->m_dangerArea->positions().value(0).toPointF() + QPointF(10000, 10000));
qDebug() << LOGFUNCTION << " update Values.." ;
SituationMap::PositionCont posCont;
int extent = 150000;
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF( 0, 0)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(extent, 0)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(extent * 2, extent)));
// appendQPointF(posCont, s_basePoint.geographic( offset + QPointF(extent/2, extent/2)) ;
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF( 0, extent)));
d->m_dangerArea->setPositions(posCont);
bool success = d->m_dangerArea->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
success = d->m_dangerArea->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
}
void FunctionDialog::onFunctionalAreaCreate()
{
qDebug() << LOGFUNCTION ;
// create and set debugInfo for debugging:
d->clearMapObjectPtr(RefPointer<AbstractMapObject>(d->m_functionalArea));
d->m_functionalArea = d->m_mapInterface->objectFactory().
create<SituationMap::FunctionalArea>(QLatin1String("AES"), QLatin1String("FunctionalAreaId"));
if (!d->m_functionalArea)
{
qDebug() << LOGFUNCTION << " no object";
return;
}
d->m_functionalArea->setIdentifier(QLatin1String("FunctionalArea-OutLined"));
d->m_functionalArea->setVisibility(d->m_visibility);
d->m_functionalArea->setVisibility(SituationMap::ObjectAppearance::Technical, d->m_visibilityTechn);
d->m_functionalArea->setVisibility(SituationMap::ObjectAppearance::Tactical, d->m_visibilityTact);
d->m_functionalArea->setSelected(d->m_selected);
LineStyle lineStyle(Qt::red, 5, LinePattern::Solid);
FillStyle fillStyle(Qt::blue, FillPattern::ForwardDiagonal);
d->m_functionalArea->setLineStyle(lineStyle);
d->m_functionalArea->setFillStyle(fillStyle);
// set additional values:
SituationMap::PositionCont posCont;
QPointF offset = QPointF(93550, 78550);
int extent = 1000;
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF( 0, 0)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(extent, 0)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(extent, extent)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(extent / 2, extent / 2)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF( 0, extent)));
std::cout << " posCont=" << posCont.size() << std::endl;
d->m_functionalArea->setPositions(posCont);
// pointSymbol :
QPointF psOrg = s_basePoint.geographic(offset + QPointF(extent / 2, extent / 2));
d->m_functionalArea->setPointSymbolOrigin(Point3D::fromQPointF(psOrg));
// !!! use only POINT symbols !!!
// DoDo: find adequate sidc
d->m_functionalArea->setPointSymbolSidc(AdvancedSymbology::SidcCodec::encodeComplete( AdvancedSymbology::SymbologyType::MIL2525D, "10012500002108000000")); // Maritime Points : Impact Point
d->m_functionalArea->setPointSymbolSidc(AdvancedSymbology::SidcCodec::encodeComplete( AdvancedSymbology::SymbologyType::MIL2525D, "10031500001102030000")); // Weapon/Weapon System
d->m_functionalArea->setPointSymbolSidc(AdvancedSymbology::SidcCodec::encodeComplete( AdvancedSymbology::SymbologyType::MIL2525D, "10031500001202000000")); // Vehicle : Tank
// d->m_functionalArea->setPointSymbolSidc(AdvancedSymbology::SidcCodec::encodeCivil("ETS_Pers_FW_BerFue")); // Color Replacement not working yet
d->m_functionalArea->setPartyId(2);
// : pointSymbol
bool success = d->m_functionalArea->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
success = d->m_functionalArea->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
std::cout << " FunctionalArea dump: " << (*d->m_functionalArea) << std::endl;
QTimer *timer = new QTimer(this);
connect(timer, &QTimer::timeout, this, &FunctionDialog::onFunctionalAreaUpdate);
timer->setSingleShot(true);
timer->start(2000);
}
void FunctionDialog::onFunctionalAreaUpdate()
{
if (!d->m_functionalArea)
{
qDebug() << LOGFUNCTION << " no object anymore";
return;
}
d->m_functionalArea->rLineStyle().setLineWidth(2);
d->m_functionalArea->rFillStyle().setFillPattern(FillPattern::Null);
d->m_functionalArea->setIdentifier(d->m_functionalArea->identifier() + QLatin1String("Update"));
// move
QPointF offset = QPointF(93550, 78550) + QPointF(100, 100);
qDebug() << LOGFUNCTION << " update Values..";
SituationMap::PositionCont posCont;
int extent = 1000;
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF( 0, 0)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(extent, 0)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(extent * 2, extent)));
// appendQPointF(posCont, s_basePoint.geographic( offset + QPointF(extent/2, extent/2) ));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF( 0, extent)));
d->m_functionalArea->setPositions(posCont);
// pointSymbol :
QPointF pSymOrg = s_basePoint.geographic(offset + QPointF(extent / 2, extent / 2));
d->m_functionalArea->setPointSymbolOrigin(Point3D::fromQPointF(pSymOrg));
d->m_functionalArea->setPartyId(3);
// : pointSymbol
bool success = d->m_functionalArea->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
success = d->m_functionalArea->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
}
void FunctionDialog::onGeoImageCreate()
{
qDebug() << LOGFUNCTION ;
// create and set debugInfo for debugging:
d->clearMapObjectPtr(RefPointer<AbstractMapObject>(d->m_geoImage));
d->m_geoImage = d->m_mapInterface->objectFactory().
create<SituationMap::GeoImage>(QLatin1String("AES"), QLatin1String("GeoImageId"));
if (!d->m_geoImage)
{
qDebug() << LOGFUNCTION << " no object";
return;
}
d->m_geoImage->setIdentifier(QLatin1String("GeoImageIdent")); // maybe empty!?
{
// d->m_geoImage->setProxyImage(); // no proxyImage -> use defaultMarker
QImage mainImage(100, 100, QImage::Format_ARGB32);
mainImage.fill(qRgba(0, 0, 0, 0));
QPainter painter(&mainImage);
painter.setBrush(QBrush(Qt::gray));
painter.setPen(Qt::NoPen);
painter.drawEllipse(mainImage.rect());
painter.setPen(QPen(Qt::red));
painter.drawText(mainImage.rect(), Qt::AlignCenter, QLatin1String("GeoImg"));
painter.end();
d->m_geoImage->setMainImage(mainImage);
d->m_geoImage->setDescription(QLatin1String("desc"));
// d->m_geoImage->setProxyImage(mainImage, QSize(20, 20));
}
d->m_geoImage->setVisibility(d->m_visibility);
d->m_geoImage->setVisibility(SituationMap::ObjectAppearance::Technical, d->m_visibilityTechn);
d->m_geoImage->setVisibility(SituationMap::ObjectAppearance::Tactical, d->m_visibilityTact);
d->m_geoImage->setSelected(d->m_selected);
QPointF origin = s_basePoint.geographic(d->m_objectBasePoint + QPointF(90500, 80500));
d->m_geoImage->setOrigin(Point3D::fromQPointF(origin));
bool success = d->m_geoImage->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
success = d->m_geoImage->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
std::cout << " GeoImage dump: " << (*d->m_geoImage) << std::endl;
}
void FunctionDialog::onMapObjectClicked(const SituationMap::Map::RefPointerMapObjectList &mapObjList,
const QPointF &viewportPosition)
{
qDebug() << LOGFUNCTION ;
// Keep in mind: It´s likely that the application has also such a slot.
for (auto mapObj : mapObjList)
{
qDebug() << LOGFUNCTION << " id=" << mapObj->uniqueMapId()
<< "object-debugInfo=" << mapObj->debugInfo()
<< "object-identifier=" << mapObj->identifier();
// GeoImage:
SituationMap::RefPointer<SituationMap::GeoImage> geoImage(mapObj);
if (geoImage.valid())
{
qDebug() << LOGFUNCTION << " geoImage found, id=" << mapObj->uniqueMapId()
<< "object-debugInfo=" << mapObj->debugInfo()
<< "object-identifier=" << mapObj->identifier();
QWidget *geoImageWidget = geoImage->createWidget();
if (!geoImageWidget)
{
qDebug() << LOGFUNCTION << " geoImage found, id=" << mapObj->uniqueMapId()
<< "object-debugInfo=" << mapObj->debugInfo()
<< "object-identifier=" << mapObj->identifier()
<< " no mainImage provided!?";
return;
}
// Bug iOSQz-000005 'QGraphicsProxyWidget will crash'
// Adding a widget will let the application crash
// Workaround: 'proxy->setOpacity(0.99);'
QGraphicsProxyWidget *proxyWidget = d->m_mapInterface->getQGraphicsView()->scene()->addWidget(geoImageWidget);
proxyWidget->setOpacity(0.99);
proxyWidget->setPos(viewportPosition + QPointF(10, 10));
return; // to do it for just one GeoImage
}
} // for
}
void FunctionDialog::onSoundAreaCreate()
{
qDebug() << LOGFUNCTION ;
// create and set debugInfo for debugging:
d->clearMapObjectPtr(RefPointer<AbstractMapObject>(d->m_soundArea));
d->m_soundArea = d->m_mapInterface->objectFactory().
create<SituationMap::SoundArea>(QLatin1String("AES"), QLatin1String("SoundAreaId"));
if (!d->m_soundArea)
{
qDebug() << LOGFUNCTION << " no object";
return;
}
d->m_soundArea->setIdentifier(QLatin1String("SoundAreaIdent")); // maybe empty!?
SituationMap::PositionCont posCont;
QPointF offset = QPointF(93000, 78000);
int extent = 1123;
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF( 0, 0)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(extent, 0)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(extent, extent)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(extent / 2, extent / 2)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF( 0, extent)));
std::cout << " posCont=" << posCont.size() << std::endl;
d->m_soundArea->setPositions(posCont);
{
QImage img(100, 100, QImage::Format_ARGB32);
img.fill(qRgba(0, 0, 0, 0));
QPainter painter(&img);
painter.setBrush(QBrush(Qt::red));
painter.setPen(Qt::NoPen);
painter.drawEllipse(img.rect());
painter.setPen(QPen(Qt::black));
painter.drawText(img.rect(), Qt::AlignCenter, QLatin1String("Img"));
painter.end();
d->m_soundArea->setMarkerData(MarkerData(img, QSize(40, 40))); // image in high resolution and small (default) size
d->m_soundArea->setMarkerOrigin(posCont[3]);
}
d->m_soundArea->setVisibility(d->m_visibility);
d->m_soundArea->setVisibility(SituationMap::ObjectAppearance::Technical, d->m_visibilityTechn);
d->m_soundArea->setVisibility(SituationMap::ObjectAppearance::Tactical, d->m_visibilityTact);
d->m_soundArea->setSelected(d->m_selected);
bool success = d->m_soundArea->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
success = d->m_soundArea->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
std::cout << " GeoImage dump: " << (*d->m_soundArea) << std::endl;
QTimer *timer = new QTimer(this);
connect(timer, &QTimer::timeout, this, &FunctionDialog::onSoundAreaUpdate);
timer->setSingleShot(true);
timer->start(2000);
}
void FunctionDialog::onSoundAreaUpdate()
{
if (!d->m_soundArea)
{
qDebug() << LOGFUNCTION << " no object anymore";
return;
}
{
// changed pos
SituationMap::PositionCont posCont = d->m_soundArea->positions();
d->m_soundArea->setMarkerOrigin(posCont[2]);
}
{
// changed img to marker
d->m_soundArea->setMarkerData(MarkerData(MarkerSymbolType::Cross, 20, Qt::cyan));
}
bool success = d->m_soundArea->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
}
void FunctionDialog::onHitLineCreate()
{
qDebug() << LOGFUNCTION ;
// create and set debugInfo for debugging:
d->clearMapObjectPtr(RefPointer<AbstractMapObject>(d->m_hitLine));
d->m_hitLine = d->m_mapInterface->objectFactory().
create<SituationMap::HitLine>(QLatin1String("AES"), QLatin1String("HitLineId"));
if (!d->m_hitLine)
{
qDebug() << LOGFUNCTION << " no object";
return;
}
d->m_hitLine->setIdentifier(QLatin1String("HitLine-OutLined"));
d->m_hitLine->setVisibility(d->m_visibility);
d->m_hitLine->setVisibility(SituationMap::ObjectAppearance::Technical, d->m_visibilityTechn);
d->m_hitLine->setVisibility(SituationMap::ObjectAppearance::Tactical, d->m_visibilityTact);
d->m_hitLine->setSelected(d->m_selected);
d->m_hitLine->rLineStyle().setLineColor(Qt::blue);
d->m_hitLine->rLineStyle().setLineWidth(3);
// set additional values:
QPointF offset = QPointF(80000, 80000);
Point3D start = Point3D::fromQPointF(s_basePoint.geographic(offset + QPointF()));
Point3D end = Point3D::fromQPointF(s_basePoint.geographic(offset + QPointF(1230, 1560)));
d->m_hitLine->setStartAndEndPoint(start, end);
bool success = d->m_hitLine->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
success = d->m_hitLine->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
std::cout << " HitLine dump: " << (*d->m_hitLine) << std::endl;
QTimer *timer = new QTimer(this);
connect(timer, &QTimer::timeout, this, &FunctionDialog::onHitLineUpdate);
timer->setSingleShot(true);
// timer->start(2000);
}
void FunctionDialog::onHitLineUpdate()
{
if (!d->m_hitLine)
{
qDebug() << LOGFUNCTION << " no object anymore";
return;
}
d->m_hitLine->setIdentifier(d->m_hitLine->identifier() + QLatin1String("Update"));
d->m_hitLine->setPartyId(4); // Will overwrite line/fillcolor
// set additional values:
Point3D start = d->m_hitLine->startPoint();
Point3D end = d->m_hitLine->endPoint();
// modify:
end.rx() += 0.001;
d->m_hitLine->setStartAndEndPoint(start, end);
bool success = d->m_hitLine->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
success = d->m_hitLine->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
}
void FunctionDialog::onLineOfSightLineCreate()
{
qDebug() << LOGFUNCTION ;
// create and set debugInfo for debugging:
d->clearMapObjectPtr(RefPointer<AbstractMapObject>(d->m_lineOfSight));
d->m_lineOfSight = d->m_mapInterface->objectFactory().
create<SituationMap::LineOfSight>(QLatin1String("MountingPoints"), QLatin1String("LineOfSight")); // SurcfacePlacementMode (<Draped|Absolute|Relative>)
d->m_lineOfSight->setPoints(Point3D(0.155, 0.926, 100) // observer
, Point3D(0.156, 0.926, 50) // obstacle
, Point3D(0.157, 0.926, 0) // target
// , Qt::cyan, // visibleColor
// , Qt::magenta
); // obstructedColor
d->m_lineOfSight->setVisibility(d->m_visibility);
d->m_lineOfSight->setVisibility(SituationMap::ObjectAppearance::Technical, d->m_visibilityTechn);
d->m_lineOfSight->setVisibility(SituationMap::ObjectAppearance::Tactical, d->m_visibilityTact);
d->m_lineOfSight->setSelected(d->m_selected);
bool success = d->m_lineOfSight->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
success = d->m_lineOfSight->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
std::cout << " LineOfSight dump: " << (*d->m_lineOfSight) << std::endl;
}
void FunctionDialog::onMineCreate()
{
qDebug() << LOGFUNCTION ;
// create and set debugInfo for debugging:
d->clearMapObjectPtr(RefPointer<AbstractMapObject>(d->m_mine));
d->m_mine = d->m_mapInterface->objectFactory().
create<SituationMap::Mine>(QLatin1String("AES"), QLatin1String("MineId"));
if (!d->m_mine)
{
qDebug() << LOGFUNCTION << " no object";
return;
}
d->m_mine->setIdentifier(QLatin1String("Mine-OutLined"));
d->m_mine->setVisibility(d->m_visibility);
d->m_mine->setVisibility(SituationMap::ObjectAppearance::Technical, d->m_visibilityTechn);
d->m_mine->setVisibility(SituationMap::ObjectAppearance::Tactical, d->m_visibilityTact);
d->m_mine->setSelected(d->m_selected);
d->m_mine->setPartyId(3); // Will overwrite line/fillcolor
// set additional values:
QPointF origin = s_basePoint.geographic(d->m_objectBasePoint + QPointF(91500, 81500));
d->m_mine->setOrigin(Point3D::fromQPointF(origin));
bool success = d->m_mine->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
success = d->m_mine->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
std::cout << " Mine dump: " << (*d->m_mine) << std::endl;
QTimer *timer = new QTimer(this);
connect(timer, &QTimer::timeout, this, &FunctionDialog::onMineUpdate);
timer->setSingleShot(true);
timer->start(2000);
}
void FunctionDialog::onMineUpdate()
{
if (!d->m_mine)
{
qDebug() << LOGFUNCTION << " no object anymore";
return;
}
d->m_mine->setState(true);
bool success = d->m_mine->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
success = d->m_mine->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
}
void FunctionDialog::onMineFieldCreate()
{
qDebug() << LOGFUNCTION ;
// create and set debugInfo for debugging:
d->clearMapObjectPtr(RefPointer<AbstractMapObject>(d->m_mineField));
d->m_mineField = d->m_mapInterface->objectFactory().
create<SituationMap::MineField>(QLatin1String("AES"), QLatin1String("MineFieldId"));
if (!d->m_mineField)
{
qDebug() << LOGFUNCTION << " no object";
return;
}
d->m_mineField->setIdentifier(QLatin1String("MineField-OutLined"));
d->m_mineField->setVisibility(d->m_visibility);
d->m_mineField->setVisibility(SituationMap::ObjectAppearance::Technical, d->m_visibilityTechn);
d->m_mineField->setVisibility(SituationMap::ObjectAppearance::Tactical, d->m_visibilityTact);
d->m_mineField->setSelected(d->m_selected);
d->m_mineField->setAesState(AesEffectState::Unknown); // != Unknown will overwrite fillPattern
d->m_mineField->rLineStyle().setLineColor(Qt::green);
d->m_mineField->rLineStyle().setLineWidth(2);
d->m_mineField->rFillStyle().setFillColor(Qt::blue);
d->m_mineField->rFillStyle().setFillPattern(FillPattern::DiagonalCross);
// d->m_mineField->setPartyId(5); // Will overwrite line/fillcolor
// set paths:
SituationMap::PositionCont posContSeg1;
QPointF offsetSeg1 = d->m_objectBasePoint + QPointF(150000, 150000);
int extent = 40000;
appendQPointF(posContSeg1, s_basePoint.geographic(offsetSeg1 + QPointF( 0, 0)));
appendQPointF(posContSeg1, s_basePoint.geographic(offsetSeg1 + QPointF(extent, 0)));
appendQPointF(posContSeg1, s_basePoint.geographic(offsetSeg1 + QPointF(extent, 2 * extent)));
appendQPointF(posContSeg1, s_basePoint.geographic(offsetSeg1 + QPointF( 0, 2 * extent)));
d->m_mineField->setSegment(1, posContSeg1);
PositionCont posContSeg2;
QPointF offsetSeg2 = d->m_objectBasePoint + QPointF(200000, 150000);
appendQPointF(posContSeg2, s_basePoint.geographic(offsetSeg2 + QPointF( 0, 0)));
appendQPointF(posContSeg2, s_basePoint.geographic(offsetSeg2 + QPointF(2 * extent, 0)));
appendQPointF(posContSeg2, s_basePoint.geographic(offsetSeg2 + QPointF(2 * extent, extent)));
appendQPointF(posContSeg2, s_basePoint.geographic(offsetSeg2 + QPointF( 0, extent)));
d->m_mineField->setSegment(2, posContSeg2);
// PositionCont posContSeg3;
// QPointF offsetSeg3 = d->m_objectBasePoint + QPointF(300000, 150000);
// posContSeg3 << offsetSeg3 + QPointF(0, 0);
// posContSeg3 << offsetSeg3 + QPointF(2 * extent, 0);
// posContSeg3 << offsetSeg3 + QPointF(2 * extent, extent);
// posContSeg3 << offsetSeg3 + QPointF(0, extent);
// d->m_mineField->setSegment(3, posContSeg3);
PositionCont posContSeg3;
QPointF offsetSeg3 = d->m_objectBasePoint + QPointF(300000, 150000);
appendQPointF(posContSeg3, s_basePoint.geographic(offsetSeg3 + QPointF( 0, 0)));
appendQPointF(posContSeg3, s_basePoint.geographic(offsetSeg3 + QPointF(2 * extent, 0)));
appendQPointF(posContSeg3, s_basePoint.geographic(offsetSeg3 + QPointF(2 * extent, extent)));
appendQPointF(posContSeg3, s_basePoint.geographic(offsetSeg3 + QPointF( 0, extent)));
d->m_mineField->setSegment(3, posContSeg3);
// PositionCont posContComplete;
// QPolygonF polyComplete;
// QPolygonF polySeg1;
// Q_FOREACH(const QPointF &item, posContSeg1)
// polySeg1.append(item);
// QPolygonF polySeg2;
// Q_FOREACH(const QPointF &item, posContSeg2)
// polySeg2.append(item);
// polyComplete = polySeg1.united(polySeg2);
// qWarning() << "polyComplete.size()=" << polyComplete.size();
// qWarning() << "polyComplete=" << polyComplete;
// Q_FOREACH(const QPointF &item, polyComplete)
// posContComplete.append(item);
// posContComplete
// << posContSeg1[0]
// << posContSeg1[3]
// << posContSeg1[2]
// << posContSeg3[2]
// << posContSeg3[1];
d->m_mineField->setPositions(posContSeg1);
PositionCont minePosCont;
appendQPointF(minePosCont, s_basePoint.geographic(offsetSeg1));
appendQPointF(minePosCont, s_basePoint.geographic(offsetSeg1 + QPointF(1000, 100)));
appendQPointF(minePosCont, s_basePoint.geographic(offsetSeg1 + QPointF(12000, 12000)));
appendQPointF(minePosCont, s_basePoint.geographic(offsetSeg1 + QPointF(12000, 13000)));
d->m_mineField->setPositionsMine(MineField::MineState::Activated, minePosCont);
PositionCont minePosContDeActive;
appendQPointF(minePosContDeActive, s_basePoint.geographic(offsetSeg1 + QPointF(0, 100)));
d->m_mineField->setPositionsMine(MineField::MineState::DeActivated, minePosContDeActive);
bool success = d->m_mineField->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
success = d->m_mineField->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
std::cout << " MineField dump: " << (*d->m_mineField) << std::endl;
QTimer *timer = new QTimer(this);
connect(timer, &QTimer::timeout, this, &FunctionDialog::onMineFieldUpdate);
timer->setSingleShot(true);
timer->start(5000);
}
void FunctionDialog::onMineFieldUpdate()
{
qDebug() << LOGFUNCTION ;
if (!d->m_mineField)
{
qDebug() << LOGFUNCTION << " no object anymore";
return;
}
d->m_mineField->setDrawOrder(10);
d->m_mineField->setMineVisibility(MineField::MineState::Activated, false);
d->m_mineField->updateView();
// remove some mines:
PositionCont empty;
d->m_mineField->setPositionsMine(MineField::MineState::DeActivated, empty);
// remove segment:
d->m_mineField->removeSegment(2);
d->m_mineField->setAesState(AesEffectState::Created); // != Unknown will overwrite fillPattern
d->m_mineField->setPartyId(5); // Will overwrite line/fillcolor
bool success = d->m_mineField->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
success = d->m_mineField->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
}
void FunctionDialog::onNuclearCreate()
{
qDebug() << LOGFUNCTION ;
// create and set debugInfo for debugging:
d->clearMapObjectPtr(RefPointer<AbstractMapObject>(d->m_nuclearAgent));
d->m_nuclearAgent = d->m_mapInterface->objectFactory().
create<SituationMap::NuclearAgent>(QLatin1String("AES"), QLatin1String("NuclearAgentId"));
if (!d->m_nuclearAgent)
{
qDebug() << LOGFUNCTION << " no object";
return;
}
d->m_nuclearAgent->setIdentifier(QLatin1String("NuclearAgent-OutLined"));
d->m_nuclearAgent->setVisibility(d->m_visibility);
d->m_nuclearAgent->setVisibility(SituationMap::ObjectAppearance::Technical, d->m_visibilityTechn);
d->m_nuclearAgent->setVisibility(SituationMap::ObjectAppearance::Tactical, false);
d->m_nuclearAgent->setSelected(d->m_selected);
d->m_nuclearAgent->setPartyId(4); // Will overwrite line/fillcolor
// set additional values:
SituationMap::PositionCont posCont;
QPointF offset = d->m_objectBasePoint + QPointF(90000, 80000);
int extent = 1000;
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(-1 * extent, 0)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(-1 * extent, 1 * extent)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(-2 * extent, 3 * extent)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(2 * extent, 3 * extent)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(1 * extent, 1 * extent)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(1 * extent, 0)));
std::cout << " posCont=" << posCont.size() << std::endl;
d->m_nuclearAgent->setPositions(posCont);
d->m_nuclearAgent->setAesState(AesEffectState::Paused);
SituationMap::PositionCont subLine1;
appendQPointF(subLine1, s_basePoint.geographic(offset + QPointF(-1 * extent, 1 * extent)));
appendQPointF(subLine1, s_basePoint.geographic(offset + QPointF(+1 * extent, 1 * extent)));
d->m_nuclearAgent->setSubsidiaryLine(0, subLine1);
SituationMap::PositionCont subLine2;
appendQPointF(subLine2, s_basePoint.geographic(offset + QPointF(-1.7 * extent, 2 * extent)));
appendQPointF(subLine2, s_basePoint.geographic(offset + QPointF(+1.7 * extent, 2 * extent)));
d->m_nuclearAgent->
setSubsidiaryLine(1, subLine2);
bool success = d->m_nuclearAgent->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
success = d->m_nuclearAgent->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
std::cout << " NuclearAgent dump: " << (*d->m_nuclearAgent) << std::endl;
QTimer *timer = new QTimer(this);
connect(timer, &QTimer::timeout, this, &FunctionDialog::onNuclearUpdate);
timer->setSingleShot(true);
// timer->start(2000);
}
void FunctionDialog::onNuclearUpdate()
{
qDebug() << LOGFUNCTION ;
if (!d->m_nuclearAgent)
{
qDebug() << LOGFUNCTION << " no object anymore";
return;
}
// move
QPointF offset(d->m_nuclearAgent->positions().value(0).toPointF() + QPointF(10000, 10000));
qDebug() << LOGFUNCTION << " update values.." ;
SituationMap::PositionCont posCont;
int extent = 10000;
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(-1 * extent, 0)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(-1 * extent, 1 * extent)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(-2 * extent, 4 * extent)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(+2 * extent, 4 * extent)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(+1 * extent, 1 * extent)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(+1 * extent, 0)));
d->m_nuclearAgent->setPositions(posCont);
d->m_nuclearAgent->removeSubsidiaryLines();
d->m_nuclearAgent->setAesState(AesEffectState::Activated);
d->m_nuclearAgent->setPartyId(5); // Will overwrite line/fillcolor
bool success = d->m_nuclearAgent->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
success = d->m_nuclearAgent->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
}
void FunctionDialog::onChargeEffectCreate()
{
qDebug() << LOGFUNCTION ;
// create and set debugInfo for debugging:
d->clearMapObjectPtr(RefPointer<AbstractMapObject>(d->m_singleFire));
d->m_singleFire = d->m_mapInterface->objectFactory().
create<SituationMap::SingleFire>(QLatin1String("AES"), QLatin1String("SingleFireId"));
if (!d->m_singleFire)
{
qDebug() << LOGFUNCTION << " no object";
return;
}
d->m_singleFire->setIdentifier(QLatin1String("ChargeEffect-OutLined"));
d->m_singleFire->setVisibility(d->m_visibility);
d->m_singleFire->setVisibility(SituationMap::ObjectAppearance::Technical, d->m_visibilityTechn);
d->m_singleFire->setVisibility(SituationMap::ObjectAppearance::Tactical, d->m_visibilityTact);
d->m_singleFire->setSelected(d->m_selected);
d->m_singleFire->setPartyId(3); // Will overwrite line/fillcolor
// set additional values:
QPointF offset = QPointF(84000, 77000);
Point3D origin = Point3D::fromQPointF(s_basePoint.geographic(offset + QPointF()));
qWarning() << LOGFUNCTION <<" origin "<< origin.toPointF();
//QPointF origin = s_basePoint.geographic(d->m_objectBasePoint + QPointF(155000, 155000));
d->m_singleFire->setOrigin(/*Point3D::fromQPointF*/(origin));
d->m_singleFire->setRadius(300);
d->m_singleFire->setImpactOrigin(d->m_singleFire->origin());
d->m_singleFire->setAesState(AesEffectState::Created);
bool success = d->m_singleFire->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
success = d->m_singleFire->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
std::cout << " SingleFire dump: " << (*d->m_singleFire) << std::endl;
// QTimer *timer = new QTimer(this);
// connect(timer, &QTimer::timeout, this, &FunctionDialog::onChargeEffectUpdate);
// timer->setSingleShot(true);
// timer->start(2000);
}
void FunctionDialog::onChargeEffectUpdate()
{
qDebug() << LOGFUNCTION ;
if (!d->m_singleFire)
{
qDebug() << LOGFUNCTION << " no object anymore";
return;
}
// move
//QPointF offset = QPointF(80000, 80000);
//Point3D origin = Point3D::fromQPointF(s_basePoint.geographic(offset + QPointF()));
//QPointF origin = s_basePoint.geographic(d->m_singleFire->origin().toPointF() + QPointF(50, 50));
//d->m_singleFire->setOrigin(origin);
d->m_singleFire->setRadius(500);
d->m_singleFire->setImpactOrigin(d->m_singleFire->origin());
d->m_singleFire->setPartyId(4); // Will overwrite line/fillcolor
d->m_singleFire->setAesState(AesEffectState::Activated); // created, Prepared, Activated
bool success = d->m_singleFire->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
}
void FunctionDialog::onBoobyTrapCreate()
{
qDebug() << LOGFUNCTION ;
// create and set debugInfo for debugging:
d->clearMapObjectPtr(RefPointer<AbstractMapObject>(d->m_virtualSingleMineAgent));
d->m_virtualSingleMineAgent = d->m_mapInterface->objectFactory().
create<SituationMap::NuclearAgent>(QLatin1String("AES"), QLatin1String("NuclearAgentId"));
if (!d->m_virtualSingleMineAgent)
{
qDebug() << LOGFUNCTION << " no object";
return;
}
d->m_virtualSingleMineAgent->setIdentifier(QLatin1String("virtualSingleMine-OutLined"));
d->m_virtualSingleMineAgent->setVisibility(d->m_visibility);
d->m_virtualSingleMineAgent->setVisibility(SituationMap::ObjectAppearance::Technical, d->m_visibilityTechn);
d->m_virtualSingleMineAgent->setVisibility(SituationMap::ObjectAppearance::Tactical, false);
d->m_virtualSingleMineAgent->setSelected(d->m_selected);
// set additional values:
SituationMap::PositionCont posCont;
QPointF offset = d->m_objectBasePoint + QPointF(90000, 80000);
int extent = 1000;
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(-1 * extent, 3 * extent)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(3 * extent, 3 * extent)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(3 * extent, -3 * extent)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(-1 * extent, -3 * extent)));
std::cout << " posCont=" << posCont.size() << std::endl;
d->m_virtualSingleMineAgent->setPositions(posCont);
d->m_virtualSingleMineAgent->setAesState(AesEffectState::Paused);
const SituationMap::PartyIdToColorFunctor::PartyData pData1(QStringLiteral("P1"),
AdvancedSymbology::Role::HostileFaker,
Qt::blue, Qt::blue);
d->m_mapInterface->partyIdToColorFunctor().setParty(1, pData1);
SituationMap::PositionCont subLine1;
appendQPointF(subLine1, s_basePoint.geographic(offset + QPointF(1 * extent, -1 * extent)));
appendQPointF(subLine1, s_basePoint.geographic(offset + QPointF(1 * extent, -3 * extent)));
appendQPointF(subLine1, s_basePoint.geographic(offset + QPointF(+5 * extent, -3 * extent)));
appendQPointF(subLine1, s_basePoint.geographic(offset + QPointF(+5 * extent, -1 * extent)));
NuclearAgent::OptionalData optData;
optData.closed = true;
optData.lineStyle = QSharedPointer<LineStyle>(new LineStyle(Qt::red, 5, LinePattern::DashDot));
optData.fillStyle = QSharedPointer<FillStyle>(new FillStyle(Qt::red, FillPattern::DiagonalCross));
d->m_virtualSingleMineAgent->setSubsidiaryLine(0, subLine1, optData);
// SituationMap::PositionCont subLine2;
// appendQPointF(subLine2, s_basePoint.geographic(offset + QPointF(-1.7 * extent, 2 * extent)));
// appendQPointF(subLine2, s_basePoint.geographic(offset + QPointF(+1.7 * extent, 2 * extent)));
// d->m_virtualSingleMineAgent->setSubsidiaryLine(1, subLine2, false);
bool success = d->m_virtualSingleMineAgent->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
success = d->m_virtualSingleMineAgent->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
std::cout << " Virtual Single Mine dump: " << (*d->m_virtualSingleMineAgent) << std::endl;
QTimer *timer = new QTimer(this);
connect(timer, &QTimer::timeout, this, &FunctionDialog::onBoobyTrapUpdate);
timer->setSingleShot(true);
timer->start(2000);
}
void FunctionDialog::onBoobyTrapUpdate()
{
qDebug() << LOGFUNCTION ;
if (!d->m_virtualSingleMineAgent)
{
qDebug() << LOGFUNCTION << " no object anymore";
return;
}
// move
//QPointF offset(d->m_virtualSingleMineAgent->positions().value(0).toPointF() + QPointF(1000, 1000));
QPointF offset = d->m_objectBasePoint + QPointF(90000, 80000);
qDebug() << LOGFUNCTION << " update values.." ;
SituationMap::PositionCont posCont;
int extent = 1000;
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(-1 * extent, 3 * extent)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(3 * extent, 3 * extent)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(3 * extent, -3 * extent)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(-1 * extent, -3 * extent)));
d->m_virtualSingleMineAgent->setPositions(posCont);
d->m_virtualSingleMineAgent->removeSubsidiaryLines();
d->m_virtualSingleMineAgent->setAesState(AesEffectState::Activated);
//d->m_virtualSingleMineAgent->setPartyId(5); // Will overwrite line/fillcolor
const SituationMap::PartyIdToColorFunctor::PartyData pData1(QStringLiteral("P1"),
AdvancedSymbology::Role::HostileFaker,
Qt::blue, Qt::blue);
d->m_mapInterface->partyIdToColorFunctor().setParty(3, pData1);
SituationMap::PositionCont subLine1;
appendQPointF(subLine1, s_basePoint.geographic(offset + QPointF(1 * extent, -1 * extent)));
appendQPointF(subLine1, s_basePoint.geographic(offset + QPointF(1 * extent, -3 * extent)));
appendQPointF(subLine1, s_basePoint.geographic(offset + QPointF(+5 * extent, -3 * extent)));
appendQPointF(subLine1, s_basePoint.geographic(offset + QPointF(+5 * extent, -1 * extent)));
NuclearAgent::OptionalData optData;
optData.closed = true;
d->m_virtualSingleMineAgent->setSubsidiaryLine(0, subLine1, optData);
bool success = d->m_virtualSingleMineAgent->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
success = d->m_virtualSingleMineAgent->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
}
void FunctionDialog::onSingleFireCreate()
{
qDebug() << LOGFUNCTION ;
// create and set debugInfo for debugging:
d->clearMapObjectPtr(RefPointer<AbstractMapObject>(d->m_singleFire));
d->m_singleFire = d->m_mapInterface->objectFactory().
create<SituationMap::SingleFire>(QLatin1String("AES"), QLatin1String("SingleFireId"));
if (!d->m_singleFire)
{
qDebug() << LOGFUNCTION << " no object";
return;
}
d->m_singleFire->setIdentifier(QLatin1String("SingleFire-OutLined"));
d->m_singleFire->setVisibility(d->m_visibility);
d->m_singleFire->setVisibility(SituationMap::ObjectAppearance::Technical, d->m_visibilityTechn);
d->m_singleFire->setVisibility(SituationMap::ObjectAppearance::Tactical, d->m_visibilityTact);
d->m_singleFire->setSelected(d->m_selected);
d->m_singleFire->setPartyId(3); // Will overwrite line/fillcolor
// set additional values:
QPointF origin = s_basePoint.geographic(d->m_objectBasePoint + QPointF(155000, 155000));
d->m_singleFire->setOrigin(Point3D::fromQPointF(origin));
d->m_singleFire->setRadius(100);
d->m_singleFire->setImpactOrigin(d->m_singleFire->origin());
d->m_singleFire->setAesState(AesEffectState::Paused);
bool success = d->m_singleFire->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
success = d->m_singleFire->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
std::cout << " SingleFire dump: " << (*d->m_singleFire) << std::endl;
QTimer *timer = new QTimer(this);
connect(timer, &QTimer::timeout, this, &FunctionDialog::onSingleFireUpdate);
timer->setSingleShot(true);
timer->start(2000);
}
void FunctionDialog::onSingleFireUpdate()
{
qDebug() << LOGFUNCTION ;
if (!d->m_singleFire)
{
qDebug() << LOGFUNCTION << " no object anymore";
return;
}
// move
QPointF origin = s_basePoint.geographic(d->m_singleFire->origin().toPointF() + QPointF(50, 50));
d->m_singleFire->setOrigin(Point3D::fromQPointF(origin));
d->m_singleFire->setRadius(250);
d->m_singleFire->setImpactOrigin(d->m_singleFire->origin());
// d->m_singleFire->setPartyId(4); // Will overwrite line/fillcolor
d->m_singleFire->setAesState(AesEffectState::Activated); // created, Prepared, Activated
bool success = d->m_singleFire->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
success = d->m_singleFire->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
}
void FunctionDialog::onShowBasePoint()
{
qDebug() << LOGFUNCTION ;
if (d->m_basePoint)
{
qDebug() << LOGFUNCTION << " already exists";
return;
}
// create and set debugInfo for debugging:
d->m_basePoint = d->m_mapInterface->objectFactory().
create<SituationMap::Polyline>(QLatin1String("AES"), QLatin1String("BasePointPolygon"));
if (!d->m_basePoint)
{
qDebug() << LOGFUNCTION << " no object";
return;
}
d->m_basePoint->setIdentifier(QLatin1String("BasePoint\n SimCoord = 0,0"));
d->m_basePoint->rLineStyle().setLineColor(Qt::red);
d->m_basePoint->rLineStyle().setLineWidth(8);
PositionCont posCont;
appendQPointF(posCont, QPointF(0, 0));
appendQPointF(posCont, d->m_mapImpl->centerPoint());
d->m_basePoint->setPositions(posCont);
bool success = d->m_basePoint->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
std::cout << " m_basePoint dump: " << (*d->m_basePoint) << std::endl;
}
void FunctionDialog::onShowPolizei()
{
onRemoveAll();
QString layername = d->m_mapInterface->layerFactory().basemapLayernamePrefix();
layername += QLatin1String("0");
LayerParameter lp = d->m_mapInterface->layerFactory().layerParameter(layername);
lp.opacity = 20;
d->m_mapInterface->layerFactory().setLayerParameter(layername, lp);
// Bld
{
RefPointer<SituationMap::BuildingOutline> building;
building = d->m_mapInterface->objectFactory().
create<SituationMap::BuildingOutline>(QLatin1String("AES"), QLatin1String("BuildingOutlineId2"));
if (!building) { qDebug() << LOGFUNCTION << " no object"; return; }
building->setIdentifier(QLatin1String("Building"));
building->setVisibility(true);
building->setVisibility(SituationMap::ObjectAppearance::Technical, true);
building->setVisibility(SituationMap::ObjectAppearance::Tactical, true);
building->rTextStyle().setTextColor(Qt::magenta);
building->rTextStyle().setSize(30);
building->rTextStyle().setAntiAliased(true);
building->rTextStyle().setHorizontalAlignment(HorizontalAlignment::Left);
building->rTextStyle().setVerticalAlignment(VerticalAlignment::BaseLine);
building->rTextStyle().setTextOutlineWidth(0);
// set additional values:
SituationMap::PositionCont posCont;
appendQPointF(posCont, s_basePoint.geographic(QPointF(93076.8, 78331.8)));
appendQPointF(posCont, s_basePoint.geographic(QPointF(93070.9, 78325.0)));
appendQPointF(posCont, s_basePoint.geographic(QPointF(93064.0, 78331.0)));
appendQPointF(posCont, s_basePoint.geographic(QPointF(93069.9, 78337.8)));
building->setPositions(posCont);
bool success = building->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
}
static bool single = true;
single = !single;
const QColor participantColor(41, 76, 56);
QPointF shooterOrigin = s_basePoint.geographic(QPointF(93072, 78344));
QPointF targetOrigin = s_basePoint.geographic(QPointF(92927, 78333));
// part0 - shooter
{
RefPointer<SituationMap::Participant> participant = d->m_mapInterface->objectFactory().
create<SituationMap::Participant>(QLatin1String("Participants"), QLatin1String("ParticipantShooter"));
participant->setOrigin(Point3D::fromQPointF(shooterOrigin));
participant->setTextModifier(Participant::TextModifier::M_HigherFormation, QLatin1String("Amok"));
participant->setTextModifier(Participant::TextModifier::T_UniqueDesignation, QLatin1String(""));
SymbolData symData;
symData.sidc = QStringLiteral("ETS_Zivil_Person");
symData.color = Qt::cyan; // Will be overwritten via partyId.
participant->setSymbol(symData);
participant->setPartyId(3);
participant->forcePartyColor(Qt::gray);
participant->setScale(1.0);
bool success = participant->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
}
// part1 - target
{
RefPointer<SituationMap::Participant> participant = d->m_mapInterface->objectFactory().
create<SituationMap::Participant>(QLatin1String("Participants"), QLatin1String("ParticipantPolizei111"));
participant->setOrigin(Point3D::fromQPointF(targetOrigin));
participant->setTextModifier(Participant::TextModifier::M_HigherFormation, QLatin1String("Schupo"));
participant->setTextModifier(Participant::TextModifier::T_UniqueDesignation, QLatin1String("FuStw.1"));
SymbolData symData;
if (single)
symData.sidc = QStringLiteral("ETS_Polizei_PKW");
else
symData.sidc = QStringLiteral("ETS_Polizei_FueKraft");
symData.color = Qt::cyan; // Will be overwritten via partyId.
participant->setSymbol(symData);
participant->setPartyId(3);
participant->forcePartyColor(participantColor);
if (single)
participant->setScale(1.0);
else
participant->setScale(2.0);
bool success = participant->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
}
if (single)
{
// part2
{
RefPointer<SituationMap::Participant> participant = d->m_mapInterface->objectFactory().
create<SituationMap::Participant>(QLatin1String("Participants"), QLatin1String("ParticipantPolizei222"));
QPointF origin = s_basePoint.geographic(QPointF(92936, 78368));
participant->setOrigin(Point3D::fromQPointF(origin));
participant->setTextModifier(Participant::TextModifier::M_HigherFormation, QLatin1String("Schupo"));
participant->setTextModifier(Participant::TextModifier::T_UniqueDesignation, QLatin1String("Wm.1"));
SymbolData symData;
symData.sidc = QStringLiteral("ETS_Polizei_Person");
symData.color = Qt::cyan; // Will be overwritten via partyId.
symData.size = 1.0;
participant->setSymbol(symData);
participant->setPartyId(3);
participant->forcePartyColor(participantColor);
participant->setScale(1.0);
bool success = participant->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
}
// part3
{
RefPointer<SituationMap::Participant> participant = d->m_mapInterface->objectFactory().
create<SituationMap::Participant>(QLatin1String("Participants"), QLatin1String("ParticipantPolizei222"));
QPointF origin = s_basePoint.geographic(QPointF(92944, 78393));
participant->setOrigin(Point3D::fromQPointF(origin));
participant->setTextModifier(Participant::TextModifier::M_HigherFormation, QLatin1String("Schupo"));
participant->setTextModifier(Participant::TextModifier::T_UniqueDesignation, QLatin1String("Wm.2"));
SymbolData symData;
symData.sidc = QStringLiteral("ETS_Polizei_Person");
symData.color = Qt::cyan; // Will be overwritten via partyId.
symData.size = 1.0;
participant->setSymbol(symData);
participant->setPartyId(3);
participant->forcePartyColor(participantColor);
participant->setScale(1.0);
bool success = participant->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
}
}
// hitline
{
RefPointer<SituationMap::HitLine> hitLine;
hitLine = d->m_mapInterface->objectFactory().
create<SituationMap::HitLine>(QLatin1String("Participants"), QLatin1String("HitLineId"));
if (!hitLine) { qDebug() << LOGFUNCTION << " no object"; return; }
hitLine->setDrawOrder(11);
hitLine->setVisibility(SituationMap::ObjectAppearance::Technical, true);
hitLine->setVisibility(SituationMap::ObjectAppearance::Tactical, false);
hitLine->setIdentifier(QLatin1String("M16"));
hitLine->rLineStyle().setLineColor(Qt::green);
hitLine->rLineStyle().setLineWidth(3);
hitLine->setStartAndEndPoint(Point3D::fromQPointF(shooterOrigin),
Point3D::fromQPointF(targetOrigin));
bool success = hitLine->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
}
// Area
{
RefPointer<FunctionalArea> functionalArea = d->m_mapInterface->objectFactory().
create<SituationMap::FunctionalArea>(QLatin1String("AES"), QLatin1String("FunctionalAreaId"));
if (!functionalArea) { qDebug() << LOGFUNCTION << " no object"; return; }
functionalArea->setIdentifier(QLatin1String("Medical"));
functionalArea->rTextStyle().setTextColor(Qt::red);
functionalArea->rTextStyle().setTextOutlineWidth(0);
functionalArea->setVisibility(d->m_visibility);
functionalArea->setVisibility(SituationMap::ObjectAppearance::Technical, d->m_visibilityTechn);
functionalArea->setVisibility(SituationMap::ObjectAppearance::Tactical, d->m_visibilityTact);
functionalArea->setLineStyle(LineStyle(Qt::red, 2, LinePattern::Solid));
functionalArea->setFillStyle(FillStyle(Qt::red, FillPattern::ForwardDiagonal));
SituationMap::PositionCont posCont;
QPointF offset(92850, 78250);
int extent = 25;
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(extent, 0)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(extent, extent)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(0, extent)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(0, 0)));
functionalArea->setPositions(posCont);
bool success = functionalArea->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
}
}
void FunctionDialog::onObjectIndicator()
{
qCritical() << LOGFUNCTION << " START";
d->m_mapInterface->objectIndicator().setMapObjectToPointTo(0);
}
void FunctionDialog::onMeasureLength()
{
qDebug() << LOGFUNCTION ;
d->m_mapInterface->measurement().measureLength();
}
void FunctionDialog::onStartLocationDisplay()
{
qCritical() << LOGFUNCTION ;
QPointF center = d->m_mapInterface->centerPoint();
d->m_mapInterface->locationDisplay().setCurrentLocation(Point3D::fromQPointF(center));
d->m_mapInterface->locationDisplay().start();
}
void FunctionDialog::onStopLocationDisplay()
{
d->m_mapInterface->locationDisplay().stop();
}
void FunctionDialog::onLoadFile()
{
qCritical() << LOGFUNCTION << " AAAAAAAAAA";
{
QString filePath(QLatin1String("/tmp/Observer1Reference.tif"));
Esri::ArcGISRuntime::Raster *isr = new Esri::ArcGISRuntime::Raster(filePath, this);
if (!isr)
{
qCritical() << LOGFUNCTION << " isr failed";
return;
}
Esri::ArcGISRuntime::RasterLayer *rl = new Esri::ArcGISRuntime::RasterLayer(isr, this);
if (!rl)
{
qCritical() << LOGFUNCTION << " rl failed";
return;
}
connect(rl, &Esri::ArcGISRuntime::RasterLayer::errorOccurred, this, [] (const Esri::ArcGISRuntime::Error &error) {
qCritical() << LOGFUNCTION << " EsriError occured: " << toString(error);
});
qCritical() << LOGFUNCTION << " getEsriMap()->operationalLayers()->size" << d->m_mapImpl->getEsriMap()->operationalLayers()->size();
d->m_mapImpl->getEsriMap()->operationalLayers()->append(rl);
qCritical() << LOGFUNCTION << " getEsriMap()->operationalLayers()->size" << d->m_mapImpl->getEsriMap()->operationalLayers()->size();
connect(rl, &Esri::ArcGISRuntime::RasterLayer::loadStatusChanged, this, [] (Esri::ArcGISRuntime::LoadStatus loadStatus) {
qCritical() << LOGFUNCTION << " loadStatus=" << (int)loadStatus;
});
rl->load();
}
}
#ifdef USE_LOCAL_SERVER
void FunctionDialog::onStartLocalService()
{
QPushButton *pb = qobject_cast<QPushButton *>(sender());
if (!pb)
return;
SituationMap::LocalServer *localServer = SituationMap::LocalServer::instance();
connect(localServer, &LocalServer::localServerStatusChanged, pb, [localServer, pb] () {
if (localServer->isLocalServerStarted())
pb->setStyleSheet(QLatin1String("QPushButton {background-color: green;}"));
else if (localServer->isLocalServerStopped())
pb->setStyleSheet(QLatin1String("QPushButton {background-color: gray;}"));
});
connect(localServer, &LocalServer::localGeoprocessingServiceStarted, this, [this] (const QString &serviceName, const LocalServiceData &svcData) {
qCritical() << LOGFUNCTION
<< " :-) service started: '" << serviceName << "'"
<< " url: '" << svcData.svcUrl().toString() << "'"
<< " sync: " << svcData.isSync();
d->m_mapImpl->viewshed().setViewshedUrl(svcData.svcUrl().toString());
});
// starts LocalServer (and pending GPSsvc, which are none yet.)
localServer->start();
}
void FunctionDialog::onStopLocalService()
{
SituationMap::LocalServer *localServer = SituationMap::LocalServer::instance();
localServer->stop();
}
void FunctionDialog::onStartViewshedSvc()
{
QPushButton *pb = qobject_cast<QPushButton *>(sender());
if (!pb)
return;
SituationMap::LocalServer *localServer = SituationMap::LocalServer::instance();
const QString viewshedSvcName(QLatin1String("Viewshed"));
localServer->setLocalGeoprocessingService(viewshedSvcName,
QLatin1String("/shd/CTC/TOOLS/arcgis/EsriJebu/LegatusBremen201803151510.gpk"),
QLatin1String("Viewshed2Feature"),
true);
localServer->startLocalGeoprocessingService(viewshedSvcName);
connect(localServer, &LocalServer::localGeoprocessingServiceStatusChanged, this, [localServer, pb] (const QString &serviceName) {
if (localServer->isLocalGeoprocessingServiceStarted(serviceName))
pb->setStyleSheet(QLatin1String("QPushButton {background-color: green;}"));
else if (localServer->isLocalGeoprocessingServiceStopped(serviceName))
pb->setStyleSheet(QLatin1String("QPushButton {background-color: gray;}"));
});
}
void FunctionDialog::onStopViewshedSvc()
{
SituationMap::LocalServer *localServer = SituationMap::LocalServer::instance();
const QString viewshedSvcName(QLatin1String("Viewshed"));
localServer->stopLocalGeoprocessingService(viewshedSvcName);
}
void FunctionDialog::onViewshedInteractive()
{
d->m_mapInterface->viewshed().create();
}
void FunctionDialog::onViewshed()
{
static long viewshedId = -1;
if (viewshedId >= 0)
d->m_mapInterface->viewshed().remove(viewshedId);
// GP-based:
QPointF viewshedPoint = d->m_mapInterface->centerPoint();
int distance = 523; //meter
if (d->m_viewshedDistance)
{
bool ok = false;
int localDis = d->m_viewshedDistance->text().toInt(&ok);
if (ok)
distance= localDis;
}
ViewshedParameter viewshedParameter;
viewshedParameter.viewshedOrigin_latLon = viewshedPoint;
viewshedParameter.outerRadius = distance;
viewshedParameter.observerHeight = 15;
viewshedId = d->m_mapInterface->viewshed().create(viewshedParameter);
qDebug() << LOGFUNCTION
// << " viewshedParameter =" << viewshedParameter;
<< " center =" << viewshedPoint
<< " distance =" << distance;
}
#endif // USE_LOCAL_SERVER
void FunctionDialog::onSightFan()
{
RB::Rubberband::deleteAllActiveRubberbands(d->m_mapInterface);
SituationMap::RB::RubberbandEllipse *rubberband = d->m_mapInterface->rubberbandFactory().create<SituationMap::RB::RubberbandEllipse>(this);
if (rubberband)
{
rubberband->setAutoDelete(true);
rubberband->constrainQuadratic(true);
rubberband->constrainOrthogonal(true);
rubberband->enableSector(true);
static SituationMap::RefPointer<SituationMap::SightFan> sightFan;
static QString toolLayerName;
if (toolLayerName.isEmpty())
{
toolLayerName = d->m_mapImpl->layerFactory().toolLayer();
}
if (nullptr == sightFan.get())
{
connect( d->m_sightFanObserverHeight, &QLineEdit::textEdited, this, [this](const QString&)
{
if (nullptr == sightFan.get()) return;
sightFan->setCenterHat(d->m_sightFanObserverHeight->text().toDouble());
sightFan->show();
});
connect(d->m_sightFanTargetHeight, &QLineEdit::textEdited, this, [this](const QString&)
{
if (nullptr == sightFan.get()) return;
sightFan->setObjectHat(d->m_sightFanTargetHeight->text().toDouble());
sightFan->show();
});
}
std::function<bool(SituationMap::RB::RubberbandBase*)> updateSightFan = [this](SituationMap::RB::RubberbandBase* rbBase) -> bool
{
SituationMap::RB::RubberbandEllipse *rubberElli = dynamic_cast<SituationMap::RB::RubberbandEllipse*>(rbBase);
if (rubberElli)
{
QPointF center;
double diameter;
double dummy;
QPointF direction;
double observerHeight = d->m_sightFanObserverHeight->text().toDouble();
double targetHeight = d->m_sightFanTargetHeight->text().toDouble();
rubberElli->rectangleParameter(center, diameter, dummy, direction);
if (diameter > 0.0)
{
double startAngle = 0.0;
double dAngle = 2.0 / 180.0*MathConst::pi;
unsigned int noBeams = 180;
double radius = diameter * 0.5;
if (rubberElli->hasSector())
{
startAngle = SituationMap::MathUtils::getMathAngle(rubberElli->sectorStart());
double endAngle = SituationMap::MathUtils::getMathAngle(rubberElli->sectorEnd());
noBeams = ceil(((startAngle > endAngle) ? (endAngle - startAngle + MathConst::pi_two) :(endAngle - startAngle)) / dAngle);
}
if (nullptr == sightFan.get())
{
SituationMap::ObjectFactory &objFac = d->m_mapInterface->objectFactory();
sightFan = objFac.create<SituationMap::SightFan>(toolLayerName);
if (sightFan)
{
sightFan->initFan(center, observerHeight, targetHeight, radius, radius / 1000.0, startAngle, dAngle, noBeams, 1.0);
}
}
else
{
sightFan->setInnerRadius(radius / 1000.0);
sightFan->setRadius(radius);
sightFan->setStartAngle(startAngle);
sightFan->setNoOfFans(noBeams);
sightFan->move(center);
}
}
}
return true;
}; // std::function<bool(SituationMap::RB::RubberbandBase*)>
rubberband->installExternalUpdate(updateSightFan);
QObject::connect(rubberband, &SituationMap::RB::Rubberband::apply, this, [this](SituationMap::RB::RubberbandBase *rubberband)
{
if (nullptr != sightFan.get())
{
sightFan->removeMySelf();
sightFan = nullptr;
}
SituationMap::RB::RubberbandEllipse *rubberElli = dynamic_cast<SituationMap::RB::RubberbandEllipse*>(rubberband);
if (rubberElli)
{
SituationMap::ObjectFactory &objFac = d->m_mapInterface->objectFactory();
sightFan = objFac.create<SituationMap::SightFan>(toolLayerName);
if (sightFan)
{
QPointF center = rubberElli->centerPoint();
double diameter;
double dummy;
QPointF direction;
double startAngle = 0.0;
double dAngle = 2.0 / 180.0*MathConst::pi;
unsigned int noBeams = 180;
double observerHeight = d->m_sightFanObserverHeight->text().toDouble();
double targetHeight = d->m_sightFanTargetHeight->text().toDouble();
rubberElli->rectangleParameter(center, diameter, dummy, direction);
if (rubberElli->hasSector())
{
startAngle = SituationMap::MathUtils::getMathAngle(rubberElli->sectorStart());
double endAngle = SituationMap::MathUtils::getMathAngle(rubberElli->sectorEnd());
noBeams = floor((endAngle - startAngle) / dAngle);
}
double radius = diameter * 0.5;
sightFan->initFan(center, observerHeight, targetHeight, radius, radius / 1000.0, startAngle, dAngle, noBeams, 1.0);
SituationMap::RB::RubberbandPointFeature *moveRB = d->m_mapInterface->rubberbandFactory().create<SituationMap::RB::RubberbandPointFeature>(this);
if (moveRB)
{
moveRB->setAutoDelete(true);
moveRB->enableModificationState();
moveRB->setCoordinateVector( QVector<QPointF>() << sightFan->center() );
std::function<bool(SituationMap::RB::RubberbandBase*)> moveSightFan = [](SituationMap::RB::RubberbandBase* rbBase) -> bool
{
SituationMap::RB::RubberbandPointFeature *rubberPFeat = dynamic_cast<SituationMap::RB::RubberbandPointFeature*>(rbBase);
if (rubberPFeat && sightFan)
{
const QPointF & loc = rubberPFeat->singleCoordinate();
sightFan->move(loc);
}
return true;
};
moveRB->installExternalUpdate(moveSightFan);
}
}
}
});
QObject::connect(rubberband, &SituationMap::RB::Rubberband::abort, this, [this](SituationMap::RB::RubberbandBase *rubberband)
{
if (nullptr != sightFan.get())
{
sightFan->removeMySelf();
sightFan = nullptr;
}
onRubberbandAbort(rubberband);
});
}
} // void FunctionDialog::onSightFan()
void FunctionDialog::onViewshedSightFan()
{
static long sightFanId = -1;
if (sightFanId >= 0)
{
d->m_mapInterface->viewshed().remove(sightFanId);
}
Viewshed &viewshed = d->m_mapInterface->viewshed();
sightFanId = viewshed.create(100.0, 1.8, 1.8, 2.5, 1.0);
} // void FunctionDialog::onViewshedSightFan()
void FunctionDialog::onLoadPlan()
{
qDebug() << LOGFUNCTION ;
OverlayHandler &overlayHandler = d->m_mapInterface->overlayHandler();
QPushButton *pb = qobject_cast<QPushButton *>(sender());
if (! pb)
return;
QString name = pb->property("name").toString();
if (name.isEmpty())
{
qWarning() << LOGFUNCTION << " no name";
return;
}
QFile file(QStringLiteral("/tmp/") + name);
if (!file.open((QIODevice::ReadOnly | QIODevice::Text)))
{
qWarning() << LOGFUNCTION << " file open failed";
return;
}
const QByteArray overlayContent = file.readAll();
qWarning() << LOGFUNCTION << " overlayContent.size()='" << overlayContent.size() << "'";
qWarning() << LOGFUNCTION << " overlayContent='" << overlayContent << "'";
int key = pb->property("key").toInt();
overlayHandler.setOverlay(key, QStringLiteral("OverlayDisplayname"), overlayContent);
overlayHandler.setMinScale(key, 500000); // limiting zoomOut
overlayHandler.setMaxScale(key, 20000); // limiting zoomIn
}
void FunctionDialog::onOverlayVisiChanged(bool checked)
{
qDebug() << LOGFUNCTION;
QCheckBox *cb = qobject_cast<QCheckBox *>(sender());
if (! cb)
{
qWarning() << LOGFUNCTION << " no object";
return;
}
int key = cb->property("key").toInt();
OverlayHandler &overlayHandler = d->m_mapInterface->overlayHandler();
overlayHandler.setOverlayVisibility(key, checked);
}
void FunctionDialog::onRemovePlan()
{
qDebug() << LOGFUNCTION;
OverlayHandler &overlayHandler = d->m_mapInterface->overlayHandler();
QString filename;
QPushButton *pb = qobject_cast<QPushButton *>(sender());
if (! pb)
return;
filename = pb->text();
if (filename.isEmpty())
{
qWarning() << LOGFUNCTION << " no filename";
return;
}
int key = pb->property("key").toInt();
overlayHandler.removeOverlay(key);
}
void FunctionDialog::onRemoveAllPlans()
{
qDebug() << LOGFUNCTION;
OverlayHandler &overlayHandler = d->m_mapInterface->overlayHandler();
qWarning() << LOGFUNCTION << " overlayCount =" << overlayHandler.overlayCount();
int nummberRemoved = overlayHandler.removeAllOverlays();
qWarning() << LOGFUNCTION << " removed =" << nummberRemoved;
qWarning() << LOGFUNCTION << " overlayCount =" << overlayHandler.overlayCount();
}
void FunctionDialog::onToPdf()
{
qDebug() << LOGFUNCTION;
QString fileName = QDir::tempPath() + QLatin1String("/sitMap.pdf");
d->m_mapInterface->toPdf(fileName,
QLatin1String("ScreenshotTitle"),
QLatin1String("Uebung: Test"),
QLatin1String("Benutzer: Norbert"),
QLatin1String("2016-01-01 - 10:11:12"));
qWarning() << LOGFUNCTION << " pdf written to '" << fileName << "'";
}
void FunctionDialog::onAreaFireCreate()
{
qDebug() << LOGFUNCTION ;
// create and set debugInfo for debugging:
d->clearMapObjectPtr(RefPointer<AbstractMapObject>(d->m_areaFire));
d->m_areaFire = d->m_mapInterface->objectFactory().
create<SituationMap::AreaFire>(QLatin1String("AES"), QLatin1String("AreaFireId"));
if (!d->m_areaFire)
{
qDebug() << LOGFUNCTION << " no object";
return;
}
d->m_areaFire->setIdentifier(QLatin1String("AreaFire-OutLined"));
d->m_areaFire->setVisibility(d->m_visibility);
d->m_areaFire->setVisibility(SituationMap::ObjectAppearance::Technical, d->m_visibilityTechn);
d->m_areaFire->setVisibility(SituationMap::ObjectAppearance::Tactical, d->m_visibilityTact);
d->m_areaFire->setSelected(d->m_selected);
LineStyle lineStyle(Qt::red, 5, LinePattern::Solid);
FillStyle fillStyle(Qt::blue, FillPattern::Null);
d->m_areaFire->setLineStyle(lineStyle);
d->m_areaFire->setFillStyle(fillStyle);
d->m_areaFire->setPartyId(3); // Will overwrite line/fillcolor
d->m_areaFire->setAesState(AesEffectState::Unknown); // != Unknown will overwrite fillPattern
// set additional values:
SituationMap::PositionCont posCont;
QPointF offset = d->m_objectBasePoint + QPointF(170000, 170000);
int extent = 100000;
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF( 0, 0)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(extent, 0)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(extent, extent)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(extent / 2, extent / 2)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF( 0, extent)));
std::cout << " posCont=" << posCont.size() << std::endl;
d->m_areaFire->setPositions(posCont);
posCont.removeAt(3);
d->m_areaFire->setImpacts(posCont);
bool success = d->m_areaFire->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
success = d->m_areaFire->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
std::cout << " AreaFire dump: " << (*d->m_areaFire) << std::endl;
QTimer *timer = new QTimer(this);
connect(timer, &QTimer::timeout, this, &FunctionDialog::onAreaFireUpdate);
timer->setSingleShot(true);
timer->start(2000);
}
void FunctionDialog::onAreaFireUpdate()
{
if (!d->m_areaFire)
{
qDebug() << LOGFUNCTION << " no object anymore";
return;
}
d->m_areaFire->setIdentifier(d->m_areaFire->identifier() + QLatin1String("Update"));
d->m_areaFire->setPartyId(4); // Will overwrite line/fillcolor
d->m_areaFire->setAesState(AesEffectState::Activated); // != Unknown will overwrite fillPattern
SituationMap::PositionCont posCont;
QPointF offset = d->m_objectBasePoint + QPointF(170000, 170000);
int extent = 100000;
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF( 0, 0)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(extent, 0)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF(extent, extent * 2)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF( 0, extent)));
appendQPointF(posCont, s_basePoint.geographic(offset + QPointF( 0, 0)));
d->m_areaFire->setPositions(posCont);
posCont.removeAt(1);
posCont.removeAt(3);
d->m_areaFire->setImpacts(posCont);
d->m_areaFire->setDrawOrder(10);
bool success = d->m_areaFire->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
success = d->m_areaFire->updateView();
qWarning() << LOGFUNCTION << " success=" << success;
}
void FunctionDialog::onDump()
{
const QString &dump = d->m_mapImpl->toDumpString();
std::cout << dump << std::endl;
LtsCoordTrans::dumpConversionCounter();
// std::stringstream myLines;
// myLines.str(dump.toStdString());
// std::string line;
// {
// while(std::getline(myLines,line,'\n')){
// qCritical() << QString::fromStdString(line);
// }
// }
}
void FunctionDialog::onOverviewMap()
{
OverviewMapHandler &omHdl = d->m_mapInterface->overviewMapHandler();
if (omHdl.builtInOverviewMapWidget())
omHdl.removeBuiltInOverviewMap();
else
omHdl.createBuiltInOverviewMap();
}
void FunctionDialog::onBackupOms()
{
qDebug() << LOGFUNCTION << " START";
s_operatorMapSettings() = d->m_mapInterface->operatorMapSettings();
// json
QFile saveFile(QStringLiteral("/tmp/oms.json"));
if (!saveFile.open(QIODevice::WriteOnly)) {
qWarning("Couldn't open oms file.");
return;
}
saveFile.write(s_operatorMapSettings().toJson());
qCritical() << "wrote " << QFileInfo(saveFile).absoluteFilePath();
qCritical() << "oms.toJson()=" << s_operatorMapSettings().toJson();
}
void FunctionDialog::onRestoreOms()
{
qDebug() << LOGFUNCTION << " START";
// bool success = d->m_mapInterface->restoreOperatorMapSettings(s_operatorMapSettings);
// qDebug() << LOGFUNCTION << " success=" << success;
// json
QFile loadFile(QStringLiteral("/tmp/oms.json"));
if (!loadFile.open(QIODevice::ReadOnly)) {
qWarning("Couldn't open oms file.");
return;
}
const QByteArray &ba = loadFile.readAll();
SituationMap::OperatorMapSettings oms;
if (oms.fromJson(ba))
qWarning("fromJson ok");
else
qWarning("fromJson failed");
bool success = d->m_mapInterface->restoreOperatorMapSettings(oms);
qDebug() << LOGFUNCTION << " success=" << success;
}
void FunctionDialog::onRemove()
{
qDebug() << LOGFUNCTION << " START XXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
if (d->m_polygon)
{
qDebug() << LOGFUNCTION << " " << d->m_polygon->debugInfo();
d->m_polygon->removeMySelf();
d->m_polygon.reset();
}
if (d->m_polyline)
{
qDebug() << LOGFUNCTION << " " << d->m_polyline->debugInfo();
d->m_polyline->removeMySelf();
d->m_polyline.reset();
}
if (d->m_text)
{
qDebug() << LOGFUNCTION << " " << d->m_text->debugInfo();
d->m_text->removeMySelf();
d->m_text.reset();
}
// if (d->m_mapObjectIndicator)
// {
// qDebug() << LOGFUNCTION << " " << d->m_mapObjectIndicator->debugInfo();
// d->m_mapObjectIndicator->removeMySelf();
// d->m_mapObjectIndicator.reset();
// }
if (d->m_participant)
{
qDebug() << LOGFUNCTION << " " << d->m_participant->debugInfo();
d->m_participant->removeMySelf();
d->m_participant.reset();
}
if (d->m_building)
{
qDebug() << LOGFUNCTION << " " << d->m_building->debugInfo();
d->m_building->removeMySelf();
d->m_building.reset();
}
if (d->m_bAgent)
{
qDebug() << LOGFUNCTION << " " << d->m_bAgent->debugInfo();
d->m_bAgent->removeMySelf();
d->m_bAgent.reset();
}
if (d->m_cAgent)
{
qDebug() << LOGFUNCTION << " " << d->m_cAgent->debugInfo();
d->m_cAgent->removeMySelf();
d->m_cAgent.reset();
}
if (d->m_dangerArea)
{
qDebug() << LOGFUNCTION << " " << d->m_dangerArea->debugInfo();
d->m_dangerArea->removeMySelf();
d->m_dangerArea.reset();
}
if (d->m_functionalArea)
{
qDebug() << LOGFUNCTION << " " << d->m_functionalArea->debugInfo();
d->m_functionalArea->removeMySelf();
d->m_functionalArea.reset();
}
if (d->m_geoImage)
{
qDebug() << LOGFUNCTION << " " << d->m_geoImage->debugInfo();
d->m_geoImage->removeMySelf();
d->m_geoImage.reset();
}
if (d->m_areaFire)
{
qDebug() << LOGFUNCTION << " " << d->m_areaFire->debugInfo();
d->m_areaFire->removeMySelf();
d->m_areaFire.reset();
}
if (d->m_soundArea)
{
qDebug() << LOGFUNCTION << " " << d->m_soundArea->debugInfo();
d->m_soundArea->removeMySelf();
d->m_soundArea.reset();
}
if (d->m_hitLine)
{
qDebug() << LOGFUNCTION << " " << d->m_hitLine->debugInfo();
d->m_hitLine->removeMySelf();
d->m_hitLine.reset();
}
if (d->m_mine)
{
qDebug() << LOGFUNCTION << " " << d->m_mine->debugInfo();
d->m_mine->removeMySelf();
d->m_mine.reset();
}
if (d->m_mineField)
{
qDebug() << LOGFUNCTION << " " << d->m_mineField->debugInfo();
d->m_mineField->removeMySelf();
d->m_mineField.reset();
}
if (d->m_nuclearAgent)
{
qDebug() << LOGFUNCTION << " " << d->m_nuclearAgent->debugInfo();
d->m_nuclearAgent->removeMySelf();
d->m_nuclearAgent.reset();
}
if (d->m_singleFire)
{
qDebug() << LOGFUNCTION << " " << d->m_singleFire->debugInfo();
d->m_singleFire->removeMySelf();
d->m_singleFire.reset();
}
if (d->m_cube)
{
qDebug() << LOGFUNCTION << " " << d->m_cube->debugInfo();
d->m_cube->removeMySelf();
d->m_cube.reset();
}
qDebug() << LOGFUNCTION << " END XXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
}
void FunctionDialog::onRemoveAll()
{
qDebug() << LOGFUNCTION << " START XXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
onRemove();
qDebug() << LOGFUNCTION << " clear ObjectFactory";
d->m_mapImpl->objectFactory().clearObjects();
qDebug() << LOGFUNCTION << " END XXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
}
void FunctionDialog::onToggleGrid()
{
bool gridOnOff = d->m_mapImpl->grid().isVisible();
d->m_mapImpl->grid().setVisible(!gridOnOff);
if (d->m_mapImpl->grid().isVisible())
d->m_pbGrid->setText(QLatin1String("Grid is ON "));
else
d->m_pbGrid->setText(QLatin1String("Grid is OFF"));
}
void FunctionDialog::onToggleVisibility()
{
d->m_visibility = !d->m_visibility;
qDebug() << LOGFUNCTION << " visibility -> " << d->m_visibility;
QPushButton *pb = qobject_cast<QPushButton *>(sender());
if (! pb)
return;
if (d->m_visibility)
pb->setText(QLatin1String("Visibility is ON "));
else
pb->setText(QLatin1String("Visibility is OFF"));
const auto objList = d->getObjList();
for (RefPointer<AbstractMapObject> mObj : objList)
{
if (mObj)
{
qDebug() << LOGFUNCTION << " " << mObj->debugInfo();
mObj->setVisibility(d->m_visibility);
mObj->updateView();
}
}
}
void FunctionDialog::onToggleVisibilityTechn()
{
d->m_visibilityTechn = !d->m_visibilityTechn;
qDebug() << LOGFUNCTION << " m_visibilityTechn -> " << d->m_visibilityTechn;
QPushButton *pb = qobject_cast<QPushButton *>(sender());
if (! pb)
return;
if (d->m_visibilityTechn)
pb->setText(QLatin1String("VisiTechn is ON "));
else
pb->setText(QLatin1String("VisiTechn is OFF"));
ObjectAppearance oa = SituationMap::ObjectAppearance::Technical;
bool localVisi = d->m_visibilityTechn;
const auto objList = d->getObjList();
for (RefPointer<AbstractMapObject> mObj : objList)
{
if (mObj)
{
qDebug() << LOGFUNCTION << " " << mObj->debugInfo();
mObj->setVisibility(oa, localVisi);
mObj->updateView();
}
}
}
void FunctionDialog::onToggleVisibilityTact()
{
d->m_visibilityTact = !d->m_visibilityTact;
qDebug() << LOGFUNCTION << " m_visibilityTact -> " << d->m_visibilityTact;
QPushButton *pb = qobject_cast<QPushButton *>(sender());
if (! pb)
return;
if (d->m_visibilityTact)
pb->setText(QLatin1String("VisiTact is ON "));
else
pb->setText(QLatin1String("VisiTact is OFF"));
ObjectAppearance oa = SituationMap::ObjectAppearance::Tactical;
bool localVisi = d->m_visibilityTact;
const auto objList = d->getObjList();
for (RefPointer<AbstractMapObject> mObj : objList)
{
if (mObj)
{
qDebug() << LOGFUNCTION << " " << mObj->debugInfo();
mObj->setVisibility(oa, localVisi);
mObj->updateView();
}
}
}
void FunctionDialog::onToggleSelection()
{
d->m_selected = !d->m_selected;
qDebug() << LOGFUNCTION << " m_selected -> " << d->m_selected;
QPushButton *pb = qobject_cast<QPushButton *>(sender());
if (! pb)
return;
if (d->m_selected)
pb->setText(QLatin1String("Selection is ON "));
else
pb->setText(QLatin1String("Selection is OFF"));
const auto objList = d->getObjList();
for (RefPointer<AbstractMapObject> mObj : objList)
{
if (mObj)
{
qDebug() << LOGFUNCTION << " " << mObj->debugInfo();
mObj->setSelected(d->m_selected);
mObj->updateView();
}
}
}
void FunctionDialog::onTogglePicking()
{
d->m_pickable = !d->m_pickable;
qDebug() << LOGFUNCTION << " m_pickable -> " << d->m_pickable;
QPushButton *pb = qobject_cast<QPushButton *>(sender());
if (! pb)
return;
if (d->m_pickable)
pb->setText(QLatin1String("Picking is ON "));
else
pb->setText(QLatin1String("Picking is OFF"));
const auto objList = d->getObjList();
for (RefPointer<AbstractMapObject> mObj : objList)
{
if (mObj)
{
qDebug() << LOGFUNCTION << " " << mObj->debugInfo();
mObj->setPickable(d->m_pickable);
mObj->updateView();
}
}
}
void FunctionDialog::onToggleBoundingBox()
{
qDebug() << LOGFUNCTION << " m_objectsWithBoundingBox=" << d->m_objectsWithBoundingBox;
QPushButton *pb = qobject_cast<QPushButton *>(sender());
if (! pb)
return;
if (d->m_objectsWithBoundingBox.isEmpty())
pb->setText(QLatin1String("BoundingBox is ON "));
else
pb->setText(QLatin1String("BoundingBox is OFF"));
// create or destroy?
if (d->m_objectsWithBoundingBox.isEmpty())
{
// create:
const auto objList = d->getObjList();
for (RefPointer<AbstractMapObject> mObj : objList)
{
if (mObj)
{
qDebug() << LOGFUNCTION << " " << mObj->debugInfo();
SituationMap::BoundingBox bbox;
mObj->boundingBox(bbox);
if (!bbox.isValid())
{
qWarning() << LOGFUNCTION << " bbox invalid, debugInfo=" << mObj->debugInfo()
<< " bbox=" << bbox.toString();
continue;
}
qDebug() << LOGFUNCTION
<< " debugInfo =" << mObj->debugInfo()
<< " bbox =" << bbox.toString();
RefPointer<SituationMap::Polygon> moPoly
= d->m_mapInterface->objectFactory().
create<SituationMap::Polygon>(QLatin1String("AES"),
QStringLiteral("BoundingBoxPrimitiveOf(%1)").arg(mObj->debugInfo()));
d->m_objectsWithBoundingBox.append(moPoly->uniqueMapId());
switch (bbox.extentType())
{
case SituationMap::BoundingBox::ExtentType::Sim:
moPoly->setPositions(bbox.positions());
break;
case SituationMap::BoundingBox::ExtentType::Pixel:
{
const QPointF pCenter = d->m_mapImpl->geoCoordinateToViewPortWindowPoint(bbox.center().toPointF()); // ToDo Check
SituationMap::BoundingBox pixelBox(SituationMap::BoundingBox::ExtentType::Pixel,
Point3D::fromQPointF(pCenter), bbox.width(), bbox.height());
const QList<QPointF> points({d->m_mapImpl->viewPortWindowPointToGeoCoordinate(pixelBox.topLeft().toPointF()), // ToDo Check
d->m_mapImpl->viewPortWindowPointToGeoCoordinate(pixelBox.topRight().toPointF()), // ToDo Check
d->m_mapImpl->viewPortWindowPointToGeoCoordinate(pixelBox.bottomRight().toPointF()), // ToDo Check
d->m_mapImpl->viewPortWindowPointToGeoCoordinate(pixelBox.bottomLeft().toPointF()) // ToDo Check
});
SituationMap::PositionCont posContForCurrentScale = convert2D3D(points);
moPoly->setPositions(posContForCurrentScale);
}
break;
case SituationMap::BoundingBox::ExtentType::Undefined:
{
qWarning() << LOGFUNCTION << " bbox has no ExtentType, bbox=" << bbox.toString();
}
} //switch
moPoly->rLineStyle().setLineColor(Qt::magenta);
moPoly->updateView();
}
}
}
else
{
// destroy:
qDebug() << LOGFUNCTION << " m_objectsWithBoundingBox=" << d->m_objectsWithBoundingBox;
for (UniqueMapId id : std::as_const(d->m_objectsWithBoundingBox))
{
RefPointer<SituationMap::AbstractMapObject> moPoly
= d->m_mapInterface->objectFactory().get(id);
moPoly->removeMySelf();
}
d->m_objectsWithBoundingBox.clear();
}
}
void FunctionDialog::onToggleBB2()
{
SituationMap::PositionCont posCont;
for (RefPointer<AbstractMapObject> mObj : d->getObjList())
{
if (!mObj)
continue;
qCritical() << LOGFUNCTION << " debugInfo" << mObj->debugInfo();
const QVector<Point3D> resultVec = MathUtils::GeometryEngine::buffer(mObj.get(), 100);
posCont.clear();
posCont.reserve(resultVec.size());
for (const Point3D &p : resultVec)
posCont.append(d->m_mapImpl->coordTranslationFunctor()->mapToGeographic(p));
RefPointer<SituationMap::Polygon> bb2Poly
= d->m_mapInterface->objectFactory().
create<SituationMap::Polygon>(QLatin1String("AES"),
QStringLiteral("BB2PrimitiveOf(%1)").arg(mObj->debugInfo()));
bb2Poly->setPositions(posCont);
bb2Poly->rLineStyle().setLineColor(Qt::magenta);
bb2Poly->updateView();
}
}
void FunctionDialog::onMapRotationChanged()
{
float mapRotationDegree = d->getMapRotation();
double currrentRotation = d->m_mapImpl->rotation();
qDebug() << LOGFUNCTION
<< " change from " << currrentRotation
<< " to new " << mapRotationDegree;
d->m_mapImpl->setRotation(mapRotationDegree);
}
void FunctionDialog::onSymbolSizeChanged()
{
float newScale = d->getScale();
qDebug() << LOGFUNCTION << " newScale " << newScale << " START";
QSlider *sl = qobject_cast<QSlider *>(sender());
if (! sl)
return;
sl->setToolTip(QStringLiteral("%1%").arg(newScale * 100));
d->m_mapInterface->setSymbolScale(newScale);
// Q_FOREACH (RefPointer<AbstractMapObject> mObj, d->getObjList())
// {
// if (mObj)
// {
// qDebug() << LOGFUNCTION << " " << mObj->debugInfo();
// mObj->setScale(newScale);
// mObj->updateView();
// }
// }
qDebug() << LOGFUNCTION << " newScale " << newScale << " END";
}
void FunctionDialog::onSymbolOpacityChanged()
{
float newOpacity = d->getSymbolOpacity();
qDebug() << LOGFUNCTION << " newOpacity " << newOpacity << " START";
const auto objList = d->getObjList();
for (RefPointer<AbstractMapObject> mObj : objList)
{
if (mObj)
{
qDebug() << LOGFUNCTION << " " << mObj->debugInfo();
Participant *part = dynamic_cast<Participant *>(mObj.get());
if (part)
{
part->setUserSymbolOpacity(newOpacity);
part->updateView();
}
}
}
}
void FunctionDialog::onDrawOrderChanged()
{
int drawOrder = d->getDrawOrder();
qDebug() << LOGFUNCTION << " newDrawOrder " << drawOrder << " START";
std::cerr << LOGFUNCTION << " drawOrder = " << drawOrder << std::endl;
const auto objList = d->getObjList();
for (RefPointer<AbstractMapObject> mObj : objList)
{
if (mObj)
{
qDebug() << LOGFUNCTION << " " << mObj->debugInfo();
mObj->setDrawOrder(drawOrder);
mObj->updateView();
}
}
}
void FunctionDialog::onMouseWindowPositionChanged(int x, int y)
{
QString strWindow(QLatin1String("Screen: X = "));
strWindow.append(QString::number(x));
strWindow.append(QLatin1String(", Y = "));
strWindow.append(QString::number(y));
setMapPositionString(strWindow);
} /* FunctionDialog::onMouseWindowPositionChanged */
void FunctionDialog::onMouseMapPositionChanged(const Point3D &mapPos, bool isValid)
{
QString strMap(QLatin1String("\nMap Coord: X = "));
strMap.append(QString::number(mapPos.x(), 'f', -1));
strMap.append(QLatin1String(", Y = "));
strMap.append(QString::number(mapPos.y(), 'f', -1));
strMap.append(QLatin1String(", z = "));
strMap.append(QString::number(mapPos.z(), 'f', -1));
if (isValid)
strMap.append(QLatin1String(" (valid)"));
else
strMap.append(QLatin1String(" (invalid)"));
QString strLatLon(QLatin1String("\nLon(x) - Lat(y) Coord: "));
// Esri::ArcGISRuntime::Point normalPt =
// Esri::ArcGISRuntime::GeometryEngine::normalizeCentralMeridian(Esri::ArcGISRuntime::Point(mapPos.x(), mapPos.y(), d->m_mapImpl->getEsriSpatialReference()));
const CoordTranslationFunctor *ctFunctor = d->m_mapImpl->coordTranslationFunctor();
if (ctFunctor)
{
Point3D geoPos = ctFunctor->mapToGeographic(mapPos);
strLatLon.append(QString::number(geoPos.x(), 'f', 10));
strLatLon.append(QLatin1String(" - "));
strLatLon.append(QString::number(geoPos.y(), 'f', 10));
strLatLon.append(QLatin1String(" - "));
strLatLon.append(QString::number(geoPos.z(), 'f', -1));
}
QString strUTM(QLatin1String("\nUTM Mgrs Coord: "));
// strUTM.append(EsriRuntimeQt::CoordinateConversion::PointToMgrs(normalPt
// , EsriRuntimeQt::MgrsConversionMode::Automatic
// , 5
// , true
// , true));
strUTM.append(d->m_mapImpl->mapToMgrsString(mapPos.toPointF()));
addMapPositionString(strMap);
addMapPositionString(strLatLon);
addMapPositionString(strUTM);
} /* FunctionDialog::onMouseMapPositionChanged */
void FunctionDialog::onMouseGeoPositionChanged(const Point3D &geoPos, bool isValid)
{
QString strSim(QLatin1String("\nGeo Coord: X = "));
strSim.append(QString::number(geoPos.x(), 'f', -1));
strSim.append(QLatin1String(", Y = "));
strSim.append(QString::number(geoPos.y(), 'f', -1));
strSim.append(QLatin1String(", z = "));
strSim.append(QString::number(geoPos.z(), 'f', -1));
if (isValid)
strSim.append(QLatin1String(" (valid)"));
else
strSim.append(QLatin1String(" (invalid)"));
addMapPositionString(strSim);
onExtendChanged();
}
void FunctionDialog::onExtendChanged()
{
double pixelSize = d->m_mapInterface->pixelSizeMeter();
double scale = d->m_mapInterface->scale();
setPixelSizeString(QStringLiteral("PixelSize=%1 - Scale=%2").arg(pixelSize).arg(scale));
}
} // namespace SituationMap