Commit b317efa6 authored by Flavio TARSETTI's avatar Flavio TARSETTI
Browse files

[resources/widgets] refactored toolchain scene

parent 0122237f
This diff is collapsed.
......@@ -74,7 +74,7 @@ from ..backend.assetmodel import AssetModel
from ..decorators import frozen
from .editor import AbstractAssetEditor
from .drawing_space import DrawingSpace
from .toolchainscene import ToolchainScene
from ..backend.resourcemodels import AlgorithmResourceModel
from ..backend.resourcemodels import DatasetResourceModel
......@@ -1430,8 +1430,8 @@ class Toolchain(QWidget):
if _file.open(QFile.ReadOnly | QIODevice.Text):
config_data = json.loads(_file.readAll().data().decode("utf-8"))
self.scene_config = config_data["drawing_space_config"]
self.scene = DrawingSpace(self.scene_config)
self.scene_config = config_data["toolchainscene_config"]
self.scene = ToolchainScene(self.scene_config)
self.block_config = config_data["block_config"]
self.connection_config = config_data["connection_config"]
......
......@@ -29,7 +29,7 @@ from PyQt5.QtGui import QColor
from PyQt5.QtGui import QPen
class DrawingSpace(QGraphicsScene):
class ToolchainScene(QGraphicsScene):
"""Playground scene for block objects"""
......@@ -37,8 +37,22 @@ class DrawingSpace(QGraphicsScene):
super().__init__()
self.grid_size = configuration["grid_size"]
self.grid_color = configuration["grid_color"]
self.grid_size = configuration.get("grid_size", 36)
self.grid_color = configuration.get("grid_color", [232, 232, 232, 255])
if not isinstance(self.grid_size, int):
raise TypeError(
self.tr("Grid size configuration has to be of type integer")
)
if not isinstance(self.grid_color, list):
raise TypeError(self.tr("Grid color configuration has to be of type list"))
if (
not all(isinstance(x, int) for x in self.grid_color)
or len(self.grid_color) != 4
):
raise TypeError(self.tr("Invalid grid element types or unmatching size"))
def drawBackground(self, painter, rect):
"""Background grid"""
......
{
"drawing_space_config":{
"toolchainscene_config":{
"scene_width": 2000,
"scene_height": 2000,
"grid_size": 36,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment