first new working version

This commit is contained in:
easyw
2019-11-04 21:35:33 +01:00
parent bca31caa15
commit 75d51c27e2
3 changed files with 31 additions and 184 deletions

View File

@ -17,13 +17,13 @@ import wx.xrc
class Move2LayerDlg ( wx.Dialog ):
def __init__( self, parent ):
wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = u"Move to Layer", pos = wx.DefaultPosition, size = wx.Size( 325,180 ), style = wx.CAPTION|wx.CLOSE_BOX|wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER )
wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = u"Move to Layer", pos = wx.DefaultPosition, size = wx.Size( 325,190 ), style = wx.CAPTION|wx.CLOSE_BOX|wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER )
self.SetSizeHints( wx.DefaultSize, wx.DefaultSize )
bSizer3 = wx.BoxSizer( wx.VERTICAL )
self.m_comment = wx.StaticText( self, wx.ID_ANY, u"Select Objects to Move to Layer\n", wx.DefaultPosition, wx.DefaultSize, 0 )
self.m_comment = wx.StaticText( self, wx.ID_ANY, u"Selected Objects to Move to chosen Layer", wx.DefaultPosition, wx.DefaultSize, 0 )
self.m_comment.Wrap( -1 )
bSizer3.Add( self.m_comment, 0, wx.ALL|wx.EXPAND, 5 )

View File

@ -25,10 +25,30 @@ from pcbnew import *
import base64
from wx.lib.embeddedimage import PyEmbeddedImage
import os
___version___="1.2.1"
___version___="1.2.2"
from . import Move2LayerDlg
def MoveToLayer(pcb,layerId):
for drw in pcb.GetDrawings():
if drw.IsSelected():
drw.SetLayer(layerId)
found_selected=True
if found_selected!=True:
LogMsg="select lines to be moved to new layer\n"
LogMsg+="use GAL for selecting lines"
wx.LogMessage(LogMsg)
else:
pcbnew.Refresh()
layerName = pcbnew.GetBoard().GetLayerName(layerId)
LogMsg="selected drawings moved to "+layerName+" layer"
wx.LogMessage(LogMsg)
#
# Python plugin stuff
class Move2Layer_Dlg(Move2LayerDlg.Move2LayerDlg):
@ -81,127 +101,16 @@ class move_to_draw_layer( pcbnew.ActionPlugin ):
of the plugin
"""
import os
self.name = "Move Selected drawings to chosen Layer\nversion "+___version___
self.name = "Move Selected Drawings to chosen Layer\nversion "+___version___
self.category = "Modify PCB"
self.description = "Move Selected drawings to chosen Layer on an existing PCB"
self.description = "Move Selected Drawings to chosen Layer on an existing PCB"
self.icon_file_name = os.path.join(os.path.dirname(__file__), "./move2layer.png")
self.show_toolbar_button = True
def Run( self ):
found_selected=False
#wx.MessageDialog(self.frame,"ciao")
#subprocess.check_call(["C:\pathToYourProgram\yourProgram.exe", "your", "arguments", "comma", "separated"])
#http://stackoverflow.com/questions/1811691/running-an-outside-program-executable-in-python
def switch(x):
return {
'Edge_Cuts': pcbnew.Edge_Cuts,
'Eco1_User': pcbnew.Eco1_User,
'Eco2_User': pcbnew.Eco2_User,
'Dwgs_User': pcbnew.Dwgs_User,
'Cmts_User': pcbnew.Cmts_User,
'Margin' : pcbnew.Margin,
'F_CrtYd' : pcbnew.F_CrtYd,
'B_CrtYd' : pcbnew.B_CrtYd,
'F_Fab' : pcbnew.F_Fab,
'B_Fab' : pcbnew.B_Fab,
'F_SilkS' : pcbnew.F_SilkS,
'B_SilkS' : pcbnew.B_SilkS,
}[x]
# class displayDialog(wx.Dialog):
# """
# The default frame
# http://stackoverflow.com/questions/3566603/how-do-i-make-wx-textctrl-multi-line-text-update-smoothly
# """
#
# #----------------------------------------------------------------------
# #def __init__(self):
# # """Constructor"""
# # wx.Frame.__init__(self, None, title="Display Frame", style=wx.DEFAULT_FRAME_STYLE, wx.ICON_INFORMATION)
# # panel = wx.Panel(self)
# def __init__(self, parent):
# wx.Dialog.__init__(self, parent, id=-1, title="Move to Layer")#
# #, style=wx.DEFAULT_DIALOG_STYLE, wx.ICON_INFORMATION)
# #, style=wx.DEFAULT_DIALOG_STYLE, wx.ICON_INFORMATION)
# #, pos=DefaultPosition, size=DefaultSize, style = wx.DEFAULT_FRAME_STYLE & (~wx.MAXIMIZE_BOX), name="fname")
# #, wx.ICON_INFORMATION) #, title="Annular Check", style=wx.DEFAULT_FRAME_STYLE, wx.ICON_INFORMATION)
# #
#
# self.SetIcon(PyEmbeddedImage(move_to_layer_ico_b64_data).GetIcon())
# #wx.IconFromBitmap(wx.Bitmap("icon.ico", wx.BITMAP_TYPE_ANY)))
# self.panel = wx.Panel(self)
#
# self.ct = 0
# self.layerSelection = "Edge_Cuts"
# layerList = ["Edge_Cuts", "Eco1_User", "Eco2_User", "Dwgs_User", "Cmts_User", "Margin", "F_CrtYd", "B_CrtYd", "F_Fab", "B_Fab", "F_SilkS", "B_SilkS"]
# self.combo = wx.ComboBox(self.panel, choices=layerList)
# self.combo.SetSelection(0)
#
# self.combo.Bind(wx.EVT_COMBOBOX, self.onCombo)
#
# self.title = wx.StaticText(self.panel, label="Move to Layer:")
# #self.result = wx.StaticText(self.panel, label="")
# #self.result.SetForegroundColour('#FF0000')
# #self.button = wx.Button(self.panel, label="Save")
# #self.lblname = wx.StaticText(self.panel, label="Your name:")
# #self.editname = wx.TextCtrl(self.panel, size=(140, -1))
# ##self.editname = wx.TextCtrl(self.panel, size = (300, 400), style = wx.TE_MULTILINE|wx.TE_READONLY)
#
#
# # Set sizer for the frame, so we can change frame size to match widgets
# self.windowSizer = wx.BoxSizer()
# self.windowSizer.Add(self.panel, 1, wx.ALL | wx.EXPAND)
#
# # Set sizer for the panel content
# self.sizer = wx.GridBagSizer(5, 0)
# self.sizer.Add(self.title, (0, 0))
# self.button = wx.Button(self.panel, label="OK")
# self.sizer.Add(self.button, (2, 0), (1, 2), flag=wx.EXPAND)
# #self.sizer.Add(self.result, (1, 0))
# #self.sizer.Add(self.lblname, (1, 0))
# ##self.sizer.Add(self.editname, (1, 0))
# self.sizer.Add(self.combo, (1, 0))
# #self.sizer.Add(self.button, (2, 0), (1, 2), flag=wx.EXPAND)
#
# # Set simple sizer for a nice border
# self.border = wx.BoxSizer()
# self.border.Add(self.sizer, 1, wx.ALL | wx.EXPAND, 5)
#
# # Use the sizers
# self.panel.SetSizerAndFit(self.border)
# self.SetSizerAndFit(self.windowSizer)
#
# #self.button = wx.Button(self.panel, label="Close")
# self.button.Bind(wx.EVT_BUTTON, self.OnClose)
# self.Bind(wx.EVT_CLOSE,self.OnClose)
#
# #----------------------------------------------------------------------
# def OnClose(self,e):
# #wx.LogMessage("c")
# e.Skip()
# self.Close()
# #self.result.SetLabel(msg)
# # Set event handlers
# #self.button.Bind(wx.EVT_BUTTON, self.OnButton)
# #self.Show()
# #self.Bind(wx.EVT_CLOSE,self.OnClose)
# def onCombo(self, event):
# """
# """
# self.layerSelection = self.combo.GetValue()
#
# #def OnClose(self,e):
# # #wx.LogMessage("c")
# # e.Skip()
# #self.Close()
#
# #def OnButton(self, e):
# # self.result.SetLabel(self.editname.GetValue())
# #def setMsg(self, t_msg):
# # self.editname.SetValue(t_msg)
board = pcbnew.GetBoard()
#wx.MessageDialog(None, 'This is a message box.', 'Test', wx.OK | wx.ICON_INFORMATION).ShowModal()
fileName = GetBoard().GetFileName()
# # dicts for converting layer name to id, used by _get_layer
# _std_layer_dict = {pcbnew.BOARD_GetStandardLayerName(n): n
@ -228,79 +137,17 @@ class move_to_draw_layer( pcbnew.ActionPlugin ):
modal_result = aParameters.ShowModal()
if modal_result == wx.ID_OK:
LayerName = aParameters.m_comboBoxLayer.GetStringSelection()
idx = aParameters.m_comboBoxLayer.FindString(LayerName)
LayerStdName = pcbnew.BOARD_GetStandardLayerName(idx)
wx.LogMessage(LayerName+';'+str(idx)+';'+LayerStdName)
#MoveToLayer(pcb, Layer)
LayerIndex = aParameters.m_comboBoxLayer.FindString(LayerName)
LayerStdName = pcbnew.BOARD_GetStandardLayerName(LayerIndex)
#wx.LogMessage(LayerName+';'+str(LayerIndex)+';'+LayerStdName)
MoveToLayer(board, LayerIndex)
else:
None # Cancel
LogMsg=''
msg="'move to layer tool'\n"
msg+="version = "+___version___
#wx.LogMessage(LogMsg)
# frame = displayDialog(None)
# #frame = wx.Frame(None)
# frame.Center()
# #frame.setMsg(LogMsg)
# frame.ShowModal()
# #dlg.Destroy()
# frame.Destroy()
#dlg=wx.MessageBox( 'Changing Layer for Selected?', 'Confirm', wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION )
#dlg=wx.MessageBox( 'Changing Layer for Selected '+frame.layerSelection+ '?', 'Confirm', wx.YES_NO | wx.NO_DEFAULT | wx.ICON_WARNING )
#if dlg == wx.YES:
# #wx.LogMessage("YES")
# #wx.LogMessage(str(board.IsModified()))
# #board.SetModified()
# #wx.LogMessage(str(board.IsModified()))
# #try:
# # board_drawings=board.GetDrawings()
# #except:
# # board_drawings=board.DrawingsList()
# #
# #for drw in board_drawings:
# for drw in board.GetDrawings():
# if drw.IsSelected():
# drw.SetLayer(switch(frame.layerSelection))
# found_selected=True
#
# if found_selected!=True:
# LogMsg="select lines to be moved to new layer\n"
# LogMsg+="use GAL for selecting lines"
# wx.LogMessage(LogMsg)
# else:
# pcbnew.Refresh()
# LogMsg="selected drawings moved to "+frame.layerSelection+" layer"
#move_to_draw_layer().register()
# pcbnew.F_Cu
# pcbnew.In1_Cu
# pcbnew.In2_Cu
#..
# pcbnew.In30_Cu
# pcbnew.B_Cu
# pcbnew.B_Adhes
# pcbnew.F_Adhes
# pcbnew.B_Paste
# pcbnew.F_Paste
# pcbnew.B_SilkS
# pcbnew.F_SilkS
# pcbnew.B_Mask
# pcbnew.F_Mask
# pcbnew.Dwgs_User
# pcbnew.Cmts_User
# pcbnew.Eco1_User
# pcbnew.Eco2_User
# pcbnew.Edge_Cuts
# pcbnew.Margin
# pcbnew.B_CrtYd
# pcbnew.F_CrtYd
# pcbnew.B_Fab
# pcbnew.F_Fab

View File

@ -45,7 +45,7 @@
<property name="minimum_size"></property>
<property name="name">Move2LayerDlg</property>
<property name="pos"></property>
<property name="size">325,180</property>
<property name="size">325,190</property>
<property name="style">wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
<property name="subclass"></property>
<property name="title">Move to Layer</property>
@ -90,7 +90,7 @@
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Select Objects to Move to Layer&#x0A;</property>
<property name="label">Selected Objects will Move to chosen Layer</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>