def __init__(self, parent): super(previewPanel, self).__init__(parent,-1) self.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DDKSHADOW)) self.SetMinSize((440,320)) self.objectList = [] self.errorList = [] self.gcode = None self.objectsMinV = None self.objectsMaxV = None self.objectsBoundaryCircleSize = None self.loadThread = None self.machineSize = util3d.Vector3(profile.getPreferenceFloat('machine_width'), profile.getPreferenceFloat('machine_depth'), profile.getPreferenceFloat('machine_height')) self.machineCenter = util3d.Vector3(self.machineSize.x / 2, self.machineSize.y / 2, 0) self.glCanvas = PreviewGLCanvas(self) #Create the popup window self.warningPopup = wx.PopupWindow(self, flags=wx.BORDER_SIMPLE) self.warningPopup.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_INFOBK)) self.warningPopup.text = wx.StaticText(self.warningPopup, -1, 'Reset scale, rotation and mirror?') self.warningPopup.yesButton = wx.Button(self.warningPopup, -1, 'yes', style=wx.BU_EXACTFIT) self.warningPopup.noButton = wx.Button(self.warningPopup, -1, 'no', style=wx.BU_EXACTFIT) self.warningPopup.sizer = wx.BoxSizer(wx.HORIZONTAL) self.warningPopup.SetSizer(self.warningPopup.sizer) self.warningPopup.sizer.Add(self.warningPopup.text, 1, flag=wx.ALL|wx.ALIGN_CENTER_VERTICAL, border=1) self.warningPopup.sizer.Add(self.warningPopup.yesButton, 0, flag=wx.EXPAND|wx.ALL, border=1) self.warningPopup.sizer.Add(self.warningPopup.noButton, 0, flag=wx.EXPAND|wx.ALL, border=1) self.warningPopup.Fit() self.warningPopup.Layout() self.warningPopup.timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.OnHideWarning, self.warningPopup.timer) self.Bind(wx.EVT_BUTTON, self.OnWarningPopup, self.warningPopup.yesButton) self.Bind(wx.EVT_BUTTON, self.OnHideWarning, self.warningPopup.noButton) parent.Bind(wx.EVT_MOVE, self.OnMove) parent.Bind(wx.EVT_SIZE, self.OnMove) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.glCanvas, 1, flag=wx.EXPAND) self.SetSizer(sizer) self.checkReloadFileTimer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.OnCheckReloadFile, self.checkReloadFileTimer) self.checkReloadFileTimer.Start(1000) group = [] self.rotateToolButton = openglGui.glRadioButton(self.glCanvas, 1, 'Rotate', (0,-1), group, self.OnToolSelect) self.scaleToolButton = openglGui.glRadioButton(self.glCanvas, 2, 'Scale', (1,-1), group, self.OnToolSelect) self.mirrorToolButton = openglGui.glRadioButton(self.glCanvas, 12, 'Mirror', (2,-1), group, self.OnToolSelect) self.resetRotationButton = openglGui.glButton(self.glCanvas, 4, 'Reset rotation', (0,-2), self.OnRotateReset) self.layFlatButton = openglGui.glButton(self.glCanvas, 5, 'Lay flat', (0,-3), self.OnLayFlat) self.resetScaleButton = openglGui.glButton(self.glCanvas, 8, 'Scale reset', (1,-2), self.OnScaleReset) self.scaleMaxButton = openglGui.glButton(self.glCanvas, 9, 'Scale to machine size', (1,-3), self.OnScaleMax) self.mirrorXButton = openglGui.glButton(self.glCanvas, 12, 'Mirror X', (2,-2), lambda : self.OnMirror(0)) self.mirrorYButton = openglGui.glButton(self.glCanvas, 13, 'Mirror Y', (2,-3), lambda : self.OnMirror(1)) self.mirrorZButton = openglGui.glButton(self.glCanvas, 14, 'Mirror Z', (2,-4), lambda : self.OnMirror(2)) self.openFileButton = openglGui.glButton(self.glCanvas, 3, 'Load model', (0,0), lambda : self.GetParent().GetParent().GetParent()._showModelLoadDialog(1)) self.sliceButton = openglGui.glButton(self.glCanvas, 6, 'Prepare model', (1,0), lambda : self.GetParent().GetParent().GetParent().OnSlice(None)) self.printButton = openglGui.glButton(self.glCanvas, 7, 'Print model', (2,0), lambda : self.GetParent().GetParent().GetParent().OnPrint(None)) extruderCount = int(profile.getPreference('extruder_amount')) if extruderCount > 1: openglGui.glButton(self.glCanvas, 3, 'Load dual model', (0,1), lambda : self.GetParent().GetParent().GetParent()._showModelLoadDialog(2)) if extruderCount > 2: openglGui.glButton(self.glCanvas, 3, 'Load triple model', (0,2), lambda : self.GetParent().GetParent().GetParent()._showModelLoadDialog(3)) if extruderCount > 3: openglGui.glButton(self.glCanvas, 3, 'Load quad model', (0,3), lambda : self.GetParent().GetParent().GetParent()._showModelLoadDialog(4)) self.scaleForm = openglGui.glFrame(self.glCanvas, (2, -3)) openglGui.glGuiLayoutGrid(self.scaleForm) openglGui.glLabel(self.scaleForm, 'Scale X', (0,0)) self.scaleXctrl = openglGui.glNumberCtrl(self.scaleForm, '1.0', (1,0), lambda value: self.OnScaleEntry(value, 0)) openglGui.glLabel(self.scaleForm, 'Scale Y', (0,1)) self.scaleYctrl = openglGui.glNumberCtrl(self.scaleForm, '1.0', (1,1), lambda value: self.OnScaleEntry(value, 1)) openglGui.glLabel(self.scaleForm, 'Scale Z', (0,2)) self.scaleZctrl = openglGui.glNumberCtrl(self.scaleForm, '1.0', (1,2), lambda value: self.OnScaleEntry(value, 2)) openglGui.glLabel(self.scaleForm, 'Size X (mm)', (0,4)) self.scaleXmmctrl = openglGui.glNumberCtrl(self.scaleForm, '0.0', (1,4), lambda value: self.OnScaleEntryMM(value, 0)) openglGui.glLabel(self.scaleForm, 'Size Y (mm)', (0,5)) self.scaleYmmctrl = openglGui.glNumberCtrl(self.scaleForm, '0.0', (1,5), lambda value: self.OnScaleEntryMM(value, 1)) openglGui.glLabel(self.scaleForm, 'Size Z (mm)', (0,6)) self.scaleZmmctrl = openglGui.glNumberCtrl(self.scaleForm, '0.0', (1,6), lambda value: self.OnScaleEntryMM(value, 2)) openglGui.glLabel(self.scaleForm, 'Uniform scale', (0,8)) self.scaleUniform = openglGui.glCheckbox(self.scaleForm, True, (1,8), None) self.viewSelection = openglGui.glComboButton(self.glCanvas, 'View mode', [0,1,2,3,4], ['3D Model', 'Transparent', 'X-Ray', 'Overhang', 'Layers'], (-1,0), self.OnViewChange) self.layerSelect = openglGui.glSlider(self.glCanvas, 0, 0, 100, (-1,-2), self.OnLayerNrChange) self.OnViewChange() self.OnToolSelect() self.returnToModelViewAndUpdateModel() self.matrix = numpy.matrix(numpy.array(profile.getObjectMatrix(), numpy.float64).reshape((3,3,)))
def __init__(self, parent): super(SceneView, self).__init__(parent) self._yaw = 30 self._pitch = 60 self._zoom = 300 self._scene = objectScene.Scene() self._gcode = None self._gcodeVBOs = [] self._gcodeFilename = None self._gcodeLoadThread = None self._objectShader = None self._objectLoadShader = None self._focusObj = None self._selectedObj = None self._objColors = [None,None,None,None] self._mouseX = -1 self._mouseY = -1 self._mouseState = None self._viewTarget = numpy.array([0,0,0], numpy.float32) self._animView = None self._animZoom = None self._platformMesh = meshLoader.loadMeshes(resources.getPathForMesh('ultimaker_platform.stl'))[0] self._platformMesh._drawOffset = numpy.array([0,0,2.5], numpy.float32) self._isSimpleMode = True self._viewport = None self._modelMatrix = None self._projMatrix = None self.tempMatrix = None self.openFileButton = openglGui.glButton(self, 4, 'Load', (0,0), self.showLoadModel) self.printButton = openglGui.glButton(self, 6, 'Print', (1,0), self.OnPrintButton) self.printButton.setDisabled(True) group = [] self.rotateToolButton = openglGui.glRadioButton(self, 8, 'Rotate', (0,-1), group, self.OnToolSelect) self.scaleToolButton = openglGui.glRadioButton(self, 9, 'Scale', (1,-1), group, self.OnToolSelect) self.mirrorToolButton = openglGui.glRadioButton(self, 10, 'Mirror', (2,-1), group, self.OnToolSelect) self.resetRotationButton = openglGui.glButton(self, 12, 'Reset', (0,-2), self.OnRotateReset) self.layFlatButton = openglGui.glButton(self, 16, 'Lay flat', (0,-3), self.OnLayFlat) self.resetScaleButton = openglGui.glButton(self, 13, 'Reset', (1,-2), self.OnScaleReset) self.scaleMaxButton = openglGui.glButton(self, 17, 'To max', (1,-3), self.OnScaleMax) self.mirrorXButton = openglGui.glButton(self, 14, 'Mirror X', (2,-2), lambda button: self.OnMirror(0)) self.mirrorYButton = openglGui.glButton(self, 18, 'Mirror Y', (2,-3), lambda button: self.OnMirror(1)) self.mirrorZButton = openglGui.glButton(self, 22, 'Mirror Z', (2,-4), lambda button: self.OnMirror(2)) self.rotateToolButton.setExpandArrow(True) self.scaleToolButton.setExpandArrow(True) self.mirrorToolButton.setExpandArrow(True) self.scaleForm = openglGui.glFrame(self, (2, -2)) openglGui.glGuiLayoutGrid(self.scaleForm) openglGui.glLabel(self.scaleForm, 'Scale X', (0,0)) self.scaleXctrl = openglGui.glNumberCtrl(self.scaleForm, '1.0', (1,0), lambda value: self.OnScaleEntry(value, 0)) openglGui.glLabel(self.scaleForm, 'Scale Y', (0,1)) self.scaleYctrl = openglGui.glNumberCtrl(self.scaleForm, '1.0', (1,1), lambda value: self.OnScaleEntry(value, 1)) openglGui.glLabel(self.scaleForm, 'Scale Z', (0,2)) self.scaleZctrl = openglGui.glNumberCtrl(self.scaleForm, '1.0', (1,2), lambda value: self.OnScaleEntry(value, 2)) openglGui.glLabel(self.scaleForm, 'Size X (mm)', (0,4)) self.scaleXmmctrl = openglGui.glNumberCtrl(self.scaleForm, '0.0', (1,4), lambda value: self.OnScaleEntryMM(value, 0)) openglGui.glLabel(self.scaleForm, 'Size Y (mm)', (0,5)) self.scaleYmmctrl = openglGui.glNumberCtrl(self.scaleForm, '0.0', (1,5), lambda value: self.OnScaleEntryMM(value, 1)) openglGui.glLabel(self.scaleForm, 'Size Z (mm)', (0,6)) self.scaleZmmctrl = openglGui.glNumberCtrl(self.scaleForm, '0.0', (1,6), lambda value: self.OnScaleEntryMM(value, 2)) openglGui.glLabel(self.scaleForm, 'Uniform scale', (0,8)) self.scaleUniform = openglGui.glCheckbox(self.scaleForm, True, (1,8), None) self.viewSelection = openglGui.glComboButton(self, 'View mode', [7,19,11,15,23], ['Normal', 'Overhang', 'Transparent', 'X-Ray', 'Layers'], (-1,0), self.OnViewChange) self.layerSelect = openglGui.glSlider(self, 10000, 0, 1, (-1,-2), lambda : self.QueueRefresh()) self.notification = openglGui.glNotification(self, (0, 0)) self._slicer = sliceEngine.Slicer(self._updateSliceProgress) self._sceneUpdateTimer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self._onRunSlicer, self._sceneUpdateTimer) self.Bind(wx.EVT_MOUSEWHEEL, self.OnMouseWheel) self.Bind(wx.EVT_LEAVE_WINDOW, self.OnMouseLeave) self.OnViewChange() self.OnToolSelect(0) self.updateToolButtons() self.updateProfileToControls()
def __init__(self): super(projectPlanner, self).__init__(None, title='Cura - Project Planner') wx.EVT_CLOSE(self, self.OnClose) self.panel = wx.Panel(self, -1) self.SetSizer(wx.BoxSizer(wx.VERTICAL)) self.GetSizer().Add(self.panel, 1, flag=wx.EXPAND) self.SetDropTarget(dropTarget.FileDropTarget(self.OnDropFiles, meshLoader.supportedExtensions())) self.list = [] self.selection = None self.printMode = 0 self.alwaysAutoPlace = profile.getPreference('planner_always_autoplace') == 'True' self.machineSize = numpy.array([profile.getPreferenceFloat('machine_width'), profile.getPreferenceFloat('machine_depth'), profile.getPreferenceFloat('machine_height')]) self.headSizeMin = numpy.array([profile.getPreferenceFloat('extruder_head_size_min_x'), profile.getPreferenceFloat('extruder_head_size_min_y'),0]) self.headSizeMax = numpy.array([profile.getPreferenceFloat('extruder_head_size_max_x'), profile.getPreferenceFloat('extruder_head_size_max_y'),0]) self.extruderOffset = [ numpy.array([0,0,0]), numpy.array([profile.getPreferenceFloat('extruder_offset_x1'), profile.getPreferenceFloat('extruder_offset_y1'), 0]), numpy.array([profile.getPreferenceFloat('extruder_offset_x2'), profile.getPreferenceFloat('extruder_offset_y2'), 0]), numpy.array([profile.getPreferenceFloat('extruder_offset_x3'), profile.getPreferenceFloat('extruder_offset_y3'), 0])] self.toolbar = toolbarUtil.Toolbar(self.panel) toolbarUtil.NormalButton(self.toolbar, self.OnLoadProject, 'open.png', 'Open project') toolbarUtil.NormalButton(self.toolbar, self.OnSaveProject, 'save.png', 'Save project') self.toolbar.AddSeparator() group = [] toolbarUtil.RadioButton(self.toolbar, group, 'object-3d-on.png', 'object-3d-off.png', '3D view', callback=self.On3DClick).SetValue(self.alwaysAutoPlace) toolbarUtil.RadioButton(self.toolbar, group, 'object-top-on.png', 'object-top-off.png', 'Topdown view', callback=self.OnTopClick).SetValue(not self.alwaysAutoPlace) self.toolbar.AddSeparator() toolbarUtil.NormalButton(self.toolbar, self.OnPreferences, 'preferences.png', 'Project planner preferences') self.toolbar.AddSeparator() toolbarUtil.NormalButton(self.toolbar, self.OnCutMesh, 'cut-mesh.png', 'Cut a plate STL into multiple STL files, and add those files to the project.\nNote: Splitting up plates sometimes takes a few minutes.') toolbarUtil.NormalButton(self.toolbar, self.OnSaveCombinedSTL, 'save-combination.png', 'Save all the combined STL files into a single STL file as a plate.') self.toolbar.AddSeparator() group = [] self.printOneAtATime = toolbarUtil.RadioButton(self.toolbar, group, 'view-normal-on.png', 'view-normal-off.png', 'Print one object at a time', callback=self.OnPrintTypeChange) self.printAllAtOnce = toolbarUtil.RadioButton(self.toolbar, group, 'all-at-once-on.png', 'all-at-once-off.png', 'Print all the objects at once', callback=self.OnPrintTypeChange) self.toolbar.AddSeparator() toolbarUtil.NormalButton(self.toolbar, self.OnQuit, 'exit.png', 'Close project planner') self.toolbar.Realize() self.toolbar2 = toolbarUtil.Toolbar(self.panel) toolbarUtil.NormalButton(self.toolbar2, self.OnAddModel, 'object-add.png', 'Add model') toolbarUtil.NormalButton(self.toolbar2, self.OnRemModel, 'object-remove.png', 'Remove model') self.toolbar2.AddSeparator() toolbarUtil.NormalButton(self.toolbar2, self.OnMoveUp, 'move-up.png', 'Move model up in print list') toolbarUtil.NormalButton(self.toolbar2, self.OnMoveDown, 'move-down.png', 'Move model down in print list') toolbarUtil.NormalButton(self.toolbar2, self.OnCopy, 'copy.png', 'Make a copy of the current selected object') toolbarUtil.NormalButton(self.toolbar2, self.OnSetCustomProfile, 'set-profile.png', 'Set a custom profile to be used to prepare a specific object.') self.toolbar2.AddSeparator() if not self.alwaysAutoPlace: toolbarUtil.NormalButton(self.toolbar2, self.OnAutoPlace, 'autoplace.png', 'Automaticly organize the objects on the platform.') toolbarUtil.NormalButton(self.toolbar2, self.OnSlice, 'slice.png', 'Prepare to project into a gcode file.') self.toolbar2.Realize() sizer = wx.GridBagSizer(2,2) self.panel.SetSizer(sizer) self.glCanvas = PreviewGLCanvas(self.panel, self) self.listbox = wx.ListBox(self.panel, -1, choices=[]) self.addButton = wx.Button(self.panel, -1, "Add") self.remButton = wx.Button(self.panel, -1, "Remove") self.sliceButton = wx.Button(self.panel, -1, "Prepare") if not self.alwaysAutoPlace: self.autoPlaceButton = wx.Button(self.panel, -1, "Auto Place") sizer.Add(self.toolbar, (0,0), span=(1,1), flag=wx.EXPAND|wx.LEFT|wx.RIGHT) sizer.Add(self.toolbar2, (0,1), span=(1,2), flag=wx.EXPAND|wx.LEFT|wx.RIGHT) sizer.Add(self.glCanvas, (1,0), span=(5,1), flag=wx.EXPAND) sizer.Add(self.listbox, (1,1), span=(1,2), flag=wx.EXPAND) sizer.Add(self.addButton, (2,1), span=(1,1)) sizer.Add(self.remButton, (2,2), span=(1,1)) sizer.Add(self.sliceButton, (3,1), span=(1,1)) if not self.alwaysAutoPlace: sizer.Add(self.autoPlaceButton, (3,2), span=(1,1)) sizer.AddGrowableCol(0) sizer.AddGrowableRow(1) self.addButton.Bind(wx.EVT_BUTTON, self.OnAddModel) self.remButton.Bind(wx.EVT_BUTTON, self.OnRemModel) self.sliceButton.Bind(wx.EVT_BUTTON, self.OnSlice) if not self.alwaysAutoPlace: self.autoPlaceButton.Bind(wx.EVT_BUTTON, self.OnAutoPlace) self.listbox.Bind(wx.EVT_LISTBOX, self.OnListSelect) panel = wx.Panel(self.panel, -1) sizer.Add(panel, (5,1), span=(1,2)) sizer = wx.GridBagSizer(2,2) panel.SetSizer(sizer) group = [] self.rotateToolButton = openglGui.glRadioButton(self.glCanvas, 8, 'Rotate', (0,-1), group, self.OnToolSelect) self.scaleToolButton = openglGui.glRadioButton(self.glCanvas, 9, 'Scale', (1,-1), group, self.OnToolSelect) self.mirrorToolButton = openglGui.glRadioButton(self.glCanvas, 10, 'Mirror', (2,-1), group, self.OnToolSelect) self.resetRotationButton = openglGui.glButton(self.glCanvas, 12, 'Reset', (0,-2), self.OnRotateReset) self.layFlatButton = openglGui.glButton(self.glCanvas, 16, 'Lay flat', (0,-3), self.OnLayFlat) self.resetScaleButton = openglGui.glButton(self.glCanvas, 13, 'Reset', (1,-2), self.OnScaleReset) self.mirrorXButton = openglGui.glButton(self.glCanvas, 14, 'Mirror X', (2,-2), lambda : self.OnMirror(0)) self.mirrorYButton = openglGui.glButton(self.glCanvas, 18, 'Mirror Y', (2,-3), lambda : self.OnMirror(1)) self.mirrorZButton = openglGui.glButton(self.glCanvas, 22, 'Mirror Z', (2,-4), lambda : self.OnMirror(2)) self.scaleForm = openglGui.glFrame(self.glCanvas, (2, -2)) openglGui.glGuiLayoutGrid(self.scaleForm) openglGui.glLabel(self.scaleForm, 'Scale X', (0,0)) self.scaleXctrl = openglGui.glNumberCtrl(self.scaleForm, '1.0', (1,0), lambda value: self.OnScaleEntry(value, 0)) openglGui.glLabel(self.scaleForm, 'Scale Y', (0,1)) self.scaleYctrl = openglGui.glNumberCtrl(self.scaleForm, '1.0', (1,1), lambda value: self.OnScaleEntry(value, 1)) openglGui.glLabel(self.scaleForm, 'Scale Z', (0,2)) self.scaleZctrl = openglGui.glNumberCtrl(self.scaleForm, '1.0', (1,2), lambda value: self.OnScaleEntry(value, 2)) openglGui.glLabel(self.scaleForm, 'Size X (mm)', (0,4)) self.scaleXmmctrl = openglGui.glNumberCtrl(self.scaleForm, '0.0', (1,4), lambda value: self.OnScaleEntryMM(value, 0)) openglGui.glLabel(self.scaleForm, 'Size Y (mm)', (0,5)) self.scaleYmmctrl = openglGui.glNumberCtrl(self.scaleForm, '0.0', (1,5), lambda value: self.OnScaleEntryMM(value, 1)) openglGui.glLabel(self.scaleForm, 'Size Z (mm)', (0,6)) self.scaleZmmctrl = openglGui.glNumberCtrl(self.scaleForm, '0.0', (1,6), lambda value: self.OnScaleEntryMM(value, 2)) openglGui.glLabel(self.scaleForm, 'Uniform scale', (0,8)) self.scaleUniform = openglGui.glCheckbox(self.scaleForm, True, (1,8), None) self.SetSize((800,600)) self.OnToolSelect()
def __init__(self, parent): super(previewPanel, self).__init__(parent, -1) self.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DDKSHADOW)) self.SetMinSize((440, 320)) self.objectList = [] self.errorList = [] self.gcode = None self.objectsMinV = None self.objectsMaxV = None self.objectsBoundaryCircleSize = None self.loadThread = None self.machineSize = util3d.Vector3( profile.getPreferenceFloat("machine_width"), profile.getPreferenceFloat("machine_depth"), profile.getPreferenceFloat("machine_height"), ) self.machineCenter = util3d.Vector3(self.machineSize.x / 2, self.machineSize.y / 2, 0) self.glCanvas = PreviewGLCanvas(self) # Create the popup window self.warningPopup = wx.PopupWindow(self, flags=wx.BORDER_SIMPLE) self.warningPopup.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_INFOBK)) self.warningPopup.text = wx.StaticText(self.warningPopup, -1, "Reset scale, rotation and mirror?") self.warningPopup.yesButton = wx.Button(self.warningPopup, -1, "yes", style=wx.BU_EXACTFIT) self.warningPopup.noButton = wx.Button(self.warningPopup, -1, "no", style=wx.BU_EXACTFIT) self.warningPopup.sizer = wx.BoxSizer(wx.HORIZONTAL) self.warningPopup.SetSizer(self.warningPopup.sizer) self.warningPopup.sizer.Add(self.warningPopup.text, 1, flag=wx.ALL | wx.ALIGN_CENTER_VERTICAL, border=1) self.warningPopup.sizer.Add(self.warningPopup.yesButton, 0, flag=wx.EXPAND | wx.ALL, border=1) self.warningPopup.sizer.Add(self.warningPopup.noButton, 0, flag=wx.EXPAND | wx.ALL, border=1) self.warningPopup.Fit() self.warningPopup.Layout() self.warningPopup.timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.OnHideWarning, self.warningPopup.timer) self.Bind(wx.EVT_BUTTON, self.OnWarningPopup, self.warningPopup.yesButton) self.Bind(wx.EVT_BUTTON, self.OnHideWarning, self.warningPopup.noButton) parent.Bind(wx.EVT_MOVE, self.OnMove) parent.Bind(wx.EVT_SIZE, self.OnMove) self.toolbar = toolbarUtil.Toolbar(self) group = [] toolbarUtil.RadioButton( self.toolbar, group, "object-3d-on.png", "object-3d-off.png", "3D view", callback=self.On3DClick ) toolbarUtil.RadioButton( self.toolbar, group, "object-top-on.png", "object-top-off.png", "Topdown view", callback=self.OnTopClick ) self.toolbar.AddSeparator() self.showBorderButton = toolbarUtil.ToggleButton( self.toolbar, "", "view-border-on.png", "view-border-off.png", "Show model borders", callback=self.OnViewChange, ) self.showSteepOverhang = toolbarUtil.ToggleButton( self.toolbar, "", "steepOverhang-on.png", "steepOverhang-off.png", "Show steep overhang", callback=self.OnViewChange, ) self.toolbar.AddSeparator() group = [] self.normalViewButton = toolbarUtil.RadioButton( self.toolbar, group, "view-normal-on.png", "view-normal-off.png", "Normal model view", callback=self.OnViewChange, ) self.transparentViewButton = toolbarUtil.RadioButton( self.toolbar, group, "view-transparent-on.png", "view-transparent-off.png", "Transparent model view", callback=self.OnViewChange, ) self.xrayViewButton = toolbarUtil.RadioButton( self.toolbar, group, "view-xray-on.png", "view-xray-off.png", "X-Ray view", callback=self.OnViewChange ) self.gcodeViewButton = toolbarUtil.RadioButton( self.toolbar, group, "view-gcode-on.png", "view-gcode-off.png", "GCode view", callback=self.OnViewChange ) self.mixedViewButton = toolbarUtil.RadioButton( self.toolbar, group, "view-mixed-on.png", "view-mixed-off.png", "Mixed model/GCode view", callback=self.OnViewChange, ) self.toolbar.AddSeparator() self.layerSpin = wx.SpinCtrl(self.toolbar, -1, "", size=(21 * 4, 21), style=wx.SP_ARROW_KEYS) self.toolbar.AddControl(self.layerSpin) self.Bind(wx.EVT_SPINCTRL, self.OnLayerNrChange, self.layerSpin) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.toolbar, 0, flag=wx.EXPAND | wx.TOP | wx.LEFT | wx.RIGHT, border=1) sizer.Add(self.glCanvas, 1, flag=wx.EXPAND) self.SetSizer(sizer) self.checkReloadFileTimer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.OnCheckReloadFile, self.checkReloadFileTimer) self.checkReloadFileTimer.Start(1000) group = [] self.rotateToolButton = openglGui.glRadioButton(self.glCanvas, 1, "Rotate", (0, 1), group, self.OnToolSelect) self.scaleToolButton = openglGui.glRadioButton(self.glCanvas, 2, "Scale", (0, 2), group, self.OnToolSelect) self.mirrorToolButton = openglGui.glRadioButton(self.glCanvas, 12, "Mirror", (0, 3), group, self.OnToolSelect) self.resetRotationButton = openglGui.glButton(self.glCanvas, 4, "Reset rotation", (1, 1), self.OnRotateReset) self.layFlatButton = openglGui.glButton(self.glCanvas, 5, "Lay flat", (1, 2), self.OnLayFlat) self.resetScaleButton = openglGui.glButton(self.glCanvas, 8, "Scale reset", (1, 1), self.OnScaleReset) self.scaleMaxButton = openglGui.glButton(self.glCanvas, 9, "Scale to machine size", (1, 2), self.OnScaleMax) self.mirrorXButton = openglGui.glButton(self.glCanvas, 12, "Mirror X", (1, 1), lambda: self.OnMirror(0)) self.mirrorYButton = openglGui.glButton(self.glCanvas, 13, "Mirror Y", (1, 2), lambda: self.OnMirror(1)) self.mirrorZButton = openglGui.glButton(self.glCanvas, 14, "Mirror Z", (1, 3), lambda: self.OnMirror(2)) self.openFileButton = openglGui.glButton( self.glCanvas, 3, "Load model", (0, 0), lambda: self.GetParent().GetParent().GetParent()._showModelLoadDialog(1), ) self.sliceButton = openglGui.glButton( self.glCanvas, 6, "Prepare model", (0, -2), lambda: self.GetParent().GetParent().GetParent().OnSlice(None) ) self.printButton = openglGui.glButton( self.glCanvas, 7, "Print model", (0, -1), lambda: self.GetParent().GetParent().GetParent().OnPrint(None) ) extruderCount = int(profile.getPreference("extruder_amount")) if extruderCount > 1: openglGui.glButton( self.glCanvas, 3, "Load dual model", (1, 0), lambda: self.GetParent().GetParent().GetParent()._showModelLoadDialog(2), ) if extruderCount > 2: openglGui.glButton( self.glCanvas, 3, "Load triple model", (2, 0), lambda: self.GetParent().GetParent().GetParent()._showModelLoadDialog(3), ) if extruderCount > 3: openglGui.glButton( self.glCanvas, 3, "Load quad model", (3, 0), lambda: self.GetParent().GetParent().GetParent()._showModelLoadDialog(4), ) self.scaleForm = openglGui.glFrame(self.glCanvas, (1, 3)) openglGui.glGuiLayoutGrid(self.scaleForm) openglGui.glLabel(self.scaleForm, "Scale X", (0, 0)) self.scaleXctrl = openglGui.glNumberCtrl( self.scaleForm, "1.0", (1, 0), lambda value: self.OnScaleEntry(value, 0) ) openglGui.glLabel(self.scaleForm, "Scale Y", (0, 1)) self.scaleYctrl = openglGui.glNumberCtrl( self.scaleForm, "1.0", (1, 1), lambda value: self.OnScaleEntry(value, 1) ) openglGui.glLabel(self.scaleForm, "Scale Z", (0, 2)) self.scaleZctrl = openglGui.glNumberCtrl( self.scaleForm, "1.0", (1, 2), lambda value: self.OnScaleEntry(value, 2) ) openglGui.glLabel(self.scaleForm, "Size X (mm)", (0, 4)) self.scaleXmmctrl = openglGui.glNumberCtrl( self.scaleForm, "0.0", (1, 4), lambda value: self.OnScaleEntryMM(value, 0) ) openglGui.glLabel(self.scaleForm, "Size Y (mm)", (0, 5)) self.scaleYmmctrl = openglGui.glNumberCtrl( self.scaleForm, "0.0", (1, 5), lambda value: self.OnScaleEntryMM(value, 1) ) openglGui.glLabel(self.scaleForm, "Size Z (mm)", (0, 6)) self.scaleZmmctrl = openglGui.glNumberCtrl( self.scaleForm, "0.0", (1, 6), lambda value: self.OnScaleEntryMM(value, 2) ) openglGui.glLabel(self.scaleForm, "Uniform scale", (0, 8)) self.scaleUniform = openglGui.glCheckbox(self.scaleForm, True, (1, 8), None) self.OnViewChange() self.OnToolSelect() self.returnToModelViewAndUpdateModel() self.matrix = numpy.matrix(numpy.array(profile.getObjectMatrix(), numpy.float64).reshape((3, 3)))
def __init__(self, parent): super(previewPanel, self).__init__(parent, -1) self.SetBackgroundColour( wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DDKSHADOW)) self.SetMinSize((440, 320)) self.objectList = [] self.errorList = [] self.gcode = None self.objectsMinV = None self.objectsMaxV = None self.objectsBoundaryCircleSize = None self.loadThread = None self.machineSize = util3d.Vector3( profile.getPreferenceFloat('machine_width'), profile.getPreferenceFloat('machine_depth'), profile.getPreferenceFloat('machine_height')) self.machineCenter = util3d.Vector3(self.machineSize.x / 2, self.machineSize.y / 2, 0) self.glCanvas = PreviewGLCanvas(self) #Create the popup window self.warningPopup = wx.PopupWindow(self, flags=wx.BORDER_SIMPLE) self.warningPopup.SetBackgroundColour( wx.SystemSettings.GetColour(wx.SYS_COLOUR_INFOBK)) self.warningPopup.text = wx.StaticText( self.warningPopup, -1, 'Reset scale, rotation and mirror?') self.warningPopup.yesButton = wx.Button(self.warningPopup, -1, 'yes', style=wx.BU_EXACTFIT) self.warningPopup.noButton = wx.Button(self.warningPopup, -1, 'no', style=wx.BU_EXACTFIT) self.warningPopup.sizer = wx.BoxSizer(wx.HORIZONTAL) self.warningPopup.SetSizer(self.warningPopup.sizer) self.warningPopup.sizer.Add(self.warningPopup.text, 1, flag=wx.ALL | wx.ALIGN_CENTER_VERTICAL, border=1) self.warningPopup.sizer.Add(self.warningPopup.yesButton, 0, flag=wx.EXPAND | wx.ALL, border=1) self.warningPopup.sizer.Add(self.warningPopup.noButton, 0, flag=wx.EXPAND | wx.ALL, border=1) self.warningPopup.Fit() self.warningPopup.Layout() self.warningPopup.timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.OnHideWarning, self.warningPopup.timer) self.Bind(wx.EVT_BUTTON, self.OnWarningPopup, self.warningPopup.yesButton) self.Bind(wx.EVT_BUTTON, self.OnHideWarning, self.warningPopup.noButton) parent.Bind(wx.EVT_MOVE, self.OnMove) parent.Bind(wx.EVT_SIZE, self.OnMove) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.glCanvas, 1, flag=wx.EXPAND) self.SetSizer(sizer) self.checkReloadFileTimer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.OnCheckReloadFile, self.checkReloadFileTimer) self.checkReloadFileTimer.Start(1000) group = [] self.rotateToolButton = openglGui.glRadioButton( self.glCanvas, 8, 'Rotate', (0, -1), group, self.OnToolSelect) self.scaleToolButton = openglGui.glRadioButton(self.glCanvas, 9, 'Scale', (1, -1), group, self.OnToolSelect) self.mirrorToolButton = openglGui.glRadioButton( self.glCanvas, 10, 'Mirror', (2, -1), group, self.OnToolSelect) self.resetRotationButton = openglGui.glButton(self.glCanvas, 12, 'Reset', (0, -2), self.OnRotateReset) self.layFlatButton = openglGui.glButton(self.glCanvas, 16, 'Lay flat', (0, -3), self.OnLayFlat) self.resetScaleButton = openglGui.glButton(self.glCanvas, 13, 'Reset', (1, -2), self.OnScaleReset) self.scaleMaxButton = openglGui.glButton(self.glCanvas, 17, 'To max', (1, -3), self.OnScaleMax) self.mirrorXButton = openglGui.glButton(self.glCanvas, 14, 'Mirror X', (2, -2), lambda: self.OnMirror(0)) self.mirrorYButton = openglGui.glButton(self.glCanvas, 18, 'Mirror Y', (2, -3), lambda: self.OnMirror(1)) self.mirrorZButton = openglGui.glButton(self.glCanvas, 22, 'Mirror Z', (2, -4), lambda: self.OnMirror(2)) self.openFileButton = openglGui.glButton( self.glCanvas, 4, 'Load', (0, 0), lambda: self.GetParent().GetParent().GetParent( )._showModelLoadDialog(1)) self.sliceButton = openglGui.glButton( self.glCanvas, 5, 'Prepare', (1, 0), lambda: self.GetParent().GetParent().GetParent().OnSlice(None)) self.printButton = openglGui.glButton( self.glCanvas, 6, 'Print', (2, 0), lambda: self.GetParent().GetParent().GetParent().OnPrint(None)) self.rotateToolButton.setExpandArrow(True) self.scaleToolButton.setExpandArrow(True) self.mirrorToolButton.setExpandArrow(True) extruderCount = int(profile.getPreference('extruder_amount')) if extruderCount > 1: openglGui.glButton( self.glCanvas, 4, 'Load dual', (0, 1), lambda: self.GetParent( ).GetParent().GetParent()._showModelLoadDialog(2)) if extruderCount > 2: openglGui.glButton( self.glCanvas, 4, 'Load triple', (0, 2), lambda: self. GetParent().GetParent().GetParent()._showModelLoadDialog(3)) if extruderCount > 3: openglGui.glButton( self.glCanvas, 4, 'Load quad', (0, 3), lambda: self.GetParent( ).GetParent().GetParent()._showModelLoadDialog(4)) self.scaleForm = openglGui.glFrame(self.glCanvas, (2, -2)) openglGui.glGuiLayoutGrid(self.scaleForm) openglGui.glLabel(self.scaleForm, 'Scale X', (0, 0)) self.scaleXctrl = openglGui.glNumberCtrl( self.scaleForm, '1.0', (1, 0), lambda value: self.OnScaleEntry(value, 0)) openglGui.glLabel(self.scaleForm, 'Scale Y', (0, 1)) self.scaleYctrl = openglGui.glNumberCtrl( self.scaleForm, '1.0', (1, 1), lambda value: self.OnScaleEntry(value, 1)) openglGui.glLabel(self.scaleForm, 'Scale Z', (0, 2)) self.scaleZctrl = openglGui.glNumberCtrl( self.scaleForm, '1.0', (1, 2), lambda value: self.OnScaleEntry(value, 2)) openglGui.glLabel(self.scaleForm, 'Size X (mm)', (0, 4)) self.scaleXmmctrl = openglGui.glNumberCtrl( self.scaleForm, '0.0', (1, 4), lambda value: self.OnScaleEntryMM(value, 0)) openglGui.glLabel(self.scaleForm, 'Size Y (mm)', (0, 5)) self.scaleYmmctrl = openglGui.glNumberCtrl( self.scaleForm, '0.0', (1, 5), lambda value: self.OnScaleEntryMM(value, 1)) openglGui.glLabel(self.scaleForm, 'Size Z (mm)', (0, 6)) self.scaleZmmctrl = openglGui.glNumberCtrl( self.scaleForm, '0.0', (1, 6), lambda value: self.OnScaleEntryMM(value, 2)) openglGui.glLabel(self.scaleForm, 'Uniform scale', (0, 8)) self.scaleUniform = openglGui.glCheckbox(self.scaleForm, True, (1, 8), None) self.viewSelection = openglGui.glComboButton( self.glCanvas, 'View mode', [7, 11, 15, 19, 23], ['Normal', 'Transparent', 'X-Ray', 'Overhang', 'Layers'], (-1, 0), self.OnViewChange) self.layerSelect = openglGui.glSlider(self.glCanvas, 0, 0, 100, (-1, -2), lambda: self.Refresh()) self.OnViewChange() self.OnToolSelect() self.updateModelTransform() self.matrix = numpy.matrix( numpy.array(profile.getObjectMatrix(), numpy.float64).reshape(( 3, 3, )))
def __init__(self, parent): super(previewPanel, self).__init__(parent, -1) self.SetBackgroundColour( wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DDKSHADOW)) self.SetMinSize((440, 320)) self.objectList = [] self.errorList = [] self.gcode = None self.objectsMinV = None self.objectsMaxV = None self.objectsBoundaryCircleSize = None self.loadThread = None self.machineSize = util3d.Vector3( profile.getPreferenceFloat('machine_width'), profile.getPreferenceFloat('machine_depth'), profile.getPreferenceFloat('machine_height')) self.machineCenter = util3d.Vector3(self.machineSize.x / 2, self.machineSize.y / 2, 0) self.glCanvas = PreviewGLCanvas(self) #Create the popup window self.warningPopup = wx.PopupWindow(self, flags=wx.BORDER_SIMPLE) self.warningPopup.SetBackgroundColour( wx.SystemSettings.GetColour(wx.SYS_COLOUR_INFOBK)) self.warningPopup.text = wx.StaticText( self.warningPopup, -1, 'Reset scale, rotation and mirror?') self.warningPopup.yesButton = wx.Button(self.warningPopup, -1, 'yes', style=wx.BU_EXACTFIT) self.warningPopup.noButton = wx.Button(self.warningPopup, -1, 'no', style=wx.BU_EXACTFIT) self.warningPopup.sizer = wx.BoxSizer(wx.HORIZONTAL) self.warningPopup.SetSizer(self.warningPopup.sizer) self.warningPopup.sizer.Add(self.warningPopup.text, 1, flag=wx.ALL | wx.ALIGN_CENTER_VERTICAL, border=1) self.warningPopup.sizer.Add(self.warningPopup.yesButton, 0, flag=wx.EXPAND | wx.ALL, border=1) self.warningPopup.sizer.Add(self.warningPopup.noButton, 0, flag=wx.EXPAND | wx.ALL, border=1) self.warningPopup.Fit() self.warningPopup.Layout() self.warningPopup.timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.OnHideWarning, self.warningPopup.timer) self.Bind(wx.EVT_BUTTON, self.OnWarningPopup, self.warningPopup.yesButton) self.Bind(wx.EVT_BUTTON, self.OnHideWarning, self.warningPopup.noButton) parent.Bind(wx.EVT_MOVE, self.OnMove) parent.Bind(wx.EVT_SIZE, self.OnMove) self.toolbar = toolbarUtil.Toolbar(self) group = [] toolbarUtil.RadioButton(self.toolbar, group, 'object-3d-on.png', 'object-3d-off.png', '3D view', callback=self.On3DClick) toolbarUtil.RadioButton(self.toolbar, group, 'object-top-on.png', 'object-top-off.png', 'Topdown view', callback=self.OnTopClick) self.toolbar.AddSeparator() self.showBorderButton = toolbarUtil.ToggleButton( self.toolbar, '', 'view-border-on.png', 'view-border-off.png', 'Show model borders', callback=self.OnViewChange) self.showSteepOverhang = toolbarUtil.ToggleButton( self.toolbar, '', 'steepOverhang-on.png', 'steepOverhang-off.png', 'Show steep overhang', callback=self.OnViewChange) self.toolbar.AddSeparator() group = [] self.normalViewButton = toolbarUtil.RadioButton( self.toolbar, group, 'view-normal-on.png', 'view-normal-off.png', 'Normal model view', callback=self.OnViewChange) self.transparentViewButton = toolbarUtil.RadioButton( self.toolbar, group, 'view-transparent-on.png', 'view-transparent-off.png', 'Transparent model view', callback=self.OnViewChange) self.xrayViewButton = toolbarUtil.RadioButton( self.toolbar, group, 'view-xray-on.png', 'view-xray-off.png', 'X-Ray view', callback=self.OnViewChange) self.gcodeViewButton = toolbarUtil.RadioButton( self.toolbar, group, 'view-gcode-on.png', 'view-gcode-off.png', 'GCode view', callback=self.OnViewChange) self.mixedViewButton = toolbarUtil.RadioButton( self.toolbar, group, 'view-mixed-on.png', 'view-mixed-off.png', 'Mixed model/GCode view', callback=self.OnViewChange) self.toolbar.AddSeparator() self.layerSpin = wx.SpinCtrl(self.toolbar, -1, '', size=(21 * 4, 21), style=wx.SP_ARROW_KEYS) self.toolbar.AddControl(self.layerSpin) self.Bind(wx.EVT_SPINCTRL, self.OnLayerNrChange, self.layerSpin) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.toolbar, 0, flag=wx.EXPAND | wx.TOP | wx.LEFT | wx.RIGHT, border=1) sizer.Add(self.glCanvas, 1, flag=wx.EXPAND) self.SetSizer(sizer) self.checkReloadFileTimer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.OnCheckReloadFile, self.checkReloadFileTimer) self.checkReloadFileTimer.Start(1000) group = [] self.rotateToolButton = openglGui.glRadioButton( self.glCanvas, 1, 'Rotate', (0, 1), group, self.OnToolSelect) self.scaleToolButton = openglGui.glRadioButton(self.glCanvas, 2, 'Scale', (0, 2), group, self.OnToolSelect) self.mirrorToolButton = openglGui.glRadioButton( self.glCanvas, 12, 'Mirror', (0, 3), group, self.OnToolSelect) self.resetRotationButton = openglGui.glButton(self.glCanvas, 4, 'Reset rotation', (1, 1), self.OnRotateReset) self.layFlatButton = openglGui.glButton(self.glCanvas, 5, 'Lay flat', (1, 2), self.OnLayFlat) self.resetScaleButton = openglGui.glButton(self.glCanvas, 8, 'Scale reset', (1, 1), self.OnScaleReset) self.scaleMaxButton = openglGui.glButton(self.glCanvas, 9, 'Scale to machine size', (1, 2), self.OnScaleMax) self.mirrorXButton = openglGui.glButton(self.glCanvas, 12, 'Mirror X', (1, 1), lambda: self.OnMirror(0)) self.mirrorYButton = openglGui.glButton(self.glCanvas, 13, 'Mirror Y', (1, 2), lambda: self.OnMirror(1)) self.mirrorZButton = openglGui.glButton(self.glCanvas, 14, 'Mirror Z', (1, 3), lambda: self.OnMirror(2)) self.openFileButton = openglGui.glButton( self.glCanvas, 3, 'Load model', (0, 0), lambda: self.GetParent(). GetParent().GetParent()._showModelLoadDialog(1)) self.sliceButton = openglGui.glButton( self.glCanvas, 6, 'Prepare model', (0, -2), lambda: self.GetParent().GetParent().GetParent().OnSlice(None)) self.printButton = openglGui.glButton( self.glCanvas, 7, 'Print model', (0, -1), lambda: self.GetParent().GetParent().GetParent().OnPrint(None)) extruderCount = int(profile.getPreference('extruder_amount')) if extruderCount > 1: openglGui.glButton( self.glCanvas, 3, 'Load dual model', (1, 0), lambda: self.GetParent().GetParent( ).GetParent()._showModelLoadDialog(2)) if extruderCount > 2: openglGui.glButton( self.glCanvas, 3, 'Load triple model', (2, 0), lambda: self. GetParent().GetParent().GetParent()._showModelLoadDialog(3)) if extruderCount > 3: openglGui.glButton( self.glCanvas, 3, 'Load quad model', (3, 0), lambda: self.GetParent().GetParent( ).GetParent()._showModelLoadDialog(4)) self.scaleForm = openglGui.glFrame(self.glCanvas, (1, 3)) openglGui.glGuiLayoutGrid(self.scaleForm) openglGui.glLabel(self.scaleForm, 'Scale X', (0, 0)) self.scaleXctrl = openglGui.glNumberCtrl( self.scaleForm, '1.0', (1, 0), lambda value: self.OnScaleEntry(value, 0)) openglGui.glLabel(self.scaleForm, 'Scale Y', (0, 1)) self.scaleYctrl = openglGui.glNumberCtrl( self.scaleForm, '1.0', (1, 1), lambda value: self.OnScaleEntry(value, 1)) openglGui.glLabel(self.scaleForm, 'Scale Z', (0, 2)) self.scaleZctrl = openglGui.glNumberCtrl( self.scaleForm, '1.0', (1, 2), lambda value: self.OnScaleEntry(value, 2)) openglGui.glLabel(self.scaleForm, 'Size X (mm)', (0, 4)) self.scaleXmmctrl = openglGui.glNumberCtrl( self.scaleForm, '0.0', (1, 4), lambda value: self.OnScaleEntryMM(value, 0)) openglGui.glLabel(self.scaleForm, 'Size Y (mm)', (0, 5)) self.scaleYmmctrl = openglGui.glNumberCtrl( self.scaleForm, '0.0', (1, 5), lambda value: self.OnScaleEntryMM(value, 1)) openglGui.glLabel(self.scaleForm, 'Size Z (mm)', (0, 6)) self.scaleZmmctrl = openglGui.glNumberCtrl( self.scaleForm, '0.0', (1, 6), lambda value: self.OnScaleEntryMM(value, 2)) openglGui.glLabel(self.scaleForm, 'Uniform scale', (0, 8)) self.scaleUniform = openglGui.glCheckbox(self.scaleForm, True, (1, 8), None) self.OnViewChange() self.OnToolSelect() self.returnToModelViewAndUpdateModel() self.matrix = numpy.matrix( numpy.array(profile.getObjectMatrix(), numpy.float64).reshape(( 3, 3, )))