Skip to content

Commit

Permalink
Merge pull request #7 from nodedge/feature/blocks-implementation
Browse files Browse the repository at this point in the history
Blocks implementation
  • Loading branch information
nodedge committed Nov 15, 2020
2 parents ff70ecb + 3ed8d51 commit 2fbb227
Show file tree
Hide file tree
Showing 209 changed files with 386 additions and 168 deletions.
70 changes: 38 additions & 32 deletions examples/calculator/calculator.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,29 +248,47 @@
"operationCode": 2
},
{
"id": 64719888,
"id": 192604048,
"title": "Output",
"posX": 240.0,
"posY": 120.0,
"inputSockets": [
{
"id": 192605008,
"index": 0,
"allowMultiEdges": false,
"location": 1,
"socketType": 1
}
],
"outputSockets": [],
"content": {},
"operationCode": 2
},
{
"id": 212486384,
"title": "Modulo",
"posX": -45.0,
"posY": 120.0,
"inputSockets": [
{
"id": 74608816,
"id": 212486416,
"index": 0,
"allowMultiEdges": false,
"location": 1,
"socketType": 2
"socketType": 1
},
{
"id": 74609296,
"id": 212486480,
"index": 1,
"allowMultiEdges": false,
"location": 1,
"socketType": 2
"socketType": 1
}
],
"outputSockets": [
{
"id": 74611312,
"id": 212486512,
"index": 0,
"allowMultiEdges": true,
"location": 4,
Expand All @@ -279,24 +297,6 @@
],
"content": {},
"operationCode": 7
},
{
"id": 192604048,
"title": "Output",
"posX": 240.0,
"posY": 120.0,
"inputSockets": [
{
"id": 192605008,
"index": 0,
"allowMultiEdges": false,
"location": 1,
"socketType": 1
}
],
"outputSockets": [],
"content": {},
"operationCode": 2
}
],
"edges": [
Expand Down Expand Up @@ -373,22 +373,28 @@
"target": 1583749804528
},
{
"id": 83443312,
"id": 86093808,
"edgeType": 3,
"source": 74608816,
"target": 1583749280096
"source": 212486512,
"target": 192605008
},
{
"id": 64719984,
"id": 212555888,
"edgeType": 3,
"source": 74609296,
"source": 212486480,
"target": 1583749280960
},
{
"id": 192603792,
"id": 212628112,
"edgeType": 2,
"source": 1583749280960,
"target": null
},
{
"id": 79788528,
"edgeType": 3,
"source": 74611312,
"target": 192605008
"source": 1583749280096,
"target": 212486416
}
]
}
5 changes: 2 additions & 3 deletions nodedge/blocks/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-

from .autogen.operator import *
from .custom.input_block import *
from .custom.output_block import *
from .autogen import *
from .custom import *

# modules = glob.glob(join(dirname(__file__), "*.py"))
# __all__ = [basename(f)[:-3] for f in modules if isfile(f) and f.endswith('_block.py')]
1 change: 1 addition & 0 deletions nodedge/blocks/autogen/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .operator import *
15 changes: 13 additions & 2 deletions nodedge/blocks/autogen/operator/add_block.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# -*- coding: utf-8 -*-
from typing import List

import logging
from operator import add

from nodedge.blocks.block import Block, EvaluationError
from nodedge.blocks.block import Block
from nodedge.blocks.block_exception import EvaluationError
from nodedge.blocks.block_config import BLOCKS_ICONS_PATH, registerNode
from nodedge.connector import SocketType

_LOG = logging.getLogger(__name__)

Expand All @@ -16,13 +20,20 @@

@registerNode(OP_NODE_ADD)
class AddBlock(Block):
icon = f"{BLOCKS_ICONS_PATH}/add.png"
icon = f"{BLOCKS_ICONS_PATH}/plus_math_100.png"
operationCode = OP_NODE_ADD
operationTitle = "Addition"
contentLabel = "+"
contentLabelObjectName = "BlockBackground"
evalString = "add"
library = "operator"
inputSocketTypes: List[SocketType] = [
SocketType.Number,
SocketType.Number,
]
outputSocketTypes: List[SocketType] = [
SocketType.Number,
]

def evalImplementation(self):
inputs = []
Expand Down
15 changes: 13 additions & 2 deletions nodedge/blocks/autogen/operator/eq_block.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# -*- coding: utf-8 -*-
from typing import List

import logging
from operator import eq

from nodedge.blocks.block import Block, EvaluationError
from nodedge.blocks.block import Block
from nodedge.blocks.block_exception import EvaluationError
from nodedge.blocks.block_config import BLOCKS_ICONS_PATH, registerNode
from nodedge.connector import SocketType

_LOG = logging.getLogger(__name__)

Expand All @@ -16,13 +20,20 @@

@registerNode(OP_NODE_EQUAL)
class EqBlock(Block):
icon = f"{BLOCKS_ICONS_PATH}/eq.png"
icon = f"{BLOCKS_ICONS_PATH}/equal_sign_100.png"
operationCode = OP_NODE_EQUAL
operationTitle = "Equal"
contentLabel = "=="
contentLabelObjectName = "BlockBackground"
evalString = "eq"
library = "operator"
inputSocketTypes: List[SocketType] = [
SocketType.Number,
SocketType.Number,
]
outputSocketTypes: List[SocketType] = [
SocketType.Number,
]

def evalImplementation(self):
inputs = []
Expand Down
15 changes: 13 additions & 2 deletions nodedge/blocks/autogen/operator/ge_block.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# -*- coding: utf-8 -*-
from typing import List

import logging
from operator import ge

from nodedge.blocks.block import Block, EvaluationError
from nodedge.blocks.block import Block
from nodedge.blocks.block_exception import EvaluationError
from nodedge.blocks.block_config import BLOCKS_ICONS_PATH, registerNode
from nodedge.connector import SocketType

_LOG = logging.getLogger(__name__)

Expand All @@ -16,13 +20,20 @@

@registerNode(OP_NODE_GREATER_EQUAL)
class GeBlock(Block):
icon = f"{BLOCKS_ICONS_PATH}/ge.png"
icon = f"{BLOCKS_ICONS_PATH}/more_or_equal_100.png"
operationCode = OP_NODE_GREATER_EQUAL
operationTitle = "Greater or Equal"
contentLabel = ">="
contentLabelObjectName = "BlockBackground"
evalString = "ge"
library = "operator"
inputSocketTypes: List[SocketType] = [
SocketType.Number,
SocketType.Number,
]
outputSocketTypes: List[SocketType] = [
SocketType.Number,
]

def evalImplementation(self):
inputs = []
Expand Down
15 changes: 13 additions & 2 deletions nodedge/blocks/autogen/operator/gt_block.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# -*- coding: utf-8 -*-
from typing import List

import logging
from operator import gt

from nodedge.blocks.block import Block, EvaluationError
from nodedge.blocks.block import Block
from nodedge.blocks.block_exception import EvaluationError
from nodedge.blocks.block_config import BLOCKS_ICONS_PATH, registerNode
from nodedge.connector import SocketType

_LOG = logging.getLogger(__name__)

Expand All @@ -16,13 +20,20 @@

@registerNode(OP_NODE_GREATER)
class GtBlock(Block):
icon = f"{BLOCKS_ICONS_PATH}/gt.png"
icon = f"{BLOCKS_ICONS_PATH}/more_than_100.png"
operationCode = OP_NODE_GREATER
operationTitle = "Greater"
contentLabel = ">"
contentLabelObjectName = "BlockBackground"
evalString = "gt"
library = "operator"
inputSocketTypes: List[SocketType] = [
SocketType.Number,
SocketType.Number,
]
outputSocketTypes: List[SocketType] = [
SocketType.Number,
]

def evalImplementation(self):
inputs = []
Expand Down
15 changes: 13 additions & 2 deletions nodedge/blocks/autogen/operator/le_block.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# -*- coding: utf-8 -*-
from typing import List

import logging
from operator import le

from nodedge.blocks.block import Block, EvaluationError
from nodedge.blocks.block import Block
from nodedge.blocks.block_exception import EvaluationError
from nodedge.blocks.block_config import BLOCKS_ICONS_PATH, registerNode
from nodedge.connector import SocketType

_LOG = logging.getLogger(__name__)

Expand All @@ -16,13 +20,20 @@

@registerNode(OP_NODE_LESS_EQUAL)
class LeBlock(Block):
icon = f"{BLOCKS_ICONS_PATH}/le.png"
icon = f"{BLOCKS_ICONS_PATH}/less_or_equal_100.png"
operationCode = OP_NODE_LESS_EQUAL
operationTitle = "Less or Equal"
contentLabel = "<="
contentLabelObjectName = "BlockBackground"
evalString = "le"
library = "operator"
inputSocketTypes: List[SocketType] = [
SocketType.Number,
SocketType.Number,
]
outputSocketTypes: List[SocketType] = [
SocketType.Number,
]

def evalImplementation(self):
inputs = []
Expand Down
15 changes: 13 additions & 2 deletions nodedge/blocks/autogen/operator/lt_block.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# -*- coding: utf-8 -*-
from typing import List

import logging
from operator import lt

from nodedge.blocks.block import Block, EvaluationError
from nodedge.blocks.block import Block
from nodedge.blocks.block_exception import EvaluationError
from nodedge.blocks.block_config import BLOCKS_ICONS_PATH, registerNode
from nodedge.connector import SocketType

_LOG = logging.getLogger(__name__)

Expand All @@ -16,13 +20,20 @@

@registerNode(OP_NODE_LESS)
class LtBlock(Block):
icon = f"{BLOCKS_ICONS_PATH}/lt.png"
icon = f"{BLOCKS_ICONS_PATH}/less_than_100.png"
operationCode = OP_NODE_LESS
operationTitle = "Less"
contentLabel = "<"
contentLabelObjectName = "BlockBackground"
evalString = "lt"
library = "operator"
inputSocketTypes: List[SocketType] = [
SocketType.Number,
SocketType.Number,
]
outputSocketTypes: List[SocketType] = [
SocketType.Number,
]

def evalImplementation(self):
inputs = []
Expand Down
15 changes: 13 additions & 2 deletions nodedge/blocks/autogen/operator/mod_block.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# -*- coding: utf-8 -*-
from typing import List

import logging
from operator import mod

from nodedge.blocks.block import Block, EvaluationError
from nodedge.blocks.block import Block
from nodedge.blocks.block_exception import EvaluationError
from nodedge.blocks.block_config import BLOCKS_ICONS_PATH, registerNode
from nodedge.connector import SocketType

_LOG = logging.getLogger(__name__)

Expand All @@ -16,13 +20,20 @@

@registerNode(OP_NODE_MODULO)
class ModBlock(Block):
icon = f"{BLOCKS_ICONS_PATH}/mod.png"
icon = f"{BLOCKS_ICONS_PATH}/percentage_100.png"
operationCode = OP_NODE_MODULO
operationTitle = "Modulo"
contentLabel = "%"
contentLabelObjectName = "BlockBackground"
evalString = "mod"
library = "operator"
inputSocketTypes: List[SocketType] = [
SocketType.Number,
SocketType.Number,
]
outputSocketTypes: List[SocketType] = [
SocketType.Number,
]

def evalImplementation(self):
inputs = []
Expand Down

0 comments on commit 2fbb227

Please sign in to comment.