[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 79/101: grc: refactor: move drawables in su
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 79/101: grc: refactor: move drawables in subpackage |
Date: |
Thu, 16 Mar 2017 14:58:11 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
jcorgan pushed a commit to branch python3
in repository gnuradio.
commit bc8ee049aefb7818b82adfc24de22590ee00b23f
Author: Sebastian Koslowski <address@hidden>
Date: Tue Sep 13 11:54:56 2016 -0600
grc: refactor: move drawables in subpackage
---
grc/gui/Platform.py | 20 ++++++++------------
grc/gui/canvas/__init__.py | 22 ++++++++++++++++++++++
grc/gui/{Block.py => canvas/block.py} | 20 +++++++++++---------
grc/gui/{Connection.py => canvas/connection.py} | 15 ++++++++-------
grc/gui/{Element.py => canvas/drawable.py} | 4 ++--
grc/gui/{FlowGraph.py => canvas/flowgraph.py} | 18 +++++++++---------
grc/gui/{Param.py => canvas/param.py} | 12 ++++++------
grc/gui/{Port.py => canvas/port.py} | 21 +++++++++------------
8 files changed, 75 insertions(+), 57 deletions(-)
diff --git a/grc/gui/Platform.py b/grc/gui/Platform.py
index 6a2a13f..44380c5 100644
--- a/grc/gui/Platform.py
+++ b/grc/gui/Platform.py
@@ -19,17 +19,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA
from __future__ import absolute_import, print_function
-import os
import sys
-from ..core.Platform import Platform as CorePlatform
+import os
from .Config import Config
-from .Block import Block
-from .Connection import Connection
-from .FlowGraph import FlowGraph
-from .Param import Param
-from .Port import Port
+from . import canvas
+from ..core.Platform import Platform as CorePlatform
class Platform(CorePlatform):
@@ -64,11 +60,11 @@ class Platform(CorePlatform):
# Factories
##############################################
Config = Config
- FlowGraph = FlowGraph
- Connection = Connection
- block_classes = {key: Block.make_cls_with_base(cls)
+ FlowGraph = canvas.FlowGraph
+ Connection = canvas.Connection
+ block_classes = {key: canvas.Block.make_cls_with_base(cls)
for key, cls in CorePlatform.block_classes.items()}
- port_classes = {key: Port.make_cls_with_base(cls)
+ port_classes = {key: canvas.Port.make_cls_with_base(cls)
for key, cls in CorePlatform.port_classes.items()}
- param_classes = {key: Param.make_cls_with_base(cls)
+ param_classes = {key: canvas.Param.make_cls_with_base(cls)
for key, cls in CorePlatform.param_classes.items()}
diff --git a/grc/gui/canvas/__init__.py b/grc/gui/canvas/__init__.py
new file mode 100644
index 0000000..f90d10c
--- /dev/null
+++ b/grc/gui/canvas/__init__.py
@@ -0,0 +1,22 @@
+# Copyright 2016 Free Software Foundation, Inc.
+# This file is part of GNU Radio
+#
+# GNU Radio Companion is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# GNU Radio Companion is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA
+
+from .block import Block
+from .connection import Connection
+from .flowgraph import FlowGraph
+from .param import Param
+from .port import Port
diff --git a/grc/gui/Block.py b/grc/gui/canvas/block.py
similarity index 97%
rename from grc/gui/Block.py
rename to grc/gui/canvas/block.py
index b37bec6..7e28a21 100644
--- a/grc/gui/Block.py
+++ b/grc/gui/canvas/block.py
@@ -18,23 +18,25 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA
"""
from __future__ import absolute_import
+
import math
import six
from gi.repository import Gtk, Pango, PangoCairo
-from . import Actions, Colors, Utils, Constants
+from .drawable import Drawable
-from .Constants import (
+from .. import Actions, Colors, Utils, Constants
+from ..Constants import (
BLOCK_LABEL_PADDING, PORT_SPACING, PORT_SEPARATION, LABEL_SEPARATION,
PORT_BORDER_SEPARATION, BLOCK_FONT, PARAM_FONT
)
-from . Element import Element
-from ..core import utils
-from ..core.Block import Block as CoreBlock
+
+from ...core import utils
+from ...core.Block import Block as CoreBlock
-class Block(CoreBlock, Element):
+class Block(CoreBlock, Drawable):
"""The graphical signal block."""
def __init__(self, parent, **n):
@@ -46,7 +48,7 @@ class Block(CoreBlock, Element):
self.states.update(_coordinate=(0, 0), _rotation=0)
self.width = self.height = 0
- Element.__init__(self) # needs the states and initial sizes
+ Drawable.__init__(self) # needs the states and initial sizes
self._surface_layouts = [
Gtk.DrawingArea().create_pango_layout(''), # title
@@ -293,7 +295,7 @@ class Block(CoreBlock, Element):
)
if port_selected:
return port_selected
- return Element.what_is_selected(self, coor, coor_m)
+ return Drawable.what_is_selected(self, coor, coor_m)
def draw_comment(self, cr):
if not self._comment_layout:
@@ -313,7 +315,7 @@ class Block(CoreBlock, Element):
@property
def extend(self):
- extend = Element.extend.fget(self)
+ extend = Drawable.extend.fget(self)
x, y = self.coordinate
for port in self.active_ports():
extend = (min_or_max(xy, offset + p_xy) for offset, min_or_max,
xy, p_xy in zip(
diff --git a/grc/gui/Connection.py b/grc/gui/canvas/connection.py
similarity index 96%
rename from grc/gui/Connection.py
rename to grc/gui/canvas/connection.py
index 9862328..14bd0c9 100644
--- a/grc/gui/Connection.py
+++ b/grc/gui/canvas/connection.py
@@ -19,15 +19,16 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA
from __future__ import absolute_import
-from . import Colors, Utils
-from .Constants import CONNECTOR_ARROW_BASE, CONNECTOR_ARROW_HEIGHT,
GR_MESSAGE_DOMAIN
-from .Element import Element
+from .drawable import Drawable
-from ..core.Element import nop_write
-from ..core.Connection import Connection as CoreConnection
+from .. import Colors, Utils
+from ..Constants import CONNECTOR_ARROW_BASE, CONNECTOR_ARROW_HEIGHT,
GR_MESSAGE_DOMAIN
+from ...core.Connection import Connection as CoreConnection
+from ...core.Element import nop_write
-class Connection(CoreConnection, Element):
+
+class Connection(CoreConnection, Drawable):
"""
A graphical connection for ports.
The connection has 2 parts, the arrow and the wire.
@@ -39,7 +40,7 @@ class Connection(CoreConnection, Element):
def __init__(self, *args, **kwargs):
super(self.__class__, self).__init__(*args, **kwargs)
- Element.__init__(self)
+ Drawable.__init__(self)
self._line = []
self._line_width_factor = 1.0
diff --git a/grc/gui/Element.py b/grc/gui/canvas/drawable.py
similarity index 98%
rename from grc/gui/Element.py
rename to grc/gui/canvas/drawable.py
index 17cd6dd..d1a6f42 100644
--- a/grc/gui/Element.py
+++ b/grc/gui/canvas/drawable.py
@@ -18,12 +18,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA
"""
from __future__ import absolute_import
-from .Constants import LINE_SELECT_SENSITIVITY
+from ..Constants import LINE_SELECT_SENSITIVITY
from six.moves import zip
-class Element(object):
+class Drawable(object):
"""
GraphicalElement is the base class for all graphical elements.
It contains an X,Y coordinate, a list of rectangular areas that the
element occupies,
diff --git a/grc/gui/FlowGraph.py b/grc/gui/canvas/flowgraph.py
similarity index 98%
rename from grc/gui/FlowGraph.py
rename to grc/gui/canvas/flowgraph.py
index f04383f..5969e00 100644
--- a/grc/gui/FlowGraph.py
+++ b/grc/gui/canvas/flowgraph.py
@@ -19,26 +19,26 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA
from __future__ import absolute_import
-import functools
import ast
+import functools
import random
from distutils.spawn import find_executable
from itertools import count
import six
+from gi.repository import GLib
from six.moves import filter
-from gi.repository import GLib
+from .drawable import Drawable
-from . import Actions, Colors, Constants, Utils, Bars, Dialogs
-from .Element import Element
-from .external_editor import ExternalEditor
+from .. import Actions, Colors, Constants, Utils, Bars, Dialogs
+from ..external_editor import ExternalEditor
-from ..core.FlowGraph import FlowGraph as CoreFlowgraph
-from ..core import Messages
+from ...core import Messages
+from ...core.FlowGraph import FlowGraph as CoreFlowgraph
-class FlowGraph(CoreFlowgraph, Element):
+class FlowGraph(CoreFlowgraph, Drawable):
"""
FlowGraph is the data structure to store graphical signal blocks,
graphical inputs and outputs,
@@ -51,7 +51,7 @@ class FlowGraph(CoreFlowgraph, Element):
Create a list for signal blocks and connections. Connect mouse
handlers.
"""
super(self.__class__, self).__init__(parent, **kwargs)
- Element.__init__(self)
+ Drawable.__init__(self)
self.drawing_area = None
# important vars dealing with mouse event tracking
self.element_moved = False
diff --git a/grc/gui/Param.py b/grc/gui/canvas/param.py
similarity index 96%
rename from grc/gui/Param.py
rename to grc/gui/canvas/param.py
index ed5257a..2ec99e7 100644
--- a/grc/gui/Param.py
+++ b/grc/gui/canvas/param.py
@@ -16,18 +16,18 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA
from __future__ import absolute_import
-from . import Utils, Constants
-from . import ParamWidgets
-from .Element import Element
+from .drawable import Drawable
-from ..core.Param import Param as _Param
+from .. import ParamWidgets, Utils, Constants
+from ...core.Param import Param as CoreParam
-class Param(_Param):
+
+class Param(CoreParam):
"""The graphical parameter."""
- make_cls_with_base = classmethod(Element.make_cls_with_base.__func__)
+ make_cls_with_base = classmethod(Drawable.make_cls_with_base.__func__)
def get_input(self, *args, **kwargs):
"""
diff --git a/grc/gui/Port.py b/grc/gui/canvas/port.py
similarity index 95%
rename from grc/gui/Port.py
rename to grc/gui/canvas/port.py
index 8ac32dc..bc40c9c 100644
--- a/grc/gui/Port.py
+++ b/grc/gui/canvas/port.py
@@ -18,18 +18,20 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA
"""
from __future__ import absolute_import
+
import math
from gi.repository import Gtk, PangoCairo, Pango
-from . import Actions, Colors, Utils, Constants
-from .Element import Element
+from .drawable import Drawable
+
+from .. import Actions, Colors, Utils, Constants
-from ..core.Element import nop_write
-from ..core.Port import Port as _Port
+from ...core.Element import nop_write
+from ...core.Port import Port as CorePort
-class Port(_Port, Element):
+class Port(CorePort, Drawable):
"""The graphical port."""
def __init__(self, parent, direction, **n):
@@ -38,7 +40,7 @@ class Port(_Port, Element):
Create list of connector coordinates.
"""
super(self.__class__, self).__init__(parent, direction, **n)
- Element.__init__(self)
+ Drawable.__init__(self)
self._connector_coordinate = (0, 0)
self._hovering = False
self.force_show_label = False
@@ -193,12 +195,7 @@ class Port(_Port, Element):
self.parent_block.rotate(direction)
def move(self, delta_coor):
- """
- Move the parent rather than self.
-
- Args:
- delta_corr: the (delta_x, delta_y) tuple
- """
+ """Move the parent rather than self."""
self.parent_block.move(delta_coor)
@property
- [Commit-gnuradio] [gnuradio] 75/101: grc: gtk3: rewrite file dialogs and support multiple extentions for screenshots, (continued)
- [Commit-gnuradio] [gnuradio] 75/101: grc: gtk3: rewrite file dialogs and support multiple extentions for screenshots, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 70/101: grc: gtk3: fancier coloring for disabled and bypassed blocks, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 83/101: grc: refactor: Cleaned up imports, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 88/101: grc: gtk3: fix multi-block move, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 91/101: grc: gtk3: fix canvas extent after zooming, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 100/101: grc: gtk minor fixes, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 01/101: grc: Main window opens with pygobject and gtk3. Still throws tons of errors., git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 72/101: Merge remote-tracking branch 'upstream/next' into gtk3, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 71/101: grc: gtk3: fixup dialogs, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 78/101: Merge remote-tracking branch 'upstream/next' into gtk3, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 79/101: grc: refactor: move drawables in subpackage,
git <=
- [Commit-gnuradio] [gnuradio] 95/101: grc: gtk3: curved connections, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 82/101: grc: gtk3: Converted to Gtk.Application (ActionHandler) and Gtk.ApplicationWindow (MainWindow), git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 96/101: grc: gtk3: invalid connection all red, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 90/101: Merge remote-tracking branch 'upstream/next' into gtk3, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 97/101: grc: gtk3: drag to connect, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 84/101: grc: refactor: Moved preferences to Config.py, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 101/101: Merge branch 'gtk3' into python3, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 47/101: grc: refactor: Port, Param, Options init clean-up, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 89/101: Merge remote-tracking branch 'upstream/next' into gtk3, git, 2017/03/16