kopia lustrzana https://github.com/hdacosta400/intelligent-textiles
scrap code for combining grids, will fix when design is fleshed out more
rodzic
dc8d9f86f2
commit
34f70c9aec
|
@ -1,27 +1,26 @@
|
||||||
from .base import InkstitchExtension
|
from .base import InkstitchExtension
|
||||||
import json
|
|
||||||
import os
|
|
||||||
import sys
|
import sys
|
||||||
from base64 import b64decode
|
from base64 import b64decode
|
||||||
from argparse import ArgumentParser, REMAINDER
|
from argparse import ArgumentParser, REMAINDER
|
||||||
|
|
||||||
import appdirs
|
import appdirs
|
||||||
import inkex
|
import inkex
|
||||||
from inkex import Line, Rectangle, Path
|
from inkex import Line, Rectangle, Path, Polyline, PathElement
|
||||||
import wx
|
import wx
|
||||||
import wx.adv
|
import wx.adv
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
|
|
||||||
from ..elements import nodes_to_elements
|
from .create_grid import BoundingBoxMetadata
|
||||||
from ..gui import PresetsPanel, SimulatorPreview, info_dialog
|
|
||||||
from ..i18n import _
|
class CombineGridsFrame(wx.Frame):
|
||||||
from ..lettering import Font, FontError
|
DEFAULT_FONT = "small_font"
|
||||||
from ..svg import get_correction_transform
|
def __init__(self, shape1, shape2, svg, *args, **kwargs):
|
||||||
from ..svg.tags import (INKSCAPE_LABEL, INKSTITCH_LETTERING, SVG_GROUP_TAG,
|
if sys.platform.startswith('win32'):
|
||||||
SVG_PATH_TAG)
|
import locale
|
||||||
from ..utils import DotDict, cache, get_bundled_dir, get_resource_dir
|
locale.setlocale(locale.LC_ALL, "C")
|
||||||
from .commands import CommandsExtension
|
lc = wx.Locale()
|
||||||
from .lettering_custom_font_dir import get_custom_font_dir
|
lc.Init(wx.LANGUAGE_DEFAULT)
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class CombineGrids(InkstitchExtension):
|
class CombineGrids(InkstitchExtension):
|
||||||
|
@ -29,12 +28,55 @@ class CombineGrids(InkstitchExtension):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
self.cancelled = False
|
self.cancelled = False
|
||||||
InkstitchExtension.__init__(self, *args, **kwargs)
|
InkstitchExtension.__init__(self, *args, **kwargs)
|
||||||
for command in self.COMMANDS:
|
self.arg_parser.add_argument("--alignment")
|
||||||
self.arg_parser.add_argument("--%s" % command, type=inkex.Boolean)
|
args, _ = self.arg_parser.parse_known_args()
|
||||||
|
inkex.errormsg("args:{}".format(args.alignment))
|
||||||
|
self.is_horizontal_connection = True if args.alignment == 1 else False
|
||||||
|
self.wires = []
|
||||||
|
self.wire_rectangles = []
|
||||||
def cancel(self):
|
def cancel(self):
|
||||||
self.cancelled = True
|
self.cancelled = True
|
||||||
|
def connect_horizontally(self):
|
||||||
|
rect1, rect2 = self.wire_rectangles
|
||||||
|
if not rect1.is_horizontally_aligned(rect2):
|
||||||
|
inkex.errormsg("Unable to horizontally connect the two objects.")
|
||||||
|
return
|
||||||
|
leftmost_rectangle = None
|
||||||
|
letmost_wire = None
|
||||||
|
other_rectangle = None
|
||||||
|
other_wire = None
|
||||||
|
if rect1.left < rect2.left:
|
||||||
|
leftmost_rectangle = rect1
|
||||||
|
letmost_wire = self.wires[0]
|
||||||
|
other_rectangle = rect2
|
||||||
|
other_wire = self.wires[1]
|
||||||
|
else:
|
||||||
|
leftmost_rectangle = rect2
|
||||||
|
letmost_wire = self.wires[1]
|
||||||
|
other_rectangle = rect1
|
||||||
|
other_wire = self.wires[0]
|
||||||
|
|
||||||
|
|
||||||
def effect(self):
|
def effect(self):
|
||||||
pass
|
for elem in self.svg.get_selected():
|
||||||
|
# inkex.errormsg("things selected:{}".format(len(self.svg.get_selected())))
|
||||||
|
inkex.errormsg("type of elem:{}".format(type(elem)))
|
||||||
|
# have to separate shapes and wires here!
|
||||||
|
wire_points = [p for p in elem.path.end_points]
|
||||||
|
if type(elem) == Polyline:
|
||||||
|
self.wires.append(wire_points)
|
||||||
|
self.wire_rectangles.append(elem.bounding_box())
|
||||||
|
if len(self.wires) != 2:
|
||||||
|
inkex.errormsg("Please select only two wires to combine!")
|
||||||
|
return
|
||||||
|
if self.is_horizontal_connection:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,13 @@
|
||||||
</submenu>
|
</submenu>
|
||||||
</effects-menu>
|
</effects-menu>
|
||||||
</effect>
|
</effect>
|
||||||
|
<param name="description" type="description">
|
||||||
|
This extension will try to combine wires together.
|
||||||
|
</param>
|
||||||
|
<param name="alignment" type="optiongroup" gui-text="Method">
|
||||||
|
<option value="0">Vertical</option>
|
||||||
|
<option value="1">Horizontal</option>
|
||||||
|
</param>
|
||||||
<script>
|
<script>
|
||||||
{{ command_tag | safe }}
|
{{ command_tag | safe }}
|
||||||
</script>
|
</script>
|
||||||
|
|
Ładowanie…
Reference in New Issue