Browse Source

Various patches to make rendering work

Yentl Van Tendeloo 8 years ago
parent
commit
1a8775d85a
4 changed files with 92 additions and 67 deletions
  1. 4 4
      integration/code/cbd_design.mvc
  2. 45 20
      integration/test_mvc.py
  3. 38 38
      models/CBD_mapper.mvc
  4. 5 5
      models/MM_rendered_graphical.mvc

+ 4 - 4
integration/code/cbd_design.mvc

@@ -2,9 +2,9 @@ import models/SimpleClassDiagrams as SCD
 include "primitives.alh"
 include "primitives.alh"
 
 
 SCD CausalBlockDiagrams_Design{
 SCD CausalBlockDiagrams_Design{
-    AttributeValue Float {
+    SimpleAttribute Float {
         constraint = $
         constraint = $
-            String constraint(model : Element, name : String):
+            String function constraint(model : Element, name : String):
                 if (bool_not(is_physical_float(model["model"][name]))):
                 if (bool_not(is_physical_float(model["model"][name]))):
                     return "Float has no float value"!
                     return "Float has no float value"!
                 else:
                 else:
@@ -12,9 +12,9 @@ SCD CausalBlockDiagrams_Design{
             $
             $
     }
     }
 
 
-    AttributeValue String {
+    SimpleAttribute String {
         constraint = $
         constraint = $
-            String constraint(model : Element, name : String):
+            String function constraint(model : Element, name : String):
                 if (bool_not(is_physical_string(model["model"][name]))):
                 if (bool_not(is_physical_string(model["model"][name]))):
                     return "String has no string value"!
                     return "String has no string value"!
                 else:
                 else:

+ 45 - 20
integration/test_mvc.py

@@ -1991,12 +1991,27 @@ class TestModelverseCore(unittest.TestCase):
                     "SimpleClassDiagrams",
                     "SimpleClassDiagrams",
                     "MM_rendered_graphical",
                     "MM_rendered_graphical",
                     ] + get_model_constructor(open("models/MM_rendered_graphical.mvc", "r").read()) + [
                     ] + get_model_constructor(open("models/MM_rendered_graphical.mvc", "r").read()) + [
+                "model_add",
+                    "CausalBlockDiagrams",
+                    "my_CBD",
+                    ] + get_model_constructor(open("integration/code/my_cbd.mvc", "r").read()) + [
                 "model_list",
                 "model_list",
                 "transformation_add_MT_language",
                 "transformation_add_MT_language",
                 "CausalBlockDiagrams",
                 "CausalBlockDiagrams",
                 "MM_rendered_graphical",
                 "MM_rendered_graphical",
                 "",
                 "",
                 "CBD_RAM",
                 "CBD_RAM",
+                "model_modify",
+                    "__merged_CBD_RAM",
+                        "instantiate",
+                            "Association",
+                            "Tracability",
+                            "CausalBlockDiagrams/Block",
+                            "MM_rendered_graphical/Group",
+                        "exit",
+                "transformation_RAMify",
+                    "__merged_CBD_RAM",
+                    "CBD_RAM",
                 "transformation_add_MT",
                 "transformation_add_MT",
                     "CBD_RAM",
                     "CBD_RAM",
                     "CausalBlockDiagrams",
                     "CausalBlockDiagrams",
@@ -2007,10 +2022,6 @@ class TestModelverseCore(unittest.TestCase):
                     "render_graphical_CBD",
                     "render_graphical_CBD",
                     ] + get_model_constructor(open("models/CBD_mapper.mvc", "r").read()) + [
                     ] + get_model_constructor(open("models/CBD_mapper.mvc", "r").read()) + [
                 "model_list",
                 "model_list",
-                "model_add",
-                    "CausalBlockDiagrams",
-                    "my_CBD",
-                    ] + get_model_constructor(open("integration/code/my_cbd.mvc", "r").read()) + [
                 "model_render",
                 "model_render",
                     "my_CBD",
                     "my_CBD",
                     "render_graphical_CBD",
                     "render_graphical_CBD",
@@ -2044,10 +2055,35 @@ class TestModelverseCore(unittest.TestCase):
                 "Waiting for model constructors...",
                 "Waiting for model constructors...",
                 "Model upload success!",
                 "Model upload success!",
                 "Ready for command...",
                 "Ready for command...",
+                # model_list
+                set(model_list) |
+                set([
+                    "  CausalBlockDiagrams : SimpleClassDiagrams",
+                    "  MM_rendered_graphical : SimpleClassDiagrams",
+                    "  my_CBD : CausalBlockDiagrams",
+                    ]),
+                "Ready for command...",
                 # transformation_add_MT_language
                 # transformation_add_MT_language
                 "Formalisms to include (terminate with empty string)?",
                 "Formalisms to include (terminate with empty string)?",
                 "Name of the RAMified transformation metamodel?",
                 "Name of the RAMified transformation metamodel?",
                 "Ready for command...",
                 "Ready for command...",
+                # model_modify
+                "Which model do you want to modify?",
+                "Model loaded, ready for commands!",
+                "Use 'help' command for a list of possible commands",
+                "Please give your command.",
+                    # instantiate
+                    "Type to instantiate?",
+                    "Name of new element?",
+                    "Source name?",
+                    "Destination name?",
+                    "Instantiation successful!",
+                    "Please give your command.",
+                "Ready for command...",
+                # transformation_RAMify
+                "Which metamodel do you want to RAMify?",
+                "Where do you want to store the RAMified metamodel?",
+                "Ready for command...",
                 # transformation_add_MT
                 # transformation_add_MT
                 "RAMified metamodel to use?",
                 "RAMified metamodel to use?",
                 "Supported metamodels:",
                 "Supported metamodels:",
@@ -2062,24 +2098,13 @@ class TestModelverseCore(unittest.TestCase):
                 # model_list
                 # model_list
                 set(model_list) |
                 set(model_list) |
                 set([
                 set([
-                     "  PetriNet : SimpleClassDiagrams",
-                     "  ReachabilityGraph : SimpleClassDiagrams",
-                     "  initialize_PN : PetriNet_RAM",
-                     "  refine_PN : ManualOperation",
-                     "  reachability : ActionLanguage",
-                     "  reachability_print : ReachabilityGraph_RAM",
-                     "  pn_reachability : ProcessModel",
-                     "  PetriNet_RAM : SimpleClassDiagrams",
-                     "  ReachabilityGraph_RAM : SimpleClassDiagrams",
-                     "  __merged_PetriNet_RAM : SimpleClassDiagrams",
-                     "  __merged_ReachabilityGraph_RAM : SimpleClassDiagrams",
-                     "  __merged_refine_PN : SimpleClassDiagrams",
-                     "  __merged_reachability : SimpleClassDiagrams",
+                    "  CausalBlockDiagrams : SimpleClassDiagrams",
+                    "  MM_rendered_graphical : SimpleClassDiagrams",
+                    "  CBD_RAM : SimpleClassDiagrams",
+                    "  my_CBD : CausalBlockDiagrams",
+                    "  render_graphical_CBD : CBD_RAM",
                      ]),
                      ]),
                 "Ready for command...",
                 "Ready for command...",
                 # model_render
                 # model_render
                 "",
                 "",
-                "",
-                "",
-                "",
             ]))
             ]))

+ 38 - 38
models/CBD_mapper.mvc

@@ -8,75 +8,75 @@ A B {
 
 
         {Contains} ForAll render_blocks {
         {Contains} ForAll render_blocks {
             LHS {
             LHS {
-                Pre_CBD/Block pre_block_0 {
+                Pre_CausalBlockDiagrams/Block pre_block_0 {
                     label = "0"
                     label = "0"
                 }
                 }
             }
             }
             RHS {
             RHS {
-                Post_CBD/Block post_block_0 {
+                Post_CausalBlockDiagrams/Block post_block_0 {
                     label = "0"
                     label = "0"
                 }
                 }
-                Post_Rendered/Group post_block_1 {
+                Post_MM_rendered_graphical/Group post_block_1 {
                     label = "1"
                     label = "1"
-                    post_x = $
+                    value_x = $
                         Integer function value(model : Element, name : String, mapping : Element):
                         Integer function value(model : Element, name : String, mapping : Element):
                             return 0!
                             return 0!
                         $
                         $
-                    post_y = $
+                    value_y = $
                         Integer function value(model : Element, name : String, mapping : Element):
                         Integer function value(model : Element, name : String, mapping : Element):
                             return 0!
                             return 0!
                         $
                         $
                 }
                 }
-                Post_Rendered/Rectangle post_block_2 {
+                Post_MM_rendered_graphical/Rectangle post_block_2 {
                     label = "2"
                     label = "2"
-                    post_x = $
+                    value_x = $
                         Integer function value(model : Element, name : String, mapping : Element):
                         Integer function value(model : Element, name : String, mapping : Element):
                             return 0!
                             return 0!
                         $
                         $
-                    post_y = $
+                    value_y = $
                         Integer function value(model : Element, name : String, mapping : Element):
                         Integer function value(model : Element, name : String, mapping : Element):
                             return 0!
                             return 0!
                         $
                         $
-                    post_width = $
+                    value_width = $
                         Integer function value(model : Element, name : String, mapping : Element):
                         Integer function value(model : Element, name : String, mapping : Element):
                             return 10!
                             return 10!
                         $
                         $
-                    post_height = $
+                    value_height = $
                         Integer function value(model : Element, name : String, mapping : Element):
                         Integer function value(model : Element, name : String, mapping : Element):
                             return 10!
                             return 10!
                         $
                         $
-                    post_lineWidth = $
+                    value_lineWidth = $
                         Integer function value(model : Element, name : String, mapping : Element):
                         Integer function value(model : Element, name : String, mapping : Element):
                             return 2!
                             return 2!
                         $
                         $
-                    post_lineColour = $
+                    value_lineColour = $
                         String function value(model : Element, name : String, mapping : Element):
                         String function value(model : Element, name : String, mapping : Element):
                             return "black"!
                             return "black"!
                         $
                         $
-                    post_fillColour = $
+                    value_fillColour = $
                         String function value(model : Element, name : String, mapping : Element):
                         String function value(model : Element, name : String, mapping : Element):
                             return "white"!
                             return "white"!
                         $
                         $
                 }
                 }
-                Post_Rendered/Text post_block_3 {
+                Post_MM_rendered_graphical/Text post_block_3 {
                     label = "3"
                     label = "3"
-                    post_x = $
+                    value_x = $
                         Integer function value(model : Element, name : String, mapping : Element):
                         Integer function value(model : Element, name : String, mapping : Element):
                             return 10!
                             return 10!
                         $
                         $
-                    post_y = $
+                    value_y = $
                         Integer function value(model : Element, name : String, mapping : Element):
                         Integer function value(model : Element, name : String, mapping : Element):
                             return 10!
                             return 10!
                         $
                         $
-                    post_lineWidth = $
+                    value_lineWidth = $
                         Integer function value(model : Element, name : String, mapping : Element):
                         Integer function value(model : Element, name : String, mapping : Element):
                             return 1!
                             return 1!
                         $
                         $
-                    post_lineColour = $
+                    value_lineColour = $
                         String function value(model : Element, name : String, mapping : Element):
                         String function value(model : Element, name : String, mapping : Element):
                             return "black"!
                             return "black"!
                         $
                         $
-                    post_content = $
+                    value_content = $
                         String function value(model : Element, name : String, mapping : Element):
                         String function value(model : Element, name : String, mapping : Element):
                             String type
                             String type
                             type = read_type(model, name)
                             type = read_type(model, name)
@@ -98,8 +98,8 @@ A B {
                                 return "PROBE"!
                                 return "PROBE"!
                         $
                         $
                 }
                 }
-                Post_Rendered/contains (post_block_1, post_block2) {}
-                Post_Rendered/contains (post_block_1, post_block3) {}
+                Post_MM_rendered_graphical/contains (post_block_1, post_block2) {}
+                Post_MM_rendered_graphical/contains (post_block_1, post_block3) {}
 
 
                 Post_Tracability (post_block_0, post_block_1) {}
                 Post_Tracability (post_block_0, post_block_1) {}
             }
             }
@@ -107,23 +107,23 @@ A B {
 
 
         {Contains} ForAll render_connections {
         {Contains} ForAll render_connections {
             LHS {
             LHS {
-                Pre_CBD/Block pre_conn_0 {
+                Pre_CausalBlockDiagrams/Block pre_conn_0 {
                     label = "0"
                     label = "0"
                 }
                 }
 
 
-                Pre_CBD/Block pre_conn_1 {
+                Pre_CausalBlockDiagrams/Block pre_conn_1 {
                     label = "1"
                     label = "1"
                 }
                 }
 
 
-                Pre_CBD/Link (pre_conn_0, pre_conn_1){
+                Pre_CausalBlockDiagrams/Link (pre_conn_0, pre_conn_1){
                     label = "2"
                     label = "2"
                 }
                 }
 
 
-                Pre_Rendered/Group pre_conn_3 {
+                Pre_MM_rendered_graphical/Group pre_conn_3 {
                     label = "3"
                     label = "3"
                 }
                 }
 
 
-                Pre_Rendered/Group pre_conn_4 {
+                Pre_MM_rendered_graphical/Group pre_conn_4 {
                     label = "4"
                     label = "4"
                 }
                 }
 
 
@@ -131,55 +131,55 @@ A B {
                 Pre_Tracability (pre_conn_0, pre_conn_4) {}
                 Pre_Tracability (pre_conn_0, pre_conn_4) {}
             }
             }
             RHS {
             RHS {
-                Post_CBD/Block post_conn_0 {
+                Post_CausalBlockDiagrams/Block post_conn_0 {
                     label = "0"
                     label = "0"
                 }
                 }
 
 
-                Post_CBD/Block post_conn_1 {
+                Post_CausalBlockDiagrams/Block post_conn_1 {
                     label = "1"
                     label = "1"
                 }
                 }
 
 
-                Post_CBD/Link (post_conn_0, post_conn_1){
+                Post_CausalBlockDiagrams/Link (post_conn_0, post_conn_1){
                     label = "2"
                     label = "2"
                 }
                 }
 
 
-                Post_Rendered/Group post_conn_3 {
+                Post_MM_rendered_graphical/Group post_conn_3 {
                     label = "3"
                     label = "3"
                 }
                 }
 
 
-                Post_Rendered/Group post_conn_4 {
+                Post_MM_rendered_graphical/Group post_conn_4 {
                     label = "4"
                     label = "4"
                 }
                 }
 
 
                 Post_Tracability (post_conn_0, post_conn_3) {}
                 Post_Tracability (post_conn_0, post_conn_3) {}
                 Post_Tracability (post_conn_0, post_conn_4) {}
                 Post_Tracability (post_conn_0, post_conn_4) {}
 
 
-                Post_Rendered/Link {
+                Post_MM_rendered_graphical/Line {
                     label = "5"
                     label = "5"
-                    post_x = $
+                    value_x = $
                         Integer function value(model : Element, name : String, mapping : Element):
                         Integer function value(model : Element, name : String, mapping : Element):
                             return read_attribute(model, mapping["3"], "x")!
                             return read_attribute(model, mapping["3"], "x")!
                         $
                         $
-                    post_y = $
+                    value_y = $
                         Integer function value(model : Element, name : String, mapping : Element):
                         Integer function value(model : Element, name : String, mapping : Element):
                             return read_attribute(model, mapping["3"], "y")!
                             return read_attribute(model, mapping["3"], "y")!
                         $
                         $
-                    post_lineWidth = $
+                    value_lineWidth = $
                         Integer function value(model : Element, name : String, mapping : Element):
                         Integer function value(model : Element, name : String, mapping : Element):
                             return 1!
                             return 1!
                         $
                         $
-                    post_lineColour = $
+                    value_lineColour = $
                         String function value(model : Element, name : String, mapping : Element):
                         String function value(model : Element, name : String, mapping : Element):
                             if (read_type(model, name) == "ICLink"):
                             if (read_type(model, name) == "ICLink"):
                                 return "red"!
                                 return "red"!
                             else:
                             else:
                                 return "black"!
                                 return "black"!
                         $
                         $
-                    post_targetX = $
+                    value_targetX = $
                         Integer function value(model : Element, name : String, mapping : Element):
                         Integer function value(model : Element, name : String, mapping : Element):
                             return read_attribute(model, mapping["4"], "x")!
                             return read_attribute(model, mapping["4"], "x")!
                         $
                         $
-                    post_targetY = $
+                    value_targetY = $
                         Integer function value(model : Element, name : String, mapping : Element):
                         Integer function value(model : Element, name : String, mapping : Element):
                             return read_attribute(model, mapping["4"], "y")!
                             return read_attribute(model, mapping["4"], "y")!
                         $
                         $

+ 5 - 5
models/MM_rendered_graphical.mvc

@@ -4,15 +4,15 @@ SimpleClassDiagram MM_rendered_graphical{
     SimpleAttribute Natural {}
     SimpleAttribute Natural {}
     SimpleAttribute String {}
     SimpleAttribute String {}
 
 
-    Class Element {
+    Class GraphicalElement {
         x : Natural
         x : Natural
         y : Natural
         y : Natural
     }
     }
 
 
-    Class Group : Element {
+    Class Group : GraphicalElement {
     }
     }
 
 
-    Class LineElement : Element {
+    Class LineElement : GraphicalElement {
         lineWidth : Natural
         lineWidth : Natural
         lineColour : String
         lineColour : String
     }
     }
@@ -32,7 +32,7 @@ SimpleClassDiagram MM_rendered_graphical{
         height : Natural
         height : Natural
     }
     }
 
 
-    Class Figure : Element {
+    Class Figure : GraphicalElement {
         width : Natural
         width : Natural
         height : Natural
         height : Natural
     }
     }
@@ -50,7 +50,7 @@ SimpleClassDiagram MM_rendered_graphical{
     Class Polygon : Shape {
     Class Polygon : Shape {
     }
     }
 
 
-    Association contains (Group, Element) {}
+    Association contains (Group, GraphicalElement) {}
     Association renders (Figure, SVG) {
     Association renders (Figure, SVG) {
         source_lower_cardinality = 1
         source_lower_cardinality = 1
         target_lower_cardinality = 1
         target_lower_cardinality = 1