mirror of
https://github.com/Denvi/FlatCAM.git
synced 2026-03-24 17:17:09 +01:00
Double-sided pcb tool fix for treeview model.
"File" menu fix.
This commit is contained in:
@@ -5,6 +5,7 @@ from FlatCAMTool import FlatCAMTool
|
||||
from FlatCAMObj import *
|
||||
from shapely.geometry import Point
|
||||
from shapely import affinity
|
||||
from PyQt4 import QtCore
|
||||
|
||||
|
||||
class DblSidedTool(FlatCAMTool):
|
||||
@@ -25,6 +26,8 @@ class DblSidedTool(FlatCAMTool):
|
||||
## Layer to mirror
|
||||
self.object_combo = QtGui.QComboBox()
|
||||
self.object_combo.setModel(self.app.collection)
|
||||
self.object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
|
||||
|
||||
self.botlay_label = QtGui.QLabel("Bottom Layer:")
|
||||
self.botlay_label.setToolTip(
|
||||
"Layer to be mirrorer."
|
||||
@@ -69,6 +72,7 @@ class DblSidedTool(FlatCAMTool):
|
||||
self.point_box_container.addWidget(self.point)
|
||||
self.box_combo = QtGui.QComboBox()
|
||||
self.box_combo.setModel(self.app.collection)
|
||||
self.box_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
|
||||
self.point_box_container.addWidget(self.box_combo)
|
||||
self.box_combo.hide()
|
||||
|
||||
@@ -129,7 +133,8 @@ class DblSidedTool(FlatCAMTool):
|
||||
px, py = self.point.get_value()
|
||||
else:
|
||||
selection_index = self.box_combo.currentIndex()
|
||||
bb_obj = self.app.collection.object_list[selection_index] # TODO: Direct access??
|
||||
model_index = self.app.collection.index(selection_index, 0, self.object_combo.rootModelIndex())
|
||||
bb_obj = model_index.internalPointer().obj
|
||||
xmin, ymin, xmax, ymax = bb_obj.bounds()
|
||||
px = 0.5 * (xmin + xmax)
|
||||
py = 0.5 * (ymin + ymax)
|
||||
@@ -158,7 +163,9 @@ class DblSidedTool(FlatCAMTool):
|
||||
|
||||
def on_mirror(self):
|
||||
selection_index = self.object_combo.currentIndex()
|
||||
fcobj = self.app.collection.object_list[selection_index]
|
||||
# fcobj = self.app.collection.object_list[selection_index]
|
||||
model_index = self.app.collection.index(selection_index, 0, self.object_combo.rootModelIndex())
|
||||
fcobj = model_index.internalPointer().obj
|
||||
|
||||
# For now, lets limit to Gerbers and Excellons.
|
||||
# assert isinstance(gerb, FlatCAMGerber)
|
||||
@@ -173,7 +180,8 @@ class DblSidedTool(FlatCAMTool):
|
||||
px, py = self.point.get_value()
|
||||
else:
|
||||
selection_index = self.box_combo.currentIndex()
|
||||
bb_obj = self.app.collection.object_list[selection_index] # TODO: Direct access??
|
||||
model_index = self.app.collection.index(selection_index, 0, self.object_combo.rootModelIndex())
|
||||
bb_obj = model_index.internalPointer().obj
|
||||
xmin, ymin, xmax, ymax = bb_obj.bounds()
|
||||
px = 0.5 * (xmin + xmax)
|
||||
py = 0.5 * (ymin + ymax)
|
||||
|
||||
@@ -25,6 +25,7 @@ from FlatCAMDraw import FlatCAMDraw
|
||||
from FlatCAMProcess import *
|
||||
from MeasurementTool import Measurement
|
||||
from DblSidedTool import DblSidedTool
|
||||
import re
|
||||
|
||||
|
||||
########################################
|
||||
@@ -147,8 +148,11 @@ class App(QtCore.QObject):
|
||||
App.log.debug("Application path is " + self.app_home)
|
||||
App.log.debug("Started in " + os.getcwd())
|
||||
|
||||
if sys.platform != 'win32':
|
||||
os.chdir(self.app_home)
|
||||
# cx_freeze workaround
|
||||
if os.path.isfile(self.app_home):
|
||||
self.app_home = os.path.dirname(self.app_home)
|
||||
|
||||
os.chdir(self.app_home)
|
||||
|
||||
####################
|
||||
## Initialize GUI ##
|
||||
@@ -1603,6 +1607,9 @@ class App(QtCore.QObject):
|
||||
except TypeError:
|
||||
filename = QtGui.QFileDialog.getSaveFileName(caption="Save Project As ...")
|
||||
|
||||
if filename == "":
|
||||
return
|
||||
|
||||
try:
|
||||
f = open(filename, 'r')
|
||||
f.close()
|
||||
|
||||
@@ -23,45 +23,54 @@ class FlatCAMGUI(QtGui.QMainWindow):
|
||||
# New
|
||||
self.menufilenew = QtGui.QAction(QtGui.QIcon('share/file16.png'), '&New', self)
|
||||
self.menufile.addAction(self.menufilenew)
|
||||
# Open recent
|
||||
|
||||
# Recent
|
||||
self.recent = self.menufile.addMenu(QtGui.QIcon('share/folder16.png'), "Open recent ...")
|
||||
|
||||
# Open gerber
|
||||
self.menufileopengerber = QtGui.QAction(QtGui.QIcon('share/folder16.png'), 'Open &Gerber ...', self)
|
||||
self.menufile.addAction(self.menufileopengerber)
|
||||
|
||||
# Open Excellon ...
|
||||
self.menufileopenexcellon = QtGui.QAction(QtGui.QIcon('share/folder16.png'), 'Open &Excellon ...', self)
|
||||
self.menufile.addAction(self.menufileopenexcellon)
|
||||
|
||||
# Open G-Code ...
|
||||
self.menufileopengcode = QtGui.QAction(QtGui.QIcon('share/folder16.png'), 'Open G-&Code ...', self)
|
||||
self.menufile.addAction(self.menufileopengcode)
|
||||
|
||||
# Open Project ...
|
||||
self.menufileopenproject = QtGui.QAction(QtGui.QIcon('share/folder16.png'), 'Open &Project ...', self)
|
||||
self.menufile.addAction(self.menufileopenproject)
|
||||
|
||||
# Open gerber
|
||||
self.menufileopengerber = QtGui.QAction('Open &Gerber ...', self)
|
||||
self.menufile.addAction(self.menufileopengerber)
|
||||
|
||||
# Open Excellon ...
|
||||
self.menufileopenexcellon = QtGui.QAction('Open &Excellon ...', self)
|
||||
self.menufile.addAction(self.menufileopenexcellon)
|
||||
|
||||
# Open G-Code ...
|
||||
self.menufileopengcode = QtGui.QAction('Open G-&Code ...', self)
|
||||
self.menufile.addAction(self.menufileopengcode)
|
||||
|
||||
# Open recent
|
||||
# Recent
|
||||
self.recent = self.menufile.addMenu("Recent files")
|
||||
|
||||
# Separator
|
||||
self.menufile.addSeparator()
|
||||
|
||||
# Save Defaults
|
||||
self.menufilesavedefaults = QtGui.QAction('Save &Defaults', self)
|
||||
self.menufile.addAction(self.menufilesavedefaults)
|
||||
|
||||
# Separator
|
||||
self.menufile.addSeparator()
|
||||
|
||||
# Save Project
|
||||
self.menufilesaveproject = QtGui.QAction(QtGui.QIcon('share/floppy16.png'), '&Save Project', self)
|
||||
self.menufile.addAction(self.menufilesaveproject)
|
||||
|
||||
# Save Project As ...
|
||||
self.menufilesaveprojectas = QtGui.QAction(QtGui.QIcon('share/floppy16.png'), 'Save Project &As ...', self)
|
||||
self.menufilesaveprojectas = QtGui.QAction('Save Project &As ...', self)
|
||||
self.menufile.addAction(self.menufilesaveprojectas)
|
||||
|
||||
# Save Project Copy ...
|
||||
self.menufilesaveprojectcopy = QtGui.QAction(QtGui.QIcon('share/floppy16.png'), 'Save Project C&opy ...', self)
|
||||
self.menufilesaveprojectcopy = QtGui.QAction('Save Project C&opy ...', self)
|
||||
self.menufile.addAction(self.menufilesaveprojectcopy)
|
||||
|
||||
# Save Defaults
|
||||
self.menufilesavedefaults = QtGui.QAction(QtGui.QIcon('share/floppy16.png'), 'Save &Defaults', self)
|
||||
self.menufile.addAction(self.menufilesavedefaults)
|
||||
# Separator
|
||||
self.menufile.addSeparator()
|
||||
|
||||
# Quit
|
||||
exit_action = QtGui.QAction(QtGui.QIcon('share/power16.png'), '&Exit', self)
|
||||
exit_action = QtGui.QAction(QtGui.QIcon('share/power16.png'), 'E&xit', self)
|
||||
# exitAction.setShortcut('Ctrl+Q')
|
||||
# exitAction.setStatusTip('Exit application')
|
||||
exit_action.triggered.connect(QtGui.qApp.quit)
|
||||
|
||||
@@ -70,8 +70,9 @@ class FlatCAMObj(QtCore.QObject):
|
||||
def on_name_editing_finished(self):
|
||||
old_name = copy(self.options["name"])
|
||||
new_name = self.ui.name_entry.get_value()
|
||||
self.options["name"] = self.ui.name_entry.get_value()
|
||||
self.app.info("Name changed from %s to %s" % (old_name, new_name))
|
||||
if new_name != old_name:
|
||||
self.options["name"] = new_name
|
||||
self.app.info("Name changed from %s to %s" % (old_name, new_name))
|
||||
|
||||
def on_offset_button_click(self):
|
||||
self.app.report_usage("obj_on_offset_button")
|
||||
|
||||
Reference in New Issue
Block a user