rewrote instruction classes

This commit is contained in:
weckyy702
2021-04-25 14:21:54 +02:00
parent d8dde66d78
commit 45cb5c0467
3 changed files with 140 additions and 193 deletions

View File

@@ -39,12 +39,12 @@ class NassiShneidermanDiagram:
@staticmethod
def _save_scope(scope: Function_scope, output_path: str):
x_size = scope.get_width()
y_size = scope.get_height()
with NSD_writer(output_path, x_size, y_size):
x, y = 0, 0
width = scope.get_width()
height = scope.get_height()
with NSD_writer(output_path, width, height):
y = 0
for instruction in scope:
x, y = instruction.to_image(x, y, x_size)[0:2]
y = instruction.convert_to_image(0, y, width)
@staticmethod
def check_conflicts(filepath:str, behavoiur: Overwrite_behaviour):

View File

@@ -3,7 +3,7 @@
__author__ = "Weckyy702"
from typing import Iterable, List
from draw.Iinstruction import Iinstruction
from draw.Iinstruction import instruction
class Function_scope(Iterable):
"""This class serves as a container for Instructions"""
@@ -17,19 +17,19 @@ class Function_scope(Iterable):
def get_height(self) -> int:
h = 0.0
for inst in self.contents:
h += inst.getblkheight()
h += inst.get_block_height()
return int(h)
def get_width(self) -> int:
w = 200.0 #minimum width for every block
w = 200 #minimum width for every block
for inst in self.contents:
w = max(w, inst.getblkwidth())
return int(w)
w = max(w, inst.get_block_width())
return w
def _add_instruction(self, inst: Iinstruction):
def _add_instruction(self, inst: instruction):
self.contents.append(inst)
def _add_instructions(self, inst: List[Iinstruction]):
def _add_instructions(self, inst: List[instruction]):
self.contents.extend(inst)
def __iter__(self):