merge with master

This commit is contained in:
Enrico Turri 2017-12-11 12:01:30 +01:00
commit 50a45949d1
177 changed files with 9348 additions and 3124 deletions

View file

@ -8,6 +8,11 @@
%name{Slic3r::Config} class DynamicPrintConfig {
DynamicPrintConfig();
~DynamicPrintConfig();
static DynamicPrintConfig* new_from_defaults();
static DynamicPrintConfig* new_from_defaults_keys(std::vector<std::string> keys);
DynamicPrintConfig* clone() %code{% RETVAL = new DynamicPrintConfig(*THIS); %};
DynamicPrintConfig* clone_only(std::vector<std::string> keys)
%code{% RETVAL = new DynamicPrintConfig(); RETVAL->apply_only(*THIS, keys, true); %};
bool has(t_config_option_key opt_key);
SV* as_hash()
%code{% RETVAL = ConfigBase__as_hash(THIS); %};
@ -15,6 +20,13 @@
%code{% RETVAL = ConfigBase__get(THIS, opt_key); %};
SV* get_at(t_config_option_key opt_key, int i)
%code{% RETVAL = ConfigBase__get_at(THIS, opt_key, i); %};
SV* get_value(t_config_option_key opt_key)
%code{%
const ConfigOptionDef *def = THIS->def()->get(opt_key);
RETVAL = (def != nullptr && ! def->ratio_over.empty()) ?
newSVnv(THIS->get_abs_value(opt_key)) :
ConfigBase__get(THIS, opt_key);
%};
bool set(t_config_option_key opt_key, SV* value)
%code{% RETVAL = ConfigBase__set(THIS, opt_key, value); %};
bool set_deserialize(t_config_option_key opt_key, SV* str)
@ -38,16 +50,24 @@
void normalize();
%name{setenv} void setenv_();
double min_object_distance() %code{% RETVAL = PrintConfig::min_object_distance(THIS); %};
%name{_load} void load(std::string file);
%name{_load_from_gcode} void load_from_gcode(std::string input_file)
static DynamicPrintConfig* load(char *path)
%code%{
auto config = new DynamicPrintConfig();
try {
THIS->load_from_gcode(input_file);
config->load(path);
RETVAL = config;
} catch (std::exception& e) {
croak("Error extracting configuration from a g-code %s:\n%s\n", input_file.c_str(), e.what());
delete config;
croak("Error extracting configuration from %s:\n%s\n", path, e.what());
}
%};
void save(std::string file);
int validate() %code%{
std::string err = THIS->validate();
if (! err.empty())
croak("Configuration is not valid: %s\n", err.c_str());
RETVAL = 1;
%};
};
%name{Slic3r::Config::Static} class StaticPrintConfig {
@ -94,8 +114,18 @@
%};
%name{setenv} void setenv_();
double min_object_distance() %code{% RETVAL = PrintConfig::min_object_distance(THIS); %};
%name{_load} void load(std::string file);
%name{_load_from_gcode} void load_from_gcode(std::string file);
static StaticPrintConfig* load(char *path)
%code%{
auto config = new FullPrintConfig();
try {
config->load(path);
RETVAL = static_cast<PrintObjectConfig*>(config);
} catch (std::exception& e) {
delete config;
croak("Error extracting configuration from %s:\n%s\n", path, e.what());
}
%};
void save(std::string file);
};

View file

@ -46,18 +46,6 @@ _new_from_width(CLASS, role, width, nozzle_diameter, height, bridge_flow_ratio)
OUTPUT:
RETVAL
Flow*
_new_from_spacing(CLASS, spacing, nozzle_diameter, height, bridge)
char* CLASS;
float spacing;
float nozzle_diameter;
float height;
bool bridge;
CODE:
RETVAL = new Flow(Flow::new_from_spacing(spacing, nozzle_diameter, height, bridge));
OUTPUT:
RETVAL
%}
};

View file

@ -17,7 +17,14 @@
%name{Slic3r::GCode} class GCode {
GCode();
~GCode();
std::string do_export(Print *print, const char *path);
void do_export(Print *print, const char *path)
%code%{
try {
THIS->do_export(print, path);
} catch (std::exception& e) {
croak(e.what());
}
%};
Ref<Pointf> origin()
%code{% RETVAL = &(THIS->origin()); %};

View file

@ -14,8 +14,26 @@ void disable_screensaver()
void enable_screensaver()
%code{% Slic3r::GUI::enable_screensaver(); %};
std::vector<std::string> scan_serial_ports()
%code{% RETVAL=Slic3r::GUI::scan_serial_ports(); %};
bool debugged()
%code{% RETVAL=Slic3r::GUI::debugged(); %};
void break_to_debugger()
%code{% Slic3r::GUI::break_to_debugger(); %};
void set_wxapp(SV *ui)
%code%{ Slic3r::GUI::set_wxapp((wxApp*)wxPli_sv_2_object(aTHX_ ui, "Wx::App")); %};
void set_main_frame(SV *ui)
%code%{ Slic3r::GUI::set_main_frame((wxFrame*)wxPli_sv_2_object(aTHX_ ui, "Wx::Frame")); %};
void set_tab_panel(SV *ui)
%code%{ Slic3r::GUI::set_tab_panel((wxNotebook*)wxPli_sv_2_object(aTHX_ ui, "Wx::Notebook")); %};
void add_debug_menu(SV *ui)
%code%{ Slic3r::GUI::add_debug_menu((wxMenuBar*)wxPli_sv_2_object(aTHX_ ui, "Wx::MenuBar")); %};
void create_preset_tab(const char *name)
%code%{ Slic3r::GUI::create_preset_tab(name); %};

44
xs/xsp/GUI_AppConfig.xsp Normal file
View file

@ -0,0 +1,44 @@
%module{Slic3r::XS};
%{
#include <xsinit.h>
#include "slic3r/GUI/AppConfig.hpp"
%}
%name{Slic3r::GUI::AppConfig} class AppConfig {
AppConfig();
~AppConfig();
void reset();
void set_defaults();
void load()
%code%{
try {
THIS->load();
} catch (std::exception& e) {
croak("Loading an application config file failed:\n%s\n", e.what());
}
%};
void save()
%code%{
try {
THIS->save();
} catch (std::exception& e) {
croak("Saving an application config file failed:\n%s\n", e.what());
}
%};
bool exists();
bool dirty();
std::string get(char *name);
void set(char *name, char *value);
bool has(char *section);
std::string get_last_dir();
void update_config_dir(char *dir);
void update_skein_dir(char *dir);
std::string get_last_output_dir(const char *alt = "");
void update_last_output_dir(char *dir);
};

View file

@ -3,22 +3,27 @@
%{
#include <xsinit.h>
#include "slic3r/GUI/Preset.hpp"
#include "slic3r/GUI/PresetBundle.hpp"
#include "slic3r/GUI/PresetHints.hpp"
%}
%name{Slic3r::GUI::Preset} class Preset {
// owned by PresetCollection, no constructor/destructor
bool is_default() %code%{ RETVAL = THIS->is_default; %};
bool is_external() %code%{ RETVAL = THIS->is_external; %};
bool is_visible() %code%{ RETVAL = THIS->is_visible; %};
bool is_dirty() %code%{ RETVAL = THIS->is_dirty; %};
bool default() %code%{ RETVAL = THIS->is_default; %};
bool external() %code%{ RETVAL = THIS->is_external; %};
bool visible() %code%{ RETVAL = THIS->is_visible; %};
bool dirty() %code%{ RETVAL = THIS->is_dirty; %};
bool is_compatible_with_printer(char *active_printer) const;
const char* name() %code%{ RETVAL = THIS->name.c_str(); %};
const char* file() %code%{ RETVAL = THIS->file.c_str(); %};
const char* name() %code%{ RETVAL = THIS->name.c_str(); %};
const char* file() %code%{ RETVAL = THIS->file.c_str(); %};
bool loaded() %code%{ RETVAL = THIS->loaded; %};
bool loaded() %code%{ RETVAL = THIS->loaded; %};
Ref<DynamicPrintConfig> config() %code%{ RETVAL = &THIS->config; %};
Ref<DynamicPrintConfig> config() %code%{ RETVAL = &THIS->config; %};
void set_num_extruders(int num_extruders);
};
%name{Slic3r::GUI::PresetCollection} class PresetCollection {
@ -27,6 +32,50 @@
Ref<Preset> default_preset() %code%{ RETVAL = &THIS->default_preset(); %};
size_t size() const;
size_t num_visible() const;
std::string name() const;
Ref<Preset> get_selected_preset() %code%{ RETVAL = &THIS->get_selected_preset(); %};
Ref<Preset> get_current_preset() %code%{ RETVAL = &THIS->get_edited_preset(); %};
std::string get_current_preset_name() %code%{ RETVAL = THIS->get_selected_preset().name; %};
Ref<Preset> get_edited_preset() %code%{ RETVAL = &THIS->get_edited_preset(); %};
Ref<Preset> find_preset(char *name, bool first_visible_if_not_found = false) %code%{ RETVAL = THIS->find_preset(name, first_visible_if_not_found); %};
bool current_is_dirty();
std::vector<std::string> current_dirty_options();
void update_tab_ui(SV *ui, bool show_incompatible)
%code%{ auto cb = (wxBitmapComboBox*)wxPli_sv_2_object( aTHX_ ui, "Wx::BitmapComboBox" );
THIS->update_tab_ui(cb, show_incompatible); %};
void update_platter_ui(SV *ui)
%code%{ auto cb = (wxBitmapComboBox*)wxPli_sv_2_object( aTHX_ ui, "Wx::BitmapComboBox" );
THIS->update_platter_ui(cb); %};
bool update_dirty_ui(SV *ui)
%code%{ RETVAL = THIS->update_dirty_ui((wxBitmapComboBox*)wxPli_sv_2_object(aTHX_ ui, "Wx::BitmapComboBox")); %};
void select_preset(int idx);
bool select_preset_by_name(char *name) %code%{ RETVAL = THIS->select_preset_by_name(name, true); %};
void discard_current_changes();
void save_current_preset(char *new_name)
%code%{
try {
THIS->save_current_preset(new_name);
} catch (std::exception& e) {
croak("Error saving a preset %s:\n%s\n", new_name, e.what());
}
%};
void delete_current_preset()
%code%{
try {
THIS->delete_current_preset();
} catch (std::exception& e) {
croak("Error deleting a preset file %s:\n%s\n", THIS->get_selected_preset().file.c_str(), e.what());
}
%};
%{
SV*
@ -34,10 +83,9 @@ PresetCollection::arrayref()
CODE:
AV* av = newAV();
av_fill(av, THIS->size()-1);
int i = 0;
for (size_t i = 0; i < THIS->size(); ++ i) {
for (int i = 0; i < int(THIS->size()); ++ i) {
Preset &preset = THIS->preset(i);
av_store(av, i++, perl_to_SV_ref(preset));
av_store(av, i, perl_to_SV_ref(preset));
}
RETVAL = newRV_noinc((SV*)av);
OUTPUT:
@ -46,15 +94,82 @@ PresetCollection::arrayref()
%}
};
%name{Slic3r::GUI::PresetBundle} class PresetBundle {
PresetBundle();
~PresetBundle();
void load_bitmaps(std::string path_bitmap_compatible, std::string path_bitmap_incompatible);
void load_presets(std::string dir_path);
void setup_directories()
%code%{
try {
THIS->setup_directories();
} catch (std::exception& e) {
croak("Cannot create configuration directories:\n%s\n", e.what());
}
%};
void load_presets()
%code%{
try {
THIS->load_presets();
} catch (std::exception& e) {
croak("Loading of Slic3r presets from %s failed.\n\n%s\n",
Slic3r::data_dir().c_str(), e.what());
}
%};
void load_config_file(const char *path)
%code%{
try {
THIS->load_config_file(path);
} catch (std::exception& e) {
croak("Loading a configuration file %s failed:\n%s\n", path, e.what());
}
%};
size_t load_configbundle(const char *path)
%code%{
try {
RETVAL = THIS->load_configbundle(path);
} catch (std::exception& e) {
croak("Loading of a config bundle %s failed:\n%s\n", path, e.what());
}
%};
void export_configbundle(char *path)
%code%{
try {
THIS->export_configbundle(path);
} catch (std::exception& e) {
croak("Export of a config bundle %s failed:\n%s\n", path, e.what());
}
%};
Ref<PresetCollection> prints() %code%{ RETVAL = &THIS->prints; %};
Ref<PresetCollection> filaments() %code%{ RETVAL = &THIS->filaments; %};
Ref<PresetCollection> printers() %code%{ RETVAL = &THIS->printers; %};
void set_default_suppressed(bool default_suppressed);
void load_selections (AppConfig *config) %code%{ THIS->load_selections(*config); %};
void export_selections(AppConfig *config) %code%{ THIS->export_selections(*config); %};
void export_selections_pp(PlaceholderParser *pp) %code%{ THIS->export_selections(*pp); %};
Ref<PresetCollection> print() %code%{ RETVAL = &THIS->prints; %};
Ref<PresetCollection> filament() %code%{ RETVAL = &THIS->filaments; %};
Ref<PresetCollection> printer() %code%{ RETVAL = &THIS->printers; %};
bool has_defauls_only();
std::vector<std::string> filament_presets() %code%{ RETVAL = THIS->filament_presets; %};
void set_filament_preset(int idx, const char *name);
void update_multi_material_filament_presets();
void update_compatible_with_printer(bool select_other_if_incompatible);
Clone<DynamicPrintConfig> full_config() %code%{ RETVAL = THIS->full_config(); %};
void update_platter_filament_ui(int extruder_idx, SV *ui)
%code%{ auto cb = (wxBitmapComboBox*)wxPli_sv_2_object(aTHX_ ui, "Wx::BitmapComboBox");
THIS->update_platter_filament_ui(extruder_idx, cb); %};
};
%name{Slic3r::GUI::PresetHints} class PresetHints {
PresetHints();
~PresetHints();
static std::string cooling_description(Preset *preset)
%code%{ RETVAL = PresetHints::cooling_description(*preset); %};
static std::string maximum_volumetric_flow_description(PresetBundle *preset)
%code%{ RETVAL = PresetHints::maximum_volumetric_flow_description(*preset); %};
};

View file

@ -9,15 +9,16 @@
%name{Slic3r::GCode::PlaceholderParser} class PlaceholderParser {
PlaceholderParser();
~PlaceholderParser();
Clone<PlaceholderParser> clone()
%code{% RETVAL = THIS; %};
void update_timestamp();
void apply_env_variables();
void apply_config(DynamicPrintConfig *config)
%code%{ THIS->apply_config(*config); %};
void set(std::string key, std::string value);
%name{set_multiple} void set(std::string key, std::vector<std::string> values);
void set(std::string key, int value);
std::string process(std::string str) const
%code%{ RETVAL = THIS->process(str, 0); %};
%code%{
try {
RETVAL = THIS->process(str, 0);
} catch (std::exception& e) {
croak(e.what());
}
%};
};

View file

@ -206,8 +206,14 @@ _constant()
double max_allowed_layer_height() const;
bool has_support_material() const;
void auto_assign_extruders(ModelObject* model_object);
std::string output_filename();
std::string output_filepath(std::string path = "");
std::string output_filepath(std::string path = "")
%code%{
try {
RETVAL = THIS->output_filepath(path);
} catch (std::exception& e) {
croak(e.what());
}
%};
void add_model_object(ModelObject* model_object, int idx = -1);
bool apply_config(DynamicPrintConfig* config)
@ -215,8 +221,12 @@ _constant()
bool has_infinite_skirt();
bool has_skirt();
std::vector<unsigned int> extruders() const;
std::string _validate()
%code%{ RETVAL = THIS->validate(); %};
int validate() %code%{
std::string err = THIS->validate();
if (! err.empty())
croak("Configuration is not valid: %s\n", err.c_str());
RETVAL = 1;
%};
Clone<BoundingBox> bounding_box();
Clone<BoundingBox> total_bounding_box();
double skirt_first_layer_height();

View file

@ -60,6 +60,18 @@ var_dir()
RETVAL = const_cast<char*>(Slic3r::var_dir().c_str());
OUTPUT: RETVAL
void
set_resources_dir(dir)
char *dir;
CODE:
Slic3r::set_resources_dir(dir);
char*
resources_dir()
CODE:
RETVAL = const_cast<char*>(Slic3r::resources_dir().c_str());
OUTPUT: RETVAL
std::string
var(file_name)
const char *file_name;
@ -67,6 +79,18 @@ var(file_name)
RETVAL = Slic3r::var(file_name);
OUTPUT: RETVAL
void
set_data_dir(dir)
char *dir;
CODE:
Slic3r::set_data_dir(dir);
char*
data_dir()
CODE:
RETVAL = const_cast<char*>(Slic3r::data_dir().c_str());
OUTPUT: RETVAL
std::string
encode_path(src)
const char *src;

View file

@ -210,12 +210,15 @@ PrintObjectSupportMaterial* O_OBJECT_SLIC3R
Ref<PrintObjectSupportMaterial> O_OBJECT_SLIC3R_T
Clone<PrintObjectSupportMaterial> O_OBJECT_SLIC3R_T
GLShader* O_OBJECT_SLIC3R
Ref<GLShader> O_OBJECT_SLIC3R_T
GLVolume* O_OBJECT_SLIC3R
Ref<GLVolume> O_OBJECT_SLIC3R_T
GLVolumeCollection* O_OBJECT_SLIC3R
Ref<GLVolumeCollection> O_OBJECT_SLIC3R_T
AppConfig* O_OBJECT_SLIC3R
Ref<AppConfig> O_OBJECT_SLIC3R_T
GLShader* O_OBJECT_SLIC3R
Ref<GLShader> O_OBJECT_SLIC3R_T
GLVolume* O_OBJECT_SLIC3R
Ref<GLVolume> O_OBJECT_SLIC3R_T
GLVolumeCollection* O_OBJECT_SLIC3R
Ref<GLVolumeCollection> O_OBJECT_SLIC3R_T
Preset* O_OBJECT_SLIC3R
Ref<Preset> O_OBJECT_SLIC3R_T
@ -223,6 +226,8 @@ PresetCollection* O_OBJECT_SLIC3R
Ref<PresetCollection> O_OBJECT_SLIC3R_T
PresetBundle* O_OBJECT_SLIC3R
Ref<PresetBundle> O_OBJECT_SLIC3R_T
PresetHints* O_OBJECT_SLIC3R
Ref<PresetHints> O_OBJECT_SLIC3R_T
Axis T_UV
ExtrusionLoopRole T_UV

View file

@ -191,6 +191,8 @@
%typemap{ModelInstancePtrs*};
%typemap{Ref<ModelInstancePtrs>}{simple};
%typemap{Clone<ModelInstancePtrs>}{simple};
%typemap{AppConfig*};
%typemap{Ref<AppConfig>}{simple};
%typemap{GLShader*};
%typemap{Ref<GLShader>}{simple};
%typemap{GLVolume*};
@ -203,6 +205,8 @@
%typemap{Ref<PresetCollection>}{simple};
%typemap{PresetBundle*};
%typemap{Ref<PresetBundle>}{simple};
%typemap{PresetHints*};
%typemap{Ref<PresetHints>}{simple};
%typemap{PrintRegionPtrs*};
%typemap{PrintObjectPtrs*};