Example #1
0
    def __init__(self):
        QtWidgets.QMainWindow.__init__(self)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        self.ontology_name = getOntologyName(task="task_entity_generation")
        self.ontology_dir = DIRECTORIES[
            "ontology_location"] % self.ontology_name
        self.ontology_file = FILES["ontology_file"] % self.ontology_name

        roundButton(self.ui.pushInfo, "info", tooltip="information")
        roundButton(self.ui.pushSave,
                    "save",
                    tooltip="save ProMo base ontology")
        roundButton(self.ui.pushGraphNode, "dot_graph", tooltip="show graph")

        checkAndFixResources(self.ontology_name, stage="ontology_stage_2")

        self.ontology_container = OntologyContainer(self.ontology_name)
        self.incidence_dictionary, self.inv_incidence_dictionary = makeIncidenceDictionaries(
            self.ontology_container.variables)

        self.reduced_network_node_list = self.ontology_container.list_reduced_network_node_objects  #__makeNodeLists()
        self.reduced_arc_list = self.ontology_container.list_reduced_network_arc_objects  # self.__makeArcLists()

        self.radio_selectors = {}
        self.__makeCombosNetworks()

        self.current_equation_IDs = {
        }  # hash: radio button index     value: equation_ID_str
        self.ui.tabWidget.setCurrentIndex(0)
        self.current_tab = 0
        self.tabs = ["node", "arc", "intra", "inter"]

        self.selected_node = None
        self.selected_arc = None
        self.selected_intra = None
        self.selected_inter = None
        self.selected_arc_network = None
        self.selected_node_network = None

        self.assignments = {}

        self.__makeEquationList()
Example #2
0
    def __init__(self):
        QtWidgets.QMainWindow.__init__(self)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        roundButton(self.ui.pushSave, "save", tooltip="save to file")
        roundButton(self.ui.pushAddTypedToken,
                    "plus",
                    tooltip="add typed token")
        roundButton(self.ui.pushSaveAndExit, "exit", tooltip="exit")

        # attach ontology
        ontology_name = getOntologyName(task="task_typed_tokens")
        ontology = OntologyContainer(
            ontology_name)  # DIRECTORIES["ontology_location"] % ontology_name)
        self.networks = ontology.list_leave_networks

        self.typed_token_file_spec = FILES["typed_token_file"] % ontology_name

        self.DATA = TypedTokenData()

        typed_tokens = []
        self.instances = {}
        for nw in self.networks:
            for token in ontology.token_typedtoken_on_networks[nw]:
                for typed_token in ontology.token_typedtoken_on_networks[nw][
                        token]:
                    typed_tokens.append(typed_token)
                    # self.instances[typed_token] = INSTANCES

        self.DATA.initialise(typed_tokens)
        self.__interfaceLogics("start")
        self.new = False
        self.selected_typed_token_class = None
        gotten = self.load()
        if gotten:
            self.__interfaceLogics("loaded")
        else:
            self.__interfaceLogics("start")
            typed_tokens_class = self.__makeTokenWithTypedTokensCombo()
            self.new = True
            self.__interfaceLogics("new")
Example #3
0
  def __init__(self):
    QtGui.QMainWindow.__init__(self)
    self.ui = Ui_MainWindow()
    self.ui.setupUi(self)

    self.ontology_name = getOntologyName()
    self.ontology = OntologyContainer(self.ontology_name)
    self.ontology_location = self.ontology.onto_path

    models_file = DIRECTORIES["model_library_location"] % self.ontology_name
    self.mod_name = afm(models_file)[0]
    # self.model_loc = '{}/models/{}'.format(self.ontology_location, self.mod_name)
    # print('JALLA')

    self.ui.ontology_name_label.setText('{}'.format(self.ontology_name))
    self.ui.model_name_label.setText('{}'.format(self.mod_name))

    self.model_loc = DIRECTORIES["model_location"] % (self.ontology_name, self.mod_name)

    self.cases_location = DIRECTORIES["cases_location"] % (self.ontology_name,
                                                           self.mod_name)
    self.case_name, new_case = afc(self.cases_location, alternative = False)

    # self.model = path.join(models_file, self.mod_name)

    # self.model_file_name = '{}.json'.format(self.mod_name)

    self.fill_language_selection()
    # message = '<b>Set up</b> <br />Ontology: {}<br />Model: {}'
    # display = message.format(self.ontology_name, self.mod_name)
    # self.ui.message_box.setText(display)
    # self.language = None
    # self.already_compiled = self.check_for_model_existance()
    # if not self.already_compiled:
      # self.setup_new_model_structure()
    # self.upload_topology()

    self.mr = ModelRenderer(self.ontology, self.mod_name, self.case_name)
    def __init__(self):
        QtWidgets.QMainWindow.__init__(self)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        self.ontology_name = getOntologyName(task="task_entity_generation")
        self.ontology_dir = DIRECTORIES[
            "ontology_location"] % self.ontology_name
        self.ontology_file = FILES["ontology_file"] % self.ontology_name

        checkAndFixResources(self.ontology_name, stage="ontology_stage_2")

        self.ontology_container = OntologyContainer(self.ontology_name)
        self.ontology_tree = self.ontology_container.ontology_tree
        self.interfaces = self.ontology_container.interfaces
        self.variables = self.ontology_container.variables  # readVariables()
        self.indices = self.ontology_container.indices
        self.incidence_dictionary, self.inv_incidence_dictionary = makeIncidenceDictionaries(
            self.variables)

        self.equation_dictionary = {}
        self.__makeEquationDictionary()
        self.equation_assignment = self.ontology_container.equation_assignment

        self.radio_selectors = {}

        self.current_component = None  # node or arc

        self.current_equation_IDs = {
        }  # hash: radio button index     value: equation_ID_str

        self.current_node_network = None
        self.previous_node_network = None
        self.current_node_variable_class = None
        self.selected_node_key = None
        self.current_node_equation = None

        self.current_arc_network = None
        self.previous_arc_network = None
        self.current_arc_variable_class = None
        self.selected_arc_key = None
        self.current_arc_equation = None

        self.current_interface_network = None
        self.previous_interface_network = None
        self.current_interface_variable_class = None
        self.selected_interface_key = None
        self.current_interface_equation = None

        self.node_indicator_item = None
        self.last_node_coordinate = None
        self.arc_indicator_item = None
        self.last_arc_coordinate = None
        self.intra_indicator_item = None
        self.last_interface_coordinate = None
        self.inter_indicator_item = None
        self.last_inter_coordinate = None

        self.node_table_objects = {}
        self.arc_table_objects = {}
        self.intra_table_objects = {}
        self.inter_table_objects = {}

        # icons
        self.icons = {
            "edit": QtGui.QIcon("%s/edit.png" % DIRECTORIES["icon_location"]),
            "OK": QtGui.QIcon("%s/accept.png" % DIRECTORIES["icon_location"]),
            "back": QtGui.QIcon("%s/back.png" % DIRECTORIES["icon_location"]),
            "left":
            QtGui.QIcon("%s/left-icon.png" % DIRECTORIES["icon_location"]),
        }

        self.__makeEmptyDataStructures()
Example #5
0
    def __init__(self, icon_f):

        super().__init__()
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        roundButton(self.ui.pushButtonInformation,
                    "info",
                    tooltip="information")
        roundButton(self.ui.pushButtonSave,
                    "save",
                    tooltip="save entity behaviour")
        roundButton(self.ui.pushButtonCancel,
                    "exit",
                    tooltip="cancel and exit")
        roundButton(self.ui.pushButtonDelete,
                    "delete",
                    tooltip="delete current var/eq tree")
        roundButton(self.ui.pushButtonMakeLatex,
                    "LaTex",
                    tooltip="make latex files for all objects")
        roundButton(self.ui.pushButtonViewLatex,
                    "variable_show",
                    tooltip="show latex")
        roundButton(self.ui.pushButtonUpdate, "update", tooltip="update tree")

        self.ui.groupBoxControls.hide()
        self.ui.pushButtonLeft.hide()
        self.ui.pushButtonRight.hide()
        self.ui.pushButtonMakeLatex.hide()
        self.ui.pushButtonViewLatex.hide()

        # output streaming
        REDIRECT_STDOUT = True
        REDIRECT_ERROR = True

        stdOut = Redirect(self.ui.msgTextBoxStandardOut)
        stdOut.home()
        stdError = Redirect(self.ui.msgTextBoxErrorOut)
        stdError.home()
        if REDIRECT_STDOUT:
            sys.stdout = Stream(newText=stdOut.update)
        if REDIRECT_ERROR:
            sys.stderr = Stream(newText=stdError.update)

        # first get ontology
        self.ontology_name = getOntologyName(task=icon_f)

        # check for infrastructure
        checkAndFixResources(self.ontology_name, stage="ontology_stage_2")

        # attach ontology
        self.ontology_container = OntologyContainer(self.ontology_name)
        self.location = DIRECTORIES["latex_doc_location"] % self.ontology_name

        self.ontology_location = DIRECTORIES["ontology_location"] % str(
            self.ontology_name)

        self.reduced_network_node_list = self.ontology_container.list_reduced_network_node_objects
        self.reduced_arc_list = self.ontology_container.list_reduced_network_arc_objects

        # instantiate entity behaviours
        networks = self.ontology_container.list_inter_branches
        # entities_list = self.reduced_network_node_list

        self.arc_objects = self.ontology_container.list_arc_objects_on_networks
        self.node_objects = self.ontology_container.list_inter_node_objects_tokens  # list_node_objects_on_networks_with_tokens
        entities_list = []
        for nw in self.node_objects:
            for o in self.node_objects[nw]:
                obj = TEMPLATE_ENTITY_OBJECT % (nw, "node", o, "base")
                entities_list.append(obj)
        for nw in self.arc_objects:
            for o in self.arc_objects[nw]:
                obj = TEMPLATE_ENTITY_OBJECT % (
                    nw, "arc", o, "base"
                )  # RULE: "base" is used for the base bipartite graph
                entities_list.append(obj)

        self.entity_behaviours = EntityBehaviour(entities_list)

        self.list_linked_equations = self.__getFilteredEquationList(
            "interface_link_equation")
        # print("debugging")

        equations_label_list, \
        self.equation_information, \
        self.equation_inverse_index = self.__makeEquationAndIndexLists()
        self.rules = {}

        # get existing data
        self.__readVariableAssignmentToEntity()

        # interface components
        self.layout_InterNetworks = QtWidgets.QVBoxLayout(
        )  # Vertical Box with horizontal boxes of radio buttons & labels
        self.ui.scrollAreaWidgetContentsInterNetworks.setLayout(
            self.layout_InterNetworks)

        # initialisations
        # network selector
        self.radio_InterNetworks = Selector("InterNetworks",
                                            self.radioReceiverState, networks,
                                            self.layout_InterNetworks)

        self.selected_InterNetwork_ID = None
        self.selected_Entity_ID = None
        self.selected_variant_ID = None
        self.selected_variant_str_ID = "base"
        self.radio_index = None
        self.selected_base_variable = None
        self.rightListEquationIDs = []
        self.rightListEquationIDs_radio_ID = []

        self.match_equations_label_list = []
        self.match_equation_ID = {}
        # self.node_arc = "nodes"
        self.node_arc = self.ui.tabWidgetNodesArcs.tabText(
            self.ui.tabWidgetNodesArcs.currentIndex())

        # controls
        self.actions = [
            "show", "duplicates", "new_variant", "edit_variant",
            "instantiate_variant"
        ]

        # prepare lists
        self.current_base_var_ID = None

        # start process

        self.status_report = self.statusBar().showMessage
        self.status_report("getting started")
        self.entity_layout_clean = True
        self.variant_layout_clean = True
        self.equation_left_clean = True
        self.equation_right_clean = True
        self.selected_variant = None
        self.state = "start"
      for o in obj:
        objectlist.append(o)
        seekList(obj[o], objectlist, parents, lists, first=False)
    else:
      list.append((parents, obj, objectlist))
  else:
    lists.append((parents, obj, objectlist))


# #testing
#
if __name__ == '__main__':

  a = QtWidgets.QApplication([])

  ontology_name = getOntologyName()

  dot_path = os.path.join(DIRECTORIES["ontology_repository"], ontology_name, DIRECTORIES["ontology_graphs_location"],
                          "%s")
  o_template = dot_path  # + ".gv"
  o = FILES["ontology_file"] % ontology_name

  ontology = getData(o)["ontology_tree"]

  #
  # the tree of networks
  f = o_template % "tree"
  print(f)
  graph_attr = {}
  graph_attr["nodesep"] = "1"
  graph_attr["ranksep"] = "0.3"