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

GUI_3DScene.xsp « xsp « xs - github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6a907291e24357a401770ccd6192afa4ee69c549 (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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
%module{Slic3r::XS};

#include <xsinit.h>
#include "slic3r/GUI/GLShader.hpp"
#include "slic3r/GUI/3DScene.hpp"

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

    bool load(const char *fragment_shader, const char *vertex_shader);
    void release();

    int  get_attrib_location(const char *name) const;
    int  get_uniform_location(const char *name) const;

    bool set_uniform(const char *name, float value) const;

    void enable() const;
    void disable() const;

    int shader_program_id() const
        %code%{ RETVAL = THIS->shader_program_id; %};

    std::string last_error() const
        %code%{ RETVAL = THIS->last_error; %};
};

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

    std::vector<double> color()
        %code%{ RETVAL.reserve(4); RETVAL.push_back(THIS->color[0]); RETVAL.push_back(THIS->color[1]); RETVAL.push_back(THIS->color[2]); RETVAL.push_back(THIS->color[3]); %};

    int                 select_group_id()
        %code%{ RETVAL = THIS->select_group_id; %};
    int                 drag_group_id()
        %code%{ RETVAL = THIS->drag_group_id; %};
    int                 selected()
        %code%{ RETVAL = THIS->selected; %};
    void                set_selected(int i)
        %code%{ THIS->selected = i; %};
    int                 hover()
        %code%{ RETVAL = THIS->hover; %};
    void                set_hover(int i)
        %code%{ THIS->hover = i; %};
    int                 zoom_to_volumes()
        %code%{ RETVAL = THIS->zoom_to_volumes; %};

    void set_layer_height_texture_data(unsigned int texture_id, unsigned int shader_id, PrintObject* print_object, float z_cursor_relative, float edit_band_width);
    void reset_layer_height_texture_data();

    int                 object_idx() const;
    int                 volume_idx() const;
    int                 instance_idx() const;
    Clone<Pointf3>      origin() const
        %code%{ RETVAL = THIS->origin; %};
    void                translate(double x, double y, double z)
        %code%{ THIS->origin.translate(x, y, z); %};
    Clone<BoundingBoxf3> bounding_box() const
        %code%{ RETVAL = THIS->bounding_box; %};
    Clone<BoundingBoxf3> transformed_bounding_box() const;

    bool                empty() const;
    bool                indexed() const;

    void                render() const;

    bool                has_layer_height_texture();
    int                 layer_height_texture_width();
    int                 layer_height_texture_height();
    int                 layer_height_texture_cells();
    void*               layer_height_texture_data_ptr_level0();
    void*               layer_height_texture_data_ptr_level1();
    double              layer_height_texture_z_to_row_id() const; 
    void                generate_layer_height_texture(PrintObject *print_object, bool force);
};


%name{Slic3r::GUI::_3DScene::GLVolume::Collection} class GLVolumeCollection {
    GLVolumeCollection();
    ~GLVolumeCollection();

    std::vector<int> load_object(ModelObject *object, int obj_idx, std::vector<int> instance_idxs, std::string color_by, std::string select_by, std::string drag_by, bool use_VBOs);

    int load_wipe_tower_preview(int obj_idx, float pos_x, float pos_y, float width, float depth, float height, float rotation_angle, bool use_VBOs);

    void erase()
        %code{% THIS->clear(); %};

    int count()
        %code{% RETVAL = THIS->volumes.size(); %};
        
    std::vector<double> get_current_print_zs(bool active_only)
        %code{% RETVAL = THIS->get_current_print_zs(active_only); %};

    void set_range(double low, double high);

    void render_VBOs() const;
    void render_legacy() const;
    void finalize_geometry(bool use_VBOs);
    void release_geometry();

    void set_print_box(float min_x, float min_y, float min_z, float max_x, float max_y, float max_z);
    bool check_outside_state(DynamicPrintConfig* config)
        %code%{ 
                RETVAL = THIS->check_outside_state(config);
        %};
    
    void reset_outside_state();    
    void update_colors_by_extruder(DynamicPrintConfig* config);

    bool move_volume_up(int idx)
        %code%{ 
            if (idx > 0 && idx < int(THIS->volumes.size())) {
                std::swap(THIS->volumes[idx-1], THIS->volumes[idx]);
                std::swap(THIS->volumes[idx-1]->composite_id,    THIS->volumes[idx]->composite_id);
                std::swap(THIS->volumes[idx-1]->select_group_id, THIS->volumes[idx]->select_group_id);
                std::swap(THIS->volumes[idx-1]->drag_group_id,   THIS->volumes[idx]->drag_group_id);
                RETVAL = true;
            } else
                RETVAL = false;
        %};
    bool move_volume_down(int idx)
        %code%{ 
            if (idx >= 0 && idx + 1 < int(THIS->volumes.size())) {
                std::swap(THIS->volumes[idx+1], THIS->volumes[idx]);
                std::swap(THIS->volumes[idx+1]->composite_id,    THIS->volumes[idx]->composite_id);
                std::swap(THIS->volumes[idx+1]->select_group_id, THIS->volumes[idx]->select_group_id);
                std::swap(THIS->volumes[idx+1]->drag_group_id,   THIS->volumes[idx]->drag_group_id);
                RETVAL = true;
            } else
                RETVAL = false;
        %};

%{

SV*
GLVolumeCollection::arrayref()
    CODE:
        AV* av = newAV();
        av_fill(av, THIS->volumes.size()-1);
        int i = 0;
        for (GLVolume *v : THIS->volumes) {
            av_store(av, i++, perl_to_SV_ref(*v));
        }
        RETVAL = newRV_noinc((SV*)av);
    OUTPUT:
        RETVAL

%}
};

%package{Slic3r::GUI::_3DScene};
%{


void
_glew_init()
    CODE:
        _3DScene::_glew_init();

unsigned int
finalize_legend_texture()
    CODE:
        RETVAL = _3DScene::finalize_legend_texture();
    OUTPUT:
        RETVAL

unsigned int
get_legend_texture_width()
    CODE:
        RETVAL = _3DScene::get_legend_texture_width();
    OUTPUT:
        RETVAL

unsigned int
get_legend_texture_height()
    CODE:
        RETVAL = _3DScene::get_legend_texture_height();
    OUTPUT:
        RETVAL
             
void
reset_legend_texture()
    CODE:
        _3DScene::reset_legend_texture();

void
generate_warning_texture(std::string msg)
    CODE:
        _3DScene::generate_warning_texture(msg);

unsigned int
finalize_warning_texture()
    CODE:
        RETVAL = _3DScene::finalize_warning_texture();
    OUTPUT:
        RETVAL

unsigned int
get_warning_texture_width()
    CODE:
        RETVAL = _3DScene::get_warning_texture_width();
    OUTPUT:
        RETVAL

unsigned int
get_warning_texture_height()
    CODE:
        RETVAL = _3DScene::get_warning_texture_height();
    OUTPUT:
        RETVAL

void
reset_warning_texture()
    CODE:
        _3DScene::reset_warning_texture();

void
_load_print_toolpaths(print, volumes, tool_colors, use_VBOs)
        Print               *print;
        GLVolumeCollection  *volumes;
        std::vector<std::string> tool_colors;
        int                  use_VBOs;
    CODE:
        _3DScene::_load_print_toolpaths(print, volumes, tool_colors, use_VBOs != 0);

void 
_load_print_object_toolpaths(print_object, volumes, tool_colors, use_VBOs)
        PrintObject        *print_object;
        GLVolumeCollection *volumes;
        std::vector<std::string> tool_colors;
        int                 use_VBOs;
    CODE:
        _3DScene::_load_print_object_toolpaths(print_object, volumes, tool_colors, use_VBOs != 0);

void
_load_wipe_tower_toolpaths(print, volumes, tool_colors, use_VBOs)
        Print               *print;
        GLVolumeCollection  *volumes;
        std::vector<std::string> tool_colors;
        int                  use_VBOs;
    CODE:
        _3DScene::_load_wipe_tower_toolpaths(print, volumes, tool_colors, use_VBOs != 0);

void 
load_gcode_preview(print, preview_data, volumes, str_tool_colors, use_VBOs)
        Print                    *print;
        GCodePreviewData         *preview_data;
        GLVolumeCollection       *volumes;
        std::vector<std::string> str_tool_colors;
        int                      use_VBOs;
    CODE:
        _3DScene::load_gcode_preview(print, preview_data, volumes, str_tool_colors, use_VBOs != 0);
        
%}