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 ...@@ -32,6 +32,7 @@ Version 0.5 - UNRELEASED
* improved stability of remote processing: disconnected nodes should not cause problems anymore * improved stability of remote processing: disconnected nodes should not cause problems anymore
* automatically distributed support bridges can now be placed at corners or edges * automatically distributed support bridges can now be placed at corners or edges
* visualize "inside" polygons (holes) through partial transparency * 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 Version 0.4.0.1 - 2010-10-24
* disabled parallel processing for Windows standalone executable * disabled parallel processing for Windows standalone executable
......
...@@ -13,6 +13,9 @@ ...@@ -13,6 +13,9 @@
</menu> </menu>
<menu action="EditMenu"> <menu action="EditMenu">
<menuitem action="UndoButton"/> <menuitem action="UndoButton"/>
<separator />
<menuitem action="CopyModelToClipboard"/>
<menuitem action="PasteModelFromClipboard"/>
</menu> </menu>
<menu action="SettingsMenu"> <menu action="SettingsMenu">
<menuitem action="LoadTaskSettings"/> <menuitem action="LoadTaskSettings"/>
......
...@@ -9501,6 +9501,7 @@ upon interesting bugs and weird results.</property> ...@@ -9501,6 +9501,7 @@ upon interesting bugs and weird results.</property>
<property name="label">_Touch off and tool change</property> <property name="label">_Touch off and tool change</property>
<property name="short_label">_Touch off</property> <property name="short_label">_Touch off</property>
<property name="stock_id">gtk-help</property> <property name="stock_id">gtk-help</property>
<property name="always_show_image">True</property>
</object> </object>
<object class="GtkImage" id="ExportVisibleToolpathsIcon"> <object class="GtkImage" id="ExportVisibleToolpathsIcon">
<property name="visible">True</property> <property name="visible">True</property>
...@@ -9510,4 +9511,18 @@ upon interesting bugs and weird results.</property> ...@@ -9510,4 +9511,18 @@ upon interesting bugs and weird results.</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="stock">gtk-save-as</property> <property name="stock">gtk-save-as</property>
</object> </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> </interface>
This diff is collapsed.
...@@ -832,6 +832,9 @@ class DXFParser(object): ...@@ -832,6 +832,9 @@ class DXFParser(object):
def import_model(filename, color_as_height=False, fonts_cache=None, def import_model(filename, color_as_height=False, fonts_cache=None,
callback=None, **kwargs): callback=None, **kwargs):
if hasattr(filename, "read"):
infile = filename
else:
try: try:
infile = open_url(filename) infile = open_url(filename)
except IOError, err_msg: except IOError, err_msg:
......
...@@ -31,12 +31,25 @@ log = pycam.Utils.log.get_logger() ...@@ -31,12 +31,25 @@ log = pycam.Utils.log.get_logger()
def import_model(filename, program_locations=None, unit="mm", callback=None, def import_model(filename, program_locations=None, unit="mm", callback=None,
**kwargs): **kwargs):
local_file = False
if hasattr(filename, "read"):
infile = filename
ps_file_handle, ps_file_name = tempfile.mkstemp(suffix=".ps")
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:
if not check_uri_exists(filename): if not check_uri_exists(filename):
log.error("PSImporter: file (%s) does not exist" % filename) log.error("PSImporter: file (%s) does not exist" % filename)
return None return None
if not os.path.isfile(filename): if not os.path.isfile(filename):
# non-local file - write it to a temporary file first # non-local file - write it to a temporary file first
local_file = False
uri = filename uri = filename
ps_file_handle, ps_file_name = tempfile.mkstemp(suffix=".ps") ps_file_handle, ps_file_name = tempfile.mkstemp(suffix=".ps")
os.close(ps_file_handle) os.close(ps_file_handle)
...@@ -45,6 +58,7 @@ def import_model(filename, program_locations=None, unit="mm", callback=None, ...@@ -45,6 +58,7 @@ def import_model(filename, program_locations=None, unit="mm", callback=None,
if not retrieve_uri(uri, ps_file_name, callback=callback): if not retrieve_uri(uri, ps_file_name, callback=callback):
log.error("PSImporter: Failed to retrieve the PS model file: " + \ log.error("PSImporter: Failed to retrieve the PS model file: " + \
"%s -> %s" % (uri, ps_file_name)) "%s -> %s" % (uri, ps_file_name))
return
filename = ps_file_name filename = ps_file_name
else: else:
local_file = True local_file = True
......
...@@ -60,10 +60,15 @@ def ImportModel(filename, use_kdtree=True, callback=None, **kwargs): ...@@ -60,10 +60,15 @@ def ImportModel(filename, use_kdtree=True, callback=None, **kwargs):
normal_conflict_warning_seen = False normal_conflict_warning_seen = False
if hasattr(filename, "read"):
f = filename
# useful for later error messages
filename = "input data"
else:
try: try:
url_file = open_url(filename) url_file = open_url(filename)
# urllib.urlopen objects do not support "seek" - so we need to read the # urllib.urlopen objects do not support "seek" - so we need to read
# whole file at once. This is ugly - anyone with a better idea? # the whole file at once. This is ugly - anyone with a better idea?
f = StringIO.StringIO(url_file.read()) f = StringIO.StringIO(url_file.read())
url_file.close() url_file.close()
except IOError, err_msg: except IOError, err_msg:
......
...@@ -83,20 +83,33 @@ def convert_eps2dxf(eps_filename, dxf_filename, location=None, unit="mm"): ...@@ -83,20 +83,33 @@ def convert_eps2dxf(eps_filename, dxf_filename, location=None, unit="mm"):
def import_model(filename, program_locations=None, unit="mm", callback=None, def import_model(filename, program_locations=None, unit="mm", callback=None,
**kwargs): **kwargs):
local_file = False
if hasattr(filename, "read"):
infile = filename
svg_file_handle, svg_file_name = tempfile.mkstemp(suffix=".svg")
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:
if not check_uri_exists(filename): if not check_uri_exists(filename):
log.error("SVGImporter: file (%s) does not exist" % filename) log.error("SVGImporter: file (%s) does not exist" % filename)
return None return None
if not os.path.isfile(filename): if not os.path.isfile(filename):
# non-local file - write it to a temporary file first # non-local file - write it to a temporary file first
local_file = False
uri = filename uri = filename
svg_file_handle, svg_file_name = tempfile.mkstemp(suffix=".svg") svg_file_handle, svg_file_name = tempfile.mkstemp(suffix=".svg")
os.close(svg_file_handle) os.close(svg_file_handle)
log.debug("Retrieving SVG file for local access: %s -> %s" % \ log.debug("Retrieving SVG file for local access: %s -> %s" % \
(uri, svg_file_name)) (uri, svg_file_name))
if not retrieve_uri(uri, svg_file_name, callback=callback): if not retrieve_uri(uri, svg_file_name, callback=callback):
log.error("SVGImporter: Failed to retrieve the SVG model file: " + \ log.error("SVGImporter: Failed to retrieve the SVG model " + \
"%s -> %s" % (uri, svg_file_name)) "file: %s -> %s" % (uri, svg_file_name))
filename = svg_file_name filename = svg_file_name
else: else:
local_file = True local_file = True
......
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