Commit 40503810 authored by Bernhard Beschow's avatar Bernhard Beschow
Browse files

let visual categories only be defined for placemarks

Visual category should be a relation between styles and geometries.
parent 493ece18
......@@ -142,7 +142,7 @@ void BookmarkManager::addBookmark( GeoDataContainer *container, const GeoDataPla
}
if (d->m_styleBuilder && bookmark->style()->iconStyle().iconPath().isEmpty()) {
StyleParameters style;
style.feature = bookmark;
style.placemark = bookmark;
bookmark->setStyle(GeoDataStyle::Ptr(new GeoDataStyle(*d->m_styleBuilder->createStyle(style))));
}
d->m_treeModel->addFeature( container, bookmark );
......
......@@ -567,7 +567,7 @@ bool PlacemarkLayout::layoutPlacemark( const GeoDataPlacemark *placemark, qreal
// create a new one...
StyleParameters parameters;
// @todo: Set / adjust to tile level
parameters.feature = placemark;
parameters.placemark = placemark;
mark = new VisiblePlacemark(placemark, m_styleBuilder->createStyle(parameters));
m_visiblePlacemarks.insert( placemark, mark );
......
......@@ -499,10 +499,6 @@ void StyleBuilder::Private::initializeDefaultStyles()
= GeoDataStyle::Ptr(new GeoDataStyle( MarbleDirs::path( "bitmaps/unmanned_hard_landing.png" ),
QFont( defaultFamily, defaultSize, 50, false ), defaultLabelColor ));
m_defaultStyle[GeoDataFeature::Folder]
= GeoDataStyle::Ptr(new GeoDataStyle( MarbleDirs::path( "bitmaps/folder.png" ),
QFont( defaultFamily, defaultSize, 50, false ), defaultLabelColor ));
m_defaultStyle[GeoDataFeature::Bookmark]
= createPOIStyle(QFont( defaultFamily, defaultSize, 50, false ),
MarbleDirs::path("svg/bookmark.svg"), defaultLabelColor );
......@@ -1193,22 +1189,22 @@ void StyleBuilder::setDefaultLabelColor( const QColor& color )
GeoDataStyle::ConstPtr StyleBuilder::createStyle(const StyleParameters &parameters) const
{
if (!parameters.feature) {
if (!parameters.placemark) {
Q_ASSERT(false && "Must not pass a null feature to StyleBuilder::createStyle");
return GeoDataStyle::Ptr();
}
if (parameters.feature->customStyle()) {
return parameters.feature->customStyle();
if (parameters.placemark->customStyle()) {
return parameters.placemark->customStyle();
}
auto const visualCategory = parameters.feature->visualCategory();
auto const visualCategory = parameters.placemark->visualCategory();
GeoDataStyle::ConstPtr style = presetStyle(visualCategory);
if (parameters.feature->nodeType() != GeoDataTypes::GeoDataPlacemarkType) {
if (parameters.placemark->nodeType() != GeoDataTypes::GeoDataPlacemarkType) {
return style;
}
GeoDataPlacemark const * placemark = static_cast<GeoDataPlacemark const *>(parameters.feature);
GeoDataPlacemark const * placemark = static_cast<GeoDataPlacemark const *>(parameters.placemark);
OsmPlacemarkData const & osmData = placemark->osmData();
if (placemark->geometry()->nodeType() == GeoDataTypes::GeoDataPointType) {
if (visualCategory == GeoDataFeature::NaturalTree) {
......@@ -1644,7 +1640,6 @@ QString StyleBuilder::visualCategoryName(GeoDataFeature::GeoDataVisualCategory c
visualCategoryNames[GeoDataFeature::RoboticRover] = "RoboticRover";
visualCategoryNames[GeoDataFeature::UnmannedSoftLandingSite] = "UnmannedSoftLandingSite";
visualCategoryNames[GeoDataFeature::UnmannedHardLandingSite] = "UnmannedHardLandingSite";
visualCategoryNames[GeoDataFeature::Folder] = "Folder";
visualCategoryNames[GeoDataFeature::Bookmark] = "Bookmark";
visualCategoryNames[GeoDataFeature::NaturalWater] = "NaturalWater";
visualCategoryNames[GeoDataFeature::NaturalReef] = "NaturalReef";
......@@ -2055,8 +2050,8 @@ GeoDataFeature::GeoDataVisualCategory StyleBuilder::determineVisualCategory(cons
return GeoDataFeature::None;
}
StyleParameters::StyleParameters(const GeoDataFeature *feature_, int tileLevel_) :
feature(feature_),
StyleParameters::StyleParameters(const GeoDataPlacemark *placemark_, int tileLevel_) :
placemark(placemark_),
tileLevel(tileLevel_)
{
// nothing to do
......
......@@ -29,9 +29,9 @@ class OsmPlacemarkData;
class MARBLE_EXPORT StyleParameters
{
public:
explicit StyleParameters(const GeoDataFeature* feature=nullptr, int tileLevel=0);
explicit StyleParameters(const GeoDataPlacemark *placemark_ = nullptr, int tileLevel = 0);
const GeoDataFeature* feature;
const GeoDataPlacemark *placemark;
int tileLevel;
};
......
......@@ -129,7 +129,6 @@ class GEODATA_EXPORT GeoDataFeature : public GeoDataObject
UnmannedSoftLandingSite, // u
UnmannedHardLandingSite, // i
Folder,
Bookmark,
Satellite,
......@@ -582,16 +581,6 @@ class GEODATA_EXPORT GeoDataFeature : public GeoDataObject
*/
void setRegion( const GeoDataRegion& region );
/**
* Return the symbol index of the placemark.
*/
GeoDataVisualCategory visualCategory() const;
/**
* Sets the symbol @p index of the placemark.
* @param category the new category to be used.
*/
void setVisualCategory( GeoDataVisualCategory category );
/**
* Return the role of the placemark.
*
......@@ -640,11 +629,6 @@ class GEODATA_EXPORT GeoDataFeature : public GeoDataObject
*/
void setStyleMap( const GeoDataStyleMap* map );
/**
* @since 0.26.0
*/
QString categoryName() const;
/// Serialize the contents of the feature to @p stream.
virtual void pack( QDataStream& stream ) const;
/// Unserialize the contents of the feature from @p stream.
......
......@@ -137,7 +137,6 @@ public:
class GeoDataFeaturePrivate
{
Q_DECLARE_TR_FUNCTIONS(GeoDataFeature)
public:
GeoDataFeaturePrivate() :
m_name(),
......@@ -145,7 +144,6 @@ class GeoDataFeaturePrivate
m_popularity( 0 ),
m_zoomLevel( 1 ),
m_visible( true ),
m_visualCategory( GeoDataFeature::Default ),
m_role(" "),
m_style( 0 ),
m_styleMap( 0 ),
......@@ -161,7 +159,6 @@ class GeoDataFeaturePrivate
m_popularity( other.m_popularity ),
m_zoomLevel( other.m_zoomLevel ),
m_visible( other.m_visible ),
m_visualCategory( other.m_visualCategory ),
m_role( other.m_role ),
m_style( other.m_style ), //FIXME: both style and stylemap need to be reworked internally!!!!
m_styleMap( other.m_styleMap ),
......@@ -184,7 +181,6 @@ class GeoDataFeaturePrivate
m_role = other.m_role;
m_style = other.m_style;
m_styleMap = other.m_styleMap;
m_visualCategory = other.m_visualCategory;
m_extendedData = other.m_extendedData;
delete m_featureExtendedData;
m_featureExtendedData = nullptr;
......@@ -230,7 +226,6 @@ class GeoDataFeaturePrivate
int m_zoomLevel; // Zoom Level of the feature
bool m_visible; // True if this feature should be shown.
GeoDataFeature::GeoDataVisualCategory m_visualCategory; // the visual category
QString m_role;
......
......@@ -53,7 +53,6 @@ class GeoDataFolderPrivate : public GeoDataContainerPrivate
GeoDataFolder::GeoDataFolder()
: GeoDataContainer( new GeoDataFolderPrivate )
{
setVisualCategory( GeoDataFeature::Folder );
}
GeoDataFolder::GeoDataFolder( const GeoDataFolder& other )
......
......@@ -81,6 +81,17 @@ class GEODATA_EXPORT GeoDataPlacemark: public GeoDataFeature
bool operator==( const GeoDataPlacemark& other ) const;
bool operator!=( const GeoDataPlacemark& other ) const;
/**
* Return the symbol index of the placemark.
*/
GeoDataVisualCategory visualCategory() const;
/**
* Sets the symbol @p index of the placemark.
* @param category the new category to be used.
*/
void setVisualCategory(GeoDataVisualCategory category);
/**
* Return the coordinates of the placemark at time @p dateTime as a GeoDataCoordinates
*
......@@ -105,9 +116,14 @@ class GEODATA_EXPORT GeoDataPlacemark: public GeoDataFeature
const GeoDataGeometry* geometry() const;
/**
* @brief displays the name of a place in the locale language of the user
*/
QString displayName() const;
* @brief displays the name of a place in the locale language of the user
*/
QString displayName() const;
/**
* @since 0.26.0
*/
QString categoryName() const;
/**
* Return the coordinates of the placemark as @p longitude,
......
......@@ -58,11 +58,14 @@ public:
class GeoDataPlacemarkPrivate : public GeoDataFeaturePrivate
{
Q_DECLARE_TR_FUNCTIONS(GeoDataPlacemark)
public:
GeoDataPlacemarkPrivate()
: m_geometry( new GeoDataPoint ),
GeoDataPlacemarkPrivate() :
m_geometry(new GeoDataPoint),
m_population( -1 ),
m_placemarkExtendedData(nullptr)
m_placemarkExtendedData(nullptr),
m_visualCategory(GeoDataFeature::Default)
{
}
......@@ -80,6 +83,7 @@ class GeoDataPlacemarkPrivate : public GeoDataFeaturePrivate
GeoDataFeaturePrivate::operator=( other );
m_population = other.m_population;
m_visualCategory = other.m_visualCategory;
GeoDataGeometry * geometry = 0;
if ( other.m_geometry ) {
......@@ -159,6 +163,7 @@ class GeoDataPlacemarkPrivate : public GeoDataFeaturePrivate
GeoDataGeometry *m_geometry; // any GeoDataGeometry entry like locations
qint64 m_population; // population in number of inhabitants
GeoDataPlacemarkExtendedData *m_placemarkExtendedData;
GeoDataFeature::GeoDataVisualCategory m_visualCategory; // the visual category
static const OsmPlacemarkData s_nullOsmPlacemarkData;
static const GeoDataPlacemarkExtendedData s_nullPlacemarkExtendedData;
......
......@@ -12,6 +12,7 @@
#include "GeoGraphicsItem.h"
#include "GeoGraphicsItem_p.h"
#include "GeoDataTypes.h"
#include "GeoDataPlacemark.h"
// Qt
......@@ -86,8 +87,13 @@ GeoDataStyle::ConstPtr GeoGraphicsItem::style() const
}
if (!d->m_style) {
auto const styling = StyleParameters(d->m_feature, d->m_renderContext.tileLevel());
d->m_style = d->m_styleBuilder->createStyle(styling);
if (d->m_feature->nodeType() == GeoDataTypes::GeoDataPlacemarkType) {
const GeoDataPlacemark *placemark = static_cast<const GeoDataPlacemark*>(d->m_feature);
auto const styling = StyleParameters(placemark, d->m_renderContext.tileLevel());
d->m_style = d->m_styleBuilder->createStyle(styling);
} else {
d->m_style = d->m_feature->style();
}
}
return d->m_style;
......
......@@ -441,8 +441,13 @@ QVector<const GeoDataFeature *> GeometryLayer::whichBuildingAt(const QPoint &cur
const int maxZoom = qMin<int>(qMax<int>(qLn(viewport->radius()*4/256)/qLn(2.0), 1), d->m_styleBuilder->maximumZoomLevel());
foreach ( GeoGraphicsItem * item, d->m_scene.items( viewport->viewLatLonAltBox(), maxZoom ) ) {
if (item->feature()->visualCategory() == GeoDataFeature::Building && item->feature()->nodeType() == GeoDataTypes::GeoDataPlacemarkType ) {
if (item->feature()->nodeType() == GeoDataTypes::GeoDataPlacemarkType) {
const GeoDataPlacemark* placemark = static_cast<const GeoDataPlacemark*>(item->feature());
if (placemark->visualCategory() != GeoDataFeature::Building) {
continue;
}
if (placemark->geometry()->nodeType() == GeoDataTypes::GeoDataPolygonType) {
const GeoDataPolygon *polygon = static_cast<const GeoDataPolygon*>(placemark->geometry());
if (polygon->contains(coordinates)) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment