示例#1
0
 def contextMenuEvent(self, event):
     if isinstance(self.port(), OutputPort):
         operator = GraphOperator(graph=self.graph, graphScene=self.scene())
         operator.set_port_item(self)
         menu = qtutils.AleaQMenu(operator.get_sensible_parent())
         menu.addAction(operator("Send to pool", menu, "port_send_to_pool"))
         menu.addAction(
             operator("Send to console", menu, "port_send_to_console"))
         menu.addAction(operator("Print", menu, "port_print_value"))
         menu.show()
         menu.move(event.screenPos())
         event.accept()
示例#2
0
文件: vertex.py 项目: gbaty/openalea
 def contextMenuEvent(self, event):
     if isinstance(self.port(), OutputPort):
         operator = GraphOperator(graph=self.graph,
                                  graphScene=self.scene())
         operator.set_port_item(self)
         menu = qtutils.AleaQMenu(operator.get_sensible_parent())
         menu.addAction(operator("Send to pool", menu, "port_send_to_pool"))
         menu.addAction(operator("Send to console", menu, "port_send_to_console"))
         menu.addAction(operator("Print", menu, "port_print_value"))
         menu.show()
         menu.move(event.screenPos())
         event.accept()
示例#3
0
文件: anno.py 项目: shiva16/openalea
    def contextMenuEvent(self, event):
        operator = GraphOperator(graph=self.graph(), graphScene=self.scene())
        widget = operator.get_sensible_parent()
        operator.set_annotation_item(self)

        menu = qtutils.AleaQMenu(widget)
        styleMenu = menu.addMenu("Style...")
        styleMenu.addAction(
            operator("Simple", styleMenu, "annotation_change_style_simple"))
        styleMenu.addAction(
            operator("Box", styleMenu, "annotation_change_style_box"))
        #display the menu...
        menu.move(event.screenPos())
        menu.show()
        event.accept()
示例#4
0
    def contextMenuEvent(self, event):
        operator = GraphOperator(graph=self.graph(),
                                 graphScene = self.scene())
        widget = operator.get_sensible_parent()
        operator.set_annotation_item(self)

        menu = qtutils.AleaQMenu(widget)
        styleMenu = menu.addMenu("Style...")
        styleMenu.addAction(operator("Simple", styleMenu,
                                     "annotation_change_style_simple"))
        styleMenu.addAction(operator("Box", styleMenu,
                                     "annotation_change_style_box"))
        #display the menu...
        menu.move(event.screenPos())
        menu.show()
        event.accept()
示例#5
0
    def instantiate_widget(self):
        self._widget = dataflowview.GraphicalGraph.create_view(self.model._workflow, clone=True)
        self._clipboard = CompositeNodeFactory("Clipboard")

        from openalea.core.service.ipython import interpreter
        interp = interpreter()

        GraphOperator.globalInterpreter = interp
        self._operator = GraphOperator(graph=self.model._workflow,
                                       graphScene=self._widget.scene(),
                                       clipboard=self._clipboard,
                                       )
        self._widget.mainMenu = types.MethodType(mainMenu, self._widget)
        self._widget.applet = self
        self._widget._actions = None

        methods = {}
        methods['actions'] = actions
        methods['mainMenu'] = mainMenu
        methods['display_help'] = _display_help

        self._widget = adapt_widget(self._widget, methods)

        if not VIEWER3D_SET:
            _set_viewer3d()

        # todo: use services
        self.widget().scene().focusedItemChanged.connect(self.item_focus_change)

        return self.widget()
示例#6
0
文件: vertex.py 项目: gbaty/openalea
    def mouseDoubleClickEvent(self, event):
        if event.button() == qt.QtCore.Qt.LeftButton:
            # Read settings
            try:
                localsettings = Settings()
                str = localsettings.get("UI", "DoubleClick")
            except:
                str = "['open']"

            operator = GraphOperator(graph=self.graph(),
                                     graphScene=self.scene())
            operator.set_vertex_item(self)

            if('open' in str):
                operator(fName="vertex_open")()
            elif('run' in str):
                operator(fName="vertex_run")()
示例#7
0
    def mouseDoubleClickEvent(self, event):
        if event.button() == qt.QtCore.Qt.LeftButton:
            # Read settings
            try:
                localsettings = Settings()
                str = localsettings.get("UI", "DoubleClick")
            except:
                str = "['open']"

            operator = GraphOperator(graph=self.graph(),
                                     graphScene=self.scene())
            operator.set_vertex_item(self)

            if ('open' in str):
                operator(fName="vertex_open")()
            elif ('run' in str):
                operator(fName="vertex_run")()
示例#8
0
 def get_graph_operator(self):
     operator = GraphOperator(graph=self.scene().get_graph(),
                              graphAdapter=self.scene().get_adapter(),
                              graphScene=self.scene(),
                              clipboard=self.__clipboard,
                              siblings=self.__siblings,
                              )
     return operator
示例#9
0
    def make_menus_helper(self, node, gwidget):
        from openalea.visualea.graph_operator import GraphOperator
        from openalea.vpltk.qt import QtGui

        operator = GraphOperator(
            graph=node,
            graphScene=gwidget.scene(),
            clipboard=self.__clipboard,
            siblings=self.__siblings,
        )

        # -- Construction the Export menu
        exp_menu = QtGui.QMenu("Export")
        exp_menu.addAction(
            operator("To Package Manager...", exp_menu,
                     "graph_export_to_factory"))

        # ---- to app submenu ----
        exp_toapp_menu = exp_menu.addMenu("To Application")
        exp_toapp_menu.addAction(
            operator("Preview...", exp_toapp_menu,
                     "graph_preview_application"))
        exp_toapp_menu.addAction(
            operator("Export...", exp_toapp_menu, "graph_export_application"))

        # ---- to image submenu ----
        exp_image_menu = exp_menu.addMenu("To Image")
        exp_image_menu.addAction(
            operator("Raster (PNG)", exp_image_menu, "graph_export_png"))
        exp_image_menu.addAction(
            operator("Vector (SVG)", exp_image_menu, "graph_export_svg"))

        exp_menu.addAction(
            operator("To Script", exp_menu, "graph_export_script"))

        # -- Contructing the Dataflow menu --
        df_menu = QtGui.QMenu("Dataflow")
        df_menu.addAction(
            operator("Reload", df_menu, "graph_reload_from_factory"))
        df_menu.addSeparator()
        df_menu.addAction(operator("Run", df_menu, "graph_run"))
        df_menu.addAction(operator("Invalidate", df_menu, "graph_invalidate"))
        df_menu.addAction(operator("Reset", df_menu, "graph_reset"))
        df_menu.addAction(
            operator("Configure IO", df_menu, "graph_configure_io"))
        df_menu.addSeparator()
        df_menu.addAction(operator("Group", df_menu, "graph_group_selection"))
        df_menu.addAction(operator("Copy", df_menu, "graph_copy"))
        df_menu.addAction(operator("Cut", df_menu, "graph_cut"))
        df_menu.addAction(operator("Paste", df_menu, "graph_paste"))
        df_menu.addAction(operator("Delete", df_menu,
                                   "graph_remove_selection"))

        return [exp_menu, df_menu]
示例#10
0
文件: vertex.py 项目: gbaty/openalea
    def contextMenuEvent(self, event):
        """ Context menu event : Display the menu"""
        self.setSelected(True)

        operator = GraphOperator(graph=self.graph(),
                                 graphScene=self.scene())
        operator.vertexType = GraphicalVertex
        operator.set_vertex_item(self)
        widget = operator.get_sensible_parent()
        menu = qtutils.AleaQMenu(widget)
        items = self.scene().get_selected_items(GraphicalVertex)

        menu.addAction(operator("Run", menu, "vertex_run"))
        menu.addAction(operator("Open Widget", menu, "vertex_open"))
        if isinstance(self.vertex(), compositenode.CompositeNode):
            menu.addAction(operator("Inspect composite node", menu, "vertex_composite_inspect"))
        menu.addSeparator()
        menu.addAction(operator("Delete", menu, "vertex_remove"))
        menu.addAction(operator("Reset", menu, "vertex_reset"))
        menu.addAction(operator("Replace By", menu, "vertex_replace"))
        menu.addAction(operator("Reload", menu, "vertex_reload"))
        menu.addSeparator()
        menu.addAction(operator("Caption", menu, "vertex_set_caption"))
        menu.addAction(operator("Show/Hide ports", menu, "vertex_show_hide_ports"))
        menu.addSeparator()

        action = operator("Mark as User Application", menu, "vertex_mark_user_app")
        action.setCheckable(True)
        action.setChecked(bool(self.vertex().user_application))
        menu.addAction(action)

        action = operator("Lazy", menu, "vertex_set_lazy")
        action.setCheckable(True)
        action.setChecked(self.vertex().lazy)
        menu.addAction(action)

        action = operator("Block", menu, "vertex_block")
        action.setCheckable(True)
        action.setChecked(self.vertex().block)
        menu.addAction(action)

        menu.addAction(operator("Internals", menu, "vertex_edit_internals"))
        menu.addSeparator()

        alignMenu = menu.addMenu("Align...")
        alignMenu.setDisabled(True)
        if len(items) > 1:
            alignMenu.setDisabled(False)
            alignMenu.addAction(operator("Align horizontally", menu, "graph_align_selection_horizontal"))
            alignMenu.addAction(operator("Align left", menu, "graph_align_selection_left"))
            alignMenu.addAction(operator("Align right", menu, "graph_align_selection_right"))
            alignMenu.addAction(operator("Align centered", menu, "graph_align_selection_mean"))
            alignMenu.addAction(operator("Distribute horizontally", menu, "graph_distribute_selection_horizontally"))
            alignMenu.addAction(operator("Distribute vertically", menu, "graph_distribute_selection_vertically"))

        # The colouring
        colorMenu = menu.addMenu("Color...")
        colorMenu.addAction(operator("Set user color...", colorMenu, "graph_set_selection_color"))
        # check if the current selection is coloured and tick the
        # menu item if an item of the selection uses the user color.
        action = operator("Use user color", colorMenu, "graph_use_user_color")
        action.setCheckable(True)
        action.setChecked(False)
        for i in items:
            if i.vertex().get_ad_hoc_dict().get_metadata("useUserColor"):
                action.setChecked(True)
                break
        colorMenu.addAction(action)

        # display the menu...
        menu.move(event.screenPos())
        menu.show()
        event.accept()
示例#11
0
    def contextMenuEvent(self, event):
        """ Context menu event : Display the menu"""
        self.setSelected(True)

        operator = GraphOperator(graph=self.graph(), graphScene=self.scene())
        operator.vertexType = GraphicalVertex
        operator.set_vertex_item(self)
        widget = operator.get_sensible_parent()
        menu = qtutils.AleaQMenu(widget)
        items = self.scene().get_selected_items(GraphicalVertex)

        menu.addAction(operator("Run", menu, "vertex_run"))
        menu.addAction(operator("Open Widget", menu, "vertex_open"))
        if isinstance(self.vertex(), compositenode.CompositeNode):
            menu.addAction(
                operator("Inspect composite node", menu,
                         "vertex_composite_inspect"))
        menu.addSeparator()
        menu.addAction(operator("Delete", menu, "vertex_remove"))
        menu.addAction(operator("Reset", menu, "vertex_reset"))
        menu.addAction(operator("Replace By", menu, "vertex_replace"))
        menu.addAction(operator("Reload", menu, "vertex_reload"))
        menu.addSeparator()
        menu.addAction(operator("Caption", menu, "vertex_set_caption"))
        menu.addAction(
            operator("Show/Hide ports", menu, "vertex_show_hide_ports"))
        menu.addSeparator()

        action = operator("Mark as User Application", menu,
                          "vertex_mark_user_app")
        action.setCheckable(True)
        action.setChecked(bool(self.vertex().user_application))
        menu.addAction(action)

        action = operator("Lazy", menu, "vertex_set_lazy")
        action.setCheckable(True)
        action.setChecked(self.vertex().lazy)
        menu.addAction(action)

        action = operator("Block", menu, "vertex_block")
        action.setCheckable(True)
        action.setChecked(self.vertex().block)
        menu.addAction(action)

        menu.addAction(operator("Internals", menu, "vertex_edit_internals"))
        menu.addSeparator()

        alignMenu = menu.addMenu("Align...")
        alignMenu.setDisabled(True)
        if len(items) > 1:
            alignMenu.setDisabled(False)
            alignMenu.addAction(
                operator("Align horizontally", menu,
                         "graph_align_selection_horizontal"))
            alignMenu.addAction(
                operator("Align left", menu, "graph_align_selection_left"))
            alignMenu.addAction(
                operator("Align right", menu, "graph_align_selection_right"))
            alignMenu.addAction(
                operator("Align centered", menu, "graph_align_selection_mean"))
            alignMenu.addAction(
                operator("Distribute horizontally", menu,
                         "graph_distribute_selection_horizontally"))
            alignMenu.addAction(
                operator("Distribute vertically", menu,
                         "graph_distribute_selection_vertically"))

        # The colouring
        colorMenu = menu.addMenu("Color...")
        colorMenu.addAction(
            operator("Set user color...", colorMenu,
                     "graph_set_selection_color"))
        # check if the current selection is coloured and tick the
        # menu item if an item of the selection uses the user color.
        action = operator("Use user color", colorMenu, "graph_use_user_color")
        action.setCheckable(True)
        action.setChecked(False)
        for i in items:
            if i.vertex().get_ad_hoc_dict().get_metadata("useUserColor"):
                action.setChecked(True)
                break
        colorMenu.addAction(action)

        # display the menu...
        menu.move(event.screenPos())
        menu.show()
        event.accept()