Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle color assignment for IMs with no fill symbology #285

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion src/cplus_plugin/gui/qgis_cplus_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import datetime

from functools import partial
from random import randint

from pathlib import Path

Expand Down Expand Up @@ -2348,7 +2349,28 @@ def style_models_layer(self, layer, models):
im_name = model.name

raster_val = model.style_pixel_value
color = model.scenario_fill_symbol().color()

model_fill_symbol = model.scenario_fill_symbol()
if model_fill_symbol is None:
self.show_message(
tr(
f"Couldn't fetch color for the implementation model {im_name},"
f" using a random color instead."
),
level=Qgis.Warning,
)
log(
tr(
f"Couldn't fetch color for the implementation model {im_name},"
f" using a random color instead, fill symbol is None"
)
)
color_names = QtGui.QColor.colorNames()
color_name = color_names[randint(0, len(color_names))]
color = QtGui.QColor(color_name)
else:
color = model_fill_symbol.color()

color_ramp_shader = QgsColorRampShader.ColorRampItem(
float(raster_val), QtGui.QColor(color), im_name
)
Expand Down
Loading