~lorzeteam/lorze/trunk

« back to all changes in this revision

Viewing changes to Scripts/lrzgdipnl.py

  • Committer: Andreas Ulrich
  • Date: 2012-10-20 15:43:56 UTC
  • Revision ID: ulrich3110@gmail.com-20121020154356-8szy0rhp8128owyo
LORZE erasandcad 0.2 alpha 2012/10/20
attributes, attribute dialogue, protocoll

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
# You should have received a copy of the GNU General Public License along with this program.  If not, see <http://www.gnu.org/licenses/>.
13
13
 
14
14
import wx
15
 
from lrzoptions import LorzeOptions
16
 
from lrzdrawing import LorzeDrawing
17
15
from lrzsmartcurs import SmartCursor
18
16
from lrzselect import LorzeSelection
19
17
from lrzgeohelp import LorzeGeoHelp
 
18
from lrzdrawing import LorzeDrawing
 
19
from lrzlog import LorzeLog
 
20
from lrzvalchck import LorzeValueCheck
 
21
from lrzattribute import LorzeAttribute
20
22
 
21
23
 
22
24
class GraphicPanel(wx.Panel):
41
43
        # wx.Pen styles: dictionairy to index
42
44
        self.__penstyldict= {'wx.SOLID':wx.SOLID, 'wx.DOT':wx.DOT, 'wx.LONG_DASH':wx.LONG_DASH, 'wx.SHORT_DASH':wx.SHORT_DASH, 'wx.DOT_DASH':wx.DOT_DASH, 'wx.USER_DASH':wx.USER_DASH}
43
45
 
44
 
        # dictionairy with LorzeDrawing() & active drawing
 
46
        # dictionairy with LorzeDrawing()
45
47
        self.__drawings= {}
46
 
        self.__activedraw= ''
47
48
 
48
49
        # panel clicked, x & y
49
50
        self.__xclick, self.__yclick= 0, 0
57
58
        # x & y position scrollbar
58
59
        self.__scrollposx, self.__scrollposy= 0, 0
59
60
 
60
 
        # factor for pensize
61
 
        self.__pensizefactor= 1
 
61
        # factor for line width
 
62
        self.__linewidthfactor= 1
62
63
 
63
64
        # drawing x & y centre, pixel on the panel
64
65
        self.__drawcentx, self.__drawcenty= 0, 0
65
66
 
66
 
        # pixels per millimeter, attribute & method
67
 
        self.__ppmm= 0
 
67
        # pixels per millimeter, get self.__ppmm
68
68
        self.GetPpmm()
69
69
 
70
70
        # scale factor for drawing
73
73
        # border graphic panel
74
74
        border= self.__bordersdict[self.__options.GetGDIBorder()]
75
75
 
76
 
        # scrollable range & size scrollbar slider
77
 
        self.__sbrange= self.__options.GetSbRange()
78
 
        self.__sbsize= self.__options.GetSbSize()
79
 
 
80
 
        # enlarge & reduce factor mouse wheel
81
 
        self.__wheelenlarge= self.__options.GetWheelEnlarge()
82
 
        self.__wheelreduce= self.__options.GetWheelReduce()
83
 
 
84
76
        # smart cursor object, pixel size smart cursor & smart cursor flag
85
77
        self.__smartcurs= SmartCursor()
86
 
        self.__sensitive= self.__options.GetSensitive()
87
78
        self.__smartflag= False
88
79
 
89
 
        # maximum scale factor penstyles
90
 
        self.__maxpenstylescale= self.__options.GetMaxPenStyleScale()
91
 
 
92
 
        # maximum userscale
93
 
        self.__maxuserscale= self.__options.GetMaxUserScale()
94
 
 
95
80
        # flag
96
 
        self.__showpenstyle= True
97
 
 
98
 
        # number of dezimal places
99
 
        self.__dps= self.__options.GetDezPlcs()
 
81
        self.__showlinestyle= True
100
82
 
101
83
        # mouse x- and y- coordinates in user units
102
84
        self.__mousex, self.__mousey= 0.0, 0.0
112
94
        # selection object
113
95
        self.__sel= LorzeSelection(self)
114
96
 
115
 
        # smart cursor paint mark size in pixel
116
 
        self.__size= self.__options.GetSmartCursSize()
117
 
 
118
 
        # smart cursor paint mark pen size in pixel
119
 
        self.__pensize= self.__options.GetSmartCursPenSize()
120
 
 
121
 
        # smart cursor paint colour point mark
122
 
        self.__colpoint= self.__options.GetSmartCursColPoint()
123
 
 
124
 
        # smart cursor paint colour segment mark
125
 
        self.__colsegm= self.__options.GetSmartCursColSegm()
126
 
 
127
 
        # smart cursor paint colour marked element
128
 
        self.__colelem= self.__options.GetSmartCursColElem()
129
 
 
130
 
        # smart cursor paint mark pen size factor marked element
131
 
        self.__markpensize= self.__options.GetSmartCursMarkPenSize()
132
 
 
133
 
        # selection colour
134
 
        self.__selcol= self.__options.GetSelCol()
135
 
 
136
97
        # geometrie helper object
137
98
        self.__geohelp= LorzeGeoHelp()
138
99
 
 
100
        # log object
 
101
        self.__log= LorzeLog(self)
 
102
 
 
103
        # LorzeValueCheck
 
104
        self.__valchck= LorzeValueCheck()
 
105
 
 
106
        # LorzeAttribute
 
107
        self.__attribute= LorzeAttribute(self, self.__options)
 
108
 
139
109
        # bindings
140
110
        self.Bind(wx.EVT_MOTION, self.OnMouseMove)
141
111
        self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
149
119
        self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
150
120
 
151
121
        # scrollbars
152
 
        self.SetScrollbar(wx.VERTICAL, 0, self.__sbsize, self.__sbrange)
153
 
        self.SetScrollbar(wx.HORIZONTAL, 0, self.__sbsize, self.__sbrange)
 
122
        self.SetScrollbar(wx.VERTICAL, 0, self.__options.GetSbSize(), self.__options.GetSbRange())
 
123
        self.SetScrollbar(wx.HORIZONTAL, 0, self.__options.GetSbSize(), self.__options.GetSbRange())
154
124
 
155
125
 
156
126
    def OnLeftDown(self, event):
199
169
                        self.__sel.ElemSelRect(self.__prevx1, self.__prevy1, self.__prevx2, self.__prevy2)
200
170
                    self.SetAction('elementsel')
201
171
 
202
 
                if self.__action== 'pointsel':
 
172
                elif self.__action== 'pointsel':
203
173
                    pass
204
174
                    # select points and set action pointsel again
205
175
                    # self.__sel.PointSelRect(x1, y1, x2, y2)
206
176
                    # self.SetAction('pointsel')
207
177
 
208
 
                if self.__action== 'line':
209
 
                    # add line, default attributes
210
 
                    colour, layer, penstyle, pensize= self.__drawings[self.__activedraw].GetDefAttr()
211
 
 
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)
214
181
 
215
182
                    # Add with addlist: [('typ', attributes), ..]
216
 
                    self.__drawings[self.__activedraw].Add([('L', (colour, layer, penstyle, pensize, coords))])
 
183
 
 
184
                    self.__drawings[self.__attribute.GetDefaultDraw()].Add([('L', (self.__attribute.GetDefaultColor(), self.__attribute.GetDefaultLayer(), self.__attribute.GetDefaultStyle(), self.__attribute.GetDefaultWidth(), coords))])
217
185
 
218
186
                    self.SetAction('line')
219
187
                self.Refresh()
238
206
        # mouse wheel
239
207
        wheel= event.GetWheelRotation()
240
208
        if wheel > 0:
241
 
            self.__userscale*= self.__wheelenlarge
242
 
            if self.__userscale> self.__maxuserscale:
243
 
                self.__userscale= self.__maxuserscale
 
209
            self.__userscale*= self.__options.GetWheelEnlarge()
 
210
            if self.__userscale> self.__options.GetMaxUserScale():
 
211
                self.__userscale= self.__options.GetMaxUserScale()
244
212
        else:
245
 
            self.__userscale*= self.__wheelreduce
 
213
            self.__userscale*= self.__options.GetWheelReduce()
246
214
        self.Refresh()
247
215
 
248
216
 
268
236
            dc.SetAxisOrientation(True, True)
269
237
 
270
238
            # half size of the smart cursor in pixel
271
 
            s= self.__sensitive/ 2
 
239
            s= self.__options.GetSensitive()/ 2
272
240
 
273
241
            # x1, y1, x2, y2 smart cursor coordinates in user units
274
 
            scrx= round(dc.DeviceToLogicalX(xpanel- s)/ self.__userscale, self.__dps)
275
 
            scry= round(dc.DeviceToLogicalY(ypanel+ s)/ self.__userscale, self.__dps)
276
 
            scx2= round(dc.DeviceToLogicalX(xpanel+ s)/ self.__userscale, self.__dps)
277
 
            scy2= round(dc.DeviceToLogicalY(ypanel- s)/ self.__userscale, self.__dps)
 
242
            scrx= round(dc.DeviceToLogicalX(xpanel- s)/ self.__userscale, self.__options.GetDezPlcs())
 
243
            scry= round(dc.DeviceToLogicalY(ypanel+ s)/ self.__userscale, self.__options.GetDezPlcs())
 
244
            scx2= round(dc.DeviceToLogicalX(xpanel+ s)/ self.__userscale, self.__options.GetDezPlcs())
 
245
            scy2= round(dc.DeviceToLogicalY(ypanel- s)/ self.__userscale, self.__options.GetDezPlcs())
278
246
            scrw= scx2- scrx
279
247
            scrh= scy2- scry
280
248
 
290
258
                paintflag= True
291
259
            else:
292
260
                # position from mouse
293
 
                self.__mousex= round(dc.DeviceToLogicalX(xpanel)/ self.__userscale, self.__dps)
294
 
                self.__mousey= round(dc.DeviceToLogicalY(ypanel)/ self.__userscale, self.__dps)
 
261
                self.__mousex= round(dc.DeviceToLogicalX(xpanel)/ self.__userscale, self.__options.GetDezPlcs())
 
262
                self.__mousey= round(dc.DeviceToLogicalY(ypanel)/ self.__userscale, self.__options.GetDezPlcs())
295
263
                if self.__smartflag== True:
296
264
                    # set smartflag False: Not Refresh Panel when not found
297
265
                    self.__smartflag= None
333
301
        scW, scH= self.__parent.GetGdiSize()
334
302
 
335
303
        # screen rect x1, x2, y1, y2
336
 
        scrx= round(dc.DeviceToLogicalX(0)/ self.__userscale, self.__dps)
337
 
        scry= round(dc.DeviceToLogicalY(scH)/ self.__userscale, self.__dps)
338
 
        scx2= round(dc.DeviceToLogicalX(scW)/ self.__userscale, self.__dps)
339
 
        scy2= round(dc.DeviceToLogicalY(0)/ self.__userscale, self.__dps)
 
304
        scrx= round(dc.DeviceToLogicalX(0)/ self.__userscale, self.__options.GetDezPlcs())
 
305
        scry= round(dc.DeviceToLogicalY(scH)/ self.__userscale, self.__options.GetDezPlcs())
 
306
        scx2= round(dc.DeviceToLogicalX(scW)/ self.__userscale, self.__options.GetDezPlcs())
 
307
        scy2= round(dc.DeviceToLogicalY(0)/ self.__userscale, self.__options.GetDezPlcs())
340
308
        scrw= scx2- scrx
341
309
        scrh= scy2- scry
342
310
 
343
311
        # check userscale for penstyles (problems with paint)
344
 
        if self.__userscale> self.__maxpenstylescale:
 
312
        if self.__userscale> self.__options.GetMaxPenStyleScale():
345
313
            # ignore penstyles, all paint in wx.SOLID
346
 
            self.__showpenstyle= False
 
314
            self.__showlinestyle= False
347
315
 
348
316
        else:
349
317
            # show penstyles
350
 
            self.__showpenstyle= True
 
318
            self.__showlinestyle= True
351
319
 
352
320
        # amounts for x & y points
353
321
        xpoints= set()
355
323
 
356
324
        for drawkey, drawing in self.__drawings.items():
357
325
            # each LorzeDrawing, get drawing elements
358
 
            elementsdict= drawing.GetElements()
359
326
 
360
 
            for lrzid, lrzelem in elementsdict.items():
 
327
            for lrzid, lrzelem in drawing.GetElements().items():
361
328
                # get rec coordinates and add to points
362
329
                ex, ey, ew, eh= lrzelem.GetRec()
363
330
                xpoints.add(ex)
370
337
                    self.__smartcurs.AddElement(lrzelem, drawkey)
371
338
 
372
339
                    # paint element
373
 
                    self.PaintDrawing(dc, lrzelem)
 
340
                    self.PaintDrawing(dc, lrzelem, drawkey)
374
341
 
375
342
        # center of the drawing elements
376
343
        if len(xpoints)> 0:
395
362
        if self.__smartcurs.GetType()!= '':
396
363
            # smart cursor found, paint in SmartCursor()
397
364
            self.PaintSmartCursor(dc)
 
365
            pass
398
366
 
399
367
        # preview
400
368
        self.PaintPreview(dc)
436
404
        hdev= float(hdev)
437
405
 
438
406
        # set scrollpos to drawing centre
439
 
        self.__scrollposx= self.__drawcentx* (self.__sbrange/ wdev)
440
 
        self.__scrollposy= self.__drawcenty* (self.__sbrange/ hdev)
 
407
        self.__scrollposx= self.__drawcentx* (self.__options.GetSbRange()/ wdev)
 
408
        self.__scrollposy= self.__drawcenty* (self.__options.GetSbRange()/ hdev)
441
409
 
442
410
        # check under- and overflow
443
411
        if self.__scrollposx< 0:
444
412
            self.__scrollposx= 0
445
 
        elif self.__scrollposx> self.__sbrange:
446
 
            self.__scrollposx= self.__sbrange
 
413
        elif self.__scrollposx> self.__options.GetSbRange():
 
414
            self.__scrollposx= self.__options.GetSbRange()
447
415
        if self.__scrollposy< 0:
448
416
            self.__scrollposy= 0
449
 
        elif self.__scrollposy> self.__sbrange:
450
 
            self.__scrollposy= self.__sbrange
 
417
        elif self.__scrollposy> self.__options.GetSbRange():
 
418
            self.__scrollposy= self.__options.GetSbRange()
451
419
 
452
420
        # set scrollbars
453
421
        self.SetScrollPos(wx.HORIZONTAL, self.__scrollposx, True)
468
436
 
469
437
        if orientation== wx.HORIZONTAL:
470
438
            # horizontal scrollbar
471
 
            self.__originx+= (value- self.__scrollposx)* (self.__sbrange/ wdev)
 
439
            self.__originx+= (value- self.__scrollposx)* (self.__options.GetSbRange()/ wdev)
472
440
 
473
441
        else:
474
442
            # vertical scrollbar
475
 
            self.__originy+= (value- self.__scrollposy)* (self.__sbrange/ hdev)
 
443
            self.__originy+= (value- self.__scrollposy)* (self.__options.GetSbRange()/ hdev)
476
444
 
477
445
        # actualize graphic panel
478
446
        self.Refresh()
526
494
        return (self.__action)
527
495
 
528
496
 
529
 
    def SetActiveDraw(self, activedraw):
530
 
        self.__activedraw= activedraw
531
 
 
532
 
 
533
 
    def GetActiveDraw(self):
534
 
        return(self.__activedraw)
535
 
 
536
 
 
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)
 
503
 
 
504
 
 
505
    def SetDefDrawing(self, defdraw):
 
506
        # set defaults for drawing in LorzeAttribute
 
507
        self.__attribute.SetDefaultDraw(defdraw)
 
508
 
 
509
 
 
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())
 
513
 
 
514
 
 
515
    def GetDefDrawing(self):
 
516
        # get defaults for drawing from LorzeAttribute, return drawing, colour, layer, style, width
 
517
        return(self.__attribute.GetDefaultDraw())
 
518
 
 
519
 
 
520
    def PaintDrawing(self, dc, lrzelem, drawkey):
538
521
        # paint lorze drawing elements
539
 
 
540
 
        if self.__showpenstyle== True:
541
 
            # show penstyles
542
 
            pen= wx.Pen(lrzelem.GetColour(), lrzelem.GetPenSize()* self.__userscale* self.__pensizefactor, self.__penstyldict[lrzelem.GetPenStyle()[0]])
543
 
 
544
 
            if lrzelem.GetPenStyle()[0]== wx.USER_DASH:
 
522
        drawing= self.__drawings[drawkey]
 
523
 
 
524
        if self.__showlinestyle== True:
 
525
            # show line styles
 
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]])
 
527
 
 
528
            if self.__attribute.GetWxStyle(lrzelem.GetStyle())[0]== 'wx.USER_DASH':
545
529
                # user penstyle
546
 
                pen.SetDashes(lrzelem.GetPenStyle()[1])
 
530
                pen.SetDashes(self.__attribute.GetWxStyle(lrzelem.GetStyle())[1])
547
531
 
548
532
            dc.SetPen(pen)
549
533
 
550
534
        else:
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))
553
537
 
554
538
        if lrzelem.GetId()[0]== 'L':
555
539
            # line
559
543
 
560
544
    def PaintSmartCursor(self, dc):
561
545
        # paint point marker, set half mark size in mm
562
 
        sh= self.__size/ 2/ self.__userscale
 
546
        sh= self.__options.GetSmartCursSize()/ 2/ self.__userscale
563
547
 
564
548
        # x1, x2, y1, y2 of the mark in mm
565
549
        x1= (self.__smartcurs.GetX()- sh)* self.__userscale
568
552
        y2= (self.__smartcurs.GetY()+ sh)* self.__userscale
569
553
 
570
554
        # get element with the smart cursor
571
 
        elementsdict= self.__drawings[self.__smartcurs.GetKey()].GetElements()
 
555
        drawing= self.__drawings[self.__smartcurs.GetKey()]
 
556
        elementsdict= drawing.GetElements()
572
557
        element= elementsdict[self.__smartcurs.GetLrzId()]
573
558
 
574
559
        # pen marked element
575
 
        dc.SetPen(wx.Pen(self.__colelem, element.GetPenSize()* self.__userscale* self.__pensizefactor* self.__markpensize,  wx.SOLID))
 
560
        dc.SetPen(wx.Pen(self.__options.GetSmartCursColElem(), self.__attribute.GetWxWidth(element.GetWidth())* self.__userscale* self.__linewidthfactor* self.__options.GetSmartCursMarkPenSize(),  wx.SOLID))
576
561
 
577
562
        # paint marked element
578
563
        if element.GetId()[0]== 'L':
581
566
 
582
567
        if self.__smartcurs.GetType()== 'P':
583
568
            # pen point mark
584
 
            dc.SetPen(wx.Pen(self.__colpoint, self.__pensize, wx.SOLID))
 
569
            dc.SetPen(wx.Pen(self.__options.GetSmartCursColPoint(), self.__options.GetSmartCursPenSize(), wx.SOLID))
585
570
        elif self.__smartcurs.GetType()== 'S':
586
571
            # pen segment mark
587
 
            dc.SetPen(wx.Pen(self.__colsegm, self.__pensize, wx.SOLID))
 
572
            dc.SetPen(wx.Pen(self.__options.GetSmartCursColSegm(), self.__options.GetSmartCursPenSize(), wx.SOLID))
588
573
 
589
574
        # point mark
590
575
        dc.DrawLine(x1, y1, x2, y2)
628
613
        for i in self.__sel.GetElements():
629
614
            # paint all elements
630
615
            lrzid, drawkey= i
631
 
            elementsdict= self.__drawings[drawkey].GetElements()
 
616
            drawing= self.__drawings[drawkey]
 
617
            elementsdict= drawing.GetElements()
632
618
            element= elementsdict[lrzid]
633
619
 
634
 
            if self.__showpenstyle== True:
 
620
            if self.__showlinestyle== True:
635
621
                # show penstyles
636
 
                pen= wx.Pen(self.__selcol, element.GetPenSize()* self.__userscale* self.__pensizefactor, self.__penstyldict[element.GetPenStyle()[0]])
 
622
                pen= wx.Pen(self.__options.GetSelCol(), self.__attribute.GetWxWidth(element.GetWidth())* self.__userscale* self.__linewidthfactor, self.__penstyldict[self.__attribute.GetWxStyle(element.GetStyle())[0]])
637
623
 
638
 
                if element.GetPenStyle()[0]== wx.USER_DASH:
 
624
                if self.__attribute.GetWxStyle(element.GetStyle())[0]== 'wx.USER_DASH':
639
625
                    # user penstyle
640
 
                    pen.SetDashes(element.GetPenStyle()[1])
 
626
                    pen.SetDashes(self.__attribute.GetWxStyle(element.GetStyle())[1])
641
627
 
642
628
                dc.SetPen(pen)
643
629
            else:
644
630
                # don't show penstyles
645
 
                dc.SetPen(wx.Pen(self.__selcol, element.GetPenSize()* self.__userscale* self.__pensizefactor, wx.SOLID))
 
631
                dc.SetPen(wx.Pen(self.__options.GetSelCol(), self.__attribute.GetWxWidth(element.GetWidth())* self.__userscale* self.__linewidthfactor, wx.SOLID))
646
632
 
647
633
            if element.GetId()[0]== 'L':
648
634
                # line
665
651
        return(self.__sel.GetElements())
666
652
 
667
653
 
 
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)
 
657
 
 
658
 
 
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)
 
662
 
 
663
 
 
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)
 
667
 
 
668
 
 
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)
 
672
 
 
673
 
 
674
    def GetColorEntry(self, name):
 
675
        # return colour values from colour dictionairy, value, label
 
676
        return(self.__attribute.GetColorEntry(name))
 
677
 
 
678
 
 
679
    def GetLayerEntry(self, name):
 
680
        # return layer values from layer dictionairy, label
 
681
        return(self.__attribute.GetLayerEntry(name))
 
682
 
 
683
 
 
684
    def GetStyleEntry(self, name):
 
685
        # return style values from style dictionairy, value, label
 
686
        return(self.__attribute.GetStyleEntry(name))
 
687
 
 
688
 
 
689
    def GetWidthEntry(self, name):
 
690
        # return width values from width dictionairy, value, label
 
691
        return(self.__attribute.GetWidthEntry(name))
 
692
 
 
693
 
 
694
    def GetAllAttrNames(self):
 
695
        # return all attribute names, colors, layers, styles, widths
 
696
        return(self.__attribute.GetAllAttrNames())
 
697
 
 
698
 
 
699
    def AddLogEntry(self, logtext):
 
700
        self.__log.AddEntry(logtext)
 
701
 
 
702
 
 
703
    def GetLog(self):
 
704
        return(self.__log.GetLog())
 
705
 
 
706
 
668
707
class TestFrame(wx.Frame):
669
708
    # object for testing
670
709
    def __init__(self):
677
716
        self.__statusinfo= ''
678
717
        self.RefreshStatus()
679
718
 
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)))]
683
 
 
684
 
        self.__drawing.Add(addlist)
685
 
 
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():
 
720
 
 
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())
 
728
 
 
729
        for drawkey, drawing in self.__gdi.GetDrawings().items():
693
730
            print(drawkey, drawing)
694
 
        print('GetActive', self.__gdi.GetActiveDraw())
 
731
 
 
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)
700
736
 
 
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')]
 
741
        for i in color:
 
742
            self.__gdi.AddColorEntry(i[0], i[1], i[2])
 
743
        for i in layer:
 
744
            self.__gdi.AddLayerEntry(i[0], i[1])
 
745
        for i in style:
 
746
            self.__gdi.AddStyleEntry(i[0], i[1], i[2])
 
747
        for i in width:
 
748
            self.__gdi.AddWidthEntry(i[0], i[1], i[2])
 
749
        print(self.__gdi.GetAllAttrNames())
 
750
 
 
751
        print('')
 
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'))
 
756
        print('')
 
757
 
 
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)))
 
764
 
 
765
        print('LorzeLog')
 
766
        log= self.__gdi.GetLog()
 
767
        for i in log:
 
768
            print(i)
 
769
 
 
770
        draw= self.__gdi.GetDefDrawing()
 
771
        self.__gdi.GetDrawings()[draw].Add([line1, line2, line3, line4, line5,  line6])
 
772
 
701
773
        self.__vbox= wx.BoxSizer(wx.VERTICAL)
702
774
        self.__vbox.Add(self.__gdi, 1, wx.EXPAND)
703
775
        self.SetSizer(self.__vbox)
733
805
 
734
806
 
735
807
if __name__== '__main__':
 
808
    from lrzoptions import LorzeOptions
 
809
 
736
810
    app= wx.App()
737
811
    frame= TestFrame()
738
812
    app.MainLoop()