2015-01-17 23:36:21 +00:00
|
|
|
%module{Slic3r::XS};
|
|
|
|
|
2015-12-07 23:39:54 +00:00
|
|
|
#include <xsinit.h>
|
2017-03-20 11:05:20 +00:00
|
|
|
#include "slic3r/GUI/GLShader.hpp"
|
2015-12-06 11:54:01 +00:00
|
|
|
#include "slic3r/GUI/3DScene.hpp"
|
2015-01-17 23:36:21 +00:00
|
|
|
|
2017-03-20 11:05:20 +00:00
|
|
|
%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;
|
|
|
|
|
2018-03-09 13:33:44 +00:00
|
|
|
int shader_program_id() const
|
|
|
|
%code%{ RETVAL = THIS->shader_program_id; %};
|
|
|
|
|
2017-03-20 11:05:20 +00:00
|
|
|
std::string last_error() const
|
|
|
|
%code%{ RETVAL = THIS->last_error; %};
|
|
|
|
};
|
|
|
|
|
2017-03-13 15:02:17 +00:00
|
|
|
%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]); %};
|
2017-05-17 14:53:40 +00:00
|
|
|
|
2017-03-13 15:02:17 +00:00
|
|
|
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; %};
|
2018-02-19 10:28:56 +00:00
|
|
|
int zoom_to_volumes()
|
|
|
|
%code%{ RETVAL = THIS->zoom_to_volumes; %};
|
2017-03-13 15:02:17 +00:00
|
|
|
|
2018-03-09 13:33:44 +00:00
|
|
|
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();
|
|
|
|
|
2017-03-13 15:02:17 +00:00
|
|
|
int object_idx() const;
|
|
|
|
int volume_idx() const;
|
|
|
|
int instance_idx() const;
|
|
|
|
Clone<Pointf3> origin() const
|
|
|
|
%code%{ RETVAL = THIS->origin; %};
|
2017-03-14 09:11:08 +00:00
|
|
|
void translate(double x, double y, double z)
|
|
|
|
%code%{ THIS->origin.translate(x, y, z); %};
|
2017-03-13 15:02:17 +00:00
|
|
|
Clone<BoundingBoxf3> bounding_box() const
|
|
|
|
%code%{ RETVAL = THIS->bounding_box; %};
|
|
|
|
Clone<BoundingBoxf3> transformed_bounding_box() const;
|
|
|
|
|
2017-03-15 15:33:25 +00:00
|
|
|
bool empty() const;
|
|
|
|
bool indexed() const;
|
|
|
|
|
2017-03-16 13:02:28 +00:00
|
|
|
void render() const;
|
2017-03-13 15:02:17 +00:00
|
|
|
|
|
|
|
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();
|
|
|
|
|
2017-03-20 11:05:20 +00:00
|
|
|
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);
|
2017-03-13 15:02:17 +00:00
|
|
|
|
2017-11-30 13:43:47 +00:00
|
|
|
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);
|
2017-05-17 14:53:40 +00:00
|
|
|
|
2017-03-13 15:02:17 +00:00
|
|
|
void erase()
|
|
|
|
%code{% THIS->clear(); %};
|
|
|
|
|
|
|
|
int count()
|
|
|
|
%code{% RETVAL = THIS->volumes.size(); %};
|
2018-02-22 07:59:47 +00:00
|
|
|
|
|
|
|
std::vector<double> get_current_print_zs()
|
|
|
|
%code{% RETVAL = THIS->get_current_print_zs(); %};
|
2017-03-16 13:02:28 +00:00
|
|
|
|
2018-02-22 07:59:47 +00:00
|
|
|
|
2017-03-13 15:02:17 +00:00
|
|
|
void set_range(double low, double high);
|
2017-03-16 13:02:28 +00:00
|
|
|
|
2017-03-20 11:05:20 +00:00
|
|
|
void render_VBOs() const;
|
|
|
|
void render_legacy() const;
|
2017-03-30 08:25:52 +00:00
|
|
|
void finalize_geometry(bool use_VBOs);
|
2017-03-20 11:05:20 +00:00
|
|
|
void release_geometry();
|
2017-06-21 12:10:22 +00:00
|
|
|
|
2018-03-09 09:40:42 +00:00
|
|
|
void set_print_box(float min_x, float min_y, float min_z, float max_x, float max_y, float max_z);
|
|
|
|
void update_outside_state(DynamicPrintConfig* config, bool all_inside);
|
2018-04-05 10:52:29 +00:00
|
|
|
void update_colors_by_extruder(DynamicPrintConfig* config);
|
2018-03-09 09:40:42 +00:00
|
|
|
|
2017-06-21 12:10:22 +00:00
|
|
|
bool move_volume_up(int idx)
|
|
|
|
%code%{
|
|
|
|
if (idx > 0 && idx < int(THIS->volumes.size())) {
|
|
|
|
std::swap(THIS->volumes[idx-1], THIS->volumes[idx]);
|
2017-06-26 14:44:16 +00:00
|
|
|
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);
|
2017-06-21 12:10:22 +00:00
|
|
|
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]);
|
2017-06-26 14:44:16 +00:00
|
|
|
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);
|
2017-06-21 12:10:22 +00:00
|
|
|
RETVAL = true;
|
|
|
|
} else
|
|
|
|
RETVAL = false;
|
|
|
|
%};
|
|
|
|
|
2017-03-13 15:02:17 +00:00
|
|
|
%{
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
%}
|
2015-01-24 22:35:29 +00:00
|
|
|
};
|
|
|
|
|
2015-01-17 23:36:21 +00:00
|
|
|
%package{Slic3r::GUI::_3DScene};
|
|
|
|
%{
|
|
|
|
|
2017-03-16 13:02:28 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
_glew_init()
|
|
|
|
CODE:
|
|
|
|
_3DScene::_glew_init();
|
|
|
|
|
2018-02-15 13:37:53 +00:00
|
|
|
unsigned int
|
|
|
|
finalize_legend_texture()
|
|
|
|
CODE:
|
|
|
|
RETVAL = _3DScene::finalize_legend_texture();
|
|
|
|
OUTPUT:
|
|
|
|
RETVAL
|
|
|
|
|
2018-01-16 13:59:06 +00:00
|
|
|
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
|
2018-02-06 11:43:25 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
reset_legend_texture()
|
|
|
|
CODE:
|
|
|
|
_3DScene::reset_legend_texture();
|
2018-03-09 09:40:42 +00:00
|
|
|
|
|
|
|
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();
|
|
|
|
|
2015-01-17 23:36:21 +00:00
|
|
|
void
|
2017-05-24 13:20:20 +00:00
|
|
|
_load_print_toolpaths(print, volumes, tool_colors, use_VBOs)
|
2017-03-13 15:02:17 +00:00
|
|
|
Print *print;
|
|
|
|
GLVolumeCollection *volumes;
|
2017-05-24 13:20:20 +00:00
|
|
|
std::vector<std::string> tool_colors;
|
2017-03-20 11:05:20 +00:00
|
|
|
int use_VBOs;
|
2017-03-13 15:02:17 +00:00
|
|
|
CODE:
|
2017-05-24 13:20:20 +00:00
|
|
|
_3DScene::_load_print_toolpaths(print, volumes, tool_colors, use_VBOs != 0);
|
2017-03-13 15:02:17 +00:00
|
|
|
|
|
|
|
void
|
2017-05-24 13:20:20 +00:00
|
|
|
_load_print_object_toolpaths(print_object, volumes, tool_colors, use_VBOs)
|
2017-03-13 15:02:17 +00:00
|
|
|
PrintObject *print_object;
|
|
|
|
GLVolumeCollection *volumes;
|
2017-05-24 13:20:20 +00:00
|
|
|
std::vector<std::string> tool_colors;
|
2017-03-20 11:05:20 +00:00
|
|
|
int use_VBOs;
|
2015-01-17 23:36:21 +00:00
|
|
|
CODE:
|
2017-05-24 13:20:20 +00:00
|
|
|
_3DScene::_load_print_object_toolpaths(print_object, volumes, tool_colors, use_VBOs != 0);
|
2015-01-17 23:36:21 +00:00
|
|
|
|
2017-05-25 20:27:53 +00:00
|
|
|
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);
|
|
|
|
|
2018-01-08 12:44:10 +00:00
|
|
|
void
|
2018-02-14 19:35:59 +00:00
|
|
|
load_gcode_preview(print, preview_data, volumes, str_tool_colors, use_VBOs)
|
2018-02-07 08:07:37 +00:00
|
|
|
Print *print;
|
2018-02-14 19:35:59 +00:00
|
|
|
GCodePreviewData *preview_data;
|
2018-02-07 08:07:37 +00:00
|
|
|
GLVolumeCollection *volumes;
|
|
|
|
std::vector<std::string> str_tool_colors;
|
|
|
|
int use_VBOs;
|
2018-01-08 12:44:10 +00:00
|
|
|
CODE:
|
2018-02-14 19:35:59 +00:00
|
|
|
_3DScene::load_gcode_preview(print, preview_data, volumes, str_tool_colors, use_VBOs != 0);
|
2018-01-08 12:44:10 +00:00
|
|
|
|
2017-03-13 15:02:17 +00:00
|
|
|
%}
|