summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--grc/gui/Platform.py20
-rw-r--r--grc/gui/canvas/__init__.py22
-rw-r--r--grc/gui/canvas/block.py (renamed from grc/gui/Block.py)20
-rw-r--r--grc/gui/canvas/connection.py (renamed from grc/gui/Connection.py)15
-rw-r--r--grc/gui/canvas/drawable.py (renamed from grc/gui/Element.py)4
-rw-r--r--grc/gui/canvas/flowgraph.py (renamed from grc/gui/FlowGraph.py)18
-rw-r--r--grc/gui/canvas/param.py (renamed from grc/gui/Param.py)12
-rw-r--r--grc/gui/canvas/port.py (renamed from grc/gui/Port.py)21
8 files changed, 75 insertions, 57 deletions
diff --git a/grc/gui/Platform.py b/grc/gui/Platform.py
index 6a2a13f644..44380c579f 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 0000000000..f90d10c4e6
--- /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
index b37bec6dfa..7e28a21fc2 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
index 9862328d6a..14bd0c9280 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
index 17cd6ddd92..d1a6f42667 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
index f04383f32c..5969e00a43 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
index ed5257ae69..2ec99e70d8 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
index 8ac32dc25f..bc40c9c56c 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