Пример #1
0
    def InputExtrusionHeight(self, value, extrude_makes_a_solid, taper_angle):
        dlg = HDialog('Make Extrusion')
        sizerMain = wx.BoxSizer(wx.VERTICAL)

        value_control = LengthCtrl(dlg)
        value_control.SetValue(value)
        dlg.AddLabelAndControl(sizerMain, 'Height', value_control)

        solid_check_box = None
        if extrude_makes_a_solid != None:
            solid_check_box = wx.CheckBox(dlg, label='Extrude makes a solid')
            solid_check_box.SetValue(extrude_makes_a_solid)
            sizerMain.Add(solid_check_box, 0, wx.ALL | wx.ALIGN_LEFT,
                          control_border)

        taper_angle_control = None
        if taper_angle != None:
            taper_angle_control = DoubleCtrl(dlg)
            taper_angle_control.SetValue(taper_angle)
            dlg.AddLabelAndControl(sizerMain, 'Taper Outward Angle',
                                   taper_angle_control)

        dlg.MakeOkAndCancel(wx.HORIZONTAL).AddToSizer(sizerMain)
        dlg.SetSizer(sizerMain)
        sizerMain.Fit(dlg)
        value_control.SetFocus()
        if dlg.ShowModal() == wx.ID_OK:
            value = value_control.GetValue()
            if extrude_makes_a_solid != None:
                extrude_makes_a_solid = solid_check_box.GetValue()
            if taper_angle != None:
                taper_angle = taper_angle_control.GetValue()
            return True, value, extrude_makes_a_solid, taper_angle
        return False, value, extrude_makes_a_solid, taper_angle
Пример #2
0
 def __init__(self, dlg, label, xstr, ystr, zstr):
     self.lgthX = LengthCtrl(dlg)
     self.sttcX = dlg.AddLabelAndControl(self, xstr, self.lgthX)
     self.lgthY = LengthCtrl(dlg)
     self.sttcY = dlg.AddLabelAndControl(self, ystr, self.lgthY)
     self.lgthZ = LengthCtrl(dlg)
     self.sttcZ = dlg.AddLabelAndControl(self, zstr, self.lgthZ)
Пример #3
0
 def AddControls(self, sizer):
     self.lgthHFeed = LengthCtrl(self)
     self.MakeLabelAndControl('Horizontal Feedrate',
                              self.lgthHFeed).AddToSizer(sizer)
     self.lgthVFeed = LengthCtrl(self)
     self.MakeLabelAndControl('Vertical Feedrate',
                              self.lgthVFeed).AddToSizer(sizer)
     self.dblSpindleSpeed = DoubleCtrl(self)
     self.MakeLabelAndControl('Spindle Speed',
                              self.dblSpindleSpeed).AddToSizer(sizer)
Пример #4
0
 def AddLeftControls(self):
     # add the controls in one column
     self.lgthTolerance = LengthCtrl(self)
     self.MakeLabelAndControl("Tolerance",
                              self.lgthTolerance).AddToSizer(self.sizerLeft)
     self.lgthMaterialAllowance = LengthCtrl(self)
     self.MakeLabelAndControl("Material Allowance",
                              self.lgthMaterialAllowance).AddToSizer(
                                  self.sizerLeft)
     self.chkSameForEachPosition = wx.CheckBox(
         self, wx.ID_ANY, 'Same for Each Pattern Position')
     HControl(wx.ALL,
              self.chkSameForEachPosition).AddToSizer(self.sizerLeft)
     SolidsDlg.AddLeftControls(self)
Пример #5
0
 def AddLeftControls(self):
     # add all the controls to the left side
     tool_on_side_choices = ['Left', 'Right', 'On']
     self.cmbToolOnSide = ComboBoxBinded(self, choices = tool_on_side_choices)
     self.MakeLabelAndControl("Tool On Side", self.cmbToolOnSide).AddToSizer(self.sizerLeft)
     
     #self.SetSketchOrderAndCombo(self.sketch)
     
     cut_mode_choices = ["Conventional", "Climb"]
     self.cmbCutMode = ComboBoxBinded(self, choices = cut_mode_choices)
     self.MakeLabelAndControl("Cut Mode", self.cmbCutMode).AddToSizer(self.sizerLeft)
     #self.Bind(wx.EVT_COMBOBOX, self.OnComboOrCheck, self.cmbCutMode)
     self.lgthRollRadius = LengthCtrl(self)
     self.MakeLabelAndControl("Roll Radius", self.lgthRollRadius).AddToSizer(self.sizerLeft)
     self.lgthOffsetExtra = LengthCtrl(self)
     self.MakeLabelAndControl("Offset Extra", self.lgthOffsetExtra).AddToSizer(self.sizerLeft)
     self.chkDoFinishingPass = wx.CheckBox(self, wx.ID_ANY, 'Do Finishing Pass')
     HControl(wx.ALL, self.chkDoFinishingPass).AddToSizer(self.sizerLeft)
     self.chkOnlyFinishingPass = wx.CheckBox(self, wx.ID_ANY, 'Only Finishing Pass')
     HControl(wx.ALL, self.chkOnlyFinishingPass).AddToSizer(self.sizerLeft)
     
     self.lgthFinishingFeedrate = LengthCtrl(self)
     self.staticFinishingFeedrate = wx.StaticText(self, wx.ID_ANY, "Finishing Feed Rate")
     self.MakeControlUsingStaticText(self.staticFinishingFeedrate, self.lgthFinishingFeedrate).AddToSizer(self.sizerLeft)
     self.cmbFinishingCutMode = ComboBoxBinded(self, choices = cut_mode_choices)
     self.staticFinishingCutMode = wx.StaticText(self, wx.ID_ANY, "Finishing Cut Mode")
     self.MakeControlUsingStaticText(self.staticFinishingCutMode, self.cmbFinishingCutMode).AddToSizer(self.sizerLeft)
     self.lgthFinishStepDown = LengthCtrl(self)
     self.staticFinishStepDown = wx.StaticText(self, wx.ID_ANY, "Finish Step Down")
     self.MakeControlUsingStaticText(self.staticFinishStepDown, self.lgthFinishStepDown).AddToSizer(self.sizerLeft)
     
     SketchOpDlg.AddLeftControls(self)
Пример #6
0
 def InputLength(self, prompt, name, value):
     dlg = HDialog('Input')
     sizerMain = wx.BoxSizer(wx.VERTICAL)
     static_label = wx.StaticText(dlg, label = prompt)
     sizerMain.Add( static_label, 0, wx.ALL, wx.ALIGN_LEFT, control_border )
     value_control = LengthCtrl(dlg)
     value_control.SetValue(value)
     dlg.AddLabelAndControl( sizerMain, name, value_control )
     dlg.MakeOkAndCancel( wx.HORIZONTAL ).AddToSizer( sizerMain )
     dlg.SetSizer( sizerMain )
     sizerMain.SetSizeHints(dlg)
     sizerMain.Fit(dlg)
     value_control.SetFocus()
     if dlg.ShowModal() == wx.ID_OK:
         return value_control.GetValue()
     return None
Пример #7
0
    def AddLeftControls(self):
        self.txtToolNumber = wx.TextCtrl(self)
        self.MakeLabelAndControl("Tool Number",
                                 self.txtToolNumber).AddToSizer(self.sizerLeft)

        self.cmbMaterial = wx.ComboBox(self,
                                       choices=["High Speed Steel", "Carbide"])
        self.Bind(wx.EVT_COMBOBOX, self.OnComboMaterial, self.cmbMaterial)
        self.MakeLabelAndControl("Tool Material",
                                 self.cmbMaterial).AddToSizer(self.sizerLeft)

        self.cmbToolType = wx.ComboBox(self, choices=Tool.GetToolTypeNames())
        self.Bind(wx.EVT_COMBOBOX, self.OnComboToolType, self.cmbToolType)
        self.MakeLabelAndControl("Tool Type",
                                 self.cmbToolType).AddToSizer(self.sizerLeft)

        self.lgthDiameter = LengthCtrl(self)
        self.MakeLabelAndControl("Diameter",
                                 self.lgthDiameter).AddToSizer(self.sizerLeft)
        self.Bind(wx.EVT_TEXT, self.OnDiamChange, self.lgthDiameter)

        self.lgthToolLengthOffset = LengthCtrl(self)
        self.MakeLabelAndControl("Tool Length Offset",
                                 self.lgthToolLengthOffset).AddToSizer(
                                     self.sizerLeft)

        self.lgthFlatRadius = LengthCtrl(self)
        self.MakeLabelAndControl(
            "Flat Radius", self.lgthFlatRadius).AddToSizer(self.sizerLeft)

        self.lgthCornerRadius = LengthCtrl(self)
        self.MakeLabelAndControl(
            "Corner Radius", self.lgthCornerRadius).AddToSizer(self.sizerLeft)

        self.lgthCuttingEdgeAngle = DoubleCtrl(self)
        self.MakeLabelAndControl("Cutting Edge Angle",
                                 self.lgthCuttingEdgeAngle).AddToSizer(
                                     self.sizerLeft)

        self.lgthCuttingEdgeHeight = LengthCtrl(self)
        self.MakeLabelAndControl("Cutting Edge Height",
                                 self.lgthCuttingEdgeHeight).AddToSizer(
                                     self.sizerLeft)

        HeeksObjDlg.AddLeftControls(self)
Пример #8
0
class SpeedOpDlg(OpDlg):
    def __init__(self, object, controls_on_left, title):
        self.controls_on_left = controls_on_left
        OpDlg.__init__(self, object, title)

    def AddControls(self, sizer):
        self.lgthHFeed = LengthCtrl(self)
        self.MakeLabelAndControl('Horizontal Feedrate',
                                 self.lgthHFeed).AddToSizer(sizer)
        self.lgthVFeed = LengthCtrl(self)
        self.MakeLabelAndControl('Vertical Feedrate',
                                 self.lgthVFeed).AddToSizer(sizer)
        self.dblSpindleSpeed = DoubleCtrl(self)
        self.MakeLabelAndControl('Spindle Speed',
                                 self.dblSpindleSpeed).AddToSizer(sizer)

    def AddLeftControls(self):
        if self.controls_on_left:
            self.AddControls(self.sizerLeft)
        OpDlg.AddLeftControls(self)

    def AddRightControls(self):
        if not self.controls_on_left:
            self.AddControls(self.sizerRight)
        OpDlg.AddRightControls(self)

    def SetDefaultFocus(self):
        self.cmbTool.SetFocus()

    def GetDataRaw(self):
        self.object.horizontal_feed_rate = self.lgthHFeed.GetValue()
        self.object.vertical_feed_rate = self.lgthVFeed.GetValue()
        self.object.spindle_speed = self.dblSpindleSpeed.GetValue()

        OpDlg.GetDataRaw(self)

    def SetFromDataRaw(self):
        self.lgthHFeed.SetValue(self.object.horizontal_feed_rate)
        self.lgthVFeed.SetValue(self.object.vertical_feed_rate)
        self.dblSpindleSpeed.SetValue(self.object.spindle_speed)

        OpDlg.SetFromDataRaw(self)
Пример #9
0
class SurfaceDlg(SolidsDlg):
    def __init__(self, object, title='Surface'):
        SolidsDlg.__init__(self, object, title)

    def SetPictureByName(self, name):
        self.SetPictureByNameAndFolder(name, 'surface')

    def SetPictureByNameAndFolder(self, name, folder):
        if self.picture:
            self.picture.SetPicture(wx.GetApp().cam_dir + '/bitmaps/' +
                                    folder + '/' + name + '.png')

    def AddLeftControls(self):
        # add the controls in one column
        self.lgthTolerance = LengthCtrl(self)
        self.MakeLabelAndControl("Tolerance",
                                 self.lgthTolerance).AddToSizer(self.sizerLeft)
        self.lgthMaterialAllowance = LengthCtrl(self)
        self.MakeLabelAndControl("Material Allowance",
                                 self.lgthMaterialAllowance).AddToSizer(
                                     self.sizerLeft)
        self.chkSameForEachPosition = wx.CheckBox(
            self, wx.ID_ANY, 'Same for Each Pattern Position')
        HControl(wx.ALL,
                 self.chkSameForEachPosition).AddToSizer(self.sizerLeft)
        SolidsDlg.AddLeftControls(self)

    def GetDataRaw(self):
        self.object.tolerance = self.lgthTolerance.GetValue()
        self.object.material_allowance = self.lgthMaterialAllowance.GetValue()
        self.object.same_for_each_pattern_position = self.chkSameForEachPosition.IsChecked(
        )
        SolidsDlg.GetDataRaw(self)

    def SetFromDataRaw(self):
        self.lgthTolerance.SetValue(self.object.tolerance)
        self.lgthMaterialAllowance.SetValue(self.object.material_allowance)
        self.chkSameForEachPosition.SetValue(
            self.object.same_for_each_pattern_position)
        SolidsDlg.SetFromDataRaw(self)
Пример #10
0
 def AddLeftControls(self):
     # add all the controls to the left side
     self.lgthStepOver = LengthCtrl(self)
     self.MakeLabelAndControl("Step Over", self.lgthStepOver).AddToSizer(self.sizerLeft)
     self.lgthMaterialAllowance = LengthCtrl(self)
     self.MakeLabelAndControl("Material Allowance", self.lgthMaterialAllowance).AddToSizer(self.sizerLeft)
     self.cmbStartingPlace = ComboBoxBinded(self, choices = ["Boundary", "Center"])
     self.MakeLabelAndControl("Starting Place", self.cmbStartingPlace).AddToSizer(self.sizerLeft)
     self.cmbCutMode = ComboBoxBinded(self, choices = ["Conventional", "Climb"])
     self.MakeLabelAndControl("Cut Mode", self.cmbCutMode).AddToSizer(self.sizerLeft)
     self.chkKeepToolDown = wx.CheckBox(self, wx.ID_ANY, 'Keep Tool Down')
     HControl(wx.ALL, self.chkKeepToolDown).AddToSizer(self.sizerLeft)
     self.chkUseZigZag = wx.CheckBox(self, wx.ID_ANY, 'Use Zig Zag')
     self.Bind(wx.EVT_CHECKBOX, self.OnUseZigZagCheck, self.chkUseZigZag)
     HControl(wx.ALL, self.chkUseZigZag).AddToSizer(self.sizerLeft)
     self.dblZigAngle = DoubleCtrl(self)
     self.MakeLabelAndControl("Zig Zag Angle", self.dblZigAngle).AddToSizer(self.sizerLeft)
     self.chkZigUnidirectional = wx.CheckBox(self, wx.ID_ANY, 'Zig Unidirectional')
     self.Bind(wx.EVT_CHECKBOX, self.OnZigUnidirectionalCheck, self.chkZigUnidirectional)
     HControl(wx.ALL, self.chkZigUnidirectional).AddToSizer(self.sizerLeft)
     
     SketchOpDlg.AddLeftControls(self)        
Пример #11
0
class ScaleDlg(HDialog):
    def __init__(self, fromp, scale_factor, copy, title):
        HDialog.__init__(self, title)
        self.ignore_event_functions = True
        sizerMain = wx.BoxSizer(wx.VERTICAL)

        self.copy = copy
        self.fromp = fromp
        self.scale_factor = scale_factor

        self.chkCopy = wx.CheckBox(self, wx.ID_ANY, 'Keep Original')
        HControl(wx.ALL, self.chkCopy).AddToSizer(sizerMain)
        self.chkCopy.SetValue(copy)

        sizerPos = wx.BoxSizer(wx.VERTICAL)
        sizerMain.Add(sizerPos, 0, wx.EXPAND)
        self.btnFrom = wx.Button(self, label='Select')
        self.AddLabelAndControl(sizerPos, 'Position to scale about',
                                self.btnFrom)
        self.fromx = LengthCtrl(self)
        self.AddLabelAndControl(sizerPos, 'X', self.fromx)
        self.fromy = LengthCtrl(self)
        self.AddLabelAndControl(sizerPos, 'Y', self.fromy)
        self.fromz = LengthCtrl(self)
        self.AddLabelAndControl(sizerPos, 'Z', self.fromz)

        self.fromx.SetValue(fromp.x)
        self.fromy.SetValue(fromp.y)
        self.fromz.SetValue(fromp.z)

        self.txt_scale_factor = wx.TextCtrl(self, wx.ID_ANY,
                                            '%.6f' % scale_factor)
        self.AddLabelAndControl(sizerMain,
                                'Scale Factor ( 1.0 for no change )',
                                self.txt_scale_factor)

        self.MakeOkAndCancel(wx.HORIZONTAL).AddToSizer(sizerMain)

        self.SetSizer(sizerMain)
        sizerMain.SetSizeHints(self)
        sizerMain.Fit(self)

        self.chkCopy.SetFocus()

        self.Bind(wx.EVT_BUTTON, self.OnPickFrom, self.btnFrom)

        self.ignore_event_functions = False

    def OnPickFrom(self, event):
        self.EndModal(self.btnFrom.GetId())

    def GetAllValues(self):
        self.fromp.x = self.fromx.GetValue()
        self.fromp.y = self.fromy.GetValue()
        self.fromp.z = self.fromz.GetValue()
        copy = self.chkCopy.GetValue()
        scale_factor = float(self.txt_scale_factor.GetValue())

        return self.fromp, scale_factor, copy
Пример #12
0
 def AddLeftControls(self):
     # add the controls in one column
     self.txtCopies1 = wx.TextCtrl(self)
     self.MakeLabelAndControl('Number of Copies A',
                              self.txtCopies1).AddToSizer(self.sizerLeft)
     self.lgthXShift1 = LengthCtrl(self)
     self.MakeLabelAndControl("X Shift A",
                              self.lgthXShift1).AddToSizer(self.sizerLeft)
     self.lgthYShift1 = LengthCtrl(self)
     self.MakeLabelAndControl("Y Shift A",
                              self.lgthYShift1).AddToSizer(self.sizerLeft)
     self.txtCopies2 = wx.TextCtrl(self)
     self.MakeLabelAndControl('Number of Copies B',
                              self.txtCopies2).AddToSizer(self.sizerLeft)
     self.lgthXShift2 = LengthCtrl(self)
     self.MakeLabelAndControl("X Shift B",
                              self.lgthXShift2).AddToSizer(self.sizerLeft)
     self.lgthYShift2 = LengthCtrl(self)
     self.MakeLabelAndControl("Y Shift B",
                              self.lgthYShift2).AddToSizer(self.sizerLeft)
Пример #13
0
class PocketDlg(SketchOpDlg):
    def __init__(self, object, title = 'Pocket Operation'):
        SketchOpDlg.__init__(self, object, title)

    def AddLeftControls(self):
        # add all the controls to the left side
        self.lgthStepOver = LengthCtrl(self)
        self.MakeLabelAndControl("Step Over", self.lgthStepOver).AddToSizer(self.sizerLeft)
        self.lgthMaterialAllowance = LengthCtrl(self)
        self.MakeLabelAndControl("Material Allowance", self.lgthMaterialAllowance).AddToSizer(self.sizerLeft)
        self.cmbStartingPlace = ComboBoxBinded(self, choices = ["Boundary", "Center"])
        self.MakeLabelAndControl("Starting Place", self.cmbStartingPlace).AddToSizer(self.sizerLeft)
        self.cmbCutMode = ComboBoxBinded(self, choices = ["Conventional", "Climb"])
        self.MakeLabelAndControl("Cut Mode", self.cmbCutMode).AddToSizer(self.sizerLeft)
        self.chkKeepToolDown = wx.CheckBox(self, wx.ID_ANY, 'Keep Tool Down')
        HControl(wx.ALL, self.chkKeepToolDown).AddToSizer(self.sizerLeft)
        self.chkUseZigZag = wx.CheckBox(self, wx.ID_ANY, 'Use Zig Zag')
        self.Bind(wx.EVT_CHECKBOX, self.OnUseZigZagCheck, self.chkUseZigZag)
        HControl(wx.ALL, self.chkUseZigZag).AddToSizer(self.sizerLeft)
        self.dblZigAngle = DoubleCtrl(self)
        self.MakeLabelAndControl("Zig Zag Angle", self.dblZigAngle).AddToSizer(self.sizerLeft)
        self.chkZigUnidirectional = wx.CheckBox(self, wx.ID_ANY, 'Zig Unidirectional')
        self.Bind(wx.EVT_CHECKBOX, self.OnZigUnidirectionalCheck, self.chkZigUnidirectional)
        HControl(wx.ALL, self.chkZigUnidirectional).AddToSizer(self.sizerLeft)
        
        SketchOpDlg.AddLeftControls(self)        
            
    def OnUseZigZagCheck(self, e):
        self.EnableControls()
        self.OnComboOrCheck(e)
        
    def OnZigUnidirectionalCheck(self, e):
        self.EnableControls()
        self.OnComboOrCheck(e)

    def GetDataRaw(self):
        self.object.step_over = self.lgthStepOver.GetValue()
        self.object.material_allowance = self.lgthMaterialAllowance.GetValue()
        self.object.from_center = self.cmbStartingPlace.GetSelection()
        self.object.cut_mode = self.cmbCutMode.GetSelection()
        self.object.keep_tool_down_if_poss = self.chkKeepToolDown.GetValue()
        self.object.use_zig_zag = self.chkUseZigZag.GetValue()
        self.object.zig_angle = self.dblZigAngle.GetValue()
        self.object.zig_unidirectional = self.chkZigUnidirectional.GetValue()
        #self.object.entry_move = self.lgthFinishStepDown.GetValue()

        SketchOpDlg.GetDataRaw(self)
        
    def SetFromDataRaw(self):
        self.lgthStepOver.SetValue(self.object.step_over)
        self.lgthMaterialAllowance.SetValue(self.object.material_allowance)
        self.cmbStartingPlace.SetSelection(self.object.from_center)
        self.cmbCutMode.SetSelection(self.object.cut_mode)
        self.chkKeepToolDown.SetValue(self.object.keep_tool_down_if_poss)
        self.chkUseZigZag.SetValue(self.object.use_zig_zag)
        self.dblZigAngle.SetValue(self.object.zig_angle)
        self.chkZigUnidirectional.SetValue(self.object.zig_unidirectional)
        
        self.EnableControls()
        
        SketchOpDlg.SetFromDataRaw(self)
        
    def EnableControls(self):
        use_zig_zag = self.chkUseZigZag.GetValue()
        
        self.dblZigAngle.Enable(use_zig_zag)
        self.chkZigUnidirectional.Enable(use_zig_zag)

    def SetPictureByName(self, name):
        self.SetPictureByNameAndFolder( name, 'pocket')

    def SetPictureByWindow(self, w):
        if w == self.lgthStepOver: PocketDlg.SetPictureByName(self, 'step over')
        elif w == self.lgthMaterialAllowance: PocketDlg.SetPictureByName(self, 'material allowance')
        elif w == self.cmbStartingPlace:
            if self.cmbStartingPlace.GetSelection() == 1:
                PocketDlg.SetPictureByName(self, 'starting center')
            else:
                PocketDlg.SetPictureByName(self, 'starting boundary')
        elif w == self.cmbCutMode:
            if self.cmbCutMode.GetSelection() == 1:
                PocketDlg.SetPictureByName(self, 'climb milling')
            else:
                PocketDlg.SetPictureByName(self, 'conventional milling')
        elif w == self.chkKeepToolDown:
            if self.chkKeepToolDown.GetValue(): PocketDlg.SetPictureByName(self, 'tool down')
            else: PocketDlg.SetPictureByName(self, 'not tool down')
        elif w == self.chkUseZigZag or w == self.chkZigUnidirectional:
            if self.chkUseZigZag.GetValue():
                if self.chkZigUnidirectional.GetValue(): PocketDlg.SetPictureByName(self, 'zig unidirectional')
                else: PocketDlg.SetPictureByName(self, 'use zig zag')
            else: PocketDlg.SetPictureByName(self, 'general')
        elif w == self.dblZigAngle: PocketDlg.SetPictureByName(self, 'zig angle')
        else:
            SketchOpDlg.SetPictureByWindow(self, w)
Пример #14
0
class AngleAndPlaneDlg(HDialog):
    def __init__(self, angle, axis, axis_type, pos, ncopies, axial_shift,
                 title):
        HDialog.__init__(self, title)
        self.ignore_event_functions = True
        sizerMain = wx.BoxSizer(wx.VERTICAL)

        self.ncopies = ncopies
        self.axis = axis
        self.axis_type = axis_type
        self.pos = pos
        self.btnPick = None
        self.btnVectorPick = None

        if ncopies:
            self.txt_num_copies = wx.TextCtrl(self, wx.ID_ANY, str(ncopies))
            self.AddLabelAndControl(sizerMain, 'Number of Copies',
                                    self.txt_num_copies)

        sizerPosAndAxis = wx.BoxSizer(wx.HORIZONTAL)
        sizerMain.Add(sizerPosAndAxis, 0, wx.EXPAND)

        sizerPos = wx.BoxSizer(wx.VERTICAL)
        sizerPosAndAxis.Add(sizerPos, 0, wx.EXPAND)
        if axis_type == 0:
            sizerPos.Add(wx.StaticText(self, label='Position to Rotate About'),
                         0, wx.EXPAND | wx.ALL, control_border)
        else:
            self.btnPick = wx.Button(self, label='Select')
            self.AddLabelAndControl(sizerPos, 'Position to Rotate About',
                                    self.btnPick)
        self.posx = LengthCtrl(self)
        self.AddLabelAndControl(sizerPos, 'X', self.posx)
        self.posy = LengthCtrl(self)
        self.AddLabelAndControl(sizerPos, 'Y', self.posy)
        self.posz = LengthCtrl(self)
        self.AddLabelAndControl(sizerPos, 'Z', self.posz)
        if axis_type == 0:
            self.btnPick = wx.Button(self, label='Select')
            sizerPos.Add(self.btnPick, wx.EXPAND | wx.ALL, control_border)
        self.posx.SetValue(self.pos.x)
        self.posy.SetValue(self.pos.y)
        self.posz.SetValue(self.pos.z)

        # add picture
        self.picture = PictureWindow(self, wx.Size(150, 100))
        pictureSizer = wx.BoxSizer(wx.HORIZONTAL)
        pictureSizer.Add(self.picture, 1, wx.EXPAND)
        sizerMain.Add(pictureSizer, 0, wx.ALL, control_border)
        sizerPlane = wx.BoxSizer(wx.VERTICAL)
        pictureSizer.Add(sizerPlane, 0, wx.EXPAND)

        if axis_type == 0:
            # non standard axis
            sizerAxis = wx.BoxSizer(wx.VERTICAL)
            sizerPosAndAxis.Add(sizerAxis, 0, wx.EXPAND)

            sizerAxis.Add(wx.StaticText(self, label='Axis to Rotate About'), 0,
                          wx.EXPAND | wx.ALL, control_border)
            self.vectorx = DoubleCtrl(self)
            self.AddLabelAndControl(sizerAxis, 'X', self.vectorx)
            self.vectory = DoubleCtrl(self)
            self.AddLabelAndControl(sizerAxis, 'Y', self.vectory)
            self.vectorz = DoubleCtrl(self)
            self.AddLabelAndControl(sizerAxis, 'Z', self.vectorz)
            self.btnVectorPick = wx.Button(self, label='Select a line')
            sizerAxis.Add(self.btnVectorPick, 0, wx.EXPAND | wx.ALL,
                          control_border)
            self.vectorx.SetValue(axis.x)
            self.vectory.SetValue(axis.y)
            self.vectorz.SetValue(axis.z)
        else:
            self.vectorx = None

        self.rbXy = wx.RadioButton(self, label='XY', style=wx.RB_GROUP)
        self.rbXz = wx.RadioButton(self, label='XZ')
        self.rbYz = wx.RadioButton(self, label='YZ')
        self.rbOther = wx.RadioButton(self, label='Other')
        sizerPlane.Add(self.rbXy, 0, wx.ALL, control_border)
        sizerPlane.Add(self.rbXz, 0, wx.ALL, control_border)
        sizerPlane.Add(self.rbYz, 0, wx.ALL, control_border)
        sizerPlane.Add(self.rbOther, 0, wx.ALL, control_border)

        self.rbXy.SetValue(axis_type == 1)
        self.rbXz.SetValue(axis_type == 2)
        self.rbYz.SetValue(axis_type == 3)
        self.rbOther.SetValue(axis_type == 0)

        self.angle_ctrl = DoubleCtrl(self)
        self.AddLabelAndControl(sizerMain, 'Angle', self.angle_ctrl)
        self.angle_ctrl.SetValue(angle)

        self.axial_shift_ctrl = LengthCtrl(self)
        self.AddLabelAndControl(sizerMain, 'Axial Shift',
                                self.axial_shift_ctrl)
        self.axial_shift_ctrl.SetValue(axial_shift)

        self.MakeOkAndCancel(wx.HORIZONTAL).AddToSizer(sizerMain)

        self.SetSizer(sizerMain)
        sizerMain.SetSizeHints(self)
        sizerMain.Fit(self)

        if ncopies:
            self.txt_num_copies.SetFocus()
        else:
            self.angle_ctrl.SetFocus()

        self.SetPicture()

        self.Bind(wx.EVT_RADIOBUTTON, self.OnRadioButton, self.rbXy)
        self.Bind(wx.EVT_RADIOBUTTON, self.OnRadioButton, self.rbXz)
        self.Bind(wx.EVT_RADIOBUTTON, self.OnRadioButton, self.rbYz)
        self.Bind(wx.EVT_RADIOBUTTON, self.OnRadioButton, self.rbOther)
        if self.btnPick: self.Bind(wx.EVT_BUTTON, self.OnPick, self.btnPick)
        if self.btnVectorPick:
            self.Bind(wx.EVT_BUTTON, self.OnPickVector, self.btnVectorPick)

        self.ignore_event_functions = False

    def OnPick(self, event):
        self.EndModal(self.btnPick.GetId())

    def OnPickVector(self, event):
        self.EndModal(self.btnVectorPick.GetId())

    def OnRadioButton(self, event):
        if self.ignore_event_functions:
            return

        if event.GetId() == self.rbXy.GetId() or event.GetId(
        ) == self.rbXz.GetId() or event.GetId() == self.rbYz.GetId():
            if self.axis_type == 0:
                self.EndModal(event.GetId())

        if event.GetId() == self.rbOther.GetId() and self.axis_type != 0:
            self.EndModal(event.GetId())

        self.SetPicture()

    def SetPictureByName(self, name):
        self.picture.SetPicture(wx.GetApp().cad_dir + '/bitmaps/angle/' +
                                name + '.png')

    def SetPicture(self):
        if self.rbXy.GetValue(): self.SetPictureByName('xy')
        elif self.rbXz.GetValue(): self.SetPictureByName('xz')
        elif self.rbYz.GetValue(): self.SetPictureByName('yz')
        elif self.rbOther.GetValue(): self.SetPictureByName('line')

    def GetAllValues(self):
        angle = self.angle_ctrl.GetValue()
        if self.rbXy.GetValue():
            axis = geom.Point3D(0, 0, 1)
            axis_type = 1
        elif self.rbXz.GetValue():
            axis = geom.Point3D(0, -1, 0)
            axis_type = 2
        elif self.rbYz.GetValue():
            axis = geom.Point3D(1, 0, 0)
            axis_type = 3
        else:
            if self.vectorx == None:
                axis = self.axis
            else:
                axis = geom.Point3D(self.vectorx.GetValue(),
                                    self.vectory.GetValue(),
                                    self.vectorz.GetValue())
            axis_type = 0
        pos = geom.Point3D(self.posx.GetValue(), self.posy.GetValue(),
                           self.posz.GetValue())

        ncopies = None
        if self.ncopies:
            ncopies = int(self.txt_num_copies.GetValue())

        axial_shift = self.axial_shift_ctrl.GetValue()

        return angle, axis, axis_type, pos, ncopies, axial_shift
Пример #15
0
class DepthOpDlg(SpeedOpDlg):
    def __init__(self, object, drill_pictures, title):
        self.drill_pictures = drill_pictures
        SpeedOpDlg.__init__(self, object, False, title)

    def AddLeftControls(self):
        self.lgthClearanceHeight = LengthCtrl(self)
        self.MakeLabelAndControl('Clearance Height',
                                 self.lgthClearanceHeight).AddToSizer(
                                     self.sizerLeft)
        self.lgthRapidDownToHeight = LengthCtrl(self)
        self.MakeLabelAndControl('Rapid Safety Space',
                                 self.lgthRapidDownToHeight).AddToSizer(
                                     self.sizerLeft)
        self.lgthStartDepth = LengthCtrl(self)
        self.MakeLabelAndControl(
            'Start Depth', self.lgthStartDepth).AddToSizer(self.sizerLeft)
        self.lgthFinalDepth = LengthCtrl(self)
        self.MakeLabelAndControl(
            'Final Depth', self.lgthFinalDepth).AddToSizer(self.sizerLeft)
        self.lgthStepDown = LengthCtrl(self)
        self.MakeLabelAndControl('Step Down',
                                 self.lgthStepDown).AddToSizer(self.sizerLeft)
        self.lgthZFinishDepth = LengthCtrl(self)
        self.MakeLabelAndControl(
            'Z Finish Depth', self.lgthZFinishDepth).AddToSizer(self.sizerLeft)
        self.lgthZThruDepth = LengthCtrl(self)
        self.MakeLabelAndControl(
            'Z Through Depth', self.lgthZThruDepth).AddToSizer(self.sizerLeft)

        SpeedOpDlg.AddLeftControls(self)

    def AddRightControls(self):
        SpeedOpDlg.AddRightControls(self)

    def SetDefaultFocus(self):
        self.lgthClearanceHeight.SetFocus()

    def GetDataRaw(self):
        self.object.clearance_height = self.lgthClearanceHeight.GetValue()
        self.object.rapid_safety_space = self.lgthRapidDownToHeight.GetValue()
        self.object.start_depth = self.lgthStartDepth.GetValue()
        self.object.final_depth = self.lgthFinalDepth.GetValue()
        self.object.step_down = self.lgthStepDown.GetValue()
        self.object.z_finish_depth = self.lgthZFinishDepth.GetValue()
        self.object.z_thru_depth = self.lgthZThruDepth.GetValue()

        SpeedOpDlg.GetDataRaw(self)

    def SetFromDataRaw(self):
        self.lgthClearanceHeight.SetValue(self.object.clearance_height)
        self.lgthRapidDownToHeight.SetValue(self.object.rapid_safety_space)
        self.lgthStartDepth.SetValue(self.object.start_depth)
        self.lgthFinalDepth.SetValue(self.object.final_depth)
        self.lgthStepDown.SetValue(self.object.step_down)
        self.lgthZFinishDepth.SetValue(self.object.z_finish_depth)
        self.lgthZThruDepth.SetValue(self.object.z_thru_depth)

        SpeedOpDlg.SetFromDataRaw(self)

    def SetPictureByWindow(self, w):
        if w == self.lgthClearanceHeight:
            DepthOpDlg.SetPictureByName(
                self, "drill clearance height"
                if self.drill_pictures else "clearance height")
        elif w == self.lgthRapidDownToHeight:
            DepthOpDlg.SetPictureByName(
                self, "drill rapid down height"
                if self.drill_pictures else "rapid down height")
        elif w == self.lgthStartDepth:
            DepthOpDlg.SetPictureByName(
                self,
                "drill start depth" if self.drill_pictures else "start depth")
        elif w == self.lgthFinalDepth:
            DepthOpDlg.SetPictureByName(
                self,
                "drill final depth" if self.drill_pictures else "final depth")
        elif w == self.lgthStepDown:
            DepthOpDlg.SetPictureByName(
                self,
                "drill step down" if self.drill_pictures else "step down")
        elif w == self.lgthZFinishDepth:
            DepthOpDlg.SetPictureByName(
                self, "drill z finish depth"
                if self.drill_pictures else "z finish depth")
        elif w == self.lgthZThruDepth:
            DepthOpDlg.SetPictureByName(
                self, "drill z thru depth"
                if self.drill_pictures else "z thru depth")

        else:
            SpeedOpDlg.SetPictureByWindow(self, w)

    def SetPictureByName(self, name):
        self.SetPictureByNameAndFolder(name, 'depthop')
Пример #16
0
    def AddLeftControls(self):
        self.lgthClearanceHeight = LengthCtrl(self)
        self.MakeLabelAndControl('Clearance Height',
                                 self.lgthClearanceHeight).AddToSizer(
                                     self.sizerLeft)
        self.lgthRapidDownToHeight = LengthCtrl(self)
        self.MakeLabelAndControl('Rapid Safety Space',
                                 self.lgthRapidDownToHeight).AddToSizer(
                                     self.sizerLeft)
        self.lgthStartDepth = LengthCtrl(self)
        self.MakeLabelAndControl(
            'Start Depth', self.lgthStartDepth).AddToSizer(self.sizerLeft)
        self.lgthFinalDepth = LengthCtrl(self)
        self.MakeLabelAndControl(
            'Final Depth', self.lgthFinalDepth).AddToSizer(self.sizerLeft)
        self.lgthStepDown = LengthCtrl(self)
        self.MakeLabelAndControl('Step Down',
                                 self.lgthStepDown).AddToSizer(self.sizerLeft)
        self.lgthZFinishDepth = LengthCtrl(self)
        self.MakeLabelAndControl(
            'Z Finish Depth', self.lgthZFinishDepth).AddToSizer(self.sizerLeft)
        self.lgthZThruDepth = LengthCtrl(self)
        self.MakeLabelAndControl(
            'Z Through Depth', self.lgthZThruDepth).AddToSizer(self.sizerLeft)

        SpeedOpDlg.AddLeftControls(self)
Пример #17
0
    def __init__(self, angle, axis, axis_type, pos, ncopies, axial_shift,
                 title):
        HDialog.__init__(self, title)
        self.ignore_event_functions = True
        sizerMain = wx.BoxSizer(wx.VERTICAL)

        self.ncopies = ncopies
        self.axis = axis
        self.axis_type = axis_type
        self.pos = pos
        self.btnPick = None
        self.btnVectorPick = None

        if ncopies:
            self.txt_num_copies = wx.TextCtrl(self, wx.ID_ANY, str(ncopies))
            self.AddLabelAndControl(sizerMain, 'Number of Copies',
                                    self.txt_num_copies)

        sizerPosAndAxis = wx.BoxSizer(wx.HORIZONTAL)
        sizerMain.Add(sizerPosAndAxis, 0, wx.EXPAND)

        sizerPos = wx.BoxSizer(wx.VERTICAL)
        sizerPosAndAxis.Add(sizerPos, 0, wx.EXPAND)
        if axis_type == 0:
            sizerPos.Add(wx.StaticText(self, label='Position to Rotate About'),
                         0, wx.EXPAND | wx.ALL, control_border)
        else:
            self.btnPick = wx.Button(self, label='Select')
            self.AddLabelAndControl(sizerPos, 'Position to Rotate About',
                                    self.btnPick)
        self.posx = LengthCtrl(self)
        self.AddLabelAndControl(sizerPos, 'X', self.posx)
        self.posy = LengthCtrl(self)
        self.AddLabelAndControl(sizerPos, 'Y', self.posy)
        self.posz = LengthCtrl(self)
        self.AddLabelAndControl(sizerPos, 'Z', self.posz)
        if axis_type == 0:
            self.btnPick = wx.Button(self, label='Select')
            sizerPos.Add(self.btnPick, wx.EXPAND | wx.ALL, control_border)
        self.posx.SetValue(self.pos.x)
        self.posy.SetValue(self.pos.y)
        self.posz.SetValue(self.pos.z)

        # add picture
        self.picture = PictureWindow(self, wx.Size(150, 100))
        pictureSizer = wx.BoxSizer(wx.HORIZONTAL)
        pictureSizer.Add(self.picture, 1, wx.EXPAND)
        sizerMain.Add(pictureSizer, 0, wx.ALL, control_border)
        sizerPlane = wx.BoxSizer(wx.VERTICAL)
        pictureSizer.Add(sizerPlane, 0, wx.EXPAND)

        if axis_type == 0:
            # non standard axis
            sizerAxis = wx.BoxSizer(wx.VERTICAL)
            sizerPosAndAxis.Add(sizerAxis, 0, wx.EXPAND)

            sizerAxis.Add(wx.StaticText(self, label='Axis to Rotate About'), 0,
                          wx.EXPAND | wx.ALL, control_border)
            self.vectorx = DoubleCtrl(self)
            self.AddLabelAndControl(sizerAxis, 'X', self.vectorx)
            self.vectory = DoubleCtrl(self)
            self.AddLabelAndControl(sizerAxis, 'Y', self.vectory)
            self.vectorz = DoubleCtrl(self)
            self.AddLabelAndControl(sizerAxis, 'Z', self.vectorz)
            self.btnVectorPick = wx.Button(self, label='Select a line')
            sizerAxis.Add(self.btnVectorPick, 0, wx.EXPAND | wx.ALL,
                          control_border)
            self.vectorx.SetValue(axis.x)
            self.vectory.SetValue(axis.y)
            self.vectorz.SetValue(axis.z)
        else:
            self.vectorx = None

        self.rbXy = wx.RadioButton(self, label='XY', style=wx.RB_GROUP)
        self.rbXz = wx.RadioButton(self, label='XZ')
        self.rbYz = wx.RadioButton(self, label='YZ')
        self.rbOther = wx.RadioButton(self, label='Other')
        sizerPlane.Add(self.rbXy, 0, wx.ALL, control_border)
        sizerPlane.Add(self.rbXz, 0, wx.ALL, control_border)
        sizerPlane.Add(self.rbYz, 0, wx.ALL, control_border)
        sizerPlane.Add(self.rbOther, 0, wx.ALL, control_border)

        self.rbXy.SetValue(axis_type == 1)
        self.rbXz.SetValue(axis_type == 2)
        self.rbYz.SetValue(axis_type == 3)
        self.rbOther.SetValue(axis_type == 0)

        self.angle_ctrl = DoubleCtrl(self)
        self.AddLabelAndControl(sizerMain, 'Angle', self.angle_ctrl)
        self.angle_ctrl.SetValue(angle)

        self.axial_shift_ctrl = LengthCtrl(self)
        self.AddLabelAndControl(sizerMain, 'Axial Shift',
                                self.axial_shift_ctrl)
        self.axial_shift_ctrl.SetValue(axial_shift)

        self.MakeOkAndCancel(wx.HORIZONTAL).AddToSizer(sizerMain)

        self.SetSizer(sizerMain)
        sizerMain.SetSizeHints(self)
        sizerMain.Fit(self)

        if ncopies:
            self.txt_num_copies.SetFocus()
        else:
            self.angle_ctrl.SetFocus()

        self.SetPicture()

        self.Bind(wx.EVT_RADIOBUTTON, self.OnRadioButton, self.rbXy)
        self.Bind(wx.EVT_RADIOBUTTON, self.OnRadioButton, self.rbXz)
        self.Bind(wx.EVT_RADIOBUTTON, self.OnRadioButton, self.rbYz)
        self.Bind(wx.EVT_RADIOBUTTON, self.OnRadioButton, self.rbOther)
        if self.btnPick: self.Bind(wx.EVT_BUTTON, self.OnPick, self.btnPick)
        if self.btnVectorPick:
            self.Bind(wx.EVT_BUTTON, self.OnPickVector, self.btnVectorPick)

        self.ignore_event_functions = False
Пример #18
0
    def __init__(self, fromp, to, ncopies, title):
        HDialog.__init__(self, title)
        self.ignore_event_functions = True
        sizerMain = wx.BoxSizer(wx.VERTICAL)

        self.ncopies = ncopies
        self.fromp = fromp
        self.to = to

        if ncopies:
            self.txt_num_copies = wx.TextCtrl(self, wx.ID_ANY, str(ncopies))
            self.AddLabelAndControl(sizerMain, 'Number of Copies',
                                    self.txt_num_copies)

        sizerPos = wx.BoxSizer(wx.VERTICAL)
        sizerMain.Add(sizerPos, 0, wx.EXPAND)
        self.btnFrom = wx.Button(self, label='Select')
        self.AddLabelAndControl(sizerPos, 'Position to move from',
                                self.btnFrom)
        self.fromx = LengthCtrl(self)
        self.AddLabelAndControl(sizerPos, 'X', self.fromx)
        self.fromy = LengthCtrl(self)
        self.AddLabelAndControl(sizerPos, 'Y', self.fromy)
        self.fromz = LengthCtrl(self)
        self.AddLabelAndControl(sizerPos, 'Z', self.fromz)

        self.fromx.SetValue(fromp.x)
        self.fromy.SetValue(fromp.y)
        self.fromz.SetValue(fromp.z)

        sizerPos2 = wx.BoxSizer(wx.VERTICAL)
        sizerMain.Add(sizerPos2, 0, wx.EXPAND)
        self.btnTo = wx.Button(self, label='Select')
        self.AddLabelAndControl(sizerPos, 'Position to move to', self.btnTo)
        self.tox = LengthCtrl(self)
        self.AddLabelAndControl(sizerPos, 'X', self.tox)
        self.toy = LengthCtrl(self)
        self.AddLabelAndControl(sizerPos, 'Y', self.toy)
        self.toz = LengthCtrl(self)
        self.AddLabelAndControl(sizerPos, 'Z', self.toz)

        self.tox.SetValue(to.x)
        self.toy.SetValue(to.y)
        self.toz.SetValue(to.z)

        self.MakeOkAndCancel(wx.HORIZONTAL).AddToSizer(sizerMain)

        self.SetSizer(sizerMain)
        sizerMain.SetSizeHints(self)
        sizerMain.Fit(self)

        if ncopies:
            self.txt_num_copies.SetFocus()
        else:
            self.fromx.SetFocus()

        self.Bind(wx.EVT_BUTTON, self.OnPickFrom, self.btnFrom)
        self.Bind(wx.EVT_BUTTON, self.OnPickTo, self.btnTo)

        self.ignore_event_functions = False
Пример #19
0
class PatternDlg(HeeksObjDlg):
    def __init__(self, object, title='Pattern', add_picture=True):
        HeeksObjDlg.__init__(self, object, title, add_picture)

    def AddLeftControls(self):
        # add the controls in one column
        self.txtCopies1 = wx.TextCtrl(self)
        self.MakeLabelAndControl('Number of Copies A',
                                 self.txtCopies1).AddToSizer(self.sizerLeft)
        self.lgthXShift1 = LengthCtrl(self)
        self.MakeLabelAndControl("X Shift A",
                                 self.lgthXShift1).AddToSizer(self.sizerLeft)
        self.lgthYShift1 = LengthCtrl(self)
        self.MakeLabelAndControl("Y Shift A",
                                 self.lgthYShift1).AddToSizer(self.sizerLeft)
        self.txtCopies2 = wx.TextCtrl(self)
        self.MakeLabelAndControl('Number of Copies B',
                                 self.txtCopies2).AddToSizer(self.sizerLeft)
        self.lgthXShift2 = LengthCtrl(self)
        self.MakeLabelAndControl("X Shift B",
                                 self.lgthXShift2).AddToSizer(self.sizerLeft)
        self.lgthYShift2 = LengthCtrl(self)
        self.MakeLabelAndControl("Y Shift B",
                                 self.lgthYShift2).AddToSizer(self.sizerLeft)

    def SetDefaultFocus(self):
        self.txtCopies1.SetFocus()

    def GetDataRaw(self):
        self.object.copies1 = int(self.txtCopies1.GetValue())
        self.object.x_shift1 = self.lgthXShift1.GetValue()
        self.object.y_shift1 = self.lgthYShift1.GetValue()
        self.object.copies2 = int(self.txtCopies2.GetValue())
        self.object.x_shift2 = self.lgthXShift2.GetValue()
        self.object.y_shift2 = self.lgthYShift2.GetValue()

    def SetFromDataRaw(self):
        self.txtCopies1.SetValue(str(self.object.copies1))
        self.lgthXShift1.SetValue(self.object.x_shift1)
        self.lgthYShift1.SetValue(self.object.y_shift1)
        self.txtCopies2.SetValue(str(self.object.copies2))
        self.lgthXShift2.SetValue(self.object.x_shift2)
        self.lgthYShift2.SetValue(self.object.y_shift2)

    def DrawPatternShape(self, dc, x, y, original_shape):
        dc.DrawBitmap(
            self.shape_bitmap if original_shape else self.shape_bitmap2,
            x - 13, y - 16)

    def RedrawBitmap2(self, numA, numB, xshiftA, yshiftA, xshiftB, yshiftB):
        # paint a picture with Draw commands
        bitmap = wx.Bitmap(300, 200)
        dc = wx.MemoryDC(bitmap)

        # paint background
        dc.SetBrush(wx.WHITE_BRUSH)
        dc.SetPen(wx.WHITE_PEN)
        dc.DrawRectangle(0, 0, 300, 200)

        #limit numbers for the drawing
        if numA > 20: numA = 20
        if numB > 20: numB = 20

        total_x = math.fabs(xshiftA) * numA + math.fabs(xshiftB) * numB
        total_y = math.fabs(yshiftA) * numA + math.fabs(yshiftB) * numB

        box = geom.Box3D()
        box.InsertPoint(0, 0, 0)
        if numA > 0 and numB > 0:
            box.InsertPoint(xshiftA * (numA - 1), yshiftA * (numA - 1), 0)
            box.InsertPoint(xshiftB * (numB - 1), yshiftB * (numB - 1), 0)
            box.InsertPoint(xshiftA * (numA - 1) + xshiftB * (numB - 1),
                            yshiftA * (numA - 1) + yshiftB * (numB - 1), 0)

        with_margins_x = box.Width() + 2 * PATTERN_MARGIN_X
        with_margins_y = box.Height() + 2 * PATTERN_MARGIN_Y

        scale_x = 1000000000.0
        if box.Width() > 0.000000001:
            scale_x = (300.0 - 2 * PATTERN_MARGIN_X) / box.Width()
        scale_y = 1000000000.0
        if box.Height() > 0.000000001:
            scale_y = (200.0 - 2 * PATTERN_MARGIN_Y) / box.Height()

        # use the smallest scale
        scale = scale_x
        if scale_y < scale: scale = scale_y

        ox = -box.MinX()
        oy = -box.MinY()

        img = wx.Image(wx.GetApp().cam_dir + '/bitmaps/pattern/shape.png')
        img2 = wx.Image(wx.GetApp().cam_dir + '/bitmaps/pattern/shape2.png')

        num = numA
        if numB > num: num = numB
        if num > 5:
            s = (24.0 - num) / 19.0
            neww = 26.0 * s
            newh = 31.0 * s
            img.Rescale(neww, newh)
            img2.Rescale(neww, newh)

        self.shape_bitmap = wx.Bitmap(img)
        self.shape_bitmap2 = wx.Bitmap(img2)

        # draw the pattern
        for j in range(0, numB):
            for i in range(0, numA):
                x = PATTERN_MARGIN_X + (ox + i * xshiftA + j * xshiftB) * scale
                ix = x
                y = PATTERN_MARGIN_Y + (oy + i * yshiftA + j * yshiftB) * scale
                iy = 200 - y
                self.DrawPatternShape(dc, ix, iy, i == 0 and j == 0)

        dc.SelectObject(wx.NullBitmap)

        return bitmap

    def RedrawBitmap(self):
        copies1 = int(self.txtCopies1.GetValue())
        x_shift1 = float(self.lgthXShift1.GetValue())
        y_shift1 = float(self.lgthYShift1.GetValue())
        copies2 = int(self.txtCopies2.GetValue())
        x_shift2 = float(self.lgthXShift2.GetValue())
        y_shift2 = float(self.lgthYShift2.GetValue())
        return self.RedrawBitmap2(copies1, copies2, x_shift1, y_shift1,
                                  x_shift2, y_shift2)

    def SetPictureByWindow(self, w):
        self.picture.bitmap = self.RedrawBitmap()
        self.picture.Refresh()
Пример #20
0
class MirrorDlg(HDialog):
    def __init__(self, axis, pos, axis_type, copy, title):
        HDialog.__init__(self, title)
        self.ignore_event_functions = True
        sizerMain = wx.BoxSizer(wx.VERTICAL)

        self.copy = copy
        self.axis = axis
        self.axis_type = axis_type
        self.pos = pos
        self.btnPick = None
        self.btnVectorPick = None

        self.chkCopy = wx.CheckBox(self, wx.ID_ANY, 'Keep Original')
        HControl(wx.ALL, self.chkCopy).AddToSizer(sizerMain)
        self.chkCopy.SetValue(copy)

        sizerPosAndAxis = wx.BoxSizer(wx.HORIZONTAL)
        sizerMain.Add(sizerPosAndAxis, 0, wx.EXPAND)

        sizerPos = wx.BoxSizer(wx.VERTICAL)
        sizerPosAndAxis.Add(sizerPos, 0, wx.EXPAND)
        if axis_type == 0:
            sizerPos.Add(wx.StaticText(self, label='Position to Mirror About'),
                         0, wx.EXPAND | wx.ALL, control_border)
        else:
            self.btnPick = wx.Button(self, label='Select')
            self.AddLabelAndControl(sizerPos, 'Position to Mirror About',
                                    self.btnPick)
        self.posx = LengthCtrl(self)
        self.AddLabelAndControl(sizerPos, 'X', self.posx)
        self.posy = LengthCtrl(self)
        self.AddLabelAndControl(sizerPos, 'Y', self.posy)
        self.posz = LengthCtrl(self)
        self.AddLabelAndControl(sizerPos, 'Z', self.posz)
        if axis_type == 0:
            self.btnPick = wx.Button(self, label='Select')
            sizerPos.Add(self.btnPick, wx.EXPAND | wx.ALL, control_border)
        self.posx.SetValue(self.pos.x)
        self.posy.SetValue(self.pos.y)
        self.posz.SetValue(self.pos.z)
        if axis_type != 0:
            self.posx.Enable(axis_type == 1)
            self.posy.Enable(axis_type == 2)
            self.posz.Enable(axis_type == 3)

        if axis_type == 0:
            # non standard axis
            sizerAxis = wx.BoxSizer(wx.VERTICAL)
            sizerPosAndAxis.Add(sizerAxis, 0, wx.EXPAND)

            sizerAxis.Add(wx.StaticText(self, label='Axis to Mirror Through'),
                          0, wx.EXPAND | wx.ALL, control_border)
            self.vectorx = DoubleCtrl(self)
            self.AddLabelAndControl(sizerAxis, 'X', self.vectorx)
            self.vectory = DoubleCtrl(self)
            self.AddLabelAndControl(sizerAxis, 'Y', self.vectory)
            self.vectorz = DoubleCtrl(self)
            self.AddLabelAndControl(sizerAxis, 'Z', self.vectorz)
            self.btnVectorPick = wx.Button(self, label='Select Axis Point')
            sizerAxis.Add(self.btnVectorPick, 0, wx.EXPAND | wx.ALL,
                          control_border)
            self.vectorx.SetValue(axis.x)
            self.vectory.SetValue(axis.y)
            self.vectorz.SetValue(axis.z)
        else:
            self.vectorx = None

        # add picture
        self.picture = PictureWindow(self, wx.Size(150, 100))
        pictureSizer = wx.BoxSizer(wx.HORIZONTAL)
        pictureSizer.Add(self.picture, 1, wx.EXPAND)
        sizerMain.Add(pictureSizer, 0, wx.ALL, control_border)
        sizerPlane = wx.BoxSizer(wx.VERTICAL)
        pictureSizer.Add(sizerPlane, 0, wx.EXPAND)

        self.rbH = wx.RadioButton(self, label='Horizontal', style=wx.RB_GROUP)
        self.rbV = wx.RadioButton(self, label='Vertical')
        self.rbZ = wx.RadioButton(self, label='Z')
        self.rbOther = wx.RadioButton(self, label='Other')
        sizerPlane.Add(self.rbH, 0, wx.ALL, control_border)
        sizerPlane.Add(self.rbV, 0, wx.ALL, control_border)
        sizerPlane.Add(self.rbZ, 0, wx.ALL, control_border)
        sizerPlane.Add(self.rbOther, 0, wx.ALL, control_border)

        self.rbH.SetValue(axis_type == 1)
        self.rbV.SetValue(axis_type == 2)
        self.rbZ.SetValue(axis_type == 3)
        self.rbOther.SetValue(axis_type == 0)

        self.MakeOkAndCancel(wx.HORIZONTAL).AddToSizer(sizerMain)

        self.SetPicture()

        self.SetSizer(sizerMain)
        sizerMain.SetSizeHints(self)
        sizerMain.Fit(self)

        self.chkCopy.SetFocus()

        self.Bind(wx.EVT_RADIOBUTTON, self.OnRadioButton, self.rbH)
        self.Bind(wx.EVT_RADIOBUTTON, self.OnRadioButton, self.rbV)
        self.Bind(wx.EVT_RADIOBUTTON, self.OnRadioButton, self.rbZ)
        self.Bind(wx.EVT_RADIOBUTTON, self.OnRadioButton, self.rbOther)
        if self.btnPick: self.Bind(wx.EVT_BUTTON, self.OnPick, self.btnPick)
        if self.btnVectorPick:
            self.Bind(wx.EVT_BUTTON, self.OnPickVector, self.btnVectorPick)

        self.ignore_event_functions = False

    def OnPick(self, event):
        self.EndModal(self.btnPick.GetId())

    def OnPickVector(self, event):
        self.EndModal(self.btnVectorPick.GetId())

    def OnRadioButton(self, event):
        if self.ignore_event_functions:
            return

        if event.GetId() == self.rbH.GetId() or event.GetId(
        ) == self.rbV.GetId() or event.GetId() == self.rbZ.GetId():
            if self.axis_type == 0:
                self.EndModal(event.GetId())

        if event.GetId() == self.rbOther.GetId() and self.axis_type != 0:
            self.EndModal(event.GetId())

        self.SetPicture()

    def SetPictureByName(self, name):
        self.picture.SetPicture(wx.GetApp().cad_dir + '/bitmaps/mirror/' +
                                name + '.png')

    def SetPicture(self):
        if self.rbH.GetValue(): self.SetPictureByName('horiz')
        elif self.rbV.GetValue(): self.SetPictureByName('vert')
        elif self.rbZ.GetValue(): self.SetPictureByName('z')
        elif self.rbOther.GetValue(): self.SetPictureByName('other')

    def GetAllValues(self):
        if self.rbH.GetValue():
            axis = geom.Point3D(1, 0, 0)
            axis_type = 1
        elif self.rbV.GetValue():
            axis = geom.Point3D(0, 1, 0)
            axis_type = 2
        elif self.rbZ.GetValue():
            axis = geom.Point3D(0, 0, 1)
            axis_type = 3
        else:
            if self.vectorx == None:
                axis = self.axis
            else:
                axis = geom.Point3D(self.vectorx.GetValue(),
                                    self.vectory.GetValue(),
                                    self.vectorz.GetValue())
            axis_type = 0
        pos = geom.Point3D(self.posx.GetValue(), self.posy.GetValue(),
                           self.posz.GetValue())

        copy = self.chkCopy.GetValue()

        return axis, pos, axis_type, copy
Пример #21
0
class ToolDlg(HeeksObjDlg):
    def __init__(self, object, title="Tool Definition"):
        HeeksObjDlg.__init__(self, object, title, True)

    def AddLeftControls(self):
        self.txtToolNumber = wx.TextCtrl(self)
        self.MakeLabelAndControl("Tool Number",
                                 self.txtToolNumber).AddToSizer(self.sizerLeft)

        self.cmbMaterial = wx.ComboBox(self,
                                       choices=["High Speed Steel", "Carbide"])
        self.Bind(wx.EVT_COMBOBOX, self.OnComboMaterial, self.cmbMaterial)
        self.MakeLabelAndControl("Tool Material",
                                 self.cmbMaterial).AddToSizer(self.sizerLeft)

        self.cmbToolType = wx.ComboBox(self, choices=Tool.GetToolTypeNames())
        self.Bind(wx.EVT_COMBOBOX, self.OnComboToolType, self.cmbToolType)
        self.MakeLabelAndControl("Tool Type",
                                 self.cmbToolType).AddToSizer(self.sizerLeft)

        self.lgthDiameter = LengthCtrl(self)
        self.MakeLabelAndControl("Diameter",
                                 self.lgthDiameter).AddToSizer(self.sizerLeft)
        self.Bind(wx.EVT_TEXT, self.OnDiamChange, self.lgthDiameter)

        self.lgthToolLengthOffset = LengthCtrl(self)
        self.MakeLabelAndControl("Tool Length Offset",
                                 self.lgthToolLengthOffset).AddToSizer(
                                     self.sizerLeft)

        self.lgthFlatRadius = LengthCtrl(self)
        self.MakeLabelAndControl(
            "Flat Radius", self.lgthFlatRadius).AddToSizer(self.sizerLeft)

        self.lgthCornerRadius = LengthCtrl(self)
        self.MakeLabelAndControl(
            "Corner Radius", self.lgthCornerRadius).AddToSizer(self.sizerLeft)

        self.lgthCuttingEdgeAngle = DoubleCtrl(self)
        self.MakeLabelAndControl("Cutting Edge Angle",
                                 self.lgthCuttingEdgeAngle).AddToSizer(
                                     self.sizerLeft)

        self.lgthCuttingEdgeHeight = LengthCtrl(self)
        self.MakeLabelAndControl("Cutting Edge Height",
                                 self.lgthCuttingEdgeHeight).AddToSizer(
                                     self.sizerLeft)

        HeeksObjDlg.AddLeftControls(self)

    def AddRightControls(self):
        self.txtTitle = wx.TextCtrl(self, wx.ID_ANY)
        self.MakeLabelAndControl('Title',
                                 self.txtTitle).AddToSizer(self.sizerRight)
        self.txtTitle.Bind(wx.EVT_TEXT, self.OnTitleEdited)
        self.cmbTitleType = wx.ComboBox(self,
                                        choices=[
                                            "Leave manually assigned title",
                                            "Automatically Generate Title"
                                        ])
        self.MakeLabelAndControl("Title Type",
                                 self.cmbTitleType).AddToSizer(self.sizerRight)
        self.cmbTitleType.Bind(wx.EVT_COMBOBOX, self.OnTitleType)

        HeeksObjDlg.AddRightControls(self)

    def GetDataRaw(self):
        self.object.tool_number = int(self.txtToolNumber.GetValue())
        self.object.material = self.cmbMaterial.GetSelection()
        self.object.type = Tool.GetToolTypeValues()[
            self.cmbToolType.GetSelection()]
        self.object.diameter = self.lgthDiameter.GetValue()
        self.object.tool_length_offset = self.lgthToolLengthOffset.GetValue()
        self.object.flat_radius = self.lgthFlatRadius.GetValue()
        self.object.corner_radius = self.lgthCornerRadius.GetValue()
        self.object.cutting_edge_angle = self.lgthCuttingEdgeAngle.GetValue()
        self.object.cutting_edge_height = self.lgthCuttingEdgeHeight.GetValue()
        self.object.title = self.txtTitle.GetValue()
        self.object.automatically_generate_title = (
            self.cmbTitleType.GetSelection() != 0)

        HeeksObjDlg.GetDataRaw(self)

    def SetFromDataRaw(self):
        self.txtToolNumber.SetValue(str(self.object.tool_number))
        self.cmbMaterial.SetSelection(self.object.material)
        self.cmbToolType.SetSelection(Tool.GetToolTypeIndex(self.object.type))
        self.lgthDiameter.SetValue(self.object.diameter)
        self.lgthToolLengthOffset.SetValue(self.object.tool_length_offset)
        self.lgthFlatRadius.SetValue(self.object.flat_radius)
        self.lgthCornerRadius.SetValue(self.object.corner_radius)
        self.lgthCuttingEdgeAngle.SetValue(self.object.cutting_edge_angle)
        self.lgthCuttingEdgeHeight.SetValue(self.object.cutting_edge_height)
        self.txtTitle.SetValue(self.object.title)
        self.cmbTitleType.SetSelection(
            1 if self.object.automatically_generate_title else 0)

        self.EnableAndSetCornerFlatAndAngle()

        HeeksObjDlg.SetFromDataRaw(self)

    def SetPictureByName(self, name):
        self.SetPictureByNameAndFolder(name, "tool")

    def SetPictureByNameAndFolder(self, name, folder):
        if self.picture:
            self.picture.SetPicture(wx.GetApp().cam_dir + '/bitmaps/' +
                                    folder + '/' + name + '.png')

    def SetPictureByWindow(self, w):
        type = Tool.GetToolTypeValues()[self.cmbToolType.GetSelection()]
        if type == TOOL_TYPE_DRILL:
            if w == self.lgthDiameter: self.SetPictureByName('drill_diameter')
            elif w == self.lgthToolLengthOffset:
                self.SetPictureByName('drill_offset')
            elif w == self.lgthFlatRadius:
                self.SetPictureByName('drill_flat')
            elif w == self.lgthCornerRadius:
                self.SetPictureByName('drill_corner')
            elif w == self.lgthCuttingEdgeAngle:
                self.SetPictureByName('drill_angle')
            elif w == self.lgthCuttingEdgeHeight:
                self.SetPictureByName('drill_height')
            else:
                self.SetPictureByName('drill')
        elif type == TOOL_TYPE_CENTREDRILL:
            if w == self.lgthDiameter:
                self.SetPictureByName('centre_drill_diameter')
            elif w == self.lgthToolLengthOffset:
                self.SetPictureByName('centre_drill_offset')
            elif w == self.lgthFlatRadius:
                self.SetPictureByName('centre_drill_flat')
            elif w == self.lgthCornerRadius:
                self.SetPictureByName('centre_drill_corner')
            elif w == self.lgthCuttingEdgeAngle:
                self.SetPictureByName('centre_drill_angle')
            elif w == self.lgthCuttingEdgeHeight:
                self.SetPictureByName('centre_drill_height')
            else:
                self.SetPictureByName('centre_drill')
        elif type == TOOL_TYPE_ENDMILL or type == TOOL_TYPE_SLOTCUTTER:
            if w == self.lgthDiameter:
                self.SetPictureByName('end_mill_diameter')
            elif w == self.lgthToolLengthOffset:
                self.SetPictureByName('end_mill_offset')
            elif w == self.lgthFlatRadius:
                self.SetPictureByName('end_mill_flat')
            elif w == self.lgthCornerRadius:
                self.SetPictureByName('end_mill_corner')
            elif w == self.lgthCuttingEdgeAngle:
                self.SetPictureByName('end_mill_angle')
            elif w == self.lgthCuttingEdgeHeight:
                self.SetPictureByName('end_mill_height')
            else:
                self.SetPictureByName('end_mill')
        elif type == TOOL_TYPE_BALLENDMILL:
            if w == self.lgthDiameter:
                self.SetPictureByName('ball_mill_diameter')
            elif w == self.lgthToolLengthOffset:
                self.SetPictureByName('ball_mill_offset')
            elif w == self.lgthFlatRadius:
                self.SetPictureByName('ball_mill_flat')
            elif w == self.lgthCornerRadius:
                self.SetPictureByName('ball_mill_corner')
            elif w == self.lgthCuttingEdgeAngle:
                self.SetPictureByName('ball_mill_angle')
            elif w == self.lgthCuttingEdgeHeight:
                self.SetPictureByName('ball_mill_height')
            else:
                self.SetPictureByName('ball_mill')
        elif type == TOOL_TYPE_CHAMFER:
            if w == self.lgthDiameter:
                self.SetPictureByName('chamfer_diameter')
            elif w == self.lgthToolLengthOffset:
                self.SetPictureByName('chamfer_offset')
            elif w == self.lgthFlatRadius:
                self.SetPictureByName('chamfer_flat')
            elif w == self.lgthCornerRadius:
                self.SetPictureByName('chamfer_corner')
            elif w == self.lgthCuttingEdgeAngle:
                self.SetPictureByName('chamfer_angle')
            elif w == self.lgthCuttingEdgeHeight:
                self.SetPictureByName('chamfer_height')
            else:
                self.SetPictureByName('chamfer')
        elif type == TOOL_TYPE_ENGRAVER:
            if w == self.lgthDiameter:
                self.SetPictureByName('engraver_diameter')
            elif w == self.lgthToolLengthOffset:
                self.SetPictureByName('engraver_offset')
            elif w == self.lgthFlatRadius:
                self.SetPictureByName('engraver_flat')
            elif w == self.lgthCornerRadius:
                self.SetPictureByName('engraver_corner')
            elif w == self.lgthCuttingEdgeAngle:
                self.SetPictureByName('engraver_angle')
            elif w == self.lgthCuttingEdgeHeight:
                self.SetPictureByName('engraver_height')
            else:
                self.SetPictureByName('engraver')

    def OnComboToolType(self, e):
        self.EnableAndSetCornerFlatAndAngle()
        self.SetTitleFromControls()
        HeeksObjDlg.SetPicture(self)

    def OnComboMaterial(self, e):
        self.SetTitleFromControls()
        HeeksObjDlg.SetPicture(self)

    def EnableAndSetCornerFlatAndAngle(self):
        type = Tool.GetToolTypeValues()[self.cmbToolType.GetSelection()]
        if type == TOOL_TYPE_DRILL or type == TOOL_TYPE_CENTREDRILL:
            self.lgthCornerRadius.Enable(False)
            self.lgthCornerRadius.SetLabel("")
            self.lgthFlatRadius.Enable(False)
            self.lgthFlatRadius.SetLabel("")
            self.lgthCuttingEdgeAngle.Enable()
            self.lgthCuttingEdgeAngle.SetValue(self.object.cutting_edge_angle)
        elif type == TOOL_TYPE_ENDMILL or type == TOOL_TYPE_SLOTCUTTER:
            self.lgthCornerRadius.Enable()
            self.lgthCornerRadius.SetValue(self.object.corner_radius)
            self.lgthFlatRadius.Enable(False)
            self.lgthFlatRadius.SetLabel("")
            self.lgthCuttingEdgeAngle.Enable(False)
            self.lgthCuttingEdgeAngle.SetLabel("")
        elif type == TOOL_TYPE_BALLENDMILL:
            self.lgthCornerRadius.Enable(False)
            self.lgthCornerRadius.SetLabel("")
            self.lgthFlatRadius.Enable(False)
            self.lgthFlatRadius.SetLabel("")
            self.lgthCuttingEdgeAngle.Enable(False)
            self.lgthCuttingEdgeAngle.SetLabel("")
        elif type == TOOL_TYPE_CHAMFER or type == TOOL_TYPE_ENGRAVER:
            self.lgthCornerRadius.Enable(False)
            self.lgthCornerRadius.SetLabel("")
            self.lgthFlatRadius.Enable()
            self.lgthFlatRadius.SetValue(self.object.flat_radius)
            self.lgthCuttingEdgeAngle.Enable()
            self.lgthCuttingEdgeAngle.SetValue(self.object.cutting_edge_angle)

    def SetTitleFromControls(self):
        if self.ignore_event_functions:
            return
        if self.cmbTitleType.GetSelection() == 0:
            return
        save_object = self.object
        self.object = self.object.MakeACopy()
        self.GetData()
        self.ignore_event_functions = True
        self.object.ResetTitle()
        self.txtTitle.SetValue(self.object.title)
        self.object = save_object
        self.ignore_event_functions = False

    def OnDiamChange(self, e):
        self.SetTitleFromControls()

    def OnTitleEdited(self, event):
        if self.ignore_event_functions:
            return
        # if the user starts typing in the title, change type to manually assigned
        self.ignore_event_functions = True
        self.cmbTitleType.SetSelection(0)
        self.ignore_event_functions = False

    def OnTitleType(self, event):
        if self.ignore_event_functions:
            return
        self.SetTitleFromControls()
Пример #22
0
class ProfileDlg(SketchOpDlg):
    def __init__(self, object, title = 'Profile Operation'):
        SketchOpDlg.__init__(self, object, title)

    def AddLeftControls(self):
        # add all the controls to the left side
        tool_on_side_choices = ['Left', 'Right', 'On']
        self.cmbToolOnSide = ComboBoxBinded(self, choices = tool_on_side_choices)
        self.MakeLabelAndControl("Tool On Side", self.cmbToolOnSide).AddToSizer(self.sizerLeft)
        
        #self.SetSketchOrderAndCombo(self.sketch)
        
        cut_mode_choices = ["Conventional", "Climb"]
        self.cmbCutMode = ComboBoxBinded(self, choices = cut_mode_choices)
        self.MakeLabelAndControl("Cut Mode", self.cmbCutMode).AddToSizer(self.sizerLeft)
        #self.Bind(wx.EVT_COMBOBOX, self.OnComboOrCheck, self.cmbCutMode)
        self.lgthRollRadius = LengthCtrl(self)
        self.MakeLabelAndControl("Roll Radius", self.lgthRollRadius).AddToSizer(self.sizerLeft)
        self.lgthOffsetExtra = LengthCtrl(self)
        self.MakeLabelAndControl("Offset Extra", self.lgthOffsetExtra).AddToSizer(self.sizerLeft)
        self.chkDoFinishingPass = wx.CheckBox(self, wx.ID_ANY, 'Do Finishing Pass')
        HControl(wx.ALL, self.chkDoFinishingPass).AddToSizer(self.sizerLeft)
        self.chkOnlyFinishingPass = wx.CheckBox(self, wx.ID_ANY, 'Only Finishing Pass')
        HControl(wx.ALL, self.chkOnlyFinishingPass).AddToSizer(self.sizerLeft)
        
        self.lgthFinishingFeedrate = LengthCtrl(self)
        self.staticFinishingFeedrate = wx.StaticText(self, wx.ID_ANY, "Finishing Feed Rate")
        self.MakeControlUsingStaticText(self.staticFinishingFeedrate, self.lgthFinishingFeedrate).AddToSizer(self.sizerLeft)
        self.cmbFinishingCutMode = ComboBoxBinded(self, choices = cut_mode_choices)
        self.staticFinishingCutMode = wx.StaticText(self, wx.ID_ANY, "Finishing Cut Mode")
        self.MakeControlUsingStaticText(self.staticFinishingCutMode, self.cmbFinishingCutMode).AddToSizer(self.sizerLeft)
        self.lgthFinishStepDown = LengthCtrl(self)
        self.staticFinishStepDown = wx.StaticText(self, wx.ID_ANY, "Finish Step Down")
        self.MakeControlUsingStaticText(self.staticFinishStepDown, self.lgthFinishStepDown).AddToSizer(self.sizerLeft)
        
        SketchOpDlg.AddLeftControls(self)
        
    def OnSketchCombo(self, event):
        choice = self.cmbToolOnSide.GetSelection()
        self.SetSketchOrderAndCombo(self.cmbSketch.GetSelectedId())
        self.cmbToolOnSide.SetSelection(choice)
        
    def SetDefaultFocus(self):
        #self.cmbSketch.SetFocus()
        pass
            
    def GetDataRaw(self):
        if self.cmbToolOnSide.GetSelection() == 0:
            self.object.tool_on_side = Profile.PROFILE_LEFT_OR_OUTSIDE
        elif self.cmbToolOnSide.GetSelection() == 1:
            self.object.tool_on_side = Profile.PROFILE_RIGHT_OR_INSIDE
        elif self.cmbToolOnSide.GetSelection() == 2:
            self.object.tool_on_side = Profile.PROFILE_ON
            
        self.object.cut_mode = Profile.PROFILE_CLIMB if self.cmbCutMode.GetValue().lower() == 'climb' else Profile.PROFILE_CONVENTIONAL
        self.object.auto_roll_radius = self.lgthRollRadius.GetValue()
        self.object.offset_extra = self.lgthOffsetExtra.GetValue()
        self.object.do_finishing_pass = self.chkDoFinishingPass.GetValue()
        self.object.only_finishing_pass = self.chkOnlyFinishingPass.GetValue()
        self.object.finishing_h_feed_rate = self.lgthFinishingFeedrate.GetValue()
        self.object.finishing_cut_mode = Profile.PROFILE_CLIMB if self.cmbFinishingCutMode.GetValue().lower() == 'climb' else Profile.PROFILE_CONVENTIONAL
        self.object.finishing_step_down = self.lgthFinishStepDown.GetValue()

        SketchOpDlg.GetDataRaw(self)
        
    def SetFromDataRaw(self):
        choice = 2
        if self.object.tool_on_side == Profile.PROFILE_RIGHT_OR_INSIDE:
            choice = 1
        elif self.object.tool_on_side == Profile.PROFILE_LEFT_OR_OUTSIDE:
            choice = 0
        self.cmbToolOnSide.SetSelection(choice)
        
        self.cmbCutMode.SetValue("Climb" if self.object.cut_mode == Profile.PROFILE_CLIMB else "Conventional")
        self.lgthRollRadius.SetValue(self.object.auto_roll_radius)
        self.lgthOffsetExtra.SetValue(self.object.offset_extra)
        self.chkDoFinishingPass.SetValue(self.object.do_finishing_pass)
        self.chkOnlyFinishingPass.SetValue(self.object.only_finishing_pass)
        self.lgthFinishingFeedrate.SetValue(self.object.finishing_h_feed_rate)
        self.cmbFinishingCutMode.SetValue("Climb" if self.object.finishing_cut_mode == Profile.PROFILE_CLIMB else "Conventional")
        self.lgthFinishStepDown.SetValue(self.object.finishing_step_down)
        
        self.EnableControls()
        
        SketchOpDlg.SetFromDataRaw(self)
        
        self.SetSketchOrderAndCombo(self.cmbSketch.GetSelectedId())
        
    def EnableControls(self):
        finish = self.chkDoFinishingPass.GetValue()
        
        self.chkOnlyFinishingPass.Enable(finish)
        self.lgthFinishingFeedrate.Enable(finish)
        self.cmbFinishingCutMode.Enable(finish)
        self.lgthFinishStepDown.Enable(finish)
        self.staticFinishingFeedrate.Enable(finish)
        self.staticFinishingCutMode.Enable(finish)
        self.staticFinishStepDown.Enable(finish)
        
    def SetPictureByName(self, name):
        self.SetPictureByNameAndFolder( name, 'profile')
        
    def SetPictureByWindow(self, w):
        if w == self.cmbToolOnSide:
            sel = self.cmbToolOnSide.GetSelection()
            if sel == 2:
                ProfileDlg.SetPictureByName(self, 'side on')
            else:
                if self.order == cad.SketchOrderType.SketchOrderTypeOpen:
                    ProfileDlg.SetPictureByName(self, 'side right' if sel == 1 else 'side left')
                elif self.order == cad.SketchOrderType.SketchOrderTypeCloseCW or self.order == cad.SketchOrderType.SketchOrderTypeCloseCCW:
                    ProfileDlg.SetPictureByName(self, 'side inside' if sel == 1 else 'side outside')
                else:
                    ProfileDlg.SetPictureByName(self, 'side inside or right' if sel == 1 else 'side outside or left')
        elif w == self.cmbCutMode:
            if self.cmbCutMode.GetValue() == 'Climb':
                self.SetPictureByNameAndFolder('climb milling', 'pocket')
            else:
                self.SetPictureByNameAndFolder('conventional milling', 'pocket')
        elif w == self.lgthRollRadius: ProfileDlg.SetPictureByName(self, 'roll radius')
        elif w == self.lgthOffsetExtra: ProfileDlg.SetPictureByName(self, 'offset extra')
        elif w == self.chkDoFinishingPass or w == self.chkOnlyFinishingPass:
            if self.chkDoFinishingPass.GetValue():
                if self.chkOnlyFinishingPass.GetValue():
                    ProfileDlg.SetPictureByName(self, 'only finishing')
                else:
                    ProfileDlg.SetPictureByName(self, 'no finishing pass')
        elif w == self.cmbFinishingCutMode:
            if self.cmbFinishingCutMode.GetValue() == 'Climb':
                self.SetPictureByNameAndFolder('climb milling', 'pocket')
            else:
                self.SetPictureByNameAndFolder('conventional milling', 'pocket')
        elif w == self.lgthFinishStepDown:
            self.SetPictureByNameAndFolder('step down', 'depthop')
#        else:
#            SketchOpDlg.SetPictureByWindow(self, w)
        
    def SetSketchOrderAndCombo(self, s):
        self.order = cad.SketchOrderType.SketchOrderTypeUnknown
        
        sketch = cad.GetObjectFromId(cad.OBJECT_TYPE_SKETCH, s)
        if sketch and sketch.GetType() == cad.OBJECT_TYPE_SKETCH:
            self.order = sketch.GetSketchOrder()
            
        if self.order == cad.SketchOrderType.SketchOrderTypeOpen:
            self.cmbToolOnSide.SetString(0, 'Left')
            self.cmbToolOnSide.SetString(1, 'Right')
        elif self.order == cad.SketchOrderType.SketchOrderTypeCloseCW or self.order == cad.SketchOrderType.SketchOrderTypeCloseCCW:
            self.cmbToolOnSide.SetString(0, 'Outside')
            self.cmbToolOnSide.SetString(1, 'Inside')
        else:
            self.cmbToolOnSide.SetString(0, 'Outside or Left')
            self.cmbToolOnSide.SetString(1, 'Inside or Right')
Пример #23
0
    def __init__(self, axis, pos, axis_type, copy, title):
        HDialog.__init__(self, title)
        self.ignore_event_functions = True
        sizerMain = wx.BoxSizer(wx.VERTICAL)

        self.copy = copy
        self.axis = axis
        self.axis_type = axis_type
        self.pos = pos
        self.btnPick = None
        self.btnVectorPick = None

        self.chkCopy = wx.CheckBox(self, wx.ID_ANY, 'Keep Original')
        HControl(wx.ALL, self.chkCopy).AddToSizer(sizerMain)
        self.chkCopy.SetValue(copy)

        sizerPosAndAxis = wx.BoxSizer(wx.HORIZONTAL)
        sizerMain.Add(sizerPosAndAxis, 0, wx.EXPAND)

        sizerPos = wx.BoxSizer(wx.VERTICAL)
        sizerPosAndAxis.Add(sizerPos, 0, wx.EXPAND)
        if axis_type == 0:
            sizerPos.Add(wx.StaticText(self, label='Position to Mirror About'),
                         0, wx.EXPAND | wx.ALL, control_border)
        else:
            self.btnPick = wx.Button(self, label='Select')
            self.AddLabelAndControl(sizerPos, 'Position to Mirror About',
                                    self.btnPick)
        self.posx = LengthCtrl(self)
        self.AddLabelAndControl(sizerPos, 'X', self.posx)
        self.posy = LengthCtrl(self)
        self.AddLabelAndControl(sizerPos, 'Y', self.posy)
        self.posz = LengthCtrl(self)
        self.AddLabelAndControl(sizerPos, 'Z', self.posz)
        if axis_type == 0:
            self.btnPick = wx.Button(self, label='Select')
            sizerPos.Add(self.btnPick, wx.EXPAND | wx.ALL, control_border)
        self.posx.SetValue(self.pos.x)
        self.posy.SetValue(self.pos.y)
        self.posz.SetValue(self.pos.z)
        if axis_type != 0:
            self.posx.Enable(axis_type == 1)
            self.posy.Enable(axis_type == 2)
            self.posz.Enable(axis_type == 3)

        if axis_type == 0:
            # non standard axis
            sizerAxis = wx.BoxSizer(wx.VERTICAL)
            sizerPosAndAxis.Add(sizerAxis, 0, wx.EXPAND)

            sizerAxis.Add(wx.StaticText(self, label='Axis to Mirror Through'),
                          0, wx.EXPAND | wx.ALL, control_border)
            self.vectorx = DoubleCtrl(self)
            self.AddLabelAndControl(sizerAxis, 'X', self.vectorx)
            self.vectory = DoubleCtrl(self)
            self.AddLabelAndControl(sizerAxis, 'Y', self.vectory)
            self.vectorz = DoubleCtrl(self)
            self.AddLabelAndControl(sizerAxis, 'Z', self.vectorz)
            self.btnVectorPick = wx.Button(self, label='Select Axis Point')
            sizerAxis.Add(self.btnVectorPick, 0, wx.EXPAND | wx.ALL,
                          control_border)
            self.vectorx.SetValue(axis.x)
            self.vectory.SetValue(axis.y)
            self.vectorz.SetValue(axis.z)
        else:
            self.vectorx = None

        # add picture
        self.picture = PictureWindow(self, wx.Size(150, 100))
        pictureSizer = wx.BoxSizer(wx.HORIZONTAL)
        pictureSizer.Add(self.picture, 1, wx.EXPAND)
        sizerMain.Add(pictureSizer, 0, wx.ALL, control_border)
        sizerPlane = wx.BoxSizer(wx.VERTICAL)
        pictureSizer.Add(sizerPlane, 0, wx.EXPAND)

        self.rbH = wx.RadioButton(self, label='Horizontal', style=wx.RB_GROUP)
        self.rbV = wx.RadioButton(self, label='Vertical')
        self.rbZ = wx.RadioButton(self, label='Z')
        self.rbOther = wx.RadioButton(self, label='Other')
        sizerPlane.Add(self.rbH, 0, wx.ALL, control_border)
        sizerPlane.Add(self.rbV, 0, wx.ALL, control_border)
        sizerPlane.Add(self.rbZ, 0, wx.ALL, control_border)
        sizerPlane.Add(self.rbOther, 0, wx.ALL, control_border)

        self.rbH.SetValue(axis_type == 1)
        self.rbV.SetValue(axis_type == 2)
        self.rbZ.SetValue(axis_type == 3)
        self.rbOther.SetValue(axis_type == 0)

        self.MakeOkAndCancel(wx.HORIZONTAL).AddToSizer(sizerMain)

        self.SetPicture()

        self.SetSizer(sizerMain)
        sizerMain.SetSizeHints(self)
        sizerMain.Fit(self)

        self.chkCopy.SetFocus()

        self.Bind(wx.EVT_RADIOBUTTON, self.OnRadioButton, self.rbH)
        self.Bind(wx.EVT_RADIOBUTTON, self.OnRadioButton, self.rbV)
        self.Bind(wx.EVT_RADIOBUTTON, self.OnRadioButton, self.rbZ)
        self.Bind(wx.EVT_RADIOBUTTON, self.OnRadioButton, self.rbOther)
        if self.btnPick: self.Bind(wx.EVT_BUTTON, self.OnPick, self.btnPick)
        if self.btnVectorPick:
            self.Bind(wx.EVT_BUTTON, self.OnPickVector, self.btnVectorPick)

        self.ignore_event_functions = False