Пример #1
0
    def __init__(self):
        super(flatSlicerWindow,
              self).__init__(None, title='Cura - ' + version.getVersion())

        self.machineSize = util3d.Vector3(
            profile.getPreferenceFloat('machine_width'),
            profile.getPreferenceFloat('machine_depth'),
            profile.getPreferenceFloat('machine_height'))
        self.filename = None
        self.svg = None

        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.SetIcon(icon.getMainIcon())

        self.toolbar = toolbarUtil.Toolbar(self.panel)

        toolbarUtil.NormalButton(self.toolbar, self.OnOpenSVG, 'open.png',
                                 'Open SVG')
        self.toolbar.AddSeparator()
        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).SetValue(True)
        self.toolbar.AddSeparator()
        toolbarUtil.NormalButton(self.toolbar, self.OnQuit, 'exit.png',
                                 'Close project planner')

        self.toolbar.Realize()

        sizer = wx.GridBagSizer(2, 2)
        self.panel.SetSizer(sizer)
        self.preview = PreviewGLCanvas(self.panel, self)

        sizer.Add(self.toolbar, (0, 0),
                  span=(1, 1),
                  flag=wx.EXPAND | wx.LEFT | wx.RIGHT)
        sizer.Add(self.preview, (1, 0), span=(5, 1), flag=wx.EXPAND)

        sizer.AddGrowableCol(0)
        sizer.AddGrowableRow(1)

        self.SetSize((600, 400))
Пример #2
0
    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.loadThread = None
        self.machineSize = util3d.Vector3(
            profile.getPreferenceFloat('machine_width'),
            profile.getPreferenceFloat('machine_depth'),
            profile.getPreferenceFloat('machine_height'))
        self.machineCenter = util3d.Vector3(
            float(profile.getProfileSetting('machine_center_x')),
            float(profile.getProfileSetting('machine_center_y')), 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.OnResetAll, 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.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)

        self.toolbar2 = toolbarUtil.Toolbar(self)

        # Mirror
        self.mirrorX = toolbarUtil.ToggleButton(
            self.toolbar2,
            'flip_x',
            'object-mirror-x-on.png',
            'object-mirror-x-off.png',
            'Mirror X',
            callback=self.updateModelTransform)
        self.mirrorY = toolbarUtil.ToggleButton(
            self.toolbar2,
            'flip_y',
            'object-mirror-y-on.png',
            'object-mirror-y-off.png',
            'Mirror Y',
            callback=self.updateModelTransform)
        self.mirrorZ = toolbarUtil.ToggleButton(
            self.toolbar2,
            'flip_z',
            'object-mirror-z-on.png',
            'object-mirror-z-off.png',
            'Mirror Z',
            callback=self.updateModelTransform)
        self.toolbar2.AddSeparator()

        # Swap
        self.swapXZ = toolbarUtil.ToggleButton(
            self.toolbar2,
            'swap_xz',
            'object-swap-xz-on.png',
            'object-swap-xz-off.png',
            'Swap XZ',
            callback=self.updateModelTransform)
        self.swapYZ = toolbarUtil.ToggleButton(
            self.toolbar2,
            'swap_yz',
            'object-swap-yz-on.png',
            'object-swap-yz-off.png',
            'Swap YZ',
            callback=self.updateModelTransform)
        self.toolbar2.AddSeparator()

        # Scale
        self.scaleReset = toolbarUtil.NormalButton(self.toolbar2,
                                                   self.OnScaleReset,
                                                   'object-scale.png',
                                                   'Reset model scale')
        self.scale = wx.TextCtrl(self.toolbar2,
                                 -1,
                                 profile.getProfileSetting('model_scale'),
                                 size=(21 * 2, 21))
        self.toolbar2.AddControl(self.scale)
        self.scale.Bind(wx.EVT_TEXT, self.OnScale)
        self.scaleMax = toolbarUtil.NormalButton(
            self.toolbar2, self.OnScaleMax, 'object-max-size.png',
            'Scale object to fit machine size')

        self.toolbar2.AddSeparator()

        # Multiply
        #self.mulXadd = toolbarUtil.NormalButton(self.toolbar2, self.OnMulXAddClick, 'object-mul-x-add.png', 'Increase number of models on X axis')
        #self.mulXsub = toolbarUtil.NormalButton(self.toolbar2, self.OnMulXSubClick, 'object-mul-x-sub.png', 'Decrease number of models on X axis')
        #self.mulYadd = toolbarUtil.NormalButton(self.toolbar2, self.OnMulYAddClick, 'object-mul-y-add.png', 'Increase number of models on Y axis')
        #self.mulYsub = toolbarUtil.NormalButton(self.toolbar2, self.OnMulYSubClick, 'object-mul-y-sub.png', 'Decrease number of models on Y axis')
        #self.toolbar2.AddSeparator()

        # Rotate
        self.rotateReset = toolbarUtil.NormalButton(self.toolbar2,
                                                    self.OnRotateReset,
                                                    'object-rotate.png',
                                                    'Reset model rotation')
        self.rotate = wx.SpinCtrl(
            self.toolbar2,
            -1,
            profile.getProfileSetting('model_rotate_base'),
            size=(21 * 3, 21),
            style=wx.SP_WRAP | wx.SP_ARROW_KEYS)
        self.rotate.SetRange(0, 360)
        self.rotate.Bind(wx.EVT_TEXT, self.OnRotate)
        self.toolbar2.AddControl(self.rotate)

        self.toolbar2.Realize()
        self.OnViewChange()

        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)
        sizer.Add(self.toolbar2,
                  0,
                  flag=wx.EXPAND | wx.BOTTOM | wx.LEFT | wx.RIGHT,
                  border=1)
        self.SetSizer(sizer)
Пример #3
0
	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.SetIcon(icon.getMainIcon())
		
		self.SetDropTarget(dropTarget.FileDropTarget(self.OnDropFiles, meshLoader.supportedExtensions()))
		
		self.list = []
		self.selection = None
		self.printMode = 0
		self.alwaysAutoPlace = 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()

		self.toolbar3 = toolbarUtil.Toolbar(self.panel)
		self.mirrorX = toolbarUtil.ToggleButton(self.toolbar3, 'flip_x', 'object-mirror-x-on.png', 'object-mirror-x-off.png', 'Mirror X', callback=self.OnMirrorChange)
		self.mirrorY = toolbarUtil.ToggleButton(self.toolbar3, 'flip_y', 'object-mirror-y-on.png', 'object-mirror-y-off.png', 'Mirror Y', callback=self.OnMirrorChange)
		self.mirrorZ = toolbarUtil.ToggleButton(self.toolbar3, 'flip_z', 'object-mirror-z-on.png', 'object-mirror-z-off.png', 'Mirror Z', callback=self.OnMirrorChange)
		self.toolbar3.AddSeparator()

		# Swap
		self.swapXZ = toolbarUtil.ToggleButton(self.toolbar3, 'swap_xz', 'object-swap-xz-on.png', 'object-swap-xz-off.png', 'Swap XZ', callback=self.OnMirrorChange)
		self.swapYZ = toolbarUtil.ToggleButton(self.toolbar3, 'swap_yz', 'object-swap-yz-on.png', 'object-swap-yz-off.png', 'Swap YZ', callback=self.OnMirrorChange)
		self.toolbar3.Realize()
		
		sizer = wx.GridBagSizer(2,2)
		self.panel.SetSizer(sizer)
		self.preview = 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.preview, (1,0), span=(5,1), flag=wx.EXPAND)
		sizer.Add(self.listbox, (1,1), span=(1,2), flag=wx.EXPAND)
		sizer.Add(self.toolbar3, (2,1), span=(1,2), flag=wx.EXPAND|wx.LEFT|wx.RIGHT)
		sizer.Add(self.addButton, (3,1), span=(1,1))
		sizer.Add(self.remButton, (3,2), span=(1,1))
		sizer.Add(self.sliceButton, (4,1), span=(1,1))
		if not self.alwaysAutoPlace:
			sizer.Add(self.autoPlaceButton, (4,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)
		
		self.scaleCtrl = wx.TextCtrl(panel, -1, '')
		self.rotateCtrl = wx.SpinCtrl(panel, -1, '', size=(21*4,21), style=wx.SP_ARROW_KEYS)
		self.rotateCtrl.SetRange(0, 360)

		sizer.Add(wx.StaticText(panel, -1, 'Scale'), (0,0), flag=wx.ALIGN_CENTER_VERTICAL)
		sizer.Add(self.scaleCtrl, (0,1), flag=wx.ALIGN_BOTTOM|wx.EXPAND)
		sizer.Add(wx.StaticText(panel, -1, 'Rotate'), (1,0), flag=wx.ALIGN_CENTER_VERTICAL)
		sizer.Add(self.rotateCtrl, (1,1), flag=wx.ALIGN_BOTTOM|wx.EXPAND)

		if int(profile.getPreference('extruder_amount')) > 1:
			self.extruderCtrl = wx.ComboBox(panel, -1, '1', choices=map(str, range(1, int(profile.getPreference('extruder_amount'))+1)), style=wx.CB_DROPDOWN|wx.CB_READONLY)
			sizer.Add(wx.StaticText(panel, -1, 'Extruder'), (2,0), flag=wx.ALIGN_CENTER_VERTICAL)
			sizer.Add(self.extruderCtrl, (2,1), flag=wx.ALIGN_BOTTOM|wx.EXPAND)
			self.extruderCtrl.Bind(wx.EVT_COMBOBOX, self.OnExtruderChange)

		self.scaleCtrl.Bind(wx.EVT_TEXT, self.OnScaleChange)
		self.rotateCtrl.Bind(wx.EVT_SPINCTRL, self.OnRotateChange)

		self.SetSize((800,600))