Welcome to mirror list, hosted at ThFree Co, Russian Federation.

GUI_Preset.xsp « xsp « xs - github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 99d23a14218dcd7a6c911756ef79952fc87be9dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
%module{Slic3r::XS};

%{
#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                        default()       %code%{ RETVAL = THIS->is_default;  %};
    bool                        external()      %code%{ RETVAL = THIS->is_external; %};
    bool                        system()        %code%{ RETVAL = THIS->is_system;   %};
    bool                        visible()       %code%{ RETVAL = THIS->is_visible;  %};
    bool                        dirty()         %code%{ RETVAL = THIS->is_dirty;    %};
    bool                        compatible()    %code%{ RETVAL = THIS->is_compatible; %};
    bool                        is_compatible_with_printer(Preset *active_printer)
        %code%{ RETVAL = THIS->is_compatible_with_printer(*active_printer); %};

    std::string                 name()          %code%{ RETVAL = THIS->name; %};
    std::string                 file()          %code%{ RETVAL = THIS->file; %};

    bool                        loaded()        %code%{ RETVAL = THIS->loaded;      %};

    Ref<DynamicPrintConfig>     config()        %code%{ RETVAL = &THIS->config;     %};

    void                        set_num_extruders(int num_extruders);
};

%name{Slic3r::GUI::PresetCollection} class PresetCollection {

    Ref<Preset>             preset(size_t idx) %code%{ RETVAL = &THIS->preset(idx); %};
    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); %};

    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); %};

%{

SV*
PresetCollection::arrayref()
    CODE:
        AV* av = newAV();
        av_fill(av, THIS->size()-1);
        for (int i = 0; i < int(THIS->size()); ++ i) {
            Preset &preset = THIS->preset(i);
            av_store(av, i, perl_to_SV_ref(preset));
        }
        RETVAL = newRV_noinc((SV*)av);
    OUTPUT:
        RETVAL

%}
};

%name{Slic3r::GUI::PresetBundle} class PresetBundle {
    PresetBundle();
    ~PresetBundle();

    void                        reset(bool delete_files);

    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(AppConfig *config)
        %code%{
            try {
                THIS->load_presets(*config);
            } 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(const char *name, DynamicPrintConfig *config)
        %code%{
            try {
                THIS->load_config(name, *config);
            } catch (std::exception& e) {
                croak("Loading a configuration %s failed:\n%s\n", name, 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, PresetBundle::LOAD_CFGBNDLE_SAVE);
            } 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());
            }
        %};

    void                        set_default_suppressed(bool default_suppressed);

    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>       sla_material() %code%{ RETVAL = &THIS->sla_materials; %};
    Ref<PresetCollection>       printer()  %code%{ RETVAL = &THIS->printers;  %};
    Ref<DynamicPrintConfig>     project_config() %code%{ RETVAL = &THIS->project_config; %};

    bool                        has_defauls_only();

    std::vector<std::string>    filament_presets() %code%{ RETVAL = THIS->filament_presets; %};
    void                        set_filament_preset(int idx, const char *name);

    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); %};
};