Explorar el Código

Several fixes to the concrete syntax mapper for CBDs: update AS identifier as well

Yentl Van Tendeloo hace 8 años
padre
commit
41c99bebea
Se han modificado 2 ficheros con 45 adiciones y 11 borrados
  1. 3 10
      interface/graphical/main.py
  2. 42 1
      models/CBD_mapper.mvc

+ 3 - 10
interface/graphical/main.py

@@ -71,7 +71,6 @@ class Window(object):
         self.canvas.bind("<Button-1>", self.left_clicked)
         self.canvas.bind("<B1-Motion>", self.left_drag)
         self.canvas.bind("<ButtonRelease-1>", self.left_released)
-        self.canvas.bind("<Button-2>", self.middle_clicked)
         self.canvas.bind("<Button-3>", self.right_clicked)
 
     def find_AS(self, x, y):
@@ -131,7 +130,7 @@ class Window(object):
             attr_assign(rendered_formula(self.selected_model.get(), self.selected_mapper.get()), self.AS_to_CS[self.current_element], "x", attrs["x"] + d_x)
             attr_assign(rendered_formula(self.selected_model.get(), self.selected_mapper.get()), self.AS_to_CS[self.current_element], "y", attrs["y"] + d_y)
 
-    def middle_clicked(self, evt):
+    def right_clicked(self, evt):
         # Middle clicked means we are modifying attributes of something
         x, y = evt.x, evt.y
 
@@ -155,13 +154,6 @@ class Window(object):
                 else:
                     attr_assign(self.selected_model.get(), as_id, k, v)
 
-    def right_clicked(self, evt):
-        # Right clicked means we are creating something
-        x, y = evt.x, evt.y
-
-        # Instantiate new element of currently using element
-        pass
-
     def visualize(self, model):
         cache = {}
         hierarchy = {}
@@ -273,7 +265,8 @@ class Window(object):
 
     def create_element(self, t):
         def create_elem():
-            print("Create element of type " + str(t))
+            instantiate(self.selected_model.get(), t)
+            self.render_model()
         return create_elem
 
     def render_model(self):

+ 42 - 1
models/CBD_mapper.mvc

@@ -6,6 +6,44 @@ Composite schedule {
     {Contains} Success success {}
     {Contains} Failure failure {}
 
+    {Contains} ForAll update_blocks {
+        LHS {
+            Pre_abstract/Block pre_update_0 {
+                label = "0"
+            }
+            Pre_rendered/Group pre_update_1 {
+                label = "1"
+            }
+            Pre_TracabilityLink (pre_update_0, pre_update_1){
+                label = "2"
+            }
+        }
+        RHS {
+            Post_abstract/Block post_update_0 {
+                label = "0"
+            }
+            Post_rendered/Group post_update_1 {
+                label = "1"
+                value___asid = $
+                    String function value(model : Element, name : String, mapping : Element):
+                        // Update the mapping!
+                        return mapping["0"]!
+                    $
+                value_x = $
+                    Integer function value(model : Element, name : String, mapping : Element):
+                        return read_attribute(model, name, "x")!
+                    $
+                value_y = $
+                    Integer function value(model : Element, name : String, mapping : Element):
+                        return read_attribute(model, name, "y")!
+                    $
+            }
+            Post_TracabilityLink (post_update_0, post_update_1){
+                label = "2"
+            }
+        }
+    }
+
     {Contains} ForAll render_blocks {
         LHS {
             Pre_abstract/Block pre_block_0 {
@@ -235,7 +273,10 @@ Composite schedule {
     }
 }
 
-Initial (schedule, render_blocks) {}
+Initial (schedule, update_blocks) {}
+
+OnSuccess (update_blocks, render_blocks) {}
+OnFailure (update_blocks, render_blocks) {}
 
 OnSuccess (render_blocks, remove_connections) {}
 OnFailure (render_blocks, remove_connections) {}