Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Marble
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Education
Marble
Commits
b256a1f4
Commit
b256a1f4
authored
Jul 03, 2016
by
Dennis Nienhüser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use StyleBuilder from MarbleModel in PlacemarkLayout/VisiblePlacemark
parent
28a120d6
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
60 additions
and
33 deletions
+60
-33
src/lib/marble/MarbleMap.cpp
src/lib/marble/MarbleMap.cpp
+1
-1
src/lib/marble/PlacemarkLayout.cpp
src/lib/marble/PlacemarkLayout.cpp
+19
-12
src/lib/marble/PlacemarkLayout.h
src/lib/marble/PlacemarkLayout.h
+3
-0
src/lib/marble/VisiblePlacemark.cpp
src/lib/marble/VisiblePlacemark.cpp
+24
-16
src/lib/marble/VisiblePlacemark.h
src/lib/marble/VisiblePlacemark.h
+8
-1
src/lib/marble/layers/PlacemarkLayer.cpp
src/lib/marble/layers/PlacemarkLayer.cpp
+3
-3
src/lib/marble/layers/PlacemarkLayer.h
src/lib/marble/layers/PlacemarkLayer.h
+2
-0
No files found.
src/lib/marble/MarbleMap.cpp
View file @
b256a1f4
...
...
@@ -164,7 +164,7 @@ MarbleMapPrivate::MarbleMapPrivate( MarbleMap *parent, MarbleModel *model ) :
m_customPaintLayer
(
parent
),
m_geometryLayer
(
model
->
treeModel
(),
&
m_styleBuilder
),
m_textureLayer
(
model
->
downloadManager
(),
model
->
pluginManager
(),
model
->
sunLocator
(),
model
->
groundOverlayModel
()
),
m_placemarkLayer
(
model
->
placemarkModel
(),
model
->
placemarkSelectionModel
(),
model
->
clock
()
),
m_placemarkLayer
(
model
->
placemarkModel
(),
model
->
placemarkSelectionModel
(),
model
->
clock
()
,
&
m_styleBuilder
),
m_vectorTileLayer
(
model
->
downloadManager
(),
model
->
pluginManager
(),
model
->
treeModel
()
),
m_isLockedToSubSolarPoint
(
false
),
m_isSubSolarPointIconVisible
(
false
)
...
...
src/lib/marble/PlacemarkLayout.cpp
View file @
b256a1f4
...
...
@@ -38,6 +38,7 @@
#include "TileCoordsPyramid.h"
#include "VisiblePlacemark.h"
#include "MathHelper.h"
#include <StyleBuilder.h>
namespace
{
//Helper function that checks for available room for the label
...
...
@@ -154,6 +155,7 @@ QSet<GeoDataFeature::GeoDataVisualCategory> acceptedVisualCategories()
PlacemarkLayout
::
PlacemarkLayout
(
QAbstractItemModel
*
placemarkModel
,
QItemSelectionModel
*
selectionModel
,
MarbleClock
*
clock
,
const
StyleBuilder
*
styleBuilder
,
QObject
*
parent
)
:
QObject
(
parent
),
m_placemarkModel
(
placemarkModel
),
...
...
@@ -168,7 +170,8 @@ PlacemarkLayout::PlacemarkLayout( QAbstractItemModel *placemarkModel,
m_showCraters
(
false
),
m_showMaria
(
false
),
m_maxLabelHeight
(
maxLabelHeight
()),
m_styleResetRequested
(
true
)
m_styleResetRequested
(
true
),
m_styleBuilder
(
styleBuilder
)
{
Q_ASSERT
(
m_placemarkModel
);
...
...
@@ -549,11 +552,25 @@ QString PlacemarkLayout::runtimeTrace() const
bool
PlacemarkLayout
::
layoutPlacemark
(
const
GeoDataPlacemark
*
placemark
,
qreal
x
,
qreal
y
,
bool
selected
)
{
// Find the corresponding visible placemark
VisiblePlacemark
*
mark
=
m_visiblePlacemarks
.
value
(
placemark
);
if
(
!
mark
)
{
// If there is no visible placemark yet for this index,
// create a new one...
StyleParameters
parameters
;
// @todo: Set / adjust to tile level
parameters
.
feature
=
placemark
;
mark
=
new
VisiblePlacemark
(
placemark
,
m_styleBuilder
->
createStyle
(
parameters
));
m_visiblePlacemarks
.
insert
(
placemark
,
mark
);
connect
(
mark
,
SIGNAL
(
updateNeeded
()),
this
,
SIGNAL
(
repaintNeeded
())
);
}
GeoDataStyle
::
ConstPtr
style
=
mark
->
style
();
// Choose Section
// Find out whether the area around the placemark is covered already.
// If there's not enough space free don't add a VisiblePlacemark here.
GeoDataStyle
::
ConstPtr
style
=
placemark
->
style
();
QRectF
labelRect
;
if
(
!
placemark
->
displayName
().
isEmpty
()
)
{
...
...
@@ -563,16 +580,6 @@ bool PlacemarkLayout::layoutPlacemark( const GeoDataPlacemark *placemark, qreal
}
}
// Find the corresponding visible placemark
VisiblePlacemark
*
mark
=
m_visiblePlacemarks
.
value
(
placemark
);
if
(
!
mark
)
{
// If there is no visible placemark yet for this index,
// create a new one...
mark
=
new
VisiblePlacemark
(
placemark
);
m_visiblePlacemarks
.
insert
(
placemark
,
mark
);
connect
(
mark
,
SIGNAL
(
updateNeeded
()),
this
,
SIGNAL
(
repaintNeeded
())
);
}
// Finally save the label position on the map.
QPointF
hotSpot
=
mark
->
hotSpot
();
...
...
src/lib/marble/PlacemarkLayout.h
View file @
b256a1f4
...
...
@@ -44,6 +44,7 @@ class PlacemarkPainter;
class
TileId
;
class
VisiblePlacemark
;
class
ViewportParams
;
class
StyleBuilder
;
/**
* Layouts the place marks with a passed QPainter.
...
...
@@ -62,6 +63,7 @@ class PlacemarkLayout : public QObject
PlacemarkLayout
(
QAbstractItemModel
*
placemarkModel
,
QItemSelectionModel
*
selectionModel
,
MarbleClock
*
clock
,
const
StyleBuilder
*
styleBuilder
,
QObject
*
parent
=
0
);
/**
...
...
@@ -160,6 +162,7 @@ class PlacemarkLayout : public QObject
int
m_maxLabelHeight
;
bool
m_styleResetRequested
;
const
StyleBuilder
*
m_styleBuilder
;
};
}
...
...
src/lib/marble/VisiblePlacemark.cpp
View file @
b256a1f4
...
...
@@ -24,11 +24,11 @@
using
namespace
Marble
;
VisiblePlacemark
::
VisiblePlacemark
(
const
GeoDataPlacemark
*
placemark
)
VisiblePlacemark
::
VisiblePlacemark
(
const
GeoDataPlacemark
*
placemark
,
const
GeoDataStyle
::
ConstPtr
&
style
)
:
m_placemark
(
placemark
),
m_selected
(
false
)
m_selected
(
false
),
m_style
(
style
)
{
GeoDataStyle
::
ConstPtr
style
=
m_placemark
->
style
();
const
RemoteIconLoader
*
remoteLoader
=
style
->
iconStyle
().
remoteIconLoader
();
QObject
::
connect
(
remoteLoader
,
SIGNAL
(
iconReady
()),
this
,
SLOT
(
setSymbolPixmap
())
);
...
...
@@ -65,11 +65,11 @@ const QPoint& VisiblePlacemark::symbolPosition() const
const
QPointF
VisiblePlacemark
::
hotSpot
()
const
{
const
QSize
iconSize
=
m_
placemark
->
style
()
->
iconStyle
().
scaledIcon
().
size
();
const
QSize
iconSize
=
m_
style
->
iconStyle
().
scaledIcon
().
size
();
GeoDataHotSpot
::
Units
xunits
;
GeoDataHotSpot
::
Units
yunits
;
QPointF
pixelHotSpot
=
m_
placemark
->
style
()
->
iconStyle
().
hotSpot
(
xunits
,
yunits
);
QPointF
pixelHotSpot
=
m_
style
->
iconStyle
().
hotSpot
(
xunits
,
yunits
);
switch
(
xunits
)
{
case
GeoDataHotSpot
::
Fraction
:
...
...
@@ -110,10 +110,8 @@ const QPixmap& VisiblePlacemark::labelPixmap() const
void
VisiblePlacemark
::
setSymbolPixmap
()
{
GeoDataStyle
::
ConstPtr
style
=
m_placemark
->
style
();
if
(
style
)
{
m_symbolPixmap
=
QPixmap
::
fromImage
(
style
->
iconStyle
().
scaledIcon
()
);
if
(
m_style
)
{
m_symbolPixmap
=
QPixmap
::
fromImage
(
m_style
->
iconStyle
().
scaledIcon
()
);
emit
updateNeeded
();
}
else
{
...
...
@@ -131,30 +129,40 @@ void VisiblePlacemark::setLabelRect( const QRectF& labelRect )
m_labelRect
=
labelRect
;
}
void
VisiblePlacemark
::
drawLabelPixmap
()
void
VisiblePlacemark
::
setStyle
(
const
GeoDataStyle
::
ConstPtr
&
style
)
{
m_style
=
style
;
drawLabelPixmap
();
setSymbolPixmap
();
}
GeoDataStyle
::
ConstPtr
VisiblePlacemark
::
style
()
const
{
GeoDataStyle
::
ConstPtr
style
=
m_placemark
->
style
();
return
m_style
;
}
void
VisiblePlacemark
::
drawLabelPixmap
()
{
QString
labelName
=
m_placemark
->
displayName
();
if
(
labelName
.
isEmpty
()
||
style
->
labelStyle
().
color
()
==
QColor
(
Qt
::
transparent
)
)
{
if
(
labelName
.
isEmpty
()
||
m_
style
->
labelStyle
().
color
()
==
QColor
(
Qt
::
transparent
)
)
{
m_labelPixmap
=
QPixmap
();
return
;
}
QFont
labelFont
=
style
->
labelStyle
().
scaledFont
();
QColor
labelColor
=
style
->
labelStyle
().
color
();
QFont
labelFont
=
m_
style
->
labelStyle
().
scaledFont
();
QColor
labelColor
=
m_
style
->
labelStyle
().
color
();
LabelStyle
labelStyle
=
Normal
;
if
(
m_selected
)
{
labelStyle
=
Selected
;
}
else
if
(
style
->
labelStyle
().
glow
()
)
{
}
else
if
(
m_
style
->
labelStyle
().
glow
()
)
{
labelStyle
=
Glow
;
}
int
textHeight
=
QFontMetrics
(
labelFont
).
height
();
int
textWidth
;
if
(
style
->
labelStyle
().
glow
()
)
{
if
(
m_
style
->
labelStyle
().
glow
()
)
{
labelFont
.
setWeight
(
75
);
// Needed to calculate the correct pixmap size;
textWidth
=
(
QFontMetrics
(
labelFont
).
width
(
labelName
)
+
qRound
(
2
*
s_labelOutlineWidth
)
);
...
...
src/lib/marble/VisiblePlacemark.h
View file @
b256a1f4
...
...
@@ -22,6 +22,8 @@
#include <QRectF>
#include <QString>
#include <GeoDataStyle.h>
namespace
Marble
{
...
...
@@ -40,7 +42,7 @@ class VisiblePlacemark : public QObject
Q_OBJECT
public:
explicit
VisiblePlacemark
(
const
GeoDataPlacemark
*
placemark
);
explicit
VisiblePlacemark
(
const
GeoDataPlacemark
*
placemark
,
const
GeoDataStyle
::
ConstPtr
&
style
);
/**
* Returns the index of the place mark model which
...
...
@@ -99,6 +101,10 @@ class VisiblePlacemark : public QObject
Selected
};
void
setStyle
(
const
GeoDataStyle
::
ConstPtr
&
style
);
GeoDataStyle
::
ConstPtr
style
()
const
;
Q_SIGNALS:
void
updateNeeded
();
...
...
@@ -118,6 +124,7 @@ private Q_SLOTS:
QRectF
m_labelRect
;
// bounding box of label
mutable
QPixmap
m_symbolPixmap
;
// cached value
GeoDataStyle
::
ConstPtr
m_style
;
};
}
...
...
src/lib/marble/layers/PlacemarkLayer.cpp
View file @
b256a1f4
...
...
@@ -28,12 +28,12 @@ using namespace Marble;
bool
PlacemarkLayer
::
m_useXWorkaround
=
false
;
PlacemarkLayer
::
PlacemarkLayer
(
QAbstractItemModel
*
placemarkModel
,
PlacemarkLayer
::
PlacemarkLayer
(
QAbstractItemModel
*
placemarkModel
,
QItemSelectionModel
*
selectionModel
,
MarbleClock
*
clock
,
MarbleClock
*
clock
,
const
StyleBuilder
*
styleBuilder
,
QObject
*
parent
)
:
QObject
(
parent
),
m_layout
(
placemarkModel
,
selectionModel
,
clock
)
m_layout
(
placemarkModel
,
selectionModel
,
clock
,
styleBuilder
)
{
m_useXWorkaround
=
testXBug
();
mDebug
()
<<
"Use workaround: "
<<
(
m_useXWorkaround
?
"1"
:
"0"
);
...
...
src/lib/marble/layers/PlacemarkLayer.h
View file @
b256a1f4
...
...
@@ -38,6 +38,7 @@ class GeoSceneLayer;
class
MarbleClock
;
class
ViewportParams
;
class
VisiblePlacemark
;
class
StyleBuilder
;
class
PlacemarkLayer
:
public
QObject
,
public
LayerInterface
{
...
...
@@ -47,6 +48,7 @@ class PlacemarkLayer : public QObject, public LayerInterface
PlacemarkLayer
(
QAbstractItemModel
*
placemarkModel
,
QItemSelectionModel
*
selectionModel
,
MarbleClock
*
clock
,
const
StyleBuilder
*
styleBuilder
,
QObject
*
parent
=
0
);
~
PlacemarkLayer
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment