Commit ae7ac56e authored by Dennis Nienhüser's avatar Dennis Nienhüser
Browse files

More flexible rendering order in GeometryLayer/GeoGraphicsScene

The Vector OSM map theme has some rendering order problems right now
that result in some item combinations to look odd. This patch provides
a more fine-granular control of the rendering order. It also refactors
the decorators previously used and merges them into that approach.

Extend paint() of GeographicsItem to take another argument, a string
layer
Each GeographicsItem specifies a list of such layers it wants to paint
GeometryLayer defines the order of layers and paints them that way
E.g. currently a highway behaves like this:

GeoLineStringItem is created, and internally creates a copy of itself
which is its decorator, assigns a z-value
GeometryLayer queries all decorators during paint, sorts them by z-value
GeoLineStringItem tests whether it is a decorator during painting,
changes rendering based on that
The patch changes this to

GeoLineStringItem is created and asks for three layers to be rendered:
.../outline, .../inline and .../label
GeometryLayer queries all layers during paint, sorts them by render
order
GeoLineStringItem changes rendering based on the provided layer name
This avoids having to treat decorators as special and duplicated items
internally, and also allows an important render order behavior change:
It is now possible to render e.g. all visible streets first and all
their labels afterwards. Previously it was only possible to render one
street after the other, so e.g. the second street could overpaint the
label of the first.

Projects: #marble

Differential Revision: https://phabricator.kde.org/D1181
parent 5ddef264
......@@ -16,6 +16,7 @@
#include <QDataStream>
#include <QSize>
#include <QPixmap>
#include <QHash>
#include "MarbleDirs.h"
#include "MarbleDebug.h"
......@@ -675,6 +676,282 @@ QSharedPointer<GeoDataStyle> GeoDataFeature::presetStyle( GeoDataVisualCategory
return GeoDataFeaturePrivate::s_defaultStyle[ category ];
}
QString GeoDataFeature::visualCategoryName(GeoDataFeature::GeoDataVisualCategory category)
{
static QHash<GeoDataFeature::GeoDataVisualCategory, QString> s_visualCategoryNames;
if (s_visualCategoryNames.isEmpty()) {
s_visualCategoryNames[None] = "None";
s_visualCategoryNames[Default] = "Default";
s_visualCategoryNames[Unknown] = "Unknown";
s_visualCategoryNames[SmallCity] = "SmallCity";
s_visualCategoryNames[SmallCountyCapital] = "SmallCountyCapital";
s_visualCategoryNames[SmallStateCapital] = "SmallStateCapital";
s_visualCategoryNames[SmallNationCapital] = "SmallNationCapital";
s_visualCategoryNames[MediumCity] = "MediumCity";
s_visualCategoryNames[MediumCountyCapital] = "MediumCountyCapital";
s_visualCategoryNames[MediumStateCapital] = "MediumStateCapital";
s_visualCategoryNames[MediumNationCapital] = "MediumNationCapital";
s_visualCategoryNames[BigCity] = "BigCity";
s_visualCategoryNames[BigCountyCapital] = "BigCountyCapital";
s_visualCategoryNames[BigStateCapital] = "BigStateCapital";
s_visualCategoryNames[BigNationCapital] = "BigNationCapital";
s_visualCategoryNames[LargeCity] = "LargeCity";
s_visualCategoryNames[LargeCountyCapital] = "LargeCountyCapital";
s_visualCategoryNames[LargeStateCapital] = "LargeStateCapital";
s_visualCategoryNames[LargeNationCapital] = "LargeNationCapital";
s_visualCategoryNames[Nation] = "Nation";
s_visualCategoryNames[PlaceCity] = "PlaceCity";
s_visualCategoryNames[PlaceSuburb] = "PlaceSuburb";
s_visualCategoryNames[PlaceHamlet] = "PlaceHamlet";
s_visualCategoryNames[PlaceLocality] = "PlaceLocality";
s_visualCategoryNames[PlaceTown] = "PlaceTown";
s_visualCategoryNames[PlaceVillage] = "PlaceVillage";
s_visualCategoryNames[Mountain] = "Mountain";
s_visualCategoryNames[Volcano] = "Volcano";
s_visualCategoryNames[Mons] = "Mons";
s_visualCategoryNames[Valley] = "Valley";
s_visualCategoryNames[Continent] = "Continent";
s_visualCategoryNames[Ocean] = "Ocean";
s_visualCategoryNames[OtherTerrain] = "OtherTerrain";
s_visualCategoryNames[Crater] = "Crater";
s_visualCategoryNames[Mare] = "Mare";
s_visualCategoryNames[GeographicPole] = "GeographicPole";
s_visualCategoryNames[MagneticPole] = "MagneticPole";
s_visualCategoryNames[ShipWreck] = "ShipWreck";
s_visualCategoryNames[AirPort] = "AirPort";
s_visualCategoryNames[Observatory] = "Observatory";
s_visualCategoryNames[MilitaryDangerArea] = "MilitaryDangerArea";
s_visualCategoryNames[Wikipedia] = "Wikipedia";
s_visualCategoryNames[OsmSite] = "OsmSite";
s_visualCategoryNames[Coordinate] = "Coordinate";
s_visualCategoryNames[MannedLandingSite] = "MannedLandingSite";
s_visualCategoryNames[RoboticRover] = "RoboticRover";
s_visualCategoryNames[UnmannedSoftLandingSite] = "UnmannedSoftLandingSite";
s_visualCategoryNames[UnmannedHardLandingSite] = "UnmannedHardLandingSite";
s_visualCategoryNames[Folder] = "Folder";
s_visualCategoryNames[Bookmark] = "Bookmark";
s_visualCategoryNames[NaturalWater] = "NaturalWater";
s_visualCategoryNames[NaturalWood] = "NaturalWood";
s_visualCategoryNames[NaturalBeach] = "NaturalBeach";
s_visualCategoryNames[NaturalWetland] = "NaturalWetland";
s_visualCategoryNames[NaturalGlacier] = "NaturalGlacier";
s_visualCategoryNames[NaturalScrub] = "NaturalScrub";
s_visualCategoryNames[NaturalCliff] = "NaturalCliff";
s_visualCategoryNames[NaturalHeath] = "NaturalHeath";
s_visualCategoryNames[HighwayTrafficSignals] = "HighwayTrafficSignals";
s_visualCategoryNames[HighwaySteps] = "HighwaySteps";
s_visualCategoryNames[HighwayUnknown] = "HighwayUnknown";
s_visualCategoryNames[HighwayPath] = "HighwayPath";
s_visualCategoryNames[HighwayFootway] = "HighwayFootway";
s_visualCategoryNames[HighwayTrack] = "HighwayTrack";
s_visualCategoryNames[HighwayPedestrian] = "HighwayPedestrian";
s_visualCategoryNames[HighwayCycleway] = "HighwayCycleway";
s_visualCategoryNames[HighwayService] = "HighwayService";
s_visualCategoryNames[HighwayRoad] = "HighwayRoad";
s_visualCategoryNames[HighwayResidential] = "HighwayResidential";
s_visualCategoryNames[HighwayLivingStreet] = "HighwayLivingStreet";
s_visualCategoryNames[HighwayUnclassified] = "HighwayUnclassified";
s_visualCategoryNames[HighwayTertiaryLink] = "HighwayTertiaryLink";
s_visualCategoryNames[HighwayTertiary] = "HighwayTertiary";
s_visualCategoryNames[HighwaySecondaryLink] = "HighwaySecondaryLink";
s_visualCategoryNames[HighwaySecondary] = "HighwaySecondary";
s_visualCategoryNames[HighwayPrimaryLink] = "HighwayPrimaryLink";
s_visualCategoryNames[HighwayPrimary] = "HighwayPrimary";
s_visualCategoryNames[HighwayTrunkLink] = "HighwayTrunkLink";
s_visualCategoryNames[HighwayTrunk] = "HighwayTrunk";
s_visualCategoryNames[HighwayMotorwayLink] = "HighwayMotorwayLink";
s_visualCategoryNames[HighwayMotorway] = "HighwayMotorway";
s_visualCategoryNames[Building] = "Building";
s_visualCategoryNames[AccomodationCamping] = "AccomodationCamping";
s_visualCategoryNames[AccomodationHostel] = "AccomodationHostel";
s_visualCategoryNames[AccomodationHotel] = "AccomodationHotel";
s_visualCategoryNames[AccomodationMotel] = "AccomodationMotel";
s_visualCategoryNames[AccomodationYouthHostel] = "AccomodationYouthHostel";
s_visualCategoryNames[AccomodationGuestHouse] = "AccomodationGuestHouse";
s_visualCategoryNames[AmenityLibrary] = "AmenityLibrary";
s_visualCategoryNames[EducationCollege] = "EducationCollege";
s_visualCategoryNames[EducationSchool] = "EducationSchool";
s_visualCategoryNames[EducationUniversity] = "EducationUniversity";
s_visualCategoryNames[FoodBar] = "FoodBar";
s_visualCategoryNames[FoodBiergarten] = "FoodBiergarten";
s_visualCategoryNames[FoodCafe] = "FoodCafe";
s_visualCategoryNames[FoodFastFood] = "FoodFastFood";
s_visualCategoryNames[FoodPub] = "FoodPub";
s_visualCategoryNames[FoodRestaurant] = "FoodRestaurant";
s_visualCategoryNames[HealthDentist] = "HealthDentist";
s_visualCategoryNames[HealthDoctors] = "HealthDoctors";
s_visualCategoryNames[HealthHospital] = "HealthHospital";
s_visualCategoryNames[HealthPharmacy] = "HealthPharmacy";
s_visualCategoryNames[HealthVeterinary] = "HealthVeterinary";
s_visualCategoryNames[MoneyAtm] = "MoneyAtm";
s_visualCategoryNames[MoneyBank] = "MoneyBank";
s_visualCategoryNames[AmenityArchaeologicalSite] = "AmenityArchaeologicalSite";
s_visualCategoryNames[AmenityEmbassy] = "AmenityEmbassy";
s_visualCategoryNames[AmenityEmergencyPhone] = "AmenityEmergencyPhone";
s_visualCategoryNames[AmenityWaterPark] = "AmenityWaterPark";
s_visualCategoryNames[AmenityCommunityCentre] = "AmenityCommunityCentre";
s_visualCategoryNames[AmenityFountain] = "AmenityFountain";
s_visualCategoryNames[AmenityNightClub] = "AmenityNightClub";
s_visualCategoryNames[AmenityBench] = "AmenityBench";
s_visualCategoryNames[AmenityCourtHouse] = "AmenityCourtHouse";
s_visualCategoryNames[AmenityFireStation] = "AmenityFireStation";
s_visualCategoryNames[AmenityHuntingStand] = "AmenityHuntingStand";
s_visualCategoryNames[AmenityPolice] = "AmenityPolice";
s_visualCategoryNames[AmenityPostBox] = "AmenityPostBox";
s_visualCategoryNames[AmenityPostOffice] = "AmenityPostOffice";
s_visualCategoryNames[AmenityPrison] = "AmenityPrison";
s_visualCategoryNames[AmenityRecycling] = "AmenityRecycling";
s_visualCategoryNames[AmenityTelephone] = "AmenityTelephone";
s_visualCategoryNames[AmenityToilets] = "AmenityToilets";
s_visualCategoryNames[AmenityTownHall] = "AmenityTownHall";
s_visualCategoryNames[AmenityWasteBasket] = "AmenityWasteBasket";
s_visualCategoryNames[AmenityDrinkingWater] = "AmenityDrinkingWater";
s_visualCategoryNames[AmenityGraveyard] = "AmenityGraveyard";
s_visualCategoryNames[BarrierCityWall] = "BarrierCityWall";
s_visualCategoryNames[BarrierGate] = "BarrierGate";
s_visualCategoryNames[BarrierLiftGate] = "BarrierLiftGate";
s_visualCategoryNames[BarrierWall] = "BarrierWall";
s_visualCategoryNames[NaturalPeak] = "NaturalPeak";
s_visualCategoryNames[NaturalTree] = "NaturalTree";
s_visualCategoryNames[ShopBeverages] = "ShopBeverages";
s_visualCategoryNames[ShopHifi] = "ShopHifi";
s_visualCategoryNames[ShopSupermarket] = "ShopSupermarket";
s_visualCategoryNames[ShopAlcohol] = "ShopAlcohol";
s_visualCategoryNames[ShopBakery] = "ShopBakery";
s_visualCategoryNames[ShopButcher] = "ShopButcher";
s_visualCategoryNames[ShopConfectionery] = "ShopConfectionery";
s_visualCategoryNames[ShopConvenience] = "ShopConvenience";
s_visualCategoryNames[ShopGreengrocer] = "ShopGreengrocer";
s_visualCategoryNames[ShopSeafood] = "ShopSeafood";
s_visualCategoryNames[ShopDepartmentStore] = "ShopDepartmentStore";
s_visualCategoryNames[ShopKiosk] = "ShopKiosk";
s_visualCategoryNames[ShopBag] = "ShopBag";
s_visualCategoryNames[ShopClothes] = "ShopClothes";
s_visualCategoryNames[ShopFashion] = "ShopFashion";
s_visualCategoryNames[ShopJewelry] = "ShopJewelry";
s_visualCategoryNames[ShopShoes] = "ShopShoes";
s_visualCategoryNames[ShopVarietyStore] = "ShopVarietyStore";
s_visualCategoryNames[ShopBeauty] = "ShopBeauty";
s_visualCategoryNames[ShopChemist] = "ShopChemist";
s_visualCategoryNames[ShopCosmetics] = "ShopCosmetics";
s_visualCategoryNames[ShopHairdresser] = "ShopHairdresser";
s_visualCategoryNames[ShopOptician] = "ShopOptician";
s_visualCategoryNames[ShopPerfumery] = "ShopPerfumery";
s_visualCategoryNames[ShopDoitYourself] = "ShopDoitYourself";
s_visualCategoryNames[ShopFlorist] = "ShopFlorist";
s_visualCategoryNames[ShopHardware] = "ShopHardware";
s_visualCategoryNames[ShopFurniture] = "ShopFurniture";
s_visualCategoryNames[ShopElectronics] = "ShopElectronics";
s_visualCategoryNames[ShopMobilePhone] = "ShopMobilePhone";
s_visualCategoryNames[ShopBicycle] = "ShopBicycle";
s_visualCategoryNames[ShopCar] = "ShopCar";
s_visualCategoryNames[ShopCarRepair] = "ShopCarRepair";
s_visualCategoryNames[ShopCarParts] = "ShopCarParts";
s_visualCategoryNames[ShopMotorcycle] = "ShopMotorcycle";
s_visualCategoryNames[ShopOutdoor] = "ShopOutdoor";
s_visualCategoryNames[ShopMusicalInstrument] = "ShopMusicalInstrument";
s_visualCategoryNames[ShopPhoto] = "ShopPhoto";
s_visualCategoryNames[ShopBook] = "ShopBook";
s_visualCategoryNames[ShopGift] = "ShopGift";
s_visualCategoryNames[ShopStationery] = "ShopStationery";
s_visualCategoryNames[ShopLaundry] = "ShopLaundry";
s_visualCategoryNames[ShopPet] = "ShopPet";
s_visualCategoryNames[ShopToys] = "ShopToys";
s_visualCategoryNames[ShopTravelAgency] = "ShopTravelAgency";
s_visualCategoryNames[Shop] = "Shop";
s_visualCategoryNames[ManmadeBridge] = "ManmadeBridge";
s_visualCategoryNames[ManmadeLighthouse] = "ManmadeLighthouse";
s_visualCategoryNames[ManmadePier] = "ManmadePier";
s_visualCategoryNames[ManmadeWaterTower] = "ManmadeWaterTower";
s_visualCategoryNames[ManmadeWindMill] = "ManmadeWindMill";
s_visualCategoryNames[TouristAttraction] = "TouristAttraction";
s_visualCategoryNames[TouristCastle] = "TouristCastle";
s_visualCategoryNames[TouristCinema] = "TouristCinema";
s_visualCategoryNames[TouristInformation] = "TouristInformation";
s_visualCategoryNames[TouristMonument] = "TouristMonument";
s_visualCategoryNames[TouristMuseum] = "TouristMuseum";
s_visualCategoryNames[TouristRuin] = "TouristRuin";
s_visualCategoryNames[TouristTheatre] = "TouristTheatre";
s_visualCategoryNames[TouristThemePark] = "TouristThemePark";
s_visualCategoryNames[TouristViewPoint] = "TouristViewPoint";
s_visualCategoryNames[TouristZoo] = "TouristZoo";
s_visualCategoryNames[TouristAlpineHut] = "TouristAlpineHut";
s_visualCategoryNames[TransportAerodrome] = "TransportAerodrome";
s_visualCategoryNames[TransportHelipad] = "TransportHelipad";
s_visualCategoryNames[TransportAirportTerminal] = "TransportAirportTerminal";
s_visualCategoryNames[TransportBusStation] = "TransportBusStation";
s_visualCategoryNames[TransportBusStop] = "TransportBusStop";
s_visualCategoryNames[TransportCarShare] = "TransportCarShare";
s_visualCategoryNames[TransportFuel] = "TransportFuel";
s_visualCategoryNames[TransportParking] = "TransportParking";
s_visualCategoryNames[TransportParkingSpace] = "TransportParkingSpace";
s_visualCategoryNames[TransportPlatform] = "TransportPlatform";
s_visualCategoryNames[TransportRentalBicycle] = "TransportRentalBicycle";
s_visualCategoryNames[TransportRentalCar] = "TransportRentalCar";
s_visualCategoryNames[TransportTaxiRank] = "TransportTaxiRank";
s_visualCategoryNames[TransportTrainStation] = "TransportTrainStation";
s_visualCategoryNames[TransportTramStop] = "TransportTramStop";
s_visualCategoryNames[TransportBicycleParking] = "TransportBicycleParking";
s_visualCategoryNames[TransportMotorcycleParking] = "TransportMotorcycleParking";
s_visualCategoryNames[TransportSubwayEntrance] = "TransportSubwayEntrance";
s_visualCategoryNames[ReligionPlaceOfWorship] = "ReligionPlaceOfWorship";
s_visualCategoryNames[ReligionBahai] = "ReligionBahai";
s_visualCategoryNames[ReligionBuddhist] = "ReligionBuddhist";
s_visualCategoryNames[ReligionChristian] = "ReligionChristian";
s_visualCategoryNames[ReligionMuslim] = "ReligionMuslim";
s_visualCategoryNames[ReligionHindu] = "ReligionHindu";
s_visualCategoryNames[ReligionJain] = "ReligionJain";
s_visualCategoryNames[ReligionJewish] = "ReligionJewish";
s_visualCategoryNames[ReligionShinto] = "ReligionShinto";
s_visualCategoryNames[ReligionSikh] = "ReligionSikh";
s_visualCategoryNames[LeisureGolfCourse] = "LeisureGolfCourse";
s_visualCategoryNames[LeisurePark] = "LeisurePark";
s_visualCategoryNames[LeisurePlayground] = "LeisurePlayground";
s_visualCategoryNames[LeisurePitch] = "LeisurePitch";
s_visualCategoryNames[LeisureSportsCentre] = "LeisureSportsCentre";
s_visualCategoryNames[LeisureStadium] = "LeisureStadium";
s_visualCategoryNames[LeisureTrack] = "LeisureTrack";
s_visualCategoryNames[LeisureSwimmingPool] = "LeisureSwimmingPool";
s_visualCategoryNames[LanduseAllotments] = "LanduseAllotments";
s_visualCategoryNames[LanduseBasin] = "LanduseBasin";
s_visualCategoryNames[LanduseCemetery] = "LanduseCemetery";
s_visualCategoryNames[LanduseCommercial] = "LanduseCommercial";
s_visualCategoryNames[LanduseConstruction] = "LanduseConstruction";
s_visualCategoryNames[LanduseFarmland] = "LanduseFarmland";
s_visualCategoryNames[LanduseFarmyard] = "LanduseFarmyard";
s_visualCategoryNames[LanduseGarages] = "LanduseGarages";
s_visualCategoryNames[LanduseGrass] = "LanduseGrass";
s_visualCategoryNames[LanduseIndustrial] = "LanduseIndustrial";
s_visualCategoryNames[LanduseLandfill] = "LanduseLandfill";
s_visualCategoryNames[LanduseMeadow] = "LanduseMeadow";
s_visualCategoryNames[LanduseMilitary] = "LanduseMilitary";
s_visualCategoryNames[LanduseQuarry] = "LanduseQuarry";
s_visualCategoryNames[LanduseRailway] = "LanduseRailway";
s_visualCategoryNames[LanduseReservoir] = "LanduseReservoir";
s_visualCategoryNames[LanduseResidential] = "LanduseResidential";
s_visualCategoryNames[LanduseRetail] = "LanduseRetail";
s_visualCategoryNames[LanduseOrchard] = "LanduseOrchard";
s_visualCategoryNames[LanduseVineyard] = "LanduseVineyard";
s_visualCategoryNames[RailwayRail] = "RailwayRail";
s_visualCategoryNames[RailwayNarrowGauge] = "RailwayNarrowGauge";
s_visualCategoryNames[RailwayTram] = "RailwayTram";
s_visualCategoryNames[RailwayLightRail] = "RailwayLightRail";
s_visualCategoryNames[RailwayAbandoned] = "RailwayAbandoned";
s_visualCategoryNames[RailwaySubway] = "RailwaySubway";
s_visualCategoryNames[RailwayPreserved] = "RailwayPreserved";
s_visualCategoryNames[RailwayMiniature] = "RailwayMiniature";
s_visualCategoryNames[RailwayConstruction] = "RailwayConstruction";
s_visualCategoryNames[RailwayMonorail] = "RailwayMonorail";
s_visualCategoryNames[RailwayFunicular] = "RailwayFunicular";
s_visualCategoryNames[PowerTower] = "PowerTower";
s_visualCategoryNames[Satellite] = "Satellite";
s_visualCategoryNames[LastIndex] = "LastIndex";
}
Q_ASSERT(s_visualCategoryNames.contains(category));
return s_visualCategoryNames[category];
}
QFont GeoDataFeature::defaultFont()
{
return GeoDataFeaturePrivate::s_defaultFont;
......
......@@ -629,6 +629,8 @@ class GEODATA_EXPORT GeoDataFeature : public GeoDataObject
static QSharedPointer<Marble::GeoDataStyle> presetStyle( GeoDataVisualCategory category );
static QString visualCategoryName(GeoDataVisualCategory category);
virtual void detach();
protected:
......
......@@ -16,6 +16,7 @@
#include "GeoPainter.h"
#include "ViewportParams.h"
#include "GeoDataStyle.h"
#include "MarbleDebug.h"
namespace Marble
{
......@@ -25,43 +26,107 @@ GeoLineStringGraphicsItem::GeoLineStringGraphicsItem( const GeoDataFeature *feat
: GeoGraphicsItem( feature ),
m_lineString( lineString )
{
QString const category = GeoDataFeature::visualCategoryName(feature->visualCategory());
QStringList paintLayers;
paintLayers << QString("LineString/%1/outline").arg(category);
paintLayers << QString("LineString/%1/inline").arg(category);
paintLayers << QString("LineString/%1/label").arg(category);
setPaintLayers(paintLayers);
}
const float GeoLineStringGraphicsItem::s_outlineZValue = -0.001;
void GeoLineStringGraphicsItem::setLineString( const GeoDataLineString* lineString )
{
m_lineString = lineString;
}
void GeoLineStringGraphicsItem::createDecorations()
const GeoDataLatLonAltBox& GeoLineStringGraphicsItem::latLonAltBox() const
{
if ( style() != nullptr ) {
if ( style()->lineStyle().cosmeticOutline() ) {
GeoLineStringGraphicsItem* outline = new GeoLineStringGraphicsItem(this->feature(), this->m_lineString);
outline->setZValue(this->zValue() + s_outlineZValue);
return m_lineString->latLonAltBox();
}
this->addDecoration(outline);
}
void GeoLineStringGraphicsItem::paint(GeoPainter* painter, const ViewportParams* viewport , const QString &layer)
{
if (layer.endsWith("/outline")) {
paintOutline(painter, viewport);
} else if (layer.endsWith("/label")) {
paintLabel(painter, viewport);
} else if (layer.endsWith("/inline")) {
paintInline(painter, viewport);
} else {
painter->drawPolyline(*m_lineString);
}
}
void GeoLineStringGraphicsItem::setLineString( const GeoDataLineString* lineString )
void GeoLineStringGraphicsItem::paintInline(GeoPainter* painter, const ViewportParams* viewport)
{
m_lineString = lineString;
if ( ( !viewport->resolves( m_lineString->latLonAltBox(), 2) ) ) {
return;
}
painter->save();
LabelPositionFlags labelPositionFlags = NoLabel;
QPen currentPen = configurePainter(painter, viewport, labelPositionFlags);
if ( ! ( currentPen.widthF() < 2.5f ) ) {
if( style()->lineStyle().cosmeticOutline() &&
style()->lineStyle().penStyle() == Qt::SolidLine ) {
if ( currentPen.widthF() > 2.5f ) {
currentPen.setWidthF( currentPen.widthF() - 2.0f );
}
currentPen.setColor( style()->polyStyle().paintedColor() );
painter->setPen( currentPen );
painter->drawPolyline(*m_lineString);
} else {
painter->drawPolyline(*m_lineString);
}
}
painter->restore();
}
const GeoDataLatLonAltBox& GeoLineStringGraphicsItem::latLonAltBox() const
void GeoLineStringGraphicsItem::paintOutline(GeoPainter *painter, const ViewportParams *viewport)
{
return m_lineString->latLonAltBox();
if ( ( !viewport->resolves( m_lineString->latLonAltBox(), 2) ) ) {
return;
}
painter->save();
LabelPositionFlags labelPositionFlags = NoLabel;
QPen currentPen = configurePainter(painter, viewport, labelPositionFlags);
if (!( currentPen.widthF() < 2.5f )) {
painter->drawPolyline(*m_lineString);
}
painter->restore();
}
void GeoLineStringGraphicsItem::paint( GeoPainter* painter, const ViewportParams* viewport )
void GeoLineStringGraphicsItem::paintLabel(GeoPainter *painter, const ViewportParams *viewport)
{
if ( ( !viewport->resolves( m_lineString->latLonAltBox(), 2) ) ) {
return;
}
painter->save();
LabelPositionFlags labelPositionFlags = NoLabel;
QPen currentPen = configurePainter(painter, viewport, labelPositionFlags);
if (!( currentPen.widthF() < 2.5f )) {
QPen pen(QColor(Qt::transparent));
pen.setWidthF(currentPen.widthF());
painter->setPen(pen);
QColor const color = style()->polyStyle().paintedColor();
painter->setBackground(QBrush(color));
painter->setBackgroundMode(Qt::OpaqueMode);
painter->drawPolyline( *m_lineString, feature()->name(), FollowLine,
style()->labelStyle().paintedColor(),
style()->labelStyle().font());
}
painter->save();
painter->restore();
}
QPen GeoLineStringGraphicsItem::configurePainter(GeoPainter *painter, const ViewportParams *viewport, LabelPositionFlags &labelPositionFlags) const
{
QPen currentPen = painter->pen();
if ( !style() ) {
painter->setPen( QPen() );
......@@ -122,30 +187,7 @@ void GeoLineStringGraphicsItem::paint( GeoPainter* painter, const ViewportParams
}
}
if ( ! ( isDecoration() && currentPen.widthF() < 2.5f ) )
{
if( style()->lineStyle().cosmeticOutline() &&
style()->lineStyle().penStyle() == Qt::SolidLine ) {
if ( isDecoration() ) {
painter->drawPolyline( *m_lineString, "", NoLabel );
} else {
if ( currentPen.widthF() > 2.5f ) {
currentPen.setWidthF( currentPen.widthF() - 2.0f );
}
currentPen.setColor( style()->polyStyle().paintedColor() );
painter->setPen( currentPen );
painter->drawPolyline( *m_lineString, feature()->name(), FollowLine,
style()->labelStyle().paintedColor(),
style()->labelStyle().font());
}
} else {
painter->drawPolyline( *m_lineString, feature()->name(), labelPositionFlags,
style()->labelStyle().paintedColor(),
style()->labelStyle().font() );
}
}
painter->restore();
return currentPen;
}
}
......@@ -29,13 +29,18 @@ public:
virtual const GeoDataLatLonAltBox& latLonAltBox() const;
virtual void paint( GeoPainter* painter, const ViewportParams *viewport );
void paint(GeoPainter* painter, const ViewportParams *viewport, const QString &layer);
protected:
const GeoDataLineString *m_lineString;
static const float s_outlineZValue;
virtual void createDecorations();
private:
void paintOutline(GeoPainter *painter, const ViewportParams *viewport);
void paintInline(GeoPainter *painter, const ViewportParams *viewport);
void paintLabel(GeoPainter *painter, const ViewportParams *viewport);
QPen configurePainter(GeoPainter* painter, const ViewportParams *viewport, LabelPositionFlags &labelPositionFlags) const;
};
}
......
......@@ -12,6 +12,7 @@
#include "GeoPainter.h"
#include "GeoDataStyle.h"
#include "GeoDataFeature.h"
#include "ViewportParams.h"
#include <QImageReader>
......@@ -24,10 +25,15 @@ namespace Marble
GeoPhotoGraphicsItem::GeoPhotoGraphicsItem( const GeoDataFeature *feature )
: GeoGraphicsItem( feature )
{
if (feature) {
QString const paintLayer = QString("Photo/%1").arg(GeoDataFeature::visualCategoryName(feature->visualCategory()));
setPaintLayers(QStringList() << paintLayer);
}
}
void GeoPhotoGraphicsItem::paint( GeoPainter* painter, const ViewportParams* viewport )
void GeoPhotoGraphicsItem::paint(GeoPainter* painter, const ViewportParams* viewport , const QString &layer)
{
Q_UNUSED(layer);
/* The code below loads the image lazily (only
* when it will actually be displayed). Once it was
* loaded but moves out of the viewport, it is unloaded
......
......@@ -29,7 +29,7 @@ public:
GeoDataPoint point() const;
virtual void paint( GeoPainter* painter, const ViewportParams *viewport );
virtual void paint(GeoPainter* painter, const ViewportParams *viewport, const QString &layer);
virtual const GeoDataLatLonAltBox& latLonAltBox() const;
......
......@@ -11,6 +11,7 @@
#include "GeoPointGraphicsItem.h"
#include "GeoPainter.h"
#include "GeoDataFeature.h"
namespace Marble
{
......@@ -18,6 +19,10 @@ namespace Marble
GeoPointGraphicsItem::GeoPointGraphicsItem( const GeoDataFeature *feature )
: GeoGraphicsItem( feature )
{
if (feature) {
QString const paintLayer = QString("Point/%1").arg(GeoDataFeature::visualCategoryName(feature->visualCategory()));
setPaintLayers(QStringList() << paintLayer);
}
}
void GeoPointGraphicsItem::setPoint( const GeoDataPoint& point )
......@@ -30,9 +35,10 @@ GeoDataPoint GeoPointGraphicsItem::point() const
return m_point;
}
void GeoPointGraphicsItem::paint( GeoPainter* painter, const ViewportParams* viewport )
void GeoPointGraphicsItem::paint(GeoPainter* painter, const ViewportParams* viewport , const QString &layer)
{
Q_UNUSED( viewport );
Q_UNUSED(viewport);
Q_UNUSED(layer);
painter->drawPoint( m_point );
}
......
......@@ -27,7 +27,7 @@ public:
void setPoint( const GeoDataPoint& point );
GeoDataPoint point() const;
virtual void paint( GeoPainter* painter, const ViewportParams *viewport );
virtual void paint(GeoPainter* painter, const ViewportParams *viewport, const QString &layer);
virtual const GeoDataLatLonAltBox& latLonAltBox() const;
......