223 lines
6.5 KiB
C++
Executable File
223 lines
6.5 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* Settings for sitMapTestApp
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
*/
|
|
#include "nglsettings.h"
|
|
#include <QtCore/QSettings>
|
|
#include <QPointF>
|
|
#include <nglsettings/nglsettings_settings.h>
|
|
#include <NGLLogger/INGLLogger.h>
|
|
#include <NGLLogger/NGLLoggerBootstrap.h>
|
|
|
|
using namespace NGL;
|
|
|
|
//-----------------------------------------------------------------------------------------
|
|
namespace MAP
|
|
{
|
|
class NGLSettingsClass : public NGL::Settings
|
|
{
|
|
public:
|
|
NGLSettingsClass();
|
|
~NGLSettingsClass() {}
|
|
};
|
|
|
|
Q_GLOBAL_STATIC ( NGLSettingsClass, s )
|
|
|
|
NGLSettingsClass::NGLSettingsClass()
|
|
: NGL::Settings(QLatin1String("mapsettings.ini"))
|
|
{
|
|
}
|
|
|
|
NGL::Settings *Settings::settings()
|
|
{
|
|
qDebug("%s", s()->settings()->fileName().toStdString().c_str());
|
|
return s();
|
|
}
|
|
|
|
//----------------------------------------
|
|
QString Settings::basePoint()
|
|
{
|
|
return s()->getString(QLatin1String("Map/BasePoint"), QLatin1String("32UMD000000000000"));
|
|
}
|
|
|
|
/*
|
|
//-----------------------------------------------------------------------------------------
|
|
double Settings::mapBasePointX()
|
|
{
|
|
return s()->getDouble(QLatin1String("Map/BasePoint_X"), 0.0);
|
|
}
|
|
|
|
//----------------------------------------
|
|
QString Settings::centerPointMgrs()
|
|
{
|
|
return s()->getString(QLatin1String("Map/Center"), QLatin1String("32UMD8000085000"));
|
|
}
|
|
|
|
double Settings::mapCenterPointX()
|
|
{
|
|
return s()->getDouble(QLatin1String("Map/CenterPoint_X"), 0.0);
|
|
}
|
|
|
|
double Settings::mapCenterPointY()
|
|
{
|
|
return s()->getDouble(QLatin1String("Map/CenterPoint_Y"), 0.0);
|
|
}
|
|
|
|
double Settings::mapBasePointY()
|
|
{
|
|
return s()->getDouble(QLatin1String("Map/BasePoint_Y"), 0.0);
|
|
}
|
|
*/
|
|
|
|
int Settings::mapWkid()
|
|
{
|
|
return s()->getInteger(QLatin1String("Map/Wkid"), 32632);
|
|
}
|
|
|
|
double Settings::mapObjectsTextScale()
|
|
{
|
|
return s()->getDouble(QLatin1String("MapObjects/TextScale"), 1.0);
|
|
}
|
|
|
|
double Settings::mapScale()
|
|
{
|
|
return s()->getDouble(QLatin1String("Map/Scale"), 100000.0);
|
|
}
|
|
|
|
double Settings::mapRotationDegree()
|
|
{
|
|
return s()->getDouble(QLatin1String("Map/RotationDegree"), 0.0);
|
|
}
|
|
/*
|
|
int Settings::XMin()
|
|
{
|
|
return s()->getInteger(QLatin1String("Map/XMin"), 0);
|
|
}
|
|
|
|
int Settings::YMin()
|
|
{
|
|
return s()->getInteger(QLatin1String("Map/YMin"), 0);
|
|
}
|
|
|
|
int Settings::XMax()
|
|
{
|
|
return s()->getInteger(QLatin1String("Map/XMax"), 0);
|
|
}
|
|
|
|
int Settings::YMax()
|
|
{
|
|
return s()->getInteger(QLatin1String("Map/YMax"), 0);
|
|
}
|
|
*/
|
|
bool Settings::mapGridVisible()
|
|
{
|
|
return s()->getBoolean(QLatin1String("Map/GridVisible"), false);
|
|
}
|
|
|
|
bool Settings::mapFunctionDialogVisible()
|
|
{
|
|
return s()->getBoolean(QLatin1String("Map/FunctionDialogVisible"), false);
|
|
}
|
|
|
|
QString Settings::mapSymbologyType()
|
|
{
|
|
return s()->getString(QLatin1String("Map/SymbologyType"), QLatin1String("APP6B") );
|
|
}
|
|
|
|
QString Settings::mapGridType()
|
|
{
|
|
return s()->getString(QLatin1String("Map/GridType"), QLatin1String("MGRS") );
|
|
}
|
|
|
|
QString Settings::mapURL()
|
|
{
|
|
return s()->getString(QLatin1String("Map/URL"), QString() );
|
|
}
|
|
|
|
// conversion functions
|
|
//-------------------------------------------------------------------------------------
|
|
SituationMap::LinePattern Settings::getLinePattern(const QString &pattern)
|
|
{
|
|
SituationMap::LinePattern linePattern = SituationMap::LinePattern::Null;
|
|
if (pattern.compare(QLatin1String("Dash")) == 0)
|
|
linePattern = SituationMap::LinePattern::Dash;
|
|
if (pattern.compare(QLatin1String("DashDot")) == 0)
|
|
linePattern = SituationMap::LinePattern::DashDot;
|
|
if (pattern.compare(QLatin1String("DashDotDot")) == 0)
|
|
linePattern = SituationMap::LinePattern::DashDotDot;
|
|
if (pattern.compare(QLatin1String("Dot")) == 0)
|
|
linePattern = SituationMap::LinePattern::Dot;
|
|
if (pattern.compare(QLatin1String("Solid")) == 0)
|
|
linePattern = SituationMap::LinePattern::Solid;
|
|
return linePattern;
|
|
}
|
|
|
|
SituationMap::FillPattern Settings::getFillPattern(const QString &pattern)
|
|
{
|
|
SituationMap::FillPattern fillPattern = SituationMap::FillPattern::Null;
|
|
if (pattern.compare(QLatin1String("BackwardDiagonal")) == 0)
|
|
fillPattern = SituationMap::FillPattern::BackwardDiagonal;
|
|
if (pattern.compare(QLatin1String("Cross")) == 0)
|
|
fillPattern = SituationMap::FillPattern::Cross;
|
|
if (pattern.compare(QLatin1String("DiagonalCross")) == 0)
|
|
fillPattern = SituationMap::FillPattern::DiagonalCross;
|
|
if (pattern.compare(QLatin1String("ForwardDiagonal")) == 0)
|
|
fillPattern = SituationMap::FillPattern::ForwardDiagonal;
|
|
if (pattern.compare(QLatin1String("Solid")) == 0)
|
|
fillPattern = SituationMap::FillPattern::Solid;
|
|
if (pattern.compare(QLatin1String("Horizontal")) == 0)
|
|
fillPattern = SituationMap::FillPattern::Horizontal;
|
|
if (pattern.compare(QLatin1String("Vertical")) == 0)
|
|
fillPattern = SituationMap::FillPattern::Vertical;
|
|
return fillPattern;
|
|
}
|
|
|
|
SituationMap::GridType Settings::getGridType(const QString &pattern)
|
|
{
|
|
SituationMap::GridType gridType = SituationMap::GridType::MGRS;
|
|
if (pattern.compare(QLatin1String("MGRS")) == 0)
|
|
gridType = SituationMap::GridType::MGRS;
|
|
if (pattern.compare(QLatin1String("UTM")) == 0)
|
|
gridType = SituationMap::GridType::UTM;
|
|
if (pattern.compare(QLatin1String("USGN")) == 0)
|
|
gridType = SituationMap::GridType::USGN;
|
|
return gridType;
|
|
}
|
|
|
|
//map objects general functions
|
|
//-----------------------------------------------------------------------------------------
|
|
QString Settings::objectIdentifier(const QString &prefix, int id)
|
|
{
|
|
return s()->getString(prefix+QLatin1String("_")+QString::number(id)+QLatin1String("/Identifier"), prefix+QLatin1String("_")+QString::number(id));
|
|
}
|
|
|
|
bool Settings::getObjectBoolAttribute(const QString &prefix, const QString &postfix, int objId, bool defaultValue)
|
|
{
|
|
return s()->getBoolean(prefix+QLatin1String("_")+QString::number(objId)+QLatin1String("/")+postfix, defaultValue);
|
|
}
|
|
|
|
int Settings::getObjectIntAttribute(const QString &prefix, const QString &postfix, int objId, int defaultValue)
|
|
{
|
|
return s()->getInteger(prefix+QLatin1String("_")+QString::number(objId)+QLatin1String("/")+postfix, defaultValue);
|
|
}
|
|
|
|
QString Settings::getObjectStringAttribute(const QString &prefix, const QString &postfix, int objId, const QString &defaultValue)
|
|
{
|
|
return s()->getString(prefix+QLatin1String("_")+QString::number(objId)+QLatin1String("/")+postfix, defaultValue);
|
|
}
|
|
|
|
QPointF Settings::getPoint(const QString &prefix, int objId, int nr )
|
|
{
|
|
QString strPoint = s()->getString(prefix+QLatin1String("_")+QString::number(objId)+QLatin1String("/P")+QString::number(nr), QLatin1String("0,0"));
|
|
double point_x, point_y;
|
|
QStringList list = strPoint.split(QLatin1Char(','));
|
|
point_x = list[0].toDouble();
|
|
point_y = list[1].toDouble();
|
|
return QPointF(point_x,point_y);
|
|
}
|
|
|
|
} //namespace
|