Skip to content

Commit

Permalink
fix segfault
Browse files Browse the repository at this point in the history
  • Loading branch information
JanCaha committed Nov 10, 2024
1 parent 6dca550 commit c72a56f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 24 deletions.
30 changes: 15 additions & 15 deletions BivariateRenderer/colorramps/bivariate_color_ramp.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
from BivariateRenderer.colormixing.color_mixing_method import ColorMixingMethod, ColorMixingMethodMultiply
from BivariateRenderer.colormixing.color_mixing_methods_register import ColorMixingMethodsRegister

from ..utils import get_icon
from ..utils import get_icon_path


class BivariateColorRamp(ABC):
_name: str = "Default Bivariate Color Ramp"
_icon: QIcon
_icon: str

def __init__(self, number_classes: int = 9) -> None:
self._number_of_classes = number_classes
Expand All @@ -27,7 +27,7 @@ def name(self) -> str:

@property
def icon(self) -> QIcon:
return self._icon
return QIcon(self._icon)

@property
def number_of_classes(self) -> int:
Expand Down Expand Up @@ -223,7 +223,7 @@ def __init__(
self._name = "Cyan - Brown"
self._color_ramp_1 = QgsGradientColorRamp(QColor("#d3d3d3"), QColor("#80b9b5"))
self._color_ramp_2 = QgsGradientColorRamp(QColor("#d3d3d3"), QColor("#a86a25"))
self._icon = get_icon("cp_cyan_brown.png")
self._icon = get_icon_path("cp_cyan_brown.png")


class BivariateColorRampTurquoiseGold(BivariateColorRampGradient):
Expand All @@ -234,7 +234,7 @@ def __init__(
self._name = "Turquoise - Gold"
self._color_ramp_1 = QgsGradientColorRamp(QColor("#d3d3d3"), QColor("#4e9ec2"))
self._color_ramp_2 = QgsGradientColorRamp(QColor("#d3d3d3"), QColor("#f6b500"))
self._icon = get_icon("cp_turquoise_gold.png")
self._icon = get_icon_path("cp_turquoise_gold.png")


class BivariateColorRampOrangeBlue(BivariateColorRampGradient):
Expand All @@ -245,7 +245,7 @@ def __init__(
self._name = "Orange - Blue"
self._color_ramp_1 = QgsGradientColorRamp(QColor("#d3d3d3"), QColor("#f6742e"))
self._color_ramp_2 = QgsGradientColorRamp(QColor("#d3d3d3"), QColor("#17afe7"))
self._icon = get_icon("cp_orange_blue.png")
self._icon = get_icon_path("cp_orange_blue.png")


class BivariateColorRampYellowBlue(BivariateColorRampGradient):
Expand All @@ -256,7 +256,7 @@ def __init__(
self._name = "Yellow - Blue"
self._color_ramp_1 = QgsGradientColorRamp(QColor("#d3d3d3"), QColor("#f1d301"))
self._color_ramp_2 = QgsGradientColorRamp(QColor("#d3d3d3"), QColor("#0097f1"))
self._icon = get_icon("cp_yellow_blue.png")
self._icon = get_icon_path("cp_yellow_blue.png")


class BivariateColorRampLigthYellowPurple(BivariateColorRampGradient):
Expand All @@ -267,7 +267,7 @@ def __init__(
self._name = "Ligth Yellow - Purple"
self._color_ramp_1 = QgsGradientColorRamp(QColor("#d3d3d3"), QColor("#cab55a"))
self._color_ramp_2 = QgsGradientColorRamp(QColor("#d3d3d3"), QColor("#9a73af"))
self._icon = get_icon("cp_ligth_yellow_purple.png")
self._icon = get_icon_path("cp_ligth_yellow_purple.png")


class BivariateColorRampCyanViolet(BivariateColorRampGradient):
Expand All @@ -278,7 +278,7 @@ def __init__(
self._name = "Cyan - Violet"
self._color_ramp_1 = QgsGradientColorRamp(QColor("#d3d3d3"), QColor("#5bcaca"))
self._color_ramp_2 = QgsGradientColorRamp(QColor("#d3d3d3"), QColor("#bf64ad"))
self._icon = get_icon("cp_cyan_violet.png")
self._icon = get_icon_path("cp_cyan_violet.png")


class BivariateColorRampBlueGreen(BivariateColorRampGradient):
Expand All @@ -289,7 +289,7 @@ def __init__(
self._name = "Blue - Green"
self._color_ramp_1 = QgsGradientColorRamp(QColor("#d3d3d3"), QColor("#6c84b7"))
self._color_ramp_2 = QgsGradientColorRamp(QColor("#d3d3d3"), QColor("#73af7f"))
self._icon = get_icon("cp_blue_green.png")
self._icon = get_icon_path("cp_blue_green.png")


class BivariateColorRampVioletBlue(BivariateColorRampGradient):
Expand All @@ -300,7 +300,7 @@ def __init__(
self._name = "Violet - Blue"
self._color_ramp_1 = QgsGradientColorRamp(QColor("#d3d3d3"), QColor("#ae3a4c"))
self._color_ramp_2 = QgsGradientColorRamp(QColor("#d3d3d3"), QColor("#4886c2"))
self._icon = get_icon("cp_violet_blue.png")
self._icon = get_icon_path("cp_violet_blue.png")


class BivariateColorRampPinkBlue(BivariateColorRampGradient):
Expand All @@ -311,7 +311,7 @@ def __init__(
self._name = "Pink - Blue"
self._color_ramp_1 = QgsGradientColorRamp(QColor("#d3d3d3"), QColor("#cb5b5b"))
self._color_ramp_2 = QgsGradientColorRamp(QColor("#d3d3d3"), QColor("#66adc0"))
self._icon = get_icon("cp_pink_blue.png")
self._icon = get_icon_path("cp_pink_blue.png")


class BivariateColorRampGreenPink(BivariateColorRampGradient):
Expand All @@ -322,7 +322,7 @@ def __init__(
self._name = "Green - Pink"
self._color_ramp_1 = QgsGradientColorRamp(QColor("#d3d3d3"), QColor("#4cac26"))
self._color_ramp_2 = QgsGradientColorRamp(QColor("#d3d3d3"), QColor("#d0258c"))
self._icon = get_icon("cp_green_pink.png")
self._icon = get_icon_path("cp_green_pink.png")


class BivariateColorRampGreenPurple(BivariateColorRampGradient):
Expand All @@ -333,7 +333,7 @@ def __init__(
self._name = "Green - Purple"
self._color_ramp_1 = QgsGradientColorRamp(QColor("#d3d3d3"), QColor("#028834"))
self._color_ramp_2 = QgsGradientColorRamp(QColor("#d3d3d3"), QColor("#7a3293"))
self._icon = get_icon("cp_green_purple.png")
self._icon = get_icon_path("cp_green_purple.png")


class BivariateColorRampOrangePurple(BivariateColorRampGradient):
Expand All @@ -344,4 +344,4 @@ def __init__(
self._name = "Orange - Purple"
self._color_ramp_1 = QgsGradientColorRamp(QColor("#d3d3d3"), QColor("#e95f00"))
self._color_ramp_2 = QgsGradientColorRamp(QColor("#d3d3d3"), QColor("#5e3c96"))
self._icon = get_icon("cp_orange_purple.png")
self._icon = get_icon_path("cp_orange_purple.png")
12 changes: 5 additions & 7 deletions BivariateRenderer/renderer/bivariate_renderer_metadata.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
from pathlib import Path

from qgis.core import (QgsRendererAbstractMetadata)

from qgis.core import QgsRendererAbstractMetadata
from qgis.PyQt.QtGui import QIcon
from qgis.PyQt.QtXml import QDomElement

from ..text_constants import Texts
from ..utils import get_icon_path
from .bivariate_renderer import BivariateRenderer
from .bivariate_renderer_widget import BivariateRendererWidget
from ..text_constants import Texts
from ..utils import get_icon


class BivariateRendererMetadata(QgsRendererAbstractMetadata):

def __init__(self):
super().__init__(Texts.bivariate_renderer_short_name, Texts.bivariate_renderer_full_name)

super().setIcon(get_icon("legend_icon.png"))
super().setIcon(QIcon(get_icon_path("legend_icon.png")))

def name(self) -> str:
return Texts.bivariate_renderer_short_name
Expand Down
4 changes: 2 additions & 2 deletions BivariateRenderer/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ def path_icon(file_name: str) -> Path:
return Path(__file__).parent / "icons" / file_name


def get_icon(file_name: str) -> QIcon:
def get_icon_path(file_name: str) -> str:

path = path_icon(file_name)

return QIcon(path.absolute().as_posix())
return path.absolute().as_posix()


def save_symbol_xml(symbol: QgsSymbol, file_name: Path) -> None:
Expand Down

0 comments on commit c72a56f

Please sign in to comment.