Exemplo n.º 1
0
    def __init__(self):
        super().__init__()

        self.toolButtons = {}
        self.lines = Lines(bresenham.line)
        self.circs = Circumferences(bresenham.circumference)
        self.fillPoints = []
        self.bezierControl = []
        self.printBezierControl = []
        self.bezierPoints = []
        self.bezierOk = False

        self.fillFn = flood_fill.flood4

        # Atalho definido para a ação de fechar o programa
        exitAct = Action(qApp.quit, self)
        exitAct.setShortcut('Ctrl+Q')
        self.addAction(exitAct)

        self.initUI()

        # Definição da área inicial de recorte
        self.clippingRect = Lines(bresenham.line)

        origin = {'x': self.toolbar.width(), 'y': self.menubar.height()}
        self.clippingRect.append(origin, {
            'x': self.width(),
            'y': self.height()
        })
Exemplo n.º 2
0
	def newMapView(self, map):
		""" Creates a new map view """
		mapview = MapView(map)
		
		self._mapviewlist.append(mapview)
		
		map_action = Action(unicode(map.getId()))
		action.activated.connect(cbwa(self.showMapView, mapview), sender=map_action, weak=False)
		self._mapgroup.addAction(map_action)
		
		self.showMapView(mapview)
		
		events.mapAdded.send(sender=self, map=map)
		
		return mapview
Exemplo n.º 3
0
    def createMenuBar(self):
        """ Cria o menu superior, adicionando os devidos
        submenus e suas respectivas ações.
        """

        self.menubar = self.menuBar()

        menu = self.menubar.addMenu('Algoritmos')

        # Submenu referente aos algoritmos relacionados
        # a construção de retas.
        submenu = menu.addMenu('Retas')
        group = QActionGroup(submenu)

        action = Action(lambda: self.lines.setFn(bresenham.line), group,
                        'Bresenham', True)
        action.setChecked(True)
        submenu.addAction(action)

        action = Action(lambda: self.lines.setFn(dda.line), group, 'DDA', True)
        submenu.addAction(action)

        # Submenu referente aos algoritmos relacionados
        # a janela de recorte 2D.
        submenu = menu.addMenu('Recorte')

        group = QActionGroup(submenu)

        action = Action(
            lambda: Painter.setClippingFn(cohen_sutherland.clipping), group,
            'Cohen-Sutherland', True)
        action.setChecked(True)
        submenu.addAction(action)

        action = Action(lambda: Painter.setClippingFn(liang_barsky.clipping),
                        group, 'Liang-Barsky', True)
        submenu.addAction(action)

        # Submenu referente aos algoritmos relacionados
        # a preenchimento de área.
        submenu = menu.addMenu('Preenchimento')

        group = QActionGroup(submenu)

        action = Action(lambda: self.setFillFn(flood_fill.flood4), group,
                        'Flood-Fill', True)
        action.setChecked(True)
        submenu.addAction(action)

        action = Action(lambda: self.setFillFn(boundary_fill.boundary4), group,
                        'Boundary-Fill', True)
        submenu.addAction(action)
Exemplo n.º 4
0
    def createToolBar(self):
        """ Cria o menu de ferramentas lateral, adicionando
        as devidas ferramentas.
        """

        self.toolbar = ToolBar(self)
        self.toolbar.setMovable(False)

        # Agrupamento de ações que apresentam como característica
        # o fato de permanecerem marcadas, para serem usadas de forma
        # contínua.
        group = QActionGroup(self.toolbar)
        action = Action(lambda: self.toolbar.chooseAction(ToolBar.TOOLS.line),
                        group, "Linha", True, lineIcon())
        self.toolbar.addAction(action, ToolBar.TOOLS.line)

        action = Action(lambda: self.toolbar.showBezierDialog(), group,
                        "Bézier", True, bezierIcon())
        self.toolbar.addAction(action, ToolBar.TOOLS.bezier)

        action = Action(lambda: self.toolbar.chooseAction(ToolBar.TOOLS.circ),
                        group, "Circunferência", True, circIcon())
        self.toolbar.addAction(action, ToolBar.TOOLS.circ)

        action = Action(lambda: self.toolbar.chooseAction(ToolBar.TOOLS.fill),
                        group, "Preenchimento", True, fillIcon())
        self.toolbar.addAction(action, ToolBar.TOOLS.fill)

        action = Action(lambda: self.toolbar.chooseAction(ToolBar.TOOLS.clip),
                        group, "Recorte", True, clipIcon())
        self.toolbar.addAction(action, ToolBar.TOOLS.clip)

        # Demais ações, que apresentam comportamento ligado apenas
        # ao evento de clique.
        action = Action(lambda: self.toolbar.showTransformDialog(),
                        self.toolbar, "Transformações", False, transformIcon())
        self.toolbar.addAction(action, ToolBar.TOOLS.transform)

        action = Action(lambda: self.toolbar.clear(), self.toolbar,
                        "Limpar Tela", False, clearIcon())
        self.toolbar.addAction(action, ToolBar.TOOLS.clear)

        # Inclusão propriamente dita da barra de ferramentas
        # a janela principal.
        self.addToolBar(Qt.LeftToolBarArea, self.toolbar)
Exemplo n.º 5
0
    def _initActions(self):
        """ Initializes toolbar and menubar buttons """
        exitAction = Action(u"Exit", "gui/icons/quit.png")
        exitAction.helptext = u"Exit program"
        action.activated.connect(self.quit, sender=exitAction)

        self._file_menu = Menu(name=u"File")
        self._file_menu.addAction(exitAction)

        self._edit_menu = Menu(name=u"Edit")
        self._view_menu = Menu(name=u"View")
        self._tools_menu = Menu(name=u"Tools")
        self._window_menu = Menu(name=u"Window")
        self._help_menu = Menu(name=u"Help")

        self._action_show_statusbar = Action(u"Statusbar", checkable=True)
        self._action_show_statusbar.helptext = u"Toggle statusbar"
        action.activated.connect(self.toggleStatusbar,
                                 sender=self._action_show_statusbar)

        self._action_show_toolbar = Action(u"Toolbar", checkable=True)
        self._action_show_toolbar.helptext = u"Toggle toolbar"
        action.activated.connect(self.toggleToolbar,
                                 sender=self._action_show_toolbar)

        self._action_show_toolbox = Action(u"Tool box", checkable=True)
        self._action_show_toolbox.helptext = u"Toggle tool box"
        action.activated.connect(self.toggleToolbox,
                                 sender=self._action_show_toolbox)

        self._view_menu.addAction(self._action_show_statusbar)
        self._view_menu.addAction(self._action_show_toolbar)
        self._view_menu.addAction(self._action_show_toolbox)
        self._view_menu.addSeparator()

        #These 3 are enabled by default therefore should be checked
        self._action_show_statusbar.setChecked(True)
        self._action_show_toolbar.setChecked(True)
        self._action_show_toolbox.setChecked(True)

        test_action1 = Action(u"Cycle buttonstyles",
                              "gui/icons/cycle_styles.png")
        test_action1.helptext = u"Cycles button styles. There are currently four button styles."
        action.activated.connect(self._actionActivated, sender=test_action1)
        self._view_menu.addAction(test_action1)

        test_action2 = Action(u"Toggle Blocking")
        test_action2.helptext = u"Toggles the blocking infos for the instances."
        action.activated.connect(self.toggleBlocking, sender=test_action2)
        self._view_menu.addAction(test_action2)

        test_action3 = Action(u"Toggle Grid")
        test_action3.helptext = u"Toggles the grids of the map."
        action.activated.connect(self.toggleGrid, sender=test_action3)
        self._view_menu.addAction(test_action3)

        test_action4 = Action(u"Toggle Coordinates")
        test_action4.helptext = u"Toggles the coordinates of the map."
        action.activated.connect(self.toggleCoordinates, sender=test_action4)
        self._view_menu.addAction(test_action4)

        self._mapgroup = ActionGroup(exclusive=True, name="Mapgroup")
        self._mapbar.addAction(self._mapgroup)
        self._window_menu.addAction(self._mapgroup)

        help_action = Action(u"Help", "gui/icons/help.png")
        help_action.helptext = u"Displays a window with some simple instructions"
        action.activated.connect(self._showHelpDialog, sender=help_action)
        self._help_menu.addAction(help_action)

        self._menubar.addMenu(self._file_menu)
        self._menubar.addMenu(self._edit_menu)
        self._menubar.addMenu(self._view_menu)
        self._menubar.addMenu(self._tools_menu)
        self._menubar.addMenu(self._window_menu)
        self._menubar.addMenu(self._help_menu)