Skip to content

Commit

Permalink
load SVG files for drawing/PCB milling
Browse files Browse the repository at this point in the history
preparations for PCB milling capabilities
- use libxml++
- allow loading SVG files generated from Gerber files with gerbv
  making a 2-dimensional FlatShape
- allow all moves to be lifted
- misc. enhancements for geometry, polys etc.
  • Loading branch information
hurzl committed Apr 11, 2012
1 parent 5028894 commit 5269f9a
Show file tree
Hide file tree
Showing 26 changed files with 978 additions and 284 deletions.
4 changes: 4 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ dnl [AC_DEFINE([HAVE_OPENVRML], [1], [Use OpenVRML])],
dnl [AC_DEFINE([NO_VRML], [1], [Without OpenVRML])])],
dnl )

PKG_CHECK_MODULES(XMLPP, libxml++-2.6 >= 2.10.0)
# AC_SUBST(XMLPP_CFLAGS)
# AC_SUBST(XMLPP_LIBS)

AC_OPENMP()

dnl ------------------------------------------------------------------
Expand Down
15 changes: 8 additions & 7 deletions doc/manual.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@ For historical reasons we leave here the links to the old svn version that devel

== Installation from binaries ==

All these binaries are very much out of date. Everything from before Feb. 2012 has almost nothing to do with the current state of development. Please see below for intalling from source.

=== Linux ===

There are currently no Repsnapper binaries pre-built for Linux. However, installation from source is relatively simple. If you'd like to package Repsnapper for your Linux distribution, please let us know!

=== Windows ===

Old v1 of Repsnapper for Windows http://www.kulitorum.com/RepSnapperBeta.rar (Kulitorums version)
There are beta versions for Windows, see the "Downloads" on github. The Windows version cannot communicate with a printer and can only calculate on a single CPU.

Historians only: the v1 of Repsnapper for Windows is here: http://www.kulitorum.com/RepSnapperBeta.rar (Kulitorums version).
This is even older, but should work with tonokip and FiveD: http://svn.kulitorum.com/RepSnapper/MSVC9/Release/RepSnapper.exe[here].

=== OS X ===

Old v1:
Old v1 (historians again):
David Buzz has posted binaries for OS X https://sites.google.com/site/davidbuzz/repsnapper-for-osx-binaries[here].

== Installation from source ==
Expand All @@ -56,6 +56,7 @@ Although RepSnapper is not generally tested outside of windows/linux/mac you may
* git
* libgtkmm-2.4-dev
* libgktglext1-dev
* libxml++-2.6
=====

Expand All @@ -66,17 +67,17 @@ Although RepSnapper is not generally tested outside of windows/linux/mac you may

Ubuntu 11.10:
--------------------------
sudo apt-get install git-core build-essential intltool libtool libgtkglext1-dev libgtkmm-2.4-dev gtk2-engines-pixbuf freeglut3-dev
sudo apt-get install git-core build-essential intltool libtool libgtkglext1-dev libgtkmm-2.4-dev gtk2-engines-pixbuf freeglut3-dev libxml++
--------------------------

Ubuntu 11.04:
--------------------------
sudo apt-get install git-core build-essential intltool libtool libgtkglext1-dev libgtkmm-2.4-dev libglut3-dev
sudo apt-get install git-core build-essential intltool libtool libgtkglext1-dev libgtkmm-2.4-dev libglut3-dev libxml++
--------------------------

Ubuntu 10.10:
--------------------------
sudo apt-get install git-core build-essential automake intltool libtool libgtkmm-2.4-dev libgtkglext1-dev libglut3-dev
sudo apt-get install git-core build-essential automake intltool libtool libgtkmm-2.4-dev libgtkglext1-dev libglut3-dev libxml++
--------------------------

Ubuntu 10.04:
Expand Down
3 changes: 2 additions & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ repsnapper_CPPFLAGS = \
-DRSDATADIR='$(repsnapperdatadir)' \
-DSYSCONFDIR='$(repsnapperconfdir)' \
-DLOCALEDIR='"$(localedir)"' \
$(XMLPP_CFLAGS) \
$(OPENMP_CFLAGS) \
-g -O3 $(WARNING_FLAGS)

Expand Down Expand Up @@ -88,7 +89,7 @@ EXTRA_DIST += $(built_header_make)

repsnapper_LDFLAGS = $(EXTRA_LDFLAGS)

repsnapper_LDADD = libreprap.la libclipper.la libpoly2tri.la liblmfit.la $(OPENMP_CFLAGS) $(OPENVRML_LIBS) $(GTKMM_LIBS) $(GL_LIBS) $(BOOST_LDFLAGS)
repsnapper_LDADD = libreprap.la libclipper.la libpoly2tri.la liblmfit.la $(OPENMP_CFLAGS) $(OPENVRML_LIBS) $(GTKMM_LIBS) $(GL_LIBS) $(XMLPP_LIBS) $(BOOST_LDFLAGS)

repsnapperdatadir = $(datadir)/@PACKAGE@
dist_repsnapperdata_DATA = src/repsnapper.ui
Expand Down
128 changes: 69 additions & 59 deletions src/file.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
This file is a part of the RepSnapper project.
Copyright (C) 2010 Michael Meeks
Copyright (C) 2012 martin.dieringer@gmx.de
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
Expand All @@ -24,59 +25,60 @@
#include "file.h"
#include "model.h"

string to_lower(const string &l)
{
string lower;
lower.resize(l.size());
std::transform(l.begin(), l.end(), lower.begin(), (int(*)(int))std::tolower);
return lower;
}

namespace {
static GSList *openGtk(const char *directory, const char *filter_str,
FileChooser::Op op, const char *title, gboolean multiple) {
GSList *result = NULL;
GtkFileChooserAction action;

const vector< Glib::RefPtr< Gio::File > >
openGtk(const string &directory, const vector<string> &file_filters,
FileChooser::Op op, const string &title, gboolean multiple) {
// GSList *result = NULL;
Gtk::FileChooserAction action;
const char *button_text;

switch (op) {
case FileChooser::SAVE:
button_text = GTK_STOCK_SAVE;
action = GTK_FILE_CHOOSER_ACTION_SAVE;
action = Gtk::FILE_CHOOSER_ACTION_SAVE;
break;
case FileChooser::OPEN:
default:
action = GTK_FILE_CHOOSER_ACTION_OPEN;
action = Gtk::FILE_CHOOSER_ACTION_OPEN;
button_text = GTK_STOCK_OPEN;
break;
}

GtkWidget *dialog = gtk_file_chooser_dialog_new
(title, NULL /* FIXME transience */, action,
GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL,
button_text,
GTK_RESPONSE_ACCEPT,
NULL);
GtkFileChooser *chooser = GTK_FILE_CHOOSER (dialog);
if (directory)
gtk_file_chooser_set_current_folder (chooser, directory);
Gtk::FileChooserDialog dialog(title, action);
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT);

gtk_file_chooser_set_select_multiple (chooser, multiple);
if (directory!="")
dialog.set_current_folder (directory);

dialog.set_select_multiple (multiple);

// essentially case-insensitive file filter
GtkFileFilter *filter = gtk_file_filter_new ();
string filter_work_string = filter_str;
gtk_file_filter_add_pattern (filter, filter_work_string.c_str());
transform(filter_work_string.begin(), filter_work_string.end(),filter_work_string.begin(),::toupper);
gtk_file_filter_add_pattern (filter, filter_work_string.c_str());
transform(filter_work_string.begin(), filter_work_string.end(),filter_work_string.begin(),::tolower);
gtk_file_filter_add_pattern (filter, filter_work_string.c_str());
gtk_file_filter_set_name (filter,filter_work_string.c_str());
gtk_file_chooser_add_filter (chooser, filter);
Gtk::FileFilter filter;
for (uint i=0; i<file_filters.size(); i++) {
filter.add_pattern(to_lower(file_filters[i]));
}
dialog.add_filter (filter);

// an option to open improperly named files
GtkFileFilter *allfiles = gtk_file_filter_new();
gtk_file_filter_add_pattern (allfiles, "*");
gtk_file_filter_set_name (allfiles, _("All Files"));
gtk_file_chooser_add_filter (chooser, allfiles);
Gtk::FileFilter allfiles;
allfiles.add_pattern("*");
allfiles.set_name(_("All Files"));
dialog.add_filter (allfiles);

if (gtk_dialog_run (GTK_DIALOG (chooser)) == GTK_RESPONSE_ACCEPT) {
result = gtk_file_chooser_get_files(chooser);
}
gtk_widget_destroy (dialog);
dialog.run();

std::vector< Glib::RefPtr < Gio::File > > result = dialog.get_files();

return result;
}
Expand All @@ -86,54 +88,60 @@ namespace {
// FIXME: impl. multi-selection cleanly
void FileChooser::ioDialog (Model *model, Op o, Type t, bool dropRFO)
{
GSList *files;
GSList *cur;
const char *filter;
const char *directory;
const char *title;
vector<Glib::RefPtr<Gio::File> > files;
vector<string> filter(1);
string directory;
string title;

gboolean multiple = FALSE;

const string dfilt[] = { "*.stl", "*.gcode", "*.wrl", "*.svg" };
vector<string> defaultfilter(dfilt, dfilt+(sizeof(dfilt)/sizeof(string)));

switch (t) {
case SETTINGS:
filter = "*.conf";
filter[0] = "*.conf" ;
title = _("Choose settings filename");
directory = model->settings.STLPath.c_str();
directory = model->settings.STLPath;
break;
case GCODE:
filter = "*.gcode";
filter[0] = "*.gcode" ;
directory = model->settings.GCodePath;
title = _("Choose GCODE filename");
directory = model->settings.GCodePath.c_str();
multiple = (o == FileChooser::OPEN);
break;
case SVG:
filter = "*.svg";
filter[0] = "*.svg" ;
title = _("Choose SVG filename");
directory = model->settings.GCodePath.c_str();
directory = model->settings.STLPath;
break;
case STL:
filter = defaultfilter; //"*.stl";
title = _("Choose filename");
multiple = (o == FileChooser::OPEN);
break;
default:
filter = "*.stl";
title = _("Choose STL filename");
directory = model->settings.STLPath.c_str();
filter = defaultfilter;
title = _("Choose filename");
directory = model->settings.STLPath;
multiple = (o == FileChooser::OPEN);
break;
}

if (!directory || directory[0] == '\0')
if (directory == "")
directory = ".";

files = openGtk (directory, filter, o, title, multiple);
if(!files) // TODO: Indicate error on errors. Nothing on cancellation
return;

for (cur = files; cur != NULL; cur = g_slist_next(cur)) {
Glib::RefPtr<Gio::File> file = Glib::wrap((GFile *)(cur->data)); // Takes ownership
for (uint i= 0; i < files.size(); i++) {

Glib::RefPtr<Gio::File> &file = files[i];

if (!file)
continue; // should never happen

std::string directory_path = file->get_parent()->get_path();

std::string directory_path = file->get_parent()->get_path();
switch (t) {
case GCODE:
if (o == OPEN)
Expand All @@ -149,18 +157,20 @@ void FileChooser::ioDialog (Model *model, Op o, Type t, bool dropRFO)
model->SaveConfig (file);
break;
case SVG:
if (o == SAVE)
if (o == OPEN)
model->ReadSVG (file);
else
model->SliceToSVG (file);
break;
default:
case STL:
default:
if (o == OPEN)
model->ReadStl (file);
model->Read(file);
else if (o == SAVE)
model->SaveStl (file);
model->settings.STLPath = directory_path;
break;
}
}
g_slist_free(files);

}
Loading

0 comments on commit 5269f9a

Please sign in to comment.