From a7398d846a5c696734163205193734606e7b84c8 Mon Sep 17 00:00:00 2001 From: jaseg Date: Fri, 14 Aug 2020 13:31:09 +0200 Subject: WIP --- plugin/main_dialog.fbp | 1342 ++++++++++++++++++++++++------------------ plugin/mesh_dialog.py | 142 ++++- plugin/mesh_plugin.py | 4 +- plugin/mesh_plugin_dialog.py | 336 ++++++----- 4 files changed, 1100 insertions(+), 724 deletions(-) diff --git a/plugin/main_dialog.fbp b/plugin/main_dialog.fbp index 1d687aa..6c389c0 100644 --- a/plugin/main_dialog.fbp +++ b/plugin/main_dialog.fbp @@ -1,6 +1,6 @@ - + ; Python @@ -14,6 +14,7 @@ mesh_plugin_dialog 1000 none + 0 MeshPlugin @@ -44,7 +45,7 @@ MainDialog - 496,258 + 588,356 wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMINIMIZE_BOX|wxRESIZE_BORDER|wxSTAY_ON_TOP ; ; forward_declare Security Mesh Generator Plugin @@ -52,42 +53,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bSizer1 @@ -150,32 +115,9 @@ wxHSCROLL|wxVSCROLL - - - - - - - - - - - - - - - - - - - - - - - 2 - wxVERTICAL + wxBOTH 1 0 @@ -183,7 +125,7 @@ fgSizer1 wxFLEX_GROWMODE_SPECIFIED none - 3 + 8 0 5 @@ -218,6 +160,7 @@ 0 wxID_ANY Mesh net name prefix + 0 0 @@ -243,29 +186,6 @@ -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -326,43 +246,16 @@ wxFILTER_NONE wxDefaultValidator - mesh- + - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 wxEXPAND - 1 + 0 0 protected @@ -402,6 +295,7 @@ 0 wxID_ANY 0 matching nets + 0 0 @@ -427,29 +321,6 @@ -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -485,6 +356,7 @@ 0 wxID_ANY Mesh angle + 0 0 @@ -510,29 +382,6 @@ -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -546,9 +395,9 @@ none 5 - wxALIGN_CENTER_VERTICAL + wxALL 0 - + 1 1 1 @@ -566,6 +415,7 @@ 1 0 + 2 Dock 0 Left @@ -576,15 +426,18 @@ 0 0 wxID_ANY + 1 + 0.000000 + 360 0 - + 0 0 1 - m_angleInput + m_angleSpin 1 @@ -594,45 +447,14 @@ Resizable 1 - - + wxSP_ARROW_KEYS|wxSP_WRAP + ; ; forward_declare 0 - - wxFILTER_NONE - wxDefaultValidator - - 0.00 + - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -668,6 +490,7 @@ 0 wxID_ANY ° (deg) + 0 0 @@ -693,29 +516,6 @@ -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -753,6 +553,7 @@ 0 wxID_ANY Trace width + 0 0 @@ -778,29 +579,6 @@ -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -814,9 +592,73 @@ none 5 - wxALIGN_CENTER_VERTICAL + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 3 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + 0.1 + 0.127 + 1000 + + 0 + + 0 + + 0 + + 1 + m_traceSpin + 1 + + + protected + 1 + + Resizable + 1 + + wxSP_ARROW_KEYS + ; ; forward_declare + 0 + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxALL 0 - + 1 1 1 @@ -844,15 +686,16 @@ 0 0 wxID_ANY + mm + 0 0 - 0 1 - m_traceInput + m_staticText6 1 @@ -863,51 +706,92 @@ 1 - + ; ; forward_declare 0 - - wxFILTER_NONE - wxDefaultValidator - - 0.127 - - - - - - - - - - - - - - - - - - - - - - - - - - - + -1 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Space width + 0 + + 0 + + + 0 + + 1 + m_staticText7 + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxEXPAND + 1 + + + bSizer6 + wxHORIZONTAL + none 5 wxALL 0 - + 1 1 1 @@ -925,6 +809,7 @@ 1 0 + 3 Dock 0 Left @@ -935,14 +820,18 @@ 0 0 wxID_ANY + 0.1 + 0.127 + 1000 0 + 0 0 1 - m_traceSpin + m_spaceSpin 1 @@ -952,39 +841,14 @@ Resizable 1 - wxSP_VERTICAL - + wxSP_ARROW_KEYS + ; ; forward_declare 0 + - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1020,6 +884,7 @@ 0 wxID_ANY mm + 0 0 @@ -1027,7 +892,7 @@ 0 1 - m_staticText6 + m_staticText8 1 @@ -1045,29 +910,6 @@ -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -1104,7 +946,8 @@ 0 0 wxID_ANY - Space width + Anchor exit direction + 0 0 @@ -1112,7 +955,7 @@ 0 1 - m_staticText7 + m_staticText11 1 @@ -1130,29 +973,6 @@ -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -1161,14 +981,14 @@ 1 - bSizer6 + bSizer41 wxHORIZONTAL none 5 - wxALIGN_CENTER_VERTICAL + wxALL 0 - + 1 1 1 @@ -1186,6 +1006,7 @@ 1 0 + 0 Dock 0 Left @@ -1196,15 +1017,18 @@ 0 0 wxID_ANY + 45 + 0.000000 + 360 0 - + 0 0 1 - m_spaceInput + m_exitSpin 1 @@ -1214,52 +1038,21 @@ Resizable 1 - - + wxSP_ARROW_KEYS|wxSP_WRAP + ; ; forward_declare 0 - - wxFILTER_NONE - wxDefaultValidator - - 0.127 + - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL + wxALIGN_CENTER_VERTICAL|wxALL 0 - + 1 1 1 @@ -1287,6 +1080,8 @@ 0 0 wxID_ANY + ° (deg) + 0 0 @@ -1294,7 +1089,7 @@ 0 1 - m_spaceSpin + m_staticText51 1 @@ -1304,82 +1099,564 @@ Resizable 1 - wxSP_VERTICAL - + + ; ; forward_declare 0 - - - - - - - - - - - - - - - - - - - - - - - - - - + -1 - - 5 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - mm - - 0 - - - 0 - - 1 - m_staticText8 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Number of mesh traces + 0 + + 0 + + + 0 + + 1 + m_staticText12 + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxALL + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + 2 + 1000 + + 0 + + 0 + + 0 + + 1 + m_traceCountSpin + 1 + + + protected + 1 + + Resizable + 1 + + wxSP_ARROW_KEYS + ; ; forward_declare + 0 + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Mesh origin offset + 0 + + 0 + + + 0 + + 1 + m_staticText13 + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxEXPAND + 2 + + + bSizer9 + wxHORIZONTAL + none + + 5 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + x + 0 + + 0 + + + 0 + + 1 + m_staticText15 + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 3 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + 0.1 + 0 + 100 + + 0 + + -100 + + 0 + + 1 + m_offsetXSpin + 1 + + + protected + 1 + + Resizable + 1 + + wxSP_ARROW_KEYS + ; ; forward_declare + 0 + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + mm + 0 + + 0 + + + 0 + + 1 + m_staticText17 + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + y + 0 + + 0 + + + 0 + + 1 + m_staticText16 + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 3 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + 0.1 + 0 + 100 + + 0 + + -100 + + 0 + + 1 + m_offsetYSpin + 1 + + + protected + 1 + + Resizable + 1 + + wxSP_ARROW_KEYS + ; ; forward_declare + 0 + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + mm + 0 + + 0 + + + 0 + + 1 + m_staticText18 1 @@ -1397,29 +1674,6 @@ -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -1451,25 +1705,31 @@ + 1 0 1 1 + 0 0 + Dock 0 Left 1 1 + 0 0 wxID_ANY - Cancel + Close + + 0 0 @@ -1484,6 +1744,8 @@ protected 1 + + Resizable 1 @@ -1498,30 +1760,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - @@ -1549,25 +1787,31 @@ + 1 0 1 1 + 0 0 + Dock 0 Left 1 1 + 0 0 wxID_ANY Remove Mesh Traces + + 0 0 @@ -1582,6 +1826,8 @@ protected 1 + + Resizable 1 @@ -1596,30 +1842,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - @@ -1637,25 +1859,31 @@ + 1 0 1 1 + 0 0 + Dock 0 Left 1 1 + 0 0 wxID_ANY Generate + + 0 0 @@ -1670,6 +1898,8 @@ protected 1 + + Resizable 1 @@ -1684,30 +1914,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/plugin/mesh_dialog.py b/plugin/mesh_dialog.py index 97943a8..3b4e91a 100644 --- a/plugin/mesh_dialog.py +++ b/plugin/mesh_dialog.py @@ -1,14 +1,32 @@ from collections import defaultdict +from dataclasses import dataclass import wx import pcbnew import shapely +from shapely.geometry import polygon +from shapely import affinity from . import mesh_plugin_dialog -# Implementing MainDialog +class GeneratorError(ValueError): + pass + +class AbortError(SystemError): + pass + +@dataclass +class GeneratorSettings: + mesh_angle: float = 0.0 # deg + trace_width: float = 0.127 # mm + space_width: float = 0.127 # mm + anchor_exit: float = 0.0 # deg + num_traces: int = 2 + offset_x: float = 0.0 # mm + offset_y: float = 0.0 # mm + class MeshPluginMainDialog(mesh_plugin_dialog.MainDialog): def __init__(self, board): mesh_plugin_dialog.MainDialog.__init__(self, None) @@ -18,10 +36,6 @@ class MeshPluginMainDialog(mesh_plugin_dialog.MainDialog): self.m_removeButton.Bind(wx.EVT_BUTTON, self.tearup_mesh) self.m_generateButton.Bind(wx.EVT_BUTTON, self.generate_mesh) self.m_net_prefix.Bind(wx.EVT_TEXT, self.update_net_label) - self.m_traceSpin.Bind(wx.EVT_SPIN_UP, lambda evt: self.spin(self.m_traceInput, 1.0)) - self.m_traceSpin.Bind(wx.EVT_SPIN_DOWN, lambda evt: self.spin(self.m_traceInput, -1.0)) - self.m_spaceSpin.Bind(wx.EVT_SPIN_UP, lambda evt: self.spin(self.m_spaceInput, 1.0)) - self.m_spaceSpin.Bind(wx.EVT_SPIN_DOWN, lambda evt: self.spin(self.m_spaceInput, -1.0)) self.tearup_confirm_dialog = wx.MessageDialog(self, "", style=wx.YES_NO | wx.NO_DEFAULT) @@ -30,14 +44,6 @@ class MeshPluginMainDialog(mesh_plugin_dialog.MainDialog): self.SetMinSize(self.GetSize()) - def spin(self, le_input, delta): - try: - current = float(le_input.Value) - current += delta - le_input.Value = '{:.03f}'.format(current) - except ValueError: - pass - def get_matching_nets(self): prefix = self.m_net_prefix.Value return { net for net in self.nets if net.startswith(prefix) } @@ -59,16 +65,31 @@ class MeshPluginMainDialog(mesh_plugin_dialog.MainDialog): self.tearup_confirm_dialog.SetYesNoLabels("Tear up {} nets".format(len(matching)), "Close") if self.tearup_confirm_dialog.ShowModal() == wx.ID_YES: - for track in self.board.GetTracks(): - if not (track.GetStatus() & pcbnew.TRACK_AR): - continue + self.tearup_mesh() + + def tearup_mesh(self): + for track in self.board.GetTracks(): + if not (track.GetStatus() & pcbnew.TRACK_AR): + continue - if not track.GetNet().GetNetname() in matching: - continue + if not track.GetNet().GetNetname() in matching: + continue - board.Remove(track) + board.Remove(track) def generate_mesh(self, evt): + try: + settings = GeneratorSettings( + mesh_angle = float(self.m_angleSpin.Value), + trace_width = float(self.m_traceSpin.Value), + space_width = float(self.m_spaceSpin.Value), + anchor_exit = float(self.m_exitSpin.Value), + num_traces = int(self.m_traceCountSpin.Value), + offset_x = float(self.m_offsetXSpin.Value), + offset_y = float(self.m_offsetYSpin.Value)) + except ValueError as e: + return wx.MessageDialog(self, "Invalid input value: {}.".format(e), "Invalid input").ShowModal() + nets = self.get_matching_nets() pads = defaultdict(lambda: []) @@ -115,11 +136,90 @@ class MeshPluginMainDialog(mesh_plugin_dialog.MainDialog): if len(anchors) > 1: return wx.MessageDialog(self, "Error: Currently, only a single anchor is supported.").ShowModal() - self.generate_mesh(zone, anchors) + try: + def warn(msg): + dialog = wx.MessageDialog(self, msg + '\n\nDo you want to abort mesh generation?', + "Mesh Generation Warning").ShowModal() + dialog = wx.MessageDialog(self, "", style=wx.YES_NO | wx.NO_DEFAULT) + dialog.SetYesNoLabels("Abort", "Ignore and continue") + + if self.tearup_confirm_dialog.ShowModal() == wx.ID_YES: + raise AbortError() + + self.generate_mesh_backend(zone, anchors, warn=warn) + + except GeneratorError as e: + return wx.MessageDialog(self, str(e), "Mesh Generation Error").ShowModal() + except AbortError: + pass + + def poly_set_to_shapely(self, poly_set): + for i in range(poly_set.OutlineCount()): + outline = poly_set.Outline(i) + + outline_points = [] + for j in range(outline.PointCount()): + point = outline.CPoint(j) + outline_points.append((pcbnew.ToMM(point.x), pcbnew.ToMM(point.y))) + yield polygon.LinearRing(outline_points) - def generate_mesh(self, zone, anchors): + def generate_mesh_backend(self, zone, anchors, warn=lambda s: None, settings=GeneratorSettings()): anchor, = anchors + anchor_outlines = list(self.poly_set_to_shapely(anchor.GetBoundingPoly())) + if len(anchor_outlines) == 0: + raise GeneratorError('Could not find any outlines for anchor {}'.format(anchor.GetReference())) + if len(anchor_outlines) > 1: + warn('Anchor {} has multiple outlines. Using first outline for trace start.') + + zone_outlines = list(self.poly_set_to_shapely(zone.GetPolyShape())) + if len(zone_outlines) == 0: + raise GeneratorError('Could not find any outlines for mesh zone.') + if len(zone_outlines) > 1: + raise GeneratorError('Mesh zone has too many outlines (has {}, should have one).'.format(len(zone_outlines))) + zone_outline, *_rest = zone_outlines + + mesh_origin = zone_outline.centroid + width_per_trace = settings.trace_width + settings.space_width + grid_cell_width = width_per_trace * settings.num_traces + + zone_outline_rotated = affinity.rotate(zone_outline, -settings.mesh_angle, origin=mesh_origin) + bbox = zone_outline_rotated.bounds + + grid_origin = (bbox[0] + settings.offset_x - grid_cell_width, bbox[1] + settings.offset_y - grid_cell_width) + grid_rows = int((bbox[3] - grid_origin[1]) / grid_cell_width + 2) + grid_cols = int((bbox[2] - grid_origin[0]) / grid_cell_width + 2) + print(f'generating grid of size {grid_rows} * {grid_cols}') + + grid = [] + for y in range(grid_rows): + row = [] + for x in range(grid_cols): + cell = polygon.LinearRing([(0, 0), (0, 1), (1, 1), (1, 0)]) + cell = affinity.scale(cell, grid_cell_width, grid_cell_width, origin=(0, 0)) + cell = affinity.translate(cell, mesh_origin.x + x*grid_cell_width, mesh_origin.y + y*grid_cell_width) + cell = affinity.rotate(cell, settings.mesh_angle, origin=mesh_origin) + row.append(cell) + grid.append(row) + break + + for row in grid: + for cell in row: + poly = pcbnew.DRAWSEGMENT() + poly.SetLayer(self.board.GetLayerID('Eco2.User')) + poly.SetShape(pcbnew.S_POLYGON) + poly.SetWidth(0) + self.board.Add(poly) + s = poly.GetPolyShape() + s.NewOutline() + for x, y in zip(*cell.xy): + s.Append(pcbnew.FromMM(x), pcbnew.FromMM(y)) + print('OUTLINE POINT', x, y) + break + + pcbnew.Refresh() + #self.tearup_mesh() + # TODO generate def update_net_label(self, evt): self.m_netLabel.SetLabel('{} matching nets'.format(len(self.get_matching_nets()))) diff --git a/plugin/mesh_plugin.py b/plugin/mesh_plugin.py index 9d4ab56..1951875 100644 --- a/plugin/mesh_plugin.py +++ b/plugin/mesh_plugin.py @@ -15,7 +15,7 @@ def check_requirements(*packages): missing.append(pkg) if missing: - wx.MessageDialog(None, "Error: Missing python dependencies:\n\n{}.".format('\n'.join(missing)), + wx.MessageDialog(None, "Error: Missing python dependencies:\n\n{}".format('\n'.join(missing)), "Missing Dependencies").ShowModal() return False @@ -31,7 +31,7 @@ class MeshPlugin(pcbnew.ActionPlugin): self.show_toolbar_button = True def Run(self): - if not check_requirements('pyclipper'): + if not check_requirements('shapely'): return from .mesh_dialog import show_dialog diff --git a/plugin/mesh_plugin_dialog.py b/plugin/mesh_plugin_dialog.py index 51bf936..e8358b2 100644 --- a/plugin/mesh_plugin_dialog.py +++ b/plugin/mesh_plugin_dialog.py @@ -1,133 +1,203 @@ -# -*- coding: utf-8 -*- - -########################################################################### -## Python code generated with wxFormBuilder (version Jun 17 2015) -## http://www.wxformbuilder.org/ -## -## PLEASE DO "NOT" EDIT THIS FILE! -########################################################################### - -import wx -import wx.xrc - -########################################################################### -## Class MainDialog -########################################################################### - -class MainDialog ( wx.Dialog ): - - def __init__( self, parent ): - wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = u"Security Mesh Generator Plugin", pos = wx.DefaultPosition, size = wx.Size( 496,258 ), style = wx.CLOSE_BOX|wx.DEFAULT_DIALOG_STYLE|wx.MINIMIZE_BOX|wx.RESIZE_BORDER|wx.STAY_ON_TOP ) - - self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize ) - - bSizer1 = wx.BoxSizer( wx.VERTICAL ) - - self.m_scrolledWindow1 = wx.ScrolledWindow( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.HSCROLL|wx.VSCROLL ) - self.m_scrolledWindow1.SetScrollRate( 5, 5 ) - fgSizer1 = wx.FlexGridSizer( 3, 2, 0, 0 ) - fgSizer1.AddGrowableCol( 1 ) - fgSizer1.SetFlexibleDirection( wx.VERTICAL ) - fgSizer1.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED ) - - self.m_staticText1 = wx.StaticText( self.m_scrolledWindow1, wx.ID_ANY, u"Mesh net name prefix", wx.DefaultPosition, wx.DefaultSize, 0 ) - self.m_staticText1.Wrap( -1 ) - fgSizer1.Add( self.m_staticText1, 1, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT|wx.ALL, 5 ) - - self.m_net_prefix = wx.TextCtrl( self.m_scrolledWindow1, wx.ID_ANY, u"mesh-", wx.DefaultPosition, wx.DefaultSize, 0 ) - fgSizer1.Add( self.m_net_prefix, 2, wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, 5 ) - - - fgSizer1.AddSpacer( ( 0, 0), 1, wx.EXPAND, 5 ) - - self.m_netLabel = wx.StaticText( self.m_scrolledWindow1, wx.ID_ANY, u"0 matching nets", wx.DefaultPosition, wx.DefaultSize, 0 ) - self.m_netLabel.Wrap( -1 ) - fgSizer1.Add( self.m_netLabel, 0, wx.ALL, 5 ) - - self.m_staticText3 = wx.StaticText( self.m_scrolledWindow1, wx.ID_ANY, u"Mesh angle", wx.DefaultPosition, wx.DefaultSize, 0 ) - self.m_staticText3.Wrap( -1 ) - fgSizer1.Add( self.m_staticText3, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT|wx.ALL, 5 ) - - bSizer4 = wx.BoxSizer( wx.HORIZONTAL ) - - self.m_angleInput = wx.TextCtrl( self.m_scrolledWindow1, wx.ID_ANY, u"0.00", wx.DefaultPosition, wx.DefaultSize, 0 ) - bSizer4.Add( self.m_angleInput, 0, wx.ALIGN_CENTER_VERTICAL, 5 ) - - self.m_staticText5 = wx.StaticText( self.m_scrolledWindow1, wx.ID_ANY, u"° (deg)", wx.DefaultPosition, wx.DefaultSize, 0 ) - self.m_staticText5.Wrap( -1 ) - bSizer4.Add( self.m_staticText5, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) - - - fgSizer1.Add( bSizer4, 1, wx.EXPAND, 5 ) - - self.m_staticText4 = wx.StaticText( self.m_scrolledWindow1, wx.ID_ANY, u"Trace width", wx.DefaultPosition, wx.DefaultSize, 0 ) - self.m_staticText4.Wrap( -1 ) - fgSizer1.Add( self.m_staticText4, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT|wx.ALL, 5 ) - - bSizer5 = wx.BoxSizer( wx.HORIZONTAL ) - - self.m_traceInput = wx.TextCtrl( self.m_scrolledWindow1, wx.ID_ANY, u"0.127", wx.DefaultPosition, wx.DefaultSize, 0 ) - bSizer5.Add( self.m_traceInput, 0, wx.ALIGN_CENTER_VERTICAL, 5 ) - - self.m_spinBtn1 = wx.SpinButton( self.m_scrolledWindow1, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.SP_VERTICAL ) - bSizer5.Add( self.m_spinBtn1, 0, wx.ALL, 5 ) - - self.m_staticText6 = wx.StaticText( self.m_scrolledWindow1, wx.ID_ANY, u"mm", wx.DefaultPosition, wx.DefaultSize, 0 ) - self.m_staticText6.Wrap( -1 ) - bSizer5.Add( self.m_staticText6, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) - - - fgSizer1.Add( bSizer5, 1, wx.EXPAND, 5 ) - - self.m_staticText7 = wx.StaticText( self.m_scrolledWindow1, wx.ID_ANY, u"Space width", wx.DefaultPosition, wx.DefaultSize, 0 ) - self.m_staticText7.Wrap( -1 ) - fgSizer1.Add( self.m_staticText7, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT|wx.ALL, 5 ) - - bSizer6 = wx.BoxSizer( wx.HORIZONTAL ) - - self.m_spaceInput = wx.TextCtrl( self.m_scrolledWindow1, wx.ID_ANY, u"0.127", wx.DefaultPosition, wx.DefaultSize, 0 ) - bSizer6.Add( self.m_spaceInput, 0, wx.ALIGN_CENTER_VERTICAL, 5 ) - - self.m_spinBtn2 = wx.SpinButton( self.m_scrolledWindow1, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.SP_VERTICAL ) - bSizer6.Add( self.m_spinBtn2, 0, wx.ALL, 5 ) - - self.m_staticText8 = wx.StaticText( self.m_scrolledWindow1, wx.ID_ANY, u"mm", wx.DefaultPosition, wx.DefaultSize, 0 ) - self.m_staticText8.Wrap( -1 ) - bSizer6.Add( self.m_staticText8, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) - - - fgSizer1.Add( bSizer6, 1, wx.EXPAND, 5 ) - - - self.m_scrolledWindow1.SetSizer( fgSizer1 ) - self.m_scrolledWindow1.Layout() - fgSizer1.Fit( self.m_scrolledWindow1 ) - bSizer1.Add( self.m_scrolledWindow1, 1, wx.EXPAND |wx.ALL, 5 ) - - bSizer99 = wx.BoxSizer( wx.HORIZONTAL ) - - self.m_cancelButton = wx.Button( self, wx.ID_ANY, u"Cancel", wx.DefaultPosition, wx.DefaultSize, 0 ) - bSizer99.Add( self.m_cancelButton, 0, wx.ALL, 5 ) - - - bSizer99.AddSpacer( ( 0, 0), 1, wx.EXPAND, 5 ) - - self.m_removeButton = wx.Button( self, wx.ID_ANY, u"Remove Mesh Traces", wx.DefaultPosition, wx.DefaultSize, 0 ) - bSizer99.Add( self.m_removeButton, 0, wx.ALL, 5 ) - - self.m_generateButton = wx.Button( self, wx.ID_ANY, u"Generate", wx.DefaultPosition, wx.DefaultSize, 0 ) - bSizer99.Add( self.m_generateButton, 0, wx.ALL, 5 ) - - - bSizer1.Add( bSizer99, 0, wx.ALL|wx.EXPAND, 3 ) - - - self.SetSizer( bSizer1 ) - self.Layout() - - self.Centre( wx.BOTH ) - - def __del__( self ): - pass - - +# -*- coding: utf-8 -*- + +########################################################################### +## Python code generated with wxFormBuilder (version Oct 26 2018) +## http://www.wxformbuilder.org/ +## +## PLEASE DO *NOT* EDIT THIS FILE! +########################################################################### + +import wx +import wx.xrc + +########################################################################### +## Class MainDialog +########################################################################### + +class MainDialog ( wx.Dialog ): + + def __init__( self, parent ): + wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = u"Security Mesh Generator Plugin", pos = wx.DefaultPosition, size = wx.Size( 588,356 ), style = wx.CLOSE_BOX|wx.DEFAULT_DIALOG_STYLE|wx.MINIMIZE_BOX|wx.RESIZE_BORDER|wx.STAY_ON_TOP ) + + self.SetSizeHints( wx.DefaultSize, wx.DefaultSize ) + + bSizer1 = wx.BoxSizer( wx.VERTICAL ) + + self.m_scrolledWindow1 = wx.ScrolledWindow( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.HSCROLL|wx.VSCROLL ) + self.m_scrolledWindow1.SetScrollRate( 5, 5 ) + fgSizer1 = wx.FlexGridSizer( 8, 2, 0, 0 ) + fgSizer1.AddGrowableCol( 1 ) + fgSizer1.SetFlexibleDirection( wx.BOTH ) + fgSizer1.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED ) + + self.m_staticText1 = wx.StaticText( self.m_scrolledWindow1, wx.ID_ANY, u"Mesh net name prefix", wx.DefaultPosition, wx.DefaultSize, 0 ) + self.m_staticText1.Wrap( -1 ) + + fgSizer1.Add( self.m_staticText1, 1, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT|wx.ALL, 5 ) + + self.m_net_prefix = wx.TextCtrl( self.m_scrolledWindow1, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) + fgSizer1.Add( self.m_net_prefix, 2, wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, 5 ) + + + fgSizer1.Add( ( 0, 0), 0, wx.EXPAND, 5 ) + + self.m_netLabel = wx.StaticText( self.m_scrolledWindow1, wx.ID_ANY, u"0 matching nets", wx.DefaultPosition, wx.DefaultSize, 0 ) + self.m_netLabel.Wrap( -1 ) + + fgSizer1.Add( self.m_netLabel, 0, wx.ALL, 5 ) + + self.m_staticText3 = wx.StaticText( self.m_scrolledWindow1, wx.ID_ANY, u"Mesh angle", wx.DefaultPosition, wx.DefaultSize, 0 ) + self.m_staticText3.Wrap( -1 ) + + fgSizer1.Add( self.m_staticText3, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT|wx.ALL, 5 ) + + bSizer4 = wx.BoxSizer( wx.HORIZONTAL ) + + self.m_angleSpin = wx.SpinCtrlDouble( self.m_scrolledWindow1, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS|wx.SP_WRAP, 0, 360, 0.000000, 1 ) + self.m_angleSpin.SetDigits( 2 ) + bSizer4.Add( self.m_angleSpin, 0, wx.ALL, 5 ) + + self.m_staticText5 = wx.StaticText( self.m_scrolledWindow1, wx.ID_ANY, u"° (deg)", wx.DefaultPosition, wx.DefaultSize, 0 ) + self.m_staticText5.Wrap( -1 ) + + bSizer4.Add( self.m_staticText5, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) + + + fgSizer1.Add( bSizer4, 1, wx.EXPAND, 5 ) + + self.m_staticText4 = wx.StaticText( self.m_scrolledWindow1, wx.ID_ANY, u"Trace width", wx.DefaultPosition, wx.DefaultSize, 0 ) + self.m_staticText4.Wrap( -1 ) + + fgSizer1.Add( self.m_staticText4, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT|wx.ALL, 5 ) + + bSizer5 = wx.BoxSizer( wx.HORIZONTAL ) + + self.m_traceSpin = wx.SpinCtrlDouble( self.m_scrolledWindow1, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 0, 1000, 0.127, 0.1 ) + self.m_traceSpin.SetDigits( 3 ) + bSizer5.Add( self.m_traceSpin, 0, wx.ALL, 5 ) + + self.m_staticText6 = wx.StaticText( self.m_scrolledWindow1, wx.ID_ANY, u"mm", wx.DefaultPosition, wx.DefaultSize, 0 ) + self.m_staticText6.Wrap( -1 ) + + bSizer5.Add( self.m_staticText6, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) + + + fgSizer1.Add( bSizer5, 1, wx.EXPAND, 5 ) + + self.m_staticText7 = wx.StaticText( self.m_scrolledWindow1, wx.ID_ANY, u"Space width", wx.DefaultPosition, wx.DefaultSize, 0 ) + self.m_staticText7.Wrap( -1 ) + + fgSizer1.Add( self.m_staticText7, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT|wx.ALL, 5 ) + + bSizer6 = wx.BoxSizer( wx.HORIZONTAL ) + + self.m_spaceSpin = wx.SpinCtrlDouble( self.m_scrolledWindow1, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 0, 1000, 0.127, 0.1 ) + self.m_spaceSpin.SetDigits( 3 ) + bSizer6.Add( self.m_spaceSpin, 0, wx.ALL, 5 ) + + self.m_staticText8 = wx.StaticText( self.m_scrolledWindow1, wx.ID_ANY, u"mm", wx.DefaultPosition, wx.DefaultSize, 0 ) + self.m_staticText8.Wrap( -1 ) + + bSizer6.Add( self.m_staticText8, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) + + + fgSizer1.Add( bSizer6, 1, wx.EXPAND, 5 ) + + self.m_staticText11 = wx.StaticText( self.m_scrolledWindow1, wx.ID_ANY, u"Anchor exit direction", wx.DefaultPosition, wx.DefaultSize, 0 ) + self.m_staticText11.Wrap( -1 ) + + fgSizer1.Add( self.m_staticText11, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT|wx.ALL, 5 ) + + bSizer41 = wx.BoxSizer( wx.HORIZONTAL ) + + self.m_exitSpin = wx.SpinCtrlDouble( self.m_scrolledWindow1, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS|wx.SP_WRAP, 0, 360, 0.000000, 45 ) + self.m_exitSpin.SetDigits( 0 ) + bSizer41.Add( self.m_exitSpin, 0, wx.ALL, 5 ) + + self.m_staticText51 = wx.StaticText( self.m_scrolledWindow1, wx.ID_ANY, u"° (deg)", wx.DefaultPosition, wx.DefaultSize, 0 ) + self.m_staticText51.Wrap( -1 ) + + bSizer41.Add( self.m_staticText51, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) + + + fgSizer1.Add( bSizer41, 1, wx.EXPAND, 5 ) + + self.m_staticText12 = wx.StaticText( self.m_scrolledWindow1, wx.ID_ANY, u"Number of mesh traces", wx.DefaultPosition, wx.DefaultSize, 0 ) + self.m_staticText12.Wrap( -1 ) + + fgSizer1.Add( self.m_staticText12, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT|wx.ALL, 5 ) + + self.m_traceCountSpin = wx.SpinCtrl( self.m_scrolledWindow1, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 0, 1000, 2 ) + fgSizer1.Add( self.m_traceCountSpin, 1, wx.ALL, 5 ) + + self.m_staticText13 = wx.StaticText( self.m_scrolledWindow1, wx.ID_ANY, u"Mesh origin offset", wx.DefaultPosition, wx.DefaultSize, 0 ) + self.m_staticText13.Wrap( -1 ) + + fgSizer1.Add( self.m_staticText13, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT|wx.ALL, 5 ) + + bSizer9 = wx.BoxSizer( wx.HORIZONTAL ) + + self.m_staticText15 = wx.StaticText( self.m_scrolledWindow1, wx.ID_ANY, u"x", wx.DefaultPosition, wx.DefaultSize, 0 ) + self.m_staticText15.Wrap( -1 ) + + bSizer9.Add( self.m_staticText15, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) + + self.m_offsetXSpin = wx.SpinCtrlDouble( self.m_scrolledWindow1, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, -100, 100, 0, 0.1 ) + self.m_offsetXSpin.SetDigits( 3 ) + bSizer9.Add( self.m_offsetXSpin, 0, wx.ALL, 5 ) + + self.m_staticText17 = wx.StaticText( self.m_scrolledWindow1, wx.ID_ANY, u"mm", wx.DefaultPosition, wx.DefaultSize, 0 ) + self.m_staticText17.Wrap( -1 ) + + bSizer9.Add( self.m_staticText17, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) + + self.m_staticText16 = wx.StaticText( self.m_scrolledWindow1, wx.ID_ANY, u"y", wx.DefaultPosition, wx.DefaultSize, 0 ) + self.m_staticText16.Wrap( -1 ) + + bSizer9.Add( self.m_staticText16, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) + + self.m_offsetYSpin = wx.SpinCtrlDouble( self.m_scrolledWindow1, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, -100, 100, 0, 0.1 ) + self.m_offsetYSpin.SetDigits( 3 ) + bSizer9.Add( self.m_offsetYSpin, 0, wx.ALL, 5 ) + + self.m_staticText18 = wx.StaticText( self.m_scrolledWindow1, wx.ID_ANY, u"mm", wx.DefaultPosition, wx.DefaultSize, 0 ) + self.m_staticText18.Wrap( -1 ) + + bSizer9.Add( self.m_staticText18, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) + + + fgSizer1.Add( bSizer9, 2, wx.EXPAND, 5 ) + + + self.m_scrolledWindow1.SetSizer( fgSizer1 ) + self.m_scrolledWindow1.Layout() + fgSizer1.Fit( self.m_scrolledWindow1 ) + bSizer1.Add( self.m_scrolledWindow1, 1, wx.EXPAND |wx.ALL, 5 ) + + bSizer99 = wx.BoxSizer( wx.HORIZONTAL ) + + self.m_cancelButton = wx.Button( self, wx.ID_ANY, u"Close", wx.DefaultPosition, wx.DefaultSize, 0 ) + bSizer99.Add( self.m_cancelButton, 0, wx.ALL, 5 ) + + + bSizer99.Add( ( 0, 0), 1, wx.EXPAND, 5 ) + + self.m_removeButton = wx.Button( self, wx.ID_ANY, u"Remove Mesh Traces", wx.DefaultPosition, wx.DefaultSize, 0 ) + bSizer99.Add( self.m_removeButton, 0, wx.ALL, 5 ) + + self.m_generateButton = wx.Button( self, wx.ID_ANY, u"Generate", wx.DefaultPosition, wx.DefaultSize, 0 ) + bSizer99.Add( self.m_generateButton, 0, wx.ALL, 5 ) + + + bSizer1.Add( bSizer99, 0, wx.ALL|wx.EXPAND, 3 ) + + + self.SetSizer( bSizer1 ) + self.Layout() + + self.Centre( wx.BOTH ) + + def __del__( self ): + pass + + -- cgit