-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from nodedge/feature/scene-coding
Feature/scene coding
- Loading branch information
Showing
60 changed files
with
874 additions
and
253 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
import os | ||
import shutil | ||
|
||
shutil.rmtree("source/apidoc") | ||
os.mkdir("source/apidoc") | ||
os.system("sphinx-apidoc -e -T -f -o source/apidoc/ -t source/_templates/ ../nodedge") | ||
os.system("make clean") | ||
os.system("make html") |
4 changes: 2 additions & 2 deletions
4
...rce/apidoc/nodedge.blocks.input_block.rst → ...rce/apidoc/nodedge.application_styler.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
nodedge.blocks.input\_block | ||
nodedge.application\_styler | ||
=========================== | ||
|
||
.. automodule:: nodedge.blocks.input_block | ||
.. automodule:: nodedge.application_styler | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
nodedge.logger | ||
============== | ||
|
||
.. automodule:: nodedge.logger | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
nodedge.scene\_coder | ||
==================== | ||
|
||
.. automodule:: nodedge.scene_coder | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import os | ||
import sys | ||
|
||
from PySide2.QtGui import QColor, QPalette | ||
from PySide2.QtWidgets import QApplication | ||
|
||
from nodedge.mdi_window import MdiWindow | ||
from nodedge.scene_coder import SceneCoder | ||
from nodedge.utils import dumpException | ||
|
||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "..")) # noqa: E402 | ||
os.environ["QT_API"] = "pyside" | ||
|
||
if __name__ == "__main__": | ||
app: QApplication = QApplication(sys.argv) | ||
|
||
QApplication.setStyle("Fusion") | ||
p = QApplication.palette() | ||
p.setColor(QPalette.Window, QColor(53, 53, 53)) | ||
p.setColor(QPalette.Button, QColor(53, 53, 53)) | ||
p.setColor(QPalette.Highlight, QColor(142, 45, 197)) | ||
p.setColor(QPalette.ButtonText, QColor(255, 255, 255)) | ||
p.setColor(QPalette.WindowText, QColor(255, 255, 255)) | ||
app.setPalette(p) | ||
|
||
window = MdiWindow() | ||
|
||
window.show() | ||
|
||
window.openFile(f"{os.path.dirname(__file__)}/calculator.json") | ||
|
||
currentScene = window.currentEditorWidget.scene | ||
coder = SceneCoder(currentScene) | ||
orderedNodeList, currentSceneCode = coder.generateCode() | ||
print(currentSceneCode) | ||
|
||
generatedFileString = coder.createFileFromGeneratedCode( | ||
orderedNodeList, currentSceneCode | ||
) | ||
|
||
try: | ||
sys.exit(app.exec_()) | ||
except Exception as e: | ||
dumpException(e) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
DEBUG_ITEMS_PRESSED: bool = True | ||
DEBUG_ITEMS_PRESSED: bool = False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,18 @@ | ||
# -*- coding: utf-8 -*- | ||
import glob | ||
from os.path import basename, dirname, isfile, join | ||
|
||
from .add_block import * | ||
from .divide_block import * | ||
from .input_block import * | ||
from .multiply_block import * | ||
from .output_block import * | ||
from .subtract_block import * | ||
from .autogen.operator.add_block import * | ||
from .autogen.operator.eq_block import * | ||
from .autogen.operator.ge_block import * | ||
from .autogen.operator.gt_block import * | ||
from .autogen.operator.le_block import * | ||
from .autogen.operator.lt_block import * | ||
from .autogen.operator.mod_block import * | ||
from .autogen.operator.mul_block import * | ||
from .autogen.operator.pow_block import * | ||
from .autogen.operator.sub_block import * | ||
from .autogen.operator.truediv_block import * | ||
from .custom.input_block import * | ||
from .custom.output_block import * | ||
|
||
# modules = glob.glob(join(dirname(__file__), "*.py")) | ||
# __all__ = [basename(f)[:-3] for f in modules if isfile(f) and f.endswith('_block.py')] |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from operator import eq | ||
|
||
from nodedge.blocks.block import Block, EvaluationError | ||
from nodedge.blocks.block_config import BLOCKS_ICONS_PATH, registerNode | ||
|
||
try: | ||
from nodedge.blocks.block_config import OP_NODE_EQUAL | ||
except: | ||
op_block_string = -1 | ||
|
||
|
||
@registerNode(OP_NODE_EQUAL) | ||
class EqBlock(Block): | ||
icon = f"{BLOCKS_ICONS_PATH}/eq.png" | ||
operationCode = OP_NODE_EQUAL | ||
operationTitle = "Equal" | ||
contentLabel = "==" | ||
contentLabelObjectName = "BlockBackground" | ||
evalString = "eq" | ||
library = "operator" | ||
|
||
def evalImplementation(self): | ||
inputs = [] | ||
for i in range(len(self.inputSockets)): | ||
inputs.append(self.inputNodeAt(i)) | ||
|
||
try: | ||
evaluatedInputs = [str(currentInput.eval()) for currentInput in inputs] | ||
operation = f"{EqBlock.evalString}({', '.join(evaluatedInputs)})" | ||
result = eval(operation) | ||
except TypeError as e: | ||
raise EvaluationError(e) | ||
|
||
self.value = result | ||
|
||
return self.value |
Oops, something went wrong.