Skip to content

Commit

Permalink
Object class filter & bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jusirkka committed Jan 9, 2023
1 parent fa30662 commit 9bd7192
Show file tree
Hide file tree
Showing 15 changed files with 350 additions and 181 deletions.
2 changes: 0 additions & 2 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,5 @@ Before 1.0:
- bug: assert failure in KV::Region when browsing high latitudes
- bug: s57 charts: sporadic index out of range error
- check that chart db fetches work across dateline

- object class filter & config
- display less details in smaller chart scales

44 changes: 32 additions & 12 deletions qml/ChartPreferencesPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,26 @@ PagePL {
}
}

TextSwitchPL {
id: swm
//% "Meta objects"
text: qsTrId("qtnav-meta-objects")
//% "Show meta objects."
description: qsTrId("qtnav-meta-objects-description")
Component.onCompleted: {
swm.checked = settings.showMeta;
}
onCheckedChanged: {
settings.showMeta = checked;
SectionHeaderPL {
//% "Optional object classes"
text: qsTrId("qtnav-optional-object-classes")
}

Repeater {
model: settings.disabledClasses
TextSwitchPL {
Component.onCompleted: {
checked = !modelData.enabled;
text = modelData.text
description = modelData.description
}
onCheckedChanged: {
modelData.enabled = !checked;
}
}
}


SectionHeaderPL {
//% "Depths & Contours"
text: qsTrId("qtnav-depths-contours")
Expand Down Expand Up @@ -190,9 +196,23 @@ PagePL {
}
}

TextSwitchPL {
id: sw3
//% "Shallow Pattern"
text: qsTrId("qtnav-shallow-pattern")
//% "Fill depth areas shallower than the safety contour with a pattern."
description: qsTrId("qtnav-shallow-pattern-description")
Component.onCompleted: {
sw3.checked = settings.shallowPattern;
}
onCheckedChanged: {
settings.shallowPattern = checked;
}
}

SectionHeaderPL {
//% "Colors"
text: qsTrId("qtnav-olors")
text: qsTrId("qtnav-colors")
}

ComboBoxPL {
Expand Down
4 changes: 4 additions & 0 deletions qutenavlib/src/s57object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,10 @@ void S57::Geometry::Area::doDecode(QDataStream& stream) {
stream >> m_indexed;
}

bool S57::Geometry::Area::crosses(const glm::vec2* vertices, const GLuint* indices, const QRectF& box) const {
return m_lines->crosses(vertices, indices, box);
}

bool S57::Geometry::Area::includes(const glm::vec2* vs, const GLuint* is, const QPointF& p) const {

auto inbox = [] (const S57::ElementData& elem, const QPointF& p) {
Expand Down
1 change: 1 addition & 0 deletions qutenavlib/src/s57object.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ class Area: public Base {
bool indexed() const {return m_indexed;}

bool includes(const glm::vec2* vs, const GLuint* is, const QPointF& p) const;
bool crosses(const glm::vec2* vertices, const GLuint* indices, const QRectF& box) const;

~Area() {
if (m_lines != m_border) {
Expand Down
11 changes: 10 additions & 1 deletion src/conf_marinerparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,26 @@ Conf::MarinerParams::MarinerParams()
m_defaults["plain_boundaries"] = false;
m_defaults["simplified_symbols"] = false;
m_defaults["max_category"] = static_cast<uint>(EnumMaxCategory::type::Mariners);
m_defaults["show_meta"] = true;
m_defaults["full_length_sectors"] = false;

QVariantList items;

items << 10 << 11 << 12 << 20 << 21 << 23 << 24 << 25 << 26 << 27 << 28 << 29 << 31;
m_defaults["text_grouping"] = items;

items.clear();

items << 300 << 301 << 302 << 303 << 304 << 305 << 306 << 307 << 308 << 309 << 310
<< 311 << 312 << 17018 << 666666;
m_defaults["disabled_classes"] = items;

load();

QVariantList vitems = m_values["text_grouping"].toList();
for (auto v: vitems) m_textGrouping.append(v.toInt());

vitems = m_values["disabled_classes"].toList();
for (auto v: vitems) m_disabledClasses.append(v.toInt());
}

Conf::MarinerParams::~MarinerParams() {}
15 changes: 14 additions & 1 deletion src/conf_marinerparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ class MarinerParams: public ConfigGroup {
CONF_DECL(ShallowPattern, shallow_pattern, bool, toBool)
CONF_DECL(PlainBoundaries, plain_boundaries, bool, toBool)
CONF_DECL(SimplifiedSymbols, simplified_symbols, bool, toBool)
CONF_DECL(ShowMeta, show_meta, bool, toBool)
CONF_DECL(FullLengthSectors, full_length_sectors, bool, toBool)

static void setColorTable(EnumColorTable::type v) {
Expand Down Expand Up @@ -102,11 +101,25 @@ class MarinerParams: public ConfigGroup {
return self()->m_textGrouping;
}

static void setDisabledClasses(const QList<int>& v) {
self()->m_disabledClasses = v;

QVariantList items;
for (auto i: v) items.append(i);

self()->m_values["disabled_classes"] = items;
}

static QList<int> DisabledClasses() {
return self()->m_disabledClasses;
}

private:

MarinerParams();

QList<int> m_textGrouping;
QList<int> m_disabledClasses;

};

Expand Down
23 changes: 20 additions & 3 deletions src/rastersymbolmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,13 +269,30 @@ bool RasterSymbolManager::paintIcon(PickIconData& icon, quint32 index, S52::Symb

if (type == S52::SymbolType::Pattern) {
const QSizeF s(Platform::pick_icon_size(), Platform::pick_icon_size());
const QPointF c = .5 * QPointF(icon.canvas.width() - s.width(), icon.canvas.height() - s.height());
const QRectF box(c, s);
icon.bbox |= box;

const auto adv = m_symbolMap[key].advance();
const qreal X = adv.x * Platform::dots_per_mm_x();
const qreal Y = adv.xy.y() * Platform::dots_per_mm_y();

if (X > .5 * s.width() || Y > .5 * s.height()) {
// Too large pattern, just draw it once centered
if (pix.width() > .9 * s.width() && pix.width() >= pix.height()) {
pix = pix.scaledToWidth(.9 * s.width());
} else if (pix.height() > .9 * s.height() && pix.height() >= pix.width()) {
pix = pix.scaledToHeight(.9 * s.height());
}

const QPointF c = .5 * QPointF(icon.canvas.width() - pix.width(), icon.canvas.height() - pix.height());
const QRectF box(c, pix.size());
icon.bbox |= box;
painter.drawPixmap(c, pix);
return true;
}

const QPointF c = .5 * QPointF(icon.canvas.width() - s.width(), icon.canvas.height() - s.height());
const QRectF box(c, s);
icon.bbox |= box;

const qreal xs = adv.xy.x() * Platform::dots_per_mm_x();

const int ny = std::floor(box.top() / Y);
Expand Down
Loading

0 comments on commit 9bd7192

Please sign in to comment.