2703 lines
97 KiB
C++
Executable File
2703 lines
97 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
*
|
|
* MainWindow for SitMapTestApp
|
|
*
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
*/
|
|
|
|
#include "mainwindow.h"
|
|
#include "nglsettings.h"
|
|
#include "ui_mainwindow.h"
|
|
|
|
#include <Map/abstract_map_object.h>
|
|
#include <Map/object_factory.h>
|
|
#include <QLabel>
|
|
|
|
#include <MapObjectsImpl/polygon_impl.h>
|
|
#include <MapObjectsImpl/polyline_impl.h>
|
|
#include <MapObjectsImpl/text_impl.h>
|
|
#include <MapObjectsImpl/area_fire_impl.h>
|
|
#include <MapObjectsImpl/biological_agent_impl.h>
|
|
#include <MapObjectsImpl/chemical_agent_impl.h>
|
|
#include <MapObjectsImpl/cube_impl.h>
|
|
#include <MapObjectsImpl/building_outline_impl.h>
|
|
#include <MapObjectsImpl/danger_area_impl.h>
|
|
#include <MapObjectsImpl/geo_image_impl.h>
|
|
#include <MapObjectsImpl/functional_area_impl.h>
|
|
#include <MapObjectsImpl/hit_line_impl.h>
|
|
#include <MapObjectsImpl/map_object_indicator_impl.h>
|
|
#include <MapObjectsImpl/mine_impl.h>
|
|
#include <MapObjectsImpl/mine_field_impl.h>
|
|
#include <MapObjectsImpl/nuclear_agent_impl.h>
|
|
#include <MapObjectsImpl/participant_impl.h>
|
|
#include <MapImpl/sidc_symbol_impl.h>
|
|
#include <MapObjectsImpl/single_fire_impl.h>
|
|
|
|
#include <Symbology/symbol_dictionary.h>
|
|
#include <Rubberbands/rubberband_factory.h>
|
|
#include <FunctionDialog/function_dialog.h>
|
|
#include <QTimer>
|
|
#include <QGraphicsView>
|
|
|
|
//TODO: use templates
|
|
|
|
|
|
//static LtsCoordTrans::UtmCoordinate s_basePoint;
|
|
|
|
|
|
//----------------------------------------------------------------------------------------------------------
|
|
MainWindow::MainWindow(QWidget *parent)
|
|
: NGLMainWindow(parent)
|
|
, m_ui(new Ui::widgetMain)
|
|
, m_logger(SituationMap::getLogger("SitMapTestApp"))
|
|
{
|
|
m_ui->setupUi(this);
|
|
|
|
connect(m_ui->actionExit, SIGNAL(triggered()), this, SLOT(onClose()));
|
|
|
|
// map slots
|
|
connect(m_ui->actionLoadMap, SIGNAL(triggered()), this, SLOT(createMap()));
|
|
connect(m_ui->actionRemoveMap, SIGNAL(triggered()), this, SLOT(destroyMap()));
|
|
|
|
// map objects
|
|
connect(m_ui->actionCreateBuildings, SIGNAL(triggered()), this, SLOT(createBuildings()));
|
|
connect(m_ui->actionRemoveBuildings, SIGNAL(triggered()), this, SLOT(removeBuildings()));
|
|
connect(m_ui->actionUpdateBuildings, SIGNAL(triggered()), this, SLOT(updateMapObjects()));
|
|
connect(m_ui->actionHideBuildings, SIGNAL(triggered()), this, SLOT(hideBuildings()));
|
|
|
|
connect(m_ui->actionCreateDangerAreas, SIGNAL(triggered()), this, SLOT(createDangerAreas()));
|
|
connect(m_ui->actionRemoveDangerAreas, SIGNAL(triggered()), this, SLOT(removeDangerAreas()));
|
|
connect(m_ui->actionUpdateDangerAreas, SIGNAL(triggered()), this, SLOT(updateMapObjects()));
|
|
connect(m_ui->actionHideDangerAreas, SIGNAL(triggered()), this, SLOT(hideDangerAreas()));
|
|
|
|
connect(m_ui->actionCreateFireAreas, SIGNAL(triggered()), this, SLOT(createFireAreas()));
|
|
connect(m_ui->actionRemoveFireAreas, SIGNAL(triggered()), this, SLOT(removeFireAreas()));
|
|
connect(m_ui->actionUpdateFireAreas, SIGNAL(triggered()), this, SLOT(updateMapObjects()));
|
|
connect(m_ui->actionHideFireAreas, SIGNAL(triggered()), this, SLOT(hideFireAreas()));
|
|
|
|
connect(m_ui->actionCreateBAgents, SIGNAL(triggered()), this, SLOT(createBAgents()));
|
|
connect(m_ui->actionRemoveBAgents, SIGNAL(triggered()), this, SLOT(removeBAgents()));
|
|
connect(m_ui->actionUpdateBAgents, SIGNAL(triggered()), this, SLOT(updateMapObjects()));
|
|
connect(m_ui->actionHideBAgents, SIGNAL(triggered()), this, SLOT(hideBAgents()));
|
|
|
|
connect(m_ui->actionCreateHitLines, SIGNAL(triggered()), this, SLOT(createHitLines()));
|
|
connect(m_ui->actionRemoveHitLines, SIGNAL(triggered()), this, SLOT(removeHitLines()));
|
|
connect(m_ui->actionUpdateHitLines, SIGNAL(triggered()), this, SLOT(updateMapObjects()));
|
|
connect(m_ui->actionHideHitLines, SIGNAL(triggered()), this, SLOT(hideHitLines()));
|
|
|
|
//Draw slots
|
|
connect(m_ui->actionPointCluster, SIGNAL(triggered()), this, SLOT(rubberbandPointCluster()));
|
|
connect(m_ui->actionMultiPoint, SIGNAL(triggered()), this, SLOT(rubberbandMultiPoint()));
|
|
connect(m_ui->actionFilledMultiPoint, SIGNAL(triggered()), this, SLOT(rubberbandFilledMultiPoint()));
|
|
connect(m_ui->actionSmoothLine, SIGNAL(triggered()), this, SLOT(rubberbandSmoothLine()));
|
|
connect(m_ui->actionFilledSmoothLine, SIGNAL(triggered()), this, SLOT(rubberbandFilledSmoothLine()));
|
|
connect(m_ui->actionRectangle, SIGNAL(triggered()), this, SLOT(rubberbandRectangle()));
|
|
connect(m_ui->actionSquare, SIGNAL(triggered()), this, SLOT(rubberbandSquare()));
|
|
connect(m_ui->actionEllipse, SIGNAL(triggered()), this, SLOT(rubberbandEllipse()));
|
|
connect(m_ui->actionArrow, SIGNAL(triggered()), this, SLOT(rubberbandArrow()));
|
|
connect(m_ui->actionCorridorBoundary, SIGNAL(triggered()), this, SLOT(rubberbandCorridorBoundary()));
|
|
connect(m_ui->actionCorridorCenterline, SIGNAL(triggered()), this, SLOT(rubberbandCorridorCenterline()));
|
|
|
|
// Create slots
|
|
connect(m_ui->actionCreatePointCluster, SIGNAL(triggered()), this, SLOT(rubberbandCreatePointClusters()));
|
|
connect(m_ui->actionCreateMultiPoint, SIGNAL(triggered()), this, SLOT(rubberbandCreateMultiPoints()));
|
|
connect(m_ui->actionCreateFilledMultiPoint, SIGNAL(triggered()), this, SLOT(rubberbandCreateFilledMultiPoints()));
|
|
connect(m_ui->actionCreateSmoothLine, SIGNAL(triggered()), this, SLOT(rubberbandCreateSmoothLines()));
|
|
connect(m_ui->actionCreateFilledSmoothLine, SIGNAL(triggered()), this, SLOT(rubberbandCreateFilledSmoothLines()));
|
|
connect(m_ui->actionCreateRectangle, SIGNAL(triggered()), this, SLOT(rubberbandCreateRectangles()));
|
|
connect(m_ui->actionCreateSquare, SIGNAL(triggered()), this, SLOT(rubberbandCreateSquares()));
|
|
connect(m_ui->actionCreateEllipse, SIGNAL(triggered()), this, SLOT(rubberbandCreateEllipses()));
|
|
connect(m_ui->actionCreateArrow, SIGNAL(triggered()), this, SLOT(rubberbandCreateArrows()));
|
|
connect(m_ui->actionCreateCorridorBoundary, SIGNAL(triggered()), this, SLOT(rubberbandCreateCorridorBoundaries()));
|
|
connect(m_ui->actionCreateCorridorCenterline, SIGNAL(triggered()), this, SLOT(rubberbandCreateCorridorCenterlines()));
|
|
|
|
init();
|
|
|
|
}
|
|
|
|
//----------------------------------------------------------------------------------------------------------
|
|
MainWindow::~MainWindow()
|
|
{
|
|
clearMapObjects();
|
|
|
|
delete m_ui;
|
|
delete m_timer;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------------------------------------
|
|
void MainWindow::init()
|
|
{
|
|
m_scale = MAP::Settings::mapScale();
|
|
INFO_LOG(m_logger) << LOGFUNCTION << " MAP SCALE = " << QString::number(m_scale,'f',6);
|
|
|
|
s_basePoint = LtsCoordTrans::UtmCoordinate::fromMgrs(MAP::Settings::basePoint());
|
|
m_objectBasePoint = QPointF(s_basePoint.x,s_basePoint.y);
|
|
INFO_LOG(m_logger) << LOGFUNCTION << " MAP BASEPOINT = " << MAP::Settings::basePoint();
|
|
|
|
m_wkid = MAP::Settings::mapWkid();
|
|
INFO_LOG(m_logger) << LOGFUNCTION << " MAP WKID = " << QString::number(m_wkid,'f',6);
|
|
|
|
m_timer = new QTimer(this);
|
|
}
|
|
|
|
//----------------------------------------------------------------------------------------------------------
|
|
void MainWindow::onClose()
|
|
{
|
|
this->close();
|
|
}
|
|
|
|
//----------------------------------------------------------------------------------------------------------
|
|
void MainWindow::destroyMap()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
if (m_map)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " REMOVE MAP ";
|
|
|
|
m_ui->gridLayout->removeWidget(m_map);
|
|
|
|
clearMapObjects();
|
|
|
|
}
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
//----------------------------------------------------------------------------------------------------------
|
|
void MainWindow::clearMapObjects()
|
|
{
|
|
m_building.reset();
|
|
m_buildingMap.clear();
|
|
|
|
m_dangerArea.reset();
|
|
m_dangerAreaMap.clear();
|
|
|
|
m_fireArea.reset();
|
|
m_fireAreaMap.clear();
|
|
|
|
m_hitLine.reset();
|
|
m_hitLineMap.clear();
|
|
|
|
m_bAgent.reset();
|
|
m_bAgentMap.clear();
|
|
|
|
delete m_map;
|
|
m_map = nullptr;
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::createMap()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
if (!m_map)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " CREATE MAP ";
|
|
|
|
// 0. License:
|
|
if (!SituationMap::Map::applyLicense())
|
|
FATAL_LOG(m_logger) << LOGFUNCTION << " applyLicense failed";
|
|
|
|
// 1. Map
|
|
m_map = SituationMap::Map::create(this);
|
|
|
|
connect(m_map, &SituationMap::Map::mapReady, this, &MainWindow::onMapReady);
|
|
connect(m_map, &SituationMap::Map::mapObjectsClicked, this, &MainWindow::onMapObjectClicked);
|
|
connect(m_map, &SituationMap::Map::extentChanged, this, &MainWindow::onExtentChanged);
|
|
connect(m_map, &SituationMap::Map::rectChanged, this, &MainWindow::onExtentChanged);
|
|
|
|
// 2. SymbologyType
|
|
AdvancedSymbology::SymbologyType symType = AdvancedSymbology::SymbologyType::MIL2525D; //default
|
|
fromString(symType, MAP::Settings::mapSymbologyType());
|
|
m_map->setSymbologyType(symType);
|
|
|
|
// 3. init (choose 2d or 3D)
|
|
m_map->init(SituationMap::Mode::Mode_2D);
|
|
|
|
// 4. Basemaps
|
|
QString mapURL = MAP::Settings::mapURL();
|
|
m_map->layerFactory().addBasemap(QLatin1Literal("DummyLayerName"),
|
|
QUrl(mapURL),
|
|
SituationMap::BasemapType::Aerial);
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " MAP created with SymbologyType = " << toString(symType);
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " MAP URL = " << mapURL;
|
|
|
|
// 5. load
|
|
m_map->load();
|
|
|
|
// 6. initializeOperationalLayers
|
|
m_map->layerFactory().initializeOperationalLayers(QStringList() << QLatin1String("AES") << QLatin1String("Participants"));
|
|
|
|
// 7. Grid
|
|
m_map->grid().setGridType(MAP::Settings::getGridType(MAP::Settings::mapGridType()));
|
|
m_map->grid().setVisible(MAP::Settings::mapGridVisible());
|
|
|
|
// 8. Initialize objectFactory
|
|
SituationMap::ObjectFactory::registerMe(typeid(SituationMap::MapObjectIndicator), new SituationMap::GenericObjectFactory<SituationMap::MapObjectIndicatorImpl>() );
|
|
SituationMap::ObjectFactory::registerMe(typeid(SituationMap::Cube), new SituationMap::GenericObjectFactory<SituationMap::CubeImpl>() );
|
|
|
|
SituationMap::ObjectFactory::registerMe(typeid(SituationMap::Polygon), new SituationMap::GenericObjectFactory<SituationMap::PolygonImpl>() );
|
|
SituationMap::ObjectFactory::registerMe(typeid(SituationMap::Polyline), new SituationMap::GenericObjectFactory<SituationMap::PolylineImpl>() );
|
|
SituationMap::ObjectFactory::registerMe(typeid(SituationMap::Text), new SituationMap::GenericObjectFactory<SituationMap::TextImpl>() );
|
|
|
|
SituationMap::ObjectFactory::registerMe(typeid(SituationMap::Participant), new SituationMap::GenericObjectFactory<SituationMap::ParticipantImpl>() );
|
|
SituationMap::ObjectFactory::registerMe(typeid(SituationMap::AreaFire), new SituationMap::GenericObjectFactory<SituationMap::AreaFireImpl>() );
|
|
SituationMap::ObjectFactory::registerMe(typeid(SituationMap::BiologicalAgent), new SituationMap::GenericObjectFactory<SituationMap::BiologicalAgentImpl>() );
|
|
SituationMap::ObjectFactory::registerMe(typeid(SituationMap::ChemicalAgent), new SituationMap::GenericObjectFactory<SituationMap::ChemicalAgentImpl>() );
|
|
SituationMap::ObjectFactory::registerMe(typeid(SituationMap::BuildingOutline), new SituationMap::GenericObjectFactory<SituationMap::BuildingOutlineImpl>() );
|
|
SituationMap::ObjectFactory::registerMe(typeid(SituationMap::DangerArea), new SituationMap::GenericObjectFactory<SituationMap::DangerAreaImpl>() );
|
|
SituationMap::ObjectFactory::registerMe(typeid(SituationMap::GeoImage), new SituationMap::GenericObjectFactory<SituationMap::GeoImageImpl>() );
|
|
SituationMap::ObjectFactory::registerMe(typeid(SituationMap::FunctionalArea), new SituationMap::GenericObjectFactory<SituationMap::FunctionalAreaImpl>() );
|
|
SituationMap::ObjectFactory::registerMe(typeid(SituationMap::HitLine), new SituationMap::GenericObjectFactory<SituationMap::HitLineImpl>() );
|
|
SituationMap::ObjectFactory::registerMe(typeid(SituationMap::Mine), new SituationMap::GenericObjectFactory<SituationMap::MineImpl>() );
|
|
SituationMap::ObjectFactory::registerMe(typeid(SituationMap::MineField), new SituationMap::GenericObjectFactory<SituationMap::MineFieldImpl>() );
|
|
SituationMap::ObjectFactory::registerMe(typeid(SituationMap::NuclearAgent), new SituationMap::GenericObjectFactory<SituationMap::NuclearAgentImpl>() );
|
|
SituationMap::ObjectFactory::registerMe(typeid(SituationMap::SingleFire), new SituationMap::GenericObjectFactory<SituationMap::SingleFireImpl>() );
|
|
|
|
SituationMap::ObjectFactory::registerMe(typeid(SituationMap::SidcSymbol), new SituationMap::GenericObjectFactory<SituationMap::SidcSymbolImpl>() );
|
|
|
|
// 9: CoordTransFunctor
|
|
m_map->initCoordTranslationFunctor();
|
|
|
|
// 10. extent, rotation: set later in mapReady
|
|
|
|
// 11. Add widget to main grid layout
|
|
m_ui->gridLayout->addWidget(m_map, 1, 0);
|
|
|
|
// 12. Create FunctionDialog:
|
|
SituationMap::FunctionDialog::addButtonToMap(m_map, MAP::Settings::mapFunctionDialogVisible());
|
|
|
|
}
|
|
else
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " UPDATE MAP";
|
|
m_map->update();
|
|
}
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::onMapObjectClicked(const SituationMap::Map::RefPointerMapObjectList &mapObjList)
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
for (auto mapObj : mapObjList)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " id=" << mapObj->uniqueMapId()
|
|
<< " object-debugInfo=" << mapObj->debugInfo()
|
|
<< " object-identifier=" << mapObj->identifier();
|
|
}
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::onMapReady()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
// QString centerPoint = MAP::Settings::centerPointMgrs();
|
|
// m_map->setCenterPoint(LtsCoordTrans::geographicFromMgrs(centerPoint)); // QPointF(92750, 80525) -> Rennplatz - Bremen
|
|
|
|
m_map->setScale(m_scale);
|
|
|
|
m_map->setRotation(MAP::Settings::mapRotationDegree());
|
|
|
|
// m_map->setExtent(MAP::Settings::XMin(), MAP::Settings::YMin(), MAP::Settings::XMax(), MAP::Settings::YMax());
|
|
|
|
m_map->update();
|
|
|
|
INFO_LOG(m_logger) << LOGFUNCTION << " MAP READY";
|
|
|
|
INFO_LOG(m_logger) << LOGFUNCTION << " MAP PIXEL SIZE = " << m_map->pixelSize();
|
|
INFO_LOG(m_logger) << LOGFUNCTION << " MAP SCALE = " << m_map->scale();
|
|
|
|
INFO_LOG(m_logger) << LOGFUNCTION << " MAP Width = " << m_map->width();
|
|
INFO_LOG(m_logger) << LOGFUNCTION << " MAP Height = " << m_map->height();
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::onExtentChanged()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " MAP EXTENT CHANGED ";
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " MAP PIXEL SIZE = " << m_map->pixelSize();
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " MAP SCALE = " << m_map->scale();
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " MAP Width = " << m_map->width();
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " MAP Height = " << m_map->height();
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::setVersionView()
|
|
{
|
|
//TODO:
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::createBuildings()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
this->createBuilding(1);
|
|
this->createBuilding(2);
|
|
//TODO: more buildings
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::createBuilding(int objId)
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
if (!m_map)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " No map object ";
|
|
return;
|
|
}
|
|
|
|
m_building = m_buildingMap[objId];
|
|
if (m_building)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Building already exists " << objId;
|
|
return;
|
|
}
|
|
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Creating building " << objId;
|
|
m_building = m_map->objectFactory().create<SituationMap::BuildingOutline>( QLatin1String("AES"), QLatin1String("BuildingOutlineId"));
|
|
|
|
if (!m_building)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " No building object ";
|
|
return;
|
|
}
|
|
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Building Identifier: " << MAP::Settings::objectIdentifier(QLatin1String("Building"),objId);
|
|
|
|
m_building->setIdentifier(MAP::Settings::objectIdentifier(QLatin1String("Building"),objId));
|
|
m_building->setVisibility(MAP::Settings::getObjectBoolAttribute(QLatin1String("Building"),QLatin1String("Visibility"),objId,true));
|
|
m_building->setVisibility(SituationMap::ObjectAppearance::Technical, MAP::Settings::getObjectBoolAttribute(QLatin1String("Building"),QLatin1String("VisibilityTech"),objId,true));
|
|
m_building->setVisibility(SituationMap::ObjectAppearance::Tactical, MAP::Settings::getObjectBoolAttribute(QLatin1String("Building"),QLatin1String("VisibilityTact"),objId,true));
|
|
|
|
m_building->rTextStyle().setTextColor(QColor(MAP::Settings::getObjectStringAttribute(QLatin1String("Building"),QLatin1String("TextColor"),objId,QLatin1String("magenta"))));
|
|
m_building->rTextStyle().setSize(MAP::Settings::getObjectIntAttribute(QLatin1String("Building"),QLatin1String("TextSize"),objId,30));
|
|
m_building->rTextStyle().setAngle(MAP::Settings::getObjectIntAttribute(QLatin1String("Building"),QLatin1String("TextAngle"),objId,0));
|
|
m_building->rTextStyle().setAntiAliased(MAP::Settings::getObjectBoolAttribute(QLatin1String("Building"),QLatin1String("TextItalic"),objId,true));
|
|
m_building->rTextStyle().setItalic(MAP::Settings::getObjectBoolAttribute(QLatin1String("Building"),QLatin1String("TextItalic"),objId,false));
|
|
|
|
m_building->setScale(MAP::Settings::mapObjectsTextScale());
|
|
|
|
// set additional values:
|
|
SituationMap::PositionCont posCont;
|
|
|
|
posCont.reserve(4);
|
|
for (int i = 1; i <= 4; i++)
|
|
{
|
|
const QPointF &pIni = MAP::Settings::getPoint(QLatin1String("Building"),objId,i);
|
|
const QPointF &pTrans = s_basePoint.geographic(pIni);
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Point " << i << " : "
|
|
<< "pIni= " << pIni << ", pTrans= " << pTrans;
|
|
posCont << SituationMap::Point3D::fromQPointF(pTrans);
|
|
}
|
|
|
|
m_building->setPositions(posCont);
|
|
|
|
// update view
|
|
bool success = m_building->updateView();
|
|
|
|
if (!success)
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " updateView NOT OK";
|
|
|
|
m_buildingMap[objId] = m_building;
|
|
|
|
connect(m_timer, &QTimer::timeout, this, [=]()
|
|
{
|
|
DEBUG_LOG(m_logger) << " Updating building " << objId;
|
|
onBuildingUpdate(objId);
|
|
});
|
|
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::onBuildingUpdate(int objId)
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
if (!m_map)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " No map object ";
|
|
return;
|
|
}
|
|
|
|
m_building = m_buildingMap[objId];
|
|
if (!m_building)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " No building object ";
|
|
return;
|
|
}
|
|
|
|
m_building->setIdentifier(MAP::Settings::objectIdentifier(QLatin1String("Building"),objId) + QLatin1String("Update"));
|
|
|
|
m_building->rTextStyle().setAngle(MAP::Settings::getObjectIntAttribute(QLatin1String("Building"),QLatin1String("TextAngleUpdate"),objId,0));
|
|
|
|
m_building->rFillStyle().setFillColor(QColor(MAP::Settings::getObjectStringAttribute(QLatin1String("Building"),QLatin1String("FillColor"),objId,QLatin1String("yellow"))));
|
|
m_building->rFillStyle().setFillPattern((SituationMap::FillPattern)MAP::Settings::getObjectIntAttribute(QLatin1String("Building"),QLatin1String("FillPattern"),objId,2));
|
|
|
|
m_building->rLineStyle().setLineColor(QColor(MAP::Settings::getObjectStringAttribute(QLatin1String("Building"),QLatin1String("LineColor"),objId,QLatin1String("red"))));
|
|
m_building->rLineStyle().setLineWidth(MAP::Settings::getObjectIntAttribute(QLatin1String("Building"),QLatin1String("LineWidth"),objId,6));
|
|
m_building->rLineStyle().setLinePattern(MAP::Settings::getLinePattern(MAP::Settings::getObjectStringAttribute(QLatin1String("Building"),QLatin1String("LinePattern"),objId,QLatin1String("DashDotDot"))));
|
|
|
|
//TODO: move building on update ?
|
|
|
|
bool success = m_building->updateView();
|
|
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " success=" << success;
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::removeBuildings()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
const QList<int> keys = m_buildingMap.keys();
|
|
foreach(int objId, keys)
|
|
{
|
|
DEBUG_LOG(m_logger) << "Removing Building: " << objId;
|
|
removeBuilding(objId);
|
|
}
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::removeBuilding(int objId)
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
m_building = m_buildingMap[objId];
|
|
if (m_building)
|
|
{
|
|
m_building->removeMySelf();
|
|
m_building.reset();
|
|
m_buildingMap.remove(objId);
|
|
}
|
|
|
|
if (m_map)
|
|
{
|
|
m_map->update();
|
|
}
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::hideBuildings()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
for (auto it = m_buildingMap.cbegin(), end = m_buildingMap.cend(); it != end; ++it)
|
|
{
|
|
int objId = it.key();
|
|
DEBUG_LOG(m_logger) << "Hide/Show Building: " << objId;
|
|
hideBuilding(objId);
|
|
}
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::hideBuilding(int objId)
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
m_building = m_buildingMap[objId];
|
|
if (m_building)
|
|
{
|
|
bool isVisible = m_building->visibility();
|
|
m_building->setVisibility(!isVisible);
|
|
m_building->updateView();
|
|
}
|
|
if (m_map)
|
|
m_map->update();
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::updateMapObjects()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
m_timer->setSingleShot(true);
|
|
m_timer->start(1000);
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::createDangerAreas()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
this->createDangerArea(1);
|
|
// this->createDangerArea(2);
|
|
//TODO: more danger areas
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::createDangerArea(int objId)
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
if (!m_map)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " No map object ";
|
|
return;
|
|
}
|
|
|
|
m_dangerArea = m_dangerAreaMap[objId];
|
|
if (m_dangerArea)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Danger Area already exists " << objId;
|
|
return;
|
|
}
|
|
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Creating danger area " << objId;
|
|
m_dangerArea = m_map->objectFactory().create<SituationMap::DangerArea>( QLatin1String("AES"), QLatin1String("DangerAreaId"));
|
|
|
|
if (!m_dangerArea)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " No danger area object ";
|
|
return;
|
|
}
|
|
|
|
m_dangerArea->setIdentifier(MAP::Settings::objectIdentifier(QLatin1String("DangerArea"),objId));
|
|
|
|
m_dangerArea->setVisibility(MAP::Settings::getObjectBoolAttribute(QLatin1String("DangerArea"),QLatin1String("Visibility"),objId,true));
|
|
m_dangerArea->setVisibility(SituationMap::ObjectAppearance::Technical, MAP::Settings::getObjectBoolAttribute(QLatin1String("DangerArea"),QLatin1String("VisibilityTech"),objId,true));
|
|
m_dangerArea->setVisibility(SituationMap::ObjectAppearance::Tactical, MAP::Settings::getObjectBoolAttribute(QLatin1String("DangerArea"),QLatin1String("VisibilityTact"),objId,true));
|
|
|
|
m_dangerArea->setScale(MAP::Settings::mapObjectsTextScale());
|
|
|
|
m_dangerArea->rFillStyle().setFillColor(QColor(MAP::Settings::getObjectStringAttribute(QLatin1String("DangerArea"),QLatin1String("FillColor"),objId,QLatin1String("yellow"))));
|
|
m_dangerArea->rFillStyle().setFillPattern(MAP::Settings::getFillPattern(MAP::Settings::getObjectStringAttribute(QLatin1String("DangerArea"),QLatin1String("FillPattern"),objId,QLatin1String("DiagonalCross"))));
|
|
|
|
m_dangerArea->rLineStyle().setLineColor(QColor(MAP::Settings::getObjectStringAttribute(QLatin1String("DangerArea"),QLatin1String("LineColor"),objId,QLatin1String("red"))));
|
|
m_dangerArea->rLineStyle().setLineWidth(MAP::Settings::getObjectIntAttribute(QLatin1String("DangerArea"),QLatin1String("LineWidth"),objId,6));
|
|
m_dangerArea->rLineStyle().setLinePattern(MAP::Settings::getLinePattern(MAP::Settings::getObjectStringAttribute(QLatin1String("DangerArea"),QLatin1String("LinePattern"),objId,QLatin1String("DashDotDot"))));
|
|
|
|
// set additional values:
|
|
SituationMap::PositionCont posCont;
|
|
QPointF offset = QPointF(MAP::Settings::getObjectIntAttribute(QLatin1String("DangerArea"),QLatin1String("Offset_X"),objId,50000), MAP::Settings::getObjectIntAttribute(QLatin1String("DangerArea"),QLatin1String("Offset_Y"),objId,50000));
|
|
|
|
int extent = MAP::Settings::getObjectIntAttribute(QLatin1String("DangerArea"),QLatin1String("Extent"),objId,30000);
|
|
posCont << SituationMap::Point3D::fromQPointF(offset - QPointF( 0, 0));
|
|
posCont << SituationMap::Point3D::fromQPointF(offset - QPointF(extent, 0));
|
|
posCont << SituationMap::Point3D::fromQPointF(offset - QPointF(extent, extent));
|
|
posCont << SituationMap::Point3D::fromQPointF(offset - QPointF( 0, extent));
|
|
|
|
m_dangerArea->setPositions(posCont);
|
|
|
|
// update view
|
|
bool success = m_dangerArea->updateView();
|
|
|
|
if (!success)
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " updateView NOT OK";
|
|
|
|
m_dangerAreaMap[objId] = m_dangerArea;
|
|
|
|
connect(m_timer, &QTimer::timeout, this, [=]()
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Updating danger area " << objId;
|
|
onDangerAreaUpdate(objId);
|
|
});
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::removeDangerAreas()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
const QList<int> keys = m_dangerAreaMap.keys();
|
|
foreach(int objId, keys )
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Removing Danger Area: " << objId;
|
|
removeDangerArea(objId);
|
|
}
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::removeDangerArea(int objId)
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
m_dangerArea = m_dangerAreaMap[objId];
|
|
if (m_dangerArea)
|
|
{
|
|
m_dangerArea->removeMySelf();
|
|
m_dangerArea.reset();
|
|
m_dangerAreaMap.remove(objId);
|
|
}
|
|
|
|
if (m_map)
|
|
{
|
|
m_map->update();
|
|
}
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::hideDangerAreas()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
for (auto it = m_dangerAreaMap.cbegin(), end = m_dangerAreaMap.cend(); it != end; ++it)
|
|
{
|
|
int objId = it.key();
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Hide/Show Danger Area: " << objId;
|
|
hideDangerArea(objId);
|
|
}
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::hideDangerArea(int objId)
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
m_dangerArea = m_dangerAreaMap[objId];
|
|
if (m_dangerArea)
|
|
{
|
|
bool isVisible = m_dangerArea->visibility();
|
|
m_dangerArea->setVisibility(!isVisible);
|
|
m_dangerArea->updateView();
|
|
}
|
|
|
|
if (m_map)
|
|
m_map->update();
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::onDangerAreaUpdate(int objId)
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
if (!m_map)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " No map object ";
|
|
return;
|
|
}
|
|
|
|
m_dangerArea = m_dangerAreaMap[objId];
|
|
if (!m_dangerArea)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " No danger area object ";
|
|
return;
|
|
}
|
|
|
|
m_dangerArea->setIdentifier(MAP::Settings::objectIdentifier(QLatin1String("DangerArea"),objId) + QLatin1String("Update"));
|
|
|
|
//TODO: change more on update ?
|
|
|
|
bool success = m_dangerArea->updateView();
|
|
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " success=" << success;
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::createBAgents()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
this->createBAgent(1);
|
|
// this->createBAgent(2);
|
|
//TODO: more B-agents
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::createBAgent(int objId)
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
if (!m_map)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " No map object ";
|
|
return;
|
|
}
|
|
|
|
m_bAgent = m_bAgentMap[objId];
|
|
if (m_bAgent)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " BAgent already exists " << objId;
|
|
return;
|
|
}
|
|
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Creating BAgent " << objId;
|
|
m_bAgent = m_map->objectFactory().create<SituationMap::BiologicalAgent>( QLatin1String("AES"), QLatin1String("BAgentId"));
|
|
|
|
if (!m_bAgent)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " No BAgent object ";
|
|
return;
|
|
}
|
|
|
|
m_bAgent->setIdentifier(MAP::Settings::objectIdentifier(QLatin1String("BAgent"),objId));
|
|
|
|
m_bAgent->setVisibility(MAP::Settings::getObjectBoolAttribute(QLatin1String("BAgent"),QLatin1String("Visibility"),objId,true));
|
|
m_bAgent->setVisibility(SituationMap::ObjectAppearance::Technical, MAP::Settings::getObjectBoolAttribute(QLatin1String("BAgent"),QLatin1String("VisibilityTech"),objId,true));
|
|
m_bAgent->setVisibility(SituationMap::ObjectAppearance::Tactical, MAP::Settings::getObjectBoolAttribute(QLatin1String("BAgent"),QLatin1String("VisibilityTact"),objId,true));
|
|
|
|
m_bAgent->setScale(MAP::Settings::mapObjectsTextScale());
|
|
|
|
m_bAgent->rFillStyle().setFillColor(QColor(MAP::Settings::getObjectStringAttribute(QLatin1String("BAgent"),QLatin1String("FillColor"),objId,QLatin1String("yellow"))));
|
|
m_bAgent->rFillStyle().setFillPattern(MAP::Settings::getFillPattern(MAP::Settings::getObjectStringAttribute(QLatin1String("BAgent"),QLatin1String("FillPattern"),objId,QLatin1String("DiagonalCross"))));
|
|
|
|
m_bAgent->rLineStyle().setLineColor(QColor(MAP::Settings::getObjectStringAttribute(QLatin1String("BAgent"),QLatin1String("LineColor"),objId,QLatin1String("red"))));
|
|
m_bAgent->rLineStyle().setLineWidth(MAP::Settings::getObjectIntAttribute(QLatin1String("BAgent"),QLatin1String("LineWidth"),objId,6));
|
|
m_bAgent->rLineStyle().setLinePattern(MAP::Settings::getLinePattern(MAP::Settings::getObjectStringAttribute(QLatin1String("BAgent"),QLatin1String("LinePattern"),objId,QLatin1String("DashDotDot"))));
|
|
|
|
m_bAgent->rTextStyle().setTextColor(QColor(MAP::Settings::getObjectStringAttribute(QLatin1String("BAgent"),QLatin1String("TextColor"),objId,QLatin1String("magenta"))));
|
|
m_bAgent->rTextStyle().setSize(MAP::Settings::getObjectIntAttribute(QLatin1String("BAgent"),QLatin1String("TextSize"),objId,30));
|
|
m_bAgent->rTextStyle().setBold(MAP::Settings::getObjectBoolAttribute(QLatin1String("BAgent"),QLatin1String("TextBold"),objId,false));
|
|
|
|
// set additional values:
|
|
QPointF center = QPointF(MAP::Settings::getObjectIntAttribute(QLatin1String("BAgent"),QLatin1String("Offset_X"),objId,50000), MAP::Settings::getObjectIntAttribute(QLatin1String("BAgent"),QLatin1String("Offset_Y"),objId,50000));
|
|
int radius = MAP::Settings::getObjectIntAttribute(QLatin1String("BAgent"),QLatin1String("Extent"),objId,30000);
|
|
|
|
m_bAgent->setOrigin(SituationMap::Point3D::fromQPointF(center));
|
|
m_bAgent->setRadius(radius);
|
|
|
|
// update view
|
|
bool success = m_bAgent->updateView();
|
|
|
|
if (!success)
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " updateView NOT OK";
|
|
|
|
m_bAgentMap[objId] = m_bAgent;
|
|
|
|
connect(m_timer, &QTimer::timeout, this, [=]()
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Updating BAgent " << objId;
|
|
onBAgentUpdate(objId);
|
|
});
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::removeBAgents()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
const QList<int> keys = m_bAgentMap.keys();
|
|
foreach(int objId, keys )
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << "Removing Fire Area: " << objId;
|
|
removeBAgent(objId);
|
|
}
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::removeBAgent(int objId)
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
m_bAgent = m_bAgentMap[objId];
|
|
if (m_bAgent)
|
|
{
|
|
m_bAgent->removeMySelf();
|
|
m_bAgent.reset();
|
|
m_bAgentMap.remove(objId);
|
|
}
|
|
|
|
if (m_map)
|
|
{
|
|
m_map->update();
|
|
}
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::hideBAgents()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
for (auto it = m_bAgentMap.cbegin(), end = m_bAgentMap.cend(); it != end; ++it)
|
|
{
|
|
int objId = it.key();
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << "Hide/Show Fire Area: " << objId;
|
|
hideBAgent(objId);
|
|
}
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::hideBAgent(int objId)
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
m_bAgent = m_bAgentMap[objId];
|
|
if (m_bAgent)
|
|
{
|
|
bool isVisible = m_bAgent->visibility();
|
|
m_bAgent->setVisibility(!isVisible);
|
|
m_bAgent->updateView();
|
|
}
|
|
|
|
if (m_map)
|
|
m_map->update();
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::onBAgentUpdate(int objId)
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
if (!m_map)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " No map object ";
|
|
return;
|
|
}
|
|
|
|
m_bAgent = m_bAgentMap[objId];
|
|
if (!m_bAgent)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " No Fire area object ";
|
|
return;
|
|
}
|
|
|
|
m_bAgent->setIdentifier(MAP::Settings::objectIdentifier(QLatin1String("BAgent"),objId) + QLatin1String("Update"));
|
|
|
|
//TODO: change more on update ?
|
|
|
|
bool success = m_bAgent->updateView();
|
|
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " success=" << success;
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::createFireAreas()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
this->createFireArea(1);
|
|
// this->createFireArea(2);
|
|
//TODO: more Fire areas
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::createFireArea(int objId)
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
if (!m_map)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " No map object ";
|
|
return;
|
|
}
|
|
|
|
m_fireArea = m_fireAreaMap[objId];
|
|
if (m_fireArea)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Fire Area already exists " << objId;
|
|
return;
|
|
}
|
|
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Creating Fire Area " << objId;
|
|
m_fireArea = m_map->objectFactory().create<SituationMap::AreaFire>( QLatin1String("AES"), QLatin1String("AreaFireId"));
|
|
|
|
if (!m_fireArea)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " No Fire Area object ";
|
|
return;
|
|
}
|
|
|
|
m_fireArea->setIdentifier(MAP::Settings::objectIdentifier(QLatin1String("FireArea"),objId));
|
|
|
|
m_fireArea->setVisibility(MAP::Settings::getObjectBoolAttribute(QLatin1String("FireArea"),QLatin1String("Visibility"),objId,true));
|
|
m_fireArea->setVisibility(SituationMap::ObjectAppearance::Technical, MAP::Settings::getObjectBoolAttribute(QLatin1String("FireArea"),QLatin1String("VisibilityTech"),objId,true));
|
|
m_fireArea->setVisibility(SituationMap::ObjectAppearance::Tactical, MAP::Settings::getObjectBoolAttribute(QLatin1String("FireArea"),QLatin1String("VisibilityTact"),objId,true));
|
|
|
|
m_fireArea->setScale(MAP::Settings::mapObjectsTextScale());
|
|
|
|
m_fireArea->rFillStyle().setFillColor(QColor(MAP::Settings::getObjectStringAttribute(QLatin1String("FireArea"),QLatin1String("FillColor"),objId,QLatin1String("blue"))));
|
|
m_fireArea->rFillStyle().setFillPattern(MAP::Settings::getFillPattern(MAP::Settings::getObjectStringAttribute(QLatin1String("FireArea"),QLatin1String("FillPattern"),objId,QLatin1String("null"))));
|
|
|
|
m_fireArea->rLineStyle().setLineColor(QColor(MAP::Settings::getObjectStringAttribute(QLatin1String("FireArea"),QLatin1String("LineColor"),objId,QLatin1String("red"))));
|
|
m_fireArea->rLineStyle().setLineWidth(MAP::Settings::getObjectIntAttribute(QLatin1String("FireArea"),QLatin1String("LineWidth"),objId,6));
|
|
m_fireArea->rLineStyle().setLinePattern(MAP::Settings::getLinePattern(MAP::Settings::getObjectStringAttribute(QLatin1String("FireArea"),QLatin1String("LinePattern"),objId,QLatin1String("Solid"))));
|
|
|
|
// set additional values:
|
|
SituationMap::PositionCont posCont;
|
|
QPointF offset = QPointF(MAP::Settings::getObjectIntAttribute(QLatin1String("FireArea"),QLatin1String("Offset_X"),objId,170000), MAP::Settings::getObjectIntAttribute(QLatin1String("FireArea"),QLatin1String("Offset_Y"),objId,170000));
|
|
|
|
int extent = MAP::Settings::getObjectIntAttribute(QLatin1String("FireArea"),QLatin1String("Extent"),objId,100000);
|
|
posCont << SituationMap::Point3D::fromQPointF(offset + QPointF( 0, 0));
|
|
posCont << SituationMap::Point3D::fromQPointF(offset + QPointF(extent, 0));
|
|
posCont << SituationMap::Point3D::fromQPointF(offset + QPointF(extent, extent));
|
|
posCont << SituationMap::Point3D::fromQPointF(offset + QPointF(extent/2, extent/2));
|
|
posCont << SituationMap::Point3D::fromQPointF(offset + QPointF( 0, extent));
|
|
|
|
m_fireArea->setPositions(posCont);
|
|
|
|
posCont.removeAt(3);
|
|
m_fireArea->setImpacts(posCont);
|
|
|
|
// TODO: use colors from PartyId ?
|
|
// m_fireArea->setPartyId(3);
|
|
// m_fireArea->setSelected(true);
|
|
|
|
// update view
|
|
bool success = m_fireArea->updateView();
|
|
|
|
if (!success)
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " updateView NOT OK";
|
|
|
|
m_fireAreaMap[objId] = m_fireArea;
|
|
|
|
connect(m_timer, &QTimer::timeout, this, [=]()
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Updating Fire Area " << objId;
|
|
onFireAreaUpdate(objId);
|
|
});
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::removeFireAreas()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
const QList<int> keys = m_fireAreaMap.keys();
|
|
foreach(int objId, keys)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << "Removing Fire Area: " << objId;
|
|
removeFireArea(objId);
|
|
}
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::removeFireArea(int objId)
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
m_fireArea = m_fireAreaMap[objId];
|
|
if (m_fireArea)
|
|
{
|
|
m_fireArea->removeMySelf();
|
|
m_fireArea.reset();
|
|
m_fireAreaMap.remove(objId);
|
|
}
|
|
|
|
if (m_map)
|
|
{
|
|
m_map->update();
|
|
}
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::hideFireAreas()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
for (auto it = m_fireAreaMap.cbegin(), end = m_fireAreaMap.cend(); it != end; ++it)
|
|
{
|
|
int objId = it.key();
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << "Hide/Show Fire Area: " << objId;
|
|
hideFireArea(objId);
|
|
}
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::hideFireArea(int objId)
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
m_fireArea = m_fireAreaMap[objId];
|
|
if (m_fireArea)
|
|
{
|
|
bool isVisible = m_fireArea->visibility();
|
|
m_fireArea->setVisibility(!isVisible);
|
|
m_fireArea->updateView();
|
|
}
|
|
|
|
if (m_map)
|
|
m_map->update();
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::onFireAreaUpdate(int objId)
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
if (!m_map)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " No map object ";
|
|
return;
|
|
}
|
|
|
|
m_fireArea = m_fireAreaMap[objId];
|
|
if (!m_fireArea)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " No Fire area object ";
|
|
return;
|
|
}
|
|
|
|
m_fireArea->setIdentifier(MAP::Settings::objectIdentifier(QLatin1String("FireArea"),objId) + QLatin1String("Update"));
|
|
m_fireArea->setPartyId(4); // Will overwrite line/fillcolor
|
|
|
|
SituationMap::PositionCont posCont;
|
|
QPointF offset = QPointF(MAP::Settings::getObjectIntAttribute(QLatin1String("FireArea"),QLatin1String("Offset_X"),objId,170000), MAP::Settings::getObjectIntAttribute(QLatin1String("FireArea"),QLatin1String("Offset_Y"),objId,170000));
|
|
|
|
int extent = MAP::Settings::getObjectIntAttribute(QLatin1String("FireArea"),QLatin1String("Extent"),objId,100000);
|
|
posCont << SituationMap::Point3D::fromQPointF(offset + QPointF( 0, 0));
|
|
posCont << SituationMap::Point3D::fromQPointF(offset + QPointF(extent, 0));
|
|
posCont << SituationMap::Point3D::fromQPointF(offset + QPointF(extent, extent*2));
|
|
posCont << SituationMap::Point3D::fromQPointF(offset + QPointF( 0, extent));
|
|
|
|
m_fireArea->setPositions(posCont);
|
|
|
|
posCont.removeAt(1);
|
|
posCont.removeAt(3);
|
|
|
|
m_fireArea->updateView();
|
|
|
|
//TODO: change more on update ?
|
|
|
|
bool success = m_fireArea->updateView();
|
|
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " success=" << success;
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::createHitLines()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
this->createHitLine(1);
|
|
// this->createHitLine(2);
|
|
//TODO: more Hit Lines
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::createHitLine(int objId)
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
if (!m_map)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " No map object ";
|
|
return;
|
|
}
|
|
|
|
m_hitLine = m_hitLineMap[objId];
|
|
if (m_hitLine)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Fire Line already exists " << objId;
|
|
return;
|
|
}
|
|
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Creating Fire Line " << objId;
|
|
m_hitLine = m_map->objectFactory().create<SituationMap::HitLine>( QLatin1String("AES"), QLatin1String("HitLineId"));
|
|
|
|
if (!m_hitLine)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " No Fire Line object ";
|
|
return;
|
|
}
|
|
|
|
m_hitLine->setIdentifier(MAP::Settings::objectIdentifier(QLatin1String("HitLine"),objId));
|
|
|
|
m_hitLine->setVisibility(MAP::Settings::getObjectBoolAttribute(QLatin1String("HitLine"),QLatin1String("Visibility"),objId,true));
|
|
m_hitLine->setVisibility(SituationMap::ObjectAppearance::Technical, MAP::Settings::getObjectBoolAttribute(QLatin1String("HitLine"),QLatin1String("VisibilityTech"),objId,true));
|
|
m_hitLine->setVisibility(SituationMap::ObjectAppearance::Tactical, MAP::Settings::getObjectBoolAttribute(QLatin1String("HitLine"),QLatin1String("VisibilityTact"),objId,true));
|
|
|
|
m_hitLine->setScale(MAP::Settings::mapObjectsTextScale());
|
|
|
|
m_hitLine->rLineStyle().setLineColor(QColor(MAP::Settings::getObjectStringAttribute(QLatin1String("HitLine"),QLatin1String("LineColor"),objId,QLatin1String("red"))));
|
|
m_hitLine->rLineStyle().setLineWidth(MAP::Settings::getObjectIntAttribute(QLatin1String("HitLine"),QLatin1String("LineWidth"),objId,6));
|
|
m_hitLine->rLineStyle().setLinePattern(MAP::Settings::getLinePattern(MAP::Settings::getObjectStringAttribute(QLatin1String("HitLine"),QLatin1String("LinePattern"),objId,QLatin1String("DashDotDot"))));
|
|
|
|
// set additional values:
|
|
QPointF offset = QPointF(MAP::Settings::getObjectIntAttribute(QLatin1String("HitLine"),QLatin1String("Offset_X"),objId,50000), MAP::Settings::getObjectIntAttribute(QLatin1String("HitLine"),QLatin1String("Offset_Y"),objId,50000));
|
|
int extent = MAP::Settings::getObjectIntAttribute(QLatin1String("HitLine"),QLatin1String("Extent"),objId,30000);
|
|
|
|
m_hitLine->setStartAndEndPoint(SituationMap::Point3D::fromQPointF(offset),
|
|
SituationMap::Point3D::fromQPointF(offset + QPointF(0, extent)));
|
|
|
|
// update view
|
|
bool success = m_hitLine->updateView();
|
|
|
|
if (!success)
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " updateView NOT OK";
|
|
|
|
m_hitLineMap[objId] = m_hitLine;
|
|
|
|
connect(m_timer, &QTimer::timeout, this, [=]()
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Updating Fire Line " << objId;
|
|
onHitLineUpdate(objId);
|
|
});
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::removeHitLines()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
const QList<int> keys = m_hitLineMap.keys();
|
|
foreach(int objId, keys)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << "Removing Hit Line: " << objId;
|
|
removeHitLine(objId);
|
|
}
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::removeHitLine(int objId)
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
m_hitLine = m_hitLineMap[objId];
|
|
if (m_hitLine)
|
|
{
|
|
m_hitLine->removeMySelf();
|
|
m_hitLine.reset();
|
|
m_hitLineMap.remove(objId);
|
|
}
|
|
|
|
if (m_map)
|
|
{
|
|
m_map->update();
|
|
}
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::hideHitLines()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
for (auto it = m_hitLineMap.cbegin(), end = m_hitLineMap.cend(); it != end; ++it)
|
|
{
|
|
int objId = it.key();
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << "Hide/Show Hit Line: " << objId;
|
|
hideHitLine(objId);
|
|
}
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::hideHitLine(int objId)
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
m_hitLine = m_hitLineMap[objId];
|
|
if (m_hitLine)
|
|
{
|
|
bool isVisible = m_hitLine->visibility();
|
|
m_hitLine->setVisibility(!isVisible);
|
|
m_hitLine->updateView();
|
|
}
|
|
|
|
if (m_map)
|
|
m_map->update();
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::onHitLineUpdate(int objId)
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
if (!m_map)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " No map object ";
|
|
return;
|
|
}
|
|
|
|
m_hitLine = m_hitLineMap[objId];
|
|
if (!m_hitLine)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " No Fire Line object ";
|
|
return;
|
|
}
|
|
|
|
m_hitLine->setIdentifier(MAP::Settings::objectIdentifier(QLatin1String("HitLine"),objId) + QLatin1String("Update"));
|
|
|
|
// set additional values:
|
|
SituationMap::Point3D start = m_hitLine->startPoint();
|
|
SituationMap::Point3D end = m_hitLine->endPoint();
|
|
|
|
m_hitLine->setStartAndEndPoint(end,
|
|
start + SituationMap::Point3D(10000, 1000, .0));
|
|
|
|
/*
|
|
// set additional values:
|
|
SituationMap::PositionCont posCont;
|
|
QPointF offset = QPointF(MAP::Settings::getObjectIntAttribute(QLatin1String("HitLine"),QLatin1String("Offset_X"),objId,50000), MAP::Settings::getObjectIntAttribute(QLatin1String("HitLine"),QLatin1String("Offset_Y"),objId,50000));
|
|
int extent = MAP::Settings::getObjectIntAttribute(QLatin1String("HitLine"),QLatin1String("Extent"),objId,30000);
|
|
|
|
posCont << offset + QPointF(extent, 0);
|
|
posCont << offset + QPointF( 0, extent);
|
|
|
|
m_hitLine->setPositions(posCont);
|
|
*/
|
|
|
|
//TODO: change more on update ?
|
|
|
|
bool success = m_hitLine->updateView();
|
|
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " success=" << success;
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::rubberbandPointCluster()
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
if (!m_map)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " No map object ";
|
|
return;
|
|
}
|
|
|
|
SituationMap::RB::RubberbandPointCluster * rubberband = nullptr;
|
|
|
|
try
|
|
{
|
|
rubberband = m_map->rubberbandFactory().create<SituationMap::RB::RubberbandPointCluster>();
|
|
}
|
|
catch (SituationMap::Exception &e)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " " << e.getMessage();
|
|
}
|
|
|
|
if (rubberband == nullptr)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " Creating rubberband failed";
|
|
}
|
|
else
|
|
{
|
|
QObject::connect( rubberband, &SituationMap::RB::Rubberband::apply, this, &MainWindow::onRubberbandPointClusterApply);
|
|
QObject::connect( rubberband, &SituationMap::RB::Rubberband::abort, this, &MainWindow::onRubberbandAbort);
|
|
}
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------
|
|
void MainWindow::onRubberbandAbort( SituationMap::RB::RubberbandBase * rubberband )
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Aborting rubberband ";
|
|
|
|
rubberband->deleteMySelf();
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::rubberbandMultiPoint()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
if (!m_map)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " No map object ";
|
|
return;
|
|
}
|
|
|
|
SituationMap::RB::RubberbandMultiPointFeature * rubberband = nullptr;
|
|
|
|
try
|
|
{
|
|
rubberband = m_map->rubberbandFactory().create<SituationMap::RB::RubberbandMultiPointFeature>();
|
|
}
|
|
catch (SituationMap::Exception &e)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " " << e.getMessage();
|
|
}
|
|
|
|
if (rubberband == nullptr)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << "Creating rubberband failed";
|
|
}
|
|
else
|
|
{
|
|
rubberband->enableClosed(false);
|
|
|
|
QObject::connect( rubberband, &SituationMap::RB::Rubberband::apply, this, &MainWindow::onRubberbandMultiPointApply);
|
|
QObject::connect( rubberband, &SituationMap::RB::Rubberband::abort, this, &MainWindow::onRubberbandAbort);
|
|
}
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::rubberbandRectangle()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
if (!m_map)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " No map object ";
|
|
return;
|
|
}
|
|
|
|
SituationMap::RB::RubberbandRectangle * rubberband = nullptr;
|
|
|
|
try
|
|
{
|
|
rubberband = m_map->rubberbandFactory().create<SituationMap::RB::RubberbandRectangle>();
|
|
}
|
|
catch (SituationMap::Exception &e)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " " << e.getMessage();
|
|
}
|
|
|
|
if (rubberband == nullptr)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " Creating rubberband failed";
|
|
}
|
|
else
|
|
{
|
|
QObject::connect( rubberband, &SituationMap::RB::Rubberband::apply, this, &MainWindow::onRubberbandRectangleApply);
|
|
QObject::connect( rubberband, &SituationMap::RB::Rubberband::abort, this, &MainWindow::onRubberbandAbort);
|
|
}
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::rubberbandSquare()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
if (!m_map)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " No map object ";
|
|
return;
|
|
}
|
|
|
|
SituationMap::RB::RubberbandRectangle * rubberband = nullptr;
|
|
|
|
try
|
|
{
|
|
rubberband = m_map->rubberbandFactory().create<SituationMap::RB::RubberbandRectangle>();
|
|
}
|
|
catch (SituationMap::Exception &e)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " " << e.getMessage();
|
|
}
|
|
|
|
if (rubberband == nullptr)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " Creating rubberband failed";
|
|
}
|
|
else
|
|
{
|
|
rubberband->constrainQuadratic(true);
|
|
QObject::connect( rubberband, &SituationMap::RB::Rubberband::apply, this, &MainWindow::onRubberbandRectangleApply);
|
|
QObject::connect( rubberband, &SituationMap::RB::Rubberband::abort, this, &MainWindow::onRubberbandAbort);
|
|
}
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::rubberbandEllipse()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
if (!m_map)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " No map object ";
|
|
return;
|
|
}
|
|
|
|
SituationMap::RB::RubberbandEllipse * rubberband = nullptr;
|
|
|
|
try
|
|
{
|
|
rubberband = m_map->rubberbandFactory().create<SituationMap::RB::RubberbandEllipse>();
|
|
}
|
|
catch (SituationMap::Exception &e)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " " << e.getMessage();
|
|
}
|
|
|
|
if (rubberband == nullptr)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " Creating rubberband failed";
|
|
}
|
|
else
|
|
{
|
|
QObject::connect( rubberband, &SituationMap::RB::Rubberband::apply, this, &MainWindow::onRubberbandEllipseApply);
|
|
QObject::connect( rubberband, &SituationMap::RB::Rubberband::abort, this, &MainWindow::onRubberbandAbort);
|
|
}
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::rubberbandArrow()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
if (!m_map)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " No map object ";
|
|
return;
|
|
}
|
|
|
|
SituationMap::RB::RubberbandArrow * rubberband = nullptr;
|
|
|
|
try
|
|
{
|
|
rubberband = m_map->rubberbandFactory().create<SituationMap::RB::RubberbandArrow>();
|
|
}
|
|
catch (SituationMap::Exception &e)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " " << e.getMessage();
|
|
}
|
|
|
|
if (rubberband == nullptr)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " Creating rubberband failed";
|
|
}
|
|
else
|
|
{
|
|
QObject::connect( rubberband, &SituationMap::RB::Rubberband::apply, this, &MainWindow::onRubberbandArrowApply);
|
|
QObject::connect( rubberband, &SituationMap::RB::Rubberband::abort, this, &MainWindow::onRubberbandAbort);
|
|
}
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::rubberbandCorridorCenterline()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
if (!m_map)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " No map object ";
|
|
return;
|
|
}
|
|
|
|
SituationMap::RB::RubberbandCorridor * rubberband = nullptr;
|
|
|
|
try
|
|
{
|
|
rubberband = m_map->rubberbandFactory().create<SituationMap::RB::RubberbandCorridor>();
|
|
}
|
|
catch (SituationMap::Exception &e)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " " << e.getMessage();
|
|
}
|
|
|
|
if (rubberband == nullptr)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " Creating rubberband failed";
|
|
}
|
|
else
|
|
{
|
|
rubberband->setInputCenterline();
|
|
rubberband->setCorridorWidth(MAP::Settings::getObjectIntAttribute(QLatin1String("RB_Corridor"),QLatin1String("Width"),1,8000) );
|
|
rubberband->setCorridorFillColor((QColor(MAP::Settings::getObjectStringAttribute(QLatin1String("RB_Corridor"),QLatin1String("FillColor"),1,QLatin1String("orange")))) );
|
|
|
|
QObject::connect( rubberband, &SituationMap::RB::Rubberband::apply, this, &MainWindow::onRubberbandCorridorApply);
|
|
QObject::connect( rubberband, &SituationMap::RB::Rubberband::abort, this, &MainWindow::onRubberbandAbort);
|
|
}
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::rubberbandCorridorBoundary()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
if (!m_map)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " No map object ";
|
|
return;
|
|
}
|
|
|
|
SituationMap::RB::RubberbandCorridor * rubberband = nullptr;
|
|
|
|
try
|
|
{
|
|
rubberband = m_map->rubberbandFactory().create<SituationMap::RB::RubberbandCorridor>();
|
|
}
|
|
catch (SituationMap::Exception &e)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " " << e.getMessage();
|
|
}
|
|
|
|
if (rubberband == nullptr)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " Creating rubberband failed";
|
|
}
|
|
else
|
|
{
|
|
rubberband->setInputBoundary();
|
|
rubberband->setCorridorFillColor((QColor(MAP::Settings::getObjectStringAttribute(QLatin1String("RB_Corridor"),QLatin1String("FillColor"),1,QLatin1String("orange")))) );
|
|
rubberband->maximumLength( MAP::Settings::getObjectIntAttribute(QLatin1String("RB_Corridor"),QLatin1String("MaxLength"),1,100000) );
|
|
rubberband->maximumSegmentLength( MAP::Settings::getObjectIntAttribute(QLatin1String("RB_Corridor"),QLatin1String("MaxSegmentLength"),1,10000) );
|
|
rubberband->minimumCorridorWidth( MAP::Settings::getObjectIntAttribute(QLatin1String("RB_Corridor"),QLatin1String("MinWidth"),1,2000) );
|
|
rubberband->maximumCorridorWidth( MAP::Settings::getObjectIntAttribute(QLatin1String("RB_Corridor"),QLatin1String("MaxWidth"),1,10000) );
|
|
rubberband->minimumPointCount( MAP::Settings::getObjectIntAttribute(QLatin1String("RB_Corridor"),QLatin1String("MinPointCount"),1,3) );
|
|
rubberband->maximumPointCount( MAP::Settings::getObjectIntAttribute(QLatin1String("RB_Corridor"),QLatin1String("MaxPointCount"),1,8) );
|
|
rubberband->draw();
|
|
|
|
QObject::connect( rubberband, &SituationMap::RB::Rubberband::apply, this, &MainWindow::onRubberbandCorridorApply);
|
|
QObject::connect( rubberband, &SituationMap::RB::Rubberband::abort, this, &MainWindow::onRubberbandAbort);
|
|
}
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::rubberbandFilledMultiPoint()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
if (!m_map)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " No map object ";
|
|
return;
|
|
}
|
|
|
|
SituationMap::RB::RubberbandMultiPointFeature * rubberband = nullptr;
|
|
|
|
try
|
|
{
|
|
rubberband = m_map->rubberbandFactory().create<SituationMap::RB::RubberbandMultiPointFeature>();
|
|
}
|
|
catch (SituationMap::Exception &e)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " " << e.getMessage();
|
|
}
|
|
|
|
if (rubberband == nullptr)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " Creating rubberband failed";
|
|
}
|
|
else
|
|
{
|
|
rubberband->enableClosed(true);
|
|
rubberband->setFillColor( (QColor(MAP::Settings::getObjectStringAttribute(QLatin1String("RB_MultiPoint"),QLatin1String("FillColor"),1,QLatin1String("teal")))) );
|
|
rubberband->maximumLength( MAP::Settings::getObjectIntAttribute(QLatin1String("RB_MultiPoint"),QLatin1String("MaxLength"),1,1000000) );
|
|
rubberband->maximumSegmentLength( MAP::Settings::getObjectIntAttribute(QLatin1String("RB_MultiPoint"),QLatin1String("MaxSegmentLength"),1,500000) );
|
|
|
|
QObject::connect( rubberband, &SituationMap::RB::Rubberband::apply, this, &MainWindow::onRubberbandMultiPointApply);
|
|
QObject::connect( rubberband, &SituationMap::RB::Rubberband::abort, this, &MainWindow::onRubberbandAbort);
|
|
}
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::rubberbandSmoothLine()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
if (!m_map)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " No map object ";
|
|
return;
|
|
}
|
|
|
|
SituationMap::RB::RubberbandSmoothLine * rubberband = nullptr;
|
|
|
|
try
|
|
{
|
|
rubberband = m_map->rubberbandFactory().create<SituationMap::RB::RubberbandSmoothLine>();
|
|
}
|
|
catch (SituationMap::Exception &e)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " " << e.getMessage();
|
|
}
|
|
|
|
if (rubberband == nullptr)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " Creating rubberband failed";
|
|
}
|
|
else
|
|
{
|
|
QObject::connect( rubberband, &SituationMap::RB::Rubberband::apply, this, &MainWindow::onRubberbandSmoothLineApply);
|
|
QObject::connect( rubberband, &SituationMap::RB::Rubberband::abort, this, &MainWindow::onRubberbandAbort);
|
|
}
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::rubberbandFilledSmoothLine()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
if (!m_map)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " No map object ";
|
|
return;
|
|
}
|
|
|
|
SituationMap::RB::RubberbandSmoothLine * rubberband = nullptr;
|
|
|
|
try
|
|
{
|
|
rubberband = m_map->rubberbandFactory().create<SituationMap::RB::RubberbandSmoothLine>();
|
|
}
|
|
catch (SituationMap::Exception &e)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " " << e.getMessage();
|
|
}
|
|
|
|
if (rubberband == nullptr)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " Creating rubberband failed";
|
|
}
|
|
else
|
|
{
|
|
rubberband->enableClosed(true);
|
|
rubberband->setFillColor( (QColor(MAP::Settings::getObjectStringAttribute(QLatin1String("RB_SmoothLine"),QLatin1String("FillColor"),1,QLatin1String("olive")))) );
|
|
|
|
QObject::connect( rubberband, &SituationMap::RB::Rubberband::apply, this, &MainWindow::onRubberbandSmoothLineApply);
|
|
QObject::connect( rubberband, &SituationMap::RB::Rubberband::abort, this, &MainWindow::onRubberbandAbort);
|
|
}
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::rubberbandCreateRectangle(int objId, int noPoints, bool isSquare)
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
if (!m_map)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " No map object ";
|
|
return;
|
|
}
|
|
|
|
SituationMap::RB::RubberbandRectangle * rubberband = nullptr;
|
|
|
|
try
|
|
{
|
|
rubberband = m_map->rubberbandFactory().create<SituationMap::RB::RubberbandRectangle>();
|
|
}
|
|
catch (SituationMap::Exception &e)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " " << e.getMessage();
|
|
}
|
|
|
|
if (rubberband == nullptr)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " Creating rubberband failed";
|
|
}
|
|
else
|
|
{
|
|
QVector<QPointF> vertexList;
|
|
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " CREATE RUBBERBAND with values from ini file";
|
|
|
|
vertexList.reserve(noPoints);
|
|
for (int i = 1; i <= noPoints; i++)
|
|
{
|
|
vertexList.append(MAP::Settings::getPoint(QLatin1String("RB_Rectangle"),objId,i));
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Point " << i << " : (" << MAP::Settings::getPoint(QLatin1String("RB_Rectangle"),objId,i).x() << "," << MAP::Settings::getPoint(QLatin1String("RB_Rectangle"),objId,i).y() << ")";
|
|
}
|
|
|
|
rubberband->setCoordinateVector(vertexList);
|
|
rubberband->setFrameHandleMargin(MAP::Settings::getObjectIntAttribute(QLatin1String("RB_Rectangle"),QLatin1String("HandleMargin"),objId,10));
|
|
rubberband->constrainQuadratic(isSquare);
|
|
|
|
QObject::connect( rubberband, &SituationMap::RB::Rubberband::apply, this, &MainWindow::onRubberbandRectangleApply);
|
|
QObject::connect( rubberband, &SituationMap::RB::Rubberband::abort, this, &MainWindow::onRubberbandAbort);
|
|
}
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::rubberbandCreateRectangles()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
if (!m_map)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " No map object ";
|
|
return;
|
|
}
|
|
|
|
rubberbandCreateRectangle(1, 4, false);
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::rubberbandCreateSquares()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
if (!m_map)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " No map object ";
|
|
return;
|
|
}
|
|
|
|
rubberbandCreateRectangle(2, 4, true);
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::rubberbandCreateEllipses()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
if (!m_map)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " No map object ";
|
|
return;
|
|
}
|
|
|
|
rubberbandCreateEllipse(1, 4);
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::rubberbandCreatePointClusters()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
if (!m_map)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " No map object ";
|
|
return;
|
|
}
|
|
|
|
rubberbandCreatePointCluster(1, 8);
|
|
//rubberbandCreatePointCluster(2, 4);
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::rubberbandCreateEllipse(int objId, int noPoints)
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
if (!m_map)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " No map object ";
|
|
return;
|
|
}
|
|
|
|
SituationMap::RB::RubberbandEllipse * rubberband = nullptr;
|
|
|
|
try
|
|
{
|
|
rubberband = m_map->rubberbandFactory().create<SituationMap::RB::RubberbandEllipse>();
|
|
}
|
|
catch (SituationMap::Exception &e)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " " << e.getMessage();
|
|
}
|
|
|
|
if (rubberband == nullptr)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " Creating rubberband failed";
|
|
}
|
|
else
|
|
{
|
|
QVector<QPointF> vertexList;
|
|
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " CREATE RUBBERBAND with values from ini file";
|
|
|
|
vertexList.reserve(noPoints);
|
|
for (int i = 1; i <= noPoints; i++)
|
|
{
|
|
vertexList.append(MAP::Settings::getPoint(QLatin1String("RB_Ellipse"),objId,i));
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Point " << i << " : (" << MAP::Settings::getPoint(QLatin1String("RB_Ellipse"),objId,i).x() << "," << MAP::Settings::getPoint(QLatin1String("RB_Ellipse"),objId,i).y() << ")";
|
|
}
|
|
|
|
rubberband->setCoordinateVector(vertexList);
|
|
rubberband->setFrameHandleMargin(MAP::Settings::getObjectIntAttribute(QLatin1String("RB_Ellipse"),QLatin1String("HandleMargin"),objId,10));
|
|
|
|
QObject::connect( rubberband, &SituationMap::RB::Rubberband::apply, this, &MainWindow::onRubberbandEllipseApply);
|
|
QObject::connect( rubberband, &SituationMap::RB::Rubberband::abort, this, &MainWindow::onRubberbandAbort);
|
|
}
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::rubberbandCreatePointCluster(int objId, int noPoints)
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
if (!m_map)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " No map object ";
|
|
return;
|
|
}
|
|
|
|
SituationMap::RB::RubberbandPointCluster * rubberband = nullptr;
|
|
|
|
try
|
|
{
|
|
rubberband = m_map->rubberbandFactory().create<SituationMap::RB::RubberbandPointCluster>();
|
|
}
|
|
catch (SituationMap::Exception &e)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " " << e.getMessage();
|
|
}
|
|
|
|
if (rubberband == nullptr)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " Creating rubberband failed";
|
|
}
|
|
else
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " CREATE RUBBERBAND with values from ini file";
|
|
|
|
QVector<QPointF> vertexList;
|
|
|
|
vertexList.reserve(noPoints);
|
|
for (int i = 1; i <= noPoints; i++)
|
|
{
|
|
vertexList.append(MAP::Settings::getPoint(QLatin1String("RB_PointCluster"),objId,i));
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Point " << i << " : (" << MAP::Settings::getPoint(QLatin1String("RB_PointCluster"),objId,i).x() << "," << MAP::Settings::getPoint(QLatin1String("RB_PointCluster"),objId,i).y() << ")";
|
|
}
|
|
|
|
rubberband->setCoordinateVector(vertexList);
|
|
|
|
QObject::connect( rubberband, &SituationMap::RB::Rubberband::apply, this, &MainWindow::onRubberbandPointClusterApply);
|
|
QObject::connect( rubberband, &SituationMap::RB::Rubberband::abort, this, &MainWindow::onRubberbandAbort);
|
|
}
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::rubberbandCreateMultiPoint(int objId, int noPoints, bool filled)
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
if (!m_map)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " No map object ";
|
|
return;
|
|
}
|
|
|
|
SituationMap::RB::RubberbandMultiPointFeature * rubberband = nullptr;
|
|
|
|
try
|
|
{
|
|
rubberband = m_map->rubberbandFactory().create<SituationMap::RB::RubberbandMultiPointFeature>();
|
|
}
|
|
catch (SituationMap::Exception &e)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " " << e.getMessage();
|
|
}
|
|
|
|
if (rubberband == nullptr)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " Creating rubberband failed";
|
|
}
|
|
else
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " CREATE RUBBERBAND with values from ini file";
|
|
|
|
QVector<QPointF> vertexList;
|
|
|
|
vertexList.reserve(noPoints);
|
|
for (int i = 1; i <= noPoints; i++)
|
|
{
|
|
vertexList.append(MAP::Settings::getPoint(QLatin1String("RB_MultiPoint"),objId,i));
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Point " << i << " : (" << MAP::Settings::getPoint(QLatin1String("RB_MultiPoint"),objId,i).x() << "," << MAP::Settings::getPoint(QLatin1String("RB_MultiPoint"),objId,i).y() << ")";
|
|
}
|
|
|
|
rubberband->setCoordinateVector(vertexList);
|
|
rubberband->enableClosed( false );
|
|
|
|
if (filled)
|
|
{
|
|
rubberband->enableClosed( true );
|
|
rubberband->setFillColor( (QColor(MAP::Settings::getObjectStringAttribute(QLatin1String("RB_MultiPoint"),QLatin1String("FillColor"),objId,QLatin1String("teal")))) );
|
|
rubberband->maximumLength( MAP::Settings::getObjectIntAttribute(QLatin1String("RB_MultiPoint"),QLatin1String("MaxLength"), objId, 1000000) );
|
|
rubberband->maximumSegmentLength( MAP::Settings::getObjectIntAttribute(QLatin1String("RB_MultiPoint"),QLatin1String("MaxSegmentLength"), objId, 500000) );
|
|
}
|
|
QObject::connect( rubberband, &SituationMap::RB::Rubberband::apply, this, &MainWindow::onRubberbandMultiPointApply);
|
|
QObject::connect( rubberband, &SituationMap::RB::Rubberband::abort, this, &MainWindow::onRubberbandAbort);
|
|
}
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::rubberbandCreateMultiPoints()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
if (!m_map)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " No map object ";
|
|
return;
|
|
}
|
|
|
|
rubberbandCreateMultiPoint(1, 5, false);
|
|
// TODO: more
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::rubberbandCreateFilledMultiPoints()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
if (!m_map)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " No map object ";
|
|
return;
|
|
}
|
|
|
|
rubberbandCreateMultiPoint(1, 5, true);
|
|
// TODO: more
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::rubberbandCreateSmoothLines()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
if (!m_map)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " No map object ";
|
|
return;
|
|
}
|
|
|
|
rubberbandCreateSmoothLine(1, 4, false);
|
|
// TODO: more
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::rubberbandCreateFilledSmoothLines()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
if (!m_map)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " No map object ";
|
|
return;
|
|
}
|
|
|
|
rubberbandCreateSmoothLine(1, 4, true);
|
|
// TODO: more
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::rubberbandCreateSmoothLine(int objId, int noPoints, bool filled)
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
if (!m_map)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " No map object ";
|
|
return;
|
|
}
|
|
|
|
SituationMap::RB::RubberbandSmoothLine * rubberband = nullptr;
|
|
|
|
try
|
|
{
|
|
rubberband = m_map->rubberbandFactory().create<SituationMap::RB::RubberbandSmoothLine>();
|
|
}
|
|
catch (SituationMap::Exception &e)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " " << e.getMessage();
|
|
}
|
|
|
|
if (rubberband == nullptr)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " Creating rubberband failed";
|
|
}
|
|
else
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " CREATE RUBBERBAND with values from ini file";
|
|
|
|
QVector<QPointF> vertexList;
|
|
|
|
vertexList.reserve(noPoints);
|
|
for (int i = 1; i <= noPoints; i++)
|
|
{
|
|
vertexList.append(MAP::Settings::getPoint(QLatin1String("RB_SmoothLine"),objId,i));
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Point " << i << " : (" << MAP::Settings::getPoint(QLatin1String("RB_SmoothLine"),objId,i).x() << "," << MAP::Settings::getPoint(QLatin1String("RB_SmoothLine"),objId,i).y() << ")";
|
|
}
|
|
|
|
rubberband->setCoordinateVector(vertexList);
|
|
rubberband->enableClosed( false );
|
|
if (filled)
|
|
{
|
|
rubberband->enableClosed( true );
|
|
rubberband->setFillColor( (QColor(MAP::Settings::getObjectStringAttribute(QLatin1String("RB_SmoothLine"),QLatin1String("FillColor"),objId,QLatin1String("olive")))) );
|
|
}
|
|
QObject::connect( rubberband, &SituationMap::RB::Rubberband::apply, this, &MainWindow::onRubberbandSmoothLineApply);
|
|
QObject::connect( rubberband, &SituationMap::RB::Rubberband::abort, this, &MainWindow::onRubberbandAbort);
|
|
}
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::rubberbandCreateCorridorBoundaries()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
if (!m_map)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " No map object ";
|
|
return;
|
|
}
|
|
|
|
rubberbandCreateCorridor(1, 5, true);
|
|
// TODO: more
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::rubberbandCreateCorridorCenterlines()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
if (!m_map)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " No map object ";
|
|
return;
|
|
}
|
|
|
|
rubberbandCreateCorridor(1, 5, false);
|
|
// TODO: more
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::rubberbandCreateCorridor(int objId, int noPoints, bool bound)
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
if (!m_map)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " No map object ";
|
|
return;
|
|
}
|
|
|
|
SituationMap::RB::RubberbandCorridor * rubberband = nullptr;
|
|
|
|
try
|
|
{
|
|
rubberband = m_map->rubberbandFactory().create<SituationMap::RB::RubberbandCorridor>();
|
|
}
|
|
catch (SituationMap::Exception &e)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << e.getMessage();
|
|
}
|
|
|
|
if (rubberband == nullptr)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " Creating rubberband failed";
|
|
}
|
|
else
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " CREATE RUBBERBAND with values from ini file";
|
|
|
|
QVector<QPointF> vertexList;
|
|
|
|
vertexList.reserve(noPoints);
|
|
for (int i = 1; i <= noPoints; i++)
|
|
{
|
|
vertexList.append(MAP::Settings::getPoint(QLatin1String("RB_Corridor"),objId,i));
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Point " << i << " : (" << MAP::Settings::getPoint(QLatin1String("RB_Corridor"),objId,i).x() << "," << MAP::Settings::getPoint(QLatin1String("RB_Corridor"),objId,i).y() << ")";
|
|
}
|
|
|
|
double corrWidth = (double)MAP::Settings::getObjectIntAttribute(QLatin1String("RB_Corridor"),QLatin1String("Width"), objId, 8000);
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Width: " << corrWidth;
|
|
|
|
QColor corrFillColor = (QColor(MAP::Settings::getObjectStringAttribute(QLatin1String("RB_Corridor"),QLatin1String("FillColor"), objId, QLatin1String("orange"))));
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Fill Color: " << corrFillColor.name();
|
|
|
|
rubberband->setCoordinateVectorWidth(vertexList, corrWidth);
|
|
rubberband->setCorridorFillColor(corrFillColor);
|
|
|
|
if (bound)
|
|
{
|
|
rubberband->setInputBoundary();
|
|
// rubberband->minimumPointCount( MAP::Settings::getObjectIntAttribute(QLatin1String("RB_Corridor"),QLatin1String("MinPointCount"), objId, 3) );
|
|
// rubberband->maximumPointCount( MAP::Settings::getObjectIntAttribute(QLatin1String("RB_Corridor"),QLatin1String("MaxPointCount"), objId, 8) );
|
|
// rubberband->minimumCorridorWidth( MAP::Settings::getObjectIntAttribute(QLatin1String("RB_Corridor"),QLatin1String("MinWidth"), objId, 5000) );
|
|
// rubberband->maximumCorridorWidth( MAP::Settings::getObjectIntAttribute(QLatin1String("RB_Corridor"),QLatin1String("MaxWidth"), objId, 10000) );
|
|
// rubberband->maximumLength( MAP::Settings::getObjectIntAttribute(QLatin1String("RB_Corridor"),QLatin1String("MaxLength"), objId, 10000) );
|
|
// rubberband->maximumSegmentLength( MAP::Settings::getObjectIntAttribute(QLatin1String("RB_Corridor"),QLatin1String("MaxSegmentLength"), objId, 50000) );
|
|
}
|
|
else
|
|
{
|
|
rubberband->setInputCenterline();
|
|
}
|
|
|
|
rubberband->draw();
|
|
|
|
QObject::connect( rubberband, &SituationMap::RB::Rubberband::apply, this, &MainWindow::onRubberbandCorridorApply);
|
|
QObject::connect( rubberband, &SituationMap::RB::Rubberband::abort, this, &MainWindow::onRubberbandAbort);
|
|
}
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::rubberbandCreateArrows()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
if (!m_map)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " No map object ";
|
|
return;
|
|
}
|
|
|
|
rubberbandCreateArrow(1, 4);
|
|
// TODO: more
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
void MainWindow::rubberbandCreateArrow(int objId, int noPoints)
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
if (!m_map)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " No map object ";
|
|
return;
|
|
}
|
|
|
|
SituationMap::RB::RubberbandArrow * rubberband = nullptr;
|
|
|
|
try
|
|
{
|
|
rubberband = m_map->rubberbandFactory().create<SituationMap::RB::RubberbandArrow>();
|
|
}
|
|
catch (SituationMap::Exception &e)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " " << e.getMessage();
|
|
}
|
|
|
|
if (rubberband == nullptr)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " Creating rubberband failed";
|
|
}
|
|
else
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " CREATE RUBBERBAND with values from ini file";
|
|
|
|
QVector<QPointF> vertexList;
|
|
|
|
vertexList.reserve(noPoints);
|
|
for (int i = 1; i <= noPoints; i++)
|
|
{
|
|
vertexList.append(MAP::Settings::getPoint(QLatin1String("RB_Arrow"),objId,i));
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Point " << i << " : (" << MAP::Settings::getPoint(QLatin1String("RB_Arrow"),objId,i).x() << "," << MAP::Settings::getPoint(QLatin1String("RB_Arrow"),objId,i).y() << ")";
|
|
}
|
|
|
|
rubberband->setCoordinateVector(vertexList);
|
|
|
|
QObject::connect( rubberband, &SituationMap::RB::Rubberband::apply, this, &MainWindow::onRubberbandArrowApply);
|
|
QObject::connect( rubberband, &SituationMap::RB::Rubberband::abort, this, &MainWindow::onRubberbandAbort);
|
|
}
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
void MainWindow::onRubberbandPointClusterApply( SituationMap::RB::RubberbandBase *rubberband)
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
SituationMap::RB::RubberbandPointCluster *initialRB = dynamic_cast<SituationMap::RB::RubberbandPointCluster*>(rubberband);
|
|
|
|
if(initialRB != nullptr)
|
|
{
|
|
bool mRbands = m_map->rubberbandFactory().allowMultipleRubberbands();
|
|
m_map->rubberbandFactory().allowMultipleRubberbands(true);
|
|
|
|
SituationMap::RB::RubberbandPointCluster *finalRB = m_map->rubberbandFactory().create<SituationMap::RB::RubberbandPointCluster>();
|
|
|
|
if (finalRB == nullptr)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " Creating final rubberband failed";
|
|
}
|
|
else
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Count of Coordinates " << initialRB->coordinateCount();
|
|
QVector<QPointF> vertexList = initialRB->coordinateVector();
|
|
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " INITIAL RUBBERBAND";
|
|
for (int i = 0; i < vertexList.size(); ++i)
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Point " << i << " : (" << vertexList.at(i).x() << "," << vertexList.at(i).y() << ")";
|
|
|
|
finalRB->setCoordinateVector(vertexList);
|
|
|
|
connect( finalRB, &SituationMap::RB::Rubberband::apply, this, &MainWindow::endRubberband);
|
|
connect( finalRB, &SituationMap::RB::Rubberband::abort, this, &MainWindow::endRubberband);
|
|
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " DELETING INITIAL RUBBERBAND";
|
|
initialRB->deleteMySelf();
|
|
}
|
|
|
|
m_map->rubberbandFactory().allowMultipleRubberbands(mRbands);
|
|
}
|
|
else
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " Converting initial rubberband failed";
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
void MainWindow::onRubberbandMultiPointApply( SituationMap::RB::RubberbandBase *rubberband)
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
SituationMap::RB::RubberbandMultiPointFeature *initialRB = dynamic_cast<SituationMap::RB::RubberbandMultiPointFeature*>(rubberband);
|
|
|
|
if (initialRB != nullptr)
|
|
{
|
|
bool mRbands = m_map->rubberbandFactory().allowMultipleRubberbands();
|
|
m_map->rubberbandFactory().allowMultipleRubberbands(true);
|
|
|
|
SituationMap::RB::RubberbandMultiPointFeature *finalRB = m_map->rubberbandFactory().create<SituationMap::RB::RubberbandMultiPointFeature>();
|
|
|
|
if (finalRB == nullptr)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " Creating final rubberband failed";
|
|
}
|
|
else
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Count of Coordinates " << initialRB->coordinateCount();
|
|
QVector<QPointF> vertexList = initialRB->coordinateVector();
|
|
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " INITIAL RUBBERBAND";
|
|
for (int i = 0; i < vertexList.size(); ++i)
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Point " << i << " : (" << vertexList.at(i).x() << "," << vertexList.at(i).y() << ")";
|
|
|
|
QColor rbDrawColor = initialRB->getDrawColor();
|
|
QColor rbFillColor = initialRB->getFillColor();
|
|
|
|
bool isClosed = initialRB->isClosedEnabled();
|
|
|
|
finalRB->setCoordinateVector(vertexList);
|
|
finalRB->setDrawColor(rbDrawColor);
|
|
|
|
if (isClosed)
|
|
{
|
|
finalRB->enableClosed(true);
|
|
finalRB->setFillColor(rbFillColor);
|
|
finalRB->maximumLength(initialRB->getMaximumLength());
|
|
finalRB->maximumSegmentLength(initialRB->getMaximumSegmentLength());
|
|
}
|
|
|
|
connect( finalRB, &SituationMap::RB::Rubberband::apply, this, &MainWindow::endRubberband);
|
|
connect( finalRB, &SituationMap::RB::Rubberband::abort, this, &MainWindow::endRubberband);
|
|
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " DELETING INITIAL RUBBERBAND";
|
|
initialRB->deleteMySelf();
|
|
}
|
|
|
|
m_map->rubberbandFactory().allowMultipleRubberbands(mRbands);
|
|
}
|
|
else
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " Converting initial rubberband failed";
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
void MainWindow::onRubberbandRectangleApply( SituationMap::RB::RubberbandBase *rubberband)
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
SituationMap::RB::RubberbandRectangle *initialRB = dynamic_cast<SituationMap::RB::RubberbandRectangle*>(rubberband);
|
|
|
|
if(initialRB != nullptr)
|
|
{
|
|
bool mRbands = m_map->rubberbandFactory().allowMultipleRubberbands();
|
|
m_map->rubberbandFactory().allowMultipleRubberbands(true);
|
|
|
|
SituationMap::RB::RubberbandRectangle *finalRB = m_map->rubberbandFactory().create<SituationMap::RB::RubberbandRectangle>();
|
|
|
|
if (finalRB == nullptr)
|
|
{
|
|
INFO_LOG(m_logger) << LOGFUNCTION << " Creating final rubberband failed";
|
|
}
|
|
else
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Count of Coordinates " << initialRB->coordinateCount();
|
|
QVector<QPointF> vertexList = initialRB->coordinateVector();
|
|
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " INITIAL RUBBERBAND";
|
|
for (int i = 0; i < vertexList.size(); ++i)
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Point " << i << " : (" << vertexList.at(i).x() << "," << vertexList.at(i).y() << ")";
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " VALID = " << initialRB->coordinatesAreValid();
|
|
|
|
QPointF simPoint = initialRB->singleCoordinate( 0, SituationMap::RB::CoordinateSystem::Geo );
|
|
QPointF mapPoint = initialRB->singleCoordinate( 0, SituationMap::RB::CoordinateSystem::Map );
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " Rectangle center : sim coordinate (" << simPoint.x() << "," << simPoint.y()
|
|
<< ") map coordinate (" << mapPoint.x() << "," << mapPoint.y() << ")";
|
|
|
|
bool constrains = initialRB->constrainQuadratic();
|
|
QColor rbDrawColor = initialRB->getDrawColor();
|
|
QColor rbFillColor = initialRB->getFillColor();
|
|
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " QUADRATIC = " << constrains;
|
|
|
|
finalRB->constrainQuadratic(constrains);
|
|
finalRB->setDrawColor(rbDrawColor);
|
|
finalRB->setFillColor(rbFillColor);
|
|
finalRB->setFrameHandleMargin(initialRB->getFrameHandleMargin());
|
|
finalRB->setCoordinateVector(vertexList);
|
|
|
|
connect( finalRB, &SituationMap::RB::Rubberband::apply, this, &MainWindow::endRubberband);
|
|
connect( finalRB, &SituationMap::RB::Rubberband::abort, this, &MainWindow::endRubberband);
|
|
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " DELETING INITIAL RUBBERBAND";
|
|
initialRB->deleteMySelf();
|
|
}
|
|
|
|
m_map->rubberbandFactory().allowMultipleRubberbands(mRbands);
|
|
}
|
|
else
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " Converting initial rubberband failed";
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
void MainWindow::onRubberbandEllipseApply( SituationMap::RB::RubberbandBase *rubberband)
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
SituationMap::RB::RubberbandEllipse *initialRB = dynamic_cast<SituationMap::RB::RubberbandEllipse*>(rubberband);
|
|
|
|
if(initialRB != nullptr)
|
|
{
|
|
bool mRbands = m_map->rubberbandFactory().allowMultipleRubberbands();
|
|
m_map->rubberbandFactory().allowMultipleRubberbands(true);
|
|
|
|
SituationMap::RB::RubberbandEllipse *finalRB = m_map->rubberbandFactory().create<SituationMap::RB::RubberbandEllipse>();
|
|
|
|
if (finalRB == nullptr)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " Creating final rubberband failed";
|
|
}
|
|
else
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Count of Coordinates " << initialRB->coordinateCount();
|
|
QVector<QPointF> vertexList = initialRB->coordinateVector();
|
|
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " INITIAL RUBBERBAND";
|
|
for (int i = 0; i < vertexList.size(); ++i)
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Point " << i << " : (" << vertexList.at(i).x() << "," << vertexList.at(i).y() << ")";
|
|
|
|
QPointF simPoint = initialRB->singleCoordinate( 0, SituationMap::RB::CoordinateSystem::Geo );
|
|
QPointF mapPoint = initialRB->singleCoordinate( 0, SituationMap::RB::CoordinateSystem::Map );
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Ellipse center : sim coordinate (" << simPoint.x() << "," << simPoint.y()
|
|
<< ") map coordinate (" << mapPoint.x() << "," << mapPoint.y() << ")";
|
|
|
|
bool constrains = initialRB->constrainQuadratic();
|
|
QColor rbDrawColor = initialRB->getDrawColor();
|
|
QColor rbFillColor = initialRB->getFillColor();
|
|
|
|
finalRB->constrainQuadratic(constrains);
|
|
finalRB->setCoordinateVector(vertexList);
|
|
finalRB->setDrawColor(rbDrawColor);
|
|
finalRB->setFillColor(rbFillColor);
|
|
finalRB->setFrameHandleMargin(initialRB->getFrameHandleMargin());
|
|
|
|
connect( finalRB, &SituationMap::RB::Rubberband::apply, this, &MainWindow::endRubberband);
|
|
connect( finalRB, &SituationMap::RB::Rubberband::abort, this, &MainWindow::endRubberband);
|
|
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " DELETING INITIAL RUBBERBAND";
|
|
initialRB->deleteMySelf();
|
|
}
|
|
|
|
m_map->rubberbandFactory().allowMultipleRubberbands(mRbands);
|
|
|
|
}
|
|
else
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " Converting initial rubberband failed";
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
void MainWindow::endRubberband( SituationMap::RB::RubberbandBase *rubberband)
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " FINAL RUBBERBAND";
|
|
|
|
QVector<QPointF> vertexList = rubberband->coordinateVector();
|
|
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Count of Coordinates " << rubberband->coordinateCount();
|
|
for (int i = 0; i < vertexList.size(); ++i)
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Point " << i << " : (" << vertexList.at(i).x() << "," << vertexList.at(i).y() << ")";
|
|
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Draw Color = " << rubberband->getDrawColor().name();
|
|
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Fill Color = " << rubberband->getFillColor().name();
|
|
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Frame margin = " << rubberband->getFrameHandleMargin();
|
|
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " DELETING FINAL RUBBERBAND";
|
|
rubberband->deleteMySelf();
|
|
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
void MainWindow::onRubberbandSmoothLineApply( SituationMap::RB::RubberbandBase *rubberband)
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
SituationMap::RB::RubberbandSmoothLine *initialRB = dynamic_cast<SituationMap::RB::RubberbandSmoothLine*>(rubberband);
|
|
|
|
if (initialRB != nullptr)
|
|
{
|
|
|
|
bool mRbands = m_map->rubberbandFactory().allowMultipleRubberbands();
|
|
m_map->rubberbandFactory().allowMultipleRubberbands(true);
|
|
|
|
SituationMap::RB::RubberbandSmoothLine *finalRB = m_map->rubberbandFactory().create<SituationMap::RB::RubberbandSmoothLine>();
|
|
|
|
if (finalRB == nullptr)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " Creating final rubberband failed";
|
|
}
|
|
else
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Count of Coordinates " << initialRB->coordinateCount();
|
|
QVector<QPointF> vertexList = initialRB->coordinateVector();
|
|
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " INITIAL RUBBERBAND";
|
|
for (int i = 0; i < vertexList.size(); ++i)
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Point " << i << " : (" << vertexList.at(i).x() << "," << vertexList.at(i).y() << ")";
|
|
|
|
QColor rbDrawColor = initialRB->getDrawColor();
|
|
QColor rbFillColor = initialRB->getFillColor();
|
|
bool isClosed = initialRB->isClosedEnabled();
|
|
|
|
finalRB->setDrawColor(rbDrawColor);
|
|
finalRB->setCoordinateVector(vertexList);
|
|
if (isClosed)
|
|
{
|
|
finalRB->enableClosed(true);
|
|
finalRB->setFillColor(rbFillColor);
|
|
}
|
|
|
|
connect( finalRB, &SituationMap::RB::Rubberband::apply, this, &MainWindow::endRubberband);
|
|
connect( finalRB, &SituationMap::RB::Rubberband::abort, this, &MainWindow::endRubberband);
|
|
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " DELETING INITIAL RUBBERBAND";
|
|
initialRB->deleteMySelf();
|
|
}
|
|
|
|
m_map->rubberbandFactory().allowMultipleRubberbands(mRbands);
|
|
}
|
|
else
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " Converting initial rubberband failed";
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
void MainWindow::onRubberbandArrowApply( SituationMap::RB::RubberbandBase *rubberband)
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
SituationMap::RB::RubberbandArrow* initialRB = dynamic_cast<SituationMap::RB::RubberbandArrow*>(rubberband);
|
|
|
|
if (initialRB != nullptr)
|
|
{
|
|
bool mRbands = m_map->rubberbandFactory().allowMultipleRubberbands();
|
|
m_map->rubberbandFactory().allowMultipleRubberbands(true);
|
|
|
|
SituationMap::RB::RubberbandArrow *finalRB = m_map->rubberbandFactory().create<SituationMap::RB::RubberbandArrow>();
|
|
|
|
if (finalRB == nullptr)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " Creating final rubberband failed";
|
|
}
|
|
else
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Count of Coordinates " << initialRB->coordinateCount();
|
|
QVector<QPointF> vertexList = initialRB->coordinateVector();
|
|
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " INITIAL RUBBERBAND";
|
|
for (int i = 0; i < vertexList.size(); ++i)
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Point " << i << " : (" << vertexList.at(i).x() << "," << vertexList.at(i).y() << ")";
|
|
|
|
finalRB->setCoordinateVector(vertexList);
|
|
finalRB->setCoordinateVectorArrow( vertexList, initialRB->arrowHalfWidth(), initialRB->arrowLength() );
|
|
|
|
connect( finalRB, &SituationMap::RB::Rubberband::apply, this, &MainWindow::endRubberband);
|
|
connect( finalRB, &SituationMap::RB::Rubberband::abort, this, &MainWindow::endRubberband);
|
|
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " DELETING INITIAL RUBBERBAND";
|
|
initialRB->deleteMySelf();
|
|
|
|
}
|
|
|
|
m_map->rubberbandFactory().allowMultipleRubberbands(mRbands);
|
|
}
|
|
else
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " Converting initial rubberband failed";
|
|
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
void MainWindow::onRubberbandCorridorApply( SituationMap::RB::RubberbandBase *rubberband)
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
SituationMap::RB::RubberbandCorridor *initialRB = dynamic_cast<SituationMap::RB::RubberbandCorridor*>(rubberband);
|
|
|
|
if (initialRB != nullptr)
|
|
{
|
|
bool mRbands = m_map->rubberbandFactory().allowMultipleRubberbands();
|
|
m_map->rubberbandFactory().allowMultipleRubberbands(true);
|
|
|
|
SituationMap::RB::RubberbandCorridor * finalRB = m_map->rubberbandFactory().create<SituationMap::RB::RubberbandCorridor>();
|
|
|
|
if (finalRB == nullptr)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " Creating final rubberband failed";
|
|
}
|
|
else
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Count of Coordinates " << initialRB->coordinateCount();
|
|
QVector<QPointF> vertexList = initialRB->coordinateVector();
|
|
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " INITIAL RUBBERBAND";
|
|
for (int i = 0; i < vertexList.size(); ++i)
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Point " << i << " : (" << vertexList.at(i).x() << "," << vertexList.at(i).y() << ")";
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Corridor width = " << initialRB->corridorWidth();
|
|
|
|
QColor rbDrawColor = initialRB->getCorridorBorderColor();
|
|
QColor rbFillColor = initialRB->getCorridorFillColor();
|
|
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Corridor Draw color = " << rbDrawColor.name();
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " Corridor Fill color = " << rbFillColor.name();
|
|
|
|
finalRB->setCorridorBorderColor(rbDrawColor);
|
|
finalRB->setCorridorFillColor(rbFillColor);
|
|
|
|
bool bound = initialRB->isEnabledInputBoundary();
|
|
if (bound)
|
|
{
|
|
finalRB->setInputBoundary();
|
|
finalRB->setCoordinateVectorWidth(vertexList, initialRB->corridorWidth());
|
|
}
|
|
else
|
|
{
|
|
finalRB->setInputCenterline();
|
|
finalRB->setCoordinateVectorWidth(vertexList, initialRB->corridorWidth());
|
|
}
|
|
|
|
connect(finalRB, &SituationMap::RB::Rubberband::apply, this, &MainWindow::endRubberband);
|
|
connect(finalRB, &SituationMap::RB::Rubberband::abort, this, &MainWindow::endRubberband);
|
|
}
|
|
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " DELETING INITIAL RUBBERBAND";
|
|
initialRB->deleteMySelf();
|
|
|
|
m_map->rubberbandFactory().allowMultipleRubberbands(mRbands);
|
|
}
|
|
else
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " Converting initial rubberband failed";
|
|
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|