Commit b039ec78 authored by sumpfralle's avatar sumpfralle

added copy and paste to and from the clipboard


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@1018 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent ba7d4da4
......@@ -32,6 +32,7 @@ Version 0.5 - UNRELEASED
* improved stability of remote processing: disconnected nodes should not cause problems anymore
* automatically distributed support bridges can now be placed at corners or edges
* visualize "inside" polygons (holes) through partial transparency
* added copy/paste of model to and from the clipboard
Version 0.4.0.1 - 2010-10-24
* disabled parallel processing for Windows standalone executable
......
......@@ -13,6 +13,9 @@
</menu>
<menu action="EditMenu">
<menuitem action="UndoButton"/>
<separator />
<menuitem action="CopyModelToClipboard"/>
<menuitem action="PasteModelFromClipboard"/>
</menu>
<menu action="SettingsMenu">
<menuitem action="LoadTaskSettings"/>
......
......@@ -9501,6 +9501,7 @@ upon interesting bugs and weird results.</property>
<property name="label">_Touch off and tool change</property>
<property name="short_label">_Touch off</property>
<property name="stock_id">gtk-help</property>
<property name="always_show_image">True</property>
</object>
<object class="GtkImage" id="ExportVisibleToolpathsIcon">
<property name="visible">True</property>
......@@ -9510,4 +9511,18 @@ upon interesting bugs and weird results.</property>
<property name="visible">True</property>
<property name="stock">gtk-save-as</property>
</object>
<object class="GtkAction" id="CopyModelToClipboard">
<property name="label">_Copy</property>
<property name="short_label">_Copy</property>
<property name="tooltip">Copy model to clipboard</property>
<property name="stock_id">gtk-copy</property>
<property name="always_show_image">True</property>
</object>
<object class="GtkAction" id="PasteModelFromClipboard">
<property name="label">_Paste</property>
<property name="short_label">_Paste</property>
<property name="tooltip">Paste a model from clipboard</property>
<property name="stock_id">gtk-paste</property>
<property name="always_show_image">True</property>
</object>
</interface>
This diff is collapsed.
......@@ -832,12 +832,15 @@ class DXFParser(object):
def import_model(filename, color_as_height=False, fonts_cache=None,
callback=None, **kwargs):
try:
infile = open_url(filename)
except IOError, err_msg:
log.error("DXFImporter: Failed to read file (%s): %s" \
% (filename, err_msg))
return None
if hasattr(filename, "read"):
infile = filename
else:
try:
infile = open_url(filename)
except IOError, err_msg:
log.error("DXFImporter: Failed to read file (%s): %s" \
% (filename, err_msg))
return None
result = DXFParser(infile, color_as_height=color_as_height,
fonts_cache=fonts_cache, callback=callback)
......
......@@ -31,23 +31,37 @@ log = pycam.Utils.log.get_logger()
def import_model(filename, program_locations=None, unit="mm", callback=None,
**kwargs):
if not check_uri_exists(filename):
log.error("PSImporter: file (%s) does not exist" % filename)
return None
if not os.path.isfile(filename):
# non-local file - write it to a temporary file first
local_file = False
uri = filename
local_file = False
if hasattr(filename, "read"):
infile = filename
ps_file_handle, ps_file_name = tempfile.mkstemp(suffix=".ps")
os.close(ps_file_handle)
log.debug("Retrieving PS file for local access: %s -> %s" % \
(uri, ps_file_name))
if not retrieve_uri(uri, ps_file_name, callback=callback):
log.error("PSImporter: Failed to retrieve the PS model file: " + \
"%s -> %s" % (uri, ps_file_name))
try:
temp_file = os.fdopen(ps_file_handle, "w")
temp_file.write(infile.read())
temp_file.close()
except IOError, err_msg:
log.error("PSImporter: Failed to create temporary local file " + \
"(%s): %s" % (ps_file_name, err_msg))
return
filename = ps_file_name
else:
local_file = True
if not check_uri_exists(filename):
log.error("PSImporter: file (%s) does not exist" % filename)
return None
if not os.path.isfile(filename):
# non-local file - write it to a temporary file first
uri = filename
ps_file_handle, ps_file_name = tempfile.mkstemp(suffix=".ps")
os.close(ps_file_handle)
log.debug("Retrieving PS file for local access: %s -> %s" % \
(uri, ps_file_name))
if not retrieve_uri(uri, ps_file_name, callback=callback):
log.error("PSImporter: Failed to retrieve the PS model file: " + \
"%s -> %s" % (uri, ps_file_name))
return
filename = ps_file_name
else:
local_file = True
if program_locations and "pstoedit" in program_locations:
pstoedit_path = program_locations["pstoedit"]
......
......@@ -60,16 +60,21 @@ def ImportModel(filename, use_kdtree=True, callback=None, **kwargs):
normal_conflict_warning_seen = False
try:
url_file = open_url(filename)
# urllib.urlopen objects do not support "seek" - so we need to read the
# whole file at once. This is ugly - anyone with a better idea?
f = StringIO.StringIO(url_file.read())
url_file.close()
except IOError, err_msg:
log.error("STLImporter: Failed to read file (%s): %s" \
% (filename, err_msg))
return None
if hasattr(filename, "read"):
f = filename
# useful for later error messages
filename = "input data"
else:
try:
url_file = open_url(filename)
# urllib.urlopen objects do not support "seek" - so we need to read
# the whole file at once. This is ugly - anyone with a better idea?
f = StringIO.StringIO(url_file.read())
url_file.close()
except IOError, err_msg:
log.error("STLImporter: Failed to read file (%s): %s" \
% (filename, err_msg))
return None
# Read the first two lines of (potentially non-binary) input - they should
# contain "solid" and "facet".
header_lines = []
......
......@@ -83,23 +83,36 @@ def convert_eps2dxf(eps_filename, dxf_filename, location=None, unit="mm"):
def import_model(filename, program_locations=None, unit="mm", callback=None,
**kwargs):
if not check_uri_exists(filename):
log.error("SVGImporter: file (%s) does not exist" % filename)
return None
if not os.path.isfile(filename):
# non-local file - write it to a temporary file first
local_file = False
uri = filename
local_file = False
if hasattr(filename, "read"):
infile = filename
svg_file_handle, svg_file_name = tempfile.mkstemp(suffix=".svg")
os.close(svg_file_handle)
log.debug("Retrieving SVG file for local access: %s -> %s" % \
(uri, svg_file_name))
if not retrieve_uri(uri, svg_file_name, callback=callback):
log.error("SVGImporter: Failed to retrieve the SVG model file: " + \
"%s -> %s" % (uri, svg_file_name))
try:
temp_file = os.fdopen(svg_file_handle, "w")
temp_file.write(infile.read())
temp_file.close()
except IOError, err_msg:
log.error("SVGImporter: Failed to create temporary local file " + \
"(%s): %s" % (svg_file_name, err_msg))
return
filename = svg_file_name
else:
local_file = True
if not check_uri_exists(filename):
log.error("SVGImporter: file (%s) does not exist" % filename)
return None
if not os.path.isfile(filename):
# non-local file - write it to a temporary file first
uri = filename
svg_file_handle, svg_file_name = tempfile.mkstemp(suffix=".svg")
os.close(svg_file_handle)
log.debug("Retrieving SVG file for local access: %s -> %s" % \
(uri, svg_file_name))
if not retrieve_uri(uri, svg_file_name, callback=callback):
log.error("SVGImporter: Failed to retrieve the SVG model " + \
"file: %s -> %s" % (uri, svg_file_name))
filename = svg_file_name
else:
local_file = True
if program_locations and "inkscape" in program_locations:
inkscape_path = program_locations["inkscape"]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment