Added search functionality to gcode editor.
Merge branch 'experimental' of https://github.com/jezmy/Printrun into experimental Conflicts: gviz.pymaster
commit
120740f002
3
gviz.py
3
gviz.py
|
@ -13,7 +13,8 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with Printrun. If not, see <http://www.gnu.org/licenses/>.
|
||||
import wx,time
|
||||
|
||||
ID_ABOUT = 101
|
||||
ID_EXIT = 110
|
||||
class window(wx.Frame):
|
||||
def __init__(self,f,size=(600,600),build_dimensions=[200,200,100,0,0,0],grid=(10,50),extrusion_width=0.5):
|
||||
wx.Frame.__init__(self,None,title="Gcode view, shift to move view, mousewheel to set layer",size=(size[0],size[1]))
|
||||
|
|
|
@ -38,6 +38,7 @@ StringIO=cStringIO
|
|||
|
||||
thread=threading.Thread
|
||||
winsize=(800,500)
|
||||
layerindex=0
|
||||
if os.name=="nt":
|
||||
winsize=(800,530)
|
||||
try:
|
||||
|
@ -916,18 +917,6 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
|
|||
|
||||
def cbutton_edit(self,e,button=None):
|
||||
bedit=ButtonEdit(self)
|
||||
def okhandler(event):
|
||||
if event.GetId()==wx.ID_OK:
|
||||
if n==len(self.custombuttons):
|
||||
self.custombuttons+=[None]
|
||||
self.custombuttons[n]=[bedit.name.GetValue().strip(),bedit.command.GetValue().strip()]
|
||||
if bedit.color.GetValue().strip()!="":
|
||||
self.custombuttons[n]+=[bedit.color.GetValue()]
|
||||
self.cbutton_save(n,self.custombuttons[n])
|
||||
bedit.Destroy()
|
||||
self.cbuttons_reload()
|
||||
|
||||
bedit.Bind(wx.EVT_BUTTON,okhandler)
|
||||
if button is not None:
|
||||
n = button.custombutton
|
||||
bedit.name.SetValue(button.properties[0])
|
||||
|
@ -946,8 +935,15 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
|
|||
n = len(self.custombuttons)
|
||||
while n>0 and self.custombuttons[n-1] is None:
|
||||
n -= 1
|
||||
bedit.Show()
|
||||
|
||||
if bedit.ShowModal()==wx.ID_OK:
|
||||
if n==len(self.custombuttons):
|
||||
self.custombuttons+=[None]
|
||||
self.custombuttons[n]=[bedit.name.GetValue().strip(),bedit.command.GetValue().strip()]
|
||||
if bedit.color.GetValue().strip()!="":
|
||||
self.custombuttons[n]+=[bedit.color.GetValue()]
|
||||
self.cbutton_save(n,self.custombuttons[n])
|
||||
bedit.Destroy()
|
||||
self.cbuttons_reload()
|
||||
|
||||
def cbutton_remove(self,e,button):
|
||||
n = button.custombutton
|
||||
|
@ -1441,7 +1437,6 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
|
|||
if self.p.online:
|
||||
wx.CallAfter(self.printbtn.Enable)
|
||||
threading.Thread(target=self.loadviz).start()
|
||||
dlg.Destroy()
|
||||
|
||||
def loadviz(self):
|
||||
Xtot,Ytot,Ztot,Xmin,Xmax,Ymin,Ymax,Zmin,Zmax = pronsole.measurements(self.f)
|
||||
|
@ -1635,6 +1630,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
|
|||
|
||||
class macroed(wx.Dialog):
|
||||
"""Really simple editor to edit macro definitions"""
|
||||
|
||||
def __init__(self,macro_name,definition,callback,gcode=False):
|
||||
self.indent_chars = " "
|
||||
title=" macro %s"
|
||||
|
@ -1645,19 +1641,22 @@ class macroed(wx.Dialog):
|
|||
self.callback = callback
|
||||
self.panel=wx.Panel(self,-1)
|
||||
titlesizer=wx.BoxSizer(wx.HORIZONTAL)
|
||||
title = wx.StaticText(self.panel,-1,title%macro_name)
|
||||
titletext = wx.StaticText(self.panel,-1," _") #title%macro_name)
|
||||
#title.SetFont(wx.Font(11,wx.NORMAL,wx.NORMAL,wx.BOLD))
|
||||
titlesizer.Add(title,1)
|
||||
titlesizer.Add(titletext,1)
|
||||
self.findb = wx.Button(self.panel, -1, _("Find")) #New button for "Find" (Jezmy)
|
||||
self.findb.Bind(wx.EVT_BUTTON, self.find)
|
||||
self.okb = wx.Button(self.panel, -1, _("Save"))
|
||||
self.okb.Bind(wx.EVT_BUTTON, self.save)
|
||||
self.Bind(wx.EVT_CLOSE, self.close)
|
||||
titlesizer.Add(self.findb)
|
||||
titlesizer.Add(self.okb)
|
||||
self.cancelb = wx.Button(self.panel, -1, _("Cancel"))
|
||||
self.cancelb.Bind(wx.EVT_BUTTON, self.close)
|
||||
titlesizer.Add(self.cancelb)
|
||||
topsizer=wx.BoxSizer(wx.VERTICAL)
|
||||
topsizer.Add(titlesizer,0,wx.EXPAND)
|
||||
self.e=wx.TextCtrl(self.panel,style=wx.TE_MULTILINE+wx.HSCROLL,size=(200,200))
|
||||
self.e=wx.TextCtrl(self.panel,style=wx.TE_MULTILINE+wx.HSCROLL,size=(400,400))
|
||||
if not self.gcode:
|
||||
self.e.SetValue(self.unindent(definition))
|
||||
else:
|
||||
|
@ -1669,6 +1668,37 @@ class macroed(wx.Dialog):
|
|||
self.Show()
|
||||
self.e.SetFocus()
|
||||
|
||||
def find(self,ev):
|
||||
# Ask user what to look for, find it and point at it ... (Jezmy)
|
||||
S = self.e.GetStringSelection()
|
||||
if not S :
|
||||
S = "Z"
|
||||
FindValue = wx.GetTextFromUser('Please enter a search string:', caption="Search", default_value=S, parent=None)
|
||||
somecode = self.e.GetValue()
|
||||
numLines = len(somecode)
|
||||
position = somecode.find(FindValue, self.e.GetInsertionPoint())
|
||||
if position == -1 :
|
||||
# ShowMessage(self,-1, "Not found!")
|
||||
titletext = wx.TextCtrl(self.panel,-1,"Not Found!")
|
||||
|
||||
|
||||
else:
|
||||
# self.title.SetValue("Position : "+str(position))
|
||||
|
||||
titletext = wx.TextCtrl(self.panel,-1,str(position))
|
||||
|
||||
# ananswer = wx.MessageBox(str(numLines)+" Lines detected in file\n"+str(position), "OK")
|
||||
self.e.SetFocus()
|
||||
self.e.SetInsertionPoint(position)
|
||||
self.e.SetSelection(position, position + len(FindValue))
|
||||
self.e.ShowPosition(position)
|
||||
|
||||
def ShowMessage(self, ev , message):
|
||||
dlg = wxMessageDialog(self, message,
|
||||
"Info!", wxOK | wxICON_INFORMATION)
|
||||
dlg.ShowModal()
|
||||
dlg.Destroy()
|
||||
|
||||
def save(self,ev):
|
||||
self.Destroy()
|
||||
if not self.gcode:
|
||||
|
@ -1760,8 +1790,6 @@ class ButtonEdit(wx.Dialog):
|
|||
topsizer.Add( (0,0),1)
|
||||
topsizer.Add(self.CreateStdDialogButtonSizer(wx.OK|wx.CANCEL),0,wx.ALIGN_CENTER)
|
||||
self.SetSizer(topsizer)
|
||||
self.handler=None
|
||||
|
||||
def macrob_enabler(self,e):
|
||||
macro = self.command.GetValue()
|
||||
valid = False
|
||||
|
|
Loading…
Reference in New Issue