199
169
self.__sel.ElemSelRect(self.__prevx1, self.__prevy1, self.__prevx2, self.__prevy2)
200
170
self.SetAction('elementsel')
202
if self.__action== 'pointsel':
172
elif self.__action== 'pointsel':
204
174
# select points and set action pointsel again
205
175
# self.__sel.PointSelRect(x1, y1, x2, y2)
206
176
# self.SetAction('pointsel')
208
if self.__action== 'line':
209
# add line, default attributes
210
colour, layer, penstyle, pensize= self.__drawings[self.__activedraw].GetDefAttr()
212
# coords: x1, y1, x2, y2
178
elif self.__action== 'line':
179
# add line, coords: x1, y1, x2, y2
213
180
coords= (self.__prevx1, self.__prevy1, self.__prevx2, self.__prevy2)
215
182
# Add with addlist: [('typ', attributes), ..]
216
self.__drawings[self.__activedraw].Add([('L', (colour, layer, penstyle, pensize, coords))])
184
self.__drawings[self.__attribute.GetDefaultDraw()].Add([('L', (self.__attribute.GetDefaultColor(), self.__attribute.GetDefaultLayer(), self.__attribute.GetDefaultStyle(), self.__attribute.GetDefaultWidth(), coords))])
218
186
self.SetAction('line')
526
494
return (self.__action)
529
def SetActiveDraw(self, activedraw):
530
self.__activedraw= activedraw
533
def GetActiveDraw(self):
534
return(self.__activedraw)
537
def PaintDrawing(self, dc, lrzelem):
497
def SetDefAttributes(self, color, layer, style, width):
498
# set defaults for drawing in LorzeAttribute
499
self.__attribute.SetDefaultColor(color)
500
self.__attribute.SetDefaultLayer(layer)
501
self.__attribute.SetDefaultStyle(style)
502
self.__attribute.SetDefaultWidth(width)
505
def SetDefDrawing(self, defdraw):
506
# set defaults for drawing in LorzeAttribute
507
self.__attribute.SetDefaultDraw(defdraw)
510
def GetDefAttributes(self):
511
# get defaults for drawing from LorzeAttribute, return drawing, colour, layer, style, width
512
return(self.__attribute.GetDefaultColor(), self.__attribute.GetDefaultLayer(), self.__attribute.GetDefaultStyle(), self.__attribute.GetDefaultWidth())
515
def GetDefDrawing(self):
516
# get defaults for drawing from LorzeAttribute, return drawing, colour, layer, style, width
517
return(self.__attribute.GetDefaultDraw())
520
def PaintDrawing(self, dc, lrzelem, drawkey):
538
521
# paint lorze drawing elements
540
if self.__showpenstyle== True:
542
pen= wx.Pen(lrzelem.GetColour(), lrzelem.GetPenSize()* self.__userscale* self.__pensizefactor, self.__penstyldict[lrzelem.GetPenStyle()[0]])
544
if lrzelem.GetPenStyle()[0]== wx.USER_DASH:
522
drawing= self.__drawings[drawkey]
524
if self.__showlinestyle== True:
526
pen= wx.Pen(self.__attribute.GetWxColor(lrzelem.GetColor()), self.__attribute.GetWxWidth(lrzelem.GetWidth())* self.__userscale* self.__linewidthfactor, self.__penstyldict[self.__attribute.GetWxStyle(lrzelem.GetStyle())[0]])
528
if self.__attribute.GetWxStyle(lrzelem.GetStyle())[0]== 'wx.USER_DASH':
546
pen.SetDashes(lrzelem.GetPenStyle()[1])
530
pen.SetDashes(self.__attribute.GetWxStyle(lrzelem.GetStyle())[1])
551
535
# don't show penstyles
552
dc.SetPen(wx.Pen(lrzelem.GetColour(), lrzelem.GetPenSize()* self.__userscale* self.__pensizefactor, wx.SOLID))
536
dc.SetPen(wx.Pen(self.__attribute.GetWxColor(lrzelem.GetColor()), self.__attribute.GetWxWidth(lrzelem.GetWidth())* self.__userscale* self.__linewidthfactor, wx.SOLID))
554
538
if lrzelem.GetId()[0]== 'L':
665
651
return(self.__sel.GetElements())
654
def AddColorEntry(self, name, value, label):
655
# add new colour in attributes, name= text, value= html color, label= text, string for lorzelog
656
self.__attribute.AddColorEntry(name, value, label)
659
def AddLayerEntry(self, name, label):
660
# add new layer in attributes, name= text, label= text, string for lorzelog
661
self.__attribute.AddLayerEntry(name, label)
664
def AddStyleEntry(self, name, value, label):
665
# add new layer in attributes, name= text, value= tupel ('wx.SOLID', []), label= text, string for lorzelog
666
self.__attribute.AddStyleEntry(name, value, label)
669
def AddWidthEntry(self, name, value, label):
670
# add new layer in attributes, name= text, value= float, label= text, string for lorzelog
671
self.__attribute.AddWidthEntry(name, value, label)
674
def GetColorEntry(self, name):
675
# return colour values from colour dictionairy, value, label
676
return(self.__attribute.GetColorEntry(name))
679
def GetLayerEntry(self, name):
680
# return layer values from layer dictionairy, label
681
return(self.__attribute.GetLayerEntry(name))
684
def GetStyleEntry(self, name):
685
# return style values from style dictionairy, value, label
686
return(self.__attribute.GetStyleEntry(name))
689
def GetWidthEntry(self, name):
690
# return width values from width dictionairy, value, label
691
return(self.__attribute.GetWidthEntry(name))
694
def GetAllAttrNames(self):
695
# return all attribute names, colors, layers, styles, widths
696
return(self.__attribute.GetAllAttrNames())
699
def AddLogEntry(self, logtext):
700
self.__log.AddEntry(logtext)
704
return(self.__log.GetLog())
668
707
class TestFrame(wx.Frame):
669
708
# object for testing
670
709
def __init__(self):
677
716
self.__statusinfo= ''
678
717
self.RefreshStatus()
680
self.__drawing= LorzeDrawing(('#GHIJKL', 'testlayer', ('wx.SOLID', []), 1))
681
addlist= [('L', (wx.BLACK, 'test', ('wx.SOLID', []), 1, (0, 0, 10, 10))), ('L', (wx.RED, 'test', ('wx.DOT', []), 1, (0, 0, -10, 10))), ('L', (wx.BLUE, 'test', ('wx.LONG_DASH', []), 1, (0, 0, -10, -10))), ('L', (wx.GREEN, 'test', ('wx.SHORT_DASH', []), 1,
682
(0, 0, 10, -10))), ('L', (wx.CYAN, 'test', ('wx.DOT_DASH', []), 1, (-15, 0, 15, 0))), ('L', (wx.LIGHT_GREY, 'test', ('wx.USER_DASH', [1, 2, 4, 2]) , 1, (0, -15, 0, 15)))]
684
self.__drawing.Add(addlist)
686
719
self.__gdi= GraphicPanel(self, self.__options)
687
self.__gdi.AddDrawing(self.__drawing, 'test')
688
self.__gdi.AddDrawing(self.__drawing, 'test2')
689
self.__gdi.SetActiveDraw('test')
690
print(u'Drawings: test, test2, active drawing= test')
691
a= self.__gdi.GetDrawings()
692
for drawkey, drawing in a.items():
721
print('AddDrawing: test2, test / SetDefAttributes: error, error, error, error / SetDefDrawing: error')
722
self.__gdi.AddDrawing(LorzeDrawing(self.__gdi), 'test2')
723
self.__gdi.AddDrawing(LorzeDrawing(self.__gdi), 'test')
724
self.__gdi.SetDefAttributes('error', 'error', 'error', 'error')
725
self.__gdi.SetDefDrawing('error')
726
print('GetDefAttributes', self.__gdi.GetDefAttributes())
727
print('GetDefDrawing', self.__gdi.GetDefDrawing())
729
for drawkey, drawing in self.__gdi.GetDrawings().items():
693
730
print(drawkey, drawing)
694
print('GetActive', self.__gdi.GetActiveDraw())
732
print('Drawing test2 removed')
695
733
self.__gdi.RemoveDrawing('test2')
696
print(u'Drawing test2 removed, drawings now:')
697
a= self.__gdi.GetDrawings()
698
for drawkey, drawing in a.items():
734
for drawkey, drawing in self.__gdi.GetDrawings().items():
699
735
print(drawkey, drawing)
737
color= [('Red', '255, 0, 0', 'base color'), ('Blue', '0, 0, 255', 'base color'), ('Green', '0, 128, 0', 'base color'), ('Yellow', '255, 255, 0', 'base color'), ('Gray', '128, 128, 128', 'base color'), ('White', '0, 0, 0', 'base color')]
738
layer= [('Layer 1', 'default'), ('Layer 2', 'default'), ('Layer 3', 'default'), ('Layer 4', 'default'), ('Layer 5', 'default'), ('Layer 6', 'default')]
739
style= [('Solid', 'SOLID', 'standard'), ('Dot', 'DOT', 'standard'), ('Long dash', 'LONG_DASH', 'standard'), ('Short dash', 'SHORT_DASH', 'standard'), ('Dot dash', 'DOT_DASH', 'standard'), ('Axis 13mm', '4, 2, 1, 2, 4', 'standard')]
740
width= [('0.13mm', '0.13', 'Rotring'), ('0.18mm', '0.18', 'Rotring'), ('0.25mm', '0.25', 'Rotring'), ('0.35mm', '0.35', 'Rotring'), ('0.50mm', '0.50', 'Rotring'), ('0.70mm', '0.70', 'Rotring')]
742
self.__gdi.AddColorEntry(i[0], i[1], i[2])
744
self.__gdi.AddLayerEntry(i[0], i[1])
746
self.__gdi.AddStyleEntry(i[0], i[1], i[2])
748
self.__gdi.AddWidthEntry(i[0], i[1], i[2])
749
print(self.__gdi.GetAllAttrNames())
752
print('GetColorEntry Blue', self.__gdi.GetColorEntry('Blue'))
753
print('GetLayerEntry Layer 3', self.__gdi.GetLayerEntry('Layer 3'))
754
print('GetStyleEntry Long dash', self.__gdi.GetStyleEntry('Long dash'))
755
print('GetWidthEntry 0.50mm', self.__gdi.GetWidthEntry('0.50mm'))
758
line1= ('L', ('Red', 'Layer 1', 'Solid', '0.13 mm', (0, 0, 10, 10)))
759
line2= ('L', ('Blue', 'Layer 2', 'Dot', '0.18 mm', (0, 0, -10, 10)))
760
line3= ('L', ('Green', 'Layer 3', 'Long dash', '0.25 mm', (0, 0, -10, -10)))
761
line4= ('L', ('Yellow', 'Layer 4', 'Short dash', '0.35 mm', (0, 0, 10, -10)))
762
line5= ('L', ('Gray', 'Layer 5', 'Dot dash', '0.50 mm', (-15, 0, 15, 0)))
763
line6= ('L', ('White', 'Layer 6', 'Axis 13mm', '0.70 mm', (0, -15, 0, 15)))
766
log= self.__gdi.GetLog()
770
draw= self.__gdi.GetDefDrawing()
771
self.__gdi.GetDrawings()[draw].Add([line1, line2, line3, line4, line5, line6])
701
773
self.__vbox= wx.BoxSizer(wx.VERTICAL)
702
774
self.__vbox.Add(self.__gdi, 1, wx.EXPAND)
703
775
self.SetSizer(self.__vbox)