Quellcode durchsuchen

Semi-working connecting lines and rerenders

Yentl Van Tendeloo vor 8 Jahren
Ursprung
Commit
9910efbab8
3 geänderte Dateien mit 25 neuen und 8 gelöschten Zeilen
  1. 4 0
      classes/canvas/canvas.xml
  2. 5 1
      frontend.py
  3. 16 7
      models/render_SCD.alc

+ 4 - 0
classes/canvas/canvas.xml

@@ -28,6 +28,7 @@
             self.element_group = {}
             self.group_location = {}
             self.connecting_lines = {}
+            self.lines = set()
         </body>
     </constructor>
     <destructor>
@@ -52,6 +53,8 @@
                 </raise>
                 <script>
                     self.shift = {}
+                    for l in self.lines:
+                        self.delete(l)
                 </script>
             </transition>
 
@@ -98,6 +101,7 @@
 
                     line = self.create_line(source_x, source_y, target_x, target_y, fill=element['lineColour'], width=element['lineWidth'], arrow=tk.LAST if element['arrow'] else tk.NONE)
                     element['elem'] = line
+                    self.lines.add(line)
                 </script>
             </transition>
 

+ 5 - 1
frontend.py

@@ -1,7 +1,7 @@
 """
 Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
 
-Date:   Wed Sep 27 16:23:55 2017
+Date:   Wed Sep 27 16:45:58 2017
 
 Model author: Yentl Van Tendeloo
 Model name:   Modelverse Visual Editor - Tkinter Version 
@@ -5654,6 +5654,7 @@ class Canvas(RuntimeClassBase, tk.Canvas, SCCDWidget):
         self.element_group = {}
         self.group_location = {}
         self.connecting_lines = {}
+        self.lines = set()
     
     def user_defined_destructor(self):
         self.destroy()
@@ -5732,6 +5733,8 @@ class Canvas(RuntimeClassBase, tk.Canvas, SCCDWidget):
     def _ready_0_exec(self, parameters):
         self.big_step.outputEventOM(Event("delete_instance", None, [self, 'elements']))
         self.shift = {}
+        for l in self.lines:
+            self.delete(l)
     
     def _ready_1_exec(self, parameters):
         element = parameters[0]
@@ -5763,6 +5766,7 @@ class Canvas(RuntimeClassBase, tk.Canvas, SCCDWidget):
         
         line = self.create_line(source_x, source_y, target_x, target_y, fill=element['lineColour'], width=element['lineWidth'], arrow=tk.LAST if element['arrow'] else tk.NONE)
         element['elem'] = line
+        self.lines.add(line)
     
     def _ready_4_guard(self, parameters):
         element = parameters[0]

+ 16 - 7
models/render_SCD.alc

@@ -21,6 +21,11 @@ Boolean function main(model : Element):
 	while (set_len(elements) > 0):
 		class = set_pop(elements)
 		
+		Integer x
+		Integer y
+		x = loc
+		y = 10
+
 		// Check if there is already an associated element
 		if (set_len(allOutgoingAssociationInstances(model, class, "TracabilityClass")) > 0):
 			// Yes, but is it still clean?
@@ -48,6 +53,8 @@ Boolean function main(model : Element):
 				while (set_len(related_groups) > 0):
 					group = set_pop(related_groups)
 					to_remove = allAssociationDestinations(model, group, "rendered/contains")
+					x = read_attribute(model, group, "x")
+					y = read_attribute(model, group, "y")
 					while (set_len(to_remove) > 0):
 						elem_to_remove = set_pop(to_remove)
 						if (read_type(model, elem_to_remove) == "rendered/Group"):
@@ -59,8 +66,8 @@ Boolean function main(model : Element):
 		text_loc = 5
 
 		group = instantiate_node(model, "rendered/Group", "")
-		instantiate_attribute(model, group, "x", loc)
-		instantiate_attribute(model, group, "y", 10)
+		instantiate_attribute(model, group, "x", x)
+		instantiate_attribute(model, group, "y", y)
 		instantiate_attribute(model, group, "__asid", list_read(string_split(class, "/"), 1))
 		dict_add(groups, class, group)
 		loc = loc + 200
@@ -121,12 +128,16 @@ Boolean function main(model : Element):
 
 		instantiate_link(model, "TracabilityClass", "", class, group)
 
-	elements = allInstances(model, "abstract/Association")
+	// Flush all associations
+	elements = allInstances(model, "rendered/ConnectingLine")
 	while (set_len(elements) > 0):
 		class = set_pop(elements)
+		model_delete_element(model, class)
 
-		if (set_len(allOutgoingAssociationInstances(model, class, "TracabilityAssociation")) > 0):
-			continue!
+	// Rerender associations
+	elements = allInstances(model, "abstract/Association")
+	while (set_len(elements) > 0):
+		class = set_pop(elements)
 
 		attr_keys = dict_keys(getAttributeList(model, class))
 
@@ -141,6 +152,4 @@ Boolean function main(model : Element):
 		instantiate_attribute(model, elem, "__asid", list_read(string_split(class, "/"), 1))
 		instantiate_link(model, "rendered/contains", "", group, elem)
 
-		instantiate_link(model, "TracabilityAssociation", "", class, elem)
-
 	return True!